aboutsummaryrefslogtreecommitdiff
path: root/tests/gcfpeek.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gcfpeek.c')
-rw-r--r--tests/gcfpeek.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/tests/gcfpeek.c b/tests/gcfpeek.c
index 3dbd12b..fcd621b 100644
--- a/tests/gcfpeek.c
+++ b/tests/gcfpeek.c
@@ -1,4 +1,4 @@
1/* grecs - Gray's Extensible Configuration System 1/* argot - Gray's Extensible Configuration System
2 Copyright (C) 2007-2016 Sergey Poznyakoff 2 Copyright (C) 2007-2016 Sergey Poznyakoff
3 3
4 Grecs is free software; you can redistribute it and/or modify it 4 Grecs is free software; you can redistribute it and/or modify it
@@ -20,7 +20,7 @@
20#include <string.h> 20#include <string.h>
21#include <errno.h> 21#include <errno.h>
22#include <stdlib.h> 22#include <stdlib.h>
23#include "grecs.h" 23#include "argot.h"
24 24
25static void 25static void
26usage(const char *arg, FILE *fp, int code) 26usage(const char *arg, FILE *fp, int code)
@@ -34,9 +34,9 @@ usage(const char *arg, FILE *fp, int code)
34int 34int
35set_parser(const char *arg) 35set_parser(const char *arg)
36{ 36{
37 grecs_parser_t p = grecs_get_parser_by_type(arg); 37 argot_parser_t p = argot_get_parser_by_type(arg);
38 if (p) { 38 if (p) {
39 grecs_parser_fun = p; 39 argot_parser_fun = p;
40 return 0; 40 return 0;
41 } 41 }
42 return 1; 42 return 1;
@@ -48,8 +48,8 @@ main(int argc, char **argv)
48 char *progname = argv[0]; 48 char *progname = argv[0];
49 char *path = NULL; 49 char *path = NULL;
50 char *file = NULL; 50 char *file = NULL;
51 struct grecs_node *tree, *root, *node; 51 struct argot_node *tree, *root, *node;
52 int flags = GRECS_NODE_FLAG_DEFAULT; 52 int flags = ARGOT_NODE_FLAG_DEFAULT;
53 int rc = 2; 53 int rc = 2;
54 int reduce = 0; 54 int reduce = 0;
55 int match = 0; 55 int match = 0;
@@ -58,7 +58,7 @@ main(int argc, char **argv)
58 while (--argc) { 58 while (--argc) {
59 char *arg = *++argv; 59 char *arg = *++argv;
60 if (strcmp(arg, "-locus") == 0) 60 if (strcmp(arg, "-locus") == 0)
61 flags |= GRECS_NODE_FLAG_LOCUS; 61 flags |= ARGOT_NODE_FLAG_LOCUS;
62 else if (strncmp(arg, "-delim=", 7) == 0) 62 else if (strncmp(arg, "-delim=", 7) == 0)
63 flags |= arg[7]; 63 flags |= arg[7];
64 else if (strcmp(arg, "-reduce") == 0) 64 else if (strcmp(arg, "-reduce") == 0)
@@ -66,18 +66,18 @@ main(int argc, char **argv)
66 else if (strcmp(arg, "-match") == 0) 66 else if (strcmp(arg, "-match") == 0)
67 match = 1; 67 match = 1;
68 else if (strcmp(arg, "-nodesc") == 0) 68 else if (strcmp(arg, "-nodesc") == 0)
69 flags &= ~GRECS_NODE_FLAG_DESCEND; 69 flags &= ~ARGOT_NODE_FLAG_DESCEND;
70 else if (strcmp(arg, "-nopath") == 0) 70 else if (strcmp(arg, "-nopath") == 0)
71 flags &= ~GRECS_NODE_FLAG_PATH; 71 flags &= ~ARGOT_NODE_FLAG_PATH;
72 else if (strncmp(arg, "-type=", 6) == 0) { 72 else if (strncmp(arg, "-type=", 6) == 0) {
73 if (set_parser(arg + 6)) 73 if (set_parser(arg + 6))
74 usage(progname, stderr, 1); 74 usage(progname, stderr, 1);
75 } else if (strncmp(arg, "-root=", 6) == 0) 75 } else if (strncmp(arg, "-root=", 6) == 0)
76 root_path = arg + 6; 76 root_path = arg + 6;
77 else if (strcmp(arg, "-strcat") == 0) 77 else if (strcmp(arg, "-strcat") == 0)
78 grecs_parser_options |= GRECS_OPTION_QUOTED_STRING_CONCAT; 78 argot_parser_options |= ARGOT_OPTION_QUOTED_STRING_CONCAT;
79 else if (strcmp(arg, "-stradj") == 0) 79 else if (strcmp(arg, "-stradj") == 0)
80 grecs_parser_options |= GRECS_OPTION_ADJUST_STRING_LOCATIONS; 80 argot_parser_options |= ARGOT_OPTION_ADJUST_STRING_LOCATIONS;
81 else if (strcmp(arg, "-h") == 0) 81 else if (strcmp(arg, "-h") == 0)
82 usage(progname, stdout, 0); 82 usage(progname, stdout, 0);
83 else if (arg[0] == '-') 83 else if (arg[0] == '-')
@@ -94,14 +94,14 @@ main(int argc, char **argv)
94 if (!file || !path || argc) 94 if (!file || !path || argc)
95 usage(progname, stderr, 1); 95 usage(progname, stderr, 1);
96 96
97 tree = grecs_parse(file); 97 tree = argot_parse(file);
98 if (!tree) 98 if (!tree)
99 exit(1); 99 exit(1);
100 if (reduce) 100 if (reduce)
101 grecs_tree_reduce(tree, NULL, 0); 101 argot_tree_reduce(tree, NULL, 0);
102 102
103 if (root_path) { 103 if (root_path) {
104 root = grecs_find_node(tree, root_path); 104 root = argot_find_node(tree, root_path);
105 if (!root) { 105 if (!root) {
106 fprintf(stderr, "%s: node %s not found\n", 106 fprintf(stderr, "%s: node %s not found\n",
107 progname, root_path); 107 progname, root_path);
@@ -111,26 +111,26 @@ main(int argc, char **argv)
111 root = tree; 111 root = tree;
112 112
113 if (match) { 113 if (match) {
114 grecs_match_buf_t match_buf; 114 argot_match_buf_t match_buf;
115 115
116 for (node = grecs_match_first(root, path, &match_buf); 116 for (node = argot_match_first(root, path, &match_buf);
117 node; 117 node;
118 node = grecs_match_next(match_buf)) { 118 node = argot_match_next(match_buf)) {
119 rc = 0; 119 rc = 0;
120 grecs_print_node(node, flags, stdout); 120 argot_print_node(node, flags, stdout);
121 fputc('\n', stdout); 121 fputc('\n', stdout);
122 } 122 }
123 grecs_match_buf_free(match_buf); 123 argot_match_buf_free(match_buf);
124 } else { 124 } else {
125 for (node = root; node; node = node->next) { 125 for (node = root; node; node = node->next) {
126 node = grecs_find_node(node, path); 126 node = argot_find_node(node, path);
127 if (!node) 127 if (!node)
128 break; 128 break;
129 rc = 0; 129 rc = 0;
130 grecs_print_node(node, flags, stdout); 130 argot_print_node(node, flags, stdout);
131 fputc('\n', stdout); 131 fputc('\n', stdout);
132 } 132 }
133 } 133 }
134 grecs_tree_free(tree); 134 argot_tree_free(tree);
135 exit(rc); 135 exit(rc);
136} 136}

Return to:

Send suggestions and report system problems to the System administrator.