X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fconfig.c;h=dccf37c813c9708cfb759b8b5dcb2ae962668d14;hb=6e1b30ae9e47ce56352acb5911c961acf2f8b9f5;hp=80c94bf3c85613e268342fc1eba88e42075ab582;hpb=9f3ca6bf02300e3dc72e3c2085a8e35aa9242678;p=flatwaifu.git diff --git a/src/config.c b/src/config.c index 80c94bf..dccf37c 100644 --- a/src/config.c +++ b/src/config.c @@ -1,24 +1,17 @@ -/* - Copyright (C) Prikol Software 1996-1997 - Copyright (C) Aleksey Volynskov 1996-1997 - Copyright (C) 2011 - - This file is part of the Doom2D:Rembo project. - - Doom2D:Rembo is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - Doom2D:Rembo is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see or - write to the Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ +/* Copyright (C) 2020 SovietPony + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "glob.h" #include @@ -35,15 +28,20 @@ static int ch; const cfg_t *CFG_find_entry (const char *key, const cfg_t *cfg) { assert(key != NULL); - assert(cfg != NULL); - int i = 0; - while (cfg[i].cfg && strcasecmp(cfg[i].cfg, key) != 0) { - i++; + if (cfg != NULL) { + int i = 0; + while (cfg[i].cfg && strcasecmp(cfg[i].cfg, key) != 0) { + i++; + } + return cfg[i].cfg ? &cfg[i] : NULL; + } else { + return NULL; } - return cfg[i].cfg ? &cfg[i] : NULL; } int CFG_update_key (const char *key, const char *value, const cfg_t *cfg) { + assert(key != NULL); + assert(value != NULL); const cfg_t *entry = CFG_find_entry(key, cfg); if (entry != NULL) { void *p = entry->p; @@ -58,6 +56,7 @@ int CFG_update_key (const char *key, const char *value, const cfg_t *cfg) { case Y_KEY: *(int*)p = I_string_to_key(value); break; default: assert(0); // unknown type -> something broken } + //logo("CFG_update_key: [%s] = [%s]\n", key, value); return 1; } else { return 0; @@ -244,9 +243,11 @@ int CFG_update_config (const char *old, const char *new, int n, const cfg_t **cf CFG_close_iterator(); } for (j = 0; j < n; j++) { - i = 0; - while (CFG_write_entry(nf, &cfg[j][i])) { - i++; + if (cfg[j] != NULL) { + i = 0; + while (CFG_write_entry(nf, &cfg[j][i])) { + i++; + } } } fclose(nf);