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