Skip to content
Snippets Groups Projects
Commit 781bfe50 authored by dx's avatar dx Committed by schneider
Browse files

style(config): minor variable/constant name changes

In preparation for next commit
parent a7f4e247
Branches
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#define CONFIG_MAX_LINE_LENGTH 80 #define MAX_LINE_LENGTH 80
enum OptionType { enum OptionType {
OptionType_Boolean, OptionType_Boolean,
...@@ -131,7 +131,7 @@ static bool set_string(struct config_option *opt, const char *value) ...@@ -131,7 +131,7 @@ static bool set_string(struct config_option *opt, const char *value)
return true; return true;
} }
static void configure(const char *key, const char *value, int lineNumber) static void configure(const char *key, const char *value, int line_number)
{ {
struct config_option *opt = findOption(key); struct config_option *opt = findOption(key);
if (!opt) { if (!opt) {
...@@ -139,7 +139,7 @@ static void configure(const char *key, const char *value, int lineNumber) ...@@ -139,7 +139,7 @@ static void configure(const char *key, const char *value, int lineNumber)
LOG_WARN( LOG_WARN(
"card10.cfg", "card10.cfg",
"line %d: ignoring unknown option '%s'", "line %d: ignoring unknown option '%s'",
lineNumber, line_number,
key key
); );
return; return;
...@@ -165,14 +165,14 @@ static void configure(const char *key, const char *value, int lineNumber) ...@@ -165,14 +165,14 @@ static void configure(const char *key, const char *value, int lineNumber)
LOG_WARN( LOG_WARN(
"card10.cfg", "card10.cfg",
"line %d: ignoring invalid value '%s' for option '%s'", "line %d: ignoring invalid value '%s' for option '%s'",
lineNumber, line_number,
value, value,
key key
); );
} }
} }
static void doline(char *line, char *eol, int lineNumber) static void doline(char *line, char *eol, int line_number)
{ {
//skip leading whitespace //skip leading whitespace
while (*line && isspace((int)*line)) while (*line && isspace((int)*line))
...@@ -190,7 +190,7 @@ static void doline(char *line, char *eol, int lineNumber) ...@@ -190,7 +190,7 @@ static void doline(char *line, char *eol, int lineNumber)
LOG_WARN( LOG_WARN(
"card10.cfg", "card10.cfg",
"line %d (%s): syntax error", "line %d (%s): syntax error",
lineNumber, line_number,
elide(line) elide(line)
); );
} }
...@@ -203,7 +203,7 @@ static void doline(char *line, char *eol, int lineNumber) ...@@ -203,7 +203,7 @@ static void doline(char *line, char *eol, int lineNumber)
--e_key; --e_key;
e_key[1] = '\0'; e_key[1] = '\0';
if (*key == '\0') { if (*key == '\0') {
LOG_WARN("card10.cfg", "line %d: empty key", lineNumber); LOG_WARN("card10.cfg", "line %d: empty key", line_number);
return; return;
} }
...@@ -220,13 +220,13 @@ static void doline(char *line, char *eol, int lineNumber) ...@@ -220,13 +220,13 @@ static void doline(char *line, char *eol, int lineNumber)
LOG_WARN( LOG_WARN(
"card10.cfg", "card10.cfg",
"line %d: empty value for option '%s'", "line %d: empty value for option '%s'",
lineNumber, line_number,
key key
); );
return; return;
} }
configure(key, value, lineNumber); configure(key, value, line_number);
} }
bool config_get_boolean(enum EpicConfigOption option) bool config_get_boolean(enum EpicConfigOption option)
...@@ -270,12 +270,12 @@ void load_config(void) ...@@ -270,12 +270,12 @@ void load_config(void)
); );
return; return;
} }
char buf[CONFIG_MAX_LINE_LENGTH + 1]; char buf[MAX_LINE_LENGTH + 1];
int lineNumber = 0; int line_number = 0;
int nread; int nread;
do { do {
nread = epic_file_read(fd, buf, CONFIG_MAX_LINE_LENGTH); nread = epic_file_read(fd, buf, MAX_LINE_LENGTH);
if (nread < CONFIG_MAX_LINE_LENGTH) { if (nread < MAX_LINE_LENGTH) {
//add fake EOL to ensure termination //add fake EOL to ensure termination
buf[nread++] = '\n'; buf[nread++] = '\n';
} }
...@@ -288,10 +288,10 @@ void load_config(void) ...@@ -288,10 +288,10 @@ void load_config(void)
//line points one character past the las (if any) '\n' hence '- 1' //line points one character past the las (if any) '\n' hence '- 1'
last_eol = line - buf - 1; last_eol = line - buf - 1;
eol = strchr(line, '\n'); eol = strchr(line, '\n');
++lineNumber; ++line_number;
if (eol) { if (eol) {
*eol = '\0'; *eol = '\0';
doline(line, eol, lineNumber); doline(line, eol, line_number);
line = eol + 1; line = eol + 1;
continue; continue;
} }
...@@ -300,7 +300,7 @@ void load_config(void) ...@@ -300,7 +300,7 @@ void load_config(void)
LOG_WARN( LOG_WARN(
"card10.cfg", "card10.cfg",
"line:%d: too long - aborting", "line:%d: too long - aborting",
lineNumber line_number
); );
return; return;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment