diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-15 00:32:05 -0400 | 
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-04-15 00:32:05 -0400 | 
| commit | 0db784a48f28a240e2a768d2773ba7cd4833a92d (patch) | |
| tree | 2abe3e720af86e19643819b65635dd38f04598c1 /src | |
| parent | ddc6f95e39c48a639171bc4a41dcf7b4d27aec97 (diff) | |
| download | stasis-0db784a48f28a240e2a768d2773ba7cd4833a92d.tar.gz | |
Add ini_setval() function
Diffstat (limited to 'src')
| -rw-r--r-- | src/ini.c | 18 | 
1 files changed, 18 insertions, 0 deletions
| @@ -188,6 +188,24 @@ int ini_data_append(struct INIFILE **ini, char *section_name, char *key, char *v      return 0;  } +int ini_setval(struct INIFILE **ini, unsigned type, char *section_name, char *key, char *value) { +    struct INISection *section = ini_section_search(ini, INI_SEARCH_EXACT, section_name); +    if (section == NULL) { +        return 1; +    } +    if (ini_has_key(*ini, section_name, key)) { +        if (!type) { +            ini_data_append(ini, section_name, key, value); +        } else { +            struct INIData *data = ini_data_get(*ini, section_name, key); +            if (data) { +                guard_free(data->value); +                data->value = strdup(value); +            } +        } +    } +} +  int ini_section_create(struct INIFILE **ini, char *key) {      struct INISection **tmp = realloc((*ini)->section, ((*ini)->section_count + 1) * sizeof(**(*ini)->section));      if (!tmp) { | 
