Browse Source

* rename macro

master
Alex 'AdUser' Z 9 years ago
parent
commit
9c4d88e6a6
  1. 12
      src/config.c
  2. 2
      src/config.h

12
src/config.c

@ -2,17 +2,15 @@
#include "config.h" #include "config.h"
#include "log.h" #include "log.h"
#define CONFIGLINE_MAX 256
f2b_config_param_t * f2b_config_param_t *
f2b_config_parse_kv_pair(const char *src) { f2b_config_parse_kv_pair(const char *src) {
f2b_config_param_t *param = NULL; f2b_config_param_t *param = NULL;
char line[CONFIGLINE_MAX] = ""; char line[CONFIG_LINE_MAX] = "";
char *p, *key, *value; char *p, *key, *value;
size_t len; size_t len;
strncpy(line, src, sizeof(line)); strncpy(line, src, sizeof(line));
line[CONFIGLINE_MAX] = '\0'; line[CONFIG_LINE_MAX] = '\0';
/* strip spaces before key */ /* strip spaces before key */
key = line; key = line;
@ -68,11 +66,11 @@ f2b_config_parse_kv_pair(const char *src) {
f2b_config_section_t * f2b_config_section_t *
f2b_config_parse_section(const char *src) { f2b_config_parse_section(const char *src) {
f2b_config_section_t *section = NULL; f2b_config_section_t *section = NULL;
char line[CONFIGLINE_MAX] = ""; char line[CONFIG_LINE_MAX] = "";
char *name, *end; char *name, *end;
strncpy(line, src, sizeof(line)); strncpy(line, src, sizeof(line));
line[CONFIGLINE_MAX] = '\0'; line[CONFIG_LINE_MAX] = '\0';
if ((end = strchr(line, ']')) == NULL) if ((end = strchr(line, ']')) == NULL)
return NULL; return NULL;
@ -144,7 +142,7 @@ f2b_config_load(const char *path) {
f2b_config_param_t *param = NULL; /* temp pointer */ f2b_config_param_t *param = NULL; /* temp pointer */
FILE *f = NULL; /* config file fd */ FILE *f = NULL; /* config file fd */
char *p; /* temp pointer */ char *p; /* temp pointer */
char line[CONFIGLINE_MAX] = ""; /* last read line */ char line[CONFIG_LINE_MAX] = ""; /* last read line */
bool skip_section = false; /* if set - skip parameters unless next section */ bool skip_section = false; /* if set - skip parameters unless next section */
size_t linenum = 0; /* current line number in config */ size_t linenum = 0; /* current line number in config */

2
src/config.h

@ -1,6 +1,8 @@
#ifndef CONFIG_H_ #ifndef CONFIG_H_
#define CONFIG_H_ #define CONFIG_H_
#define CONFIG_LINE_MAX 256
#define CONFIG_KEY_MAX 32 #define CONFIG_KEY_MAX 32
#define CONFIG_VAL_MAX 192 #define CONFIG_VAL_MAX 192

Loading…
Cancel
Save