1 /* File generated by GAA 1.6.0
11 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(WINDOWS)
16 void __gaa_helpsingle(char short_name
, char *name
,
17 char *arg_desc
, char *opt_help
)
19 int col1
, col3
, col4
, tabsize
= 3, curr
;
22 col1
= 5; /* Default values */
27 for(i
= 0; i
< col1
; i
++)
36 printf("-%c, ", short_name
);
41 printf("-%c ", short_name
);
47 printf("--%s ", name
);
48 curr
+= 3 + strlen(name
);
50 if(arg_desc
&& *arg_desc
)
52 printf("%s ", arg_desc
);
53 curr
+= 1 + strlen(arg_desc
);
60 if(opt_help
) /* let's print the option's help body */
62 const char *str
= opt_help
;
82 while((curr
- col3
) % tabsize
!= 0 && curr
< col4
);
89 for(i
= 1; str
[i
] && str
[i
] != ' ' && str
[i
] != '\n'
90 && str
[i
] != '\t'; i
++);
91 if(curr
+ i
- 1 >= col4
)
111 printf("gnutls-serv help\nUsage: gnutls-serv [options]""\n");
112 __gaa_helpsingle('g', "generate", "", "Generate Diffie Hellman Parameters.");
113 __gaa_helpsingle('p', "port", """integer"" ", "The port to connect to.");
114 __gaa_helpsingle(0, "http", "", "Act as an HTTP Server.");
115 __gaa_helpsingle(0, "x509cafile", """FILE"" ", "Certificate file to use.");
116 __gaa_helpsingle(0, "pgpkeyring", """FILE"" ", "PGP Key ring file to use.");
117 __gaa_helpsingle(0, "pgptrustdb", """FILE"" ", "PGP trustdb file to use.");
118 __gaa_helpsingle(0, "pgpkeyfile", """FILE"" ", "PGP Key file to use.");
119 __gaa_helpsingle(0, "pgpcertfile", """FILE"" ", "PGP Public Key (certificate) file to use.");
120 __gaa_helpsingle(0, "x509keyfile", """FILE"" ", "X.509 key file to use.");
121 __gaa_helpsingle(0, "x509certfile", """FILE"" ", "X.509 Certificate file to use.");
122 __gaa_helpsingle(0, "pgpkeyserver", """FILE"" ", "PGP Keyserver to use.");
123 __gaa_helpsingle(0, "srppasswd", """FILE"" ", "SRP password file to use.");
124 __gaa_helpsingle(0, "srppasswdconf", """FILE"" ", "SRP password conf file to use.");
125 __gaa_helpsingle(0, "ciphers", """cipher1 cipher2..."" ", "Ciphers to enable.");
126 __gaa_helpsingle(0, "protocols", """protocol1 protocol2..."" ", "Protocols to enable.");
127 __gaa_helpsingle(0, "comp", """comp1 comp2..."" ", "Compression methods to enable.");
128 __gaa_helpsingle(0, "macs", """mac1 mac2..."" ", "MACs to enable.");
129 __gaa_helpsingle(0, "kx", """kx1 kx2..."" ", "Key exchange methods to enable.");
130 __gaa_helpsingle(0, "ctypes", """certType1 certType2..."" ", "Certificate types to enable.");
131 __gaa_helpsingle('l', "list", "", "Print a list of the supported algorithms and modes.");
132 __gaa_helpsingle('h', "help", "", "prints this help");
140 #ifndef GAA_HEADER_POKY
141 #define GAA_HEADER_POKY
143 typedef struct _gaainfo gaainfo
;
172 char *srp_passwd_conf
;
206 int gaa(int argc
, char *argv
[], gaainfo
*gaaval
);
210 int gaa_file(char *name
, gaainfo
*gaaval
);
223 #define GAAERROR(x) \
229 char *gaa_current_option
;
232 /* Generated by gaa */
240 #define GAA_ERROR_NOMATCH 0
241 #define GAA_ERROR_NOTENOUGH_ARGS 1
242 #define GAA_ERROR_INVALID_ARG 2
243 #define GAA_ERROR_UNKNOWN 3
245 #define GAA_NOT_AN_OPTION 0
246 #define GAA_WORD_OPTION 1
247 #define GAA_LETTER_OPTION 2
248 #define GAA_MULTIPLE_OPTION 3
251 #define GAA_NB_OPTION 21
252 #define GAAOPTID_help 1
253 #define GAAOPTID_list 2
254 #define GAAOPTID_ctypes 3
255 #define GAAOPTID_kx 4
256 #define GAAOPTID_macs 5
257 #define GAAOPTID_comp 6
258 #define GAAOPTID_protocols 7
259 #define GAAOPTID_ciphers 8
260 #define GAAOPTID_srppasswdconf 9
261 #define GAAOPTID_srppasswd 10
262 #define GAAOPTID_pgpkeyserver 11
263 #define GAAOPTID_x509certfile 12
264 #define GAAOPTID_x509keyfile 13
265 #define GAAOPTID_pgpcertfile 14
266 #define GAAOPTID_pgpkeyfile 15
267 #define GAAOPTID_pgptrustdb 16
268 #define GAAOPTID_pgpkeyring 17
269 #define GAAOPTID_x509cafile 18
270 #define GAAOPTID_http 19
271 #define GAAOPTID_port 20
272 #define GAAOPTID_generate 21
276 #define GAA_CHECK1STR(a,b) \
279 gaa_current_option = a; \
283 #define GAA_CHECKSTR(a,b) \
284 if(strcmp(a,str) == 0) \
286 gaa_current_option = a; \
290 #define GAA_TESTMOREARGS \
293 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
295 if(gaa_last_non_option == gaa_index) \
296 return GAA_ERROR_NOTENOUGH_ARGS; \
299 #define GAA_TESTMOREOPTIONALARGS \
302 while((gaa_last_non_option != gaa_index) && (gaa_arg_used[gaa_index] == 1)) \
304 if(gaa_last_non_option == gaa_index) \
308 #define GAA_FILL_2ARGS(target, func) \
309 target = func(GAAargv[gaa_index]); \
310 gaa_arg_used[gaa_index] = 1; \
314 return GAA_ERROR_INVALID_ARG; \
319 #define GAA_FILL(target, func, num) \
322 target = func(GAAargv[gaa_index]); \
323 gaa_arg_used[gaa_index] = 1; \
327 return GAA_ERROR_INVALID_ARG; \
336 #define GAA_LIST_FILL(target, func, type ,num) \
341 if ( gaa_last_non_option - gaa_index > 0) \
342 target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
343 for(; gaa_index < gaa_last_non_option; gaa_index++) \
345 if(gaa_arg_used[gaa_index] == 0) \
347 GAA_FILL_2ARGS(target[num], func); \
352 return GAA_ERROR_NOTENOUGH_ARGS; \
355 #define GAA_OPTIONALLIST_FILL(target, func, type ,num) \
360 if ( gaa_last_non_option - gaa_index > 0) \
361 target = malloc((gaa_last_non_option - gaa_index) * sizeof(type));\
362 for(; gaa_index < gaa_last_non_option; gaa_index++) \
364 if(gaa_arg_used[gaa_index] == 0) \
366 GAA_FILL_2ARGS(target[num], func); \
372 #define GAA_OBLIGAT(str) \
374 for(i = 0; i < strlen(str); i++) \
376 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
377 if(j == GAA_ERROR_NOMATCH) \
379 printf("Error: invalid 'obligat' set\n"); \
382 if(opt_list[j] == 1) \
387 if(strlen(str) == 1) \
388 printf("You must give the -%s option\n", str); \
390 printf("You must give at least one option of '%s'\n", str); \
394 #define GAA_INCOMP(str) \
396 for(i = 0; i < strlen(str); i++) \
398 j = gaa_get_option_num(str + i, GAA_LETTER_OPTION); \
399 if(j == GAA_ERROR_NOMATCH) \
401 printf("Error: invalid 'obligat' set\n"); \
404 if(opt_list[j] == 1) \
409 printf("The options '%s' are incompatible\n", str); \
417 int gaa_processing_file
= 0;
420 int gaa_getint(char *arg
)
424 if(sscanf(arg
, "%d%c", &tmp
, &a
) != 1)
426 printf("Option %s: '%s' isn't an integer\n", gaa_current_option
, arg
);
432 char gaa_getchar(char *arg
)
436 printf("Option %s: '%s' isn't an character\n", gaa_current_option
, arg
);
442 char* gaa_getstr(char *arg
)
446 float gaa_getfloat(char *arg
)
450 if(sscanf(arg
, "%f%c", &tmp
, &a
) != 1)
452 printf("Option %s: '%s' isn't a float number\n", gaa_current_option
, arg
);
457 /* option structures */
459 struct GAAOPTION_ctypes
471 struct GAAOPTION_macs
477 struct GAAOPTION_comp
483 struct GAAOPTION_protocols
489 struct GAAOPTION_ciphers
495 struct GAAOPTION_srppasswdconf
501 struct GAAOPTION_srppasswd
507 struct GAAOPTION_pgpkeyserver
513 struct GAAOPTION_x509certfile
519 struct GAAOPTION_x509keyfile
525 struct GAAOPTION_pgpcertfile
531 struct GAAOPTION_pgpkeyfile
537 struct GAAOPTION_pgptrustdb
543 struct GAAOPTION_pgpkeyring
549 struct GAAOPTION_x509cafile
555 struct GAAOPTION_port
562 int gaa_is_an_argument(char *str
)
565 if(str
[0] == '/' && str
[1] != 0)
566 return GAA_MULTIPLE_OPTION
;
569 return GAA_NOT_AN_OPTION
;
571 return GAA_NOT_AN_OPTION
;
575 return GAA_WORD_OPTION
;
577 return GAA_NOT_AN_OPTION
;
580 return GAA_LETTER_OPTION
;
582 return GAA_MULTIPLE_OPTION
;
585 int gaa_get_option_num(char *str
, int status
)
589 case GAA_LETTER_OPTION
:
590 GAA_CHECK1STR("", GAAOPTID_ctypes
);
591 GAA_CHECK1STR("", GAAOPTID_kx
);
592 GAA_CHECK1STR("", GAAOPTID_macs
);
593 GAA_CHECK1STR("", GAAOPTID_comp
);
594 GAA_CHECK1STR("", GAAOPTID_protocols
);
595 GAA_CHECK1STR("", GAAOPTID_ciphers
);
596 GAA_CHECK1STR("", GAAOPTID_srppasswdconf
);
597 GAA_CHECK1STR("", GAAOPTID_srppasswd
);
598 GAA_CHECK1STR("", GAAOPTID_pgpkeyserver
);
599 GAA_CHECK1STR("", GAAOPTID_x509certfile
);
600 GAA_CHECK1STR("", GAAOPTID_x509keyfile
);
601 GAA_CHECK1STR("", GAAOPTID_pgpcertfile
);
602 GAA_CHECK1STR("", GAAOPTID_pgpkeyfile
);
603 GAA_CHECK1STR("", GAAOPTID_pgptrustdb
);
604 GAA_CHECK1STR("", GAAOPTID_pgpkeyring
);
605 GAA_CHECK1STR("", GAAOPTID_x509cafile
);
606 GAA_CHECK1STR("p", GAAOPTID_port
);
607 case GAA_MULTIPLE_OPTION
:
609 GAA_CHECK1STR("h", GAAOPTID_help
);
610 GAA_CHECK1STR("l", GAAOPTID_list
);
611 GAA_CHECK1STR("", GAAOPTID_http
);
612 GAA_CHECK1STR("g", GAAOPTID_generate
);
616 case GAA_WORD_OPTION
:
617 GAA_CHECKSTR("help", GAAOPTID_help
);
618 GAA_CHECKSTR("list", GAAOPTID_list
);
619 GAA_CHECKSTR("ctypes", GAAOPTID_ctypes
);
620 GAA_CHECKSTR("kx", GAAOPTID_kx
);
621 GAA_CHECKSTR("macs", GAAOPTID_macs
);
622 GAA_CHECKSTR("comp", GAAOPTID_comp
);
623 GAA_CHECKSTR("protocols", GAAOPTID_protocols
);
624 GAA_CHECKSTR("ciphers", GAAOPTID_ciphers
);
625 GAA_CHECKSTR("srppasswdconf", GAAOPTID_srppasswdconf
);
626 GAA_CHECKSTR("srppasswd", GAAOPTID_srppasswd
);
627 GAA_CHECKSTR("pgpkeyserver", GAAOPTID_pgpkeyserver
);
628 GAA_CHECKSTR("x509certfile", GAAOPTID_x509certfile
);
629 GAA_CHECKSTR("x509keyfile", GAAOPTID_x509keyfile
);
630 GAA_CHECKSTR("pgpcertfile", GAAOPTID_pgpcertfile
);
631 GAA_CHECKSTR("pgpkeyfile", GAAOPTID_pgpkeyfile
);
632 GAA_CHECKSTR("pgptrustdb", GAAOPTID_pgptrustdb
);
633 GAA_CHECKSTR("pgpkeyring", GAAOPTID_pgpkeyring
);
634 GAA_CHECKSTR("x509cafile", GAAOPTID_x509cafile
);
635 GAA_CHECKSTR("http", GAAOPTID_http
);
636 GAA_CHECKSTR("port", GAAOPTID_port
);
637 GAA_CHECKSTR("generate", GAAOPTID_generate
);
643 return GAA_ERROR_NOMATCH
;
646 int gaa_try(int gaa_num
, int gaa_index
, gaainfo
*gaaval
, char *opt_list
)
649 int gaa_last_non_option
;
650 struct GAAOPTION_ctypes GAATMP_ctypes
;
651 struct GAAOPTION_kx GAATMP_kx
;
652 struct GAAOPTION_macs GAATMP_macs
;
653 struct GAAOPTION_comp GAATMP_comp
;
654 struct GAAOPTION_protocols GAATMP_protocols
;
655 struct GAAOPTION_ciphers GAATMP_ciphers
;
656 struct GAAOPTION_srppasswdconf GAATMP_srppasswdconf
;
657 struct GAAOPTION_srppasswd GAATMP_srppasswd
;
658 struct GAAOPTION_pgpkeyserver GAATMP_pgpkeyserver
;
659 struct GAAOPTION_x509certfile GAATMP_x509certfile
;
660 struct GAAOPTION_x509keyfile GAATMP_x509keyfile
;
661 struct GAAOPTION_pgpcertfile GAATMP_pgpcertfile
;
662 struct GAAOPTION_pgpkeyfile GAATMP_pgpkeyfile
;
663 struct GAAOPTION_pgptrustdb GAATMP_pgptrustdb
;
664 struct GAAOPTION_pgpkeyring GAATMP_pgpkeyring
;
665 struct GAAOPTION_x509cafile GAATMP_x509cafile
;
666 struct GAAOPTION_port GAATMP_port
;
669 #ifdef GAA_REST_EXISTS
670 struct GAAREST GAAREST_tmp
;
673 opt_list
[gaa_num
] = 1;
675 for(gaa_last_non_option
= gaa_index
;
676 (gaa_last_non_option
!= GAAargc
) && (gaa_is_an_argument(GAAargv
[gaa_last_non_option
]) == GAA_NOT_AN_OPTION
);
677 gaa_last_non_option
++);
679 if(gaa_num
== GAA_REST
)
682 gaa_last_non_option
= GAAargc
;
690 { gaa_help(); exit(0); ;};
697 { print_list(); exit(0); ;};
701 case GAAOPTID_ctypes
:
703 GAA_LIST_FILL(GAATMP_ctypes
.arg1
, gaa_getstr
, char*, GAATMP_ctypes
.size1
);
705 { gaaval
->ctype
= GAATMP_ctypes
.arg1
; gaaval
->nctype
= GAATMP_ctypes
.size1
;};
711 GAA_LIST_FILL(GAATMP_kx
.arg1
, gaa_getstr
, char*, GAATMP_kx
.size1
);
713 { gaaval
->kx
= GAATMP_kx
.arg1
; gaaval
->nkx
= GAATMP_kx
.size1
;};
719 GAA_LIST_FILL(GAATMP_macs
.arg1
, gaa_getstr
, char*, GAATMP_macs
.size1
);
721 { gaaval
->macs
= GAATMP_macs
.arg1
; gaaval
->nmacs
= GAATMP_macs
.size1
;};
727 GAA_LIST_FILL(GAATMP_comp
.arg1
, gaa_getstr
, char*, GAATMP_comp
.size1
);
729 { gaaval
->comp
= GAATMP_comp
.arg1
; gaaval
->ncomp
= GAATMP_comp
.size1
;};
733 case GAAOPTID_protocols
:
735 GAA_LIST_FILL(GAATMP_protocols
.arg1
, gaa_getstr
, char*, GAATMP_protocols
.size1
);
737 { gaaval
->proto
= GAATMP_protocols
.arg1
; gaaval
->nproto
= GAATMP_protocols
.size1
;};
741 case GAAOPTID_ciphers
:
743 GAA_LIST_FILL(GAATMP_ciphers
.arg1
, gaa_getstr
, char*, GAATMP_ciphers
.size1
);
745 { gaaval
->ciphers
= GAATMP_ciphers
.arg1
; gaaval
->nciphers
= GAATMP_ciphers
.size1
;};
749 case GAAOPTID_srppasswdconf
:
752 GAA_FILL(GAATMP_srppasswdconf
.arg1
, gaa_getstr
, GAATMP_srppasswdconf
.size1
);
755 { gaaval
->srp_passwd_conf
= GAATMP_srppasswdconf
.arg1
;};
759 case GAAOPTID_srppasswd
:
762 GAA_FILL(GAATMP_srppasswd
.arg1
, gaa_getstr
, GAATMP_srppasswd
.size1
);
765 { gaaval
->srp_passwd
= GAATMP_srppasswd
.arg1
;};
769 case GAAOPTID_pgpkeyserver
:
772 GAA_FILL(GAATMP_pgpkeyserver
.arg1
, gaa_getstr
, GAATMP_pgpkeyserver
.size1
);
775 { gaaval
->pgp_keyserver
= GAATMP_pgpkeyserver
.arg1
;};
779 case GAAOPTID_x509certfile
:
782 GAA_FILL(GAATMP_x509certfile
.arg1
, gaa_getstr
, GAATMP_x509certfile
.size1
);
785 { gaaval
->x509_certfile
= GAATMP_x509certfile
.arg1
;};
789 case GAAOPTID_x509keyfile
:
792 GAA_FILL(GAATMP_x509keyfile
.arg1
, gaa_getstr
, GAATMP_x509keyfile
.size1
);
795 { gaaval
->x509_keyfile
= GAATMP_x509keyfile
.arg1
;};
799 case GAAOPTID_pgpcertfile
:
802 GAA_FILL(GAATMP_pgpcertfile
.arg1
, gaa_getstr
, GAATMP_pgpcertfile
.size1
);
805 { gaaval
->pgp_certfile
= GAATMP_pgpcertfile
.arg1
;};
809 case GAAOPTID_pgpkeyfile
:
812 GAA_FILL(GAATMP_pgpkeyfile
.arg1
, gaa_getstr
, GAATMP_pgpkeyfile
.size1
);
815 { gaaval
->pgp_keyfile
= GAATMP_pgpkeyfile
.arg1
;};
819 case GAAOPTID_pgptrustdb
:
822 GAA_FILL(GAATMP_pgptrustdb
.arg1
, gaa_getstr
, GAATMP_pgptrustdb
.size1
);
825 { gaaval
->pgp_keyring
= GAATMP_pgptrustdb
.arg1
;};
829 case GAAOPTID_pgpkeyring
:
832 GAA_FILL(GAATMP_pgpkeyring
.arg1
, gaa_getstr
, GAATMP_pgpkeyring
.size1
);
835 { gaaval
->pgp_keyring
= GAATMP_pgpkeyring
.arg1
;};
839 case GAAOPTID_x509cafile
:
842 GAA_FILL(GAATMP_x509cafile
.arg1
, gaa_getstr
, GAATMP_x509cafile
.size1
);
845 { gaaval
->x509_cafile
= GAATMP_x509cafile
.arg1
;};
852 { gaaval
->http
= 1 ;};
859 GAA_FILL(GAATMP_port
.arg1
, gaa_getint
, GAATMP_port
.size1
);
862 { gaaval
->port
= GAATMP_port
.arg1
;};
866 case GAAOPTID_generate
:
869 { gaaval
->generate
= 1 ;};
877 return GAA_ERROR_UNKNOWN
;
880 int gaa(int argc
, char **argv
, gaainfo
*gaaval
)
889 opt_list
= (char*) malloc(GAA_NB_OPTION
+ 1);
890 for(i
= 0; i
< GAA_NB_OPTION
+ 1; i
++)
897 { gaaval
->generate
=0; gaaval
->port
=5556; gaaval
->http
=0; gaaval
->ciphers
=NULL
;
898 gaaval
->kx
=NULL
; gaaval
->comp
=NULL
; gaaval
->macs
=NULL
; gaaval
->ctype
=NULL
; gaaval
->nciphers
=0;
899 gaaval
->nkx
=0; gaaval
->ncomp
=0; gaaval
->nmacs
=0; gaaval
->nctype
= 0;
900 gaaval
->x509_cafile
= NULL
; gaaval
->pgp_keyfile
=NULL
; gaaval
->pgp_certfile
=NULL
;
901 gaaval
->x509_keyfile
=NULL
; gaaval
->x509_certfile
=NULL
; gaaval
->pgp_keyserver
=NULL
;
902 gaaval
->srp_passwd
=NULL
; gaaval
->srp_passwd_conf
=NULL
;
903 gaaval
->pgp_trustdb
=NULL
; gaaval
->pgp_keyring
=NULL
; ;};
911 gaa_arg_used
= malloc(argc
* sizeof(char));
912 for(i
= 1; i
< argc
; i
++)
914 for(i
= 1; i
< argc
; i
++)
916 if(gaa_arg_used
[i
] == 0)
919 tmp1
= gaa_is_an_argument(GAAargv
[i
]);
922 case GAA_WORD_OPTION
:
924 case GAA_LETTER_OPTION
:
926 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
927 if(tmp2
== GAA_ERROR_NOMATCH
)
929 printf("Invalid option '%s'\n", argv
[i
]+j
);
932 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
934 case GAA_ERROR_NOTENOUGH_ARGS
:
935 printf("'%s': not enough arguments\n",gaa_current_option
);
937 case GAA_ERROR_INVALID_ARG
:
938 printf("Invalid arguments\n");
943 printf("Unknown error\n");
947 case GAA_MULTIPLE_OPTION
:
948 for(j
= 1; j
< strlen(argv
[i
]); j
++)
950 tmp2
= gaa_get_option_num(argv
[i
]+j
, tmp1
);
951 if(tmp2
== GAA_ERROR_NOMATCH
)
953 printf("Invalid option '%c'\n", *(argv
[i
]+j
));
956 switch(gaa_try(tmp2
, i
+1, gaaval
, opt_list
))
958 case GAA_ERROR_NOTENOUGH_ARGS
:
959 printf("'%s': not enough arguments\n",gaa_current_option
);
961 case GAA_ERROR_INVALID_ARG
:
962 printf("Invalid arguments\n");
967 printf("Unknown error\n");
976 if(gaa_processing_file
== 0)
980 #ifdef GAA_REST_EXISTS
981 switch(gaa_try(GAA_REST
, 1, gaaval
, opt_list
))
983 case GAA_ERROR_NOTENOUGH_ARGS
:
984 printf("Rest: not enough arguments\n");
986 case GAA_ERROR_INVALID_ARG
:
987 printf("Invalid arguments\n");
992 printf("Unknown error\n");
996 for(i
= 1; i
< argc
; i
++)
998 if(gaa_arg_used
[i
] == 0)
1000 printf("Too many arguments\n");
1012 struct gaastrnode
*next
;
1015 typedef struct gaastrnode gaa_str_node
;
1017 int gaa_internal_get_next_str(FILE *file
, gaa_str_node
*tmp_str
, int argc
)
1021 int i
= 0, len
= 0, newline
= 0;
1026 if(fscanf(file
,"%c", &a
) != 1) return 0;
1028 while(a
== ' ' || a
== 9 || a
== '\n')
1035 if(fscanf(file
,"%c", &a
) != 1) return 0;
1038 pos_ini
= ftell(file
) - 1;
1040 while(a
!= ' ' && a
!= 9 && a
!= '\n')
1044 if(fscanf(file
,"%c", &a
) != 1) a
= ' ';
1047 tmp_str
->str
= malloc((len
+ 1) * sizeof(char));
1050 tmp_str
->str
[0] = '-';
1051 tmp_str
->str
[1] = '-';
1059 fseek(file
,pos_ini
, SEEK_SET
);
1062 if(fscanf(file
, "%c", &a
) != 1)
1067 tmp_str
->str
[i
] = a
;
1070 while(a
!= ' ' && a
!= 9 && a
!= '\n');
1072 tmp_str
->str
[i
- 1] = 0;
1074 fseek(file
,- 1, SEEK_CUR
);
1075 /* printf("%d\n", ftell(file)); */
1080 int gaa_file(char *name
, gaainfo
*gaaval
)
1082 gaa_str_node
*first_str
, **tmp_str
, *tmp_str2
;
1088 gaa_processing_file
= 1;
1090 if((file
= fopen(name
, "r")) == NULL
)
1092 printf("Couldn't open '%s' configuration file for reading\n", name
);
1096 tmp_str
= &first_str
;
1100 *tmp_str
= malloc(sizeof(gaa_str_node
));
1101 (*tmp_str
)->str
= NULL
;
1102 (*tmp_str
)->next
= NULL
;
1104 rval
= gaa_internal_get_next_str(file
, *tmp_str
, argc
);
1105 tmp_str
= &((*tmp_str
)->next
);
1112 argv
= malloc((1 + argc
) * sizeof(char*));
1113 tmp_str2
= first_str
;
1115 for(i
= 1; i
< argc
; i
++)
1117 argv
[i
] = tmp_str2
->str
;
1118 tmp_str2
= tmp_str2
->next
;
1121 rval
= gaa(argc
, argv
, gaaval
);
1122 gaa_processing_file
= 0;