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, "x509keyfile", "FILE ", "X.509 key file to use.");
153 __gaa_helpsingle(0, "x509certfile", "FILE ", "X.509 Certificate file to use.");
154 __gaa_helpsingle(0, "srpusername", "NAME ", "SRP username to use.");
155 __gaa_helpsingle(0, "srppasswd", "PASSWD ", "SRP password to use.");
156 __gaa_helpsingle(0, "pskusername", "NAME ", "PSK username to use.");
157 __gaa_helpsingle(0, "pskkey", "KEY ", "PSK key (in hex) to use.");
158 __gaa_helpsingle(0, "opaque-prf-input", "DATA ", "Use Opaque PRF Input DATA.");
159 __gaa_helpsingle('p', "port", "PORT ", "The port to connect to.");
160 __gaa_helpsingle(0, "insecure", "", "Don't abort program if server certificate can't be validated.");
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
;
186 char *opaque_prf_input
;
242 int disable_extensions
;
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 35
310 #define GAAOPTID_copyright 1
311 #define GAAOPTID_version 2
312 #define GAAOPTID_help 3
313 #define GAAOPTID_list 4
314 #define GAAOPTID_insecure 5
315 #define GAAOPTID_port 6
316 #define GAAOPTID_opaque_prf_input 7
317 #define GAAOPTID_pskkey 8
318 #define GAAOPTID_pskusername 9
319 #define GAAOPTID_srppasswd 10
320 #define GAAOPTID_srpusername 11
321 #define GAAOPTID_x509certfile 12
322 #define GAAOPTID_x509keyfile 13
323 #define GAAOPTID_pgpcertfile 14
324 #define GAAOPTID_pgpkeyring 15
325 #define GAAOPTID_pgpkeyfile 16
326 #define GAAOPTID_x509crlfile 17
327 #define GAAOPTID_x509cafile 18
328 #define GAAOPTID_priority 19
329 #define GAAOPTID_ctypes 20
330 #define GAAOPTID_kx 21
331 #define GAAOPTID_macs 22
332 #define GAAOPTID_comp 23
333 #define GAAOPTID_protocols 24
334 #define GAAOPTID_ciphers 25
335 #define GAAOPTID_verbose 26
336 #define GAAOPTID_recordsize 27
337 #define GAAOPTID_print_cert 28
338 #define GAAOPTID_disable_extensions 29
339 #define GAAOPTID_fingerprint 30
340 #define GAAOPTID_x509fmtder 31
341 #define GAAOPTID_crlf 32
342 #define GAAOPTID_starttls 33
343 #define GAAOPTID_resume 34
344 #define GAAOPTID_debug 35
348 #define GAA_CHECK1STR(a,b) \
351 gaa_current_option = a; \
355 #define GAA_CHECKSTR(a,b) \
356 if(strcmp(a,str) == 0) \
358 gaa_current_option = a; \
362 #define GAA_TESTMOREARGS \
365 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
367 if(gaa_last_non_option == gaa_index) \
368 return GAA_ERROR_NOTENOUGH_ARGS; \
371 #define GAA_TESTMOREOPTIONALARGS \
374 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
376 if(gaa_last_non_option == gaa_index) \
380 #define GAA_FILL_2ARGS(target, func) \
381 target = func(GAAargv[gaa_index]); \
382 gaa_arg_used[gaa_index] = 1; \
386 return GAA_ERROR_INVALID_ARG; \
391 #define GAA_FILL(target, func, num) \
394 target = func(GAAargv[gaa_index]); \
395 gaa_arg_used[gaa_index] = 1; \
399 return GAA_ERROR_INVALID_ARG; \
408 #define GAA_LIST_FILL(target, func, type ,num) \
413 if ( gaa_last_non_option - gaa_index > 0) \
414 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
415 for(; gaa_index < gaa_last_non_option; gaa_index++) \
417 if(gaa_arg_used[gaa_index] == 0) \
419 GAA_FILL_2ARGS(target[num], func); \
424 return GAA_ERROR_NOTENOUGH_ARGS; \
427 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
432 if ( gaa_last_non_option - gaa_index > 0) \
433 target = gaa_malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
434 for(; gaa_index < gaa_last_non_option; gaa_index++) \
436 if(gaa_arg_used[gaa_index] == 0) \
438 GAA_FILL_2ARGS(target[num], func); \
444 #define GAA_OBLIGAT(str) \
446 for(i = 0; i < strlen(str); i++) \
448 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
449 if(j == GAA_ERROR_NOMATCH) \
451 printf("Error: invalid 'obligat' set\n"); \
454 if(opt_list[j] == 1) \
459 if(strlen(str) == 1) \
460 printf("You must give the -%s option\n", str); \
462 printf("You must give at least one option of '%s'\n", str); \
466 #define GAA_INCOMP(str) \
468 for(i = 0; i < strlen(str); i++) \
470 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
471 if(j == GAA_ERROR_NOMATCH) \
473 printf("Error: invalid 'obligat' set\n"); \
476 if(opt_list[j] == 1) \
481 printf("The options '%s' are incompatible\n", str); \
486 static char **GAAargv
;
488 static char *gaa_arg_used
;
489 static int gaa_processing_file
= 0;
490 static int inited
= 0;
492 static int gaa_getint(char *arg
)
496 if(sscanf(arg
, "%d%c", &tmp
, &a
) < 1)
498 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
504 static char gaa_getchar(char *arg
)
508 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
514 static char* gaa_getstr(char *arg
)
518 static float gaa_getfloat(char *arg
)
522 if(sscanf(arg
, "%f%c", &tmp
, &a
) < 1)
524 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
529 /* option structures */
531 struct GAAOPTION_port
537 struct GAAOPTION_opaque_prf_input
543 struct GAAOPTION_pskkey
549 struct GAAOPTION_pskusername
555 struct GAAOPTION_srppasswd
561 struct GAAOPTION_srpusername
567 struct GAAOPTION_x509certfile
573 struct GAAOPTION_x509keyfile
579 struct GAAOPTION_pgpcertfile
585 struct GAAOPTION_pgpkeyring
591 struct GAAOPTION_pgpkeyfile
597 struct GAAOPTION_x509crlfile
603 struct GAAOPTION_x509cafile
609 struct GAAOPTION_priority
615 struct GAAOPTION_ctypes
627 struct GAAOPTION_macs
633 struct GAAOPTION_comp
639 struct GAAOPTION_protocols
645 struct GAAOPTION_ciphers
651 struct GAAOPTION_recordsize
657 struct GAAOPTION_debug
662 #define GAA_REST_EXISTS
671 static int gaa_is_an_argument(char *str
)
674 if(str
[0] == '/' && str
[1] != 0)
675 return GAA_MULTIPLE_OPTION
;
678 return GAA_NOT_AN_OPTION
;
680 return GAA_NOT_AN_OPTION
;
684 return GAA_WORD_OPTION
;
686 return GAA_NOT_AN_OPTION
;
689 return GAA_LETTER_OPTION
;
691 return GAA_MULTIPLE_OPTION
;
694 static int gaa_get_option_num(char *str
, int status
)
698 case GAA_LETTER_OPTION
:
699 GAA_CHECK1STR("p", GAAOPTID_port
);
700 GAA_CHECK1STR("", GAAOPTID_opaque_prf_input
);
701 GAA_CHECK1STR("", GAAOPTID_pskkey
);
702 GAA_CHECK1STR("", GAAOPTID_pskusername
);
703 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
704 GAA_CHECK1STR("", GAAOPTID_srpusername
);
705 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
706 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
707 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
708 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
709 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
710 GAA_CHECK1STR("", GAAOPTID_x509crlfile
);
711 GAA_CHECK1STR("", GAAOPTID_x509cafile
);
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_recordsize
);
720 GAA_CHECK1STR("d", GAAOPTID_debug
);
721 case GAA_MULTIPLE_OPTION
:
723 GAA_CHECK1STR("", GAAOPTID_copyright
);
724 GAA_CHECK1STR("v", GAAOPTID_version
);
725 GAA_CHECK1STR("h", GAAOPTID_help
);
726 GAA_CHECK1STR("l", GAAOPTID_list
);
727 GAA_CHECK1STR("", GAAOPTID_insecure
);
728 GAA_CHECK1STR("V", GAAOPTID_verbose
);
729 GAA_CHECK1STR("", GAAOPTID_print_cert
);
730 GAA_CHECK1STR("", GAAOPTID_disable_extensions
);
731 GAA_CHECK1STR("f", GAAOPTID_fingerprint
);
732 GAA_CHECK1STR("", GAAOPTID_x509fmtder
);
733 GAA_CHECK1STR("", GAAOPTID_crlf
);
734 GAA_CHECK1STR("s", GAAOPTID_starttls
);
735 GAA_CHECK1STR("r", GAAOPTID_resume
);
739 case GAA_WORD_OPTION
:
740 GAA_CHECKSTR("copyright", GAAOPTID_copyright
);
741 GAA_CHECKSTR("version", GAAOPTID_version
);
742 GAA_CHECKSTR("help", GAAOPTID_help
);
743 GAA_CHECKSTR("list", GAAOPTID_list
);
744 GAA_CHECKSTR("insecure", GAAOPTID_insecure
);
745 GAA_CHECKSTR("port", GAAOPTID_port
);
746 GAA_CHECKSTR("opaque-prf-input", GAAOPTID_opaque_prf_input
);
747 GAA_CHECKSTR("pskkey", GAAOPTID_pskkey
);
748 GAA_CHECKSTR("pskusername", GAAOPTID_pskusername
);
749 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
750 GAA_CHECKSTR("srpusername", GAAOPTID_srpusername
);
751 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
752 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
753 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
754 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
755 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
756 GAA_CHECKSTR("x509crlfile", GAAOPTID_x509crlfile
);
757 GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile
);
758 GAA_CHECKSTR("priority", GAAOPTID_priority
);
759 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
760 GAA_CHECKSTR("kx", GAAOPTID_kx
);
761 GAA_CHECKSTR("macs", GAAOPTID_macs
);
762 GAA_CHECKSTR("comp", GAAOPTID_comp
);
763 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
764 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
765 GAA_CHECKSTR("verbose", GAAOPTID_verbose
);
766 GAA_CHECKSTR("recordsize", GAAOPTID_recordsize
);
767 GAA_CHECKSTR("print-cert", GAAOPTID_print_cert
);
768 GAA_CHECKSTR("disable-extensions", GAAOPTID_disable_extensions
);
769 GAA_CHECKSTR("fingerprint", GAAOPTID_fingerprint
);
770 GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder
);
771 GAA_CHECKSTR("crlf", GAAOPTID_crlf
);
772 GAA_CHECKSTR("starttls", GAAOPTID_starttls
);
773 GAA_CHECKSTR("resume", GAAOPTID_resume
);
774 GAA_CHECKSTR("debug", GAAOPTID_debug
);
780 return GAA_ERROR_NOMATCH
;
783 static int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
786 int gaa_last_non_option
;
787 struct GAAOPTION_port GAATMP_port
;
788 struct GAAOPTION_opaque_prf_input GAATMP_opaque_prf_input
;
789 struct GAAOPTION_pskkey GAATMP_pskkey
;
790 struct GAAOPTION_pskusername GAATMP_pskusername
;
791 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
792 struct GAAOPTION_srpusername GAATMP_srpusername
;
793 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
794 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
795 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
796 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
797 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
798 struct GAAOPTION_x509crlfile GAATMP_x509crlfile
;
799 struct GAAOPTION_x509cafile GAATMP_x509cafile
;
800 struct GAAOPTION_priority GAATMP_priority
;
801 struct GAAOPTION_ctypes GAATMP_ctypes
;
802 struct GAAOPTION_kx GAATMP_kx
;
803 struct GAAOPTION_macs GAATMP_macs
;
804 struct GAAOPTION_comp GAATMP_comp
;
805 struct GAAOPTION_protocols GAATMP_protocols
;
806 struct GAAOPTION_ciphers GAATMP_ciphers
;
807 struct GAAOPTION_recordsize GAATMP_recordsize
;
808 struct GAAOPTION_debug GAATMP_debug
;
811 #ifdef GAA_REST_EXISTS
812 struct GAAREST GAAREST_tmp
;
815 opt_list
[gaa_num
] = 1;
817 for(gaa_last_non_option
= gaa_index
;
818 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
819 gaa_last_non_option
++);
821 if(gaa_num
== GAA_REST
)
824 gaa_last_non_option
= GAAargc
;
829 case GAAOPTID_copyright
:
832 { print_license(); exit(0); ;};
836 case GAAOPTID_version
:
839 { cli_version(); exit(0); ;};
846 { gaa_help(); exit(0); ;};
853 { print_list(gaaval
->verbose
); exit(0); ;};
857 case GAAOPTID_insecure
:
860 { gaaval
->insecure
= 1 ;};
867 GAA_FILL(GAATMP_port
.arg1
, gaa_getstr
, GAATMP_port
.size1
);
870 { gaaval
->port
= GAATMP_port
.arg1
;};
874 case GAAOPTID_opaque_prf_input
:
877 GAA_FILL(GAATMP_opaque_prf_input
.arg1
, gaa_getstr
, GAATMP_opaque_prf_input
.size1
);
880 { gaaval
->opaque_prf_input
= GAATMP_opaque_prf_input
.arg1
;};
884 case GAAOPTID_pskkey
:
887 GAA_FILL(GAATMP_pskkey
.arg1
, gaa_getstr
, GAATMP_pskkey
.size1
);
890 { gaaval
->psk_key
= GAATMP_pskkey
.arg1
;};
894 case GAAOPTID_pskusername
:
897 GAA_FILL(GAATMP_pskusername
.arg1
, gaa_getstr
, GAATMP_pskusername
.size1
);
900 { gaaval
->psk_username
= GAATMP_pskusername
.arg1
;};
904 case GAAOPTID_srppasswd
:
907 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
910 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
914 case GAAOPTID_srpusername
:
917 GAA_FILL(GAATMP_srpusername
.arg1
, gaa_getstr
, GAATMP_srpusername
.size1
);
920 { gaaval
->srp_username
= GAATMP_srpusername
.arg1
;};
924 case GAAOPTID_x509certfile
:
927 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
930 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
934 case GAAOPTID_x509keyfile
:
937 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
940 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
944 case GAAOPTID_pgpcertfile
:
947 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
950 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
954 case GAAOPTID_pgpkeyring
:
957 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
960 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
964 case GAAOPTID_pgpkeyfile
:
967 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
970 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
974 case GAAOPTID_x509crlfile
:
977 GAA_FILL(GAATMP_x509crlfile
.arg1
, gaa_getstr
, GAATMP_x509crlfile
.size1
);
980 { gaaval
->x509_crlfile
= GAATMP_x509crlfile
.arg1
;};
984 case GAAOPTID_x509cafile
:
987 GAA_FILL(GAATMP_x509cafile
.arg1
, gaa_getstr
, GAATMP_x509cafile
.size1
);
990 { gaaval
->x509_cafile
= GAATMP_x509cafile
.arg1
;};
994 case GAAOPTID_priority
:
997 GAA_FILL(GAATMP_priority
.arg1
, gaa_getstr
, GAATMP_priority
.size1
);
1000 { gaaval
->priorities
= GAATMP_priority
.arg1
;};
1004 case GAAOPTID_ctypes
:
1006 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
1008 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
1014 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
1016 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
1022 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
1024 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
1030 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
1032 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
1036 case GAAOPTID_protocols
:
1038 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
1040 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
1044 case GAAOPTID_ciphers
:
1046 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
1048 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
1052 case GAAOPTID_verbose
:
1055 { gaaval
->verbose
= 1 ;};
1059 case GAAOPTID_recordsize
:
1062 GAA_FILL(GAATMP_recordsize
.arg1
, gaa_getint
, GAATMP_recordsize
.size1
);
1065 { gaaval
->record_size
= GAATMP_recordsize
.arg1
;};
1069 case GAAOPTID_print_cert
:
1072 { gaaval
->print_cert
= 1 ;};
1076 case GAAOPTID_disable_extensions
:
1079 { gaaval
->disable_extensions
= 1 ;};
1083 case GAAOPTID_fingerprint
:
1086 { gaaval
->fingerprint
= 1 ;};
1090 case GAAOPTID_x509fmtder
:
1093 { gaaval
->fmtder
= 1 ;};
1100 { gaaval
->crlf
= 1 ;};
1104 case GAAOPTID_starttls
:
1107 { gaaval
->starttls
= 1 ;};
1111 case GAAOPTID_resume
:
1114 { gaaval
->resume
= 1 ;};
1118 case GAAOPTID_debug
:
1121 GAA_FILL(GAATMP_debug
.arg1
, gaa_getint
, GAATMP_debug
.size1
);
1124 { gaaval
->debug
= GAATMP_debug
.arg1
;};
1130 GAA_FILL(GAAREST_tmp
.arg1
, gaa_getstr
, GAAREST_tmp
.size1
);
1133 { gaaval
->rest_args
= GAAREST_tmp
.arg1
; ;};
1138 #line 413 "gaa.skel"
1141 return GAA_ERROR_UNKNOWN
;
1144 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
1153 opt_list
= (char*) gaa_malloc(GAA_NB_OPTION
+ 1);
1155 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
1157 /* initialization */
1162 { gaaval
->resume
=0; gaaval
->port
="443"; gaaval
->rest_args
=NULL
; gaaval
->ciphers
=NULL
;
1163 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
1164 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0; gaaval
->record_size
=0;
1165 gaaval
->fingerprint
=0; gaaval
->pgp_keyring
=NULL
; gaaval
->x509_crlfile
= NULL
;
1166 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
; gaaval
->disable_extensions
= 0;
1167 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
; gaaval
->crlf
= 0;
1168 gaaval
->srp_username
=NULL
; gaaval
->srp_passwd
=NULL
; gaaval
->fmtder
= 0; gaaval
->starttls
=0;
1169 gaaval
->debug
= 0; gaaval
->print_cert
= 0; gaaval
->verbose
= 0; gaaval
->psk_key
= NULL
;
1170 gaaval
->psk_username
= NULL
; gaaval
->priorities
= NULL
;
1171 gaaval
->opaque_prf_input
= NULL
; ;};
1175 #line 438 "gaa.skel"
1176 gaa_arg_used
= NULL
;
1179 gaa_arg_used
= gaa_malloc(argc
* sizeof(char));
1182 for(i
= 1; i
< argc
; i
++)
1183 gaa_arg_used
[i
] = 0;
1184 for(i
= 1; i
< argc
; i
++)
1186 if(gaa_arg_used
[i
] == 0)
1189 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
1192 case GAA_WORD_OPTION
:
1194 case GAA_LETTER_OPTION
:
1196 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1197 if(tmp2
== GAA_ERROR_NOMATCH
)
1199 printf("Invalid option '%s'\n", argv
[i
]+j
);
1202 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1204 case GAA_ERROR_NOTENOUGH_ARGS
:
1205 printf("'%s': not enough arguments\n",gaa_current_option
);
1207 case GAA_ERROR_INVALID_ARG
:
1208 printf("Invalid arguments\n");
1213 printf("Unknown error\n");
1215 gaa_arg_used
[i
] = 1;
1217 case GAA_MULTIPLE_OPTION
:
1218 for(j
= 1; j
< strlen(argv
[i
]); j
++)
1220 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
1221 if(tmp2
== GAA_ERROR_NOMATCH
)
1223 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
1226 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1228 case GAA_ERROR_NOTENOUGH_ARGS
:
1229 printf("'%s': not enough arguments\n",gaa_current_option
);
1231 case GAA_ERROR_INVALID_ARG
:
1232 printf("Invalid arguments\n");
1237 printf("Unknown error\n");
1240 gaa_arg_used
[i
] = 1;
1246 if(gaa_processing_file
== 0)
1249 #line 507 "gaa.skel"
1250 #ifdef GAA_REST_EXISTS
1251 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
1253 case GAA_ERROR_NOTENOUGH_ARGS
:
1254 printf("Rest: not enough arguments\n");
1256 case GAA_ERROR_INVALID_ARG
:
1257 printf("Invalid arguments\n");
1262 printf("Unknown error\n");
1266 for(i
= 1; i
< argc
; i
++)
1268 if(gaa_arg_used
[i
] == 0)
1270 printf("Too many arguments\n");
1282 struct gaastrnode
*next
;
1285 typedef struct gaastrnode gaa_str_node
;
1287 static int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1291 int i
= 0, len
= 0, newline
= 0;
1299 if (a
== EOF
) return 0;
1301 while(a
== ' ' || a
== 9 || a
== '\n')
1309 if (a
== EOF
) return 0;
1312 pos_ini
= ftell(file
) - 1;
1314 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1319 if(a
==EOF
) return 0; //a = ' ';
1323 tmp_str
->str
= gaa_malloc((len
) * sizeof(char));
1327 tmp_str
->str
[0] = '-';
1328 tmp_str
->str
[1] = '-';
1336 fseek(file
,pos_ini
, SEEK_SET
);
1345 tmp_str
->str
[i
] = a
;
1348 while(a
!= ' ' && a
!= 9 && a
!= '\n' && i
< len
);
1350 tmp_str
->str
[i
- 1] = 0;
1352 fseek(file
,- 1, SEEK_CUR
);
1353 /* printf("%d\n", ftell(file)); */
1358 int gaa_file(const char *name
, gaainfo
*gaaval
)
1360 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1366 gaa_processing_file
= 1;
1368 if((file
= fopen(name
, "r")) == NULL
)
1370 printf("Couldn't open '%s' configuration file for reading\n", name
);
1374 tmp_str
= &first_str
;
1378 *tmp_str
= gaa_malloc(sizeof(gaa_str_node
));
1380 (*tmp_str
)->str
= NULL
;
1381 (*tmp_str
)->next
= NULL
;
1383 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1384 tmp_str
= &((*tmp_str
)->next
);
1391 argv
= gaa_malloc((1 + argc
) * sizeof(char*));
1393 tmp_str2
= first_str
;
1395 for(i
= 1; i
< argc
; i
++)
1397 argv
[i
] = tmp_str2
->str
;
1398 tmp_str2
= tmp_str2
->next
;
1401 rval
= gaa(argc
, argv
, gaaval
);
1402 gaa_processing_file
= 0;