summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sp_config.c11
-rw-r--r--src/sp_config.h6
2 files changed, 8 insertions, 9 deletions
diff --git a/src/sp_config.c b/src/sp_config.c
index 5431eca..d29247b 100644
--- a/src/sp_config.c
+++ b/src/sp_config.c
@@ -6,7 +6,7 @@
6 6
7 7
8static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) { 8static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) {
9 sp_config_keyword sp_func[] = { 9 static const sp_config_keyword sp_func[] = {
10 {parse_unserialize, SP_TOKEN_UNSERIALIZE_HMAC, &(SPCFG(unserialize))}, 10 {parse_unserialize, SP_TOKEN_UNSERIALIZE_HMAC, &(SPCFG(unserialize))},
11 {parse_enable, SP_TOKEN_HARDEN_RANDOM, &(SPCFG(random).enable)}, 11 {parse_enable, SP_TOKEN_HARDEN_RANDOM, &(SPCFG(random).enable)},
12 {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))}, 12 {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))},
@@ -29,7 +29,7 @@ static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) {
29 return sp_process_rule(parsed_rule, sp_func); 29 return sp_process_rule(parsed_rule, sp_func);
30} 30}
31 31
32zend_result sp_parse_config(const char *filename) { 32zend_result sp_parse_config(const char *const filename) {
33 FILE *fd = fopen(filename, "rb"); 33 FILE *fd = fopen(filename, "rb");
34 if (fd == NULL) { 34 if (fd == NULL) {
35 sp_log_err("config", "Could not open configuration file %s : %s", filename, strerror(errno)); 35 sp_log_err("config", "Could not open configuration file %s : %s", filename, strerror(errno));
@@ -65,7 +65,7 @@ zend_result sp_parse_config(const char *filename) {
65} 65}
66 66
67 67
68zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *config_keywords) { 68zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *const config_keywords) {
69 for (sp_parsed_keyword *kw = parsed_rule; kw->kw; kw++) { 69 for (sp_parsed_keyword *kw = parsed_rule; kw->kw; kw++) {
70 bool found_kw = false; 70 bool found_kw = false;
71 for (const sp_config_keyword *ckw = config_keywords; ckw->func; ckw++) { 71 for (const sp_config_keyword *ckw = config_keywords; ckw->func; ckw++) {
@@ -119,13 +119,12 @@ SP_PARSEKW_FN(parse_list) {
119 CHECK_DUPLICATE_KEYWORD(retval); 119 CHECK_DUPLICATE_KEYWORD(retval);
120 120
121 sp_list_node **list = retval; 121 sp_list_node **list = retval;
122 char *tok, *tmp;
123 122
124 SP_PARSE_ARG(value); 123 SP_PARSE_ARG(value);
125 124
126 tmp = ZSTR_VAL(value); 125 char* tmp = ZSTR_VAL(value);
127 while (1) { 126 while (1) {
128 tok = strsep(&tmp, ","); 127 const char* const tok = strsep(&tmp, ",");
129 if (tok == NULL) { 128 if (tok == NULL) {
130 break; 129 break;
131 } 130 }
diff --git a/src/sp_config.h b/src/sp_config.h
index 87710a0..3d92f2f 100644
--- a/src/sp_config.h
+++ b/src/sp_config.h
@@ -176,7 +176,7 @@ typedef struct {
176 HashTable *entries; // ht of sp_ini_entry 176 HashTable *entries; // ht of sp_ini_entry
177} sp_config_ini; 177} sp_config_ini;
178 178
179#define SP_PARSE_FN_(fname, kwvar) int fname(char *token, sp_parsed_keyword *kwvar, void *retval) 179#define SP_PARSE_FN_(fname, kwvar) int fname(char const *const token, sp_parsed_keyword *kwvar, void *retval)
180#define SP_PARSE_FN(fname) SP_PARSE_FN_(fname, parsed_rule) 180#define SP_PARSE_FN(fname) SP_PARSE_FN_(fname, parsed_rule)
181#define SP_PARSEKW_FN(fname) SP_PARSE_FN_(fname, kw) 181#define SP_PARSEKW_FN(fname) SP_PARSE_FN_(fname, kw)
182 182
@@ -269,9 +269,9 @@ typedef struct {
269 269
270#define SP_TOKEN_LIST "list" 270#define SP_TOKEN_LIST "list"
271 271
272zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *config_keywords); 272zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *const config_keywords);
273 273
274zend_result sp_parse_config(const char *filename); 274zend_result sp_parse_config(const char *const filename);
275 275
276#define SP_PARSE_CHECK_ARG_EXISTS(value) \ 276#define SP_PARSE_CHECK_ARG_EXISTS(value) \
277if (!value) { \ 277if (!value) { \