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