2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.4 1997-05-14 06:54:07 adam
10 * Revision 1.3 1996/05/29 15:48:48 quinn
11 * Added \n to the isspace rule.
13 * Revision 1.2 1996/05/29 10:05:01 quinn
14 * Changed space criteria to support 8-bit characters
16 * Revision 1.1 1995/11/01 13:55:06 quinn
19 * Revision 1.2 1995/10/30 13:54:27 quinn
22 * Revision 1.1 1995/10/10 16:28:18 quinn
33 #define l_isspace(c) ((c) == '\t' || (c) == ' ' || (c) == '\n')
35 int readconf_line(FILE *f, char *line, int len, char *argv[], int num)
40 while ((p = fgets(line, len, f)))
42 while (*p && isspace(*p))
50 for (argc = 0; *p ; argc++)
52 if (*p == '#') /* trailing comment */
55 while (*p && !l_isspace(*p))
60 while (*p && l_isspace(*p))
68 * Read lines of a configuration file.
70 int readconf(char *name, void *rprivate,
71 int (*fun)(char *name, void *rprivate, int argc, char *argv[]))
74 char line[512], *m_argv[50];
77 if (!(f = fopen(name, "r")))
79 logf(LOG_WARN|LOG_ERRNO, "readconf: %s", name);
86 if (!(m_argc = readconf_line(f, line, 512, m_argv, 50)))
92 if ((res = (*fun)(name, rprivate, m_argc, m_argv)))