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