2 * Copyright (C) 2012 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
6 * $Id: load_file.c,v 1.6.2.2 2012/07/22 08:04:24 darren_r Exp $
13 load_file(char *filename)
15 alist_t *a, *rtop, *rbot;
16 char *s, line[1024], *t;
20 fp = fopen(filename + 7, "r");
22 fprintf(stderr, "load_file cannot open '%s'\n", filename);
31 while (fgets(line, sizeof(line) - 1, fp)) {
32 line[sizeof(line) - 1] = '\0';
35 * Hunt for CR/LF. If no LF, stop processing.
37 s = strchr(line, '\n');
39 fprintf(stderr, "%d:%s: line too long\n",
47 * Remove trailing spaces
49 for (; ISSPACE(*s); s--)
52 s = strchr(line, '\r');
55 for (t = line; ISSPACE(*t); t++)
64 * Remove comment markers
74 * Trim off tailing white spaces
76 s = strlen(t) + t - 1;
80 a = alist_new(AF_UNSPEC, t);
89 fprintf(stderr, "%s:%d unrecognised content :%s\n",
90 filename, linenum, t);