X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fconfig.c;h=dccf37c813c9708cfb759b8b5dcb2ae962668d14;hb=HEAD;hp=6ebb4255fed453583c5d95455e2652316985b4cb;hpb=1e058b808ddb343442012f01d6fd5692920a3018;p=flatwaifu.git diff --git a/src/config.c b/src/config.c index 6ebb425..78664aa 100644 --- a/src/config.c +++ b/src/config.c @@ -22,7 +22,8 @@ #include "system.h" #include "files.h" #include "input.h" -#include "cp866.h" + +#include "common/cp866.h" static FILE *f; static int ch; @@ -41,9 +42,10 @@ const cfg_t *CFG_find_entry (const char *key, const cfg_t *cfg) { } int CFG_update_key (const char *key, const char *value, const cfg_t *cfg) { + const cfg_t *entry; assert(key != NULL); assert(value != NULL); - const cfg_t *entry = CFG_find_entry(key, cfg); + entry = CFG_find_entry(key, cfg); if (entry != NULL) { void *p = entry->p; switch (entry->t) { @@ -91,12 +93,12 @@ static void CFG_skip_line (void) { } int CFG_scan_iterator (char *key, int keylen, char *value, int valuelen) { + int i; + int found = 0; assert(key != NULL); assert(keylen > 0); assert(value != NULL); assert(valuelen > 0); - int i; - int found = 0; while (feof(f) == 0 && found == 0) { CFG_skip_space(); if (ch == ';') { @@ -141,13 +143,13 @@ void CFG_close_iterator (void) { /* --- reader --- */ int CFG_read_config (const char *name, int n, const cfg_t **cfg) { - assert(name != NULL); - assert(n >= 0); - assert(cfg != NULL); int i; char key[64]; char value[64]; assert(name != NULL); + assert(n >= 0); + assert(cfg != NULL); + assert(name != NULL); if (CFG_open_iterator(name)) { while (CFG_scan_iterator(key, 64, value, 64)) { i = 0; @@ -177,11 +179,12 @@ static void CFG_write_key_value (FILE *f, const char *key, const char *value) { } static int CFG_write_entry (FILE *f, const cfg_t *entry) { - assert(f != NULL); - assert(entry != NULL); char buf[16]; const char *str; - const char *key = entry->cfg; + const char *key; + assert(f != NULL); + assert(entry != NULL); + key = entry->cfg; if (key != NULL) { switch (entry->t) { case Y_BYTE: @@ -217,14 +220,15 @@ static int CFG_write_entry (FILE *f, const cfg_t *entry) { } int CFG_update_config (const char *old, const char *new, int n, const cfg_t **cfg, const char *msg) { + int i, j; + char key[64]; + char value[64]; + FILE *nf; assert(old != NULL); assert(new != NULL); assert(n >= 0); assert(cfg != NULL); - int i, j; - char key[64]; - char value[64]; - FILE *nf = fopen(new, "wb"); + nf = fopen(new, "wb"); if (nf != NULL) { if (msg != NULL) { fwrite("; ", 2, 1, nf);