1 /* File generated by GAA 1.6.0
13 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
18 void __gaa_helpsingle(char short_name
, char *name
,
19 char *arg_desc
, char *opt_help
)
21 int col1
, col3
, col4
, tabsize
= 3, curr
;
24 col1
= 5; /* Default values */
29 for(i
= 0; i
< col1
; i
++)
38 printf("-%c, ", short_name
);
43 printf("-%c ", short_name
);
49 printf("--%s ", name
);
50 curr
+= 3 + strlen(name
);
52 if(arg_desc
&& *arg_desc
)
54 printf("%s ", arg_desc
);
55 curr
+= 1 + strlen(arg_desc
);
62 if(opt_help
) /* let's print the option's help body */
64 const char *str
= opt_help
;
84 while((curr
- col3
) % tabsize
!= 0 && curr
< col4
);
91 for(i
= 1; str
[i
] && str
[i
] != ' ' && str
[i
] != '\n'
92 && str
[i
] != '\t'; i
++);
93 if(curr
+ i
- 1 >= col4
)
113 printf("gnutls-cli help\nUsage: gnutls-cli [options] hostname""\n");
114 __gaa_helpsingle('r', "resume", "", "Connect, establish a session. Connect again and resume this session.");
115 __gaa_helpsingle(0, "crlf", "", "Send CR LF instead of LF.");
116 __gaa_helpsingle(0, "x509fmtder", "", "Use DER format for certificates");
117 __gaa_helpsingle('f', "fingerprint", "", "Send the openpgp fingerprint, instead of the key.");
118 __gaa_helpsingle('p', "port", """integer"" ", "The port to connect to.");
119 __gaa_helpsingle(0, "recordsize", """integer"" ", "The maximum record size to advertize.");
120 __gaa_helpsingle(0, "ciphers", """cipher1 cipher2..."" ", "Ciphers to enable.");
121 __gaa_helpsingle(0, "protocols", """protocol1 protocol2..."" ", "Protocols to enable.");
122 __gaa_helpsingle(0, "comp", """comp1 comp2..."" ", "Compression methods to enable.");
123 __gaa_helpsingle(0, "macs", """mac1 mac2..."" ", "MACs to enable.");
124 __gaa_helpsingle(0, "kx", """kx1 kx2..."" ", "Key exchange methods to enable.");
125 __gaa_helpsingle(0, "ctypes", """certType1 certType2..."" ", "Certificate types to enable.");
126 __gaa_helpsingle(0, "x509cafile", """FILE"" ", "Certificate file to use.");
127 __gaa_helpsingle(0, "pgpkeyfile", """FILE"" ", "PGP Key file to use.");
128 __gaa_helpsingle(0, "pgpkeyring", """FILE"" ", "PGP Key ring file to use.");
129 __gaa_helpsingle(0, "pgptrustdb", """FILE"" ", "PGP trustdb file to use.");
130 __gaa_helpsingle(0, "pgpcertfile", """FILE"" ", "PGP Public Key (certificate) file to use.");
131 __gaa_helpsingle(0, "x509keyfile", """FILE"" ", "X.509 key file to use.");
132 __gaa_helpsingle(0, "x509certfile", """FILE"" ", "X.509 Certificate file to use.");
133 __gaa_helpsingle(0, "srpusername", """NAME"" ", "SRP username to use.");
134 __gaa_helpsingle(0, "srppasswd", """PASSWD"" ", "SRP password to use.");
135 __gaa_helpsingle('l', "list", "", "Print a list of the supported algorithms and modes.");
136 __gaa_helpsingle('h', "help", "", "prints this help");
144 #ifndef GAA_HEADER_POKY
145 #define GAA_HEADER_POKY
147 typedef struct _gaainfo gaainfo
;
218 int gaa(int argc
, char *argv
[], gaainfo
*gaaval
);
222 int gaa_file(char *name
, gaainfo
*gaaval
);
235 #define GAAERROR(x) \
241 char *gaa_current_option
;
244 /* Generated by gaa */
252 #define GAA_ERROR_NOMATCH 0
253 #define GAA_ERROR_NOTENOUGH_ARGS 1
254 #define GAA_ERROR_INVALID_ARG 2
255 #define GAA_ERROR_UNKNOWN 3
257 #define GAA_NOT_AN_OPTION 0
258 #define GAA_WORD_OPTION 1
259 #define GAA_LETTER_OPTION 2
260 #define GAA_MULTIPLE_OPTION 3
263 #define GAA_NB_OPTION 23
264 #define GAAOPTID_help 1
265 #define GAAOPTID_list 2
266 #define GAAOPTID_srppasswd 3
267 #define GAAOPTID_srpusername 4
268 #define GAAOPTID_x509certfile 5
269 #define GAAOPTID_x509keyfile 6
270 #define GAAOPTID_pgpcertfile 7
271 #define GAAOPTID_pgptrustdb 8
272 #define GAAOPTID_pgpkeyring 9
273 #define GAAOPTID_pgpkeyfile 10
274 #define GAAOPTID_x509cafile 11
275 #define GAAOPTID_ctypes 12
276 #define GAAOPTID_kx 13
277 #define GAAOPTID_macs 14
278 #define GAAOPTID_comp 15
279 #define GAAOPTID_protocols 16
280 #define GAAOPTID_ciphers 17
281 #define GAAOPTID_recordsize 18
282 #define GAAOPTID_port 19
283 #define GAAOPTID_fingerprint 20
284 #define GAAOPTID_x509fmtder 21
285 #define GAAOPTID_crlf 22
286 #define GAAOPTID_resume 23
290 #define GAA_CHECK1STR(a,b) \
293 gaa_current_option = a; \
297 #define GAA_CHECKSTR(a,b) \
298 if(strcmp(a,str) == 0) \
300 gaa_current_option = a; \
304 #define GAA_TESTMOREARGS \
307 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
309 if(gaa_last_non_option == gaa_index) \
310 return GAA_ERROR_NOTENOUGH_ARGS; \
313 #define GAA_TESTMOREOPTIONALARGS \
316 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
318 if(gaa_last_non_option == gaa_index) \
322 #define GAA_FILL_2ARGS(target, func) \
323 target = func(GAAargv[gaa_index]); \
324 gaa_arg_used[gaa_index] = 1; \
328 return GAA_ERROR_INVALID_ARG; \
333 #define GAA_FILL(target, func, num) \
336 target = func(GAAargv[gaa_index]); \
337 gaa_arg_used[gaa_index] = 1; \
341 return GAA_ERROR_INVALID_ARG; \
350 #define GAA_LIST_FILL(target, func, type ,num) \
355 if ( gaa_last_non_option - gaa_index > 0) \
356 target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
357 for(; gaa_index < gaa_last_non_option; gaa_index++) \
359 if(gaa_arg_used[gaa_index] == 0) \
361 GAA_FILL_2ARGS(target[num], func); \
366 return GAA_ERROR_NOTENOUGH_ARGS; \
369 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
374 if ( gaa_last_non_option - gaa_index > 0) \
375 target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
376 for(; gaa_index < gaa_last_non_option; gaa_index++) \
378 if(gaa_arg_used[gaa_index] == 0) \
380 GAA_FILL_2ARGS(target[num], func); \
386 #define GAA_OBLIGAT(str) \
388 for(i = 0; i < strlen(str); i++) \
390 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
391 if(j == GAA_ERROR_NOMATCH) \
393 printf("Error: invalid 'obligat' set\n"); \
396 if(opt_list[j] == 1) \
401 if(strlen(str) == 1) \
402 printf("You must give the -%s option\n", str); \
404 printf("You must give at least one option of '%s'\n", str); \
408 #define GAA_INCOMP(str) \
410 for(i = 0; i < strlen(str); i++) \
412 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
413 if(j == GAA_ERROR_NOMATCH) \
415 printf("Error: invalid 'obligat' set\n"); \
418 if(opt_list[j] == 1) \
423 printf("The options '%s' are incompatible\n", str); \
431 int gaa_processing_file
= 0;
434 int gaa_getint(char *arg
)
438 if(sscanf(arg
, "%d%c", &tmp
, &a
) != 1)
440 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
446 char gaa_getchar(char *arg
)
450 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
456 char* gaa_getstr(char *arg
)
460 float gaa_getfloat(char *arg
)
464 if(sscanf(arg
, "%f%c", &tmp
, &a
) != 1)
466 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
471 /* option structures */
473 struct GAAOPTION_srppasswd
479 struct GAAOPTION_srpusername
485 struct GAAOPTION_x509certfile
491 struct GAAOPTION_x509keyfile
497 struct GAAOPTION_pgpcertfile
503 struct GAAOPTION_pgptrustdb
509 struct GAAOPTION_pgpkeyring
515 struct GAAOPTION_pgpkeyfile
521 struct GAAOPTION_x509cafile
527 struct GAAOPTION_ctypes
539 struct GAAOPTION_macs
545 struct GAAOPTION_comp
551 struct GAAOPTION_protocols
557 struct GAAOPTION_ciphers
563 struct GAAOPTION_recordsize
569 struct GAAOPTION_port
574 #define GAA_REST_EXISTS
583 int gaa_is_an_argument(char *str
)
586 if(str
[0] == '/' && str
[1] != 0)
587 return GAA_MULTIPLE_OPTION
;
590 return GAA_NOT_AN_OPTION
;
592 return GAA_NOT_AN_OPTION
;
596 return GAA_WORD_OPTION
;
598 return GAA_NOT_AN_OPTION
;
601 return GAA_LETTER_OPTION
;
603 return GAA_MULTIPLE_OPTION
;
606 int gaa_get_option_num(char *str
, int status
)
610 case GAA_LETTER_OPTION
:
611 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
612 GAA_CHECK1STR("", GAAOPTID_srpusername
);
613 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
614 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
615 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
616 GAA_CHECK1STR("", GAAOPTID_pgptrustdb
);
617 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
618 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
619 GAA_CHECK1STR("", GAAOPTID_x509cafile
);
620 GAA_CHECK1STR("", GAAOPTID_ctypes
);
621 GAA_CHECK1STR("", GAAOPTID_kx
);
622 GAA_CHECK1STR("", GAAOPTID_macs
);
623 GAA_CHECK1STR("", GAAOPTID_comp
);
624 GAA_CHECK1STR("", GAAOPTID_protocols
);
625 GAA_CHECK1STR("", GAAOPTID_ciphers
);
626 GAA_CHECK1STR("", GAAOPTID_recordsize
);
627 GAA_CHECK1STR("p", GAAOPTID_port
);
628 case GAA_MULTIPLE_OPTION
:
630 GAA_CHECK1STR("h", GAAOPTID_help
);
631 GAA_CHECK1STR("l", GAAOPTID_list
);
632 GAA_CHECK1STR("f", GAAOPTID_fingerprint
);
633 GAA_CHECK1STR("", GAAOPTID_x509fmtder
);
634 GAA_CHECK1STR("", GAAOPTID_crlf
);
635 GAA_CHECK1STR("r", GAAOPTID_resume
);
639 case GAA_WORD_OPTION
:
640 GAA_CHECKSTR("help", GAAOPTID_help
);
641 GAA_CHECKSTR("list", GAAOPTID_list
);
642 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
643 GAA_CHECKSTR("srpusername", GAAOPTID_srpusername
);
644 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
645 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
646 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
647 GAA_CHECKSTR("pgptrustdb", GAAOPTID_pgptrustdb
);
648 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
649 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
650 GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile
);
651 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
652 GAA_CHECKSTR("kx", GAAOPTID_kx
);
653 GAA_CHECKSTR("macs", GAAOPTID_macs
);
654 GAA_CHECKSTR("comp", GAAOPTID_comp
);
655 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
656 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
657 GAA_CHECKSTR("recordsize", GAAOPTID_recordsize
);
658 GAA_CHECKSTR("port", GAAOPTID_port
);
659 GAA_CHECKSTR("fingerprint", GAAOPTID_fingerprint
);
660 GAA_CHECKSTR("x509fmtder", GAAOPTID_x509fmtder
);
661 GAA_CHECKSTR("crlf", GAAOPTID_crlf
);
662 GAA_CHECKSTR("resume", GAAOPTID_resume
);
668 return GAA_ERROR_NOMATCH
;
671 int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
674 int gaa_last_non_option
;
675 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
676 struct GAAOPTION_srpusername GAATMP_srpusername
;
677 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
678 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
679 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
680 struct GAAOPTION_pgptrustdb GAATMP_pgptrustdb
;
681 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
682 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
683 struct GAAOPTION_x509cafile GAATMP_x509cafile
;
684 struct GAAOPTION_ctypes GAATMP_ctypes
;
685 struct GAAOPTION_kx GAATMP_kx
;
686 struct GAAOPTION_macs GAATMP_macs
;
687 struct GAAOPTION_comp GAATMP_comp
;
688 struct GAAOPTION_protocols GAATMP_protocols
;
689 struct GAAOPTION_ciphers GAATMP_ciphers
;
690 struct GAAOPTION_recordsize GAATMP_recordsize
;
691 struct GAAOPTION_port GAATMP_port
;
694 #ifdef GAA_REST_EXISTS
695 struct GAAREST GAAREST_tmp
;
698 opt_list
[gaa_num
] = 1;
700 for(gaa_last_non_option
= gaa_index
;
701 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
702 gaa_last_non_option
++);
704 if(gaa_num
== GAA_REST
)
707 gaa_last_non_option
= GAAargc
;
715 { gaa_help(); exit(0); ;};
722 { print_list(); exit(0); ;};
726 case GAAOPTID_srppasswd
:
729 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
732 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
736 case GAAOPTID_srpusername
:
739 GAA_FILL(GAATMP_srpusername
.arg1
, gaa_getstr
, GAATMP_srpusername
.size1
);
742 { gaaval
->srp_username
= GAATMP_srpusername
.arg1
;};
746 case GAAOPTID_x509certfile
:
749 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
752 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
756 case GAAOPTID_x509keyfile
:
759 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
762 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
766 case GAAOPTID_pgpcertfile
:
769 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
772 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
776 case GAAOPTID_pgptrustdb
:
779 GAA_FILL(GAATMP_pgptrustdb
.arg1
, gaa_getstr
, GAATMP_pgptrustdb
.size1
);
782 { gaaval
->pgp_keyring
= GAATMP_pgptrustdb
.arg1
;};
786 case GAAOPTID_pgpkeyring
:
789 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
792 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
796 case GAAOPTID_pgpkeyfile
:
799 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
802 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
806 case GAAOPTID_x509cafile
:
809 GAA_FILL(GAATMP_x509cafile
.arg1
, gaa_getstr
, GAATMP_x509cafile
.size1
);
812 { gaaval
->x509_cafile
= GAATMP_x509cafile
.arg1
;};
816 case GAAOPTID_ctypes
:
818 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
820 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
826 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
828 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
834 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
836 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
842 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
844 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
848 case GAAOPTID_protocols
:
850 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
852 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
856 case GAAOPTID_ciphers
:
858 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
860 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
864 case GAAOPTID_recordsize
:
867 GAA_FILL(GAATMP_recordsize
.arg1
, gaa_getint
, GAATMP_recordsize
.size1
);
870 { gaaval
->record_size
= GAATMP_recordsize
.arg1
;};
877 GAA_FILL(GAATMP_port
.arg1
, gaa_getint
, GAATMP_port
.size1
);
880 { gaaval
->port
= GAATMP_port
.arg1
;};
884 case GAAOPTID_fingerprint
:
887 { gaaval
->fingerprint
= 1 ;};
891 case GAAOPTID_x509fmtder
:
894 { gaaval
->fmtder
= 1 ;};
901 { gaaval
->crlf
= 1 ;};
905 case GAAOPTID_resume
:
908 { gaaval
->resume
= 1 ;};
913 GAA_LIST_FILL(GAAREST_tmp
.arg1
, gaa_getstr
, char*, GAAREST_tmp
.size1
);
915 { gaaval
->rest_args
= GAAREST_tmp
.arg1
; gaaval
->nrest_args
= GAAREST_tmp
.size1
;};
923 return GAA_ERROR_UNKNOWN
;
926 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
935 opt_list
= (char*) malloc(GAA_NB_OPTION
+ 1);
936 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
943 { gaaval
->resume
=0; gaaval
->port
=443; gaaval
->rest_args
=NULL
; gaaval
->nrest_args
=0; gaaval
->ciphers
=NULL
;
944 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
945 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0; gaaval
->record_size
=0;
946 gaaval
->fingerprint
=0; gaaval
->pgp_trustdb
=NULL
; gaaval
->pgp_keyring
=NULL
;
947 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
;
948 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
; gaaval
->crlf
= 0;
949 gaaval
->srp_username
=NULL
; gaaval
->srp_passwd
=NULL
; gaaval
->fmtder
= 0; ;};
957 gaa_arg_used
= malloc(argc
* sizeof(char));
958 for(i
= 1; i
< argc
; i
++)
960 for(i
= 1; i
< argc
; i
++)
962 if(gaa_arg_used
[i
] == 0)
965 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
968 case GAA_WORD_OPTION
:
970 case GAA_LETTER_OPTION
:
972 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
973 if(tmp2
== GAA_ERROR_NOMATCH
)
975 printf("Invalid option '%s'\n", argv
[i
]+j
);
978 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
980 case GAA_ERROR_NOTENOUGH_ARGS
:
981 printf("'%s': not enough arguments\n",gaa_current_option
);
983 case GAA_ERROR_INVALID_ARG
:
984 printf("Invalid arguments\n");
989 printf("Unknown error\n");
993 case GAA_MULTIPLE_OPTION
:
994 for(j
= 1; j
< strlen(argv
[i
]); j
++)
996 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
997 if(tmp2
== GAA_ERROR_NOMATCH
)
999 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
1002 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
1004 case GAA_ERROR_NOTENOUGH_ARGS
:
1005 printf("'%s': not enough arguments\n",gaa_current_option
);
1007 case GAA_ERROR_INVALID_ARG
:
1008 printf("Invalid arguments\n");
1013 printf("Unknown error\n");
1016 gaa_arg_used
[i
] = 1;
1022 if(gaa_processing_file
== 0)
1025 #line 507 "gaa.skel"
1026 #ifdef GAA_REST_EXISTS
1027 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
1029 case GAA_ERROR_NOTENOUGH_ARGS
:
1030 printf("Rest: not enough arguments\n");
1032 case GAA_ERROR_INVALID_ARG
:
1033 printf("Invalid arguments\n");
1038 printf("Unknown error\n");
1042 for(i
= 1; i
< argc
; i
++)
1044 if(gaa_arg_used
[i
] == 0)
1046 printf("Too many arguments\n");
1058 struct gaastrnode
*next
;
1061 typedef struct gaastrnode gaa_str_node
;
1063 int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1067 int i
= 0, len
= 0, newline
= 0;
1072 if(fscanf(file
,"%c", &a
) != 1) return 0;
1074 while(a
== ' ' || a
== 9 || a
== '\n')
1081 if(fscanf(file
,"%c", &a
) != 1) return 0;
1084 pos_ini
= ftell(file
) - 1;
1086 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1090 if(fscanf(file
,"%c", &a
) != 1) a
= ' ';
1093 tmp_str
->str
= malloc((len
+ 1) * sizeof(char));
1096 tmp_str
->str
[0] = '-';
1097 tmp_str
->str
[1] = '-';
1105 fseek(file
,pos_ini
, SEEK_SET
);
1108 if(fscanf(file
, "%c", &a
) != 1)
1113 tmp_str
->str
[i
] = a
;
1116 while(a
!= ' ' && a
!= 9 && a
!= '\n');
1118 tmp_str
->str
[i
- 1] = 0;
1120 fseek(file
,- 1, SEEK_CUR
);
1121 /* printf("%d\n", ftell(file)); */
1126 int gaa_file(char *name
, gaainfo
*gaaval
)
1128 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1134 gaa_processing_file
= 1;
1136 if((file
= fopen(name
, "r")) == NULL
)
1138 printf("Couldn't open '%s' configuration file for reading\n", name
);
1142 tmp_str
= &first_str
;
1146 *tmp_str
= malloc(sizeof(gaa_str_node
));
1147 (*tmp_str
)->str
= NULL
;
1148 (*tmp_str
)->next
= NULL
;
1150 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1151 tmp_str
= &((*tmp_str
)->next
);
1158 argv
= malloc((1 + argc
) * sizeof(char*));
1159 tmp_str2
= first_str
;
1161 for(i
= 1; i
< argc
; i
++)
1163 argv
[i
] = tmp_str2
->str
;
1164 tmp_str2
= tmp_str2
->next
;
1167 rval
= gaa(argc
, argv
, gaaval
);
1168 gaa_processing_file
= 0;