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.
42 "helpdir", CMD_HELPDIR,
45 #define CMD_PASSWORD 5
46 "password", CMD_PASSWORD,
47 #define CMD_CONFIGDIR 6
48 "configdir", CMD_CONFIGDIR,
50 "contact", CMD_CONTACT,
51 #define CMD_HOSTNAME 8
52 "hostname", CMD_HOSTNAME,
53 #define CMD_LANGUAGE 9
54 "language", CMD_LANGUAGE,
57 #define CMD_TEMPLATE 11
58 "template", CMD_TEMPLATE,
66 * We probably should check that the user hasn't put anything else
67 * on the line but I can't be bothered!
71 while ((c = getc(fp)) != EOF && c != '\n')
76 * Get next word, skipping blanks & comments.
78 static int getWord(buffer, size, fp)
88 while ((c = getc(fp)) != EOF) {
90 while ((c = getc(fp)) != EOF && c != '\n')
98 } else if (c == '\\') {
102 } else if (c == '"') {
106 if (!string && isspace(c)) {
107 while (isspace(c = getc(fp)) && c != '\n')
110 if (cp != buffer) /* Trailing whitespace */
112 continue; /* Leading whitespace */
114 if (cp >= buffer+size-1)
119 return (cp != buffer);
122 void readConfiguration( config )
131 * A procedure to read in the configuration parameters.
132 * At the moment this is just a "quick hack" and it should be
133 * replaced in the next version by a proper scanner.
136 while ( getWord( buffer, BUFSIZ, config ) != NULL ) {
137 for ( i = 0; commands[i].str != NULL; i++ )
138 if ( EQ( buffer, commands[i].str ) )
140 if ( commands[i].str == NULL ) {
141 printFormatted( lineLength, TRUE, stdout,
142 "Unrecognised command <%s>", buffer );
145 if ( getWord( buffer, BUFSIZ, config ) == NULL ) {
146 printFormatted( lineLength, TRUE, stdout,
147 "value missing in configuration file" );
150 switch ( commands[i].cmd ) {
152 base = strdup( buffer );
156 ldaphost = strdup( buffer );
160 helpDir = strdup( buffer );
164 user = strdup( buffer );
168 password = strdup( buffer );
172 configDir = strdup( buffer );
176 contact = strdup( buffer );
180 hostname = strdup( buffer );
184 defaultLanguage = lowerCase( strdup( buffer ) );
188 banner = strdup( buffer );
192 if ( templateTranslationTable == NULL
193 && ( templateTranslationTable = (table *)malloc(sizeof(table)*tableSize) ) == NULL ) {
194 printFormatted( lineLength, TRUE, stdout,
197 } else if ( numberOfTemplates+1 == tableSize ) {
198 tableSize += TABLE_INCREMENT;
199 if ( ( templateTranslationTable = (table *)realloc(templateTranslationTable, sizeof(table)*tableSize) ) == NULL ) {
200 printFormatted( lineLength, TRUE, stdout,
205 templateTranslationTable[numberOfTemplates].key =
206 lowerCase( strdup( buffer ) );
207 if ( getWord( buffer, BUFSIZ, config ) == NULL ) {
208 printFormatted( lineLength, TRUE, stdout,
209 "objectClass missing in config file" );
212 templateTranslationTable[numberOfTemplates].value =
213 lowerCase( strdup( buffer ) );
218 printFormatted( lineLength, TRUE, stdout,
219 "Attribute <%s> not recognised.",