Mercurial > hg > freeDiameter
comparison extensions/acl_wl/aw_conf.y @ 1354:0dff6a604b0a
acl_wl: add reload support using SIGUSR1
author | Thomas Klausner <tk@giga.or.at> |
---|---|
date | Fri, 17 May 2019 12:59:19 +0200 |
parents | 1c6c8fa622ff |
children | 566bb46cc73f |
comparison
equal
deleted
inserted
replaced
1350:0f226d35501e | 1354:0dff6a604b0a |
---|---|
55 #include <string.h> | 55 #include <string.h> |
56 #include <errno.h> | 56 #include <errno.h> |
57 | 57 |
58 /* Forward declaration */ | 58 /* Forward declaration */ |
59 int yyparse(char * conffile); | 59 int yyparse(char * conffile); |
60 void aw_confrestart(FILE *input_file); | |
60 | 61 |
61 static int fqdn_added = 0; | 62 static int fqdn_added = 0; |
62 | 63 |
63 /* Parse the configuration file */ | 64 /* Parse the configuration file */ |
64 int aw_conf_handle(char * conffile) | 65 int aw_conf_handle(char * conffile) |
72 | 73 |
73 aw_confin = fopen(conffile, "r"); | 74 aw_confin = fopen(conffile, "r"); |
74 if (aw_confin == NULL) { | 75 if (aw_confin == NULL) { |
75 ret = errno; | 76 ret = errno; |
76 fd_log_debug("Unable to open extension configuration file %s for reading: %s", conffile, strerror(ret)); | 77 fd_log_debug("Unable to open extension configuration file %s for reading: %s", conffile, strerror(ret)); |
77 TRACE_DEBUG (INFO, "Error occurred, message logged -- configuration file."); | 78 TRACE_DEBUG (INFO, "acl_wl: Error occurred, message logged -- configuration file."); |
78 return ret; | 79 return ret; |
79 } | 80 } |
80 | 81 |
82 aw_confrestart(aw_confin); | |
81 ret = yyparse(conffile); | 83 ret = yyparse(conffile); |
82 | 84 |
83 fclose(aw_confin); | 85 fclose(aw_confin); |
84 | 86 |
85 if (ret != 0) { | 87 if (ret != 0) { |
86 TRACE_DEBUG (INFO, "Unable to parse the configuration file."); | 88 TRACE_DEBUG (INFO, "acl_wl: Unable to parse the configuration file."); |
87 return EINVAL; | 89 return EINVAL; |
88 } else { | 90 } else { |
89 TRACE_DEBUG(FULL, "Read %d FQDN entries successfully.", fqdn_added); | 91 TRACE_DEBUG(FULL, "acl_wl: Read %d FQDN entries successfully.", fqdn_added); |
90 } | 92 } |
91 | 93 |
92 return 0; | 94 return 0; |
93 } | 95 } |
94 | 96 |
96 int aw_conflex(YYSTYPE *lvalp, YYLTYPE *llocp); | 98 int aw_conflex(YYSTYPE *lvalp, YYLTYPE *llocp); |
97 | 99 |
98 /* Function to report the errors */ | 100 /* Function to report the errors */ |
99 void yyerror (YYLTYPE *ploc, char * conffile, char const *s) | 101 void yyerror (YYLTYPE *ploc, char * conffile, char const *s) |
100 { | 102 { |
101 TRACE_DEBUG(INFO, "Error in configuration parsing"); | 103 TRACE_DEBUG(INFO, "acl_wl: Error in configuration parsing"); |
102 | 104 |
103 if (ploc->first_line != ploc->last_line) | 105 if (ploc->first_line != ploc->last_line) |
104 fd_log_debug("%s:%d.%d-%d.%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s); | 106 fd_log_debug("%s:%d.%d-%d.%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s); |
105 else if (ploc->first_column != ploc->last_column) | 107 else if (ploc->first_column != ploc->last_column) |
106 fd_log_debug("%s:%d.%d-%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_column, s); | 108 fd_log_debug("%s:%d.%d-%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_column, s); |
128 /* The grammar definition */ | 130 /* The grammar definition */ |
129 conffile: /* empty grammar is OK */ | 131 conffile: /* empty grammar is OK */ |
130 | conffile FQDN | 132 | conffile FQDN |
131 { | 133 { |
132 fqdn_added++; | 134 fqdn_added++; |
133 TRACE_DEBUG(FULL, "Added FQDN: %s", $2); | 135 TRACE_DEBUG(FULL, "acl_wl: Added FQDN: %s", $2); |
134 } | 136 } |
135 | conffile LEX_ERROR | 137 | conffile LEX_ERROR |
136 { | 138 { |
137 yyerror(&yylloc, conffile, "An error occurred while parsing the configuration file"); | 139 yyerror(&yylloc, conffile, "acl_wl: An error occurred while parsing the configuration file"); |
138 return EINVAL; | 140 return EINVAL; |
139 } | 141 } |
140 ; | 142 ; |
141 | 143 |