11/**
22 * \file configuration.c
3- * \author Lukas Hutak <[email protected] > 3+ * \author Tomas Cejka <[email protected] > 4+ * \author Jaroslav Hlavac <[email protected] > 45 * \brief Configuration parser (source file)
56 */
67
3940 */
4041
4142#include "configuration.h"
42- #include "lnfstore .h"
43+ #include "unirecplugin .h"
4344
4445#include <stdlib.h>
4546#include <inttypes.h>
@@ -130,44 +131,44 @@ configuration_validate(ipx_ctx_t *ctx, const struct conf_params *cfg)
130131{
131132 int ret_code = IPX_OK ;
132133
133- if (!cfg -> profiles .en && !cfg -> files .path ) {
134- IPX_CTX_ERROR (ctx , "Storage path is not set." , '\0' );
135- ret_code = IPX_ERR_FORMAT ;
136- }
137-
138- if (!cfg -> files .suffix ) {
139- IPX_CTX_ERROR (ctx , "File suffix is not set." , '\0' );
140- ret_code = IPX_ERR_FORMAT ;
141- }
142-
143- if (!cfg -> file_lnf .prefix ) {
144- IPX_CTX_ERROR (ctx , "LNF file prefix is not set." , '\0' );
145- ret_code = IPX_ERR_FORMAT ;
146- }
147-
148- if (cfg -> file_index .en ) {
149- if (!cfg -> file_index .prefix ) {
150- IPX_CTX_ERROR (ctx , "Index file prefix is not set." , '\0' );
151- ret_code = IPX_ERR_FORMAT ;
152- }
153-
154- if (cfg -> file_index .est_cnt == 0 ) {
155- IPX_CTX_ERROR (ctx , "Estimated item count in Bloom Filter Index must be greater "
156- "than 0." , '\0' );
157- ret_code = IPX_ERR_FORMAT ;
158- }
159-
160- // Check output prefixes
161- if (strcmp (cfg -> file_index .prefix , cfg -> file_lnf .prefix ) == 0 ) {
162- IPX_CTX_ERROR (ctx , "The same file prefix for LNF and Index file is not allowed" );
163- ret_code = IPX_ERR_FORMAT ;
164- }
165- }
166-
167- if (cfg -> window .size == 0 ) {
168- IPX_CTX_ERROR (ctx , "Window size must be greater than 0." , '\0' );
169- ret_code = IPX_ERR_FORMAT ;
170- }
134+ // if (!cfg->profiles.en && !cfg->files.path) {
135+ // IPX_CTX_ERROR(ctx, "Storage path is not set.", '\0');
136+ // ret_code = IPX_ERR_FORMAT;
137+ // }
138+
139+ // if (!cfg->files.suffix) {
140+ // IPX_CTX_ERROR(ctx, "File suffix is not set.", '\0');
141+ // ret_code = IPX_ERR_FORMAT;
142+ // }
143+
144+ // if (!cfg->file_lnf.prefix) {
145+ // IPX_CTX_ERROR(ctx, "LNF file prefix is not set.", '\0');
146+ // ret_code = IPX_ERR_FORMAT;
147+ // }
148+
149+ // if (cfg->file_index.en) {
150+ // if (!cfg->file_index.prefix) {
151+ // IPX_CTX_ERROR(ctx, "Index file prefix is not set.", '\0');
152+ // ret_code = IPX_ERR_FORMAT;
153+ // }
154+
155+ // if (cfg->file_index.est_cnt == 0) {
156+ // IPX_CTX_ERROR(ctx, "Estimated item count in Bloom Filter Index must be greater "
157+ // "than 0.", '\0');
158+ // ret_code = IPX_ERR_FORMAT;
159+ // }
160+
161+ // // Check output prefixes
162+ // if (strcmp(cfg->file_index.prefix, cfg->file_lnf.prefix) == 0) {
163+ // IPX_CTX_ERROR(ctx, "The same file prefix for LNF and Index file is not allowed");
164+ // ret_code = IPX_ERR_FORMAT;
165+ // }
166+ // }
167+
168+ // if (cfg->window.size == 0) {
169+ // IPX_CTX_ERROR(ctx, "Window size must be greater than 0.", '\0');
170+ // ret_code = IPX_ERR_FORMAT;
171+ // }
171172
172173 return ret_code ;
173174}
@@ -183,37 +184,37 @@ static int
183184configuration_set_defaults (ipx_ctx_t * ctx , struct conf_params * cnf )
184185{
185186 cnf -> ctx = ctx ;
186- cnf -> profiles .en = false; // Disabled by default
187+ // cnf->profiles.en = false; // Disabled by default
187188
188189 // Dump interval
189- cnf -> window .align = true;
190- cnf -> window .size = WINDOW_SIZE ;
190+ // cnf->window.align = true;
191+ // cnf->window.size = WINDOW_SIZE;
191192
192193 // Files (common)
193- cnf -> files .suffix = strdup (SUFFIX_MASK );
194- if (!cnf -> files .suffix ) {
195- IPX_CTX_ERROR (ctx , "Unable to allocate memory (%s:%d)" , __FILE__ , __LINE__ );
196- return 1 ;
197- }
194+ // cnf->files.suffix = strdup(SUFFIX_MASK);
195+ // if (!cnf->files.suffix) {
196+ // IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
197+ // return 1;
198+ // }
198199
199200 // LNF file
200- cnf -> file_lnf .compress = false;
201- cnf -> file_lnf .prefix = strdup (LNF_FILE_PREFIX );
202- if (!cnf -> file_lnf .prefix ) {
203- IPX_CTX_ERROR (ctx , "Unable to allocate memory (%s:%d)" , __FILE__ , __LINE__ );
204- return 1 ;
205- }
206-
207- // Index file
208- cnf -> file_index .en = false;
209- cnf -> file_index .autosize = true;
210- cnf -> file_index .est_cnt = BF_DEFAULT_ITEM_CNT_EST ;
211- cnf -> file_index .fp_prob = BF_DEFAULT_FP_PROB ;
212- cnf -> file_index .prefix = strdup (BF_FILE_PREFIX );
213- if (!cnf -> file_index .prefix ) {
214- IPX_CTX_ERROR (ctx , "Unable to allocate memory (%s:%d)" , __FILE__ , __LINE__ );
215- return 1 ;
216- }
201+ // cnf->file_lnf.compress = false;
202+ // cnf->file_lnf.prefix = strdup(LNF_FILE_PREFIX);
203+ // if (!cnf->file_lnf.prefix) {
204+ // IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
205+ // return 1;
206+ // }
207+
208+ //// Index file
209+ // cnf->file_index.en = false;
210+ // cnf->file_index.autosize = true;
211+ // cnf->file_index.est_cnt = BF_DEFAULT_ITEM_CNT_EST;
212+ // cnf->file_index.fp_prob = BF_DEFAULT_FP_PROB;
213+ // cnf->file_index.prefix = strdup(BF_FILE_PREFIX);
214+ // if (!cnf->file_index.prefix) {
215+ // IPX_CTX_ERROR(ctx, "Unable to allocate memory (%s:%d)", __FILE__, __LINE__);
216+ // return 1;
217+ // }
217218
218219 return 0 ;
219220}
@@ -238,11 +239,11 @@ configuration_parse_dump(ipx_ctx_t *ctx, fds_xml_ctx_t *dump, struct conf_params
238239 return IPX_ERR_DENIED ;
239240 }
240241
241- cnf -> window .size = (uint32_t ) content -> val_uint ;
242+ // cnf->window.size = (uint32_t) content->val_uint;
242243 break ;
243244 case DUMP_ALIGN :
244245 assert (content -> type == FDS_OPTS_T_BOOL );
245- cnf -> window .align = content -> val_bool ;
246+ // cnf->window.align = content->val_bool;
246247 break ;
247248 default :
248249 assert (false);
@@ -269,19 +270,19 @@ configuration_parse_idx(ipx_ctx_t *ctx, fds_xml_ctx_t *idx, struct conf_params *
269270 switch (content -> id ) {
270271 case IDX_ENABLE :
271272 assert (content -> type == FDS_OPTS_T_BOOL );
272- cnf -> file_index .en = content -> val_bool ;
273+ // cnf->file_index.en = content->val_bool;
273274 break ;
274275 case IDX_AUTOSIZE :
275276 assert (content -> type == FDS_OPTS_T_BOOL );
276- cnf -> file_index .autosize = content -> val_bool ;
277+ // cnf->file_index.autosize = content->val_bool;
277278 break ;
278279 case IDX_COUNT :
279280 assert (content -> type == FDS_OPTS_T_UINT );
280- cnf -> file_index .est_cnt = content -> val_uint ;
281+ // cnf->file_index.est_cnt = content->val_uint;
281282 break ;
282283 case IDX_PROB :
283284 assert (content -> type == FDS_OPTS_T_DOUBLE );
284- cnf -> file_index .fp_prob = content -> val_double ; // checked later in validator
285+ // cnf->file_index.fp_prob = content->val_double; // checked later in validator
285286 break ;
286287 default :
287288 assert (false);
@@ -306,22 +307,22 @@ configuration_parse_root(ipx_ctx_t *ctx, fds_xml_ctx_t *root, struct conf_params
306307 switch (content -> id ) {
307308 case NODE_STORAGE :
308309 assert (content -> type == FDS_OPTS_T_STRING );
309- cnf -> files .path = utils_path_preprocessor ( content -> ptr_string ) ;
310- if (!cnf -> files .path ) {
311- const char * err_str ;
312- ipx_strerror (errno , err_str );
313- IPX_CTX_ERROR (ctx , "Failed to process the <storagePath> expression: %s" , err_str );
314- return IPX_ERR_DENIED ;
315- }
310+ // cnf->files.path = content->ptr_string;
311+ // if (!cnf->files.path) {
312+ // const char *err_str;
313+ // ipx_strerror(errno, err_str);
314+ // IPX_CTX_ERROR(ctx, "Failed to process the <storagePath> expression: %s", err_str);
315+ // return IPX_ERR_DENIED;
316+ // }
316317 break ;
317318 case NODE_ID_FIELD :
318319 assert (content -> type == FDS_OPTS_T_STRING );
319- free (cnf -> file_lnf .ident );
320- cnf -> file_lnf .ident = strdup (content -> ptr_string );
320+ // free(cnf->file_lnf.ident);
321+ // cnf->file_lnf.ident = strdup(content->ptr_string);
321322 break ;
322323 case NODE_COMPRESS :
323324 assert (content -> type == FDS_OPTS_T_BOOL );
324- cnf -> file_lnf .compress = content -> val_bool ;
325+ // cnf->file_lnf.compress = content->val_bool;
325326 break ;
326327 case NODE_DUMP :
327328 assert (content -> type == FDS_OPTS_T_CONTEXT );
@@ -405,29 +406,26 @@ configuration_parse(ipx_ctx_t *ctx, const char *params)
405406}
406407
407408void
408- configuration_free (struct conf_params * config )
409+ configuration_free (struct conf_params * c )
409410{
410- if (!config ) {
411+ if (!c ) {
411412 return ;
412413 }
413414
414- free (config -> files .path );
415+ free (c -> trap_ifc_socket );
416+ c -> trap_ifc_socket = NULL ;
415417
416- if (config -> files .suffix ) {
417- free (config -> files .suffix );
418- }
418+ free (c -> trap_ifc_timeout );
419+ c -> trap_ifc_timeout = NULL ;
419420
420- if (config -> file_lnf .prefix ) {
421- free (config -> file_lnf .prefix );
422- }
421+ free (c -> trap_ifc_autoflush );
422+ c -> trap_ifc_autoflush = NULL ;
423423
424- if (config -> file_lnf .ident ) {
425- free (config -> file_lnf .ident );
426- }
424+ free (c -> trap_ifc_bufferswitch );
425+ c -> trap_ifc_bufferswitch = NULL ;
427426
428- if (config -> file_index .prefix ) {
429- free (config -> file_index .prefix );
430- }
427+ free (c -> unirec_format );
428+ c -> unirec_format = NULL ;
431429
432- free (config );
430+ free (c );
433431}
0 commit comments