2 * Copyright (C) 1994-1997, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.5 1997-09-04 07:53:02 adam
8 * Added include readconf.h.
10 * Revision 1.4 1997/05/14 06:54:07 adam
13 * Revision 1.3 1996/05/29 15:48:48 quinn
14 * Added \n to the isspace rule.
16 * Revision 1.2 1996/05/29 10:05:01 quinn
17 * Changed space criteria to support 8-bit characters
19 * Revision 1.1 1995/11/01 13:55:06 quinn
22 * Revision 1.2 1995/10/30 13:54:27 quinn
25 * Revision 1.1 1995/10/10 16:28:18 quinn
37 #define l_isspace(c) ((c) == '\t' || (c) == ' ' || (c) == '\n')
39 int readconf_line(FILE *f, char *line, int len, char *argv[], int num)
44 while ((p = fgets(line, len, f)))
46 while (*p && isspace(*p))
54 for (argc = 0; *p ; argc++)
56 if (*p == '#') /* trailing comment */
59 while (*p && !l_isspace(*p))
64 while (*p && l_isspace(*p))
72 * Read lines of a configuration file.
74 int readconf(char *name, void *rprivate,
75 int (*fun)(char *name, void *rprivate, int argc, char *argv[]))
78 char line[512], *m_argv[50];
81 if (!(f = fopen(name, "r")))
83 logf(LOG_WARN|LOG_ERRNO, "readconf: %s", name);
90 if (!(m_argc = readconf_line(f, line, 512, m_argv, 50)))
96 if ((res = (*fun)(name, rprivate, m_argc, m_argv)))