Bug Summary

File:src/ocsptool-gaa.c
Location:line 687, column 2
Description:Value stored to 'OK' is never read

Annotated Source Code

1/* File generated by GAA 1.6.6
2 */
3#define GAA_NO_WIN32
4#line 1 "ocsptool.gaa"
5
6
7/* C declarations */
8
9#include <config.h>
10#ifdef _WIN32
11# include <io.h>
12#endif
13
14#include "ocsptool-common.h"
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("Ocsptool help\nUsage : ocsptool [options]\n");
132 __gaa_helpsingle('e', "verify-response", "", "Verify response.");
133 __gaa_helpsingle('i', "request-info", "", "Print information on a OCSP request.");
134 __gaa_helpsingle('j', "response-info", "", "Print information on a OCSP response.");
135 __gaa_helpsingle('q', "generate-request", "", "Generate a OCSP request.");
136 __gaa_helpsingle(0, "no-nonce", "", "don't add nonce to OCSP request.");
137 __gaa_helpsingle(0, "load-issuer", "FILE ", "read issuer certificate from FILE.");
138 __gaa_helpsingle(0, "load-cert", "FILE ", "read certificate to check from FILE.");
139 __gaa_helpsingle(0, "load-trust", "FILE ", "read OCSP trust anchors from FILE.");
140 __gaa_helpsingle(0, "load-signer", "FILE ", "read OCSP response signer from FILE.");
141 __gaa_helpsingle(0, "inder", "", "Use DER format for input certificates.");
142 __gaa_helpsingle('Q', "load-request", "FILE ", "read DER encoded OCSP request from FILE.");
143 __gaa_helpsingle('S', "load-response", "FILE ", "read DER encoded OCSP response from FILE.");
144 __gaa_helpsingle(0, "outfile", "FILE ", "Output file.");
145 __gaa_helpsingle(0, "infile", "FILE ", "Input file.");
146 __gaa_helpsingle('V', "verbose", "", "More verbose output.");
147 __gaa_helpsingle('d', "debug", "integer ", "Enable debugging");
148 __gaa_helpsingle('v', "version", "", "prints the program's version number");
149 __gaa_helpsingle('h', "help", "", "shows this help text");
150
151#line 100 "gaa.skel"
152}
153/* Copy of C area */
154
155#line 104 "gaa.skel"
156/* GAA HEADER */
157#ifndef GAA_HEADER_POKY
158#define GAA_HEADER_POKY
159
160typedef struct _gaainfo gaainfo;
161
162struct _gaainfo
163{
164#line 59 "ocsptool.gaa"
165 int debug;
166#line 56 "ocsptool.gaa"
167 int verbose;
168#line 53 "ocsptool.gaa"
169 char *infile;
170#line 50 "ocsptool.gaa"
171 char *outfile;
172#line 47 "ocsptool.gaa"
173 char *resp;
174#line 44 "ocsptool.gaa"
175 char *req;
176#line 41 "ocsptool.gaa"
177 int inder;
178#line 38 "ocsptool.gaa"
179 char *signer;
180#line 35 "ocsptool.gaa"
181 char *trust;
182#line 32 "ocsptool.gaa"
183 char *cert;
184#line 29 "ocsptool.gaa"
185 char *issuer;
186#line 26 "ocsptool.gaa"
187 int nononce;
188#line 16 "ocsptool.gaa"
189 int action;
190
191#line 114 "gaa.skel"
192};
193
194#ifdef __cplusplus
195extern "C"
196{
197#endif
198
199 int gaa(int argc, char *argv[], gaainfo *gaaval);
200
201 void gaa_help(void);
202
203 int gaa_file(const char *name, gaainfo *gaaval);
204
205#ifdef __cplusplus
206}
207#endif
208
209
210#endif
211
212#line 135 "gaa.skel"
213
214/* C declarations */
215
216#define GAAERROR(x){ gaa_error = 1; return x; } \
217{ \
218gaa_error = 1; \
219return x; \
220}
221
222static char *gaa_current_option;
223static int gaa_error = 0;
224
225/* Generated by gaa */
226
227#include <string.h>
228#include <stdlib.h>
229
230
231#define GAA_OK-1 -1
232
233#define GAA_ERROR_NOMATCH0 0
234#define GAA_ERROR_NOTENOUGH_ARGS1 1
235#define GAA_ERROR_INVALID_ARG2 2
236#define GAA_ERROR_UNKNOWN3 3
237
238#define GAA_NOT_AN_OPTION0 0
239#define GAA_WORD_OPTION1 1
240#define GAA_LETTER_OPTION2 2
241#define GAA_MULTIPLE_OPTION3 3
242
243#define GAA_REST0 0
244#define GAA_NB_OPTION18 18
245#define GAAOPTID_help1 1
246#define GAAOPTID_version2 2
247#define GAAOPTID_debug3 3
248#define GAAOPTID_verbose4 4
249#define GAAOPTID_infile5 5
250#define GAAOPTID_outfile6 6
251#define GAAOPTID_load_response7 7
252#define GAAOPTID_load_request8 8
253#define GAAOPTID_inder9 9
254#define GAAOPTID_load_signer10 10
255#define GAAOPTID_load_trust11 11
256#define GAAOPTID_load_cert12 12
257#define GAAOPTID_load_issuer13 13
258#define GAAOPTID_no_nonce14 14
259#define GAAOPTID_generate_request15 15
260#define GAAOPTID_response_info16 16
261#define GAAOPTID_request_info17 17
262#define GAAOPTID_verify_response18 18
263
264#line 168 "gaa.skel"
265
266#define GAA_CHECK1STR(a,b)if(a[0] == str[0]) { gaa_current_option = a; return b; } \
267if(a[0] == str[0]) \
268{ \
269 gaa_current_option = a; \
270 return b; \
271}
272
273#define GAA_CHECKSTR(a,b)if(strcmp(a,str) == 0) { gaa_current_option = a; return b; } \
274if(strcmp(a,str) == 0) \
275{ \
276 gaa_current_option = a; \
277 return b; \
278}
279
280#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; }
\
281if(!OK) \
282{ \
283while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
284 gaa_index++; \
285if(gaa_last_non_option == gaa_index) \
286 return GAA_ERROR_NOTENOUGH_ARGS1; \
287}
288
289#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; }
\
290if(!OK) \
291{ \
292while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
293 gaa_index++; \
294if(gaa_last_non_option == gaa_index) \
295 OK = 1; \
296}
297
298#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; }
\
299target = func(GAAargv[gaa_index]); \
300gaa_arg_used[gaa_index] = 1; \
301if(gaa_error == 1) \
302{ \
303 gaa_error = 0; \
304 return GAA_ERROR_INVALID_ARG2; \
305}
306
307
308
309#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; }
\
310if(!OK) \
311{ \
312target = func(GAAargv[gaa_index]); \
313gaa_arg_used[gaa_index] = 1; \
314if(gaa_error == 1) \
315{ \
316 gaa_error = 0; \
317 return GAA_ERROR_INVALID_ARG2; \
318} \
319num = 1; \
320} \
321else \
322{ \
323num = 0; \
324}
325
326#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; }
\
327if(!OK) \
328{ \
329num = 0; \
330target = NULL((void*)0); \
331if ( gaa_last_non_option - gaa_index > 0) \
332 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
333for(; gaa_index < gaa_last_non_option; gaa_index++) \
334{ \
335 if(gaa_arg_used[gaa_index] == 0) \
336 { \
337 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; }
; \
338 num++; \
339 } \
340} \
341if(num == 0) \
342 return GAA_ERROR_NOTENOUGH_ARGS1; \
343}
344
345#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++; } } }
\
346if(!OK) \
347{ \
348num = 0; \
349target = NULL((void*)0); \
350if ( gaa_last_non_option - gaa_index > 0) \
351 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
352for(; gaa_index < gaa_last_non_option; gaa_index++) \
353{ \
354 if(gaa_arg_used[gaa_index] == 0) \
355 { \
356 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; }
; \
357 num++; \
358 } \
359} \
360}
361
362#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; }
\
363k = 0; \
364for(i = 0; i < strlen(str); i++) \
365{ \
366 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \
367 if(j == GAA_ERROR_NOMATCH0) \
368 { \
369 printf("Error: invalid 'obligat' set\n"); \
370 exit(-1); \
371 } \
372 if(opt_list[j] == 1) \
373 k = 1; \
374} \
375if(k == 0) \
376{ \
377 if(strlen(str) == 1) \
378 printf("You must give the -%s option\n", str); \
379 else \
380 printf("You must give at least one option of '%s'\n", str); \
381 return 0; \
382}
383
384#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; }
\
385k = 0; \
386for(i = 0; i < strlen(str); i++) \
387{ \
388 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION2); \
389 if(j == GAA_ERROR_NOMATCH0) \
390 { \
391 printf("Error: invalid 'obligat' set\n"); \
392 exit(-1); \
393 } \
394 if(opt_list[j] == 1) \
395 k++; \
396} \
397if(k > 1) \
398{ \
399 printf("The options '%s' are incompatible\n", str); \
400 return 0; \
401}
402
403
404static char **GAAargv;
405static int GAAargc;
406static char *gaa_arg_used;
407static int gaa_processing_file = 0;
408static int inited = 0;
409
410static int gaa_getint(char *arg)
411{
412 int tmp;
413 char a;
414 if(sscanf(arg, "%d%c", &tmp, &a) < 1)
415 {
416 printf("Option %s: '%s' isn't an integer\n", gaa_current_option, arg);
417 GAAERROR(-1){ gaa_error = 1; return -1; };
418 }
419 return tmp;
420}
421
422static char gaa_getchar(char *arg)
423{
424 if(strlen(arg) != 1)
425 {
426 printf("Option %s: '%s' isn't an character\n", gaa_current_option, arg);
427 GAAERROR(-1){ gaa_error = 1; return -1; };
428 }
429 return arg[0];
430}
431
432static char* gaa_getstr(char *arg)
433{
434 return arg;
435}
436static float gaa_getfloat(char *arg)
437{
438 float tmp;
439 char a;
440 if(sscanf(arg, "%f%c", &tmp, &a) < 1)
441 {
442 printf("Option %s: '%s' isn't a float number\n", gaa_current_option, arg);
443 GAAERROR(-1){ gaa_error = 1; return -1; };
444 }
445 return tmp;
446}
447/* option structures */
448
449struct GAAOPTION_debug
450{
451 int arg1;
452 int size1;
453};
454
455struct GAAOPTION_infile
456{
457 char* arg1;
458 int size1;
459};
460
461struct GAAOPTION_outfile
462{
463 char* arg1;
464 int size1;
465};
466
467struct GAAOPTION_load_response
468{
469 char* arg1;
470 int size1;
471};
472
473struct GAAOPTION_load_request
474{
475 char* arg1;
476 int size1;
477};
478
479struct GAAOPTION_load_signer
480{
481 char* arg1;
482 int size1;
483};
484
485struct GAAOPTION_load_trust
486{
487 char* arg1;
488 int size1;
489};
490
491struct GAAOPTION_load_cert
492{
493 char* arg1;
494 int size1;
495};
496
497struct GAAOPTION_load_issuer
498{
499 char* arg1;
500 int size1;
501};
502
503#line 349 "gaa.skel"
504static int gaa_is_an_argument(char *str)
505{
506#ifdef GAA_WIN32
507 if(str[0] == '/' && str[1] != 0)
508 return GAA_MULTIPLE_OPTION3;
509#endif
510 if(str[0] != '-')
511 return GAA_NOT_AN_OPTION0;
512 if(str[1] == 0)
513 return GAA_NOT_AN_OPTION0;
514 if(str[1] == '-')
515 {
516 if(str[2] != 0)
517 return GAA_WORD_OPTION1;
518 else
519 return GAA_NOT_AN_OPTION0;
520 }
521 if(str[2] == 0)
522 return GAA_LETTER_OPTION2;
523 else
524 return GAA_MULTIPLE_OPTION3;
525}
526
527static int gaa_get_option_num(char *str, int status)
528{
529 switch(status)
530 {
531 case GAA_LETTER_OPTION2:
532 GAA_CHECK1STR("d", GAAOPTID_debug)if("d"[0] == str[0]) { gaa_current_option = "d"; return 3; };
533 GAA_CHECK1STR("", GAAOPTID_infile)if(""[0] == str[0]) { gaa_current_option = ""; return 5; };
534 GAA_CHECK1STR("", GAAOPTID_outfile)if(""[0] == str[0]) { gaa_current_option = ""; return 6; };
535 GAA_CHECK1STR("S", GAAOPTID_load_response)if("S"[0] == str[0]) { gaa_current_option = "S"; return 7; };
536 GAA_CHECK1STR("Q", GAAOPTID_load_request)if("Q"[0] == str[0]) { gaa_current_option = "Q"; return 8; };
537 GAA_CHECK1STR("", GAAOPTID_load_signer)if(""[0] == str[0]) { gaa_current_option = ""; return 10; };
538 GAA_CHECK1STR("", GAAOPTID_load_trust)if(""[0] == str[0]) { gaa_current_option = ""; return 11; };
539 GAA_CHECK1STR("", GAAOPTID_load_cert)if(""[0] == str[0]) { gaa_current_option = ""; return 12; };
540 GAA_CHECK1STR("", GAAOPTID_load_issuer)if(""[0] == str[0]) { gaa_current_option = ""; return 13; };
541 case GAA_MULTIPLE_OPTION3:
542#line 375 "gaa.skel"
543 GAA_CHECK1STR("h", GAAOPTID_help)if("h"[0] == str[0]) { gaa_current_option = "h"; return 1; };
544 GAA_CHECK1STR("v", GAAOPTID_version)if("v"[0] == str[0]) { gaa_current_option = "v"; return 2; };
545 GAA_CHECK1STR("V", GAAOPTID_verbose)if("V"[0] == str[0]) { gaa_current_option = "V"; return 4; };
546 GAA_CHECK1STR("", GAAOPTID_inder)if(""[0] == str[0]) { gaa_current_option = ""; return 9; };
547 GAA_CHECK1STR("", GAAOPTID_no_nonce)if(""[0] == str[0]) { gaa_current_option = ""; return 14; };
548 GAA_CHECK1STR("q", GAAOPTID_generate_request)if("q"[0] == str[0]) { gaa_current_option = "q"; return 15; };
549 GAA_CHECK1STR("j", GAAOPTID_response_info)if("j"[0] == str[0]) { gaa_current_option = "j"; return 16; };
550 GAA_CHECK1STR("i", GAAOPTID_request_info)if("i"[0] == str[0]) { gaa_current_option = "i"; return 17; };
551 GAA_CHECK1STR("e", GAAOPTID_verify_response)if("e"[0] == str[0]) { gaa_current_option = "e"; return 18; };
552
553#line 277 "gaa.skel"
554 break;
555 case GAA_WORD_OPTION1:
556 GAA_CHECKSTR("help", GAAOPTID_help)if(strcmp("help",str) == 0) { gaa_current_option = "help"; return
1; }
;
557 GAA_CHECKSTR("version", GAAOPTID_version)if(strcmp("version",str) == 0) { gaa_current_option = "version"
; return 2; }
;
558 GAA_CHECKSTR("debug", GAAOPTID_debug)if(strcmp("debug",str) == 0) { gaa_current_option = "debug"; return
3; }
;
559 GAA_CHECKSTR("verbose", GAAOPTID_verbose)if(strcmp("verbose",str) == 0) { gaa_current_option = "verbose"
; return 4; }
;
560 GAA_CHECKSTR("infile", GAAOPTID_infile)if(strcmp("infile",str) == 0) { gaa_current_option = "infile"
; return 5; }
;
561 GAA_CHECKSTR("outfile", GAAOPTID_outfile)if(strcmp("outfile",str) == 0) { gaa_current_option = "outfile"
; return 6; }
;
562 GAA_CHECKSTR("load-response", GAAOPTID_load_response)if(strcmp("load-response",str) == 0) { gaa_current_option = "load-response"
; return 7; }
;
563 GAA_CHECKSTR("load-request", GAAOPTID_load_request)if(strcmp("load-request",str) == 0) { gaa_current_option = "load-request"
; return 8; }
;
564 GAA_CHECKSTR("inder", GAAOPTID_inder)if(strcmp("inder",str) == 0) { gaa_current_option = "inder"; return
9; }
;
565 GAA_CHECKSTR("load-signer", GAAOPTID_load_signer)if(strcmp("load-signer",str) == 0) { gaa_current_option = "load-signer"
; return 10; }
;
566 GAA_CHECKSTR("load-trust", GAAOPTID_load_trust)if(strcmp("load-trust",str) == 0) { gaa_current_option = "load-trust"
; return 11; }
;
567 GAA_CHECKSTR("load-cert", GAAOPTID_load_cert)if(strcmp("load-cert",str) == 0) { gaa_current_option = "load-cert"
; return 12; }
;
568 GAA_CHECKSTR("load-issuer", GAAOPTID_load_issuer)if(strcmp("load-issuer",str) == 0) { gaa_current_option = "load-issuer"
; return 13; }
;
569 GAA_CHECKSTR("no-nonce", GAAOPTID_no_nonce)if(strcmp("no-nonce",str) == 0) { gaa_current_option = "no-nonce"
; return 14; }
;
570 GAA_CHECKSTR("generate-request", GAAOPTID_generate_request)if(strcmp("generate-request",str) == 0) { gaa_current_option =
"generate-request"; return 15; }
;
571 GAA_CHECKSTR("response-info", GAAOPTID_response_info)if(strcmp("response-info",str) == 0) { gaa_current_option = "response-info"
; return 16; }
;
572 GAA_CHECKSTR("request-info", GAAOPTID_request_info)if(strcmp("request-info",str) == 0) { gaa_current_option = "request-info"
; return 17; }
;
573 GAA_CHECKSTR("verify-response", GAAOPTID_verify_response)if(strcmp("verify-response",str) == 0) { gaa_current_option =
"verify-response"; return 18; }
;
574
575#line 281 "gaa.skel"
576 break;
577 default: break;
578 }
579 return GAA_ERROR_NOMATCH0;
580}
581
582static int gaa_try(int gaa_num, int gaa_index, gaainfo *gaaval, char *opt_list)
583{
584 int OK = 0;
585 int gaa_last_non_option;
586 struct GAAOPTION_debug GAATMP_debug;
587 struct GAAOPTION_infile GAATMP_infile;
588 struct GAAOPTION_outfile GAATMP_outfile;
589 struct GAAOPTION_load_response GAATMP_load_response;
590 struct GAAOPTION_load_request GAATMP_load_request;
591 struct GAAOPTION_load_signer GAATMP_load_signer;
592 struct GAAOPTION_load_trust GAATMP_load_trust;
593 struct GAAOPTION_load_cert GAATMP_load_cert;
594 struct GAAOPTION_load_issuer GAATMP_load_issuer;
595
596#line 393 "gaa.skel"
597#ifdef GAA_REST_EXISTS
598 struct GAAREST GAAREST_tmp;
599#endif
600
601 opt_list[gaa_num] = 1;
602
603 for(gaa_last_non_option = gaa_index;
604 (gaa_last_non_option != GAAargc) && (gaa_is_an_argument(GAAargv[gaa_last_non_option]) == GAA_NOT_AN_OPTION0);
605 gaa_last_non_option++);
606
607 if(gaa_num == GAA_REST0)
608 {
609 gaa_index = 1;
610 gaa_last_non_option = GAAargc;
611 }
612
613 switch(gaa_num)
614 {
615 case GAAOPTID_help1:
616 OK = 0;
617#line 63 "ocsptool.gaa"
618{ gaa_help(); exit(0); ;};
619
620 return GAA_OK-1;
621 break;
622 case GAAOPTID_version2:
623 OK = 0;
624#line 62 "ocsptool.gaa"
625{ ocsptool_version(); exit(0); ;};
626
627 return GAA_OK-1;
628 break;
629 case GAAOPTID_debug3:
630 OK = 0;
631 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; }
;
632 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; }
;
633 gaa_index++;
634#line 60 "ocsptool.gaa"
635{ gaaval->debug = GAATMP_debug.arg1 ;};
636
637 return GAA_OK-1;
638 break;
639 case GAAOPTID_verbose4:
640 OK = 0;
641#line 57 "ocsptool.gaa"
642{ gaaval->verbose = 1 ;};
643
644 return GAA_OK-1;
645 break;
646 case GAAOPTID_infile5:
647 OK = 0;
648 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; }
;
649 GAA_FILL(GAATMP_infile.arg1, gaa_getstr, GAATMP_infile.size1)if(!OK) { GAATMP_infile.arg1 = gaa_getstr(GAAargv[gaa_index])
; gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_infile.size1 = 1; } else { GAATMP_infile
.size1 = 0; }
;
650 gaa_index++;
651#line 54 "ocsptool.gaa"
652{ gaaval->infile = GAATMP_infile.arg1 ;};
653
654 return GAA_OK-1;
655 break;
656 case GAAOPTID_outfile6:
657 OK = 0;
658 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; }
;
659 GAA_FILL(GAATMP_outfile.arg1, gaa_getstr, GAATMP_outfile.size1)if(!OK) { GAATMP_outfile.arg1 = gaa_getstr(GAAargv[gaa_index]
); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_outfile.size1 = 1; } else { GAATMP_outfile
.size1 = 0; }
;
660 gaa_index++;
661#line 51 "ocsptool.gaa"
662{ gaaval->outfile = GAATMP_outfile.arg1 ;};
663
664 return GAA_OK-1;
665 break;
666 case GAAOPTID_load_response7:
667 OK = 0;
668 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; }
;
669 GAA_FILL(GAATMP_load_response.arg1, gaa_getstr, GAATMP_load_response.size1)if(!OK) { GAATMP_load_response.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_load_response.size1 = 1; } else { GAATMP_load_response
.size1 = 0; }
;
670 gaa_index++;
671#line 48 "ocsptool.gaa"
672{ gaaval->resp = GAATMP_load_response.arg1 ;};
673
674 return GAA_OK-1;
675 break;
676 case GAAOPTID_load_request8:
677 OK = 0;
678 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; }
;
679 GAA_FILL(GAATMP_load_request.arg1, gaa_getstr, GAATMP_load_request.size1)if(!OK) { GAATMP_load_request.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_load_request.size1 = 1; } else { GAATMP_load_request
.size1 = 0; }
;
680 gaa_index++;
681#line 45 "ocsptool.gaa"
682{ gaaval->req = GAATMP_load_request.arg1 ;};
683
684 return GAA_OK-1;
685 break;
686 case GAAOPTID_inder9:
687 OK = 0;
Value stored to 'OK' is never read
688#line 42 "ocsptool.gaa"
689{ gaaval->inder=1 ;};
690
691 return GAA_OK-1;
692 break;
693 case GAAOPTID_load_signer10:
694 OK = 0;
695 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; }
;
696 GAA_FILL(GAATMP_load_signer.arg1, gaa_getstr, GAATMP_load_signer.size1)if(!OK) { GAATMP_load_signer.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_load_signer.size1 = 1; } else { GAATMP_load_signer
.size1 = 0; }
;
697 gaa_index++;
698#line 39 "ocsptool.gaa"
699{ gaaval->signer = GAATMP_load_signer.arg1 ;};
700
701 return GAA_OK-1;
702 break;
703 case GAAOPTID_load_trust11:
704 OK = 0;
705 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; }
;
706 GAA_FILL(GAATMP_load_trust.arg1, gaa_getstr, GAATMP_load_trust.size1)if(!OK) { GAATMP_load_trust.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_load_trust.size1 = 1; } else { GAATMP_load_trust
.size1 = 0; }
;
707 gaa_index++;
708#line 36 "ocsptool.gaa"
709{ gaaval->trust = GAATMP_load_trust.arg1 ;};
710
711 return GAA_OK-1;
712 break;
713 case GAAOPTID_load_cert12:
714 OK = 0;
715 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; }
;
716 GAA_FILL(GAATMP_load_cert.arg1, gaa_getstr, GAATMP_load_cert.size1)if(!OK) { GAATMP_load_cert.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_load_cert.size1 = 1; } else { GAATMP_load_cert
.size1 = 0; }
;
717 gaa_index++;
718#line 33 "ocsptool.gaa"
719{ gaaval->cert = GAATMP_load_cert.arg1 ;};
720
721 return GAA_OK-1;
722 break;
723 case GAAOPTID_load_issuer13:
724 OK = 0;
725 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; }
;
726 GAA_FILL(GAATMP_load_issuer.arg1, gaa_getstr, GAATMP_load_issuer.size1)if(!OK) { GAATMP_load_issuer.arg1 = gaa_getstr(GAAargv[gaa_index
]); gaa_arg_used[gaa_index] = 1; if(gaa_error == 1) { gaa_error
= 0; return 2; } GAATMP_load_issuer.size1 = 1; } else { GAATMP_load_issuer
.size1 = 0; }
;
727 gaa_index++;
728#line 30 "ocsptool.gaa"
729{ gaaval->issuer = GAATMP_load_issuer.arg1 ;};
730
731 return GAA_OK-1;
732 break;
733 case GAAOPTID_no_nonce14:
734 OK = 0;
735#line 27 "ocsptool.gaa"
736{ gaaval->nononce = 1 ;};
737
738 return GAA_OK-1;
739 break;
740 case GAAOPTID_generate_request15:
741 OK = 0;
742#line 24 "ocsptool.gaa"
743{ gaaval->action = ACTION_GEN_REQ; ;};
744
745 return GAA_OK-1;
746 break;
747 case GAAOPTID_response_info16:
748 OK = 0;
749#line 22 "ocsptool.gaa"
750{ gaaval->action = ACTION_RESP_INFO; ;};
751
752 return GAA_OK-1;
753 break;
754 case GAAOPTID_request_info17:
755 OK = 0;
756#line 20 "ocsptool.gaa"
757{ gaaval->action = ACTION_REQ_INFO; ;};
758
759 return GAA_OK-1;
760 break;
761 case GAAOPTID_verify_response18:
762 OK = 0;
763#line 18 "ocsptool.gaa"
764{ gaaval->action = ACTION_VERIFY_RESP; ;};
765
766 return GAA_OK-1;
767 break;
768
769#line 413 "gaa.skel"
770 default: break;
771 }
772 return GAA_ERROR_UNKNOWN3;
773}
774
775int gaa(int argc, char **argv, gaainfo *gaaval)
776{
777 int tmp1, tmp2;
778 int i, j;
779 char *opt_list;
780
781 GAAargv = argv;
782 GAAargc = argc;
783
784 opt_list = (char*) gaa_malloc(GAA_NB_OPTION18 + 1);
785
786 for(i = 0; i < GAA_NB_OPTION18 + 1; i++)
787 opt_list[i] = 0;
788 /* initialization */
789 if(inited == 0)
790 {
791
792#line 65 "ocsptool.gaa"
793{ gaaval->action = ACTION_NONE;
794 gaaval->nononce = 0;
795 gaaval->inder = 0;
796 gaaval->issuer = NULL((void*)0);
797 gaaval->cert = NULL((void*)0);
798 gaaval->trust = NULL((void*)0);
799 gaaval->req = NULL((void*)0);
800 gaaval->resp = NULL((void*)0);
801 gaaval->outfile = NULL((void*)0);
802 gaaval->infile = NULL((void*)0);
803 gaaval->verbose = 0;
804 gaaval->debug = 0; ;};
805
806 }
807 inited = 1;
808#line 438 "gaa.skel"
809 gaa_arg_used = NULL((void*)0);
810
811 if (argc > 0) {
812 gaa_arg_used = gaa_malloc(argc * sizeof(char));
813 }
814
815 for(i = 1; i < argc; i++)
816 gaa_arg_used[i] = 0;
817 for(i = 1; i < argc; i++)
818 {
819 if(gaa_arg_used[i] == 0)
820 {
821 j = 0;
822 tmp1 = gaa_is_an_argument(GAAargv[i]);
823 switch(tmp1)
824 {
825 case GAA_WORD_OPTION1:
826 j++;
827 case GAA_LETTER_OPTION2:
828 j++;
829 tmp2 = gaa_get_option_num(argv[i]+j, tmp1);
830 if(tmp2 == GAA_ERROR_NOMATCH0)
831 {
832 printf("Invalid option '%s'\n", argv[i]+j);
833 return 0;
834 }
835 switch(gaa_try(tmp2, i+1, gaaval, opt_list))
836 {
837 case GAA_ERROR_NOTENOUGH_ARGS1:
838 printf("'%s': not enough arguments\n",gaa_current_option);
839 return 0;
840 case GAA_ERROR_INVALID_ARG2:
841 printf("Invalid arguments\n");
842 return 0;
843 case GAA_OK-1:
844 break;
845 default:
846 printf("Unknown error\n");
847 }
848 gaa_arg_used[i] = 1;
849 break;
850 case GAA_MULTIPLE_OPTION3:
851 for(j = 1; j < strlen(argv[i]); j++)
852 {
853 tmp2 = gaa_get_option_num(argv[i]+j, tmp1);
854 if(tmp2 == GAA_ERROR_NOMATCH0)
855 {
856 printf("Invalid option '%c'\n", *(argv[i]+j));
857 return 0;
858 }
859 switch(gaa_try(tmp2, i+1, gaaval, opt_list))
860 {
861 case GAA_ERROR_NOTENOUGH_ARGS1:
862 printf("'%s': not enough arguments\n",gaa_current_option);
863 return 0;
864 case GAA_ERROR_INVALID_ARG2:
865 printf("Invalid arguments\n");
866 return 0;
867 case GAA_OK-1:
868 break;
869 default:
870 printf("Unknown error\n");
871 }
872 }
873 gaa_arg_used[i] = 1;
874 break;
875 default: break;
876 }
877 }
878 }
879if(gaa_processing_file == 0)
880{
881
882#line 507 "gaa.skel"
883#ifdef GAA_REST_EXISTS
884 switch(gaa_try(GAA_REST0, 1, gaaval, opt_list))
885 {
886 case GAA_ERROR_NOTENOUGH_ARGS1:
887 printf("Rest: not enough arguments\n");
888 return 0;
889 case GAA_ERROR_INVALID_ARG2:
890 printf("Invalid arguments\n");
891 return 0;
892 case GAA_OK-1:
893 break;
894 default:
895 printf("Unknown error\n");
896 }
897#endif
898}
899 for(i = 1; i < argc; i++)
900 {
901 if(gaa_arg_used[i] == 0)
902 {
903 printf("Too many arguments\n");
904 return 0;
905 }
906 }
907 free(gaa_arg_used);
908 free(opt_list);
909 return -1;
910}
911
912struct gaastrnode
913{
914 char *str;
915 struct gaastrnode *next;
916};
917
918typedef struct gaastrnode gaa_str_node;
919
920static int gaa_internal_get_next_str(FILE *file, gaa_str_node *tmp_str, int argc)
921{
922 int pos_ini;
923 int a;
924 int i = 0, len = 0, newline = 0;
925
926 if(argc == 1) {
927 newline = 1;
928 len = 2;
929 }
930
931 a = fgetc( file);
932 if (a == EOF(-1)) return 0;
933
934 while(a == ' ' || a == 9 || a == '\n')
935 {
936 if(a == '\n')
937 {
938 newline=1;
939 len = 2;
940 }
941 a = fgetc( file);
942 if (a == EOF(-1)) return 0;
943 }
944
945 pos_ini = ftell(file) - 1;
946
947 while(a != ' ' && a != 9 && a != '\n')
948 {
949
950 len++;
951 a = fgetc( file);
952 if(a==EOF(-1)) return 0; //a = ' ';
953 }
954
955 len += 1;
956 tmp_str->str = gaa_malloc((len) * sizeof(char));
957
958 if(newline == 1)
959 {
960 tmp_str->str[0] = '-';
961 tmp_str->str[1] = '-';
962 i = 2;
963 }
964 else
965 {
966 i = 0;
967 }
968
969 fseek(file,pos_ini, SEEK_SET0);
970 do
971 {
972 a = fgetc( file);
973
974 if (a == EOF(-1)) {
975 i+=2;
976 break;
977 }
978 tmp_str->str[i] = a;
979 i++;
980 }
981 while(a != ' ' && a != 9 && a != '\n' && i < len);
982
983 tmp_str->str[i - 1] = 0;
984
985 fseek(file,- 1, SEEK_CUR1);
986/* printf("%d\n", ftell(file)); */
987
988 return -1;
989}
990
991int gaa_file(const char *name, gaainfo *gaaval)
992{
993 gaa_str_node *first_str, **tmp_str, *tmp_str2;
994 int rval, i;
995 char **argv;
996 int argc = 0;
997 FILE *file;
998
999 gaa_processing_file = 1;
1000
1001 if((file = fopen(name, "r")) == NULL((void*)0))
1002 {
1003 printf("Couldn't open '%s' configuration file for reading\n", name);
1004 return 1;
1005 }
1006
1007 tmp_str = &first_str;
1008 do
1009 {
1010 argc++;
1011 *tmp_str = gaa_malloc(sizeof(gaa_str_node));
1012
1013 (*tmp_str)->str = NULL((void*)0);
1014 (*tmp_str)->next = NULL((void*)0);
1015
1016 rval = gaa_internal_get_next_str(file, *tmp_str, argc);
1017 tmp_str = &((*tmp_str)->next);
1018 }
1019 while(rval == -1);
1020
1021 if(rval == 1)
1022 return 0;
1023
1024 argv = gaa_malloc((1 + argc) * sizeof(char*));
1025
1026 tmp_str2 = first_str;
1027 argv[0] = "cfg";
1028 for(i = 1; i < argc; i++)
1029 {
1030 argv[i] = tmp_str2->str;
1031 tmp_str2 = tmp_str2->next;
1032 }
1033
1034 rval = gaa(argc, argv, gaaval);
1035 gaa_processing_file = 0;
1036 return rval;
1037}