diff options
-rw-r--r-- | common/elapi/elapi_event.c | 60 | ||||
-rw-r--r-- | common/elapi/elapi_event.h | 12 | ||||
-rw-r--r-- | common/elapi/elapi_internal.c | 2 | ||||
-rw-r--r-- | common/elapi/elapi_log.c | 62 | ||||
-rw-r--r-- | common/elapi/elapi_log.h | 4 | ||||
-rw-r--r-- | common/elapi/elapi_priv.h | 12 | ||||
-rw-r--r-- | common/elapi/elapi_test/elapi_ut.c | 74 |
7 files changed, 113 insertions, 113 deletions
diff --git a/common/elapi/elapi_event.c b/common/elapi/elapi_event.c index e1baf424..a517babd 100644 --- a/common/elapi/elapi_event.c +++ b/common/elapi/elapi_event.c @@ -777,90 +777,90 @@ static int process_arg_list(struct collection_item *col, /*****************************************************************************/ /* Create event template */ -int elapi_create_event_template_with_vargs(struct collection_item **template, - unsigned base, - va_list args) +int elapi_create_event_tplt_with_vargs(struct collection_item **tpl, + unsigned base, + va_list args) { int error = EOK; - struct collection_item *tpl = NULL; + struct collection_item *new_tpl = NULL; - TRACE_FLOW_STRING("elapi_create_event_template_with_vargs", "Entry"); + TRACE_FLOW_STRING("elapi_create_event_tplt_with_vargs", "Entry"); - if (template == NULL ) { + if (tpl == NULL ) { TRACE_ERROR_STRING("Template storage must be provided", ""); return EINVAL; } - *template = NULL; + *tpl = NULL; /* Create collection */ - error = col_create_collection(&tpl, E_TEMPLATE_NAME, COL_CLASS_ELAPI_TEMPLATE); + error = col_create_collection(&new_tpl, E_TEMPLATE_NAME, COL_CLASS_ELAPI_TEMPLATE); if (error) { TRACE_ERROR_NUMBER("Failed to create collection. Error", error); return error; } /* Add elements using base mask */ - error = add_base_elements(tpl, base); + error = add_base_elements(new_tpl, base); if (error) { TRACE_ERROR_NUMBER("Failed to add base elements. Error", error); - col_destroy_collection(tpl); + col_destroy_collection(new_tpl); return error; } /* Process variable argument list */ - error = process_arg_list(tpl, args); + error = process_arg_list(new_tpl, args); if (error) { TRACE_ERROR_NUMBER("Failed to process argument list. Error", error); - col_destroy_collection(tpl); + col_destroy_collection(new_tpl); return error; } - *template = tpl; + *tpl = new_tpl; - TRACE_FLOW_STRING("elapi_create_event_template_with_vargs", "Exit"); + TRACE_FLOW_STRING("elapi_create_event_tplt_with_vargs", "Exit"); return error; } /* Create event template */ -int elapi_create_event_template(struct collection_item **template, - unsigned base, ...) +int elapi_create_event_tplt(struct collection_item **tpl, + unsigned base, ...) { int error = EOK; va_list args; - TRACE_FLOW_STRING("elapi_create_event_template", "Entry"); + TRACE_FLOW_STRING("elapi_create_event_tplt", "Entry"); /* Process varible arguments */ va_start(args, base); /* Create template using arguments */ - error = elapi_create_event_template_with_vargs(template, - base, - args); + error = elapi_create_event_tplt_with_vargs(tpl, + base, + args); va_end(args); - TRACE_FLOW_STRING("elapi_create_event_template", "Exit"); + TRACE_FLOW_STRING("elapi_create_event_tplt", "Exit"); return error; } /* Function to destroy event template */ -void elapi_destroy_event_template(struct collection_item *template) +void elapi_destroy_event_tplt(struct collection_item *tpl) { - TRACE_FLOW_STRING("elapi_destroy_event_template", "Entry"); + TRACE_FLOW_STRING("elapi_destroy_event_tplt", "Entry"); - col_destroy_collection(template); + col_destroy_collection(tpl); - TRACE_FLOW_STRING("elapi_destroy_event_template", "Exit"); + TRACE_FLOW_STRING("elapi_destroy_event_tplt", "Exit"); } /* Create event from template, colection and arguments */ int elapi_create_event_with_vargs(struct collection_item **event, - struct collection_item *template, + struct collection_item *tpl, struct collection_item *collection, int mode, va_list args) { @@ -887,9 +887,9 @@ int elapi_create_event_with_vargs(struct collection_item **event, /* Add elements from the template */ /* Check for template */ - if (template != NULL) { + if (tpl != NULL) { error = col_add_collection_to_collection(evt, NULL, NULL, - (struct collection_item *)template, + (struct collection_item *)tpl, COL_ADD_MODE_FLAT); if (error) { TRACE_ERROR_NUMBER("Failed to add elements from the template. Error", error); @@ -934,7 +934,7 @@ int elapi_create_event_with_vargs(struct collection_item **event, /* Create event a wrapper around a function with arg list */ int elapi_create_event(struct collection_item **event, - struct collection_item *template, + struct collection_item *tpl, struct collection_item *collection, int mode, ...) { @@ -946,7 +946,7 @@ int elapi_create_event(struct collection_item **event, va_start(args, mode); error = elapi_create_event_with_vargs(event, - template, + tpl, collection, mode, args); diff --git a/common/elapi/elapi_event.h b/common/elapi/elapi_event.h index 3e52dfdb..c83eec8b 100644 --- a/common/elapi/elapi_event.h +++ b/common/elapi/elapi_event.h @@ -128,11 +128,11 @@ * The list of key value pairs MUST be terminated by special * argument E_EOARG. */ -int elapi_create_event_template(struct collection_item **template, - unsigned base, ...); +int elapi_create_event_tplt(struct collection_item **tpl, + unsigned base, ...); /* Function to destroy event template */ -void elapi_destroy_event_template(struct collection_item *template); +void elapi_destroy_event_tplt(struct collection_item *tpl); /***************************************************************************/ /* Creates a new event using template (must be provided) @@ -143,7 +143,7 @@ void elapi_destroy_event_template(struct collection_item *template); * See example for details about format specification. */ int elapi_create_event(struct collection_item **event, - struct collection_item *template, + struct collection_item *tpl, struct collection_item *collection, int mode, ...); @@ -163,10 +163,10 @@ void elapi_destroy_event(struct collection_item *event); /* TREAD UNSAFE ELAPI EVENT API - for simple use cases */ /***************************************************************************/ /* Initializes default internal template */ -int elapi_set_default_template(unsigned base, ...); +int elapi_set_default_tplt(unsigned base, ...); /* Retrieve default template */ -int elapi_get_default_template(struct collection_item **template); +int elapi_get_default_tplt(struct collection_item **tpl); /* This function will use internal default template. diff --git a/common/elapi/elapi_internal.c b/common/elapi/elapi_internal.c index d80725b2..fbbc0151 100644 --- a/common/elapi/elapi_internal.c +++ b/common/elapi/elapi_internal.c @@ -728,7 +728,7 @@ void elapi_print_dispatcher(struct elapi_dispatcher *handle) printf("\n\nConfig collection:\n\n"); if (handle->ini_config) col_debug_collection(handle->ini_config, COL_TRAVERSE_DEFAULT); printf("\nDefault template:\n\n"); - if (handle->default_template) col_debug_collection(handle->default_template, COL_TRAVERSE_DEFAULT); + if (handle->default_tpl) col_debug_collection(handle->default_tpl, COL_TRAVERSE_DEFAULT); printf("\n\nDeep target inspection:\n\n"); if (handle->target_list) { diff --git a/common/elapi/elapi_log.c b/common/elapi/elapi_log.c index ee4c1a0c..22a375b4 100644 --- a/common/elapi/elapi_log.c +++ b/common/elapi/elapi_log.c @@ -55,7 +55,7 @@ static int elapi_close_registered = 0; /* Internal function to log message using args */ static int elapi_dsp_msg_with_vargs(uint32_t target, struct elapi_dispatcher *dispatcher, - struct collection_item *template, + struct collection_item *tpl, va_list args) { int error = EOK; @@ -70,7 +70,7 @@ static int elapi_dsp_msg_with_vargs(uint32_t target, /* Create event */ error = elapi_create_event_with_vargs(&event, - template, + tpl, NULL, 0, args); @@ -395,7 +395,7 @@ void elapi_destroy_dispatcher(struct elapi_dispatcher *dispatcher) if (dispatcher) { TRACE_INFO_STRING("Deleting template if any...", ""); - col_destroy_collection(dispatcher->default_template); + col_destroy_collection(dispatcher->default_tpl); if (dispatcher->target_list) { TRACE_INFO_STRING("Closing target list.", ""); @@ -479,13 +479,13 @@ int elapi_dsp_log(uint32_t target, } /* Initializes default internal template */ -int elapi_set_default_template(unsigned base, ...) +int elapi_set_default_tplt(unsigned base, ...) { int error = EOK; struct collection_item *tpl = NULL; va_list args; - TRACE_FLOW_STRING("elapi_set_default_template", "Entry"); + TRACE_FLOW_STRING("elapi_set_default_tplt", "Entry"); if (global_dispatcher == NULL) { error = elapi_init(NULL, NULL); @@ -496,16 +496,16 @@ int elapi_set_default_template(unsigned base, ...) } /* Clean previous instance of the default template */ - elapi_destroy_event_template(global_dispatcher->default_template); - global_dispatcher->default_template = NULL; + elapi_destroy_event_tplt(global_dispatcher->default_tpl); + global_dispatcher->default_tpl = NULL; /* Process varible arguments */ va_start(args, base); /* Create template out of base and args */ - error = elapi_create_event_template_with_vargs(&tpl, - base, - args); + error = elapi_create_event_tplt_with_vargs(&tpl, + base, + args); va_end(args); if (error) { @@ -513,32 +513,32 @@ int elapi_set_default_template(unsigned base, ...) return error; } - global_dispatcher->default_template = tpl; + global_dispatcher->default_tpl = tpl; - TRACE_FLOW_STRING("elapi_set_default_template", "Exit"); + TRACE_FLOW_STRING("elapi_set_default_tplt", "Exit"); return error; } /* There is one default template associated with the dispatcher */ -int elapi_get_default_template(struct collection_item **template) +int elapi_get_default_tplt(struct collection_item **tpl) { int error = EOK; - TRACE_FLOW_STRING("elapi_get_default_template", "Entry"); + TRACE_FLOW_STRING("elapi_get_default_tplt", "Entry"); if ((global_dispatcher == NULL) || - (global_dispatcher->default_template == NULL)) { + (global_dispatcher->default_tpl == NULL)) { TRACE_INFO_STRING("Default template does not exit", ""); - error = elapi_set_default_template(E_BASE_DEFV1, E_EOARG); + error = elapi_set_default_tplt(E_BASE_DEFV1, E_EOARG); if (error) { TRACE_ERROR_NUMBER("Set default template returned error", error); return error; } } - *template = global_dispatcher->default_template; - TRACE_FLOW_NUMBER("elapi_get_default_template. Exit returning", error); + *tpl = global_dispatcher->default_tpl; + TRACE_FLOW_NUMBER("elapi_get_default_tplt. Exit returning", error); return error; } @@ -547,7 +547,7 @@ int elapi_get_default_template(struct collection_item **template) /* Function to log raw key value pairs without creating an event */ int elapi_dsp_msg(uint32_t target, struct elapi_dispatcher *dispatcher, - struct collection_item *template, + struct collection_item *tpl, ...) { int error = EOK; @@ -555,9 +555,9 @@ int elapi_dsp_msg(uint32_t target, TRACE_FLOW_STRING("elapi_dsp_msg", "Entry"); - va_start(args, template); + va_start(args, tpl); - error = elapi_dsp_msg_with_vargs(target, dispatcher, template, args); + error = elapi_dsp_msg_with_vargs(target, dispatcher, tpl, args); va_end(args); @@ -620,7 +620,7 @@ int elapi_create_simple_event(struct collection_item **event, ...) int error = EOK; struct collection_item *evt = NULL; va_list args; - struct collection_item *template = NULL; + struct collection_item *tpl = NULL; TRACE_FLOW_STRING("elapi_create_simple_event", "Entry"); @@ -633,7 +633,7 @@ int elapi_create_simple_event(struct collection_item **event, ...) *event = NULL; /* Get default template */ - error = elapi_get_default_template(&template); + error = elapi_get_default_tplt(&tpl); if (error) { TRACE_ERROR_NUMBER("Failed to get default template. Error", error); return error; @@ -643,7 +643,7 @@ int elapi_create_simple_event(struct collection_item **event, ...) /* Create event */ error = elapi_create_event_with_vargs(&evt, - template, + tpl, NULL, 0, args); @@ -663,29 +663,29 @@ int elapi_create_simple_event(struct collection_item **event, ...) } /* Log key value pairs */ -int elapi_msg(uint32_t target, struct collection_item *template, ...) +int elapi_msg(uint32_t target, struct collection_item *tpl, ...) { int error = EOK; va_list args; - struct collection_item *use_template; + struct collection_item *use_tpl; TRACE_FLOW_STRING("elapi_msg", "Entry"); - if (!template) { + if (!tpl) { /* Get default template */ - error = elapi_get_default_template(&use_template); + error = elapi_get_default_tplt(&use_tpl); if (error) { TRACE_ERROR_NUMBER("Failed to get default template. Error", error); return error; } } - else use_template = template; + else use_tpl = tpl; - va_start(args, template); + va_start(args, tpl); error = elapi_dsp_msg_with_vargs(target, global_dispatcher, - use_template, + use_tpl, args); va_end(args); diff --git a/common/elapi/elapi_log.h b/common/elapi/elapi_log.h index 5417caa7..70841803 100644 --- a/common/elapi/elapi_log.h +++ b/common/elapi/elapi_log.h @@ -82,7 +82,7 @@ int elapi_dsp_log(uint32_t target, /* Function to log raw key value pairs without creating an event */ int elapi_dsp_msg(uint32_t target, struct elapi_dispatcher *dispatcher, - struct collection_item *template, + struct collection_item *tpl, ...); /********** Advanced dispatcher management functions **********/ @@ -137,7 +137,7 @@ int elapi_init(const char *appname, const char *config_path); /* Log key value pairs */ int elapi_msg(uint32_t target, - struct collection_item *template, ...); + struct collection_item *tpl, ...); /* Log event */ int elapi_log(uint32_t target, diff --git a/common/elapi/elapi_priv.h b/common/elapi/elapi_priv.h index e7480f90..15a03074 100644 --- a/common/elapi/elapi_priv.h +++ b/common/elapi/elapi_priv.h @@ -38,7 +38,7 @@ #define COL_CLASS_ELAPI_RES_ITEM COL_CLASS_ELAPI_BASE + 5 /* Names for the collections */ -#define E_TEMPLATE_NAME "template" +#define E_TEMPLATE_NAME "tplt" #define E_EVENT_NAME "event" /* Constants used in INI file and in @@ -110,7 +110,7 @@ struct elapi_dispatcher { /* Items to resolve */ struct collection_iterator *resolve_list; /* Default event template */ - struct collection_item *default_template; + struct collection_item *default_tpl; /* Async processing related data */ struct elapi_async_ctx *async_ctx; }; @@ -236,14 +236,14 @@ int elapi_init_resolve_list(struct collection_iterator **list); /* Function to create event using arg list */ int elapi_create_event_with_vargs(struct collection_item **event, - struct collection_item *template, + struct collection_item *tpl, struct collection_item *collection, int mode, va_list args); /* Function to create event template using arg list */ -int elapi_create_event_template_with_vargs(struct collection_item **template, - unsigned base, - va_list args); +int elapi_create_event_tplt_with_vargs(struct collection_item **tpl, + unsigned base, + va_list args); /* Sink handler function */ int elapi_sink_cb(const char *sink, diff --git a/common/elapi/elapi_test/elapi_ut.c b/common/elapi/elapi_test/elapi_ut.c index 92c3aa31..9097a438 100644 --- a/common/elapi/elapi_test/elapi_ut.c +++ b/common/elapi/elapi_test/elapi_ut.c @@ -50,20 +50,20 @@ int elapi_init_test(void) return 0; } -int elapi_get_default_template_test(void) +int elapi_get_default_tplt_test(void) { - struct collection_item *template; + struct collection_item *tpl; int error = 0; - printf("elapi_get_default_template_test test START:\n"); + printf("elapi_get_default_tplt_test test START:\n"); - error = elapi_get_default_template(&template); + error = elapi_get_default_tplt(&tpl); if (error) { - printf("elapi_get_default_template failed: %d", error); + printf("elapi_get_default_tplt failed: %d", error); return error; } - printf("elapi_get_default_template test success!\n"); + printf("elapi_get_default_tplt test success!\n"); return 0; } @@ -75,7 +75,7 @@ int simple_event_test(void) printf("Simple test START:\n"); - error = elapi_set_default_template( + error = elapi_set_default_tplt( E_BASE_DEFV1 | E_BASE_HOSTEXT /* FIXME Ticket #207 */, "%n( bin )", bin, 8, " %sb( logical1 )", "false", @@ -165,7 +165,7 @@ int simple_event_test(void) int complex_event_test(void) { int error = 0; - struct collection_item *template = NULL; + struct collection_item *tpl = NULL; struct collection_item *event = NULL, *event_copy = NULL; char bin[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; struct collection_item *col = NULL; @@ -173,8 +173,8 @@ int complex_event_test(void) printf("Complex test START:\n"); - error = elapi_create_event_template( - &template, + error = elapi_create_event_tplt( + &tpl, E_BASE_DEFV1 | E_BASE_HOSTEXT, "%lu(long_unsigned_number)", 123456789, "%s(just_string)", "string", @@ -193,7 +193,7 @@ int complex_event_test(void) error = elapi_create_event( &event, - template, + tpl, NULL, 0, " %db(evt_logical)", 0, @@ -204,11 +204,11 @@ int complex_event_test(void) if (error) { printf("Failed to set create template %d\n", error); - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); return error; } - col_debug_collection(template, COL_TRAVERSE_DEFAULT); + col_debug_collection(tpl, COL_TRAVERSE_DEFAULT); col_debug_collection(event, COL_TRAVERSE_DEFAULT); error = elapi_log(E_TARGET_DEBUG, event); @@ -221,10 +221,10 @@ int complex_event_test(void) } - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); - error = elapi_create_event_template( - &template, + error = elapi_create_event_tplt( + &tpl, E_BASE_DEFV1 | E_BASE_HOSTEXT, "%n( bin )", bin, 8, " %sb( logical1 )", "false", @@ -247,14 +247,14 @@ int complex_event_test(void) /* We are forcing overwrite with different type */ (error = col_add_int_property(col, NULL, "unsigned_number", 1)) || (error = col_add_long_property(col, NULL, "bin", 100000000L))) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to add property. Error %d\n", error); return error; } error = elapi_create_event( &event, - template, + tpl, col, COL_ADD_MODE_FLAT, E_MESSAGE, @@ -264,14 +264,14 @@ int complex_event_test(void) if (error) { printf("Failed to set create template %d\n", error); - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); col_destroy_collection(col); return error; } col_destroy_collection(col); - col_debug_collection(template, COL_TRAVERSE_DEFAULT); + col_debug_collection(tpl, COL_TRAVERSE_DEFAULT); printf("\nPRINTING EVENT\n\n"); printf("\nPRINTING EVENT, removed message added bin\n\n"); @@ -282,7 +282,7 @@ int complex_event_test(void) /* We are forsing overwrite with different type */ (error = col_add_int_property(col, NULL, "zzz", 1)) || (error = col_add_long_property(col, NULL, "zzz2", 100000000L))) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to add property. Error %d\n", error); elapi_destroy_event(event); return error; @@ -299,7 +299,7 @@ int complex_event_test(void) if (error) { printf("Failed to set create template %d\n", error); elapi_destroy_event(event); - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); col_destroy_collection(col); return error; } @@ -314,7 +314,7 @@ int complex_event_test(void) /* We are forsing overwrite with different type */ (error = col_add_int_property(col, NULL, "zzz", 1)) || (error = col_add_long_property(col, NULL, "zzz2", 100000000L))) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to add property. Error %d\n", error); elapi_destroy_event(event); return error; @@ -329,7 +329,7 @@ int complex_event_test(void) if (error) { printf("Failed to set create template %d\n", error); elapi_destroy_event(event); - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); col_destroy_collection(col); return error; } @@ -343,7 +343,7 @@ int complex_event_test(void) if (error) { printf("Failed to set create template %d\n", error); elapi_destroy_event(event); - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); return error; } @@ -351,7 +351,7 @@ int complex_event_test(void) if (error) { elapi_destroy_event(event); elapi_destroy_event(event_copy); - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to create dispatcher %d\n", error); return error; } @@ -362,7 +362,7 @@ int complex_event_test(void) if (error) { elapi_destroy_event(event_copy); - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to log event! %d\n", error); return error; } @@ -372,54 +372,54 @@ int complex_event_test(void) elapi_destroy_event(event_copy); if (error) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to log event! %d\n", error); return error; } - error = elapi_dsp_msg(E_TARGET_DEBUG, dispatcher, template, "a", "b", "c", "d", E_EOARG); + error = elapi_dsp_msg(E_TARGET_DEBUG, dispatcher, tpl, "a", "b", "c", "d", E_EOARG); if (error) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to log event! %d\n", error); return error; } error = elapi_dsp_msg(E_TARGET_DEBUG, dispatcher, NULL, "a", "b", "c", "d", E_EOARG); if (error) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to log event! %d\n", error); return error; } error = elapi_dsp_msg(E_TARGET_DEBUG, dispatcher, - template, + tpl, E_MESSAGE, "date = %(R_stamp__), pid = %(__pid__), " "hostname = %(__host__), %(__halias__), " "ip = %(__ip__), [%(__iplist__);%(!__iplist__);%(__iplist__)]" , E_EOARG); if (error) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to log event! %d\n", error); return error; } error = elapi_dsp_msg(E_TARGET_DEBUG, dispatcher, - template, + tpl, E_MESSAGE, "date = %(R_stamp__), pid = %(__pid__), " "hostname = %(__host__), %(__halias__), " "ip = %(__ip__), [%(__iplist__);%(__iplist__);%(__iplist__)]" , E_EOARG); if (error) { - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); printf("Failed to log event! %d\n", error); return error; } - elapi_destroy_event_template(template); + elapi_destroy_event_tplt(tpl); elapi_print_dispatcher(dispatcher); @@ -435,7 +435,7 @@ int main(int argc, char *argv[]) { int error = 0; test_fn tests[] = { elapi_init_test, - elapi_get_default_template_test, + elapi_get_default_tplt_test, simple_event_test, complex_event_test, NULL }; |