1 /* File generated by GAA 1.6.6
9 void print_serv_license(void);
10 void serv_version(void);
17 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
22 static void* gaa_malloc( size_t size
) {
26 fprintf(stderr
, "gaa: could not allocate memory");
32 static void __gaa_helpsingle(char short_name
, char *name
,
33 char *arg_desc
, char *opt_help
)
35 int col1
, col3
, col4
, tabsize
= 3, curr
;
38 col1
= 5; /* Default values */
43 for(i
= 0; i
< col1
; i
++)
52 printf("-%c, ", short_name
);
57 printf("-%c ", short_name
);
63 printf("--%s ", name
);
64 curr
+= 3 + strlen(name
);
66 if(arg_desc
&& *arg_desc
)
68 printf("%s ", arg_desc
);
69 curr
+= 1 + strlen(arg_desc
);
76 if(opt_help
) /* let's print the option's help body */
78 const char *str
= opt_help
;
98 while((curr
- col3
) % tabsize
!= 0 && curr
< col4
);
105 for(i
= 1; str
[i
] && str
[i
] != ' ' && str
[i
] != '\n'
106 && str
[i
] != '\t'; i
++);
107 if(curr
+ i
- 1 >= col4
)
127 printf("GNU TLS 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 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, "http", "", "Act as an HTTP Server.");
134 __gaa_helpsingle(0, "echo", "", "Act as an Echo Server.");
135 __gaa_helpsingle(0, "dhparams", "FILE ", "DH params file to use.");
136 __gaa_helpsingle(0, "x509fmtder", "", "Use DER format for certificates");
137 __gaa_helpsingle(0, "x509cafile", "FILE ", "Certificate file to use.");
138 __gaa_helpsingle(0, "x509crlfile", "FILE ", "CRL file to use.");
139 __gaa_helpsingle(0, "pgpkeyring", "FILE ", "PGP Key ring file to use.");
140 __gaa_helpsingle(0, "pgptrustdb", "FILE ", "PGP trustdb file to use.");
141 __gaa_helpsingle(0, "pgpkeyfile", "FILE ", "PGP Key file to use.");
142 __gaa_helpsingle(0, "pgpcertfile", "FILE ", "PGP Public Key (certificate) file to use.");
143 __gaa_helpsingle(0, "x509keyfile", "FILE ", "X.509 key file to use.");
144 __gaa_helpsingle(0, "x509certfile", "FILE ", "X.509 Certificate file to use.");
145 __gaa_helpsingle(0, "x509dsakeyfile", "FILE ", "Alternative X.509 key file to use.");
146 __gaa_helpsingle(0, "x509dsacertfile", "FILE ", "Alternative X.509 certificate file to use.");
147 __gaa_helpsingle(0, "require-cert", "", "Require a valid certificate.");
148 __gaa_helpsingle(0, "pskpasswd", "FILE ", "PSK password file to use.");
149 __gaa_helpsingle(0, "srppasswd", "FILE ", "SRP password file to use.");
150 __gaa_helpsingle(0, "srppasswdconf", "FILE ", "SRP password conf file to use.");
151 __gaa_helpsingle(0, "authz-x509-attr-cert", "FILE ", "Use X.509 Attribute Certificate in FILE as authorization data.");
152 __gaa_helpsingle(0, "authz-saml-assertion", "FILE ", "Use SAML Assertion in FILE as authorization data.");
153 __gaa_helpsingle(0, "ciphers", "cipher1 cipher2... ", "Ciphers to enable.");
154 __gaa_helpsingle(0, "protocols", "protocol1 protocol2... ", "Protocols to enable.");
155 __gaa_helpsingle(0, "comp", "comp1 comp2... ", "Compression methods to enable.");
156 __gaa_helpsingle(0, "macs", "mac1 mac2... ", "MACs to enable.");
157 __gaa_helpsingle(0, "kx", "kx1 kx2... ", "Key exchange methods to enable.");
158 __gaa_helpsingle(0, "ctypes", "certType1 certType2... ", "Certificate types to enable.");
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 __gaa_helpsingle(0, "copyright", "", "prints the program's license");
170 #ifndef GAA_HEADER_POKY
171 #define GAA_HEADER_POKY
173 typedef struct _gaainfo gaainfo
;
202 char *authz_saml_assertion
;
204 char *authz_x509_attr_cert
;
206 char *srp_passwd_conf
;
214 char *x509_dsacertfile
;
216 char *x509_dsakeyfile
;
236 char *dh_params_file
;
258 int gaa(int argc
, char *argv
[], gaainfo
*gaaval
);
262 int gaa_file(const char *name
, gaainfo
*gaaval
);
275 #define GAAERROR(x) \
281 static char *gaa_current_option
;
282 static int gaa_error
= 0;
284 /* Generated by gaa */
292 #define GAA_ERROR_NOMATCH 0
293 #define GAA_ERROR_NOTENOUGH_ARGS 1
294 #define GAA_ERROR_INVALID_ARG 2
295 #define GAA_ERROR_UNKNOWN 3
297 #define GAA_NOT_AN_OPTION 0
298 #define GAA_WORD_OPTION 1
299 #define GAA_LETTER_OPTION 2
300 #define GAA_MULTIPLE_OPTION 3
303 #define GAA_NB_OPTION 35
304 #define GAAOPTID_copyright 1
305 #define GAAOPTID_version 2
306 #define GAAOPTID_help 3
307 #define GAAOPTID_list 4
308 #define GAAOPTID_ctypes 5
309 #define GAAOPTID_kx 6
310 #define GAAOPTID_macs 7
311 #define GAAOPTID_comp 8
312 #define GAAOPTID_protocols 9
313 #define GAAOPTID_ciphers 10
314 #define GAAOPTID_authz_saml_assertion 11
315 #define GAAOPTID_authz_x509_attr_cert 12
316 #define GAAOPTID_srppasswdconf 13
317 #define GAAOPTID_srppasswd 14
318 #define GAAOPTID_pskpasswd 15
319 #define GAAOPTID_require_cert 16
320 #define GAAOPTID_x509dsacertfile 17
321 #define GAAOPTID_x509dsakeyfile 18
322 #define GAAOPTID_x509certfile 19
323 #define GAAOPTID_x509keyfile 20
324 #define GAAOPTID_pgpcertfile 21
325 #define GAAOPTID_pgpkeyfile 22
326 #define GAAOPTID_pgptrustdb 23
327 #define GAAOPTID_pgpkeyring 24
328 #define GAAOPTID_x509crlfile 25
329 #define GAAOPTID_x509cafile 26
330 #define GAAOPTID_x509fmtder 27
331 #define GAAOPTID_dhparams 28
332 #define GAAOPTID_echo 29
333 #define GAAOPTID_http 30
334 #define GAAOPTID_nodb 31
335 #define GAAOPTID_quiet 32
336 #define GAAOPTID_port 33
337 #define GAAOPTID_generate 34
338 #define GAAOPTID_debug 35
342 #define GAA_CHECK1STR(a,b) \
345 gaa_current_option = a; \
349 #define GAA_CHECKSTR(a,b) \
350 if(strcmp(a,str) == 0) \
352 gaa_current_option = a; \
356 #define GAA_TESTMOREARGS \
359 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
361 if(gaa_last_non_option == gaa_index) \
362 return GAA_ERROR_NOTENOUGH_ARGS; \
365 #define GAA_TESTMOREOPTIONALARGS \
368 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
370 if(gaa_last_non_option == gaa_index) \
374 #define GAA_FILL_2ARGS(target, func) \
375 target = func(GAAargv[gaa_index]); \
376 gaa_arg_used[gaa_index] = 1; \
380 return GAA_ERROR_INVALID_ARG; \
385 #define GAA_FILL(target, func, num) \
388 target = func(GAAargv[gaa_index]); \
389 gaa_arg_used[gaa_index] = 1; \
393 return GAA_ERROR_INVALID_ARG; \
402 #define GAA_LIST_FILL(target, func, type ,num) \
407 if ( gaa_last_non_option - gaa_index > 0) \
408 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
409 for(; gaa_index < gaa_last_non_option; gaa_index++) \
411 if(gaa_arg_used[gaa_index] == 0) \
413 GAA_FILL_2ARGS(target[num], func); \
418 return GAA_ERROR_NOTENOUGH_ARGS; \
421 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
426 if ( gaa_last_non_option - gaa_index > 0) \
427 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
428 for(; gaa_index < gaa_last_non_option; gaa_index++) \
430 if(gaa_arg_used[gaa_index] == 0) \
432 GAA_FILL_2ARGS(target[num], func); \
438 #define GAA_OBLIGAT(str) \
440 for(i = 0; i < strlen(str); i++) \
442 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
443 if(j == GAA_ERROR_NOMATCH) \
445 printf("Error: invalid 'obligat' set\n"); \
448 if(opt_list[j] == 1) \
453 if(strlen(str) == 1) \
454 printf("You must give the -%s option\n", str); \
456 printf("You must give at least one option of '%s'\n", str); \
460 #define GAA_INCOMP(str) \
462 for(i = 0; i < strlen(str); i++) \
464 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
465 if(j == GAA_ERROR_NOMATCH) \
467 printf("Error: invalid 'obligat' set\n"); \
470 if(opt_list[j] == 1) \
475 printf("The options '%s' are incompatible\n", str); \
480 static char **GAAargv
;
482 static char *gaa_arg_used
;
483 static int gaa_processing_file
= 0;
484 static int inited
= 0;
486 static int gaa_getint(char *arg
)
490 if(sscanf(arg
, "%d%c", &tmp
, &a
) < 1)
492 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
498 static char gaa_getchar(char *arg
)
502 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
508 static char* gaa_getstr(char *arg
)
512 static float gaa_getfloat(char *arg
)
516 if(sscanf(arg
, "%f%c", &tmp
, &a
) < 1)
518 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
523 /* option structures */
525 struct GAAOPTION_ctypes
537 struct GAAOPTION_macs
543 struct GAAOPTION_comp
549 struct GAAOPTION_protocols
555 struct GAAOPTION_ciphers
561 struct GAAOPTION_authz_saml_assertion
567 struct GAAOPTION_authz_x509_attr_cert
573 struct GAAOPTION_srppasswdconf
579 struct GAAOPTION_srppasswd
585 struct GAAOPTION_pskpasswd
591 struct GAAOPTION_x509dsacertfile
597 struct GAAOPTION_x509dsakeyfile
603 struct GAAOPTION_x509certfile
609 struct GAAOPTION_x509keyfile
615 struct GAAOPTION_pgpcertfile
621 struct GAAOPTION_pgpkeyfile
627 struct GAAOPTION_pgptrustdb
633 struct GAAOPTION_pgpkeyring
639 struct GAAOPTION_x509crlfile
645 struct GAAOPTION_x509cafile
651 struct GAAOPTION_dhparams
657 struct GAAOPTION_port
663 struct GAAOPTION_debug
670 static int gaa_is_an_argument(char *str
)
673 if(str
[0] == '/' && str
[1] != 0)
674 return GAA_MULTIPLE_OPTION
;
677 return GAA_NOT_AN_OPTION
;
679 return GAA_NOT_AN_OPTION
;
683 return GAA_WORD_OPTION
;
685 return GAA_NOT_AN_OPTION
;
688 return GAA_LETTER_OPTION
;
690 return GAA_MULTIPLE_OPTION
;
693 static int gaa_get_option_num(char *str
, int status
)
697 case GAA_LETTER_OPTION
:
698 GAA_CHECK1STR("", GAAOPTID_ctypes
);
699 GAA_CHECK1STR("", GAAOPTID_kx
);
700 GAA_CHECK1STR("", GAAOPTID_macs
);
701 GAA_CHECK1STR("", GAAOPTID_comp
);
702 GAA_CHECK1STR("", GAAOPTID_protocols
);
703 GAA_CHECK1STR("", GAAOPTID_ciphers
);
704 GAA_CHECK1STR("", GAAOPTID_authz_saml_assertion
);
705 GAA_CHECK1STR("", GAAOPTID_authz_x509_attr_cert
);
706 GAA_CHECK1STR("", GAAOPTID_srppasswdconf
);
707 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
708 GAA_CHECK1STR("", GAAOPTID_pskpasswd
);
709 GAA_CHECK1STR("", GAAOPTID_x509dsacertfile
);
710 GAA_CHECK1STR("", GAAOPTID_x509dsakeyfile
);
711 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
712 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
713 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
714 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
715 GAA_CHECK1STR("", GAAOPTID_pgptrustdb
);
716 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
717 GAA_CHECK1STR("", GAAOPTID_x509crlfile
);
718 GAA_CHECK1STR("", GAAOPTID_x509cafile
);
719 GAA_CHECK1STR("", GAAOPTID_dhparams
);
720 GAA_CHECK1STR("p", GAAOPTID_port
);
721 GAA_CHECK1STR("d", GAAOPTID_debug
);
722 case GAA_MULTIPLE_OPTION
:
724 GAA_CHECK1STR("", GAAOPTID_copyright
);
725 GAA_CHECK1STR("v", GAAOPTID_version
);
726 GAA_CHECK1STR("h", GAAOPTID_help
);
727 GAA_CHECK1STR("l", GAAOPTID_list
);
728 GAA_CHECK1STR("", GAAOPTID_require_cert
);
729 GAA_CHECK1STR("", GAAOPTID_x509fmtder
);
730 GAA_CHECK1STR("", GAAOPTID_echo
);
731 GAA_CHECK1STR("", GAAOPTID_http
);
732 GAA_CHECK1STR("", GAAOPTID_nodb
);
733 GAA_CHECK1STR("q", GAAOPTID_quiet
);
734 GAA_CHECK1STR("g", GAAOPTID_generate
);
738 case GAA_WORD_OPTION
:
739 GAA_CHECKSTR("copyright", GAAOPTID_copyright
);
740 GAA_CHECKSTR("version", GAAOPTID_version
);
741 GAA_CHECKSTR("help", GAAOPTID_help
);
742 GAA_CHECKSTR("list", GAAOPTID_list
);
743 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
744 GAA_CHECKSTR("kx", GAAOPTID_kx
);
745 GAA_CHECKSTR("macs", GAAOPTID_macs
);
746 GAA_CHECKSTR("comp", GAAOPTID_comp
);
747 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
748 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
749 GAA_CHECKSTR("authz-saml-assertion", GAAOPTID_authz_saml_assertion
);
750 GAA_CHECKSTR("authz-x509-attr-cert", GAAOPTID_authz_x509_attr_cert
);
751 GAA_CHECKSTR("srppasswdconf", GAAOPTID_srppasswdconf
);
752 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
753 GAA_CHECKSTR("pskpasswd", GAAOPTID_pskpasswd
);
754 GAA_CHECKSTR("require-cert", GAAOPTID_require_cert
);
755 GAA_CHECKSTR("x509dsacertfile", GAAOPTID_x509dsacertfile
);
756 GAA_CHECKSTR("x509dsakeyfile", GAAOPTID_x509dsakeyfile
);
757 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
758 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
759 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
760 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
761 GAA_CHECKSTR("pgptrustdb", GAAOPTID_pgptrustdb
);
762 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
763 GAA_CHECKSTR("x509crlfile", GAAOPTID_x509crlfile
);
764 GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile
);
765 GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder
);
766 GAA_CHECKSTR("dhparams", GAAOPTID_dhparams
);
767 GAA_CHECKSTR("echo", GAAOPTID_echo
);
768 GAA_CHECKSTR("http", GAAOPTID_http
);
769 GAA_CHECKSTR("nodb", GAAOPTID_nodb
);
770 GAA_CHECKSTR("quiet", GAAOPTID_quiet
);
771 GAA_CHECKSTR("port", GAAOPTID_port
);
772 GAA_CHECKSTR("generate", GAAOPTID_generate
);
773 GAA_CHECKSTR("debug", GAAOPTID_debug
);
779 return GAA_ERROR_NOMATCH
;
782 static int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
785 int gaa_last_non_option
;
786 struct GAAOPTION_ctypes GAATMP_ctypes
;
787 struct GAAOPTION_kx GAATMP_kx
;
788 struct GAAOPTION_macs GAATMP_macs
;
789 struct GAAOPTION_comp GAATMP_comp
;
790 struct GAAOPTION_protocols GAATMP_protocols
;
791 struct GAAOPTION_ciphers GAATMP_ciphers
;
792 struct GAAOPTION_authz_saml_assertion GAATMP_authz_saml_assertion
;
793 struct GAAOPTION_authz_x509_attr_cert GAATMP_authz_x509_attr_cert
;
794 struct GAAOPTION_srppasswdconf GAATMP_srppasswdconf
;
795 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
796 struct GAAOPTION_pskpasswd GAATMP_pskpasswd
;
797 struct GAAOPTION_x509dsacertfile GAATMP_x509dsacertfile
;
798 struct GAAOPTION_x509dsakeyfile GAATMP_x509dsakeyfile
;
799 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
800 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
801 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
802 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
803 struct GAAOPTION_pgptrustdb GAATMP_pgptrustdb
;
804 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
805 struct GAAOPTION_x509crlfile GAATMP_x509crlfile
;
806 struct GAAOPTION_x509cafile GAATMP_x509cafile
;
807 struct GAAOPTION_dhparams GAATMP_dhparams
;
808 struct GAAOPTION_port GAATMP_port
;
809 struct GAAOPTION_debug GAATMP_debug
;
812 #ifdef GAA_REST_EXISTS
813 struct GAAREST GAAREST_tmp
;
816 opt_list
[gaa_num
] = 1;
818 for(gaa_last_non_option
= gaa_index
;
819 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
820 gaa_last_non_option
++);
822 if(gaa_num
== GAA_REST
)
825 gaa_last_non_option
= GAAargc
;
830 case GAAOPTID_copyright
:
833 { print_serv_license(); exit(0); ;};
837 case GAAOPTID_version
:
840 { serv_version(); exit(0); ;};
847 { gaa_help(); exit(0); ;};
854 { print_list(0); exit(0); ;};
858 case GAAOPTID_ctypes
:
860 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
862 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
868 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
870 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
876 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
878 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
884 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
886 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
890 case GAAOPTID_protocols
:
892 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
894 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
898 case GAAOPTID_ciphers
:
900 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
902 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
906 case GAAOPTID_authz_saml_assertion
:
909 GAA_FILL(GAATMP_authz_saml_assertion
.arg1
, gaa_getstr
, GAATMP_authz_saml_assertion
.size1
);
912 { gaaval
->authz_saml_assertion
= GAATMP_authz_saml_assertion
.arg1
;};
916 case GAAOPTID_authz_x509_attr_cert
:
919 GAA_FILL(GAATMP_authz_x509_attr_cert
.arg1
, gaa_getstr
, GAATMP_authz_x509_attr_cert
.size1
);
922 { gaaval
->authz_x509_attr_cert
= GAATMP_authz_x509_attr_cert
.arg1
;};
926 case GAAOPTID_srppasswdconf
:
929 GAA_FILL(GAATMP_srppasswdconf
.arg1
, gaa_getstr
, GAATMP_srppasswdconf
.size1
);
932 { gaaval
->srp_passwd_conf
= GAATMP_srppasswdconf
.arg1
;};
936 case GAAOPTID_srppasswd
:
939 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
942 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
946 case GAAOPTID_pskpasswd
:
949 GAA_FILL(GAATMP_pskpasswd
.arg1
, gaa_getstr
, GAATMP_pskpasswd
.size1
);
952 { gaaval
->psk_passwd
= GAATMP_pskpasswd
.arg1
;};
956 case GAAOPTID_require_cert
:
959 { gaaval
->require_cert
= 1 ;};
963 case GAAOPTID_x509dsacertfile
:
966 GAA_FILL(GAATMP_x509dsacertfile
.arg1
, gaa_getstr
, GAATMP_x509dsacertfile
.size1
);
969 { gaaval
->x509_dsacertfile
= GAATMP_x509dsacertfile
.arg1
;};
973 case GAAOPTID_x509dsakeyfile
:
976 GAA_FILL(GAATMP_x509dsakeyfile
.arg1
, gaa_getstr
, GAATMP_x509dsakeyfile
.size1
);
979 { gaaval
->x509_dsakeyfile
= GAATMP_x509dsakeyfile
.arg1
;};
983 case GAAOPTID_x509certfile
:
986 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
989 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
993 case GAAOPTID_x509keyfile
:
996 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
999 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
1003 case GAAOPTID_pgpcertfile
:
1006 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
1009 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
1013 case GAAOPTID_pgpkeyfile
:
1016 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
1019 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
1023 case GAAOPTID_pgptrustdb
:
1026 GAA_FILL(GAATMP_pgptrustdb
.arg1
, gaa_getstr
, GAATMP_pgptrustdb
.size1
);
1029 { gaaval
->pgp_trustdb
= GAATMP_pgptrustdb
.arg1
;};
1033 case GAAOPTID_pgpkeyring
:
1036 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
1039 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
1043 case GAAOPTID_x509crlfile
:
1046 GAA_FILL(GAATMP_x509crlfile
.arg1
, gaa_getstr
, GAATMP_x509crlfile
.size1
);
1049 { gaaval
->x509_crlfile
= GAATMP_x509crlfile
.arg1
;};
1053 case GAAOPTID_x509cafile
:
1056 GAA_FILL(GAATMP_x509cafile
.arg1
, gaa_getstr
, GAATMP_x509cafile
.size1
);
1059 { gaaval
->x509_cafile
= GAATMP_x509cafile
.arg1
;};
1063 case GAAOPTID_x509fmtder
:
1066 { gaaval
->fmtder
= 1 ;};
1070 case GAAOPTID_dhparams
:
1073 GAA_FILL(GAATMP_dhparams
.arg1
, gaa_getstr
, GAATMP_dhparams
.size1
);
1076 { gaaval
->dh_params_file
= GAATMP_dhparams
.arg1
;};
1083 { gaaval
->http
= 0 ;};
1090 { gaaval
->http
= 1 ;};
1097 { gaaval
->nodb
= 1 ;};
1101 case GAAOPTID_quiet
:
1104 { gaaval
->quiet
= 1 ;};
1111 GAA_FILL(GAATMP_port
.arg1
, gaa_getint
, GAATMP_port
.size1
);
1114 { gaaval
->port
= GAATMP_port
.arg1
;};
1118 case GAAOPTID_generate
:
1121 { gaaval
->generate
= 1 ;};
1125 case GAAOPTID_debug
:
1128 GAA_FILL(GAATMP_debug
.arg1
, gaa_getint
, GAATMP_debug
.size1
);
1131 { gaaval
->debug
= GAATMP_debug
.arg1
;};
1136 #line 413 "gaa.skel"
1139 return GAA_ERROR_UNKNOWN
;
1142 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
1151 opt_list
= (char*) gaa_malloc(GAA_NB_OPTION
+ 1);
1153 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
1155 /* initialization */
1159 #line 117 "serv.gaa"
1160 { gaaval
->generate
=0; gaaval
->port
=5556; gaaval
->http
=0; gaaval
->ciphers
=NULL
;
1161 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
1162 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0; gaaval
->nodb
= 0;
1163 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
;
1164 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
; gaaval
->x509_crlfile
= NULL
;
1165 gaaval
->x509_dsakeyfile
=NULL
; gaaval
->x509_dsacertfile
=NULL
;
1166 gaaval
->srp_passwd
=NULL
; gaaval
->srp_passwd_conf
=NULL
; gaaval
->quiet
= 0;
1167 gaaval
->pgp_trustdb
=NULL
; gaaval
->pgp_keyring
=NULL
; gaaval
->fmtder
= 0;
1168 gaaval
->dh_params_file
=NULL
; gaaval
->debug
=0; gaaval
->require_cert
= 0; gaaval
->psk_passwd
= 0; ;};
1172 #line 438 "gaa.skel"
1173 gaa_arg_used
= NULL
;
1176 gaa_arg_used
= gaa_malloc(argc
* sizeof(char));
1179 for(i
= 1; i
< argc
; i
++)
1180 gaa_arg_used
[i
] = 0;
1181 for(i
= 1; i
< argc
; i
++)
1183 if(gaa_arg_used
[i
] == 0)
1186 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
1189 case GAA_WORD_OPTION
:
1191 case GAA_LETTER_OPTION
:
1193 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1194 if(tmp2
== GAA_ERROR_NOMATCH
)
1196 printf("Invalid option '%s'\n", argv
[i
]+j
);
1199 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1201 case GAA_ERROR_NOTENOUGH_ARGS
:
1202 printf("'%s': not enough arguments\n",gaa_current_option
);
1204 case GAA_ERROR_INVALID_ARG
:
1205 printf("Invalid arguments\n");
1210 printf("Unknown error\n");
1212 gaa_arg_used
[i
] = 1;
1214 case GAA_MULTIPLE_OPTION
:
1215 for(j
= 1; j
< strlen(argv
[i
]); j
++)
1217 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1218 if(tmp2
== GAA_ERROR_NOMATCH
)
1220 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
1223 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1225 case GAA_ERROR_NOTENOUGH_ARGS
:
1226 printf("'%s': not enough arguments\n",gaa_current_option
);
1228 case GAA_ERROR_INVALID_ARG
:
1229 printf("Invalid arguments\n");
1234 printf("Unknown error\n");
1237 gaa_arg_used
[i
] = 1;
1243 if(gaa_processing_file
== 0)
1246 #line 507 "gaa.skel"
1247 #ifdef GAA_REST_EXISTS
1248 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
1250 case GAA_ERROR_NOTENOUGH_ARGS
:
1251 printf("Rest: not enough arguments\n");
1253 case GAA_ERROR_INVALID_ARG
:
1254 printf("Invalid arguments\n");
1259 printf("Unknown error\n");
1263 for(i
= 1; i
< argc
; i
++)
1265 if(gaa_arg_used
[i
] == 0)
1267 printf("Too many arguments\n");
1279 struct gaastrnode
*next
;
1282 typedef struct gaastrnode gaa_str_node
;
1284 static int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1288 int i
= 0, len
= 0, newline
= 0;
1296 if (a
== EOF
) return 0;
1298 while(a
== ' ' || a
== 9 || a
== '\n')
1306 if (a
== EOF
) return 0;
1309 pos_ini
= ftell(file
) - 1;
1311 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1316 if(a
==EOF
) return 0; /* a = ' '; */
1320 tmp_str
->str
= gaa_malloc((len
) * sizeof(char));
1324 tmp_str
->str
[0] = '-';
1325 tmp_str
->str
[1] = '-';
1333 fseek(file
,pos_ini
, SEEK_SET
);
1342 tmp_str
->str
[i
] = a
;
1345 while(a
!= ' ' && a
!= 9 && a
!= '\n' && i
< len
);
1347 tmp_str
->str
[i
- 1] = 0;
1349 fseek(file
,- 1, SEEK_CUR
);
1350 /* printf("%d\n", ftell(file)); */
1355 int gaa_file(const char *name
, gaainfo
*gaaval
)
1357 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1363 gaa_processing_file
= 1;
1365 if((file
= fopen(name
, "r")) == NULL
)
1367 printf("Couldn't open '%s' configuration file for reading\n", name
);
1371 tmp_str
= &first_str
;
1375 *tmp_str
= gaa_malloc(sizeof(gaa_str_node
));
1377 (*tmp_str
)->str
= NULL
;
1378 (*tmp_str
)->next
= NULL
;
1380 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1381 tmp_str
= &((*tmp_str
)->next
);
1388 argv
= gaa_malloc((1 + argc
) * sizeof(char*));
1390 tmp_str2
= first_str
;
1392 for(i
= 1; i
< argc
; i
++)
1394 argv
[i
] = tmp_str2
->str
;
1395 tmp_str2
= tmp_str2
->next
;
1398 rval
= gaa(argc
, argv
, gaaval
);
1399 gaa_processing_file
= 0;