2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.9 1999-11-30 13:47:12 adam
8 * Improved installation. Moved header files to include/yaz.
10 * Revision 1.8 1999/08/27 09:40:32 adam
11 * Renamed logf function to yaz_log. Removed VC++ project files.
13 * Revision 1.7 1999/06/30 09:10:32 adam
14 * Fixed reading of MS-DOS files.
16 * Revision 1.6 1998/10/13 16:09:55 adam
17 * Added support for arbitrary OID's for tagsets, schemas and attribute sets.
18 * Added support for multiple attribute set references and tagset references
19 * from an abstract syntax file.
20 * Fixed many bad logs-calls in routines that read the various
21 * specifications regarding data1 (*.abs,*.att,...) and made the messages
22 * consistent whenever possible.
23 * Added extra 'lineno' argument to function readconf_line.
25 * Revision 1.5 1997/09/04 07:53:02 adam
26 * Added include readconf.h.
28 * Revision 1.4 1997/05/14 06:54:07 adam
31 * Revision 1.3 1996/05/29 15:48:48 quinn
32 * Added \n to the isspace rule.
34 * Revision 1.2 1996/05/29 10:05:01 quinn
35 * Changed space criteria to support 8-bit characters
37 * Revision 1.1 1995/11/01 13:55:06 quinn
40 * Revision 1.2 1995/10/30 13:54:27 quinn
43 * Revision 1.1 1995/10/10 16:28:18 quinn
53 #include <yaz/readconf.h>
55 #define l_isspace(c) ((c) == '\t' || (c) == ' ' || (c) == '\n' || (c) == '\r')
57 int readconf_line(FILE *f, int *lineno, char *line, int len,
58 char *argv[], int num)
63 while ((p = fgets(line, len, f)))
66 while (*p && l_isspace(*p))
74 for (argc = 0; *p ; argc++)
76 if (*p == '#') /* trailing comment */
79 while (*p && !l_isspace(*p))
84 while (*p && l_isspace(*p))
92 * Read lines of a configuration file.
94 int readconf(char *name, void *rprivate,
95 int (*fun)(char *name, void *rprivate, int argc, char *argv[]))
98 char line[512], *m_argv[50];
102 if (!(f = fopen(name, "r")))
104 yaz_log(LOG_WARN|LOG_ERRNO, "readconf: %s", name);
111 if (!(m_argc = readconf_line(f, &lineno, line, 512, m_argv, 50)))
117 if ((res = (*fun)(name, rprivate, m_argc, m_argv)))