@@ -48,46 +48,42 @@ ARGUS_OPTIONS(
4848
4949void print_array_strings(argus_t argus, const char * name)
5050{
51- if (!argus_is_set(argus, name)) return;
51+ if (!argus_is_set(& argus, name)) return;
5252
5353 printf("%s:\n", name);
54- argus_array_it_t it = argus_array_it(argus, name);
55- while (argus_array_next(&it)) {
54+ argus_array_it_t it = argus_array_it(& argus, name);
55+ while (argus_array_next(&it))
5656 printf(" - %s\n", it.value.as_string);
57- }
5857}
5958
6059void print_array_ints(argus_t argus, const char * name)
6160{
62- if (!argus_is_set(argus, name)) return;
61+ if (!argus_is_set(& argus, name)) return;
6362
6463 printf("%s:\n", name);
65- argus_array_it_t it = argus_array_it(argus, name);
66- while (argus_array_next(&it)) {
64+ argus_array_it_t it = argus_array_it(& argus, name);
65+ while (argus_array_next(&it))
6766 printf(" - %d\n", it.value.as_int);
68- }
6967}
7068
7169void print_map_strings(argus_t argus, const char * name)
7270{
73- if (!argus_is_set(argus, name)) return;
71+ if (!argus_is_set(& argus, name)) return;
7472
7573 printf("%s:\n", name);
76- argus_map_it_t it = argus_map_it(argus, name);
77- while (argus_map_next(&it)) {
74+ argus_map_it_t it = argus_map_it(& argus, name);
75+ while (argus_map_next(&it))
7876 printf(" %s = %s\n", it.key, it.value.as_string);
79- }
8077}
8178
8279void print_map_bools(argus_t argus, const char * name)
8380{
84- if (!argus_is_set(argus, name)) return;
81+ if (!argus_is_set(& argus, name)) return;
8582
8683 printf("%s:\n", name);
87- argus_map_it_t it = argus_map_it(argus, name);
88- while (argus_map_next(&it)) {
84+ argus_map_it_t it = argus_map_it(& argus, name);
85+ while (argus_map_next(&it))
8986 printf(" %s = %s\n", it.key, it.value.as_bool ? "true" : "false");
90- }
9187}
9288
9389int main(int argc, char ** argv)
@@ -100,17 +96,16 @@ int main(int argc, char **argv)
10096 return 1;
10197
10298 // Basic values
103- const char * name = argus_get(argus, "name").as_string;
104- const char * host = argus_get(argus, "host").as_string;
105- int port = argus_get(argus, "port").as_int;
99+ const char * name = argus_get(& argus, "name").as_string;
100+ const char * host = argus_get(& argus, "host").as_string;
101+ int port = argus_get(& argus, "port").as_int;
106102
107103 printf("=== Service Configuration ===\n");
108104 printf("Name: %s\n", name);
109105 printf("Host: %s:%d\n", host, port);
110106
111- if (argus_is_set(argus, "contact")) {
112- printf("Contact: %s\n", argus_get(argus, "contact").as_string);
113- }
107+ if (argus_is_set(&argus, "contact"))
108+ printf("Contact: %s\n", argus_get(&argus, "contact").as_string);
114109 printf("\n");
115110
116111 // Collections
@@ -121,8 +116,8 @@ int main(int argc, char **argv)
121116
122117 // Generate config file
123118 const char * output = "config.json";
124- if (argus_is_set(argus, "output")) {
125- output = argus_get(argus, "output").as_string;
119+ if (argus_is_set(& argus, "output")) {
120+ output = argus_get(& argus, "output").as_string;
126121 }
127122
128123 FILE * config = fopen(output, "w");
@@ -136,14 +131,14 @@ int main(int argc, char **argv)
136131 fprintf(config, " \" host\" : \" %s\" ,\n", host);
137132 fprintf(config, " \" port\" : %d", port);
138133
139- if (argus_is_set(argus, "contact")) {
140- fprintf(config, ",\n \" contact\" : \" %s\" ", argus_get(argus, "contact").as_string);
134+ if (argus_is_set(& argus, "contact")) {
135+ fprintf(config, ",\n \" contact\" : \" %s\" ", argus_get(& argus, "contact").as_string);
141136 }
142137
143138 // Add arrays
144- if (argus_is_set(argus, "tags")) {
139+ if (argus_is_set(& argus, "tags")) {
145140 fprintf(config, ",\n \" tags\" : [ ");
146- argus_array_it_t it = argus_array_it(argus, "tags");
141+ argus_array_it_t it = argus_array_it(& argus, "tags");
147142 bool first = true;
148143 while (argus_array_next(&it)) {
149144 if (!first) fprintf(config, ", ");
@@ -153,9 +148,9 @@ int main(int argc, char **argv)
153148 fprintf(config, "] ");
154149 }
155150
156- if (argus_is_set(argus, "ports")) {
151+ if (argus_is_set(& argus, "ports")) {
157152 fprintf(config, ",\n \" ports\" : [ ");
158- argus_array_it_t it = argus_array_it(argus, "ports");
153+ argus_array_it_t it = argus_array_it(& argus, "ports");
159154 bool first = true;
160155 while (argus_array_next(&it)) {
161156 if (!first) fprintf(config, ", ");
@@ -166,9 +161,9 @@ int main(int argc, char **argv)
166161 }
167162
168163 // Add maps
169- if (argus_is_set(argus, "env")) {
164+ if (argus_is_set(& argus, "env")) {
170165 fprintf(config, ",\n \" environment\" : {");
171- argus_map_it_t it = argus_map_it(argus, "env");
166+ argus_map_it_t it = argus_map_it(& argus, "env");
172167 bool first = true;
173168 while (argus_map_next(&it)) {
174169 if (!first) fprintf(config, ", ");
@@ -179,9 +174,9 @@ int main(int argc, char **argv)
179174 fprintf(config, "}");
180175 }
181176
182- if (argus_is_set(argus, "features")) {
177+ if (argus_is_set(& argus, "features")) {
183178 fprintf(config, ",\n \" features\" : {");
184- argus_map_it_t it = argus_map_it(argus, "features");
179+ argus_map_it_t it = argus_map_it(& argus, "features");
185180 bool first = true;
186181 while (argus_map_next(&it)) {
187182 if (!first) fprintf(config, ", ");
0 commit comments