Bug Summary

File:src/srptool-gaa.c
Location:line 577, column 3
Description:Value stored to 'gaa_index' is never read

Annotated Source Code

1/* File generated by GAA 1.6.6
2 */
3#define GAA_NO_WIN32
4#line 1 "srptool.gaa"
5
6
7/* C declarations */
8
9#include <config.h>
10#ifdef _WIN32
11# include <io.h>
12#endif
13
14void srptool_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
26static void* gaa_malloc( size_t size) {
27void* 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
36static 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
129void gaa_help(void)
130{
131 printf("Srptool help\nUsage : srptool [options]\n");
132 __gaa_helpsingle('d', "debug", "integer ", "Enable debugging");
133 __gaa_helpsingle('u', "username", "username ", "specify username.");
134 __gaa_helpsingle('p', "passwd", "FILE ", "specify a password file.");
135 __gaa_helpsingle('i', "index", "INDEX ", "specify the index of the group parameters in tpasswd.conf to use.");
136 __gaa_helpsingle('s', "salt", "SALT ", "specify salt size for crypt algorithm.");
137 __gaa_helpsingle(0, "verify", "", "just verify password.");
138 __gaa_helpsingle('c', "passwd-conf", "FILE ", "specify a password conf file.");
139 __gaa_helpsingle(0, "create-conf", "FILE ", "Generate a tpasswd.conf file.");
140 __gaa_helpsingle('v', "version", "", "prints the program's version number");
141 __gaa_helpsingle('h', "help", "", "shows this help text");
142
143#line 100 "gaa.skel"
144}
145/* Copy of C area */
146
147#line 104 "gaa.skel"
148/* GAA HEADER */
149#ifndef GAA_HEADER_POKY
150#define GAA_HEADER_POKY
151
152typedef struct _gaainfo gaainfo;
153
154struct _gaainfo
155{
156#line 37 "srptool.gaa"
157 char *create_conf;
158#line 34 "srptool.gaa"
159 char *passwd_conf;
160#line 31 "srptool.gaa"
161 int verify;
162#line 28 "srptool.gaa"
163 int salt;
164#line 25 "srptool.gaa"
165 int index;
166#line 22 "srptool.gaa"
167 char *passwd;
168#line 19 "srptool.gaa"
169 char *username;
170#line 16 "srptool.gaa"
171 int debug;
172
173#line 114 "gaa.skel"
174};
175
176#ifdef __cplusplus
177extern "C"
178{
179#endif
180
181 int gaa(int argc, char *argv[], gaainfo *gaaval);
182
183 void gaa_help(void);
184
185 int gaa_file(const char *name, gaainfo *gaaval);
186
187#ifdef __cplusplus
188}
189#endif
190
191
192#endif
193
194#line 135 "gaa.skel"
195
196/* C declarations */
197
198#define GAAERROR(x){ gaa_error = 1; return x; } \
199{ \
200gaa_error = 1; \
201return x; \
202}
203
204static char *gaa_current_option;
205static int gaa_error = 0;
206
207/* Generated by gaa */
208
209#include <string.h>
210#include <stdlib.h>
211
212
213#define GAA_OK-1 -1
214
215#define GAA_ERROR_NOMATCH0 0
216#define GAA_ERROR_NOTENOUGH_ARGS1 1
217#define GAA_ERROR_INVALID_ARG2 2
218#define GAA_ERROR_UNKNOWN3 3
219
220#define GAA_NOT_AN_OPTION0 0
221#define GAA_WORD_OPTION1 1
222#define GAA_LETTER_OPTION2 2
223#define GAA_MULTIPLE_OPTION3 3
224
225#define GAA_REST0 0
226#define GAA_NB_OPTION10 10
227#define GAAOPTID_help1 1
228#define GAAOPTID_version2 2
229#define GAAOPTID_create_conf3 3
230#define GAAOPTID_passwd_conf4 4
231#define GAAOPTID_verify5 5
232#define GAAOPTID_salt6 6
233#define GAAOPTID_index7 7
234#define GAAOPTID_passwd8 8
235#define GAAOPTID_username9 9
236#define GAAOPTID_debug10 10
237
238#line 168 "gaa.skel"
239
240#define GAA_CHECK1STR(a,b)if(a[0] == str[0]) { gaa_current_option = a; return b; } \
241if(a[0] == str[0]) \
242{ \
243 gaa_current_option = a; \
244 return b; \
245}
246
247#define GAA_CHECKSTR(a,b)if(strcmp(a,str) == 0) { gaa_current_option = a; return b; } \
248if(strcmp(a,str) == 0) \
249{ \
250 gaa_current_option = a; \
251 return b; \
252}
253
254#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; }
\
255if(!OK) \
256{ \
257while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
258 gaa_index++; \
259if(gaa_last_non_option == gaa_index) \
260 return GAA_ERROR_NOTENOUGH_ARGS1; \
261}
262
263#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; }
\
264if(!OK) \
265{ \
266while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
267 gaa_index++; \
268if(gaa_last_non_option == gaa_index) \
269 OK = 1; \
270}
271
272#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; }
\
273target = func(GAAargv[gaa_index]); \
274gaa_arg_used[gaa_index] = 1; \
275if(gaa_error == 1) \
276{ \
277 gaa_error = 0; \
278 return GAA_ERROR_INVALID_ARG2; \
279}
280
281
282
283#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; }
\
284if(!OK) \
285{ \
286target = func(GAAargv[gaa_index]); \
287gaa_arg_used[gaa_index] = 1; \
288if(gaa_error == 1) \
289{ \
290 gaa_error = 0; \
291 return GAA_ERROR_INVALID_ARG2; \
292} \
293num = 1; \
294} \
295else \
296{ \
297num = 0; \
298}
299
300#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; }
\
301if(!OK) \
302{ \
303num = 0; \
304target = NULL((void*)0); \
305if ( gaa_last_non_option - gaa_index > 0) \
306 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
307for(; gaa_index < gaa_last_non_option; gaa_index++) \
308{ \
309 if(gaa_arg_used[gaa_index] == 0) \
310 { \
311 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; }
; \
312 num++; \
313 } \
314} \
315if(num == 0) \
316 return GAA_ERROR_NOTENOUGH_ARGS1; \
317}
318
319#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++; } } }
\
320if(!OK) \
321{ \
322num = 0; \
323target = NULL((void*)0); \
324if ( gaa_last_non_option - gaa_index > 0) \
325 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
326for(; gaa_index < gaa_last_non_option; gaa_index++) \
327{ \
328 if(gaa_arg_used[gaa_index] == 0) \
329 { \
330 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; }
; \
331 num++; \
332 } \
333} \
334}
335
336#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; }
\
337k = 0; \
338for(i = 0; i < strlen(str); i++) \
339{ \
340 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \
341 if(j == GAA_ERROR_NOMATCH0) \
342 { \
343 printf("Error: invalid 'obligat' set\n"); \
344 exit(-1); \
345 } \
346 if(opt_list[j] == 1) \
347 k = 1; \
348} \
349if(k == 0) \
350{ \
351 if(strlen(str) == 1) \
352 printf("You must give the -%s option\n", str); \
353 else \
354 printf("You must give at least one option of '%s'\n", str); \
355 return 0; \
356}
357
358#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; }
\
359k = 0; \
360for(i = 0; i < strlen(str); i++) \
361{ \
362 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \
363 if(j == GAA_ERROR_NOMATCH0) \
364 { \
365 printf("Error: invalid 'obligat' set\n"); \
366 exit(-1); \
367 } \
368 if(opt_list[j] == 1) \
369 k++; \
370} \
371if(k > 1) \
372{ \
373 printf("The options '%s' are incompatible\n", str); \
374 return 0; \
375}
376
377
378static char **GAAargv;
379static int GAAargc;
380static char *gaa_arg_used;
381static int gaa_processing_file = 0;
382static int inited = 0;
383
384static int gaa_getint(char *arg)
385{
386 int tmp;
387 char a;
388 if(sscanf(arg, "%d%c", &tmp, &a) < 1)
389 {
390 printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg);
391 GAAERROR(-1){ gaa_error = 1; return -1; };
392 }
393 return tmp;
394}
395
396static char gaa_getchar(char *arg)
397{
398 if(strlen(arg) != 1)
399 {
400 printf("Option %s: '%s' isn't an character\n", gaa_current_option, arg);
401 GAAERROR(-1){ gaa_error = 1; return -1; };
402 }
403 return arg[0];
404}
405
406static char* gaa_getstr(char *arg)
407{
408 return arg;
409}
410static float gaa_getfloat(char *arg)
411{
412 float tmp;
413 char a;
414 if(sscanf(arg, "%f%c", &tmp, &a) < 1)
415 {
416 printf("Option %s: '%s' isn't a float number\n", gaa_current_option, arg);
417 GAAERROR(-1){ gaa_error = 1; return -1; };
418 }
419 return tmp;
420}
421/* option structures */
422
423struct GAAOPTION_create_conf
424{
425 char* arg1;
426 int size1;
427};
428
429struct GAAOPTION_passwd_conf
430{
431 char* arg1;
432 int size1;
433};
434
435struct GAAOPTION_salt
436{
437 int arg1;
438 int size1;
439};
440
441struct GAAOPTION_index
442{
443 int arg1;
444 int size1;
445};
446
447struct GAAOPTION_passwd
448{
449 char* arg1;
450 int size1;
451};
452
453struct GAAOPTION_username
454{
455 char* arg1;
456 int size1;
457};
458
459struct GAAOPTION_debug
460{
461 int arg1;
462 int size1;
463};
464
465#line 349 "gaa.skel"
466static int gaa_is_an_argument(char *str)
467{
468#ifdef GAA_WIN32
469 if(str[0] == '/' && str[1] != 0)
470 return GAA_MULTIPLE_OPTION3;
471#endif
472 if(str[0] != '-')
473 return GAA_NOT_AN_OPTION0;
474 if(str[1] == 0)
475 return GAA_NOT_AN_OPTION0;
476 if(str[1] == '-')
477 {
478 if(str[2] != 0)
479 return GAA_WORD_OPTION1;
480 else
481 return GAA_NOT_AN_OPTION0;
482 }
483 if(str[2] == 0)
484 return GAA_LETTER_OPTION2;
485 else
486 return GAA_MULTIPLE_OPTION3;
487}
488
489static int gaa_get_option_num(char *str, int status)
490{
491 switch(status)
492 {
493 case GAA_LETTER_OPTION2:
494 GAA_CHECK1STR("", GAAOPTID_create_conf)if(""[0] == str[0]) { gaa_current_option = ""; return 3; };
495 GAA_CHECK1STR("c", GAAOPTID_passwd_conf)if("c"[0] == str[0]) { gaa_current_option = "c"; return 4; };
496 GAA_CHECK1STR("s", GAAOPTID_salt)if("s"[0] == str[0]) { gaa_current_option = "s"; return 6; };
497 GAA_CHECK1STR("i", GAAOPTID_index)if("i"[0] == str[0]) { gaa_current_option = "i"; return 7; };
498 GAA_CHECK1STR("p", GAAOPTID_passwd)if("p"[0] == str[0]) { gaa_current_option = "p"; return 8; };
499 GAA_CHECK1STR("u", GAAOPTID_username)if("u"[0] == str[0]) { gaa_current_option = "u"; return 9; };
500 GAA_CHECK1STR("d", GAAOPTID_debug)if("d"[0] == str[0]) { gaa_current_option = "d"; return 10; };
501 case GAA_MULTIPLE_OPTION3:
502#line 375 "gaa.skel"
503 GAA_CHECK1STR("h", GAAOPTID_help)if("h"[0] == str[0]) { gaa_current_option = "h"; return 1; };
504 GAA_CHECK1STR("v", GAAOPTID_version)if("v"[0] == str[0]) { gaa_current_option = "v"; return 2; };
505 GAA_CHECK1STR("", GAAOPTID_verify)if(""[0] == str[0]) { gaa_current_option = ""; return 5; };
506
507#line 277 "gaa.skel"
508 break;
509 case GAA_WORD_OPTION1:
510 GAA_CHECKSTR("help", GAAOPTID_help)if(strcmp("help",str) == 0) { gaa_current_option = "help"; return
1; }
;
511 GAA_CHECKSTR("version", GAAOPTID_version)if(strcmp("version",str) == 0) { gaa_current_option = "version"
; return 2; }
;
512 GAA_CHECKSTR("create-conf", GAAOPTID_create_conf)if(strcmp("create-conf",str) == 0) { gaa_current_option = "create-conf"
; return 3; }
;
513 GAA_CHECKSTR("passwd-conf", GAAOPTID_passwd_conf)if(strcmp("passwd-conf",str) == 0) { gaa_current_option = "passwd-conf"
; return 4; }
;
514 GAA_CHECKSTR("verify", GAAOPTID_verify)if(strcmp("verify",str) == 0) { gaa_current_option = "verify"
; return 5; }
;
515 GAA_CHECKSTR("salt", GAAOPTID_salt)if(strcmp("salt",str) == 0) { gaa_current_option = "salt"; return
6; }
;
516 GAA_CHECKSTR("index", GAAOPTID_index)if(strcmp("index",str) == 0) { gaa_current_option = "index"; return
7; }
;
517 GAA_CHECKSTR("passwd", GAAOPTID_passwd)if(strcmp("passwd",str) == 0) { gaa_current_option = "passwd"
; return 8; }
;
518 GAA_CHECKSTR("username", GAAOPTID_username)if(strcmp("username",str) == 0) { gaa_current_option = "username"
; return 9; }
;
519 GAA_CHECKSTR("debug", GAAOPTID_debug)if(strcmp("debug",str) == 0) { gaa_current_option = "debug"; return
10; }
;
520
521#line 281 "gaa.skel"
522 break;
523 default: break;
524 }
525 return GAA_ERROR_NOMATCH0;
526}
527
528static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
529{
530 int OK = 0;
531 int gaa_last_non_option;
532 struct GAAOPTION_create_conf GAATMP_create_conf;
533 struct GAAOPTION_passwd_conf GAATMP_passwd_conf;
534 struct GAAOPTION_salt GAATMP_salt;
535 struct GAAOPTION_index GAATMP_index;
536 struct GAAOPTION_passwd GAATMP_passwd;
537 struct GAAOPTION_username GAATMP_username;
538 struct GAAOPTION_debug GAATMP_debug;
539
540#line 393 "gaa.skel"
541#ifdef GAA_REST_EXISTS
542 struct GAAREST GAAREST_tmp;
543#endif
544
545 opt_list[gaa_num] = 1;
546
547 for(gaa_last_non_option = gaa_index;
548 (gaa_last_non_option != GAAargc) && (gaa_is_an_argument(GAAargv[gaa_last_non_option]) == GAA_NOT_AN_OPTION0);
549 gaa_last_non_option++);
550
551 if(gaa_num == GAA_REST0)
552 {
553 gaa_index = 1;
554 gaa_last_non_option = GAAargc;
555 }
556
557 switch(gaa_num)
558 {
559 case GAAOPTID_help1:
560 OK = 0;
561#line 41 "srptool.gaa"
562{ gaa_help(); exit(0); ;};
563
564 return GAA_OK-1;
565 break;
566 case GAAOPTID_version2:
567 OK = 0;
568#line 40 "srptool.gaa"
569{ srptool_version(); exit(0); ;};
570
571 return GAA_OK-1;
572 break;
573 case GAAOPTID_create_conf3:
574 OK = 0;
575 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; }
;
576 GAA_FILL(GAATMP_create_conf.arg1, gaa_getstr, GAATMP_create_conf.size1)if(!OK) { GAATMP_create_conf.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_create_conf.size1 = 1; } else { GAATMP_create_conf
.size1 = 0; }
;
577 gaa_index++;
Value stored to 'gaa_index' is never read
578#line 38 "srptool.gaa"
579{ gaaval->create_conf = GAATMP_create_conf.arg1 ;};
580
581 return GAA_OK-1;
582 break;
583 case GAAOPTID_passwd_conf4:
584 OK = 0;
585 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; }
;
586 GAA_FILL(GAATMP_passwd_conf.arg1, gaa_getstr, GAATMP_passwd_conf.size1)if(!OK) { GAATMP_passwd_conf.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_passwd_conf.size1 = 1; } else { GAATMP_passwd_conf
.size1 = 0; }
;
587 gaa_index++;
588#line 35 "srptool.gaa"
589{ gaaval->passwd_conf = GAATMP_passwd_conf.arg1 ;};
590
591 return GAA_OK-1;
592 break;
593 case GAAOPTID_verify5:
594 OK = 0;
595#line 32 "srptool.gaa"
596{ gaaval->verify = 1 ;};
597
598 return GAA_OK-1;
599 break;
600 case GAAOPTID_salt6:
601 OK = 0;
602 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; }
;
603 GAA_FILL(GAATMP_salt.arg1, gaa_getint, GAATMP_salt.size1)if(!OK) { GAATMP_salt.arg1 = gaa_getint(GAAargv[gaa_index]); gaa_arg_used
[gaa_index] = 1; if(gaa_error == 1) { gaa_error = 0; return 2
; } GAATMP_salt.size1 = 1; } else { GAATMP_salt.size1 = 0; }
;
604 gaa_index++;
605#line 29 "srptool.gaa"
606{ gaaval->salt = GAATMP_salt.arg1 ;};
607
608 return GAA_OK-1;
609 break;
610 case GAAOPTID_index7:
611 OK = 0;
612 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; }
;
613 GAA_FILL(GAATMP_index.arg1, gaa_getint, GAATMP_index.size1)if(!OK) { GAATMP_index.arg1 = gaa_getint(GAAargv[gaa_index]);
gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error =
0; return 2; } GAATMP_index.size1 = 1; } else { GAATMP_index
.size1 = 0; }
;
614 gaa_index++;
615#line 26 "srptool.gaa"
616{ gaaval->index = GAATMP_index.arg1 ;};
617
618 return GAA_OK-1;
619 break;
620 case GAAOPTID_passwd8:
621 OK = 0;
622 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; }
;
623 GAA_FILL(GAATMP_passwd.arg1, gaa_getstr, GAATMP_passwd.size1)if(!OK) { GAATMP_passwd.arg1 = gaa_getstr(GAAargv[gaa_index])
; gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_passwd.size1 = 1; } else { GAATMP_passwd
.size1 = 0; }
;
624 gaa_index++;
625#line 23 "srptool.gaa"
626{ gaaval->passwd = GAATMP_passwd.arg1 ;};
627
628 return GAA_OK-1;
629 break;
630 case GAAOPTID_username9:
631 OK = 0;
632 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; }
;
633 GAA_FILL(GAATMP_username.arg1, gaa_getstr, GAATMP_username.size1)if(!OK) { GAATMP_username.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_username.size1 = 1; } else { GAATMP_username
.size1 = 0; }
;
634 gaa_index++;
635#line 20 "srptool.gaa"
636{ gaaval->username = GAATMP_username.arg1 ;};
637
638 return GAA_OK-1;
639 break;
640 case GAAOPTID_debug10:
641 OK = 0;
642 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; }
;
643 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; }
;
644 gaa_index++;
645#line 17 "srptool.gaa"
646{ gaaval->debug = GAATMP_debug.arg1 ;};
647
648 return GAA_OK-1;
649 break;
650
651#line 413 "gaa.skel"
652 default: break;
653 }
654 return GAA_ERROR_UNKNOWN3;
655}
656
657int gaa(int argc, char **argv, gaainfo *gaaval)
658{
659 int tmp1, tmp2;
660 int i, j;
661 char *opt_list;
662
663 GAAargv = argv;
664 GAAargc = argc;
665
666 opt_list = (char*) gaa_malloc(GAA_NB_OPTION10 + 1);
667
668 for(i = 0; i < GAA_NB_OPTION10 + 1; i++)
669 opt_list[i] = 0;
670 /* initialization */
671 if(inited == 0)
672 {
673
674#line 43 "srptool.gaa"
675{ gaaval->username=NULL((void*)0); gaaval->passwd=NULL((void*)0); gaaval->salt=0;
676 gaaval->create_conf=NULL((void*)0); gaaval->passwd_conf=NULL((void*)0); gaaval->verify = 0;
677 gaaval->index = 1; gaaval->debug = 0; ;};
678
679 }
680 inited = 1;
681#line 438 "gaa.skel"
682 gaa_arg_used = NULL((void*)0);
683
684 if (argc > 0) {
685 gaa_arg_used = gaa_malloc(argc * sizeof(char));
686 }
687
688 for(i = 1; i < argc; i++)
689 gaa_arg_used[i] = 0;
690 for(i = 1; i < argc; i++)
691 {
692 if(gaa_arg_used[i] == 0)
693 {
694 j = 0;
695 tmp1 = gaa_is_an_argument(GAAargv[i]);
696 switch(tmp1)
697 {
698 case GAA_WORD_OPTION1:
699 j++;
700 case GAA_LETTER_OPTION2:
701 j++;
702 tmp2 = gaa_get_option_num(argv[i]+j, tmp1);
703 if(tmp2 == GAA_ERROR_NOMATCH0)
704 {
705 printf("Invalid option '%s'\n", argv[i]+j);
706 return 0;
707 }
708 switch(gaa_try(tmp2, i+1, gaaval, opt_list))
709 {
710 case GAA_ERROR_NOTENOUGH_ARGS1:
711 printf("'%s': not enough arguments\n",gaa_current_option);
712 return 0;
713 case GAA_ERROR_INVALID_ARG2:
714 printf("Invalid arguments\n");
715 return 0;
716 case GAA_OK-1:
717 break;
718 default:
719 printf("Unknown error\n");
720 }
721 gaa_arg_used[i] = 1;
722 break;
723 case GAA_MULTIPLE_OPTION3:
724 for(j = 1; j < strlen(argv[i]); j++)
725 {
726 tmp2 = gaa_get_option_num(argv[i]+j, tmp1);
727 if(tmp2 == GAA_ERROR_NOMATCH0)
728 {
729 printf("Invalid option '%c'\n", *(argv[i]+j));
730 return 0;
731 }
732 switch(gaa_try(tmp2, i+1, gaaval, opt_list))
733 {
734 case GAA_ERROR_NOTENOUGH_ARGS1:
735 printf("'%s': not enough arguments\n",gaa_current_option);
736 return 0;
737 case GAA_ERROR_INVALID_ARG2:
738 printf("Invalid arguments\n");
739 return 0;
740 case GAA_OK-1:
741 break;
742 default:
743 printf("Unknown error\n");
744 }
745 }
746 gaa_arg_used[i] = 1;
747 break;
748 default: break;
749 }
750 }
751 }
752if(gaa_processing_file == 0)
753{
754
755#line 507 "gaa.skel"
756#ifdef GAA_REST_EXISTS
757 switch(gaa_try(GAA_REST0, 1, gaaval, opt_list))
758 {
759 case GAA_ERROR_NOTENOUGH_ARGS1:
760 printf("Rest: not enough arguments\n");
761 return 0;
762 case GAA_ERROR_INVALID_ARG2:
763 printf("Invalid arguments\n");
764 return 0;
765 case GAA_OK-1:
766 break;
767 default:
768 printf("Unknown error\n");
769 }
770#endif
771}
772 for(i = 1; i < argc; i++)
773 {
774 if(gaa_arg_used[i] == 0)
775 {
776 printf("Too many arguments\n");
777 return 0;
778 }
779 }
780 free(gaa_arg_used);
781 free(opt_list);
782 return -1;
783}
784
785struct gaastrnode
786{
787 char *str;
788 struct gaastrnode *next;
789};
790
791typedef struct gaastrnode gaa_str_node;
792
793static int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
794{
795 int pos_ini;
796 int a;
797 int i = 0, len = 0, newline = 0;
798
799 if(argc == 1) {
800 newline = 1;
801 len = 2;
802 }
803
804 a = fgetc( file);
805 if (a == EOF(-1)) return 0;
806
807 while(a == ' ' || a == 9 || a == '\n')
808 {
809 if(a == '\n')
810 {
811 newline=1;
812 len = 2;
813 }
814 a = fgetc( file);
815 if (a == EOF(-1)) return 0;
816 }
817
818 pos_ini = ftell(file) - 1;
819
820 while(a != ' ' && a != 9 && a != '\n')
821 {
822
823 len++;
824 a = fgetc( file);
825 if(a==EOF(-1)) return 0; //a = ' ';
826 }
827
828 len += 1;
829 tmp_str->str = gaa_malloc((len) * sizeof(char));
830
831 if(newline == 1)
832 {
833 tmp_str->str[0] = '-';
834 tmp_str->str[1] = '-';
835 i = 2;
836 }
837 else
838 {
839 i = 0;
840 }
841
842 fseek(file,pos_ini, SEEK_SET0);
843 do
844 {
845 a = fgetc( file);
846
847 if (a == EOF(-1)) {
848 i+=2;
849 break;
850 }
851 tmp_str->str[i] = a;
852 i++;
853 }
854 while(a != ' ' && a != 9 && a != '\n' && i < len);
855
856 tmp_str->str[i - 1] = 0;
857
858 fseek(file,- 1, SEEK_CUR1);
859/* printf("%d\n", ftell(file)); */
860
861 return -1;
862}
863
864int gaa_file(const char *name, gaainfo *gaaval)
865{
866 gaa_str_node *first_str, **tmp_str, *tmp_str2;
867 int rval, i;
868 char **argv;
869 int argc = 0;
870 FILE *file;
871
872 gaa_processing_file = 1;
873
874 if((file = fopen(name, "r")) == NULL((void*)0))
875 {
876 printf("Couldn't open '%s' configuration file for reading\n", name);
877 return 1;
878 }
879
880 tmp_str = &first_str;
881 do
882 {
883 argc++;
884 *tmp_str = gaa_malloc(sizeof(gaa_str_node));
885
886 (*tmp_str)->str = NULL((void*)0);
887 (*tmp_str)->next = NULL((void*)0);
888
889 rval = gaa_internal_get_next_str(file, *tmp_str, argc);
890 tmp_str = &((*tmp_str)->next);
891 }
892 while(rval == -1);
893
894 if(rval == 1)
895 return 0;
896
897 argv = gaa_malloc((1 + argc) * sizeof(char*));
898
899 tmp_str2 = first_str;
900 argv[0] = "cfg";
901 for(i = 1; i < argc; i++)
902 {
903 argv[i] = tmp_str2->str;
904 tmp_str2 = tmp_str2->next;
905 }
906
907 rval = gaa(argc, argv, gaaval);
908 gaa_processing_file = 0;
909 return rval;
910}