diff options
author | Mattias Andrée <m@maandree.se> | 2025-03-05 19:26:58 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-03-05 19:26:58 +0100 |
commit | b42c9662303d1a33ebe038d1895c08945cdbd40f (patch) | |
tree | c05b169b1d28e8d42b111290f9181d2cbad1138b /src/config-ini.c | |
parent | Merge redshift.h into common.h (diff) | |
download | redshift-ng-b42c9662303d1a33ebe038d1895c08945cdbd40f.tar.gz redshift-ng-b42c9662303d1a33ebe038d1895c08945cdbd40f.tar.bz2 redshift-ng-b42c9662303d1a33ebe038d1895c08945cdbd40f.tar.xz |
Cleanup and style update (avoid typedef)
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'src/config-ini.c')
-rw-r--r-- | src/config-ini.c | 50 |
1 files changed, 14 insertions, 36 deletions
diff --git a/src/config-ini.c b/src/config-ini.c index 4f12610..b8566b9 100644 --- a/src/config-ini.c +++ b/src/config-ini.c @@ -16,31 +16,9 @@ Copyright (c) 2010-2018 Jon Lund Steffensen <jonlst@gmail.com> */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#ifndef _WIN32 -# include <pwd.h> -#endif - +#include "common.h" #include "config-ini.h" -#ifdef ENABLE_NLS -# include <libintl.h> -# define _(s) gettext(s) -#else -# define _(s) s -#endif - #define MAX_CONFIG_PATH 4096 #define MAX_LINE_LENGTH 512 @@ -173,9 +151,9 @@ open_config_file(const char *filepath) } int -config_ini_init(config_ini_state_t *state, const char *filepath) +config_ini_init(struct config_ini_state *state, const char *filepath) { - config_ini_section_t *section = NULL; + struct config_ini_section *section = NULL; state->sections = NULL; FILE *f = open_config_file(filepath); @@ -215,7 +193,7 @@ config_ini_init(config_ini_state_t *state, const char *filepath) *end = '\0'; /* Create section. */ - section = malloc(sizeof(config_ini_section_t)); + section = malloc(sizeof(struct config_ini_section)); if (section == NULL) { fclose(f); config_ini_free(state); @@ -260,8 +238,8 @@ config_ini_init(config_ini_state_t *state, const char *filepath) } /* Create section. */ - config_ini_setting_t *setting = - malloc(sizeof(config_ini_setting_t)); + struct config_ini_setting *setting = + malloc(sizeof(struct config_ini_setting)); if (setting == NULL) { fclose(f); config_ini_free(state); @@ -303,16 +281,16 @@ config_ini_init(config_ini_state_t *state, const char *filepath) } void -config_ini_free(config_ini_state_t *state) +config_ini_free(struct config_ini_state *state) { - config_ini_section_t *section = state->sections; + struct config_ini_section *section = state->sections; while (section != NULL) { - config_ini_setting_t *setting = section->settings; - config_ini_section_t *section_prev = section; + struct config_ini_setting *setting = section->settings; + struct config_ini_section *section_prev = section; while (setting != NULL) { - config_ini_setting_t *setting_prev = setting; + struct config_ini_setting *setting_prev = setting; free(setting->name); free(setting->value); setting = setting->next; @@ -325,10 +303,10 @@ config_ini_free(config_ini_state_t *state) } } -config_ini_section_t * -config_ini_get_section(config_ini_state_t *state, const char *name) +struct config_ini_section * +config_ini_get_section(struct config_ini_state *state, const char *name) { - config_ini_section_t *section = state->sections; + struct config_ini_section *section = state->sections; while (section != NULL) { if (strcasecmp(section->name, name) == 0) { return section; |