File: | src/serv-gaa.c |
Location: | line 808, 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 "serv.gaa" |
5 | |
6 | |
7 | #include <config.h> |
8 | #include <common.h> |
9 | |
10 | void serv_version(void); |
11 | |
12 | #include <stdio.h> |
13 | #include <string.h> |
14 | #include <stdlib.h> |
15 | |
16 | #ifndef GAA_NO_WIN32 |
17 | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS) |
18 | #define GAA_WIN32 |
19 | #endif |
20 | #endif |
21 | |
22 | static void* gaa_malloc( size_t size) { |
23 | void* ret; |
24 | ret = malloc(size); |
25 | if (ret==NULL((void*)0)) { |
26 | fprintf(stderrstderr, "gaa: could not allocate memory"); |
27 | exit(1); |
28 | } |
29 | return ret; |
30 | } |
31 | |
32 | static void __gaa_helpsingle(char short_name, char *name, |
33 | char *arg_desc, char *opt_help) |
34 | { |
35 | int col1, col3, col4, tabsize = 3, curr; |
36 | int i; |
37 | |
38 | col1 = 5; /* Default values */ |
39 | col3 = 30; |
40 | col4 = 70; |
41 | |
42 | curr = 0; |
43 | for(i = 0; i < col1; i++) |
44 | { |
45 | printf(" "); |
46 | curr++; |
47 | } |
48 | if(short_name) |
49 | { |
50 | if(name && *name) |
51 | { |
52 | printf("-%c, ", short_name); |
53 | curr += 4; |
54 | } |
55 | else |
56 | { |
57 | printf("-%c ", short_name); |
58 | curr += 3; |
59 | } |
60 | } |
61 | if(name && *name) |
62 | { |
63 | printf("--%s ", name); |
64 | curr += 3 + strlen(name); |
65 | } |
66 | if(arg_desc && *arg_desc) |
67 | { |
68 | printf("%s ", arg_desc); |
69 | curr += 1 + strlen(arg_desc); |
70 | } |
71 | if(curr >= col3) |
72 | { |
73 | printf("\n"); |
74 | curr = 0; |
75 | } |
76 | if(opt_help) /* let's print the option's help body */ |
77 | { |
78 | const char *str = opt_help; |
79 | while(*str) |
80 | { |
81 | while(curr < col3) |
82 | { |
83 | printf(" "); |
84 | curr++; |
85 | } |
86 | switch(*str) |
87 | { |
88 | case '\n': |
89 | printf("\n"); |
90 | curr = 0; |
91 | break; |
92 | case '\t': |
93 | do |
94 | { |
95 | printf(" "); |
96 | curr++; |
97 | } |
98 | while((curr - col3) % tabsize != 0 && curr < col4); |
99 | case ' ': |
100 | if(*str == ' ') |
101 | { |
102 | curr++; |
103 | printf(" "); |
104 | } |
105 | for(i = 1; str[i] && str[i] != ' ' && str[i] != '\n' |
106 | && str[i] != '\t'; i++); |
107 | if(curr + i - 1 >= col4) |
108 | curr = col4; |
109 | break; |
110 | default: |
111 | printf("%c", *str); |
112 | curr++; |
113 | } |
114 | if(curr >= col4) |
115 | { |
116 | printf("\n"); |
117 | curr = 0; |
118 | } |
119 | str++; |
120 | } |
121 | } |
122 | printf("\n"); |
123 | } |
124 | |
125 | void gaa_help(void) |
126 | { |
127 | printf("GnuTLS test server\nUsage: gnutls-serv [options]\n\n\n"); |
128 | __gaa_helpsingle('d', "debug", "integer ", "Enable debugging"); |
129 | __gaa_helpsingle('g', "generate", "", "Generate Diffie-Hellman and RSA-EXPORT Parameters."); |
130 | __gaa_helpsingle('p', "port", "integer ", "The port to connect to."); |
131 | __gaa_helpsingle('q', "quiet", "", "Suppress some messages."); |
132 | __gaa_helpsingle(0, "nodb", "", "Does not use the resume database."); |
133 | __gaa_helpsingle(0, "noticket", "", "Does not issue session tickets."); |
134 | __gaa_helpsingle(0, "http", "", "Act as an HTTP Server."); |
135 | __gaa_helpsingle(0, "echo", "", "Act as an Echo Server."); |
136 | __gaa_helpsingle(0, "udp", "", "Enable UDP server instead of TCP."); |
137 | __gaa_helpsingle(0, "mtu", "integer ", "Set MTU for datagram TLS."); |
138 | __gaa_helpsingle(0, "dhparams", "FILE ", "DH params file to use."); |
139 | __gaa_helpsingle(0, "x509fmtder", "", "Use DER format for certificates"); |
140 | __gaa_helpsingle(0, "x509cafile", "FILE ", "Certificate file or PKCS #11 URL to use."); |
141 | __gaa_helpsingle(0, "x509crlfile", "FILE ", "CRL file to use."); |
142 | __gaa_helpsingle(0, "pgpkeyring", "FILE ", "PGP Key ring file to use."); |
143 | __gaa_helpsingle(0, "pgpkeyfile", "FILE ", "PGP Key file to use."); |
144 | __gaa_helpsingle(0, "pgpcertfile", "FILE ", "PGP Public Key (certificate) file to use."); |
145 | __gaa_helpsingle(0, "pgpsubkey", "HEX|auto ", "PGP subkey to use."); |
146 | __gaa_helpsingle(0, "x509keyfile", "FILE ", "X.509 key file or PKCS #11 URL to use."); |
147 | __gaa_helpsingle(0, "x509certfile", "FILE ", "X.509 Certificate file or PKCS #11 URL to use."); |
148 | __gaa_helpsingle(0, "x509dsakeyfile", "FILE ", "Alternative X.509 key file to use."); |
149 | __gaa_helpsingle(0, "x509dsacertfile", "FILE ", "Alternative X.509 certificate file to use."); |
150 | __gaa_helpsingle(0, "x509ecckeyfile", "FILE ", "Alternative X.509 key file to use."); |
151 | __gaa_helpsingle(0, "x509ecccertfile", "FILE ", "Alternative X.509 certificate file to use."); |
152 | __gaa_helpsingle('r', "require-cert", "", "Require a valid certificate."); |
153 | __gaa_helpsingle('a', "disable-client-cert", "", "Disable request for a client certificate."); |
154 | __gaa_helpsingle(0, "pskpasswd", "FILE ", "PSK password file to use."); |
155 | __gaa_helpsingle(0, "pskhint", "HINT ", "PSK identity hint to use."); |
156 | __gaa_helpsingle(0, "srppasswd", "FILE ", "SRP password file to use."); |
157 | __gaa_helpsingle(0, "srppasswdconf", "FILE ", "SRP password conf file to use."); |
158 | __gaa_helpsingle(0, "priority", "PRIORITY STRING ", "Priorities string."); |
159 | __gaa_helpsingle('l', "list", "", "Print a list of the supported algorithms and modes."); |
160 | __gaa_helpsingle('h', "help", "", "prints this help"); |
161 | __gaa_helpsingle('v', "version", "", "prints the program's version number"); |
162 | |
163 | #line 100 "gaa.skel" |
164 | } |
165 | /* Copy of C area */ |
166 | |
167 | #line 104 "gaa.skel" |
168 | /* GAA HEADER */ |
169 | #ifndef GAA_HEADER_POKY |
170 | #define GAA_HEADER_POKY |
171 | |
172 | typedef struct _gaainfo gaainfo; |
173 | |
174 | struct _gaainfo |
175 | { |
176 | #line 100 "serv.gaa" |
177 | char *priorities; |
178 | #line 97 "serv.gaa" |
179 | char *srp_passwd_conf; |
180 | #line 94 "serv.gaa" |
181 | char *srp_passwd; |
182 | #line 91 "serv.gaa" |
183 | char *psk_hint; |
184 | #line 88 "serv.gaa" |
185 | char *psk_passwd; |
186 | #line 85 "serv.gaa" |
187 | int disable_client_cert; |
188 | #line 82 "serv.gaa" |
189 | int require_cert; |
190 | #line 79 "serv.gaa" |
191 | char *x509_ecccertfile; |
192 | #line 76 "serv.gaa" |
193 | char *x509_ecckeyfile; |
194 | #line 73 "serv.gaa" |
195 | char *x509_dsacertfile; |
196 | #line 70 "serv.gaa" |
197 | char *x509_dsakeyfile; |
198 | #line 67 "serv.gaa" |
199 | char *x509_certfile; |
200 | #line 64 "serv.gaa" |
201 | char *x509_keyfile; |
202 | #line 61 "serv.gaa" |
203 | char *pgp_subkey; |
204 | #line 58 "serv.gaa" |
205 | char *pgp_certfile; |
206 | #line 55 "serv.gaa" |
207 | char *pgp_keyfile; |
208 | #line 52 "serv.gaa" |
209 | char *pgp_keyring; |
210 | #line 49 "serv.gaa" |
211 | char *x509_crlfile; |
212 | #line 46 "serv.gaa" |
213 | char *x509_cafile; |
214 | #line 43 "serv.gaa" |
215 | int fmtder; |
216 | #line 40 "serv.gaa" |
217 | char *dh_params_file; |
218 | #line 37 "serv.gaa" |
219 | int mtu; |
220 | #line 34 "serv.gaa" |
221 | int udp; |
222 | #line 30 "serv.gaa" |
223 | int http; |
224 | #line 27 "serv.gaa" |
225 | int noticket; |
226 | #line 24 "serv.gaa" |
227 | int nodb; |
228 | #line 21 "serv.gaa" |
229 | int quiet; |
230 | #line 18 "serv.gaa" |
231 | int port; |
232 | #line 15 "serv.gaa" |
233 | int generate; |
234 | #line 12 "serv.gaa" |
235 | int debug; |
236 | |
237 | #line 114 "gaa.skel" |
238 | }; |
239 | |
240 | #ifdef __cplusplus |
241 | extern "C" |
242 | { |
243 | #endif |
244 | |
245 | int gaa(int argc, char *argv[], gaainfo *gaaval); |
246 | |
247 | void gaa_help(void); |
248 | |
249 | int gaa_file(const char *name, gaainfo *gaaval); |
250 | |
251 | #ifdef __cplusplus |
252 | } |
253 | #endif |
254 | |
255 | |
256 | #endif |
257 | |
258 | #line 135 "gaa.skel" |
259 | |
260 | /* C declarations */ |
261 | |
262 | #define GAAERROR(x){ gaa_error = 1; return x; } \ |
263 | { \ |
264 | gaa_error = 1; \ |
265 | return x; \ |
266 | } |
267 | |
268 | static char *gaa_current_option; |
269 | static int gaa_error = 0; |
270 | |
271 | /* Generated by gaa */ |
272 | |
273 | #include <string.h> |
274 | #include <stdlib.h> |
275 | |
276 | |
277 | #define GAA_OK-1 -1 |
278 | |
279 | #define GAA_ERROR_NOMATCH0 0 |
280 | #define GAA_ERROR_NOTENOUGH_ARGS1 1 |
281 | #define GAA_ERROR_INVALID_ARG2 2 |
282 | #define GAA_ERROR_UNKNOWN3 3 |
283 | |
284 | #define GAA_NOT_AN_OPTION0 0 |
285 | #define GAA_WORD_OPTION1 1 |
286 | #define GAA_LETTER_OPTION2 2 |
287 | #define GAA_MULTIPLE_OPTION3 3 |
288 | |
289 | #define GAA_REST0 0 |
290 | #define GAA_NB_OPTION34 34 |
291 | #define GAAOPTID_version1 1 |
292 | #define GAAOPTID_help2 2 |
293 | #define GAAOPTID_list3 3 |
294 | #define GAAOPTID_priority4 4 |
295 | #define GAAOPTID_srppasswdconf5 5 |
296 | #define GAAOPTID_srppasswd6 6 |
297 | #define GAAOPTID_pskhint7 7 |
298 | #define GAAOPTID_pskpasswd8 8 |
299 | #define GAAOPTID_disable_client_cert9 9 |
300 | #define GAAOPTID_require_cert10 10 |
301 | #define GAAOPTID_x509ecccertfile11 11 |
302 | #define GAAOPTID_x509ecckeyfile12 12 |
303 | #define GAAOPTID_x509dsacertfile13 13 |
304 | #define GAAOPTID_x509dsakeyfile14 14 |
305 | #define GAAOPTID_x509certfile15 15 |
306 | #define GAAOPTID_x509keyfile16 16 |
307 | #define GAAOPTID_pgpsubkey17 17 |
308 | #define GAAOPTID_pgpcertfile18 18 |
309 | #define GAAOPTID_pgpkeyfile19 19 |
310 | #define GAAOPTID_pgpkeyring20 20 |
311 | #define GAAOPTID_x509crlfile21 21 |
312 | #define GAAOPTID_x509cafile22 22 |
313 | #define GAAOPTID_x509fmtder23 23 |
314 | #define GAAOPTID_dhparams24 24 |
315 | #define GAAOPTID_mtu25 25 |
316 | #define GAAOPTID_udp26 26 |
317 | #define GAAOPTID_echo27 27 |
318 | #define GAAOPTID_http28 28 |
319 | #define GAAOPTID_noticket29 29 |
320 | #define GAAOPTID_nodb30 30 |
321 | #define GAAOPTID_quiet31 31 |
322 | #define GAAOPTID_port32 32 |
323 | #define GAAOPTID_generate33 33 |
324 | #define GAAOPTID_debug34 34 |
325 | |
326 | #line 168 "gaa.skel" |
327 | |
328 | #define GAA_CHECK1STR(a,b)if(a[0] == str[0]) { gaa_current_option = a; return b; } \ |
329 | if(a[0] == str[0]) \ |
330 | { \ |
331 | gaa_current_option = a; \ |
332 | return b; \ |
333 | } |
334 | |
335 | #define GAA_CHECKSTR(a,b)if(strcmp(a,str) == 0) { gaa_current_option = a; return b; } \ |
336 | if(strcmp(a,str) == 0) \ |
337 | { \ |
338 | gaa_current_option = a; \ |
339 | return b; \ |
340 | } |
341 | |
342 | #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; } \ |
343 | if(!OK) \ |
344 | { \ |
345 | while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \ |
346 | gaa_index++; \ |
347 | if(gaa_last_non_option == gaa_index) \ |
348 | return GAA_ERROR_NOTENOUGH_ARGS1; \ |
349 | } |
350 | |
351 | #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; } \ |
352 | if(!OK) \ |
353 | { \ |
354 | while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \ |
355 | gaa_index++; \ |
356 | if(gaa_last_non_option == gaa_index) \ |
357 | OK = 1; \ |
358 | } |
359 | |
360 | #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; } \ |
361 | target = func(GAAargv[gaa_index]); \ |
362 | gaa_arg_used[gaa_index] = 1; \ |
363 | if(gaa_error == 1) \ |
364 | { \ |
365 | gaa_error = 0; \ |
366 | return GAA_ERROR_INVALID_ARG2; \ |
367 | } |
368 | |
369 | |
370 | |
371 | #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; } \ |
372 | if(!OK) \ |
373 | { \ |
374 | target = func(GAAargv[gaa_index]); \ |
375 | gaa_arg_used[gaa_index] = 1; \ |
376 | if(gaa_error == 1) \ |
377 | { \ |
378 | gaa_error = 0; \ |
379 | return GAA_ERROR_INVALID_ARG2; \ |
380 | } \ |
381 | num = 1; \ |
382 | } \ |
383 | else \ |
384 | { \ |
385 | num = 0; \ |
386 | } |
387 | |
388 | #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; } \ |
389 | if(!OK) \ |
390 | { \ |
391 | num = 0; \ |
392 | target = NULL((void*)0); \ |
393 | if ( gaa_last_non_option - gaa_index > 0) \ |
394 | target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\ |
395 | for(; gaa_index < gaa_last_non_option; gaa_index++) \ |
396 | { \ |
397 | if(gaa_arg_used[gaa_index] == 0) \ |
398 | { \ |
399 | 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; }; \ |
400 | num++; \ |
401 | } \ |
402 | } \ |
403 | if(num == 0) \ |
404 | return GAA_ERROR_NOTENOUGH_ARGS1; \ |
405 | } |
406 | |
407 | #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++; } } } \ |
408 | if(!OK) \ |
409 | { \ |
410 | num = 0; \ |
411 | target = NULL((void*)0); \ |
412 | if ( gaa_last_non_option - gaa_index > 0) \ |
413 | target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\ |
414 | for(; gaa_index < gaa_last_non_option; gaa_index++) \ |
415 | { \ |
416 | if(gaa_arg_used[gaa_index] == 0) \ |
417 | { \ |
418 | 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; }; \ |
419 | num++; \ |
420 | } \ |
421 | } \ |
422 | } |
423 | |
424 | #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; } \ |
425 | k = 0; \ |
426 | for(i = 0; i < strlen(str); i++) \ |
427 | { \ |
428 | j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \ |
429 | if(j == GAA_ERROR_NOMATCH0) \ |
430 | { \ |
431 | printf("Error: invalid 'obligat' set\n"); \ |
432 | exit(-1); \ |
433 | } \ |
434 | if(opt_list[j] == 1) \ |
435 | k = 1; \ |
436 | } \ |
437 | if(k == 0) \ |
438 | { \ |
439 | if(strlen(str) == 1) \ |
440 | printf("You must give the -%s option\n", str); \ |
441 | else \ |
442 | printf("You must give at least one option of '%s'\n", str); \ |
443 | return 0; \ |
444 | } |
445 | |
446 | #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; } \ |
447 | k = 0; \ |
448 | for(i = 0; i < strlen(str); i++) \ |
449 | { \ |
450 | j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \ |
451 | if(j == GAA_ERROR_NOMATCH0) \ |
452 | { \ |
453 | printf("Error: invalid 'obligat' set\n"); \ |
454 | exit(-1); \ |
455 | } \ |
456 | if(opt_list[j] == 1) \ |
457 | k++; \ |
458 | } \ |
459 | if(k > 1) \ |
460 | { \ |
461 | printf("The options '%s' are incompatible\n", str); \ |
462 | return 0; \ |
463 | } |
464 | |
465 | |
466 | static char **GAAargv; |
467 | static int GAAargc; |
468 | static char *gaa_arg_used; |
469 | static int gaa_processing_file = 0; |
470 | static int inited = 0; |
471 | |
472 | static int gaa_getint(char *arg) |
473 | { |
474 | int tmp; |
475 | char a; |
476 | if(sscanf(arg, "%d%c", &tmp, &a) < 1) |
477 | { |
478 | printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg); |
479 | GAAERROR(-1){ gaa_error = 1; return -1; }; |
480 | } |
481 | return tmp; |
482 | } |
483 | |
484 | static char gaa_getchar(char *arg) |
485 | { |
486 | if(strlen(arg) != 1) |
487 | { |
488 | printf("Option %s: '%s' isn't an character\n", gaa_current_option, arg); |
489 | GAAERROR(-1){ gaa_error = 1; return -1; }; |
490 | } |
491 | return arg[0]; |
492 | } |
493 | |
494 | static char* gaa_getstr(char *arg) |
495 | { |
496 | return arg; |
497 | } |
498 | static float gaa_getfloat(char *arg) |
499 | { |
500 | float tmp; |
501 | char a; |
502 | if(sscanf(arg, "%f%c", &tmp, &a) < 1) |
503 | { |
504 | printf("Option %s: '%s' isn't a float number\n", gaa_current_option, arg); |
505 | GAAERROR(-1){ gaa_error = 1; return -1; }; |
506 | } |
507 | return tmp; |
508 | } |
509 | /* option structures */ |
510 | |
511 | struct GAAOPTION_priority |
512 | { |
513 | char* arg1; |
514 | int size1; |
515 | }; |
516 | |
517 | struct GAAOPTION_srppasswdconf |
518 | { |
519 | char* arg1; |
520 | int size1; |
521 | }; |
522 | |
523 | struct GAAOPTION_srppasswd |
524 | { |
525 | char* arg1; |
526 | int size1; |
527 | }; |
528 | |
529 | struct GAAOPTION_pskhint |
530 | { |
531 | char* arg1; |
532 | int size1; |
533 | }; |
534 | |
535 | struct GAAOPTION_pskpasswd |
536 | { |
537 | char* arg1; |
538 | int size1; |
539 | }; |
540 | |
541 | struct GAAOPTION_x509ecccertfile |
542 | { |
543 | char* arg1; |
544 | int size1; |
545 | }; |
546 | |
547 | struct GAAOPTION_x509ecckeyfile |
548 | { |
549 | char* arg1; |
550 | int size1; |
551 | }; |
552 | |
553 | struct GAAOPTION_x509dsacertfile |
554 | { |
555 | char* arg1; |
556 | int size1; |
557 | }; |
558 | |
559 | struct GAAOPTION_x509dsakeyfile |
560 | { |
561 | char* arg1; |
562 | int size1; |
563 | }; |
564 | |
565 | struct GAAOPTION_x509certfile |
566 | { |
567 | char* arg1; |
568 | int size1; |
569 | }; |
570 | |
571 | struct GAAOPTION_x509keyfile |
572 | { |
573 | char* arg1; |
574 | int size1; |
575 | }; |
576 | |
577 | struct GAAOPTION_pgpsubkey |
578 | { |
579 | char* arg1; |
580 | int size1; |
581 | }; |
582 | |
583 | struct GAAOPTION_pgpcertfile |
584 | { |
585 | char* arg1; |
586 | int size1; |
587 | }; |
588 | |
589 | struct GAAOPTION_pgpkeyfile |
590 | { |
591 | char* arg1; |
592 | int size1; |
593 | }; |
594 | |
595 | struct GAAOPTION_pgpkeyring |
596 | { |
597 | char* arg1; |
598 | int size1; |
599 | }; |
600 | |
601 | struct GAAOPTION_x509crlfile |
602 | { |
603 | char* arg1; |
604 | int size1; |
605 | }; |
606 | |
607 | struct GAAOPTION_x509cafile |
608 | { |
609 | char* arg1; |
610 | int size1; |
611 | }; |
612 | |
613 | struct GAAOPTION_dhparams |
614 | { |
615 | char* arg1; |
616 | int size1; |
617 | }; |
618 | |
619 | struct GAAOPTION_mtu |
620 | { |
621 | int arg1; |
622 | int size1; |
623 | }; |
624 | |
625 | struct GAAOPTION_port |
626 | { |
627 | int arg1; |
628 | int size1; |
629 | }; |
630 | |
631 | struct GAAOPTION_debug |
632 | { |
633 | int arg1; |
634 | int size1; |
635 | }; |
636 | |
637 | #line 349 "gaa.skel" |
638 | static int gaa_is_an_argument(char *str) |
639 | { |
640 | #ifdef GAA_WIN32 |
641 | if(str[0] == '/' && str[1] != 0) |
642 | return GAA_MULTIPLE_OPTION3; |
643 | #endif |
644 | if(str[0] != '-') |
645 | return GAA_NOT_AN_OPTION0; |
646 | if(str[1] == 0) |
647 | return GAA_NOT_AN_OPTION0; |
648 | if(str[1] == '-') |
649 | { |
650 | if(str[2] != 0) |
651 | return GAA_WORD_OPTION1; |
652 | else |
653 | return GAA_NOT_AN_OPTION0; |
654 | } |
655 | if(str[2] == 0) |
656 | return GAA_LETTER_OPTION2; |
657 | else |
658 | return GAA_MULTIPLE_OPTION3; |
659 | } |
660 | |
661 | static int gaa_get_option_num(char *str, int status) |
662 | { |
663 | switch(status) |
664 | { |
665 | case GAA_LETTER_OPTION2: |
666 | GAA_CHECK1STR("", GAAOPTID_priority)if(""[0] == str[0]) { gaa_current_option = ""; return 4; }; |
667 | GAA_CHECK1STR("", GAAOPTID_srppasswdconf)if(""[0] == str[0]) { gaa_current_option = ""; return 5; }; |
668 | GAA_CHECK1STR("", GAAOPTID_srppasswd)if(""[0] == str[0]) { gaa_current_option = ""; return 6; }; |
669 | GAA_CHECK1STR("", GAAOPTID_pskhint)if(""[0] == str[0]) { gaa_current_option = ""; return 7; }; |
670 | GAA_CHECK1STR("", GAAOPTID_pskpasswd)if(""[0] == str[0]) { gaa_current_option = ""; return 8; }; |
671 | GAA_CHECK1STR("", GAAOPTID_x509ecccertfile)if(""[0] == str[0]) { gaa_current_option = ""; return 11; }; |
672 | GAA_CHECK1STR("", GAAOPTID_x509ecckeyfile)if(""[0] == str[0]) { gaa_current_option = ""; return 12; }; |
673 | GAA_CHECK1STR("", GAAOPTID_x509dsacertfile)if(""[0] == str[0]) { gaa_current_option = ""; return 13; }; |
674 | GAA_CHECK1STR("", GAAOPTID_x509dsakeyfile)if(""[0] == str[0]) { gaa_current_option = ""; return 14; }; |
675 | GAA_CHECK1STR("", GAAOPTID_x509certfile)if(""[0] == str[0]) { gaa_current_option = ""; return 15; }; |
676 | GAA_CHECK1STR("", GAAOPTID_x509keyfile)if(""[0] == str[0]) { gaa_current_option = ""; return 16; }; |
677 | GAA_CHECK1STR("", GAAOPTID_pgpsubkey)if(""[0] == str[0]) { gaa_current_option = ""; return 17; }; |
678 | GAA_CHECK1STR("", GAAOPTID_pgpcertfile)if(""[0] == str[0]) { gaa_current_option = ""; return 18; }; |
679 | GAA_CHECK1STR("", GAAOPTID_pgpkeyfile)if(""[0] == str[0]) { gaa_current_option = ""; return 19; }; |
680 | GAA_CHECK1STR("", GAAOPTID_pgpkeyring)if(""[0] == str[0]) { gaa_current_option = ""; return 20; }; |
681 | GAA_CHECK1STR("", GAAOPTID_x509crlfile)if(""[0] == str[0]) { gaa_current_option = ""; return 21; }; |
682 | GAA_CHECK1STR("", GAAOPTID_x509cafile)if(""[0] == str[0]) { gaa_current_option = ""; return 22; }; |
683 | GAA_CHECK1STR("", GAAOPTID_dhparams)if(""[0] == str[0]) { gaa_current_option = ""; return 24; }; |
684 | GAA_CHECK1STR("", GAAOPTID_mtu)if(""[0] == str[0]) { gaa_current_option = ""; return 25; }; |
685 | GAA_CHECK1STR("p", GAAOPTID_port)if("p"[0] == str[0]) { gaa_current_option = "p"; return 32; }; |
686 | GAA_CHECK1STR("d", GAAOPTID_debug)if("d"[0] == str[0]) { gaa_current_option = "d"; return 34; }; |
687 | case GAA_MULTIPLE_OPTION3: |
688 | #line 375 "gaa.skel" |
689 | GAA_CHECK1STR("v", GAAOPTID_version)if("v"[0] == str[0]) { gaa_current_option = "v"; return 1; }; |
690 | GAA_CHECK1STR("h", GAAOPTID_help)if("h"[0] == str[0]) { gaa_current_option = "h"; return 2; }; |
691 | GAA_CHECK1STR("l", GAAOPTID_list)if("l"[0] == str[0]) { gaa_current_option = "l"; return 3; }; |
692 | GAA_CHECK1STR("a", GAAOPTID_disable_client_cert)if("a"[0] == str[0]) { gaa_current_option = "a"; return 9; }; |
693 | GAA_CHECK1STR("r", GAAOPTID_require_cert)if("r"[0] == str[0]) { gaa_current_option = "r"; return 10; }; |
694 | GAA_CHECK1STR("", GAAOPTID_x509fmtder)if(""[0] == str[0]) { gaa_current_option = ""; return 23; }; |
695 | GAA_CHECK1STR("", GAAOPTID_udp)if(""[0] == str[0]) { gaa_current_option = ""; return 26; }; |
696 | GAA_CHECK1STR("", GAAOPTID_echo)if(""[0] == str[0]) { gaa_current_option = ""; return 27; }; |
697 | GAA_CHECK1STR("", GAAOPTID_http)if(""[0] == str[0]) { gaa_current_option = ""; return 28; }; |
698 | GAA_CHECK1STR("", GAAOPTID_noticket)if(""[0] == str[0]) { gaa_current_option = ""; return 29; }; |
699 | GAA_CHECK1STR("", GAAOPTID_nodb)if(""[0] == str[0]) { gaa_current_option = ""; return 30; }; |
700 | GAA_CHECK1STR("q", GAAOPTID_quiet)if("q"[0] == str[0]) { gaa_current_option = "q"; return 31; }; |
701 | GAA_CHECK1STR("g", GAAOPTID_generate)if("g"[0] == str[0]) { gaa_current_option = "g"; return 33; }; |
702 | |
703 | #line 277 "gaa.skel" |
704 | break; |
705 | case GAA_WORD_OPTION1: |
706 | GAA_CHECKSTR("version", GAAOPTID_version)if(strcmp("version",str) == 0) { gaa_current_option = "version" ; return 1; }; |
707 | GAA_CHECKSTR("help", GAAOPTID_help)if(strcmp("help",str) == 0) { gaa_current_option = "help"; return 2; }; |
708 | GAA_CHECKSTR("list", GAAOPTID_list)if(strcmp("list",str) == 0) { gaa_current_option = "list"; return 3; }; |
709 | GAA_CHECKSTR("priority", GAAOPTID_priority)if(strcmp("priority",str) == 0) { gaa_current_option = "priority" ; return 4; }; |
710 | GAA_CHECKSTR("srppasswdconf", GAAOPTID_srppasswdconf)if(strcmp("srppasswdconf",str) == 0) { gaa_current_option = "srppasswdconf" ; return 5; }; |
711 | GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd)if(strcmp("srppasswd",str) == 0) { gaa_current_option = "srppasswd" ; return 6; }; |
712 | GAA_CHECKSTR("pskhint", GAAOPTID_pskhint)if(strcmp("pskhint",str) == 0) { gaa_current_option = "pskhint" ; return 7; }; |
713 | GAA_CHECKSTR("pskpasswd", GAAOPTID_pskpasswd)if(strcmp("pskpasswd",str) == 0) { gaa_current_option = "pskpasswd" ; return 8; }; |
714 | GAA_CHECKSTR("disable-client-cert", GAAOPTID_disable_client_cert)if(strcmp("disable-client-cert",str) == 0) { gaa_current_option = "disable-client-cert"; return 9; }; |
715 | GAA_CHECKSTR("require-cert", GAAOPTID_require_cert)if(strcmp("require-cert",str) == 0) { gaa_current_option = "require-cert" ; return 10; }; |
716 | GAA_CHECKSTR("x509ecccertfile", GAAOPTID_x509ecccertfile)if(strcmp("x509ecccertfile",str) == 0) { gaa_current_option = "x509ecccertfile"; return 11; }; |
717 | GAA_CHECKSTR("x509ecckeyfile", GAAOPTID_x509ecckeyfile)if(strcmp("x509ecckeyfile",str) == 0) { gaa_current_option = "x509ecckeyfile" ; return 12; }; |
718 | GAA_CHECKSTR("x509dsacertfile", GAAOPTID_x509dsacertfile)if(strcmp("x509dsacertfile",str) == 0) { gaa_current_option = "x509dsacertfile"; return 13; }; |
719 | GAA_CHECKSTR("x509dsakeyfile", GAAOPTID_x509dsakeyfile)if(strcmp("x509dsakeyfile",str) == 0) { gaa_current_option = "x509dsakeyfile" ; return 14; }; |
720 | GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile)if(strcmp("x509certfile",str) == 0) { gaa_current_option = "x509certfile" ; return 15; }; |
721 | GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile)if(strcmp("x509keyfile",str) == 0) { gaa_current_option = "x509keyfile" ; return 16; }; |
722 | GAA_CHECKSTR("pgpsubkey", GAAOPTID_pgpsubkey)if(strcmp("pgpsubkey",str) == 0) { gaa_current_option = "pgpsubkey" ; return 17; }; |
723 | GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile)if(strcmp("pgpcertfile",str) == 0) { gaa_current_option = "pgpcertfile" ; return 18; }; |
724 | GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile)if(strcmp("pgpkeyfile",str) == 0) { gaa_current_option = "pgpkeyfile" ; return 19; }; |
725 | GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring)if(strcmp("pgpkeyring",str) == 0) { gaa_current_option = "pgpkeyring" ; return 20; }; |
726 | GAA_CHECKSTR("x509crlfile", GAAOPTID_x509crlfile)if(strcmp("x509crlfile",str) == 0) { gaa_current_option = "x509crlfile" ; return 21; }; |
727 | GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile)if(strcmp("x509cafile",str) == 0) { gaa_current_option = "x509cafile" ; return 22; }; |
728 | GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder)if(strcmp("x509fmtder",str) == 0) { gaa_current_option = "x509fmtder" ; return 23; }; |
729 | GAA_CHECKSTR("dhparams", GAAOPTID_dhparams)if(strcmp("dhparams",str) == 0) { gaa_current_option = "dhparams" ; return 24; }; |
730 | GAA_CHECKSTR("mtu", GAAOPTID_mtu)if(strcmp("mtu",str) == 0) { gaa_current_option = "mtu"; return 25; }; |
731 | GAA_CHECKSTR("udp", GAAOPTID_udp)if(strcmp("udp",str) == 0) { gaa_current_option = "udp"; return 26; }; |
732 | GAA_CHECKSTR("echo", GAAOPTID_echo)if(strcmp("echo",str) == 0) { gaa_current_option = "echo"; return 27; }; |
733 | GAA_CHECKSTR("http", GAAOPTID_http)if(strcmp("http",str) == 0) { gaa_current_option = "http"; return 28; }; |
734 | GAA_CHECKSTR("noticket", GAAOPTID_noticket)if(strcmp("noticket",str) == 0) { gaa_current_option = "noticket" ; return 29; }; |
735 | GAA_CHECKSTR("nodb", GAAOPTID_nodb)if(strcmp("nodb",str) == 0) { gaa_current_option = "nodb"; return 30; }; |
736 | GAA_CHECKSTR("quiet", GAAOPTID_quiet)if(strcmp("quiet",str) == 0) { gaa_current_option = "quiet"; return 31; }; |
737 | GAA_CHECKSTR("port", GAAOPTID_port)if(strcmp("port",str) == 0) { gaa_current_option = "port"; return 32; }; |
738 | GAA_CHECKSTR("generate", GAAOPTID_generate)if(strcmp("generate",str) == 0) { gaa_current_option = "generate" ; return 33; }; |
739 | GAA_CHECKSTR("debug", GAAOPTID_debug)if(strcmp("debug",str) == 0) { gaa_current_option = "debug"; return 34; }; |
740 | |
741 | #line 281 "gaa.skel" |
742 | break; |
743 | default: break; |
744 | } |
745 | return GAA_ERROR_NOMATCH0; |
746 | } |
747 | |
748 | static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list) |
749 | { |
750 | int OK = 0; |
751 | int gaa_last_non_option; |
752 | struct GAAOPTION_priority GAATMP_priority; |
753 | struct GAAOPTION_srppasswdconf GAATMP_srppasswdconf; |
754 | struct GAAOPTION_srppasswd GAATMP_srppasswd; |
755 | struct GAAOPTION_pskhint GAATMP_pskhint; |
756 | struct GAAOPTION_pskpasswd GAATMP_pskpasswd; |
757 | struct GAAOPTION_x509ecccertfile GAATMP_x509ecccertfile; |
758 | struct GAAOPTION_x509ecckeyfile GAATMP_x509ecckeyfile; |
759 | struct GAAOPTION_x509dsacertfile GAATMP_x509dsacertfile; |
760 | struct GAAOPTION_x509dsakeyfile GAATMP_x509dsakeyfile; |
761 | struct GAAOPTION_x509certfile GAATMP_x509certfile; |
762 | struct GAAOPTION_x509keyfile GAATMP_x509keyfile; |
763 | struct GAAOPTION_pgpsubkey GAATMP_pgpsubkey; |
764 | struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile; |
765 | struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile; |
766 | struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring; |
767 | struct GAAOPTION_x509crlfile GAATMP_x509crlfile; |
768 | struct GAAOPTION_x509cafile GAATMP_x509cafile; |
769 | struct GAAOPTION_dhparams GAATMP_dhparams; |
770 | struct GAAOPTION_mtu GAATMP_mtu; |
771 | struct GAAOPTION_port GAATMP_port; |
772 | struct GAAOPTION_debug GAATMP_debug; |
773 | |
774 | #line 393 "gaa.skel" |
775 | #ifdef GAA_REST_EXISTS |
776 | struct GAAREST GAAREST_tmp; |
777 | #endif |
778 | |
779 | opt_list[gaa_num] = 1; |
780 | |
781 | for(gaa_last_non_option = gaa_index; |
782 | (gaa_last_non_option != GAAargc) && (gaa_is_an_argument(GAAargv[gaa_last_non_option]) == GAA_NOT_AN_OPTION0); |
783 | gaa_last_non_option++); |
784 | |
785 | if(gaa_num == GAA_REST0) |
786 | { |
787 | gaa_index = 1; |
788 | gaa_last_non_option = GAAargc; |
789 | } |
790 | |
791 | switch(gaa_num) |
792 | { |
793 | case GAAOPTID_version1: |
794 | OK = 0; |
795 | #line 106 "serv.gaa" |
796 | { serv_version(); exit(0); ;}; |
797 | |
798 | return GAA_OK-1; |
799 | break; |
800 | case GAAOPTID_help2: |
801 | OK = 0; |
802 | #line 104 "serv.gaa" |
803 | { gaa_help(); exit(0); ;}; |
804 | |
805 | return GAA_OK-1; |
806 | break; |
807 | case GAAOPTID_list3: |
808 | OK = 0; |
Value stored to 'OK' is never read | |
809 | #line 103 "serv.gaa" |
810 | { print_list(gaaval->priorities, 0); exit(0); ;}; |
811 | |
812 | return GAA_OK-1; |
813 | break; |
814 | case GAAOPTID_priority4: |
815 | OK = 0; |
816 | 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; }; |
817 | GAA_FILL(GAATMP_priority.arg1, gaa_getstr, GAATMP_priority.size1)if(!OK) { GAATMP_priority.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_priority.size1 = 1; } else { GAATMP_priority .size1 = 0; }; |
818 | gaa_index++; |
819 | #line 101 "serv.gaa" |
820 | { gaaval->priorities = GAATMP_priority.arg1 ;}; |
821 | |
822 | return GAA_OK-1; |
823 | break; |
824 | case GAAOPTID_srppasswdconf5: |
825 | OK = 0; |
826 | 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; }; |
827 | GAA_FILL(GAATMP_srppasswdconf.arg1, gaa_getstr, GAATMP_srppasswdconf.size1)if(!OK) { GAATMP_srppasswdconf.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_srppasswdconf.size1 = 1; } else { GAATMP_srppasswdconf .size1 = 0; }; |
828 | gaa_index++; |
829 | #line 98 "serv.gaa" |
830 | { gaaval->srp_passwd_conf = GAATMP_srppasswdconf.arg1 ;}; |
831 | |
832 | return GAA_OK-1; |
833 | break; |
834 | case GAAOPTID_srppasswd6: |
835 | OK = 0; |
836 | 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; }; |
837 | GAA_FILL(GAATMP_srppasswd.arg1, gaa_getstr, GAATMP_srppasswd.size1)if(!OK) { GAATMP_srppasswd.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_srppasswd.size1 = 1; } else { GAATMP_srppasswd .size1 = 0; }; |
838 | gaa_index++; |
839 | #line 95 "serv.gaa" |
840 | { gaaval->srp_passwd = GAATMP_srppasswd.arg1 ;}; |
841 | |
842 | return GAA_OK-1; |
843 | break; |
844 | case GAAOPTID_pskhint7: |
845 | OK = 0; |
846 | 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; }; |
847 | GAA_FILL(GAATMP_pskhint.arg1, gaa_getstr, GAATMP_pskhint.size1)if(!OK) { GAATMP_pskhint.arg1 = gaa_getstr(GAAargv[gaa_index] ); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_pskhint.size1 = 1; } else { GAATMP_pskhint .size1 = 0; }; |
848 | gaa_index++; |
849 | #line 92 "serv.gaa" |
850 | { gaaval->psk_hint = GAATMP_pskhint.arg1 ;}; |
851 | |
852 | return GAA_OK-1; |
853 | break; |
854 | case GAAOPTID_pskpasswd8: |
855 | OK = 0; |
856 | 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; }; |
857 | GAA_FILL(GAATMP_pskpasswd.arg1, gaa_getstr, GAATMP_pskpasswd.size1)if(!OK) { GAATMP_pskpasswd.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_pskpasswd.size1 = 1; } else { GAATMP_pskpasswd .size1 = 0; }; |
858 | gaa_index++; |
859 | #line 89 "serv.gaa" |
860 | { gaaval->psk_passwd = GAATMP_pskpasswd.arg1 ;}; |
861 | |
862 | return GAA_OK-1; |
863 | break; |
864 | case GAAOPTID_disable_client_cert9: |
865 | OK = 0; |
866 | #line 86 "serv.gaa" |
867 | { gaaval->disable_client_cert = 1 ;}; |
868 | |
869 | return GAA_OK-1; |
870 | break; |
871 | case GAAOPTID_require_cert10: |
872 | OK = 0; |
873 | #line 83 "serv.gaa" |
874 | { gaaval->require_cert = 1 ;}; |
875 | |
876 | return GAA_OK-1; |
877 | break; |
878 | case GAAOPTID_x509ecccertfile11: |
879 | OK = 0; |
880 | 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; }; |
881 | GAA_FILL(GAATMP_x509ecccertfile.arg1, gaa_getstr, GAATMP_x509ecccertfile.size1)if(!OK) { GAATMP_x509ecccertfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509ecccertfile.size1 = 1; } else { GAATMP_x509ecccertfile .size1 = 0; }; |
882 | gaa_index++; |
883 | #line 80 "serv.gaa" |
884 | { gaaval->x509_ecccertfile = GAATMP_x509ecccertfile.arg1 ;}; |
885 | |
886 | return GAA_OK-1; |
887 | break; |
888 | case GAAOPTID_x509ecckeyfile12: |
889 | OK = 0; |
890 | 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; }; |
891 | GAA_FILL(GAATMP_x509ecckeyfile.arg1, gaa_getstr, GAATMP_x509ecckeyfile.size1)if(!OK) { GAATMP_x509ecckeyfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509ecckeyfile.size1 = 1; } else { GAATMP_x509ecckeyfile .size1 = 0; }; |
892 | gaa_index++; |
893 | #line 77 "serv.gaa" |
894 | { gaaval->x509_ecckeyfile = GAATMP_x509ecckeyfile.arg1 ;}; |
895 | |
896 | return GAA_OK-1; |
897 | break; |
898 | case GAAOPTID_x509dsacertfile13: |
899 | OK = 0; |
900 | 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; }; |
901 | GAA_FILL(GAATMP_x509dsacertfile.arg1, gaa_getstr, GAATMP_x509dsacertfile.size1)if(!OK) { GAATMP_x509dsacertfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509dsacertfile.size1 = 1; } else { GAATMP_x509dsacertfile .size1 = 0; }; |
902 | gaa_index++; |
903 | #line 74 "serv.gaa" |
904 | { gaaval->x509_dsacertfile = GAATMP_x509dsacertfile.arg1 ;}; |
905 | |
906 | return GAA_OK-1; |
907 | break; |
908 | case GAAOPTID_x509dsakeyfile14: |
909 | OK = 0; |
910 | 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; }; |
911 | GAA_FILL(GAATMP_x509dsakeyfile.arg1, gaa_getstr, GAATMP_x509dsakeyfile.size1)if(!OK) { GAATMP_x509dsakeyfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509dsakeyfile.size1 = 1; } else { GAATMP_x509dsakeyfile .size1 = 0; }; |
912 | gaa_index++; |
913 | #line 71 "serv.gaa" |
914 | { gaaval->x509_dsakeyfile = GAATMP_x509dsakeyfile.arg1 ;}; |
915 | |
916 | return GAA_OK-1; |
917 | break; |
918 | case GAAOPTID_x509certfile15: |
919 | OK = 0; |
920 | 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; }; |
921 | GAA_FILL(GAATMP_x509certfile.arg1, gaa_getstr, GAATMP_x509certfile.size1)if(!OK) { GAATMP_x509certfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509certfile.size1 = 1; } else { GAATMP_x509certfile .size1 = 0; }; |
922 | gaa_index++; |
923 | #line 68 "serv.gaa" |
924 | { gaaval->x509_certfile = GAATMP_x509certfile.arg1 ;}; |
925 | |
926 | return GAA_OK-1; |
927 | break; |
928 | case GAAOPTID_x509keyfile16: |
929 | OK = 0; |
930 | 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; }; |
931 | GAA_FILL(GAATMP_x509keyfile.arg1, gaa_getstr, GAATMP_x509keyfile.size1)if(!OK) { GAATMP_x509keyfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509keyfile.size1 = 1; } else { GAATMP_x509keyfile .size1 = 0; }; |
932 | gaa_index++; |
933 | #line 65 "serv.gaa" |
934 | { gaaval->x509_keyfile = GAATMP_x509keyfile.arg1 ;}; |
935 | |
936 | return GAA_OK-1; |
937 | break; |
938 | case GAAOPTID_pgpsubkey17: |
939 | OK = 0; |
940 | 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; }; |
941 | GAA_FILL(GAATMP_pgpsubkey.arg1, gaa_getstr, GAATMP_pgpsubkey.size1)if(!OK) { GAATMP_pgpsubkey.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_pgpsubkey.size1 = 1; } else { GAATMP_pgpsubkey .size1 = 0; }; |
942 | gaa_index++; |
943 | #line 62 "serv.gaa" |
944 | { gaaval->pgp_subkey = GAATMP_pgpsubkey.arg1 ;}; |
945 | |
946 | return GAA_OK-1; |
947 | break; |
948 | case GAAOPTID_pgpcertfile18: |
949 | OK = 0; |
950 | 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; }; |
951 | GAA_FILL(GAATMP_pgpcertfile.arg1, gaa_getstr, GAATMP_pgpcertfile.size1)if(!OK) { GAATMP_pgpcertfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_pgpcertfile.size1 = 1; } else { GAATMP_pgpcertfile .size1 = 0; }; |
952 | gaa_index++; |
953 | #line 59 "serv.gaa" |
954 | { gaaval->pgp_certfile = GAATMP_pgpcertfile.arg1 ;}; |
955 | |
956 | return GAA_OK-1; |
957 | break; |
958 | case GAAOPTID_pgpkeyfile19: |
959 | OK = 0; |
960 | 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; }; |
961 | GAA_FILL(GAATMP_pgpkeyfile.arg1, gaa_getstr, GAATMP_pgpkeyfile.size1)if(!OK) { GAATMP_pgpkeyfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_pgpkeyfile.size1 = 1; } else { GAATMP_pgpkeyfile .size1 = 0; }; |
962 | gaa_index++; |
963 | #line 56 "serv.gaa" |
964 | { gaaval->pgp_keyfile = GAATMP_pgpkeyfile.arg1 ;}; |
965 | |
966 | return GAA_OK-1; |
967 | break; |
968 | case GAAOPTID_pgpkeyring20: |
969 | OK = 0; |
970 | 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; }; |
971 | GAA_FILL(GAATMP_pgpkeyring.arg1, gaa_getstr, GAATMP_pgpkeyring.size1)if(!OK) { GAATMP_pgpkeyring.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_pgpkeyring.size1 = 1; } else { GAATMP_pgpkeyring .size1 = 0; }; |
972 | gaa_index++; |
973 | #line 53 "serv.gaa" |
974 | { gaaval->pgp_keyring = GAATMP_pgpkeyring.arg1 ;}; |
975 | |
976 | return GAA_OK-1; |
977 | break; |
978 | case GAAOPTID_x509crlfile21: |
979 | OK = 0; |
980 | 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; }; |
981 | GAA_FILL(GAATMP_x509crlfile.arg1, gaa_getstr, GAATMP_x509crlfile.size1)if(!OK) { GAATMP_x509crlfile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509crlfile.size1 = 1; } else { GAATMP_x509crlfile .size1 = 0; }; |
982 | gaa_index++; |
983 | #line 50 "serv.gaa" |
984 | { gaaval->x509_crlfile = GAATMP_x509crlfile.arg1 ;}; |
985 | |
986 | return GAA_OK-1; |
987 | break; |
988 | case GAAOPTID_x509cafile22: |
989 | OK = 0; |
990 | 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; }; |
991 | GAA_FILL(GAATMP_x509cafile.arg1, gaa_getstr, GAATMP_x509cafile.size1)if(!OK) { GAATMP_x509cafile.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_x509cafile.size1 = 1; } else { GAATMP_x509cafile .size1 = 0; }; |
992 | gaa_index++; |
993 | #line 47 "serv.gaa" |
994 | { gaaval->x509_cafile = GAATMP_x509cafile.arg1 ;}; |
995 | |
996 | return GAA_OK-1; |
997 | break; |
998 | case GAAOPTID_x509fmtder23: |
999 | OK = 0; |
1000 | #line 44 "serv.gaa" |
1001 | { gaaval->fmtder = 1 ;}; |
1002 | |
1003 | return GAA_OK-1; |
1004 | break; |
1005 | case GAAOPTID_dhparams24: |
1006 | OK = 0; |
1007 | 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; }; |
1008 | GAA_FILL(GAATMP_dhparams.arg1, gaa_getstr, GAATMP_dhparams.size1)if(!OK) { GAATMP_dhparams.arg1 = gaa_getstr(GAAargv[gaa_index ]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2; } GAATMP_dhparams.size1 = 1; } else { GAATMP_dhparams .size1 = 0; }; |
1009 | gaa_index++; |
1010 | #line 41 "serv.gaa" |
1011 | { gaaval->dh_params_file = GAATMP_dhparams.arg1 ;}; |
1012 | |
1013 | return GAA_OK-1; |
1014 | break; |
1015 | case GAAOPTID_mtu25: |
1016 | OK = 0; |
1017 | 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; }; |
1018 | GAA_FILL(GAATMP_mtu.arg1, gaa_getint, GAATMP_mtu.size1)if(!OK) { GAATMP_mtu.arg1 = gaa_getint(GAAargv[gaa_index]); gaa_arg_used [gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2 ; } GAATMP_mtu.size1 = 1; } else { GAATMP_mtu.size1 = 0; }; |
1019 | gaa_index++; |
1020 | #line 38 "serv.gaa" |
1021 | { gaaval->mtu = GAATMP_mtu.arg1 ;}; |
1022 | |
1023 | return GAA_OK-1; |
1024 | break; |
1025 | case GAAOPTID_udp26: |
1026 | OK = 0; |
1027 | #line 35 "serv.gaa" |
1028 | { gaaval->udp = 1 ;}; |
1029 | |
1030 | return GAA_OK-1; |
1031 | break; |
1032 | case GAAOPTID_echo27: |
1033 | OK = 0; |
1034 | #line 32 "serv.gaa" |
1035 | { gaaval->http = 0 ;}; |
1036 | |
1037 | return GAA_OK-1; |
1038 | break; |
1039 | case GAAOPTID_http28: |
1040 | OK = 0; |
1041 | #line 31 "serv.gaa" |
1042 | { gaaval->http = 1 ;}; |
1043 | |
1044 | return GAA_OK-1; |
1045 | break; |
1046 | case GAAOPTID_noticket29: |
1047 | OK = 0; |
1048 | #line 28 "serv.gaa" |
1049 | { gaaval->noticket = 1 ;}; |
1050 | |
1051 | return GAA_OK-1; |
1052 | break; |
1053 | case GAAOPTID_nodb30: |
1054 | OK = 0; |
1055 | #line 25 "serv.gaa" |
1056 | { gaaval->nodb = 1 ;}; |
1057 | |
1058 | return GAA_OK-1; |
1059 | break; |
1060 | case GAAOPTID_quiet31: |
1061 | OK = 0; |
1062 | #line 22 "serv.gaa" |
1063 | { gaaval->quiet = 1 ;}; |
1064 | |
1065 | return GAA_OK-1; |
1066 | break; |
1067 | case GAAOPTID_port32: |
1068 | OK = 0; |
1069 | 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; }; |
1070 | 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; }; |
1071 | gaa_index++; |
1072 | #line 19 "serv.gaa" |
1073 | { gaaval->port = GAATMP_port.arg1 ;}; |
1074 | |
1075 | return GAA_OK-1; |
1076 | break; |
1077 | case GAAOPTID_generate33: |
1078 | OK = 0; |
1079 | #line 16 "serv.gaa" |
1080 | { gaaval->generate = 1 ;}; |
1081 | |
1082 | return GAA_OK-1; |
1083 | break; |
1084 | case GAAOPTID_debug34: |
1085 | OK = 0; |
1086 | 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; }; |
1087 | 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; }; |
1088 | gaa_index++; |
1089 | #line 13 "serv.gaa" |
1090 | { gaaval->debug = GAATMP_debug.arg1 ;}; |
1091 | |
1092 | return GAA_OK-1; |
1093 | break; |
1094 | |
1095 | #line 413 "gaa.skel" |
1096 | default: break; |
1097 | } |
1098 | return GAA_ERROR_UNKNOWN3; |
1099 | } |
1100 | |
1101 | int gaa(int argc, char **argv, gaainfo *gaaval) |
1102 | { |
1103 | int tmp1, tmp2; |
1104 | int i, j, k; |
1105 | char *opt_list; |
1106 | |
1107 | GAAargv = argv; |
1108 | GAAargc = argc; |
1109 | |
1110 | opt_list = (char*) gaa_malloc(GAA_NB_OPTION34 + 1); |
1111 | |
1112 | for(i = 0; i < GAA_NB_OPTION34 + 1; i++) |
1113 | opt_list[i] = 0; |
1114 | /* initialization */ |
1115 | if(inited == 0) |
1116 | { |
1117 | |
1118 | #line 110 "serv.gaa" |
1119 | { gaaval->generate=0; gaaval->port=5556; gaaval->http=0; gaaval->nodb = 0; gaaval->noticket = 0; |
1120 | gaaval->x509_cafile = NULL((void*)0); gaaval->pgp_keyfile=NULL((void*)0); gaaval->pgp_certfile=NULL((void*)0); |
1121 | gaaval->x509_keyfile=NULL((void*)0); gaaval->x509_certfile=NULL((void*)0); gaaval->x509_crlfile = NULL((void*)0); |
1122 | gaaval->x509_dsakeyfile=NULL((void*)0); gaaval->x509_dsacertfile=NULL((void*)0); |
1123 | gaaval->x509_ecckeyfile=NULL((void*)0); gaaval->x509_ecccertfile=NULL((void*)0); |
1124 | gaaval->srp_passwd=NULL((void*)0); gaaval->srp_passwd_conf=NULL((void*)0); gaaval->quiet = 0; |
1125 | gaaval->pgp_keyring=NULL((void*)0); gaaval->fmtder = 0; |
1126 | gaaval->disable_client_cert = 0; gaaval->priorities = NULL((void*)0); |
1127 | gaaval->dh_params_file=NULL((void*)0); gaaval->debug=0; gaaval->require_cert = 0; gaaval->psk_passwd = 0; |
1128 | gaaval->pgp_subkey = NULL((void*)0); gaaval->udp = 0; gaaval->mtu = 1300; ;}; |
1129 | |
1130 | } |
1131 | inited = 1; |
1132 | #line 438 "gaa.skel" |
1133 | gaa_arg_used = NULL((void*)0); |
1134 | |
1135 | if (argc > 0) { |
1136 | gaa_arg_used = gaa_malloc(argc * sizeof(char)); |
1137 | } |
1138 | |
1139 | for(i = 1; i < argc; i++) |
1140 | gaa_arg_used[i] = 0; |
1141 | for(i = 1; i < argc; i++) |
1142 | { |
1143 | if(gaa_arg_used[i] == 0) |
1144 | { |
1145 | j = 0; |
1146 | tmp1 = gaa_is_an_argument(GAAargv[i]); |
1147 | switch(tmp1) |
1148 | { |
1149 | case GAA_WORD_OPTION1: |
1150 | j++; |
1151 | case GAA_LETTER_OPTION2: |
1152 | j++; |
1153 | tmp2 = gaa_get_option_num(argv[i]+j, tmp1); |
1154 | if(tmp2 == GAA_ERROR_NOMATCH0) |
1155 | { |
1156 | printf("Invalid option '%s'\n", argv[i]+j); |
1157 | return 0; |
1158 | } |
1159 | switch(gaa_try(tmp2, i+1, gaaval, opt_list)) |
1160 | { |
1161 | case GAA_ERROR_NOTENOUGH_ARGS1: |
1162 | printf("'%s': not enough arguments\n",gaa_current_option); |
1163 | return 0; |
1164 | case GAA_ERROR_INVALID_ARG2: |
1165 | printf("Invalid arguments\n"); |
1166 | return 0; |
1167 | case GAA_OK-1: |
1168 | break; |
1169 | default: |
1170 | printf("Unknown error\n"); |
1171 | } |
1172 | gaa_arg_used[i] = 1; |
1173 | break; |
1174 | case GAA_MULTIPLE_OPTION3: |
1175 | for(j = 1; j < strlen(argv[i]); j++) |
1176 | { |
1177 | tmp2 = gaa_get_option_num(argv[i]+j, tmp1); |
1178 | if(tmp2 == GAA_ERROR_NOMATCH0) |
1179 | { |
1180 | printf("Invalid option '%c'\n", *(argv[i]+j)); |
1181 | return 0; |
1182 | } |
1183 | switch(gaa_try(tmp2, i+1, gaaval, opt_list)) |
1184 | { |
1185 | case GAA_ERROR_NOTENOUGH_ARGS1: |
1186 | printf("'%s': not enough arguments\n",gaa_current_option); |
1187 | return 0; |
1188 | case GAA_ERROR_INVALID_ARG2: |
1189 | printf("Invalid arguments\n"); |
1190 | return 0; |
1191 | case GAA_OK-1: |
1192 | break; |
1193 | default: |
1194 | printf("Unknown error\n"); |
1195 | } |
1196 | } |
1197 | gaa_arg_used[i] = 1; |
1198 | break; |
1199 | default: break; |
1200 | } |
1201 | } |
1202 | } |
1203 | if(gaa_processing_file == 0) |
1204 | { |
1205 | GAA_INCOMP("ra")k = 0; for(i = 0; i < strlen("ra"); i++) { j = gaa_get_option_num ("ra" + 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", "ra"); return 0; }; |
1206 | |
1207 | #line 507 "gaa.skel" |
1208 | #ifdef GAA_REST_EXISTS |
1209 | switch(gaa_try(GAA_REST0, 1, gaaval, opt_list)) |
1210 | { |
1211 | case GAA_ERROR_NOTENOUGH_ARGS1: |
1212 | printf("Rest: not enough arguments\n"); |
1213 | return 0; |
1214 | case GAA_ERROR_INVALID_ARG2: |
1215 | printf("Invalid arguments\n"); |
1216 | return 0; |
1217 | case GAA_OK-1: |
1218 | break; |
1219 | default: |
1220 | printf("Unknown error\n"); |
1221 | } |
1222 | #endif |
1223 | } |
1224 | for(i = 1; i < argc; i++) |
1225 | { |
1226 | if(gaa_arg_used[i] == 0) |
1227 | { |
1228 | printf("Too many arguments\n"); |
1229 | return 0; |
1230 | } |
1231 | } |
1232 | free(gaa_arg_used); |
1233 | free(opt_list); |
1234 | return -1; |
1235 | } |
1236 | |
1237 | struct gaastrnode |
1238 | { |
1239 | char *str; |
1240 | struct gaastrnode *next; |
1241 | }; |
1242 | |
1243 | typedef struct gaastrnode gaa_str_node; |
1244 | |
1245 | static int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc) |
1246 | { |
1247 | int pos_ini; |
1248 | int a; |
1249 | int i = 0, len = 0, newline = 0; |
1250 | |
1251 | if(argc == 1) { |
1252 | newline = 1; |
1253 | len = 2; |
1254 | } |
1255 | |
1256 | a = fgetc( file); |
1257 | if (a == EOF(-1)) return 0; |
1258 | |
1259 | while(a == ' ' || a == 9 || a == '\n') |
1260 | { |
1261 | if(a == '\n') |
1262 | { |
1263 | newline=1; |
1264 | len = 2; |
1265 | } |
1266 | a = fgetc( file); |
1267 | if (a == EOF(-1)) return 0; |
1268 | } |
1269 | |
1270 | pos_ini = ftell(file) - 1; |
1271 | |
1272 | while(a != ' ' && a != 9 && a != '\n') |
1273 | { |
1274 | |
1275 | len++; |
1276 | a = fgetc( file); |
1277 | if(a==EOF(-1)) return 0; |
1278 | } |
1279 | |
1280 | len += 1; |
1281 | tmp_str->str = gaa_malloc((len) * sizeof(char)); |
1282 | |
1283 | if(newline == 1) |
1284 | { |
1285 | tmp_str->str[0] = '-'; |
1286 | tmp_str->str[1] = '-'; |
1287 | i = 2; |
1288 | } |
1289 | else |
1290 | { |
1291 | i = 0; |
1292 | } |
1293 | |
1294 | fseek(file,pos_ini, SEEK_SET0); |
1295 | do |
1296 | { |
1297 | a = fgetc( file); |
1298 | |
1299 | if (a == EOF(-1)) { |
1300 | i+=2; |
1301 | break; |
1302 | } |
1303 | tmp_str->str[i] = a; |
1304 | i++; |
1305 | } |
1306 | while(a != ' ' && a != 9 && a != '\n' && i < len); |
1307 | |
1308 | tmp_str->str[i - 1] = 0; |
1309 | |
1310 | fseek(file,- 1, SEEK_CUR1); |
1311 | /* printf("%d\n", ftell(file)); */ |
1312 | |
1313 | return -1; |
1314 | } |
1315 | |
1316 | int gaa_file(const char *name, gaainfo *gaaval) |
1317 | { |
1318 | gaa_str_node *first_str, **tmp_str, *tmp_str2; |
1319 | int rval, i; |
1320 | char **argv; |
1321 | int argc = 0; |
1322 | FILE *file; |
1323 | |
1324 | gaa_processing_file = 1; |
1325 | |
1326 | if((file = fopen(name, "r")) == NULL((void*)0)) |
1327 | { |
1328 | printf("Couldn't open '%s' configuration file for reading\n", name); |
1329 | return 1; |
1330 | } |
1331 | |
1332 | tmp_str = &first_str; |
1333 | do |
1334 | { |
1335 | argc++; |
1336 | *tmp_str = gaa_malloc(sizeof(gaa_str_node)); |
1337 | |
1338 | (*tmp_str)->str = NULL((void*)0); |
1339 | (*tmp_str)->next = NULL((void*)0); |
1340 | |
1341 | rval = gaa_internal_get_next_str(file, *tmp_str, argc); |
1342 | tmp_str = &((*tmp_str)->next); |
1343 | } |
1344 | while(rval == -1); |
1345 | |
1346 | if(rval == 1) |
1347 | return 0; |
1348 | |
1349 | argv = gaa_malloc((1 + argc) * sizeof(char*)); |
1350 | |
1351 | tmp_str2 = first_str; |
1352 | argv[0] = "cfg"; |
1353 | for(i = 1; i < argc; i++) |
1354 | { |
1355 | argv[i] = tmp_str2->str; |
1356 | tmp_str2 = tmp_str2->next; |
1357 | } |
1358 | |
1359 | rval = gaa(argc, argv, gaaval); |
1360 | gaa_processing_file = 0; |
1361 | return rval; |
1362 | } |