2 static char copyright[] = "Copyright 1992 The University of Adelaide";
8 * Author: Mark R. Prior
9 * Communications and Systems Branch
10 * Information Technology Division
11 * The University of Adelaide
12 * E-mail: mrp@itd.adelaide.edu.au
16 * Process the configuration file.
18 * Redistribution and use in source and binary forms are permitted
19 * provided that the above copyright notice and this paragraph are
20 * duplicated in all such forms and that any documentation,
21 * advertising materials, and other materials related to such
22 * distribution and use acknowledge that the software was developed
23 * by the University of Adelaide. The name of the University may not
24 * be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
28 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
43 "helpdir", CMD_HELPDIR,
46 #define CMD_PASSWORD 5
47 "password", CMD_PASSWORD,
48 #define CMD_CONFIGDIR 6
49 "configdir", CMD_CONFIGDIR,
51 "contact", CMD_CONTACT,
52 #define CMD_HOSTNAME 8
53 "hostname", CMD_HOSTNAME,
54 #define CMD_LANGUAGE 9
55 "language", CMD_LANGUAGE,
58 #define CMD_TEMPLATE 11
59 "template", CMD_TEMPLATE,
67 * We probably should check that the user hasn't put anything else
68 * on the line but I can't be bothered!
72 while ((c = getc(fp)) != EOF && c != '\n')
77 * Get next word, skipping blanks & comments.
80 getWord( char *buffer, int size, FILE *fp )
87 while ((c = getc(fp)) != EOF) {
89 while ((c = getc(fp)) != EOF && c != '\n')
97 } else if (c == '\\') {
101 } else if (c == '"') {
105 if (!string && isspace(c)) {
106 while (isspace(c = getc(fp)) && c != '\n')
109 if (cp != buffer) /* Trailing whitespace */
111 continue; /* Leading whitespace */
113 if (cp >= buffer+size-1)
118 return (cp != buffer);
122 readConfiguration( FILE *config )
129 * A procedure to read in the configuration parameters.
130 * At the moment this is just a "quick hack" and it should be
131 * replaced in the next version by a proper scanner.
134 while ( getWord( buffer, BUFSIZ, config ) != NULL ) {
135 for ( i = 0; commands[i].str != NULL; i++ )
136 if ( EQ( buffer, commands[i].str ) )
138 if ( commands[i].str == NULL ) {
139 printFormatted( lineLength, TRUE, stdout,
140 "Unrecognised command <%s>", buffer );
143 if ( getWord( buffer, BUFSIZ, config ) == NULL ) {
144 printFormatted( lineLength, TRUE, stdout,
145 "value missing in configuration file" );
148 switch ( commands[i].cmd ) {
150 base = strdup( buffer );
154 ldaphost = strdup( buffer );
158 helpDir = strdup( buffer );
162 user = strdup( buffer );
166 password = strdup( buffer );
170 configDir = strdup( buffer );
174 contact = strdup( buffer );
178 hostname = strdup( buffer );
182 defaultLanguage = lowerCase( strdup( buffer ) );
186 banner = strdup( buffer );
190 if ( templateTranslationTable == NULL
191 && ( templateTranslationTable = (table *)malloc(sizeof(table)*tableSize) ) == NULL ) {
192 printFormatted( lineLength, TRUE, stdout,
195 } else if ( numberOfTemplates+1 == tableSize ) {
196 tableSize += TABLE_INCREMENT;
197 if ( ( templateTranslationTable = (table *)realloc(templateTranslationTable, sizeof(table)*tableSize) ) == NULL ) {
198 printFormatted( lineLength, TRUE, stdout,
203 templateTranslationTable[numberOfTemplates].key =
204 lowerCase( strdup( buffer ) );
205 if ( getWord( buffer, BUFSIZ, config ) == NULL ) {
206 printFormatted( lineLength, TRUE, stdout,
207 "objectClass missing in config file" );
210 templateTranslationTable[numberOfTemplates].value =
211 lowerCase( strdup( buffer ) );
216 printFormatted( lineLength, TRUE, stdout,
217 "Attribute <%s> not recognised.",