Mercurial > masqmail
comparison src/conf.c @ 394:c8e3d1a79313
Refactoring in conf.c: read_rval().
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Sat, 18 Feb 2012 19:32:40 +0100 |
parents | 5e728dd64c1b |
children | 5f0829f8e6c7 |
comparison
equal
deleted
inserted
replaced
393:5e728dd64c1b | 394:c8e3d1a79313 |
---|---|
254 } | 254 } |
255 } | 255 } |
256 return FALSE; | 256 return FALSE; |
257 } | 257 } |
258 | 258 |
259 /* | |
260 ** after parsing, eat trailing characters until and including the Newline | |
261 */ | |
262 static gboolean | |
263 eat_line_trailing(FILE *in) | |
264 { | |
265 gint c; | |
266 | |
267 while ((c = fgetc(in)) != EOF) { | |
268 if (c == '\n') { | |
269 return TRUE; | |
270 } | |
271 } | |
272 return FALSE; | |
273 } | |
274 | |
275 static gboolean | 259 static gboolean |
276 eat_spaces(FILE *in) | 260 eat_spaces(FILE *in) |
277 { | 261 { |
278 gint c; | 262 gint c; |
279 | 263 |
330 if (!eat_spaces(in)) { | 314 if (!eat_spaces(in)) { |
331 return FALSE; | 315 return FALSE; |
332 } | 316 } |
333 | 317 |
334 c = fgetc(in); | 318 c = fgetc(in); |
335 if (c != '\"') { | 319 if (c != '"') { |
336 while ((isalnum(c) || c == '_' || c == '-' || c == '.' | 320 /* unquoted rval */ |
337 || c == '/' || c == '@' || c == ';' || c == ':') | 321 ungetc(c, in); |
338 && (ptr < buf + size - 1) | 322 while ((c = fgetc(in)) != EOF) { |
339 && (c != EOF)) { | 323 if (ptr >= buf+size-1) { |
340 *ptr = c; | 324 /* rval too long */ |
341 ptr++; | 325 break; |
342 c = fgetc(in); | 326 } |
327 if (!isalnum(c) && c != '_' && c != '-' && | |
328 c != '.' && c != '/' && c != '@' && | |
329 c != ';' && c != ':') { | |
330 break; | |
331 } | |
332 *ptr++ = c; | |
343 } | 333 } |
344 *ptr = '\0'; | 334 *ptr = '\0'; |
345 ungetc(c, in); | 335 ungetc(c, in); |
346 } else { | 336 } else { |
337 /* quoted rval */ | |
347 gboolean escape = FALSE; | 338 gboolean escape = FALSE; |
348 c = fgetc(in); | 339 while ((c = fgetc(in)) != EOF) { |
349 while (((c != '\"') || escape) && (ptr < buf + size - 1)) { | 340 if (ptr >= buf+size-1) { |
350 if (c != '\n') { /* ignore line breaks */ | 341 /* rval too long */ |
351 if ((c == '\\') && (!escape)) { | 342 break; |
352 escape = TRUE; | 343 } |
353 } else { | 344 if (!escape && c == '"') { |
354 *ptr = c; | 345 break; |
355 ptr++; | 346 } |
356 escape = FALSE; | 347 if (!escape && c == '\\') { |
357 } | 348 escape = TRUE; |
358 } | 349 continue; |
359 c = fgetc(in); | 350 } |
351 *ptr++ = c; | |
352 escape = FALSE; | |
360 } | 353 } |
361 *ptr = '\0'; | 354 *ptr = '\0'; |
362 } | 355 } |
363 | |
364 eat_line_trailing(in); | |
365 | |
366 DEBUG(9) fprintf(stderr, "rval = %s\n", buf); | 356 DEBUG(9) fprintf(stderr, "rval = %s\n", buf); |
357 /* eat trailing of line */ | |
358 while ((c = fgetc(in)) != EOF && c != '\n') { | |
359 continue; | |
360 } | |
367 | 361 |
368 return TRUE; | 362 return TRUE; |
369 } | 363 } |
370 | 364 |
371 static gboolean | 365 static gboolean |