[svn-commits] kmoore: branch kmoore/event_system_strip r395496 - in /team/kmoore/event_syst...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Jul 26 09:10:29 CDT 2013
Author: kmoore
Date: Fri Jul 26 09:10:27 2013
New Revision: 395496
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395496
Log:
Remove some more chunks of the old event system
Modified:
team/kmoore/event_system_strip/include/asterisk/event.h
team/kmoore/event_system_strip/main/event.c
team/kmoore/event_system_strip/tests/test_cel.c
team/kmoore/event_system_strip/tests/test_event.c
Modified: team/kmoore/event_system_strip/include/asterisk/event.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/include/asterisk/event.h?view=diff&rev=395496&r1=395495&r2=395496
==============================================================================
--- team/kmoore/event_system_strip/include/asterisk/event.h (original)
+++ team/kmoore/event_system_strip/include/asterisk/event.h Fri Jul 26 09:10:27 2013
@@ -187,20 +187,6 @@
enum ast_event_ie_type ie_type, void *data, size_t raw_datalen);
/*!
- * \brief Append an 'exists' parameter to a subscription
- *
- * \param sub the dynamic subscription allocated with ast_event_subscribe_new()
- * \param ie_type the information element type that must be present in the event
- * for it to match this subscription.
- *
- * \retval 0 success
- * \retval non-zero failure
- * \since 1.6.1
- */
-int ast_event_sub_append_ie_exists(struct ast_event_sub *sub,
- enum ast_event_ie_type ie_type);
-
-/*!
* \brief Activate a dynamically built subscription
*
* \param sub the subscription to activate that was allocated using
@@ -228,15 +214,6 @@
* \version 1.6.1 return changed to NULL
*/
struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *event_sub);
-
-/*!
- * \brief Get description for a subscription
- *
- * \param sub subscription
- *
- * \return string description of the subscription
- */
-const char *ast_event_subscriber_get_description(struct ast_event_sub *sub);
/*!
* \brief Check if subscribers exist
@@ -394,24 +371,6 @@
uint32_t data);
/*!
- * \brief Append an information element that has a raw payload
- *
- * \param event the event that the IE will be appended to
- * \param ie_type the type of IE to append
- * \param data A pointer to the raw data for the payload of the IE
- * \param data_len The amount of data to copy into the payload
- *
- * \retval 0 success
- * \retval -1 failure
- *
- * The pointer to the event will get updated with the new location for the event
- * that now contains the appended information element. If the re-allocation of
- * the memory for this event fails, it will be set to NULL.
- */
-int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type,
- const void *data, size_t data_len);
-
-/*!
* \brief Get the value of an information element that has an integer payload
*
* \param event The event to get the IE from
@@ -435,40 +394,6 @@
const char *ast_event_get_ie_str(const struct ast_event *event, enum ast_event_ie_type ie_type);
/*!
- * \brief Get the hash for the string payload of an IE
- *
- * \param event The event to get the IE from
- * \param ie_type the type of information element to retrieve the hash for
- *
- * \return This function returns the hash value as calculated by ast_str_hash()
- * for the string payload. This is stored in the event to avoid
- * unnecessary string comparisons.
- */
-uint32_t ast_event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type);
-
-/*!
- * \brief Get the value of an information element that has a raw payload
- *
- * \param event The event to get the IE from
- * \param ie_type the type of information element to retrieve
- *
- * \return This returns the payload of the information element with the given type.
- * If the information element isn't found, NULL will be returned.
- */
-const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type);
-
-/*!
- * \brief Get the length of the raw payload for a particular IE
- *
- * \param event The event to get the IE payload length from
- * \param ie_type the type of information element to get the length of
- *
- * \return If an IE of type ie_type is found, its payload length is returned.
- * Otherwise, 0 is returned.
- */
-uint16_t ast_event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type);
-
-/*!
* \brief Get the string representation of an information element type
*
* \param ie_type the information element type to get the string representation of
@@ -499,28 +424,6 @@
enum ast_event_type ast_event_get_type(const struct ast_event *event);
/*!
- * \brief Get the string representation of the type of the given event
- *
- * \arg event the event to get the type of
- *
- * \return the string representation of the event type of the provided event
- * \since 1.6.1
- */
-const char *ast_event_get_type_name(const struct ast_event *event);
-
-/*!
- * \brief Convert a string into an event type
- *
- * \param str the string to convert
- * \param event_type an output parameter for the event type
- *
- * \retval 0 success
- * \retval non-zero failure
- * \since 1.6.1
- */
-int ast_event_str_to_event_type(const char *str, enum ast_event_type *event_type);
-
-/*!
* \brief Convert a string to an IE type
*
* \param str the string to convert
@@ -590,24 +493,6 @@
* \return This returns the payload of the information element as a string.
*/
const char *ast_event_iterator_get_ie_str(struct ast_event_iterator *iterator);
-
-/*!
- * \brief Get the value of the current IE in the iterator instance that has a raw payload
- *
- * \param iterator The iterator instance
- *
- * \return This returns the payload of the information element as type raw.
- */
-void *ast_event_iterator_get_ie_raw(struct ast_event_iterator *iterator);
-
-/*!
- * \brief Get the length of the raw payload for the current IE for an iterator
- *
- * \param iterator The IE iterator
- *
- * \return The payload length of the current IE
- */
-uint16_t ast_event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: team/kmoore/event_system_strip/main/event.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/main/event.c?view=diff&rev=395496&r1=395495&r2=395496
==============================================================================
--- team/kmoore/event_system_strip/main/event.c (original)
+++ team/kmoore/event_system_strip/main/event.c Fri Jul 26 09:10:27 2013
@@ -45,6 +45,11 @@
#include "asterisk/cli.h"
static struct ast_taskprocessor *event_dispatcher;
+static int event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type,
+ const void *data, size_t data_len);
+static const void *event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type);
+static uint16_t event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type);
+static uint32_t event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type);
/*!
* \brief An event information element
@@ -123,16 +128,6 @@
/*! \brief Event subscriptions
* The event subscribers are indexed by which event they are subscribed to */
static AST_RWDLLIST_HEAD(ast_event_sub_list, ast_event_sub) ast_event_subs[AST_EVENT_TOTAL];
-
-/*!
- * \brief Event Names
- */
-static const char * const event_names[AST_EVENT_TOTAL] = {
- [AST_EVENT_ALL] = "All",
- [AST_EVENT_CUSTOM] = "Custom",
- [AST_EVENT_SUB] = "Subscription",
- [AST_EVENT_CEL] = "CEL",
-};
struct ie_map {
enum ast_event_ie_pltype ie_pltype;
@@ -193,36 +188,6 @@
[AST_EVENT_IE_ATTEMPTED_TRANSPORT] = { AST_EVENT_IE_PLTYPE_STR, "AttemptedTransport" },
};
-const char *ast_event_get_type_name(const struct ast_event *event)
-{
- enum ast_event_type type;
-
- type = ast_event_get_type(event);
-
- if (type < 0 || type >= ARRAY_LEN(event_names)) {
- ast_log(LOG_ERROR, "Invalid event type - '%d'\n", type);
- return "";
- }
-
- return event_names[type];
-}
-
-int ast_event_str_to_event_type(const char *str, enum ast_event_type *event_type)
-{
- int i;
-
- for (i = 0; i < ARRAY_LEN(event_names); i++) {
- if (ast_strlen_zero(event_names[i]) || strcasecmp(event_names[i], str)) {
- continue;
- }
-
- *event_type = i;
- return 0;
- }
-
- return -1;
-}
-
const char *ast_event_get_ie_type_name(enum ast_event_ie_type ie_type)
{
if (ie_type <= 0 || ie_type >= ARRAY_LEN(ie_maps)) {
@@ -241,22 +206,6 @@
}
return ie_maps[ie_type].ie_pltype;
-}
-
-int ast_event_str_to_ie_type(const char *str, enum ast_event_ie_type *ie_type)
-{
- int i;
-
- for (i = 0; i < ARRAY_LEN(ie_maps); i++) {
- if (strcasecmp(ie_maps[i].name, str)) {
- continue;
- }
-
- *ie_type = i;
- return 0;
- }
-
- return -1;
}
size_t ast_event_get_size(const struct ast_event *event)
@@ -469,8 +418,8 @@
const char *str;
uint32_t hash;
- hash = event2 ? ast_event_get_ie_str_hash(event2, ie_val->ie_type) : ie_val->payload.hash;
- if (hash != ast_event_get_ie_str_hash(event, ie_val->ie_type)) {
+ hash = event2 ? event_get_ie_str_hash(event2, ie_val->ie_type) : ie_val->payload.hash;
+ if (hash != event_get_ie_str_hash(event, ie_val->ie_type)) {
return 0;
}
@@ -490,12 +439,12 @@
case AST_EVENT_IE_PLTYPE_RAW:
{
- const void *buf = event2 ? ast_event_get_ie_raw(event2, ie_val->ie_type) : ie_val->payload.raw;
- uint16_t ie_payload_len = event2 ? ast_event_get_ie_raw_payload_len(event2, ie_val->ie_type) : ie_val->raw_datalen;
+ const void *buf = event2 ? event_get_ie_raw(event2, ie_val->ie_type) : ie_val->payload.raw;
+ uint16_t ie_payload_len = event2 ? event_get_ie_raw_payload_len(event2, ie_val->ie_type) : ie_val->raw_datalen;
return (buf
- && ie_payload_len == ast_event_get_ie_raw_payload_len(event, ie_val->ie_type)
- && !memcmp(buf, ast_event_get_ie_raw(event, ie_val->ie_type), ie_payload_len)) ? 1 : 0;
+ && ie_payload_len == event_get_ie_raw_payload_len(event, ie_val->ie_type)
+ && !memcmp(buf, event_get_ie_raw(event, ie_val->ie_type), ie_payload_len)) ? 1 : 0;
}
case AST_EVENT_IE_PLTYPE_UNKNOWN:
@@ -529,7 +478,7 @@
ast_event_append_ie_str(&event, ie_val->ie_type, ie_val->payload.str);
break;
case AST_EVENT_IE_PLTYPE_RAW:
- ast_event_append_ie_raw(&event, ie_val->ie_type, ie_val->payload.raw, ie_val->raw_datalen);
+ event_append_ie_raw(&event, ie_val->ie_type, ie_val->payload.raw, ie_val->raw_datalen);
break;
}
if (!event)
@@ -761,11 +710,6 @@
}
ast_free(sub);
-}
-
-const char *ast_event_subscriber_get_description(struct ast_event_sub *sub)
-{
- return sub ? sub->description : NULL;
}
struct ast_event_sub *ast_event_unsubscribe(struct ast_event_sub *sub)
@@ -821,12 +765,12 @@
return str_payload ? str_payload->str : NULL;
}
-void *ast_event_iterator_get_ie_raw(struct ast_event_iterator *iterator)
+static void *event_iterator_get_ie_raw(struct ast_event_iterator *iterator)
{
return iterator->ie->ie_payload;
}
-uint16_t ast_event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator)
+static uint16_t event_iterator_get_ie_raw_payload_len(struct ast_event_iterator *iterator)
{
return ntohs(iterator->ie->ie_payload_len);
}
@@ -840,16 +784,16 @@
{
const uint32_t *ie_val;
- ie_val = ast_event_get_ie_raw(event, ie_type);
+ ie_val = event_get_ie_raw(event, ie_type);
return ie_val ? ntohl(get_unaligned_uint32(ie_val)) : 0;
}
-uint32_t ast_event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type)
+static uint32_t event_get_ie_str_hash(const struct ast_event *event, enum ast_event_ie_type ie_type)
{
const struct ast_event_ie_str_payload *str_payload;
- str_payload = ast_event_get_ie_raw(event, ie_type);
+ str_payload = event_get_ie_raw(event, ie_type);
return str_payload ? str_payload->hash : 0;
}
@@ -858,33 +802,33 @@
{
const struct ast_event_ie_str_payload *str_payload;
- str_payload = ast_event_get_ie_raw(event, ie_type);
+ str_payload = event_get_ie_raw(event, ie_type);
return str_payload ? str_payload->str : NULL;
}
-const void *ast_event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type)
+static const void *event_get_ie_raw(const struct ast_event *event, enum ast_event_ie_type ie_type)
{
struct ast_event_iterator iterator;
int res;
for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
- return ast_event_iterator_get_ie_raw(&iterator);
+ return event_iterator_get_ie_raw(&iterator);
}
}
return NULL;
}
-uint16_t ast_event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type)
+static uint16_t event_get_ie_raw_payload_len(const struct ast_event *event, enum ast_event_ie_type ie_type)
{
struct ast_event_iterator iterator;
int res;
for (res = ast_event_iterator_init(&iterator, event); !res; res = ast_event_iterator_next(&iterator)) {
if (ast_event_iterator_get_ie_type(&iterator) == ie_type) {
- return ast_event_iterator_get_ie_raw_payload_len(&iterator);
+ return event_iterator_get_ie_raw_payload_len(&iterator);
}
}
@@ -903,17 +847,17 @@
strcpy(str_payload->str, str);
str_payload->hash = ast_str_hash(str);
- return ast_event_append_ie_raw(event, ie_type, str_payload, payload_len);
+ return event_append_ie_raw(event, ie_type, str_payload, payload_len);
}
int ast_event_append_ie_uint(struct ast_event **event, enum ast_event_ie_type ie_type,
uint32_t data)
{
data = htonl(data);
- return ast_event_append_ie_raw(event, ie_type, &data, sizeof(data));
-}
-
-int ast_event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type,
+ return event_append_ie_raw(event, ie_type, &data, sizeof(data));
+}
+
+static int event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type ie_type,
const void *data, size_t data_len)
{
struct ast_event_ie *ie;
@@ -1010,7 +954,7 @@
ast_event_append_ie_uint(&event, ie_val->ie_type, ie_val->payload.uint);
break;
case AST_EVENT_IE_PLTYPE_RAW:
- ast_event_append_ie_raw(&event, ie_val->ie_type,
+ event_append_ie_raw(&event, ie_val->ie_type,
ie_val->payload.raw, ie_val->raw_datalen);
break;
case AST_EVENT_IE_PLTYPE_UNKNOWN:
Modified: team/kmoore/event_system_strip/tests/test_cel.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/tests/test_cel.c?view=diff&rev=395496&r1=395495&r2=395496
==============================================================================
--- team/kmoore/event_system_strip/tests/test_cel.c (original)
+++ team/kmoore/event_system_strip/tests/test_cel.c Fri Jul 26 09:10:27 2013
@@ -1707,12 +1707,6 @@
case AST_EVENT_IE_PLTYPE_STR:
{
const char *str;
- uint32_t hash;
-
- hash = ast_event_get_ie_str_hash(event2, type);
- if (hash != ast_event_get_ie_str_hash(event1, type)) {
- return 0;
- }
str = ast_event_get_ie_str(event2, type);
if (str) {
@@ -1766,7 +1760,7 @@
return 0;
}
- ast_log(LOG_ERROR, "Event: %s %s\n", ast_event_get_type_name(event),
+ ast_log(LOG_ERROR, "Event: %s\n",
ast_cel_get_type_name(ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TYPE)));
do {
Modified: team/kmoore/event_system_strip/tests/test_event.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/event_system_strip/tests/test_event.c?view=diff&rev=395496&r1=395495&r2=395496
==============================================================================
--- team/kmoore/event_system_strip/tests/test_event.c (original)
+++ team/kmoore/event_system_strip/tests/test_event.c Fri Jul 26 09:10:27 2013
@@ -28,14 +28,11 @@
* - ast_event_report_subs()
* - ast_event_get_ie_type_name()
* - ast_event_get_ie_pltype()
- * - ast_event_str_to_event_type()
- * - ast_event_str_to_ie_type()
* - ast_event_iterator_init()
* - ast_event_iterator_next()
* - ast_event_iterator_get_ie_type()
* - ast_event_iterator_get_ie_uint()
* - ast_event_iterator_get_ie_str()
- * - ast_event_iterator_get_ie_raw()
*/
/*** MODULEINFO
@@ -67,32 +64,25 @@
return -1;
}
- /* Check #2: Check string representation of event type */
- if (strcmp(type_name, ast_event_get_type_name(event))) {
- ast_test_status_update(test, "Didn't get expected type name: '%s' != '%s'\n",
- type_name, ast_event_get_type_name(event));
- return -1;
- }
-
- /* Check #3: Check for the string IE */
+ /* Check #4: Check for the string IE */
if (strcmp(str, ast_event_get_ie_str(event, AST_EVENT_IE_CEL_USEREVENT_NAME))) {
ast_test_status_update(test, "Failed to get string IE.\n");
return -1;
}
- /* Check #4: Check for the uint IE */
+ /* Check #5: Check for the uint IE */
if (uint != ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_AMAFLAGS)) {
ast_test_status_update(test, "Failed to get uint IE.\n");
return -1;
}
- /* Check #5: Check if a check for a str IE that isn't there works */
+ /* Check #6: Check if a check for a str IE that isn't there works */
if ((foo = ast_event_get_ie_str(event, AST_EVENT_IE_CEL_CIDNAME))) {
ast_test_status_update(test, "CEL_CIDNAME IE check returned non-NULL %p\n", foo);
return -1;
}
- /* Check #6: Check if a check for a uint IE that isn't there returns 0 */
+ /* Check #7: Check if a check for a uint IE that isn't there returns 0 */
if (ast_event_get_ie_uint(event, AST_EVENT_IE_CEL_EVENT_TIME_USEC)) {
ast_test_status_update(test, "UNIQUEID IE should be 0\n");
return -1;
@@ -334,14 +324,6 @@
goto return_cleanup;
}
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_STR].sub),
- test_subs_class_type_str(TEST_SUBS_CUSTOM_STR))) {
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_CUSTOM_STR subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
ast_test_status_update(test, "Check that a CUSTOM subscriber exists\n");
sub_res = ast_event_check_subscriber(AST_EVENT_CUSTOM,
AST_EVENT_IE_END);
@@ -367,14 +349,6 @@
goto return_cleanup;
}
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_ALL_STR].sub),
- test_subs_class_type_str(TEST_SUBS_ALL_STR))) {
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_ALL_STR subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
/*
* Subscription TEST_SUBS_CUSTOM_RAW:
* - allocate normally
@@ -391,14 +365,6 @@
goto return_cleanup;
}
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_RAW].sub),
- test_subs_class_type_str(TEST_SUBS_CUSTOM_RAW))) {
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_CUSTOM_RAW subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
/*
* Subscription TEST_SUBS_CUSTOM_UINT:
* - allocate normally
@@ -415,14 +381,6 @@
goto return_cleanup;
}
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_UINT].sub),
- test_subs_class_type_str(TEST_SUBS_CUSTOM_UINT))) {
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_CUSTOM_UINT subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
/*
* Subscription TEST_SUBS_CUSTOM_EXISTS:
* - allocate normally
@@ -435,14 +393,6 @@
AST_EVENT_IE_END);
if (!test_subs[TEST_SUBS_CUSTOM_EXISTS].sub) {
ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_EXISTS subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_EXISTS].sub),
- test_subs_class_type_str(TEST_SUBS_CUSTOM_EXISTS))) {
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_CUSTOM_EXISTS subscription\n");
res = AST_TEST_FAIL;
goto return_cleanup;
}
@@ -472,16 +422,6 @@
goto return_cleanup;
}
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub),
- "")) {
- ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub);
- test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL;
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_CUSTOM_DYNAMIC subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
if (ast_event_sub_append_ie_uint(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub, AST_EVENT_IE_CEL_AMAFLAGS, 4)) {
ast_event_sub_destroy(test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub);
test_subs[TEST_SUBS_CUSTOM_DYNAMIC].sub = NULL;
@@ -622,14 +562,6 @@
AST_EVENT_IE_END);
if (!test_subs[TEST_SUBS_CUSTOM_ANY].sub) {
ast_test_status_update(test, "Failed to create TEST_SUBS_CUSTOM_ANY subscription\n");
- res = AST_TEST_FAIL;
- goto return_cleanup;
- }
-
- if (strcmp(ast_event_subscriber_get_description(test_subs[TEST_SUBS_CUSTOM_ANY].sub),
- test_subs_class_type_str(TEST_SUBS_CUSTOM_ANY))) {
- ast_test_status_update(test,
- "Unexpected subscription description on TEST_SUBS_CUSTOM_ANY subscription\n");
res = AST_TEST_FAIL;
goto return_cleanup;
}
More information about the svn-commits
mailing list