File: | src/tls_test-gaa.c |
Location: | line 485, column 2 |
Description: | Value stored to 'OK' is never read |
1 | /* File generated by GAA 1.6.6 |
2 | */ |
3 | #define GAA_NO_WIN32 |
4 | #line 1 "tls_test.gaa" |
5 | |
6 | |
7 | /* C declarations */ |
8 | |
9 | #include <config.h> |
10 | #ifdef _WIN32 |
11 | # include <io.h> |
12 | #endif |
13 | |
14 | void tls_test_version(void); |
15 | |
16 | #include <stdio.h> |
17 | #include <string.h> |
18 | #include <stdlib.h> |
19 | |
20 | #ifndef GAA_NO_WIN32 |
21 | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS) |
22 | #define GAA_WIN32 |
23 | #endif |
24 | #endif |
25 | |
26 | static void* gaa_malloc( size_t size) { |
27 | void* ret; |
28 | ret = malloc(size); |
29 | if (ret==NULL((void*)0)) { |
30 | fprintf(stderrstderr, "gaa: could not allocate memory"); |
31 | exit(1); |
32 | } |
33 | return ret; |
34 | } |
35 | |
36 | static void __gaa_helpsingle(char short_name, char *name, |
37 | char *arg_desc, char *opt_help) |
38 | { |
39 | int col1, col3, col4, tabsize = 3, curr; |
40 | int i; |
41 | |
42 | col1 = 5; /* Default values */ |
43 | col3 = 30; |
44 | col4 = 70; |
45 | |
46 | curr = 0; |
47 | for(i = 0; i < col1; i++) |
48 | { |
49 | printf(" "); |
50 | curr++; |
51 | } |
52 | if(short_name) |
53 | { |
54 | if(name && *name) |
55 | { |
56 | printf("-%c, ", short_name); |
57 | curr += 4; |
58 | } |
59 | else |
60 | { |
61 | printf("-%c ", short_name); |
62 | curr += 3; |
63 | } |
64 | } |
65 | if(name && *name) |
66 | { |
67 | printf("--%s ", name); |
68 | curr += 3 + strlen(name); |
69 | } |
70 | if(arg_desc && *arg_desc) |
71 | { |
72 | printf("%s ", arg_desc); |
73 | curr += 1 + strlen(arg_desc); |
74 | } |
75 | if(curr >= col3) |
76 | { |
77 | printf("\n"); |
78 | curr = 0; |
79 | } |
80 | if(opt_help) /* let's print the option's help body */ |
81 | { |
82 | const char *str = opt_help; |
83 | while(*str) |
84 | { |
85 | while(curr < col3) |
86 | { |
87 | printf(" "); |
88 | curr++; |
89 | } |
90 | switch(*str) |
91 | { |
92 | case '\n': |
93 | printf("\n"); |
94 | curr = 0; |
95 | break; |
96 | case '\t': |
97 | do |
98 | { |
99 | printf(" "); |
100 | curr++; |
101 | } |
102 | while((curr - col3) % tabsize != 0 && curr < col4); |
103 | case ' ': |
104 | if(*str == ' ') |
105 | { |
106 | curr++; |
107 | printf(" "); |
108 | } |
109 | for(i = 1; str[i] && str[i] != ' ' && str[i] != '\n' |
110 | && str[i] != '\t'; i++); |
111 | if(curr + i - 1 >= col4) |
112 | curr = col4; |
113 | break; |
114 | default: |
115 | printf("%c", *str); |
116 | curr++; |
117 | } |
118 | if(curr >= col4) |
119 | { |
120 | printf("\n"); |
121 | curr = 0; |
122 | } |
123 | str++; |
124 | } |
125 | } |
126 | printf("\n"); |
127 | } |
128 | |
129 | void gaa_help(void) |
130 | { |
131 | printf("GnuTLS debug client\nUsage: gnutls-cli-debug [options] hostname\n\n\n"); |
132 | __gaa_helpsingle('p', "port", "integer ", "The port to connect to."); |
133 | __gaa_helpsingle('d', "debug", "integer ", "Enable debugging"); |
134 | __gaa_helpsingle('V', "verbose", "", "More verbose output"); |
135 | __gaa_helpsingle('v', "version", "", "prints the program's version number"); |
136 | __gaa_helpsingle('h', "help", "", "prints this help"); |
137 | |
138 | #line 100 "gaa.skel" |
139 | } |
140 | /* Copy of C area */ |
141 | |
142 | #line 104 "gaa.skel" |
143 | /* GAA HEADER */ |
144 | #ifndef GAA_HEADER_POKY |
145 | #define GAA_HEADER_POKY |
146 | |
147 | typedef struct _gaainfo gaainfo; |
148 | |
149 | struct _gaainfo |
150 | { |
151 | #line 29 "tls_test.gaa" |
152 | char *rest_args; |
153 | #line 22 "tls_test.gaa" |
154 | int more_info; |
155 | #line 19 "tls_test.gaa" |
156 | int debug; |
157 | #line 16 "tls_test.gaa" |
158 | int pp; |
159 | |
160 | #line 114 "gaa.skel" |
161 | }; |
162 | |
163 | #ifdef __cplusplus |
164 | extern "C" |
165 | { |
166 | #endif |
167 | |
168 | int gaa(int argc, char *argv[], gaainfo *gaaval); |
169 | |
170 | void gaa_help(void); |
171 | |
172 | int gaa_file(const char *name, gaainfo *gaaval); |
173 | |
174 | #ifdef __cplusplus |
175 | } |
176 | #endif |
177 | |
178 | |
179 | #endif |
180 | |
181 | #line 135 "gaa.skel" |
182 | |
183 | /* C declarations */ |
184 | |
185 | #define GAAERROR(x){ gaa_error = 1; return x; } \ |
186 | { \ |
187 | gaa_error = 1; \ |
188 | return x; \ |
189 | } |
190 | |
191 | static char *gaa_current_option; |
192 | static int gaa_error = 0; |
193 | |
194 | /* Generated by gaa */ |
195 | |
196 | #include <string.h> |
197 | #include <stdlib.h> |
198 | |
199 | |
200 | #define GAA_OK-1 -1 |
201 | |
202 | #define GAA_ERROR_NOMATCH0 0 |
203 | #define GAA_ERROR_NOTENOUGH_ARGS1 1 |
204 | #define GAA_ERROR_INVALID_ARG2 2 |
205 | #define GAA_ERROR_UNKNOWN3 3 |
206 | |
207 | #define GAA_NOT_AN_OPTION0 0 |
208 | #define GAA_WORD_OPTION1 1 |
209 | #define GAA_LETTER_OPTION2 2 |
210 | #define GAA_MULTIPLE_OPTION3 3 |
211 | |
212 | #define GAA_REST0 0 |
213 | #define GAA_NB_OPTION5 5 |
214 | #define GAAOPTID_help1 1 |
215 | #define GAAOPTID_version2 2 |
216 | #define GAAOPTID_verbose3 3 |
217 | #define GAAOPTID_debug4 4 |
218 | #define GAAOPTID_port5 5 |
219 | |
220 | #line 168 "gaa.skel" |
221 | |
222 | #define GAA_CHECK1STR(a,b)if(a[0] == str[0]) { gaa_current_option = a; return b; } \ |
223 | if(a[0] == str[0]) \ |
224 | { \ |
225 | gaa_current_option = a; \ |
226 | return b; \ |
227 | } |
228 | |
229 | #define GAA_CHECKSTR(a,b)if(strcmp(a,str) == 0) { gaa_current_option = a; return b; } \ |
230 | if(strcmp(a,str) == 0) \ |
231 | { \ |
232 | gaa_current_option = a; \ |
233 | return b; \ |
234 | } |
235 | |
236 | #define GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; } \ |
237 | if(!OK) \ |
238 | { \ |
239 | while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \ |
240 | gaa_index++; \ |
241 | if(gaa_last_non_option == gaa_index) \ |
242 | return GAA_ERROR_NOTENOUGH_ARGS1; \ |
243 | } |
244 | |
245 | #define GAA_TESTMOREOPTIONALARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) OK = 1; } \ |
246 | if(!OK) \ |
247 | { \ |
248 | while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \ |
249 | gaa_index++; \ |
250 | if(gaa_last_non_option == gaa_index) \ |
251 | OK = 1; \ |
252 | } |
253 | |
254 | #define GAA_FILL_2ARGS(target, func)target = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1 ; if(gaa_error == 1) { gaa_error = 0; return 2; } \ |
255 | target = func(GAAargv[gaa_index]); \ |
256 | gaa_arg_used[gaa_index] = 1; \ |
257 | if(gaa_error == 1) \ |
258 | { \ |
259 | gaa_error = 0; \ |
260 | return GAA_ERROR_INVALID_ARG2; \ |
261 | } |
262 | |
263 | |
264 | |
265 | #define GAA_FILL(target, func, num)if(!OK) { target = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index ] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } num = 1 ; } else { num = 0; } \ |
266 | if(!OK) \ |
267 | { \ |
268 | target = func(GAAargv[gaa_index]); \ |
269 | gaa_arg_used[gaa_index] = 1; \ |
270 | if(gaa_error == 1) \ |
271 | { \ |
272 | gaa_error = 0; \ |
273 | return GAA_ERROR_INVALID_ARG2; \ |
274 | } \ |
275 | num = 1; \ |
276 | } \ |
277 | else \ |
278 | { \ |
279 | num = 0; \ |
280 | } |
281 | |
282 | #define GAA_LIST_FILL(target, func, type ,num)if(!OK) { num = 0; target = ((void*)0); if ( gaa_last_non_option - gaa_index > 0) target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));for(; gaa_index < gaa_last_non_option ; gaa_index++) { if(gaa_arg_used[gaa_index] == 0) { target[num ] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1; if (gaa_error == 1) { gaa_error = 0; return 2; }; num++; } } if( num == 0) return 1; } \ |
283 | if(!OK) \ |
284 | { \ |
285 | num = 0; \ |
286 | target = NULL((void*)0); \ |
287 | if ( gaa_last_non_option - gaa_index > 0) \ |
288 | target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\ |
289 | for(; gaa_index < gaa_last_non_option; gaa_index++) \ |
290 | { \ |
291 | if(gaa_arg_used[gaa_index] == 0) \ |
292 | { \ |
293 | GAA_FILL_2ARGS(target[num], func)target[num] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index ] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; }; \ |
294 | num++; \ |
295 | } \ |
296 | } \ |
297 | if(num == 0) \ |
298 | return GAA_ERROR_NOTENOUGH_ARGS1; \ |
299 | } |
300 | |
301 | #define GAA_OPTIONALLIST_FILL(target, func, type ,num)if(!OK) { num = 0; target = ((void*)0); if ( gaa_last_non_option - gaa_index > 0) target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));for(; gaa_index < gaa_last_non_option ; gaa_index++) { if(gaa_arg_used[gaa_index] == 0) { target[num ] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1; if (gaa_error == 1) { gaa_error = 0; return 2; }; num++; } } } \ |
302 | if(!OK) \ |
303 | { \ |
304 | num = 0; \ |
305 | target = NULL((void*)0); \ |
306 | if ( gaa_last_non_option - gaa_index > 0) \ |
307 | target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\ |
308 | for(; gaa_index < gaa_last_non_option; gaa_index++) \ |
309 | { \ |
310 | if(gaa_arg_used[gaa_index] == 0) \ |
311 | { \ |
312 | GAA_FILL_2ARGS(target[num], func)target[num] = func(GAAargv[gaa_index]); gaa_arg_used[gaa_index ] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; }; \ |
313 | num++; \ |
314 | } \ |
315 | } \ |
316 | } |
317 | |
318 | #define GAA_OBLIGAT(str)k = 0; for(i = 0; i < strlen(str); i++) { j = gaa_get_option_num (str + i, 2); if(j == 0) { printf("Error: invalid 'obligat' set\n" ); exit(-1); } if(opt_list[j] == 1) k = 1; } if(k == 0) { if( strlen(str) == 1) printf("You must give the -%s option\n", str ); else printf("You must give at least one option of '%s'\n", str); return 0; } \ |
319 | k = 0; \ |
320 | for(i = 0; i < strlen(str); i++) \ |
321 | { \ |
322 | j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \ |
323 | if(j == GAA_ERROR_NOMATCH0) \ |
324 | { \ |
325 | printf("Error: invalid 'obligat' set\n"); \ |
326 | exit(-1); \ |
327 | } \ |
328 | if(opt_list[j] == 1) \ |
329 | k = 1; \ |
330 | } \ |
331 | if(k == 0) \ |
332 | { \ |
333 | if(strlen(str) == 1) \ |
334 | printf("You must give the -%s option\n", str); \ |
335 | else \ |
336 | printf("You must give at least one option of '%s'\n", str); \ |
337 | return 0; \ |
338 | } |
339 | |
340 | #define GAA_INCOMP(str)k = 0; for(i = 0; i < strlen(str); i++) { j = gaa_get_option_num (str + i, 2); if(j == 0) { printf("Error: invalid 'obligat' set\n" ); exit(-1); } if(opt_list[j] == 1) k++; } if(k > 1) { printf ("The options '%s' are incompatible\n", str); return 0; } \ |
341 | k = 0; \ |
342 | for(i = 0; i < strlen(str); i++) \ |
343 | { \ |
344 | j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \ |
345 | if(j == GAA_ERROR_NOMATCH0) \ |
346 | { \ |
347 | printf("Error: invalid 'obligat' set\n"); \ |
348 | exit(-1); \ |
349 | } \ |
350 | if(opt_list[j] == 1) \ |
351 | k++; \ |
352 | } \ |
353 | if(k > 1) \ |
354 | { \ |
355 | printf("The options '%s' are incompatible\n", str); \ |
356 | return 0; \ |
357 | } |
358 | |
359 | |
360 | static char **GAAargv; |
361 | static int GAAargc; |
362 | static char *gaa_arg_used; |
363 | static int gaa_processing_file = 0; |
364 | static int inited = 0; |
365 | |
366 | static int gaa_getint(char *arg) |
367 | { |
368 | int tmp; |
369 | char a; |
370 | if(sscanf(arg, "%d%c", &tmp, &a) < 1) |
371 | { |
372 | printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg); |
373 | GAAERROR(-1){ gaa_error = 1; return -1; }; |
374 | } |
375 | return tmp; |
376 | } |
377 | |
378 | |
379 | static char* gaa_getstr(char *arg) |
380 | { |
381 | return arg; |
382 | } |
383 | |
384 | /* option structures */ |
385 | |
386 | struct GAAOPTION_debug |
387 | { |
388 | int arg1; |
389 | int size1; |
390 | }; |
391 | |
392 | struct GAAOPTION_port |
393 | { |
394 | int arg1; |
395 | int size1; |
396 | }; |
397 | #define GAA_REST_EXISTS |
398 | |
399 | struct GAAREST |
400 | { |
401 | char* arg1; |
402 | int size1; |
403 | }; |
404 | |
405 | #line 349 "gaa.skel" |
406 | static int gaa_is_an_argument(char *str) |
407 | { |
408 | #ifdef GAA_WIN32 |
409 | if(str[0] == '/' && str[1] != 0) |
410 | return GAA_MULTIPLE_OPTION3; |
411 | #endif |
412 | if(str[0] != '-') |
413 | return GAA_NOT_AN_OPTION0; |
414 | if(str[1] == 0) |
415 | return GAA_NOT_AN_OPTION0; |
416 | if(str[1] == '-') |
417 | { |
418 | if(str[2] != 0) |
419 | return GAA_WORD_OPTION1; |
420 | else |
421 | return GAA_NOT_AN_OPTION0; |
422 | } |
423 | if(str[2] == 0) |
424 | return GAA_LETTER_OPTION2; |
425 | else |
426 | return GAA_MULTIPLE_OPTION3; |
427 | } |
428 | |
429 | static int gaa_get_option_num(char *str, int status) |
430 | { |
431 | switch(status) |
432 | { |
433 | case GAA_LETTER_OPTION2: |
434 | GAA_CHECK1STR("d", GAAOPTID_debug)if("d"[0] == str[0]) { gaa_current_option = "d"; return 4; }; |
435 | GAA_CHECK1STR("p", GAAOPTID_port)if("p"[0] == str[0]) { gaa_current_option = "p"; return 5; }; |
436 | case GAA_MULTIPLE_OPTION3: |
437 | #line 375 "gaa.skel" |
438 | GAA_CHECK1STR("h", GAAOPTID_help)if("h"[0] == str[0]) { gaa_current_option = "h"; return 1; }; |
439 | GAA_CHECK1STR("v", GAAOPTID_version)if("v"[0] == str[0]) { gaa_current_option = "v"; return 2; }; |
440 | GAA_CHECK1STR("V", GAAOPTID_verbose)if("V"[0] == str[0]) { gaa_current_option = "V"; return 3; }; |
441 | |
442 | #line 277 "gaa.skel" |
443 | break; |
444 | case GAA_WORD_OPTION1: |
445 | GAA_CHECKSTR("help", GAAOPTID_help)if(strcmp("help",str) == 0) { gaa_current_option = "help"; return 1; }; |
446 | GAA_CHECKSTR("version", GAAOPTID_version)if(strcmp("version",str) == 0) { gaa_current_option = "version" ; return 2; }; |
447 | GAA_CHECKSTR("verbose", GAAOPTID_verbose)if(strcmp("verbose",str) == 0) { gaa_current_option = "verbose" ; return 3; }; |
448 | GAA_CHECKSTR("debug", GAAOPTID_debug)if(strcmp("debug",str) == 0) { gaa_current_option = "debug"; return 4; }; |
449 | GAA_CHECKSTR("port", GAAOPTID_port)if(strcmp("port",str) == 0) { gaa_current_option = "port"; return 5; }; |
450 | |
451 | #line 281 "gaa.skel" |
452 | break; |
453 | default: break; |
454 | } |
455 | return GAA_ERROR_NOMATCH0; |
456 | } |
457 | |
458 | static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list) |
459 | { |
460 | int OK = 0; |
461 | int gaa_last_non_option; |
462 | struct GAAOPTION_debug GAATMP_debug; |
463 | struct GAAOPTION_port GAATMP_port; |
464 | |
465 | #line 393 "gaa.skel" |
466 | #ifdef GAA_REST_EXISTS |
467 | struct GAAREST GAAREST_tmp; |
468 | #endif |
469 | |
470 | opt_list[gaa_num] = 1; |
471 | |
472 | for(gaa_last_non_option = gaa_index; |
473 | (gaa_last_non_option != GAAargc) && (gaa_is_an_argument(GAAargv[gaa_last_non_option]) == GAA_NOT_AN_OPTION0); |
474 | gaa_last_non_option++); |
475 | |
476 | if(gaa_num == GAA_REST0) |
477 | { |
478 | gaa_index = 1; |
479 | gaa_last_non_option = GAAargc; |
480 | } |
481 | |
482 | switch(gaa_num) |
483 | { |
484 | case GAAOPTID_help1: |
485 | OK = 0; |
Value stored to 'OK' is never read | |
486 | #line 26 "tls_test.gaa" |
487 | { gaa_help(); exit(0); ;}; |
488 | |
489 | return GAA_OK-1; |
490 | break; |
491 | case GAAOPTID_version2: |
492 | OK = 0; |
493 | #line 25 "tls_test.gaa" |
494 | { tls_test_version(); exit(0); ;}; |
495 | |
496 | return GAA_OK-1; |
497 | break; |
498 | case GAAOPTID_verbose3: |
499 | OK = 0; |
500 | #line 23 "tls_test.gaa" |
501 | { gaaval->more_info += 1 ;}; |
502 | |
503 | return GAA_OK-1; |
504 | break; |
505 | case GAAOPTID_debug4: |
506 | OK = 0; |
507 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
508 | GAA_FILL(GAATMP_debug.arg1, gaa_getint, GAATMP_debug.size1)if(!OK) { GAATMP_debug.arg1 = gaa_getint(GAAargv[gaa_index]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_debug.size1 = 1; } else { GAATMP_debug .size1 = 0; }; |
509 | gaa_index++; |
510 | #line 20 "tls_test.gaa" |
511 | { gaaval->debug = GAATMP_debug.arg1 ;}; |
512 | |
513 | return GAA_OK-1; |
514 | break; |
515 | case GAAOPTID_port5: |
516 | OK = 0; |
517 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
518 | GAA_FILL(GAATMP_port.arg1, gaa_getint, GAATMP_port.size1)if(!OK) { GAATMP_port.arg1 = gaa_getint(GAAargv[gaa_index]); gaa_arg_used [gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2 ; } GAATMP_port.size1 = 1; } else { GAATMP_port.size1 = 0; }; |
519 | gaa_index++; |
520 | #line 17 "tls_test.gaa" |
521 | { gaaval->pp = GAATMP_port.arg1 ;}; |
522 | |
523 | return GAA_OK-1; |
524 | break; |
525 | case GAA_REST0: |
526 | GAA_TESTMOREARGSif(!OK) { while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) gaa_index++; if(gaa_last_non_option == gaa_index) return 1; }; |
527 | GAA_FILL(GAAREST_tmp.arg1, gaa_getstr, GAAREST_tmp.size1)if(!OK) { GAAREST_tmp.arg1 = gaa_getstr(GAAargv[gaa_index]); gaa_arg_used [gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2 ; } GAAREST_tmp.size1 = 1; } else { GAAREST_tmp.size1 = 0; }; |
528 | gaa_index++; |
529 | #line 30 "tls_test.gaa" |
530 | { gaaval->rest_args = GAAREST_tmp.arg1; ;}; |
531 | |
532 | return GAA_OK-1; |
533 | break; |
534 | |
535 | #line 413 "gaa.skel" |
536 | default: break; |
537 | } |
538 | return GAA_ERROR_UNKNOWN3; |
539 | } |
540 | |
541 | int gaa(int argc, char **argv, gaainfo *gaaval) |
542 | { |
543 | int tmp1, tmp2; |
544 | int l; |
545 | size_t i, j; |
546 | char *opt_list; |
547 | |
548 | i = 0; |
549 | |
550 | GAAargv = argv; |
551 | GAAargc = argc; |
552 | |
553 | opt_list = (char*) gaa_malloc(GAA_NB_OPTION5 + 1); |
554 | |
555 | for(l = 0; l < GAA_NB_OPTION5 + 1; l++) |
556 | opt_list[l] = 0; |
557 | /* initialization */ |
558 | if(inited == 0) |
559 | { |
560 | |
561 | #line 32 "tls_test.gaa" |
562 | { gaaval->rest_args=NULL((void*)0); gaaval->pp = 443; gaaval->more_info = 0; ;}; |
563 | |
564 | } |
565 | inited = 1; |
566 | #line 438 "gaa.skel" |
567 | gaa_arg_used = NULL((void*)0); |
568 | |
569 | if (argc > 0) { |
570 | gaa_arg_used = gaa_malloc(argc * sizeof(char)); |
571 | } |
572 | |
573 | for(l = 1; l < argc; l++) |
574 | gaa_arg_used[l] = 0; |
575 | for(l = 1; l < argc; l++) |
576 | { |
577 | if(gaa_arg_used[l] == 0) |
578 | { |
579 | j = 0; |
580 | tmp1 = gaa_is_an_argument(GAAargv[l]); |
581 | switch(tmp1) |
582 | { |
583 | case GAA_WORD_OPTION1: |
584 | j++; |
585 | case GAA_LETTER_OPTION2: |
586 | j++; |
587 | tmp2 = gaa_get_option_num(argv[l]+j, tmp1); |
588 | if(tmp2 == GAA_ERROR_NOMATCH0) |
589 | { |
590 | printf("Invalid option '%s'\n", argv[l]+j); |
591 | return 0; |
592 | } |
593 | switch(gaa_try(tmp2, l+1, gaaval, opt_list)) |
594 | { |
595 | case GAA_ERROR_NOTENOUGH_ARGS1: |
596 | printf("'%s': not enough arguments\n",gaa_current_option); |
597 | return 0; |
598 | case GAA_ERROR_INVALID_ARG2: |
599 | printf("Invalid arguments\n"); |
600 | return 0; |
601 | case GAA_OK-1: |
602 | break; |
603 | default: |
604 | printf("Unknown error\n"); |
605 | } |
606 | gaa_arg_used[l] = 1; |
607 | break; |
608 | case GAA_MULTIPLE_OPTION3: |
609 | for(j = 1; j < strlen(argv[l]); j++) |
610 | { |
611 | tmp2 = gaa_get_option_num(argv[l]+j, tmp1); |
612 | if(tmp2 == GAA_ERROR_NOMATCH0) |
613 | { |
614 | printf("Invalid option '%c'\n", *(argv[l]+j)); |
615 | return 0; |
616 | } |
617 | switch(gaa_try(tmp2, l+1, gaaval, opt_list)) |
618 | { |
619 | case GAA_ERROR_NOTENOUGH_ARGS1: |
620 | printf("'%s': not enough arguments\n",gaa_current_option); |
621 | return 0; |
622 | case GAA_ERROR_INVALID_ARG2: |
623 | printf("Invalid arguments\n"); |
624 | return 0; |
625 | case GAA_OK-1: |
626 | break; |
627 | default: |
628 | printf("Unknown error\n"); |
629 | } |
630 | } |
631 | gaa_arg_used[l] = 1; |
632 | break; |
633 | default: break; |
634 | } |
635 | } |
636 | } |
637 | if(gaa_processing_file == 0) |
638 | { |
639 | |
640 | #line 507 "gaa.skel" |
641 | #ifdef GAA_REST_EXISTS |
642 | switch(gaa_try(GAA_REST0, 1, gaaval, opt_list)) |
643 | { |
644 | case GAA_ERROR_NOTENOUGH_ARGS1: |
645 | printf("Rest: not enough arguments\n"); |
646 | return 0; |
647 | case GAA_ERROR_INVALID_ARG2: |
648 | printf("Invalid arguments\n"); |
649 | return 0; |
650 | case GAA_OK-1: |
651 | break; |
652 | default: |
653 | printf("Unknown error\n"); |
654 | } |
655 | #endif |
656 | } |
657 | for(l = 1; l < argc; l++) |
658 | { |
659 | if(gaa_arg_used[l] == 0) |
660 | { |
661 | printf("Too many arguments\n"); |
662 | return 0; |
663 | } |
664 | } |
665 | free(gaa_arg_used); |
666 | free(opt_list); |
667 | return -1; |
668 | } |
669 | |
670 | struct gaastrnode |
671 | { |
672 | char *str; |
673 | struct gaastrnode *next; |
674 | }; |
675 | |
676 | typedef struct gaastrnode gaa_str_node; |
677 | |
678 | static int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc) |
679 | { |
680 | int pos_ini; |
681 | int a; |
682 | int i = 0, len = 0, newline = 0; |
683 | |
684 | if(argc == 1) { |
685 | newline = 1; |
686 | len = 2; |
687 | } |
688 | |
689 | a = fgetc( file); |
690 | if (a == EOF(-1)) return 0; |
691 | |
692 | while(a == ' ' || a == 9 || a == '\n') |
693 | { |
694 | if(a == '\n') |
695 | { |
696 | newline=1; |
697 | len = 2; |
698 | } |
699 | a = fgetc( file); |
700 | if (a == EOF(-1)) return 0; |
701 | } |
702 | |
703 | pos_ini = ftell(file) - 1; |
704 | |
705 | while(a != ' ' && a != 9 && a != '\n') |
706 | { |
707 | |
708 | len++; |
709 | a = fgetc( file); |
710 | if(a==EOF(-1)) return 0; /* a = ' '; */ |
711 | } |
712 | |
713 | len += 1; |
714 | tmp_str->str = gaa_malloc((len) * sizeof(char)); |
715 | |
716 | if(newline == 1) |
717 | { |
718 | tmp_str->str[0] = '-'; |
719 | tmp_str->str[1] = '-'; |
720 | i = 2; |
721 | } |
722 | else |
723 | { |
724 | i = 0; |
725 | } |
726 | |
727 | fseek(file,pos_ini, SEEK_SET0); |
728 | do |
729 | { |
730 | a = fgetc( file); |
731 | |
732 | if (a == EOF(-1)) { |
733 | i+=2; |
734 | break; |
735 | } |
736 | tmp_str->str[i] = a; |
737 | i++; |
738 | } |
739 | while(a != ' ' && a != 9 && a != '\n' && i < len); |
740 | |
741 | tmp_str->str[i - 1] = 0; |
742 | |
743 | fseek(file,- 1, SEEK_CUR1); |
744 | /* printf("%d\n", ftell(file)); */ |
745 | |
746 | return -1; |
747 | } |
748 | |
749 | int gaa_file(const char *name, gaainfo *gaaval) |
750 | { |
751 | gaa_str_node *first_str, **tmp_str, *tmp_str2; |
752 | int rval, i; |
753 | char **argv; |
754 | int argc = 0; |
755 | FILE *file; |
756 | |
757 | gaa_processing_file = 1; |
758 | |
759 | if((file = fopen(name, "r")) == NULL((void*)0)) |
760 | { |
761 | printf("Couldn't open '%s' configuration file for reading\n", name); |
762 | return 1; |
763 | } |
764 | |
765 | tmp_str = &first_str; |
766 | do |
767 | { |
768 | argc++; |
769 | *tmp_str = gaa_malloc(sizeof(gaa_str_node)); |
770 | |
771 | (*tmp_str)->str = NULL((void*)0); |
772 | (*tmp_str)->next = NULL((void*)0); |
773 | |
774 | rval = gaa_internal_get_next_str(file, *tmp_str, argc); |
775 | tmp_str = &((*tmp_str)->next); |
776 | } |
777 | while(rval == -1); |
778 | |
779 | if(rval == 1) |
780 | return 0; |
781 | |
782 | argv = gaa_malloc((1 + argc) * sizeof(char*)); |
783 | |
784 | tmp_str2 = first_str; |
785 | argv[0] = "cfg"; |
786 | for(i = 1; i < argc; i++) |
787 | { |
788 | argv[i] = tmp_str2->str; |
789 | tmp_str2 = tmp_str2->next; |
790 | } |
791 | |
792 | rval = gaa(argc, argv, gaaval); |
793 | gaa_processing_file = 0; |
794 | return rval; |
795 | } |