| File: | os/config.c |
| Location: | line 260, column 6 |
| Description: | Value stored to 'equals_missing' is never read |
| 1 | /* |
| 2 | Copyright 1987, 1998 The Open Group |
| 3 | |
| 4 | Permission to use, copy, modify, distribute, and sell this software and its |
| 5 | documentation for any purpose is hereby granted without fee, provided that |
| 6 | the above copyright notice appear in all copies and that both that |
| 7 | copyright notice and this permission notice appear in supporting |
| 8 | documentation. |
| 9 | |
| 10 | The above copyright notice and this permission notice shall be included in |
| 11 | all copies or substantial portions of the Software. |
| 12 | |
| 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 17 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 | |
| 20 | Except as contained in this notice, the name of The Open Group shall not be |
| 21 | used in advertising or otherwise to promote the sale, use or other dealings |
| 22 | in this Software without prior written authorization from The Open Group. |
| 23 | * Copyright 1990, 1991 Network Computing Devices; |
| 24 | * Portions Copyright 1987 by Digital Equipment Corporation |
| 25 | * |
| 26 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 27 | * documentation for any purpose is hereby granted without fee, provided that |
| 28 | * the above copyright notice appear in all copies and that both that |
| 29 | * copyright notice and this permission notice appear in supporting |
| 30 | * documentation, and that the names of Network Computing Devices, |
| 31 | * or Digital not be used in advertising or |
| 32 | * publicity pertaining to distribution of the software without specific, |
| 33 | * written prior permission. Network Computing Devices, or Digital |
| 34 | * make no representations about the |
| 35 | * suitability of this software for any purpose. It is provided "as is" |
| 36 | * without express or implied warranty. |
| 37 | * |
| 38 | * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH |
| 39 | * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 40 | * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, OR DIGITAL BE |
| 41 | * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 42 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
| 43 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 44 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 45 | * |
| 46 | */ |
| 47 | |
| 48 | #include "config.h" |
| 49 | |
| 50 | #include <stdio.h> |
| 51 | #include <stdlib.h> |
| 52 | #include <ctype.h> |
| 53 | #include <X11/Xtrans/Xtrans.h> |
| 54 | #include <X11/Xos.h> |
| 55 | #include "misc.h" |
| 56 | #include "configstr.h" |
| 57 | #include "osdep.h" |
| 58 | #include "globals.h" |
| 59 | #include "access.h" |
| 60 | #include "difsutils.h" |
| 61 | #include <X11/fonts/fontutil.h> |
| 62 | #include "difs.h" |
| 63 | #include <X11/fonts/fontconf.h> |
| 64 | |
| 65 | /* libXfont/src/bitmap/snfstr.h */ |
| 66 | extern void SnfSetFormat(int bit, int byte, int glyph, int scan); |
| 67 | |
| 68 | static const char * const default_config_files[] = { |
| 69 | #ifdef DEFAULT_CONFIG_FILE"/Users/jeremy/src/freedesktop/jhbuild/build/etc/X11/fs/config" |
| 70 | DEFAULT_CONFIG_FILE"/Users/jeremy/src/freedesktop/jhbuild/build/etc/X11/fs/config", |
| 71 | #else |
| 72 | "/usr/lib/X11/fs/config", |
| 73 | #endif |
| 74 | NULL((void*)0) |
| 75 | }; |
| 76 | |
| 77 | static char *font_catalogue = NULL((void*)0); |
| 78 | |
| 79 | static char *config_set_int(ConfigOptionPtr parm, char *val); |
| 80 | static char *config_set_bool(ConfigOptionPtr parm, char *val); |
| 81 | static char *config_set_catalogue(ConfigOptionPtr parm, char *val); |
| 82 | static char *config_set_glyph_caching_mode(ConfigOptionPtr parm, char *val); |
| 83 | static char *config_set_list(ConfigOptionPtr parm, char *val); |
| 84 | static char *config_set_file(ConfigOptionPtr parm, char *val); |
| 85 | static char *config_set_resolutions(ConfigOptionPtr parm, char *val); |
| 86 | static char *config_set_ignored_transports(ConfigOptionPtr parm, char *val); |
| 87 | static char *config_set_snf_format(ConfigOptionPtr parm, char *val); |
| 88 | |
| 89 | /* these need to be in lower case and alphabetical order so a |
| 90 | * binary search lookup can be used |
| 91 | */ |
| 92 | static ConfigOptionRec config_options[] = { |
| 93 | {"alternate-servers", config_set_list}, |
| 94 | {"catalogue", config_set_catalogue}, |
| 95 | {"client-limit", config_set_int}, |
| 96 | {"clone-self", config_set_bool}, |
| 97 | {"default-point-size", config_set_int}, |
| 98 | {"default-resolutions", config_set_resolutions}, |
| 99 | {"deferglyphs", config_set_glyph_caching_mode}, |
| 100 | {"error-file", config_set_file}, |
| 101 | {"no-listen", config_set_ignored_transports}, |
| 102 | {"port", config_set_int}, |
| 103 | {"server-number", config_set_int}, |
| 104 | {"snf-format", config_set_snf_format}, |
| 105 | {"trusted-clients", config_set_list}, |
| 106 | {"use-syslog", config_set_bool}, |
| 107 | {NULL((void*)0), NULL((void*)0)}, |
| 108 | }; |
| 109 | |
| 110 | /* max size in bytes of config file */ |
| 111 | #define CONFIG_MAX_FILESIZE32767 32767 |
| 112 | |
| 113 | #define CONFIG_ERR_MEMORY"CONFIG: insufficient memory to load configuration file \"%s\"\n" \ |
| 114 | "CONFIG: insufficient memory to load configuration file \"%s\"\n" |
| 115 | #define CONFIG_ERR_OPEN"CONFIG: can't open configuration file \"%s\"\n" "CONFIG: can't open configuration file \"%s\"\n" |
| 116 | #define CONFIG_ERR_READ"CONFIG: error reading configuration file \"%s\"\n" "CONFIG: error reading configuration file \"%s\"\n" |
| 117 | #define CONFIG_ERR_VALUE"CONFIG: bad value \"%s\" for parameter \"%s\"\n" "CONFIG: bad value \"%s\" for parameter \"%s\"\n" |
| 118 | #define CONFIG_ERR_UNKNOWN"CONFIG: unknown parameter \"%s\"\n" "CONFIG: unknown parameter \"%s\"\n" |
| 119 | #define CONFIG_ERR_NOEQUALS"CONFIG: missing '=' after parameter \"%s\"\n" "CONFIG: missing '=' after parameter \"%s\"\n" |
| 120 | #define CONFIG_ERR_RANGE"CONFIG: value out of range for parameter \"%s\"\n" "CONFIG: value out of range for parameter \"%s\"\n" |
| 121 | #define CONFIG_ERR_SYNTAX"CONFIG: syntax error near parameter \"%s\"\n" "CONFIG: syntax error near parameter \"%s\"\n" |
| 122 | #define CONFIG_ERR_NOVALUE"CONFIG: missing value for parameter \"%s\"\n" "CONFIG: missing value for parameter \"%s\"\n" |
| 123 | #define CONFIG_ERR_EXTRAVALUE"CONFIG: extra value for parameter \"%s\"\n" "CONFIG: extra value for parameter \"%s\"\n" |
| 124 | |
| 125 | #define iseol(c)((c) == '\n' || (c) == '\r' || (c) == '\f') ((c) == '\n' || (c) == '\r' || (c) == '\f') |
| 126 | #define skip_whitespace(c)while(isspace(*(c)) || *(c) == ',') (c)++; while(isspace(*(c)) || *(c) == ',') (c)++; |
| 127 | #define skip_val(c)while(!isspace(*(c)) && *(c) != ',' && *(c) != '\0') (c) ++; while(!isspace(*(c)) && *(c) != ',' && *(c) != '\0')\ |
| 128 | (c) ++; |
| 129 | #define skip_list_val(c)while(!isspace(*(c)) && *(c) != '\0') (c) ++; while(!isspace(*(c)) && *(c) != '\0')\ |
| 130 | (c) ++; |
| 131 | #define blank_comment(c)while (!((*(c)) == '\n' || (*(c)) == '\r' || (*(c)) == '\f') && *(c) != '\0') *(c)++= ' '; while (!iseol(*(c))((*(c)) == '\n' || (*(c)) == '\r' || (*(c)) == '\f') && *(c) != '\0') \ |
| 132 | *(c)++= ' '; |
| 133 | |
| 134 | static char * |
| 135 | next_assign(char *c) |
| 136 | { |
| 137 | int nesting = 0; |
| 138 | |
| 139 | while (*c != '\0') { |
| 140 | if (*c == '(') |
| 141 | nesting++; |
| 142 | else if (*c == ')') |
| 143 | nesting--; |
| 144 | else if (*c == '=' && nesting == 0) |
| 145 | return c; |
| 146 | c++; |
| 147 | } |
| 148 | return (char *) 0; |
| 149 | } |
| 150 | |
| 151 | static void |
| 152 | strip_comments(char *data) |
| 153 | { |
| 154 | char *c; |
| 155 | |
| 156 | c = data; |
| 157 | while ((c = strchr(c, '#')) != NULL((void*)0)) { |
| 158 | if (c == data || *(c - 1) != '\\') { |
| 159 | blank_comment(c)while (!((*(c)) == '\n' || (*(c)) == '\r' || (*(c)) == '\f') && *(c) != '\0') *(c)++= ' ';; |
| 160 | } else { |
| 161 | c++; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | static ConfigOptionPtr |
| 167 | match_param_name(char *name) |
| 168 | { |
| 169 | int pos, |
| 170 | rc, |
| 171 | low, |
| 172 | high; |
| 173 | |
| 174 | low = 0; |
| 175 | high = sizeof(config_options) / sizeof(ConfigOptionRec) - 2; |
| 176 | pos = high >> 1; |
| 177 | |
| 178 | while (low <= high) { |
| 179 | rc = strcmp(name, config_options[pos].parm_name); |
| 180 | if (rc == 0) { |
| 181 | return &config_options[pos]; |
| 182 | } else if (rc < 0) { |
| 183 | high = pos - 1; |
| 184 | } else { |
| 185 | low = pos + 1; |
| 186 | } |
| 187 | pos = ((high + low) >> 1); |
| 188 | } |
| 189 | return NULL((void*)0); |
| 190 | } |
| 191 | |
| 192 | static int |
| 193 | parse_config(char *data) |
| 194 | { |
| 195 | char *c, |
| 196 | *val = NULL((void*)0), |
| 197 | *next_eq, |
| 198 | *consumed, |
| 199 | *p; |
| 200 | char param_name[64]; |
| 201 | Bool equals_missing; |
| 202 | ConfigOptionPtr param; |
| 203 | |
| 204 | c = data; |
| 205 | skip_whitespace(c)while(isspace(*(c)) || *(c) == ',') (c)++;; |
| 206 | |
| 207 | while (*c != '\0') { |
| 208 | equals_missing = FALSE0; |
| 209 | |
| 210 | /* get parm name in lower case */ |
| 211 | p = c; |
| 212 | while (isalnum(*c) || *c == '-') { |
| 213 | if (isupper(*c)) |
| 214 | *c = tolower(*c); |
| 215 | c++; |
| 216 | } |
| 217 | memmove( param_name, p, min(sizeof(param_name), (int) (c - p)))__builtin___memmove_chk (param_name, p, (((sizeof(param_name) ) < ((int) (c - p))) ? (sizeof(param_name)) : ((int) (c - p ))), __builtin_object_size (param_name, 0)); |
| 218 | param_name[(int) (c - p)] = '\0'; |
| 219 | |
| 220 | /* check for junk */ |
| 221 | if (!isspace(*c) && *c != '=') { |
| 222 | ErrorF(CONFIG_ERR_SYNTAX"CONFIG: syntax error near parameter \"%s\"\n", param_name); |
| 223 | /* eat garbage */ |
| 224 | while (!isspace(*c) && *c != '=' && *c != '\0') |
| 225 | c++; |
| 226 | } |
| 227 | skip_whitespace(c)while(isspace(*(c)) || *(c) == ',') (c)++;; |
| 228 | if (*c != '=') { |
| 229 | ErrorF(CONFIG_ERR_NOEQUALS"CONFIG: missing '=' after parameter \"%s\"\n", param_name); |
| 230 | equals_missing = TRUE1; |
| 231 | } else { |
| 232 | c++; |
| 233 | } |
| 234 | |
| 235 | skip_whitespace(c)while(isspace(*(c)) || *(c) == ',') (c)++;; |
| 236 | |
| 237 | /* find next assignment to guess where the value ends */ |
| 238 | if ((next_eq = next_assign(c)) != NULL((void*)0)) { |
| 239 | /* back up over whitespace */ |
| 240 | for (val = next_eq - 1; val >= c && |
| 241 | (isspace(*val) || *val == ','); |
| 242 | val--); |
| 243 | |
| 244 | /* back over parm name */ |
| 245 | for (; val >= c && (isalnum(*val) || *val == '-'); val--); |
| 246 | |
| 247 | if (val <= c) { |
| 248 | /* no value, ignore */ |
| 249 | ErrorF(CONFIG_ERR_NOVALUE"CONFIG: missing value for parameter \"%s\"\n", param_name); |
| 250 | continue; |
| 251 | } |
| 252 | *val = '\0'; |
| 253 | } else if (*c == '\0') { |
| 254 | /* no value, ignore */ |
| 255 | ErrorF(CONFIG_ERR_NOVALUE"CONFIG: missing value for parameter \"%s\"\n", param_name); |
| 256 | continue; |
| 257 | } |
| 258 | /* match parm name */ |
| 259 | if (equals_missing) { |
| 260 | equals_missing = FALSE0; |
Value stored to 'equals_missing' is never read | |
| 261 | } else if ((param = match_param_name(param_name)) == NULL((void*)0)) { |
| 262 | ErrorF(CONFIG_ERR_UNKNOWN"CONFIG: unknown parameter \"%s\"\n", param_name); |
| 263 | } else { |
| 264 | consumed = (param->set_func) (param, c); |
| 265 | |
| 266 | skip_whitespace(consumed)while(isspace(*(consumed)) || *(consumed) == ',') (consumed)++ ;; |
| 267 | if (*consumed != '\0') { |
| 268 | ErrorF(CONFIG_ERR_EXTRAVALUE"CONFIG: extra value for parameter \"%s\"\n", |
| 269 | param_name); |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | if (next_eq != NULL((void*)0)) |
| 274 | c = val + 1; |
| 275 | else /* last setting */ |
| 276 | break; |
| 277 | } |
| 278 | return FSSuccess-1; |
| 279 | } |
| 280 | |
| 281 | /* |
| 282 | * handles anything that should be set once the file is parsed |
| 283 | */ |
| 284 | void |
| 285 | SetConfigValues(void) |
| 286 | { |
| 287 | int err, |
| 288 | num; |
| 289 | |
| 290 | if (font_catalogue == NULL((void*)0)) { |
| 291 | FatalError("font catalogue is missing/empty\n"); |
| 292 | } |
| 293 | |
| 294 | err = SetFontCatalogue(font_catalogue, &num); |
| 295 | if (err != FSSuccess-1) { |
| 296 | FatalError("element #%d (starting at 0) of font path is bad or has a bad font:\n\"%s\"\n", |
| 297 | num, font_catalogue); |
| 298 | } |
| 299 | InitErrors(); |
| 300 | fsfree((char *) font_catalogue)FSfree((pointer)(char *) font_catalogue); |
| 301 | font_catalogue = NULL((void*)0); |
| 302 | } |
| 303 | |
| 304 | |
| 305 | /* If argument is NULL, uses first file found from default_config_files */ |
| 306 | int |
| 307 | ReadConfigFile(const char *filename) |
| 308 | { |
| 309 | FILE *fp = NULL((void*)0); |
| 310 | int ret; |
| 311 | int len; |
| 312 | int i; |
| 313 | char *data; |
| 314 | |
| 315 | data = (char *) fsalloc(CONFIG_MAX_FILESIZE)FSalloc((unsigned long)32767); |
| 316 | if (!data) { |
| 317 | ErrorF(CONFIG_ERR_MEMORY"CONFIG: insufficient memory to load configuration file \"%s\"\n", filename); |
| 318 | return FSBadAlloc9; |
| 319 | } |
| 320 | if (filename != NULL((void*)0)) { |
| 321 | fp = fopen(filename, "r"); |
| 322 | if (fp == NULL((void*)0)) { |
| 323 | ErrorF(CONFIG_ERR_OPEN"CONFIG: can't open configuration file \"%s\"\n", filename); |
| 324 | } |
| 325 | } else { |
| 326 | for (i = 0; default_config_files[i] != NULL((void*)0); i++) { |
| 327 | filename = default_config_files[i]; |
| 328 | if ((fp = fopen(filename, "r")) != NULL((void*)0)) { |
| 329 | if (configfilename == NULL((void*)0)) { |
| 330 | configfilename = strdup(filename); /* save for clones */ |
| 331 | } |
| 332 | break; |
| 333 | } |
| 334 | } |
| 335 | if (fp == NULL((void*)0)) { |
| 336 | for (i = 0; default_config_files[i] != NULL((void*)0); i++) { |
| 337 | ErrorF(CONFIG_ERR_OPEN"CONFIG: can't open configuration file \"%s\"\n", default_config_files[i]); |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | if (fp == NULL((void*)0)) { |
| 342 | fsfree(data)FSfree((pointer)data); |
| 343 | return FSBadName7; |
| 344 | } |
| 345 | ret = fread(data, sizeof(char), CONFIG_MAX_FILESIZE32767, fp); |
| 346 | if (ret <= 0) { |
| 347 | fsfree(data)FSfree((pointer)data); |
| 348 | (void) fclose(fp); |
| 349 | ErrorF(CONFIG_ERR_READ"CONFIG: error reading configuration file \"%s\"\n", filename); |
| 350 | return FSBadName7; |
| 351 | } |
| 352 | len = ftell(fp); |
| 353 | len = min(len, CONFIG_MAX_FILESIZE)(((len) < (32767)) ? (len) : (32767)); |
| 354 | data[len] = '\0'; /* NULL terminate the data */ |
| 355 | |
| 356 | (void) fclose(fp); |
| 357 | |
| 358 | strip_comments(data); |
| 359 | ret = parse_config(data); |
| 360 | |
| 361 | fsfree(data)FSfree((pointer)data); |
| 362 | |
| 363 | return ret; |
| 364 | } |
| 365 | |
| 366 | struct nameVal { |
| 367 | const char *name; |
| 368 | int val; |
| 369 | }; |
| 370 | |
| 371 | static char * |
| 372 | config_parse_nameVal ( |
| 373 | ConfigOptionPtr parm, |
| 374 | char *c, |
| 375 | int *ret, |
| 376 | int *pval, |
| 377 | struct nameVal *name_val) |
| 378 | { |
| 379 | char *start, |
| 380 | t; |
| 381 | int i, |
| 382 | len; |
| 383 | |
| 384 | start = c; |
| 385 | skip_val(c)while(!isspace(*(c)) && *(c) != ',' && *(c) != '\0') (c) ++;; |
| 386 | t = *c; |
| 387 | *c = '\0'; |
| 388 | len = c - start; |
| 389 | |
| 390 | for (i = 0; name_val[i].name; i++) { |
| 391 | if (!strncmpnocase(start, name_val[i].name, len)) { |
| 392 | *pval = name_val[i].val; |
| 393 | *ret = 0; |
| 394 | *c = t; |
| 395 | return c; |
| 396 | } |
| 397 | } |
| 398 | ErrorF(CONFIG_ERR_VALUE"CONFIG: bad value \"%s\" for parameter \"%s\"\n", start, parm->parm_name); |
| 399 | *c = t; |
| 400 | *ret = -1; |
| 401 | return c; |
| 402 | } |
| 403 | |
| 404 | static char * |
| 405 | config_parse_bool ( |
| 406 | ConfigOptionPtr parm, |
| 407 | char *c, |
| 408 | int *ret, |
| 409 | Bool *pval) |
| 410 | { |
| 411 | static struct nameVal bool_val[] = { |
| 412 | { "yes", TRUE1 }, |
| 413 | { "on", TRUE1 }, |
| 414 | { "1", TRUE1 }, |
| 415 | { "true", TRUE1 }, |
| 416 | { "no", FALSE0 }, |
| 417 | { "off", FALSE0 }, |
| 418 | { "0", FALSE0 }, |
| 419 | { "false", FALSE0 }, |
| 420 | { (char *) 0, 0 }, |
| 421 | }; |
| 422 | return config_parse_nameVal (parm, c, ret, pval, bool_val); |
| 423 | } |
| 424 | |
| 425 | static char * |
| 426 | config_parse_int( |
| 427 | ConfigOptionPtr parm, |
| 428 | char *c, |
| 429 | int *ret, |
| 430 | int *pval) |
| 431 | { |
| 432 | char *start, |
| 433 | t; |
| 434 | |
| 435 | start = c; |
| 436 | while (*c != '\0' && !isspace(*c) && *c != ',') { |
| 437 | if (!isdigit(*c)) { /* error */ |
| 438 | skip_val(c)while(!isspace(*(c)) && *(c) != ',' && *(c) != '\0') (c) ++;; |
| 439 | t = *c; |
| 440 | *c = '\0'; |
| 441 | ErrorF(CONFIG_ERR_VALUE"CONFIG: bad value \"%s\" for parameter \"%s\"\n", start, parm->parm_name); |
| 442 | *ret = -1; |
| 443 | *c = t; |
| 444 | return c; |
| 445 | } |
| 446 | c++; |
| 447 | } |
| 448 | t = *c; |
| 449 | *c = '\0'; |
| 450 | *ret = 0; |
| 451 | *pval = atoi(start); |
| 452 | *c = t; |
| 453 | return c; |
| 454 | } |
| 455 | |
| 456 | |
| 457 | /* config option sets */ |
| 458 | /* these have to know how to do the real work and tweak the proper things */ |
| 459 | static char * |
| 460 | config_set_int( |
| 461 | ConfigOptionPtr parm, |
| 462 | char *val) |
| 463 | { |
| 464 | int ival, |
| 465 | ret; |
| 466 | |
| 467 | val = config_parse_int(parm, val, &ret, &ival); |
| 468 | if (ret == -1) |
| 469 | return val; |
| 470 | |
| 471 | /* now do individual attribute checks */ |
| 472 | if (!strcmp(parm->parm_name, "port") && !portFromCmdline) { |
| 473 | ListenPort = ival; |
| 474 | } else if (!strcmp(parm->parm_name, "client-limit")) { |
| 475 | AccessSetConnectionLimit(ival); |
| 476 | } else if (!strcmp(parm->parm_name, "default-point-size")) { |
| 477 | SetDefaultPointSize(ival); |
| 478 | } |
| 479 | return val; |
| 480 | } |
| 481 | |
| 482 | static char * |
| 483 | config_set_bool( |
| 484 | ConfigOptionPtr parm, |
| 485 | char *val) |
| 486 | { |
| 487 | int |
| 488 | ret; |
| 489 | Bool bval; |
| 490 | |
| 491 | val = config_parse_bool(parm, val, &ret, &bval); |
| 492 | if (ret == -1) |
| 493 | return val; |
| 494 | |
| 495 | /* now do individual attribute checks */ |
| 496 | if (!strcmp(parm->parm_name, "use-syslog")) { |
| 497 | UseSyslog = bval; |
| 498 | } else if (!strcmp(parm->parm_name, "clone-self")) { |
| 499 | CloneSelf = bval; |
| 500 | } |
| 501 | return val; |
| 502 | } |
| 503 | |
| 504 | static char * |
| 505 | config_set_file( |
| 506 | ConfigOptionPtr parm, |
| 507 | char *val) |
| 508 | { |
| 509 | char *start = val, |
| 510 | t; |
| 511 | |
| 512 | skip_val(val)while(!isspace(*(val)) && *(val) != ',' && *( val) != '\0') (val) ++;; |
| 513 | t = *val; |
| 514 | *val = '\0'; |
| 515 | if (!strcmp(parm->parm_name, "error-file")) { |
| 516 | memmove( ErrorFile, start, val - start + 1)__builtin___memmove_chk (ErrorFile, start, val - start + 1, __builtin_object_size (ErrorFile, 0)); |
| 517 | } |
| 518 | *val = t; |
| 519 | return val; |
| 520 | } |
| 521 | |
| 522 | static char * |
| 523 | config_set_catalogue( |
| 524 | ConfigOptionPtr parm, |
| 525 | char *val) |
| 526 | { |
| 527 | char *b; |
| 528 | |
| 529 | if (!strcmp(parm->parm_name, "catalogue")) { |
| 530 | /* stash it for later */ |
| 531 | fsfree((char *) font_catalogue)FSfree((pointer)(char *) font_catalogue); /* dump any previous one */ |
| 532 | b = font_catalogue = (char *) fsalloc(strlen(val) + 1)FSalloc((unsigned long)strlen(val) + 1); |
| 533 | if (!font_catalogue) |
| 534 | FatalError("insufficent memory for font catalogue\n"); |
| 535 | while (*val) { /* remove all the gunk */ |
| 536 | if (!isspace(*val)) { |
| 537 | *b++ = *val; |
| 538 | } |
| 539 | val++; |
| 540 | } |
| 541 | *b = '\0'; |
| 542 | } |
| 543 | return val; |
| 544 | } |
| 545 | |
| 546 | static char * |
| 547 | config_set_list( |
| 548 | ConfigOptionPtr parm, |
| 549 | char *val) |
| 550 | { |
| 551 | char *start = val, |
| 552 | t; |
| 553 | |
| 554 | skip_list_val(val)while(!isspace(*(val)) && *(val) != '\0') (val) ++;; |
| 555 | t = *val; |
| 556 | *val = '\0'; |
| 557 | if (!strcmp(parm->parm_name, "alternate-servers")) { |
| 558 | SetAlternateServers(start); |
| 559 | } |
| 560 | *val = t; |
| 561 | return val; |
| 562 | } |
| 563 | |
| 564 | static char * |
| 565 | config_set_ignored_transports( |
| 566 | ConfigOptionPtr parm, |
| 567 | char *val) |
| 568 | { |
| 569 | char *start = val, |
| 570 | t; |
| 571 | |
| 572 | skip_list_val(val)while(!isspace(*(val)) && *(val) != '\0') (val) ++;; |
| 573 | t = *val; |
| 574 | *val = '\0'; |
| 575 | _FontTransNoListen(start); |
| 576 | *val = t; |
| 577 | return val; |
| 578 | } |
| 579 | |
| 580 | static char * |
| 581 | config_set_glyph_caching_mode( |
| 582 | ConfigOptionPtr parm, |
| 583 | char *val) |
| 584 | { |
| 585 | char *start = val, |
| 586 | t; |
| 587 | |
| 588 | skip_list_val(val)while(!isspace(*(val)) && *(val) != '\0') (val) ++;; |
| 589 | t = *val; |
| 590 | *val = '\0'; |
| 591 | if (!strcmp(parm->parm_name, "deferglyphs")) { |
| 592 | ParseGlyphCachingMode(start); |
| 593 | } |
| 594 | *val = t; |
| 595 | return val; |
| 596 | } |
| 597 | |
| 598 | static char * |
| 599 | config_set_resolutions( |
| 600 | ConfigOptionPtr parm, |
| 601 | char *val) |
| 602 | { |
| 603 | char *start = val, |
| 604 | t; |
| 605 | int err; |
| 606 | |
| 607 | skip_list_val(val)while(!isspace(*(val)) && *(val) != '\0') (val) ++;; |
| 608 | t = *val; |
| 609 | *val = '\0'; |
| 610 | if (!strcmp(parm->parm_name, "default-resolutions")) { |
| 611 | err = SetDefaultResolutions(start); |
| 612 | if (err != FSSuccess-1) { |
| 613 | FatalError("bogus resolution list \"%s\"\n", start); |
| 614 | } |
| 615 | } |
| 616 | *val = t; |
| 617 | return val; |
| 618 | } |
| 619 | |
| 620 | |
| 621 | static char * |
| 622 | config_parse_endian( |
| 623 | ConfigOptionPtr parm, |
| 624 | char *c, |
| 625 | int *ret, |
| 626 | int *pval) |
| 627 | { |
| 628 | static struct nameVal endian_val[] = { |
| 629 | { "lsb", LSBFirst0 }, |
| 630 | { "little", LSBFirst0 }, |
| 631 | { "lsbfirst", LSBFirst0 }, |
| 632 | { "msb", MSBFirst1 }, |
| 633 | { "big", MSBFirst1 }, |
| 634 | { "msbfirst", MSBFirst1 }, |
| 635 | { (char *) 0, 0 }, |
| 636 | }; |
| 637 | return config_parse_nameVal (parm, c, ret, pval, endian_val); |
| 638 | } |
| 639 | |
| 640 | /* ARGSUSED */ |
| 641 | static char * |
| 642 | config_set_snf_format ( |
| 643 | ConfigOptionPtr parm, |
| 644 | char *val) |
| 645 | { |
| 646 | int bit, byte, glyph, scan; |
| 647 | int ret; |
| 648 | |
| 649 | val = config_parse_endian (parm, val, &ret, &bit); |
| 650 | if (ret == -1) |
| 651 | return val; |
| 652 | skip_whitespace (val)while(isspace(*(val)) || *(val) == ',') (val)++;; |
| 653 | val = config_parse_endian (parm, val, &ret, &byte); |
| 654 | if (ret == -1) |
| 655 | return val; |
| 656 | skip_whitespace (val)while(isspace(*(val)) || *(val) == ',') (val)++;; |
| 657 | val = config_parse_int (parm, val, &ret, &glyph); |
| 658 | if (ret == -1) |
| 659 | return val; |
| 660 | skip_whitespace (val)while(isspace(*(val)) || *(val) == ',') (val)++;; |
| 661 | val = config_parse_int (parm, val, &ret, &scan); |
| 662 | if (ret == -1) |
| 663 | return val; |
| 664 | #ifdef XFONT_SNFFORMAT |
| 665 | SnfSetFormat (bit, byte, glyph, scan); |
| 666 | #endif |
| 667 | return val; |
| 668 | } |