X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=blobdiff_plain;f=src%2Fconfig.c;h=ed611c3b47772c3525f4ebaa2daf7588501c72fa;hp=885a0e4b8aeee0b998c6d0e270c114b38939235a;hb=49c7dbd3920be7bb57a9ec39779d9695fbe8f0c5;hpb=9e7ef91e1f6a1eb4c65ba52535d92eac3922f20e diff --git a/src/config.c b/src/config.c index 885a0e4..ed611c3 100644 --- a/src/config.c +++ b/src/config.c @@ -209,10 +209,12 @@ static int CFG_write_entry (FILE *f, const cfg_t *entry) { return entry->t == 0 ? 0 : 1; } -int CFG_update_config (const char *old, const char *new, const cfg_t *cfg, const char *msg) { +int CFG_update_config (const char *old, const char *new, int n, const cfg_t **cfg, const char *msg) { 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"); @@ -224,15 +226,21 @@ int CFG_update_config (const char *old, const char *new, const cfg_t *cfg, const } if (CFG_open_iterator(old)) { while (CFG_scan_iterator(key, 64, value, 64)) { - if (CFG_find_entry(key, cfg) == NULL) { + i = 0; + while (i < n && CFG_find_entry(key, cfg[i]) == NULL) { + i++; + } + if (i >= n) { CFG_write_key_value(nf, key, value); } } CFG_close_iterator(); } - int i = 0; - while (CFG_write_entry(nf, &cfg[i])) { - i++; + for (j = 0; j < n; j++) { + i = 0; + while (CFG_write_entry(nf, &cfg[j][i])) { + i++; + } } fclose(nf); }