comparison cfgparser.c @ 179:6f890e61739b

fix...
author szabii
date Wed, 21 Mar 2001 02:56:06 +0000
parents 554c6e5f36ef
children aa52cdb712d8
comparison
equal deleted inserted replaced
178:55206b791586 179:6f890e61739b
226 #define MAX_LINE_LEN 1000 226 #define MAX_LINE_LEN 1000
227 #define MAX_OPT_LEN 100 227 #define MAX_OPT_LEN 100
228 #define MAX_PARAM_LEN 100 228 #define MAX_PARAM_LEN 100
229 FILE *fp; 229 FILE *fp;
230 char *line; 230 char *line;
231 char opt[MAX_OPT_LEN]; 231 char opt[MAX_OPT_LEN + 1];
232 char param[MAX_PARAM_LEN]; 232 char param[MAX_PARAM_LEN + 1];
233 char c; /* for the "" and '' check */ 233 char c; /* for the "" and '' check */
234 int tmp; 234 int tmp;
235 int line_num = 0; 235 int line_num = 0;
236 int line_pos; /* line pos */ 236 int line_pos; /* line pos */
237 int opt_pos; /* opt pos */ 237 int opt_pos; /* opt pos */
241 #ifdef DEBUG 241 #ifdef DEBUG
242 assert(conffile != NULL); 242 assert(conffile != NULL);
243 #endif 243 #endif
244 if (++recursion_depth > MAX_RECURSION_DEPTH) { 244 if (++recursion_depth > MAX_RECURSION_DEPTH) {
245 printf("too deep 'include'. check your configfiles\n"); 245 printf("too deep 'include'. check your configfiles\n");
246 --recursion_depth;
246 return -1; 247 return -1;
247 } 248 }
248 249
249 printf("Reading config file: %s\n", conffile); 250 printf("Reading config file: %s\n", conffile);
250 251
251 if (init_conf(conf, CONFIG_FILE) == -1) { 252 if (init_conf(conf, CONFIG_FILE) == -1) {
252 ret = -1; 253 ret = -1;
253 goto out; 254 goto out;
254 } 255 }
255 256
256 if ((line = (char *) malloc(MAX_LINE_LEN)) == NULL) { 257 if ((line = (char *) malloc(MAX_LINE_LEN + 1)) == NULL) {
257 perror("parse_config_file: can't get memory for 'line'"); 258 perror("parse_config_file: can't get memory for 'line'");
258 ret = -1; 259 ret = -1;
259 goto out; 260 goto out;
260 } 261 }
261 262