1 /* File generated by GAA 1.6.0b3
12 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
17 void __gaa_helpsingle(char short_name
, char *name
,
18 char *arg_desc
, char *opt_help
)
20 int col1
, col3
, col4
, tabsize
= 3, curr
;
23 col1
= 5; /* Default values */
28 for(i
= 0; i
< col1
; i
++)
37 printf("-%c, ", short_name
);
42 printf("-%c ", short_name
);
48 printf("--%s ", name
);
49 curr
+= 3 + strlen(name
);
51 if(arg_desc
&& *arg_desc
)
53 printf("%s ", arg_desc
);
54 curr
+= 1 + strlen(arg_desc
);
61 if(opt_help
) /* let's print the option's help body */
63 const char *str
= opt_help
;
83 while((curr
- col3
) % tabsize
!= 0 && curr
< col4
);
90 for(i
= 1; str
[i
] && str
[i
] != ' ' && str
[i
] != '\n'
91 && str
[i
] != '\t'; i
++);
92 if(curr
+ i
- 1 >= col4
)
112 printf("gnutls-cli help\nUsage: gnutls-cli [options] hostname""\n");
113 __gaa_helpsingle('r', "resume", "", "Connect, establish a session. Connect again and resume this session.");
114 __gaa_helpsingle('f', "fingerprint", "", "Send the openpgp fingerprint, instead of the key.");
115 __gaa_helpsingle('p', "port", """integer"" ", "The port to connect to.");
116 __gaa_helpsingle(0, "recordsize", """integer"" ", "The maximum record size to advertize.");
117 __gaa_helpsingle(0, "ciphers", """cipher1 cipher2..."" ", "Ciphers to enable.");
118 __gaa_helpsingle(0, "protocols", """protocol1 protocol2..."" ", "Protocols to enable.");
119 __gaa_helpsingle(0, "comp", """comp1 comp2..."" ", "Compression methods to enable.");
120 __gaa_helpsingle(0, "macs", """mac1 mac2..."" ", "MACs to enable.");
121 __gaa_helpsingle(0, "kx", """kx1 kx2..."" ", "Key exchange methods to enable.");
122 __gaa_helpsingle(0, "ctypes", """certType1 certType2..."" ", "Certificate types to enable.");
123 __gaa_helpsingle(0, "cafile", """FILE"" ", "Certificate file to use.");
124 __gaa_helpsingle(0, "pgpkeyfile", """FILE"" ", "PGP Key file to use.");
125 __gaa_helpsingle(0, "pgpkeyring", """FILE"" ", "PGP Key ring file to use.");
126 __gaa_helpsingle(0, "pgptrustdb", """FILE"" ", "PGP trustdb file to use.");
127 __gaa_helpsingle(0, "pgpcertfile", """FILE"" ", "PGP Public Key (certificate) file to use.");
128 __gaa_helpsingle(0, "x509keyfile", """FILE"" ", "X.509 key file to use.");
129 __gaa_helpsingle(0, "x509certfile", """FILE"" ", "X.509 Certificate file to use.");
130 __gaa_helpsingle(0, "srpusername", """NAME"" ", "SRP username to use.");
131 __gaa_helpsingle(0, "srppasswd", """PASSWD"" ", "SRP password to use.");
132 __gaa_helpsingle('l', "list", "", "Print a list of the supported algorithms and modes.");
133 __gaa_helpsingle('h', "help", "", "prints this help");
141 #ifndef GAA_HEADER_POKY
142 #define GAA_HEADER_POKY
144 typedef struct _gaainfo gaainfo
;
211 int gaa(int argc
, char *argv
[], gaainfo
*gaaval
);
215 int gaa_file(char *name
, gaainfo
*gaaval
);
228 #define GAAERROR(x) \
234 char *gaa_current_option
;
237 /* Generated by gaa */
245 #define GAA_ERROR_NOMATCH 0
246 #define GAA_ERROR_NOTENOUGH_ARGS 1
247 #define GAA_ERROR_INVALID_ARG 2
248 #define GAA_ERROR_UNKNOWN 3
250 #define GAA_NOT_AN_OPTION 0
251 #define GAA_WORD_OPTION 1
252 #define GAA_LETTER_OPTION 2
253 #define GAA_MULTIPLE_OPTION 3
256 #define GAA_NB_OPTION 21
257 #define GAAOPTID_help 1
258 #define GAAOPTID_list 2
259 #define GAAOPTID_srppasswd 3
260 #define GAAOPTID_srpusername 4
261 #define GAAOPTID_x509certfile 5
262 #define GAAOPTID_x509keyfile 6
263 #define GAAOPTID_pgpcertfile 7
264 #define GAAOPTID_pgptrustdb 8
265 #define GAAOPTID_pgpkeyring 9
266 #define GAAOPTID_pgpkeyfile 10
267 #define GAAOPTID_cafile 11
268 #define GAAOPTID_ctypes 12
269 #define GAAOPTID_kx 13
270 #define GAAOPTID_macs 14
271 #define GAAOPTID_comp 15
272 #define GAAOPTID_protocols 16
273 #define GAAOPTID_ciphers 17
274 #define GAAOPTID_recordsize 18
275 #define GAAOPTID_port 19
276 #define GAAOPTID_fingerprint 20
277 #define GAAOPTID_resume 21
281 #define GAA_CHECK1STR(a,b) \
284 gaa_current_option = a; \
288 #define GAA_CHECKSTR(a,b) \
289 if(strcmp(a,str) == 0) \
291 gaa_current_option = a; \
295 #define GAA_TESTMOREARGS \
298 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
300 if(gaa_last_non_option == gaa_index) \
301 return GAA_ERROR_NOTENOUGH_ARGS; \
304 #define GAA_TESTMOREOPTIONALARGS \
307 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
309 if(gaa_last_non_option == gaa_index) \
313 #define GAA_FILL_2ARGS(target, func) \
314 target = func(GAAargv[gaa_index]); \
315 gaa_arg_used[gaa_index] = 1; \
319 return GAA_ERROR_INVALID_ARG; \
324 #define GAA_FILL(target, func, num) \
327 target = func(GAAargv[gaa_index]); \
328 gaa_arg_used[gaa_index] = 1; \
332 return GAA_ERROR_INVALID_ARG; \
341 #define GAA_LIST_FILL(target, func, type ,num) \
346 if ( gaa_last_non_option - gaa_index > 0) \
347 target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
348 for(; gaa_index < gaa_last_non_option; gaa_index++) \
350 if(gaa_arg_used[gaa_index] == 0) \
352 GAA_FILL_2ARGS(target[num], func); \
357 return GAA_ERROR_NOTENOUGH_ARGS; \
360 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
365 if ( gaa_last_non_option - gaa_index > 0) \
366 target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
367 for(; gaa_index < gaa_last_non_option; gaa_index++) \
369 if(gaa_arg_used[gaa_index] == 0) \
371 GAA_FILL_2ARGS(target[num], func); \
377 #define GAA_OBLIGAT(str) \
379 for(i = 0; i < strlen(str); i++) \
381 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
382 if(j == GAA_ERROR_NOMATCH) \
384 printf("Error: invalid 'obligat' set\n"); \
387 if(opt_list[j] == 1) \
392 if(strlen(str) == 1) \
393 printf("You must give the -%s option\n", str); \
395 printf("You must give at least one option of '%s'\n", str); \
399 #define GAA_INCOMP(str) \
401 for(i = 0; i < strlen(str); i++) \
403 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
404 if(j == GAA_ERROR_NOMATCH) \
406 printf("Error: invalid 'obligat' set\n"); \
409 if(opt_list[j] == 1) \
414 printf("The options '%s' are incompatible\n", str); \
422 int gaa_processing_file
= 0;
425 int gaa_getint(char *arg
)
429 if(sscanf(arg
, "%d%c", &tmp
, &a
) != 1)
431 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
437 char gaa_getchar(char *arg
)
441 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
447 char* gaa_getstr(char *arg
)
451 float gaa_getfloat(char *arg
)
455 if(sscanf(arg
, "%f%c", &tmp
, &a
) != 1)
457 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
462 /* option structures */
464 struct GAAOPTION_srppasswd
470 struct GAAOPTION_srpusername
476 struct GAAOPTION_x509certfile
482 struct GAAOPTION_x509keyfile
488 struct GAAOPTION_pgpcertfile
494 struct GAAOPTION_pgptrustdb
500 struct GAAOPTION_pgpkeyring
506 struct GAAOPTION_pgpkeyfile
512 struct GAAOPTION_cafile
518 struct GAAOPTION_ctypes
530 struct GAAOPTION_macs
536 struct GAAOPTION_comp
542 struct GAAOPTION_protocols
548 struct GAAOPTION_ciphers
554 struct GAAOPTION_recordsize
560 struct GAAOPTION_port
565 #define GAA_REST_EXISTS
574 int gaa_is_an_argument(char *str
)
577 if(str
[0] == '/' && str
[1] != 0)
578 return GAA_MULTIPLE_OPTION
;
581 return GAA_NOT_AN_OPTION
;
583 return GAA_NOT_AN_OPTION
;
587 return GAA_WORD_OPTION
;
589 return GAA_NOT_AN_OPTION
;
592 return GAA_LETTER_OPTION
;
594 return GAA_MULTIPLE_OPTION
;
597 int gaa_get_option_num(char *str
, int status
)
601 case GAA_LETTER_OPTION
:
602 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
603 GAA_CHECK1STR("", GAAOPTID_srpusername
);
604 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
605 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
606 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
607 GAA_CHECK1STR("", GAAOPTID_pgptrustdb
);
608 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
609 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
610 GAA_CHECK1STR("", GAAOPTID_cafile
);
611 GAA_CHECK1STR("", GAAOPTID_ctypes
);
612 GAA_CHECK1STR("", GAAOPTID_kx
);
613 GAA_CHECK1STR("", GAAOPTID_macs
);
614 GAA_CHECK1STR("", GAAOPTID_comp
);
615 GAA_CHECK1STR("", GAAOPTID_protocols
);
616 GAA_CHECK1STR("", GAAOPTID_ciphers
);
617 GAA_CHECK1STR("", GAAOPTID_recordsize
);
618 GAA_CHECK1STR("p", GAAOPTID_port
);
619 case GAA_MULTIPLE_OPTION
:
621 GAA_CHECK1STR("h", GAAOPTID_help
);
622 GAA_CHECK1STR("l", GAAOPTID_list
);
623 GAA_CHECK1STR("f", GAAOPTID_fingerprint
);
624 GAA_CHECK1STR("r", GAAOPTID_resume
);
628 case GAA_WORD_OPTION
:
629 GAA_CHECKSTR("help", GAAOPTID_help
);
630 GAA_CHECKSTR("list", GAAOPTID_list
);
631 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
632 GAA_CHECKSTR("srpusername", GAAOPTID_srpusername
);
633 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
634 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
635 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
636 GAA_CHECKSTR("pgptrustdb", GAAOPTID_pgptrustdb
);
637 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
638 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
639 GAA_CHECKSTR("cafile", GAAOPTID_cafile
);
640 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
641 GAA_CHECKSTR("kx", GAAOPTID_kx
);
642 GAA_CHECKSTR("macs", GAAOPTID_macs
);
643 GAA_CHECKSTR("comp", GAAOPTID_comp
);
644 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
645 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
646 GAA_CHECKSTR("recordsize", GAAOPTID_recordsize
);
647 GAA_CHECKSTR("port", GAAOPTID_port
);
648 GAA_CHECKSTR("fingerprint", GAAOPTID_fingerprint
);
649 GAA_CHECKSTR("resume", GAAOPTID_resume
);
655 return GAA_ERROR_NOMATCH
;
658 int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
661 int gaa_last_non_option
;
662 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
663 struct GAAOPTION_srpusername GAATMP_srpusername
;
664 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
665 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
666 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
667 struct GAAOPTION_pgptrustdb GAATMP_pgptrustdb
;
668 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
669 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
670 struct GAAOPTION_cafile GAATMP_cafile
;
671 struct GAAOPTION_ctypes GAATMP_ctypes
;
672 struct GAAOPTION_kx GAATMP_kx
;
673 struct GAAOPTION_macs GAATMP_macs
;
674 struct GAAOPTION_comp GAATMP_comp
;
675 struct GAAOPTION_protocols GAATMP_protocols
;
676 struct GAAOPTION_ciphers GAATMP_ciphers
;
677 struct GAAOPTION_recordsize GAATMP_recordsize
;
678 struct GAAOPTION_port GAATMP_port
;
681 #ifdef GAA_REST_EXISTS
682 struct GAAREST GAAREST_tmp
;
685 opt_list
[gaa_num
] = 1;
687 for(gaa_last_non_option
= gaa_index
;
688 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
689 gaa_last_non_option
++);
691 if(gaa_num
== GAA_REST
)
694 gaa_last_non_option
= GAAargc
;
702 { gaa_help(); exit(0); ;};
709 { print_list(); exit(0); ;};
713 case GAAOPTID_srppasswd
:
716 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
719 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
723 case GAAOPTID_srpusername
:
726 GAA_FILL(GAATMP_srpusername
.arg1
, gaa_getstr
, GAATMP_srpusername
.size1
);
729 { gaaval
->srp_username
= GAATMP_srpusername
.arg1
;};
733 case GAAOPTID_x509certfile
:
736 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
739 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
743 case GAAOPTID_x509keyfile
:
746 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
749 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
753 case GAAOPTID_pgpcertfile
:
756 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
759 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
763 case GAAOPTID_pgptrustdb
:
766 GAA_FILL(GAATMP_pgptrustdb
.arg1
, gaa_getstr
, GAATMP_pgptrustdb
.size1
);
769 { gaaval
->pgp_keyring
= GAATMP_pgptrustdb
.arg1
;};
773 case GAAOPTID_pgpkeyring
:
776 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
779 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
783 case GAAOPTID_pgpkeyfile
:
786 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
789 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
793 case GAAOPTID_cafile
:
796 GAA_FILL(GAATMP_cafile
.arg1
, gaa_getstr
, GAATMP_cafile
.size1
);
799 { gaaval
->x509_cafile
= GAATMP_cafile
.arg1
;};
803 case GAAOPTID_ctypes
:
805 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
807 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
813 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
815 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
821 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
823 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
829 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
831 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
835 case GAAOPTID_protocols
:
837 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
839 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
843 case GAAOPTID_ciphers
:
845 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
847 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
851 case GAAOPTID_recordsize
:
854 GAA_FILL(GAATMP_recordsize
.arg1
, gaa_getint
, GAATMP_recordsize
.size1
);
857 { gaaval
->record_size
= GAATMP_recordsize
.arg1
;};
864 GAA_FILL(GAATMP_port
.arg1
, gaa_getint
, GAATMP_port
.size1
);
867 { gaaval
->port
= GAATMP_port
.arg1
;};
871 case GAAOPTID_fingerprint
:
874 { gaaval
->fingerprint
= 1 ;};
878 case GAAOPTID_resume
:
881 { gaaval
->resume
= 1 ;};
886 GAA_LIST_FILL(GAAREST_tmp
.arg1
, gaa_getstr
, char*, GAAREST_tmp
.size1
);
888 { gaaval
->rest_args
= GAAREST_tmp
.arg1
; gaaval
->nrest_args
= GAAREST_tmp
.size1
;};
896 return GAA_ERROR_UNKNOWN
;
899 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
908 opt_list
= (char*) malloc(GAA_NB_OPTION
+ 1);
909 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
916 { gaaval
->resume
=0; gaaval
->port
=443; gaaval
->rest_args
=NULL
; gaaval
->nrest_args
=0; gaaval
->ciphers
=NULL
;
917 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
918 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0; gaaval
->record_size
=0;
919 gaaval
->fingerprint
=0; gaaval
->pgp_trustdb
=NULL
; gaaval
->pgp_keyring
=NULL
;
920 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
;
921 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
;
922 gaaval
->srp_username
=NULL
; gaaval
->srp_passwd
=NULL
; ;};
930 gaa_arg_used
= malloc(argc
* sizeof(char));
931 for(i
= 1; i
< argc
; i
++)
933 for(i
= 1; i
< argc
; i
++)
935 if(gaa_arg_used
[i
] == 0)
938 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
941 case GAA_WORD_OPTION
:
943 case GAA_LETTER_OPTION
:
945 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
946 if(tmp2
== GAA_ERROR_NOMATCH
)
948 printf("Invalid option '%s'\n", argv
[i
]+j
);
951 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
953 case GAA_ERROR_NOTENOUGH_ARGS
:
954 printf("'%s': not enough arguments\n",gaa_current_option
);
956 case GAA_ERROR_INVALID_ARG
:
957 printf("Invalid arguments\n");
962 printf("Unknown error\n");
966 case GAA_MULTIPLE_OPTION
:
967 for(j
= 1; j
< strlen(argv
[i
]); j
++)
969 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
970 if(tmp2
== GAA_ERROR_NOMATCH
)
972 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
975 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
977 case GAA_ERROR_NOTENOUGH_ARGS
:
978 printf("'%s': not enough arguments\n",gaa_current_option
);
980 case GAA_ERROR_INVALID_ARG
:
981 printf("Invalid arguments\n");
986 printf("Unknown error\n");
995 if(gaa_processing_file
== 0)
999 #ifdef GAA_REST_EXISTS
1000 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
1002 case GAA_ERROR_NOTENOUGH_ARGS
:
1003 printf("Rest: not enough arguments\n");
1005 case GAA_ERROR_INVALID_ARG
:
1006 printf("Invalid arguments\n");
1011 printf("Unknown error\n");
1015 for(i
= 1; i
< argc
; i
++)
1017 if(gaa_arg_used
[i
] == 0)
1019 printf("Too many arguments\n");
1031 struct gaastrnode
*next
;
1034 typedef struct gaastrnode gaa_str_node
;
1036 int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1040 int i
= 0, len
= 0, newline
= 0;
1045 if(fscanf(file
,"%c", &a
) != 1) return 0;
1047 while(a
== ' ' || a
== 9 || a
== '\n')
1054 if(fscanf(file
,"%c", &a
) != 1) return 0;
1057 pos_ini
= ftell(file
) - 1;
1059 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1063 if(fscanf(file
,"%c", &a
) != 1) a
= ' ';
1066 tmp_str
->str
= malloc((len
+ 1) * sizeof(char));
1069 tmp_str
->str
[0] = '-';
1070 tmp_str
->str
[1] = '-';
1078 fseek(file
,pos_ini
, SEEK_SET
);
1081 if(fscanf(file
, "%c", &a
) != 1)
1086 tmp_str
->str
[i
] = a
;
1089 while(a
!= ' ' && a
!= 9 && a
!= '\n');
1091 tmp_str
->str
[i
- 1] = 0;
1093 fseek(file
,- 1, SEEK_CUR
);
1094 /* printf("%d\n", ftell(file)); */
1099 int gaa_file(char *name
, gaainfo
*gaaval
)
1101 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1107 gaa_processing_file
= 1;
1109 if((file
= fopen(name
, "r")) == NULL
)
1111 printf("Couldn't open '%s' configuration file for reading\n", name
);
1115 tmp_str
= &first_str
;
1119 *tmp_str
= malloc(sizeof(gaa_str_node
));
1120 (*tmp_str
)->str
= NULL
;
1121 (*tmp_str
)->next
= NULL
;
1123 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1124 tmp_str
= &((*tmp_str
)->next
);
1131 argv
= malloc((1 + argc
) * sizeof(char*));
1132 tmp_str2
= first_str
;
1134 for(i
= 1; i
< argc
; i
++)
1136 argv
[i
] = tmp_str2
->str
;
1137 tmp_str2
= tmp_str2
->next
;
1140 rval
= gaa(argc
, argv
, gaaval
);
1141 gaa_processing_file
= 0;