2 * Copyright (C) 1994, Index Data I/S
4 * Sebastian Hammer, Adam Dickmeiss
7 * Revision 1.1 1994-08-17 15:34:23 adam
8 * Initial version of resource manager.
21 static struct res *first = NULL, *last = NULL;
22 static int res_init = 0;
26 const char *alex_path (const char *name)
28 static char path[256];
31 if (!(alex_prefix = getenv ("ALEXPREFIX")))
34 if (*alex_prefix && alex_prefix[strlen(alex_prefix)-1] == '/')
35 sprintf (path, "%s%s", alex_prefix, name);
37 sprintf (path, "%s/%s", alex_prefix, name);
41 static void reread (void)
47 int val_size, val_max = 1024;
53 val_buf = xmalloc (val_max);
55 if (!(alex_base = getenv ("ALEXBASE")))
58 strcpy (path, alex_path(alex_base));
60 fr = fopen (path, "r");
63 log (LOG_FATAL, "cannot open %s", path);
68 line = fgets (fr_buf, 1023, fr);
75 while (fr_buf[no] && fr_buf[no] != '\n')
80 resp = last = first = xmalloc (sizeof(*resp));
83 resp = xmalloc (sizeof(*resp));
88 resp->name = xmalloc (no+1);
90 strcpy (resp->name, fr_buf);
97 if (fr_buf[no] == 0 || fr_buf[no] == '\n' )
102 if (fr_buf[no] == ':')
110 resp = last = first = xmalloc (sizeof(*resp));
113 resp = xmalloc (sizeof(*resp));
118 resp->name = xmalloc (no);
119 strcpy (resp->name, fr_buf);
121 while (fr_buf[no] == ' ')
126 if (fr_buf[no] == '\0' || fr_buf[no] == '\n')
128 val_buf[val_size++] = '\0';
129 resp->value = xmalloc (val_size);
130 strcpy (resp->value, val_buf);
133 else if (fr_buf[no] == '\\' && fr_buf[no+1] == '\n')
135 line = fgets (fr_buf, 1023, fr);
138 resp->value = xmalloc (val_size);
139 strcpy (resp->value, val_buf);
145 val_buf[val_size] = fr_buf[no++];
154 const char *res_get (const char *name)
161 const char *res_put (const char *name, const char *value)