1 /* File generated by GAA 1.6.6
11 void print_license(void);
12 void cli_version(void);
19 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
24 static void* gaa_malloc( size_t size
) {
28 fprintf(stderr
, "gaa: could not allocate memory");
34 static void __gaa_helpsingle(char short_name
, char *name
,
35 char *arg_desc
, char *opt_help
)
37 int col1
, col3
, col4
, tabsize
= 3, curr
;
40 col1
= 5; /* Default values */
45 for(i
= 0; i
< col1
; i
++)
54 printf("-%c, ", short_name
);
59 printf("-%c ", short_name
);
65 printf("--%s ", name
);
66 curr
+= 3 + strlen(name
);
68 if(arg_desc
&& *arg_desc
)
70 printf("%s ", arg_desc
);
71 curr
+= 1 + strlen(arg_desc
);
78 if(opt_help
) /* let's print the option's help body */
80 const char *str
= opt_help
;
100 while((curr
- col3
) % tabsize
!= 0 && curr
< col4
);
107 for(i
= 1; str
[i
] && str
[i
] != ' ' && str
[i
] != '\n'
108 && str
[i
] != '\t'; i
++);
109 if(curr
+ i
- 1 >= col4
)
129 printf("GNU TLS test client\nUsage: gnutls-cli [options] hostname\n\n\n");
130 __gaa_helpsingle('d', "debug", "integer ", "Enable debugging");
131 __gaa_helpsingle('r', "resume", "", "Connect, establish a session. Connect again and resume this session.");
132 __gaa_helpsingle('s', "starttls", "", "Connect, establish a plain session and start TLS when EOF or a SIGALRM is received.");
133 __gaa_helpsingle(0, "crlf", "", "Send CR LF instead of LF.");
134 __gaa_helpsingle(0, "x509fmtder", "", "Use DER format for certificates to read from.");
135 __gaa_helpsingle('f', "fingerprint", "", "Send the openpgp fingerprint, instead of the key.");
136 __gaa_helpsingle(0, "disable-extensions", "", "Disable all the TLS extensions.");
137 __gaa_helpsingle(0, "print-cert", "", "Print the certificate in PEM format.");
138 __gaa_helpsingle(0, "recordsize", "integer ", "The maximum record size to advertize.");
139 __gaa_helpsingle('V', "verbose", "", "More verbose output.");
140 __gaa_helpsingle(0, "ciphers", "cipher1 cipher2... ", "Ciphers to enable.");
141 __gaa_helpsingle(0, "protocols", "protocol1 protocol2... ", "Protocols to enable.");
142 __gaa_helpsingle(0, "comp", "comp1 comp2... ", "Compression methods to enable.");
143 __gaa_helpsingle(0, "macs", "mac1 mac2... ", "MACs to enable.");
144 __gaa_helpsingle(0, "kx", "kx1 kx2... ", "Key exchange methods to enable.");
145 __gaa_helpsingle(0, "ctypes", "certType1 certType2... ", "Certificate types to enable.");
146 __gaa_helpsingle(0, "priority", "PRIORITY STRING ", "Priorities string.");
147 __gaa_helpsingle(0, "x509cafile", "FILE ", "Certificate file to use.");
148 __gaa_helpsingle(0, "x509crlfile", "FILE ", "CRL file to use.");
149 __gaa_helpsingle(0, "pgpkeyfile", "FILE ", "PGP Key file to use.");
150 __gaa_helpsingle(0, "pgpkeyring", "FILE ", "PGP Key ring file to use.");
151 __gaa_helpsingle(0, "pgpcertfile", "FILE ", "PGP Public Key (certificate) file to use.");
152 __gaa_helpsingle(0, "pgpsubkey", "HEX|auto ", "PGP subkey to use.");
153 __gaa_helpsingle(0, "x509keyfile", "FILE ", "X.509 key file to use.");
154 __gaa_helpsingle(0, "x509certfile", "FILE ", "X.509 Certificate file to use.");
155 __gaa_helpsingle(0, "srpusername", "NAME ", "SRP username to use.");
156 __gaa_helpsingle(0, "srppasswd", "PASSWD ", "SRP password to use.");
157 __gaa_helpsingle(0, "pskusername", "NAME ", "PSK username to use.");
158 __gaa_helpsingle(0, "pskkey", "KEY ", "PSK key (in hex) to use.");
159 __gaa_helpsingle(0, "opaque-prf-input", "DATA ", "Use Opaque PRF Input DATA.");
160 __gaa_helpsingle('p', "port", "PORT ", "The port to connect to.");
161 __gaa_helpsingle(0, "insecure", "", "Don't abort program if server certificate can't be validated.");
162 __gaa_helpsingle('l', "list", "", "Print a list of the supported algorithms and modes.");
163 __gaa_helpsingle('h', "help", "", "prints this help");
164 __gaa_helpsingle('v', "version", "", "prints the program's version number");
165 __gaa_helpsingle(0, "copyright", "", "prints the program's license");
173 #ifndef GAA_HEADER_POKY
174 #define GAA_HEADER_POKY
176 typedef struct _gaainfo gaainfo
;
187 char *opaque_prf_input
;
245 int disable_extensions
;
267 int gaa(int argc
, char *argv
[], gaainfo
*gaaval
);
271 int gaa_file(const char *name
, gaainfo
*gaaval
);
284 #define GAAERROR(x) \
290 static char *gaa_current_option
;
291 static int gaa_error
= 0;
293 /* Generated by gaa */
301 #define GAA_ERROR_NOMATCH 0
302 #define GAA_ERROR_NOTENOUGH_ARGS 1
303 #define GAA_ERROR_INVALID_ARG 2
304 #define GAA_ERROR_UNKNOWN 3
306 #define GAA_NOT_AN_OPTION 0
307 #define GAA_WORD_OPTION 1
308 #define GAA_LETTER_OPTION 2
309 #define GAA_MULTIPLE_OPTION 3
312 #define GAA_NB_OPTION 36
313 #define GAAOPTID_copyright 1
314 #define GAAOPTID_version 2
315 #define GAAOPTID_help 3
316 #define GAAOPTID_list 4
317 #define GAAOPTID_insecure 5
318 #define GAAOPTID_port 6
319 #define GAAOPTID_opaque_prf_input 7
320 #define GAAOPTID_pskkey 8
321 #define GAAOPTID_pskusername 9
322 #define GAAOPTID_srppasswd 10
323 #define GAAOPTID_srpusername 11
324 #define GAAOPTID_x509certfile 12
325 #define GAAOPTID_x509keyfile 13
326 #define GAAOPTID_pgpsubkey 14
327 #define GAAOPTID_pgpcertfile 15
328 #define GAAOPTID_pgpkeyring 16
329 #define GAAOPTID_pgpkeyfile 17
330 #define GAAOPTID_x509crlfile 18
331 #define GAAOPTID_x509cafile 19
332 #define GAAOPTID_priority 20
333 #define GAAOPTID_ctypes 21
334 #define GAAOPTID_kx 22
335 #define GAAOPTID_macs 23
336 #define GAAOPTID_comp 24
337 #define GAAOPTID_protocols 25
338 #define GAAOPTID_ciphers 26
339 #define GAAOPTID_verbose 27
340 #define GAAOPTID_recordsize 28
341 #define GAAOPTID_print_cert 29
342 #define GAAOPTID_disable_extensions 30
343 #define GAAOPTID_fingerprint 31
344 #define GAAOPTID_x509fmtder 32
345 #define GAAOPTID_crlf 33
346 #define GAAOPTID_starttls 34
347 #define GAAOPTID_resume 35
348 #define GAAOPTID_debug 36
352 #define GAA_CHECK1STR(a,b) \
355 gaa_current_option = a; \
359 #define GAA_CHECKSTR(a,b) \
360 if(strcmp(a,str) == 0) \
362 gaa_current_option = a; \
366 #define GAA_TESTMOREARGS \
369 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
371 if(gaa_last_non_option == gaa_index) \
372 return GAA_ERROR_NOTENOUGH_ARGS; \
375 #define GAA_TESTMOREOPTIONALARGS \
378 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
380 if(gaa_last_non_option == gaa_index) \
384 #define GAA_FILL_2ARGS(target, func) \
385 target = func(GAAargv[gaa_index]); \
386 gaa_arg_used[gaa_index] = 1; \
390 return GAA_ERROR_INVALID_ARG; \
395 #define GAA_FILL(target, func, num) \
398 target = func(GAAargv[gaa_index]); \
399 gaa_arg_used[gaa_index] = 1; \
403 return GAA_ERROR_INVALID_ARG; \
412 #define GAA_LIST_FILL(target, func, type ,num) \
417 if ( gaa_last_non_option - gaa_index > 0) \
418 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
419 for(; gaa_index < gaa_last_non_option; gaa_index++) \
421 if(gaa_arg_used[gaa_index] == 0) \
423 GAA_FILL_2ARGS(target[num], func); \
428 return GAA_ERROR_NOTENOUGH_ARGS; \
431 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
436 if ( gaa_last_non_option - gaa_index > 0) \
437 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
438 for(; gaa_index < gaa_last_non_option; gaa_index++) \
440 if(gaa_arg_used[gaa_index] == 0) \
442 GAA_FILL_2ARGS(target[num], func); \
448 #define GAA_OBLIGAT(str) \
450 for(i = 0; i < strlen(str); i++) \
452 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
453 if(j == GAA_ERROR_NOMATCH) \
455 printf("Error: invalid 'obligat' set\n"); \
458 if(opt_list[j] == 1) \
463 if(strlen(str) == 1) \
464 printf("You must give the -%s option\n", str); \
466 printf("You must give at least one option of '%s'\n", str); \
470 #define GAA_INCOMP(str) \
472 for(i = 0; i < strlen(str); i++) \
474 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
475 if(j == GAA_ERROR_NOMATCH) \
477 printf("Error: invalid 'obligat' set\n"); \
480 if(opt_list[j] == 1) \
485 printf("The options '%s' are incompatible\n", str); \
490 static char **GAAargv
;
492 static char *gaa_arg_used
;
493 static int gaa_processing_file
= 0;
494 static int inited
= 0;
496 static int gaa_getint(char *arg
)
500 if(sscanf(arg
, "%d%c", &tmp
, &a
) < 1)
502 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
508 static char gaa_getchar(char *arg
)
512 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
518 static char* gaa_getstr(char *arg
)
522 static float gaa_getfloat(char *arg
)
526 if(sscanf(arg
, "%f%c", &tmp
, &a
) < 1)
528 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
533 /* option structures */
535 struct GAAOPTION_port
541 struct GAAOPTION_opaque_prf_input
547 struct GAAOPTION_pskkey
553 struct GAAOPTION_pskusername
559 struct GAAOPTION_srppasswd
565 struct GAAOPTION_srpusername
571 struct GAAOPTION_x509certfile
577 struct GAAOPTION_x509keyfile
583 struct GAAOPTION_pgpsubkey
589 struct GAAOPTION_pgpcertfile
595 struct GAAOPTION_pgpkeyring
601 struct GAAOPTION_pgpkeyfile
607 struct GAAOPTION_x509crlfile
613 struct GAAOPTION_x509cafile
619 struct GAAOPTION_priority
625 struct GAAOPTION_ctypes
637 struct GAAOPTION_macs
643 struct GAAOPTION_comp
649 struct GAAOPTION_protocols
655 struct GAAOPTION_ciphers
661 struct GAAOPTION_recordsize
667 struct GAAOPTION_debug
672 #define GAA_REST_EXISTS
681 static int gaa_is_an_argument(char *str
)
684 if(str
[0] == '/' && str
[1] != 0)
685 return GAA_MULTIPLE_OPTION
;
688 return GAA_NOT_AN_OPTION
;
690 return GAA_NOT_AN_OPTION
;
694 return GAA_WORD_OPTION
;
696 return GAA_NOT_AN_OPTION
;
699 return GAA_LETTER_OPTION
;
701 return GAA_MULTIPLE_OPTION
;
704 static int gaa_get_option_num(char *str
, int status
)
708 case GAA_LETTER_OPTION
:
709 GAA_CHECK1STR("p", GAAOPTID_port
);
710 GAA_CHECK1STR("", GAAOPTID_opaque_prf_input
);
711 GAA_CHECK1STR("", GAAOPTID_pskkey
);
712 GAA_CHECK1STR("", GAAOPTID_pskusername
);
713 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
714 GAA_CHECK1STR("", GAAOPTID_srpusername
);
715 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
716 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
717 GAA_CHECK1STR("", GAAOPTID_pgpsubkey
);
718 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
719 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
720 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
721 GAA_CHECK1STR("", GAAOPTID_x509crlfile
);
722 GAA_CHECK1STR("", GAAOPTID_x509cafile
);
723 GAA_CHECK1STR("", GAAOPTID_priority
);
724 GAA_CHECK1STR("", GAAOPTID_ctypes
);
725 GAA_CHECK1STR("", GAAOPTID_kx
);
726 GAA_CHECK1STR("", GAAOPTID_macs
);
727 GAA_CHECK1STR("", GAAOPTID_comp
);
728 GAA_CHECK1STR("", GAAOPTID_protocols
);
729 GAA_CHECK1STR("", GAAOPTID_ciphers
);
730 GAA_CHECK1STR("", GAAOPTID_recordsize
);
731 GAA_CHECK1STR("d", GAAOPTID_debug
);
732 case GAA_MULTIPLE_OPTION
:
734 GAA_CHECK1STR("", GAAOPTID_copyright
);
735 GAA_CHECK1STR("v", GAAOPTID_version
);
736 GAA_CHECK1STR("h", GAAOPTID_help
);
737 GAA_CHECK1STR("l", GAAOPTID_list
);
738 GAA_CHECK1STR("", GAAOPTID_insecure
);
739 GAA_CHECK1STR("V", GAAOPTID_verbose
);
740 GAA_CHECK1STR("", GAAOPTID_print_cert
);
741 GAA_CHECK1STR("", GAAOPTID_disable_extensions
);
742 GAA_CHECK1STR("f", GAAOPTID_fingerprint
);
743 GAA_CHECK1STR("", GAAOPTID_x509fmtder
);
744 GAA_CHECK1STR("", GAAOPTID_crlf
);
745 GAA_CHECK1STR("s", GAAOPTID_starttls
);
746 GAA_CHECK1STR("r", GAAOPTID_resume
);
750 case GAA_WORD_OPTION
:
751 GAA_CHECKSTR("copyright", GAAOPTID_copyright
);
752 GAA_CHECKSTR("version", GAAOPTID_version
);
753 GAA_CHECKSTR("help", GAAOPTID_help
);
754 GAA_CHECKSTR("list", GAAOPTID_list
);
755 GAA_CHECKSTR("insecure", GAAOPTID_insecure
);
756 GAA_CHECKSTR("port", GAAOPTID_port
);
757 GAA_CHECKSTR("opaque-prf-input", GAAOPTID_opaque_prf_input
);
758 GAA_CHECKSTR("pskkey", GAAOPTID_pskkey
);
759 GAA_CHECKSTR("pskusername", GAAOPTID_pskusername
);
760 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
761 GAA_CHECKSTR("srpusername", GAAOPTID_srpusername
);
762 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
763 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
764 GAA_CHECKSTR("pgpsubkey", GAAOPTID_pgpsubkey
);
765 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
766 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
767 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
768 GAA_CHECKSTR("x509crlfile", GAAOPTID_x509crlfile
);
769 GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile
);
770 GAA_CHECKSTR("priority", GAAOPTID_priority
);
771 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
772 GAA_CHECKSTR("kx", GAAOPTID_kx
);
773 GAA_CHECKSTR("macs", GAAOPTID_macs
);
774 GAA_CHECKSTR("comp", GAAOPTID_comp
);
775 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
776 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
777 GAA_CHECKSTR("verbose", GAAOPTID_verbose
);
778 GAA_CHECKSTR("recordsize", GAAOPTID_recordsize
);
779 GAA_CHECKSTR("print-cert", GAAOPTID_print_cert
);
780 GAA_CHECKSTR("disable-extensions", GAAOPTID_disable_extensions
);
781 GAA_CHECKSTR("fingerprint", GAAOPTID_fingerprint
);
782 GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder
);
783 GAA_CHECKSTR("crlf", GAAOPTID_crlf
);
784 GAA_CHECKSTR("starttls", GAAOPTID_starttls
);
785 GAA_CHECKSTR("resume", GAAOPTID_resume
);
786 GAA_CHECKSTR("debug", GAAOPTID_debug
);
792 return GAA_ERROR_NOMATCH
;
795 static int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
798 int gaa_last_non_option
;
799 struct GAAOPTION_port GAATMP_port
;
800 struct GAAOPTION_opaque_prf_input GAATMP_opaque_prf_input
;
801 struct GAAOPTION_pskkey GAATMP_pskkey
;
802 struct GAAOPTION_pskusername GAATMP_pskusername
;
803 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
804 struct GAAOPTION_srpusername GAATMP_srpusername
;
805 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
806 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
807 struct GAAOPTION_pgpsubkey GAATMP_pgpsubkey
;
808 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
809 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
810 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
811 struct GAAOPTION_x509crlfile GAATMP_x509crlfile
;
812 struct GAAOPTION_x509cafile GAATMP_x509cafile
;
813 struct GAAOPTION_priority GAATMP_priority
;
814 struct GAAOPTION_ctypes GAATMP_ctypes
;
815 struct GAAOPTION_kx GAATMP_kx
;
816 struct GAAOPTION_macs GAATMP_macs
;
817 struct GAAOPTION_comp GAATMP_comp
;
818 struct GAAOPTION_protocols GAATMP_protocols
;
819 struct GAAOPTION_ciphers GAATMP_ciphers
;
820 struct GAAOPTION_recordsize GAATMP_recordsize
;
821 struct GAAOPTION_debug GAATMP_debug
;
824 #ifdef GAA_REST_EXISTS
825 struct GAAREST GAAREST_tmp
;
828 opt_list
[gaa_num
] = 1;
830 for(gaa_last_non_option
= gaa_index
;
831 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
832 gaa_last_non_option
++);
834 if(gaa_num
== GAA_REST
)
837 gaa_last_non_option
= GAAargc
;
842 case GAAOPTID_copyright
:
845 { print_license(); exit(0); ;};
849 case GAAOPTID_version
:
852 { cli_version(); exit(0); ;};
859 { gaa_help(); exit(0); ;};
866 { print_list(gaaval
->verbose
); exit(0); ;};
870 case GAAOPTID_insecure
:
873 { gaaval
->insecure
= 1 ;};
880 GAA_FILL(GAATMP_port
.arg1
, gaa_getstr
, GAATMP_port
.size1
);
883 { gaaval
->port
= GAATMP_port
.arg1
;};
887 case GAAOPTID_opaque_prf_input
:
890 GAA_FILL(GAATMP_opaque_prf_input
.arg1
, gaa_getstr
, GAATMP_opaque_prf_input
.size1
);
893 { gaaval
->opaque_prf_input
= GAATMP_opaque_prf_input
.arg1
;};
897 case GAAOPTID_pskkey
:
900 GAA_FILL(GAATMP_pskkey
.arg1
, gaa_getstr
, GAATMP_pskkey
.size1
);
903 { gaaval
->psk_key
= GAATMP_pskkey
.arg1
;};
907 case GAAOPTID_pskusername
:
910 GAA_FILL(GAATMP_pskusername
.arg1
, gaa_getstr
, GAATMP_pskusername
.size1
);
913 { gaaval
->psk_username
= GAATMP_pskusername
.arg1
;};
917 case GAAOPTID_srppasswd
:
920 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
923 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
927 case GAAOPTID_srpusername
:
930 GAA_FILL(GAATMP_srpusername
.arg1
, gaa_getstr
, GAATMP_srpusername
.size1
);
933 { gaaval
->srp_username
= GAATMP_srpusername
.arg1
;};
937 case GAAOPTID_x509certfile
:
940 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
943 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
947 case GAAOPTID_x509keyfile
:
950 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
953 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
957 case GAAOPTID_pgpsubkey
:
960 GAA_FILL(GAATMP_pgpsubkey
.arg1
, gaa_getstr
, GAATMP_pgpsubkey
.size1
);
963 { gaaval
->pgp_subkey
= GAATMP_pgpsubkey
.arg1
;};
967 case GAAOPTID_pgpcertfile
:
970 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
973 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
977 case GAAOPTID_pgpkeyring
:
980 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
983 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
987 case GAAOPTID_pgpkeyfile
:
990 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
993 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
997 case GAAOPTID_x509crlfile
:
1000 GAA_FILL(GAATMP_x509crlfile
.arg1
, gaa_getstr
, GAATMP_x509crlfile
.size1
);
1003 { gaaval
->x509_crlfile
= GAATMP_x509crlfile
.arg1
;};
1007 case GAAOPTID_x509cafile
:
1010 GAA_FILL(GAATMP_x509cafile
.arg1
, gaa_getstr
, GAATMP_x509cafile
.size1
);
1013 { gaaval
->x509_cafile
= GAATMP_x509cafile
.arg1
;};
1017 case GAAOPTID_priority
:
1020 GAA_FILL(GAATMP_priority
.arg1
, gaa_getstr
, GAATMP_priority
.size1
);
1023 { gaaval
->priorities
= GAATMP_priority
.arg1
;};
1027 case GAAOPTID_ctypes
:
1029 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
1031 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
1037 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
1039 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
1045 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
1047 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
1053 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
1055 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
1059 case GAAOPTID_protocols
:
1061 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
1063 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
1067 case GAAOPTID_ciphers
:
1069 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
1071 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
1075 case GAAOPTID_verbose
:
1078 { gaaval
->verbose
= 1 ;};
1082 case GAAOPTID_recordsize
:
1085 GAA_FILL(GAATMP_recordsize
.arg1
, gaa_getint
, GAATMP_recordsize
.size1
);
1088 { gaaval
->record_size
= GAATMP_recordsize
.arg1
;};
1092 case GAAOPTID_print_cert
:
1095 { gaaval
->print_cert
= 1 ;};
1099 case GAAOPTID_disable_extensions
:
1102 { gaaval
->disable_extensions
= 1 ;};
1106 case GAAOPTID_fingerprint
:
1109 { gaaval
->fingerprint
= 1 ;};
1113 case GAAOPTID_x509fmtder
:
1116 { gaaval
->fmtder
= 1 ;};
1123 { gaaval
->crlf
= 1 ;};
1127 case GAAOPTID_starttls
:
1130 { gaaval
->starttls
= 1 ;};
1134 case GAAOPTID_resume
:
1137 { gaaval
->resume
= 1 ;};
1141 case GAAOPTID_debug
:
1144 GAA_FILL(GAATMP_debug
.arg1
, gaa_getint
, GAATMP_debug
.size1
);
1147 { gaaval
->debug
= GAATMP_debug
.arg1
;};
1153 GAA_FILL(GAAREST_tmp
.arg1
, gaa_getstr
, GAAREST_tmp
.size1
);
1156 { gaaval
->rest_args
= GAAREST_tmp
.arg1
; ;};
1161 #line 413 "gaa.skel"
1164 return GAA_ERROR_UNKNOWN
;
1167 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
1176 opt_list
= (char*) gaa_malloc(GAA_NB_OPTION
+ 1);
1178 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
1180 /* initialization */
1185 { gaaval
->resume
=0; gaaval
->port
="443"; gaaval
->rest_args
=NULL
; gaaval
->ciphers
=NULL
;
1186 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
1187 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0; gaaval
->record_size
=0;
1188 gaaval
->fingerprint
=0; gaaval
->pgp_keyring
=NULL
; gaaval
->x509_crlfile
= NULL
;
1189 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
; gaaval
->disable_extensions
= 0;
1190 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
; gaaval
->crlf
= 0;
1191 gaaval
->srp_username
=NULL
; gaaval
->srp_passwd
=NULL
; gaaval
->fmtder
= 0; gaaval
->starttls
=0;
1192 gaaval
->debug
= 0; gaaval
->print_cert
= 0; gaaval
->verbose
= 0; gaaval
->psk_key
= NULL
;
1193 gaaval
->psk_username
= NULL
; gaaval
->priorities
= NULL
;
1194 gaaval
->opaque_prf_input
= NULL
; gaaval
->pgp_subkey
= NULL
; ;};
1198 #line 438 "gaa.skel"
1199 gaa_arg_used
= NULL
;
1202 gaa_arg_used
= gaa_malloc(argc
* sizeof(char));
1205 for(i
= 1; i
< argc
; i
++)
1206 gaa_arg_used
[i
] = 0;
1207 for(i
= 1; i
< argc
; i
++)
1209 if(gaa_arg_used
[i
] == 0)
1212 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
1215 case GAA_WORD_OPTION
:
1217 case GAA_LETTER_OPTION
:
1219 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1220 if(tmp2
== GAA_ERROR_NOMATCH
)
1222 printf("Invalid option '%s'\n", argv
[i
]+j
);
1225 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1227 case GAA_ERROR_NOTENOUGH_ARGS
:
1228 printf("'%s': not enough arguments\n",gaa_current_option
);
1230 case GAA_ERROR_INVALID_ARG
:
1231 printf("Invalid arguments\n");
1236 printf("Unknown error\n");
1238 gaa_arg_used
[i
] = 1;
1240 case GAA_MULTIPLE_OPTION
:
1241 for(j
= 1; j
< strlen(argv
[i
]); j
++)
1243 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1244 if(tmp2
== GAA_ERROR_NOMATCH
)
1246 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
1249 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1251 case GAA_ERROR_NOTENOUGH_ARGS
:
1252 printf("'%s': not enough arguments\n",gaa_current_option
);
1254 case GAA_ERROR_INVALID_ARG
:
1255 printf("Invalid arguments\n");
1260 printf("Unknown error\n");
1263 gaa_arg_used
[i
] = 1;
1269 if(gaa_processing_file
== 0)
1272 #line 507 "gaa.skel"
1273 #ifdef GAA_REST_EXISTS
1274 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
1276 case GAA_ERROR_NOTENOUGH_ARGS
:
1277 printf("Rest: not enough arguments\n");
1279 case GAA_ERROR_INVALID_ARG
:
1280 printf("Invalid arguments\n");
1285 printf("Unknown error\n");
1289 for(i
= 1; i
< argc
; i
++)
1291 if(gaa_arg_used
[i
] == 0)
1293 printf("Too many arguments\n");
1305 struct gaastrnode
*next
;
1308 typedef struct gaastrnode gaa_str_node
;
1310 static int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1314 int i
= 0, len
= 0, newline
= 0;
1322 if (a
== EOF
) return 0;
1324 while(a
== ' ' || a
== 9 || a
== '\n')
1332 if (a
== EOF
) return 0;
1335 pos_ini
= ftell(file
) - 1;
1337 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1342 if(a
==EOF
) return 0; //a = ' ';
1346 tmp_str
->str
= gaa_malloc((len
) * sizeof(char));
1350 tmp_str
->str
[0] = '-';
1351 tmp_str
->str
[1] = '-';
1359 fseek(file
,pos_ini
, SEEK_SET
);
1368 tmp_str
->str
[i
] = a
;
1371 while(a
!= ' ' && a
!= 9 && a
!= '\n' && i
< len
);
1373 tmp_str
->str
[i
- 1] = 0;
1375 fseek(file
,- 1, SEEK_CUR
);
1376 /* printf("%d\n", ftell(file)); */
1381 int gaa_file(const char *name
, gaainfo
*gaaval
)
1383 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1389 gaa_processing_file
= 1;
1391 if((file
= fopen(name
, "r")) == NULL
)
1393 printf("Couldn't open '%s' configuration file for reading\n", name
);
1397 tmp_str
= &first_str
;
1401 *tmp_str
= gaa_malloc(sizeof(gaa_str_node
));
1403 (*tmp_str
)->str
= NULL
;
1404 (*tmp_str
)->next
= NULL
;
1406 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1407 tmp_str
= &((*tmp_str
)->next
);
1414 argv
= gaa_malloc((1 + argc
) * sizeof(char*));
1416 tmp_str2
= first_str
;
1418 for(i
= 1; i
< argc
; i
++)
1420 argv
[i
] = tmp_str2
->str
;
1421 tmp_str2
= tmp_str2
->next
;
1424 rval
= gaa(argc
, argv
, gaaval
);
1425 gaa_processing_file
= 0;