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, "pgpkeyfile", "FILE ", "PGP Key file to use.");
141 __gaa_helpsingle(0, "pgpcertfile", "FILE ", "PGP Public Key (certificate) file to use.");
142 __gaa_helpsingle(0, "pgpsubkey", "HEX|auto ", "PGP subkey 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('r', "require-cert", "", "Require a valid certificate.");
148 __gaa_helpsingle('a', "disable-client-cert", "", "Disable request for a client certificate.");
149 __gaa_helpsingle(0, "pskpasswd", "FILE ", "PSK password file to use.");
150 __gaa_helpsingle(0, "pskhint", "HINT ", "PSK identity hint to use.");
151 __gaa_helpsingle(0, "srppasswd", "FILE ", "SRP password file to use.");
152 __gaa_helpsingle(0, "srppasswdconf", "FILE ", "SRP password conf file to use.");
153 __gaa_helpsingle(0, "opaque-prf-input", "DATA ", "Use Opaque PRF Input DATA.");
154 __gaa_helpsingle(0, "ciphers", "cipher1 cipher2... ", "Ciphers to enable.");
155 __gaa_helpsingle(0, "protocols", "protocol1 protocol2... ", "Protocols to enable.");
156 __gaa_helpsingle(0, "comp", "comp1 comp2... ", "Compression methods to enable.");
157 __gaa_helpsingle(0, "macs", "mac1 mac2... ", "MACs to enable.");
158 __gaa_helpsingle(0, "kx", "kx1 kx2... ", "Key exchange methods to enable.");
159 __gaa_helpsingle(0, "ctypes", "certType1 certType2... ", "Certificate types to enable.");
160 __gaa_helpsingle(0, "priority", "PRIORITY STRING ", "Priorities string.");
161 __gaa_helpsingle('l', "list", "", "Print a list of the supported algorithms and modes.");
162 __gaa_helpsingle('h', "help", "", "prints this help");
163 __gaa_helpsingle('v', "version", "", "prints the program's version number");
164 __gaa_helpsingle(0, "copyright", "", "prints the program's license");
172 #ifndef GAA_HEADER_POKY
173 #define GAA_HEADER_POKY
175 typedef struct _gaainfo gaainfo
;
206 char *opaque_prf_input
;
208 char *srp_passwd_conf
;
216 int disable_client_cert
;
220 char *x509_dsacertfile
;
222 char *x509_dsakeyfile
;
242 char *dh_params_file
;
264 int gaa(int argc
, char *argv
[], gaainfo
*gaaval
);
268 int gaa_file(const char *name
, gaainfo
*gaaval
);
281 #define GAAERROR(x) \
287 static char *gaa_current_option
;
288 static int gaa_error
= 0;
290 /* Generated by gaa */
298 #define GAA_ERROR_NOMATCH 0
299 #define GAA_ERROR_NOTENOUGH_ARGS 1
300 #define GAA_ERROR_INVALID_ARG 2
301 #define GAA_ERROR_UNKNOWN 3
303 #define GAA_NOT_AN_OPTION 0
304 #define GAA_WORD_OPTION 1
305 #define GAA_LETTER_OPTION 2
306 #define GAA_MULTIPLE_OPTION 3
309 #define GAA_NB_OPTION 37
310 #define GAAOPTID_copyright 1
311 #define GAAOPTID_version 2
312 #define GAAOPTID_help 3
313 #define GAAOPTID_list 4
314 #define GAAOPTID_priority 5
315 #define GAAOPTID_ctypes 6
316 #define GAAOPTID_kx 7
317 #define GAAOPTID_macs 8
318 #define GAAOPTID_comp 9
319 #define GAAOPTID_protocols 10
320 #define GAAOPTID_ciphers 11
321 #define GAAOPTID_opaque_prf_input 12
322 #define GAAOPTID_srppasswdconf 13
323 #define GAAOPTID_srppasswd 14
324 #define GAAOPTID_pskhint 15
325 #define GAAOPTID_pskpasswd 16
326 #define GAAOPTID_disable_client_cert 17
327 #define GAAOPTID_require_cert 18
328 #define GAAOPTID_x509dsacertfile 19
329 #define GAAOPTID_x509dsakeyfile 20
330 #define GAAOPTID_x509certfile 21
331 #define GAAOPTID_x509keyfile 22
332 #define GAAOPTID_pgpsubkey 23
333 #define GAAOPTID_pgpcertfile 24
334 #define GAAOPTID_pgpkeyfile 25
335 #define GAAOPTID_pgpkeyring 26
336 #define GAAOPTID_x509crlfile 27
337 #define GAAOPTID_x509cafile 28
338 #define GAAOPTID_x509fmtder 29
339 #define GAAOPTID_dhparams 30
340 #define GAAOPTID_echo 31
341 #define GAAOPTID_http 32
342 #define GAAOPTID_nodb 33
343 #define GAAOPTID_quiet 34
344 #define GAAOPTID_port 35
345 #define GAAOPTID_generate 36
346 #define GAAOPTID_debug 37
350 #define GAA_CHECK1STR(a,b) \
353 gaa_current_option = a; \
357 #define GAA_CHECKSTR(a,b) \
358 if(strcmp(a,str) == 0) \
360 gaa_current_option = a; \
364 #define GAA_TESTMOREARGS \
367 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
369 if(gaa_last_non_option == gaa_index) \
370 return GAA_ERROR_NOTENOUGH_ARGS; \
373 #define GAA_TESTMOREOPTIONALARGS \
376 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
378 if(gaa_last_non_option == gaa_index) \
382 #define GAA_FILL_2ARGS(target, func) \
383 target = func(GAAargv[gaa_index]); \
384 gaa_arg_used[gaa_index] = 1; \
388 return GAA_ERROR_INVALID_ARG; \
393 #define GAA_FILL(target, func, num) \
396 target = func(GAAargv[gaa_index]); \
397 gaa_arg_used[gaa_index] = 1; \
401 return GAA_ERROR_INVALID_ARG; \
410 #define GAA_LIST_FILL(target, func, type ,num) \
415 if ( gaa_last_non_option - gaa_index > 0) \
416 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
417 for(; gaa_index < gaa_last_non_option; gaa_index++) \
419 if(gaa_arg_used[gaa_index] == 0) \
421 GAA_FILL_2ARGS(target[num], func); \
426 return GAA_ERROR_NOTENOUGH_ARGS; \
429 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
434 if ( gaa_last_non_option - gaa_index > 0) \
435 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
436 for(; gaa_index < gaa_last_non_option; gaa_index++) \
438 if(gaa_arg_used[gaa_index] == 0) \
440 GAA_FILL_2ARGS(target[num], func); \
446 #define GAA_OBLIGAT(str) \
448 for(i = 0; i < strlen(str); i++) \
450 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
451 if(j == GAA_ERROR_NOMATCH) \
453 printf("Error: invalid 'obligat' set\n"); \
456 if(opt_list[j] == 1) \
461 if(strlen(str) == 1) \
462 printf("You must give the -%s option\n", str); \
464 printf("You must give at least one option of '%s'\n", str); \
468 #define GAA_INCOMP(str) \
470 for(i = 0; i < strlen(str); i++) \
472 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
473 if(j == GAA_ERROR_NOMATCH) \
475 printf("Error: invalid 'obligat' set\n"); \
478 if(opt_list[j] == 1) \
483 printf("The options '%s' are incompatible\n", str); \
488 static char **GAAargv
;
490 static char *gaa_arg_used
;
491 static int gaa_processing_file
= 0;
492 static int inited
= 0;
494 static int gaa_getint(char *arg
)
498 if(sscanf(arg
, "%d%c", &tmp
, &a
) < 1)
500 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
506 static char gaa_getchar(char *arg
)
510 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
516 static char* gaa_getstr(char *arg
)
520 static float gaa_getfloat(char *arg
)
524 if(sscanf(arg
, "%f%c", &tmp
, &a
) < 1)
526 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
531 /* option structures */
533 struct GAAOPTION_priority
539 struct GAAOPTION_ctypes
551 struct GAAOPTION_macs
557 struct GAAOPTION_comp
563 struct GAAOPTION_protocols
569 struct GAAOPTION_ciphers
575 struct GAAOPTION_opaque_prf_input
581 struct GAAOPTION_srppasswdconf
587 struct GAAOPTION_srppasswd
593 struct GAAOPTION_pskhint
599 struct GAAOPTION_pskpasswd
605 struct GAAOPTION_x509dsacertfile
611 struct GAAOPTION_x509dsakeyfile
617 struct GAAOPTION_x509certfile
623 struct GAAOPTION_x509keyfile
629 struct GAAOPTION_pgpsubkey
635 struct GAAOPTION_pgpcertfile
641 struct GAAOPTION_pgpkeyfile
647 struct GAAOPTION_pgpkeyring
653 struct GAAOPTION_x509crlfile
659 struct GAAOPTION_x509cafile
665 struct GAAOPTION_dhparams
671 struct GAAOPTION_port
677 struct GAAOPTION_debug
684 static int gaa_is_an_argument(char *str
)
687 if(str
[0] == '/' && str
[1] != 0)
688 return GAA_MULTIPLE_OPTION
;
691 return GAA_NOT_AN_OPTION
;
693 return GAA_NOT_AN_OPTION
;
697 return GAA_WORD_OPTION
;
699 return GAA_NOT_AN_OPTION
;
702 return GAA_LETTER_OPTION
;
704 return GAA_MULTIPLE_OPTION
;
707 static int gaa_get_option_num(char *str
, int status
)
711 case GAA_LETTER_OPTION
:
712 GAA_CHECK1STR("", GAAOPTID_priority
);
713 GAA_CHECK1STR("", GAAOPTID_ctypes
);
714 GAA_CHECK1STR("", GAAOPTID_kx
);
715 GAA_CHECK1STR("", GAAOPTID_macs
);
716 GAA_CHECK1STR("", GAAOPTID_comp
);
717 GAA_CHECK1STR("", GAAOPTID_protocols
);
718 GAA_CHECK1STR("", GAAOPTID_ciphers
);
719 GAA_CHECK1STR("", GAAOPTID_opaque_prf_input
);
720 GAA_CHECK1STR("", GAAOPTID_srppasswdconf
);
721 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
722 GAA_CHECK1STR("", GAAOPTID_pskhint
);
723 GAA_CHECK1STR("", GAAOPTID_pskpasswd
);
724 GAA_CHECK1STR("", GAAOPTID_x509dsacertfile
);
725 GAA_CHECK1STR("", GAAOPTID_x509dsakeyfile
);
726 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
727 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
728 GAA_CHECK1STR("", GAAOPTID_pgpsubkey
);
729 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
730 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
731 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
732 GAA_CHECK1STR("", GAAOPTID_x509crlfile
);
733 GAA_CHECK1STR("", GAAOPTID_x509cafile
);
734 GAA_CHECK1STR("", GAAOPTID_dhparams
);
735 GAA_CHECK1STR("p", GAAOPTID_port
);
736 GAA_CHECK1STR("d", GAAOPTID_debug
);
737 case GAA_MULTIPLE_OPTION
:
739 GAA_CHECK1STR("", GAAOPTID_copyright
);
740 GAA_CHECK1STR("v", GAAOPTID_version
);
741 GAA_CHECK1STR("h", GAAOPTID_help
);
742 GAA_CHECK1STR("l", GAAOPTID_list
);
743 GAA_CHECK1STR("a", GAAOPTID_disable_client_cert
);
744 GAA_CHECK1STR("r", GAAOPTID_require_cert
);
745 GAA_CHECK1STR("", GAAOPTID_x509fmtder
);
746 GAA_CHECK1STR("", GAAOPTID_echo
);
747 GAA_CHECK1STR("", GAAOPTID_http
);
748 GAA_CHECK1STR("", GAAOPTID_nodb
);
749 GAA_CHECK1STR("q", GAAOPTID_quiet
);
750 GAA_CHECK1STR("g", GAAOPTID_generate
);
754 case GAA_WORD_OPTION
:
755 GAA_CHECKSTR("copyright", GAAOPTID_copyright
);
756 GAA_CHECKSTR("version", GAAOPTID_version
);
757 GAA_CHECKSTR("help", GAAOPTID_help
);
758 GAA_CHECKSTR("list", GAAOPTID_list
);
759 GAA_CHECKSTR("priority", GAAOPTID_priority
);
760 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
761 GAA_CHECKSTR("kx", GAAOPTID_kx
);
762 GAA_CHECKSTR("macs", GAAOPTID_macs
);
763 GAA_CHECKSTR("comp", GAAOPTID_comp
);
764 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
765 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
766 GAA_CHECKSTR("opaque-prf-input", GAAOPTID_opaque_prf_input
);
767 GAA_CHECKSTR("srppasswdconf", GAAOPTID_srppasswdconf
);
768 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
769 GAA_CHECKSTR("pskhint", GAAOPTID_pskhint
);
770 GAA_CHECKSTR("pskpasswd", GAAOPTID_pskpasswd
);
771 GAA_CHECKSTR("disable-client-cert", GAAOPTID_disable_client_cert
);
772 GAA_CHECKSTR("require-cert", GAAOPTID_require_cert
);
773 GAA_CHECKSTR("x509dsacertfile", GAAOPTID_x509dsacertfile
);
774 GAA_CHECKSTR("x509dsakeyfile", GAAOPTID_x509dsakeyfile
);
775 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
776 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
777 GAA_CHECKSTR("pgpsubkey", GAAOPTID_pgpsubkey
);
778 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
779 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
780 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
781 GAA_CHECKSTR("x509crlfile", GAAOPTID_x509crlfile
);
782 GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile
);
783 GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder
);
784 GAA_CHECKSTR("dhparams", GAAOPTID_dhparams
);
785 GAA_CHECKSTR("echo", GAAOPTID_echo
);
786 GAA_CHECKSTR("http", GAAOPTID_http
);
787 GAA_CHECKSTR("nodb", GAAOPTID_nodb
);
788 GAA_CHECKSTR("quiet", GAAOPTID_quiet
);
789 GAA_CHECKSTR("port", GAAOPTID_port
);
790 GAA_CHECKSTR("generate", GAAOPTID_generate
);
791 GAA_CHECKSTR("debug", GAAOPTID_debug
);
797 return GAA_ERROR_NOMATCH
;
800 static int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
803 int gaa_last_non_option
;
804 struct GAAOPTION_priority GAATMP_priority
;
805 struct GAAOPTION_ctypes GAATMP_ctypes
;
806 struct GAAOPTION_kx GAATMP_kx
;
807 struct GAAOPTION_macs GAATMP_macs
;
808 struct GAAOPTION_comp GAATMP_comp
;
809 struct GAAOPTION_protocols GAATMP_protocols
;
810 struct GAAOPTION_ciphers GAATMP_ciphers
;
811 struct GAAOPTION_opaque_prf_input GAATMP_opaque_prf_input
;
812 struct GAAOPTION_srppasswdconf GAATMP_srppasswdconf
;
813 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
814 struct GAAOPTION_pskhint GAATMP_pskhint
;
815 struct GAAOPTION_pskpasswd GAATMP_pskpasswd
;
816 struct GAAOPTION_x509dsacertfile GAATMP_x509dsacertfile
;
817 struct GAAOPTION_x509dsakeyfile GAATMP_x509dsakeyfile
;
818 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
819 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
820 struct GAAOPTION_pgpsubkey GAATMP_pgpsubkey
;
821 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
822 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
823 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
824 struct GAAOPTION_x509crlfile GAATMP_x509crlfile
;
825 struct GAAOPTION_x509cafile GAATMP_x509cafile
;
826 struct GAAOPTION_dhparams GAATMP_dhparams
;
827 struct GAAOPTION_port GAATMP_port
;
828 struct GAAOPTION_debug GAATMP_debug
;
831 #ifdef GAA_REST_EXISTS
832 struct GAAREST GAAREST_tmp
;
835 opt_list
[gaa_num
] = 1;
837 for(gaa_last_non_option
= gaa_index
;
838 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
839 gaa_last_non_option
++);
841 if(gaa_num
== GAA_REST
)
844 gaa_last_non_option
= GAAargc
;
849 case GAAOPTID_copyright
:
852 { print_serv_license(); exit(0); ;};
856 case GAAOPTID_version
:
859 { serv_version(); exit(0); ;};
866 { gaa_help(); exit(0); ;};
873 { print_list(0); exit(0); ;};
877 case GAAOPTID_priority
:
880 GAA_FILL(GAATMP_priority
.arg1
, gaa_getstr
, GAATMP_priority
.size1
);
883 { gaaval
->priorities
= GAATMP_priority
.arg1
;};
887 case GAAOPTID_ctypes
:
889 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
891 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
897 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
899 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
905 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
907 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
913 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
915 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
919 case GAAOPTID_protocols
:
921 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
923 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
927 case GAAOPTID_ciphers
:
929 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
931 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
935 case GAAOPTID_opaque_prf_input
:
938 GAA_FILL(GAATMP_opaque_prf_input
.arg1
, gaa_getstr
, GAATMP_opaque_prf_input
.size1
);
941 { gaaval
->opaque_prf_input
= GAATMP_opaque_prf_input
.arg1
;};
945 case GAAOPTID_srppasswdconf
:
948 GAA_FILL(GAATMP_srppasswdconf
.arg1
, gaa_getstr
, GAATMP_srppasswdconf
.size1
);
951 { gaaval
->srp_passwd_conf
= GAATMP_srppasswdconf
.arg1
;};
955 case GAAOPTID_srppasswd
:
958 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
961 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
965 case GAAOPTID_pskhint
:
968 GAA_FILL(GAATMP_pskhint
.arg1
, gaa_getstr
, GAATMP_pskhint
.size1
);
971 { gaaval
->psk_hint
= GAATMP_pskhint
.arg1
;};
975 case GAAOPTID_pskpasswd
:
978 GAA_FILL(GAATMP_pskpasswd
.arg1
, gaa_getstr
, GAATMP_pskpasswd
.size1
);
981 { gaaval
->psk_passwd
= GAATMP_pskpasswd
.arg1
;};
985 case GAAOPTID_disable_client_cert
:
988 { gaaval
->disable_client_cert
= 1 ;};
992 case GAAOPTID_require_cert
:
995 { gaaval
->require_cert
= 1 ;};
999 case GAAOPTID_x509dsacertfile
:
1002 GAA_FILL(GAATMP_x509dsacertfile
.arg1
, gaa_getstr
, GAATMP_x509dsacertfile
.size1
);
1005 { gaaval
->x509_dsacertfile
= GAATMP_x509dsacertfile
.arg1
;};
1009 case GAAOPTID_x509dsakeyfile
:
1012 GAA_FILL(GAATMP_x509dsakeyfile
.arg1
, gaa_getstr
, GAATMP_x509dsakeyfile
.size1
);
1015 { gaaval
->x509_dsakeyfile
= GAATMP_x509dsakeyfile
.arg1
;};
1019 case GAAOPTID_x509certfile
:
1022 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
1025 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
1029 case GAAOPTID_x509keyfile
:
1032 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
1035 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
1039 case GAAOPTID_pgpsubkey
:
1042 GAA_FILL(GAATMP_pgpsubkey
.arg1
, gaa_getstr
, GAATMP_pgpsubkey
.size1
);
1045 { gaaval
->pgp_subkey
= GAATMP_pgpsubkey
.arg1
;};
1049 case GAAOPTID_pgpcertfile
:
1052 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
1055 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
1059 case GAAOPTID_pgpkeyfile
:
1062 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
1065 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
1069 case GAAOPTID_pgpkeyring
:
1072 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
1075 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
1079 case GAAOPTID_x509crlfile
:
1082 GAA_FILL(GAATMP_x509crlfile
.arg1
, gaa_getstr
, GAATMP_x509crlfile
.size1
);
1085 { gaaval
->x509_crlfile
= GAATMP_x509crlfile
.arg1
;};
1089 case GAAOPTID_x509cafile
:
1092 GAA_FILL(GAATMP_x509cafile
.arg1
, gaa_getstr
, GAATMP_x509cafile
.size1
);
1095 { gaaval
->x509_cafile
= GAATMP_x509cafile
.arg1
;};
1099 case GAAOPTID_x509fmtder
:
1102 { gaaval
->fmtder
= 1 ;};
1106 case GAAOPTID_dhparams
:
1109 GAA_FILL(GAATMP_dhparams
.arg1
, gaa_getstr
, GAATMP_dhparams
.size1
);
1112 { gaaval
->dh_params_file
= GAATMP_dhparams
.arg1
;};
1119 { gaaval
->http
= 0 ;};
1126 { gaaval
->http
= 1 ;};
1133 { gaaval
->nodb
= 1 ;};
1137 case GAAOPTID_quiet
:
1140 { gaaval
->quiet
= 1 ;};
1147 GAA_FILL(GAATMP_port
.arg1
, gaa_getint
, GAATMP_port
.size1
);
1150 { gaaval
->port
= GAATMP_port
.arg1
;};
1154 case GAAOPTID_generate
:
1157 { gaaval
->generate
= 1 ;};
1161 case GAAOPTID_debug
:
1164 GAA_FILL(GAATMP_debug
.arg1
, gaa_getint
, GAATMP_debug
.size1
);
1167 { gaaval
->debug
= GAATMP_debug
.arg1
;};
1172 #line 413 "gaa.skel"
1175 return GAA_ERROR_UNKNOWN
;
1178 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
1187 opt_list
= (char*) gaa_malloc(GAA_NB_OPTION
+ 1);
1189 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
1191 /* initialization */
1195 #line 123 "serv.gaa"
1196 { gaaval
->generate
=0; gaaval
->port
=5556; gaaval
->http
=0; gaaval
->ciphers
=NULL
;
1197 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
1198 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0; gaaval
->nodb
= 0;
1199 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
;
1200 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
; gaaval
->x509_crlfile
= NULL
;
1201 gaaval
->x509_dsakeyfile
=NULL
; gaaval
->x509_dsacertfile
=NULL
;
1202 gaaval
->srp_passwd
=NULL
; gaaval
->srp_passwd_conf
=NULL
; gaaval
->quiet
= 0;
1203 gaaval
->pgp_keyring
=NULL
; gaaval
->fmtder
= 0;
1204 gaaval
->disable_client_cert
= 0; gaaval
->priorities
= NULL
;
1205 gaaval
->dh_params_file
=NULL
; gaaval
->debug
=0; gaaval
->require_cert
= 0; gaaval
->psk_passwd
= 0;
1206 gaaval
->opaque_prf_input
=NULL
; gaaval
->pgp_subkey
= NULL
;;};
1210 #line 438 "gaa.skel"
1211 gaa_arg_used
= NULL
;
1214 gaa_arg_used
= gaa_malloc(argc
* sizeof(char));
1217 for(i
= 1; i
< argc
; i
++)
1218 gaa_arg_used
[i
] = 0;
1219 for(i
= 1; i
< argc
; i
++)
1221 if(gaa_arg_used
[i
] == 0)
1224 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
1227 case GAA_WORD_OPTION
:
1229 case GAA_LETTER_OPTION
:
1231 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1232 if(tmp2
== GAA_ERROR_NOMATCH
)
1234 printf("Invalid option '%s'\n", argv
[i
]+j
);
1237 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1239 case GAA_ERROR_NOTENOUGH_ARGS
:
1240 printf("'%s': not enough arguments\n",gaa_current_option
);
1242 case GAA_ERROR_INVALID_ARG
:
1243 printf("Invalid arguments\n");
1248 printf("Unknown error\n");
1250 gaa_arg_used
[i
] = 1;
1252 case GAA_MULTIPLE_OPTION
:
1253 for(j
= 1; j
< strlen(argv
[i
]); j
++)
1255 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1256 if(tmp2
== GAA_ERROR_NOMATCH
)
1258 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
1261 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1263 case GAA_ERROR_NOTENOUGH_ARGS
:
1264 printf("'%s': not enough arguments\n",gaa_current_option
);
1266 case GAA_ERROR_INVALID_ARG
:
1267 printf("Invalid arguments\n");
1272 printf("Unknown error\n");
1275 gaa_arg_used
[i
] = 1;
1281 if(gaa_processing_file
== 0)
1285 #line 507 "gaa.skel"
1286 #ifdef GAA_REST_EXISTS
1287 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
1289 case GAA_ERROR_NOTENOUGH_ARGS
:
1290 printf("Rest: not enough arguments\n");
1292 case GAA_ERROR_INVALID_ARG
:
1293 printf("Invalid arguments\n");
1298 printf("Unknown error\n");
1302 for(i
= 1; i
< argc
; i
++)
1304 if(gaa_arg_used
[i
] == 0)
1306 printf("Too many arguments\n");
1318 struct gaastrnode
*next
;
1321 typedef struct gaastrnode gaa_str_node
;
1323 static int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1327 int i
= 0, len
= 0, newline
= 0;
1335 if (a
== EOF
) return 0;
1337 while(a
== ' ' || a
== 9 || a
== '\n')
1345 if (a
== EOF
) return 0;
1348 pos_ini
= ftell(file
) - 1;
1350 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1355 if(a
==EOF
) return 0; /* a = ' '; */
1359 tmp_str
->str
= gaa_malloc((len
) * sizeof(char));
1363 tmp_str
->str
[0] = '-';
1364 tmp_str
->str
[1] = '-';
1372 fseek(file
,pos_ini
, SEEK_SET
);
1381 tmp_str
->str
[i
] = a
;
1384 while(a
!= ' ' && a
!= 9 && a
!= '\n' && i
< len
);
1386 tmp_str
->str
[i
- 1] = 0;
1388 fseek(file
,- 1, SEEK_CUR
);
1389 /* printf("%d\n", ftell(file)); */
1394 int gaa_file(const char *name
, gaainfo
*gaaval
)
1396 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1402 gaa_processing_file
= 1;
1404 if((file
= fopen(name
, "r")) == NULL
)
1406 printf("Couldn't open '%s' configuration file for reading\n", name
);
1410 tmp_str
= &first_str
;
1414 *tmp_str
= gaa_malloc(sizeof(gaa_str_node
));
1416 (*tmp_str
)->str
= NULL
;
1417 (*tmp_str
)->next
= NULL
;
1419 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1420 tmp_str
= &((*tmp_str
)->next
);
1427 argv
= gaa_malloc((1 + argc
) * sizeof(char*));
1429 tmp_str2
= first_str
;
1431 for(i
= 1; i
< argc
; i
++)
1433 argv
[i
] = tmp_str2
->str
;
1434 tmp_str2
= tmp_str2
->next
;
1437 rval
= gaa(argc
, argv
, gaaval
);
1438 gaa_processing_file
= 0;