2 * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 RCSID("$Id: extra.c,v 1.7.2.1 2000/12/07 16:06:09 assar Exp $");
44 static struct value *_extra_values;
46 static int _krb_extra_read = 0;
49 define_variable(const char *variable, const char *value)
52 e = malloc(sizeof(*e));
55 e->variable = strdup(variable);
56 if(e->variable == NULL) {
60 e->value = strdup(value);
61 if(e->value == NULL) {
66 e->next = _extra_values;
82 while(krb_get_krbextra(i++, file, sizeof(file)) == 0) {
83 FILE *f = fopen(file, "r");
86 while(fgets(line, sizeof(line), f)) {
87 char *var, *tmp, *val;
89 /* skip initial whitespace */
90 var = line + strspn(line, " \t");
91 /* skip non-whitespace */
92 tmp = var + strcspn(var, " \t=");
94 val = tmp + strspn(tmp, " \t=");
96 tmp = val + strcspn(val, " \t\n");
98 if(*var == '\0' || *var == '#' || *val == '\0')
101 krb_warning("%s: setting `%s' to `%s'\n", file, var, val);
102 define_variable(var, val);
113 read_extra_file(void)
115 char name[1024], data[1024];
116 DWORD name_sz, data_sz;
125 if(RegCreateKey(HKEY_CURRENT_USER, "krb4", ®_key) != 0)
130 name_sz = sizeof(name);
131 data_sz = sizeof(data);
132 if(RegEnumValue(reg_key,
142 define_variable(name, data);
144 RegCloseKey(reg_key);
151 find_variable(const char *variable)
154 for(e = _extra_values; e; e = e->next) {
155 if(strcasecmp(variable, e->variable) == 0)
162 krb_get_config_string(const char *variable)
165 return find_variable(variable);
169 krb_get_config_bool(const char *variable)
171 const char *value = krb_get_config_string(variable);
174 return strcasecmp(value, "yes") == 0 ||
175 strcasecmp(value, "true") == 0 ||