<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/5961">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">RFC: core: Remove 'Data Retrieval API'<br><br>Change-Id: I4b2185a83aeb74798b4ad43ff8f89f971096aa83<br>---<br>M apps/app_meetme.c<br>M apps/app_queue.c<br>M apps/app_voicemail.c<br>M channels/chan_dahdi.c<br>M channels/chan_iax2.c<br>M channels/chan_sip.c<br>M include/asterisk/_private.h<br>M include/asterisk/channel.h<br>D include/asterisk/data.h<br>M include/asterisk/indications.h<br>M main/asterisk.c<br>M main/cdr.c<br>M main/channel.c<br>M main/channel_internal_api.c<br>D main/data.c<br>M main/indications.c<br>M main/pbx.c<br>M res/res_odbc.c<br>18 files changed, 1 insertion(+), 6,114 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/61/5961/3</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/apps/app_meetme.c b/apps/app_meetme.c<br>index 71ca9dc..d98c418 100644<br>--- a/apps/app_meetme.c<br>+++ b/apps/app_meetme.c<br>@@ -69,7 +69,6 @@<br> #include "asterisk/dial.h"<br> #include "asterisk/causes.h"<br> #include "asterisk/paths.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/test.h"<br> #include "asterisk/stasis.h"<br> #include "asterisk/stasis_channels.h"<br>@@ -8005,186 +8004,6 @@<br>  return sla_load_config(reload);<br> }<br> <br>-#define MEETME_DATA_EXPORT(MEMBER)                                     \<br>-    MEMBER(ast_conference, confno, AST_DATA_STRING)                 \<br>-    MEMBER(ast_conference, dahdiconf, AST_DATA_INTEGER)             \<br>-    MEMBER(ast_conference, users, AST_DATA_INTEGER)                 \<br>-    MEMBER(ast_conference, markedusers, AST_DATA_INTEGER)           \<br>-    MEMBER(ast_conference, maxusers, AST_DATA_INTEGER)              \<br>-    MEMBER(ast_conference, isdynamic, AST_DATA_BOOLEAN)             \<br>-    MEMBER(ast_conference, locked, AST_DATA_BOOLEAN)                \<br>-    MEMBER(ast_conference, recordingfilename, AST_DATA_STRING)      \<br>-    MEMBER(ast_conference, recordingformat, AST_DATA_STRING)        \<br>-    MEMBER(ast_conference, pin, AST_DATA_PASSWORD)                  \<br>-    MEMBER(ast_conference, pinadmin, AST_DATA_PASSWORD)             \<br>-    MEMBER(ast_conference, start, AST_DATA_TIMESTAMP)               \<br>-    MEMBER(ast_conference, endtime, AST_DATA_TIMESTAMP)<br>-<br>-AST_DATA_STRUCTURE(ast_conference, MEETME_DATA_EXPORT);<br>-<br>-#define MEETME_USER_DATA_EXPORT(MEMBER)                                   \<br>-    MEMBER(ast_conf_user, user_no, AST_DATA_INTEGER)                \<br>-    MEMBER(ast_conf_user, talking, AST_DATA_BOOLEAN)                \<br>-    MEMBER(ast_conf_user, dahdichannel, AST_DATA_BOOLEAN)           \<br>-    MEMBER(ast_conf_user, jointime, AST_DATA_TIMESTAMP)             \<br>-    MEMBER(ast_conf_user, kicktime, AST_DATA_TIMESTAMP)             \<br>-    MEMBER(ast_conf_user, timelimit, AST_DATA_MILLISECONDS)         \<br>-    MEMBER(ast_conf_user, play_warning, AST_DATA_MILLISECONDS)      \<br>-    MEMBER(ast_conf_user, warning_freq, AST_DATA_MILLISECONDS)<br>-<br>-AST_DATA_STRUCTURE(ast_conf_user, MEETME_USER_DATA_EXPORT);<br>-<br>-static int user_add_provider_cb(void *obj, void *arg, int flags)<br>-{<br>-        struct ast_data *data_meetme_user;<br>-   struct ast_data *data_meetme_user_channel;<br>-   struct ast_data *data_meetme_user_volume;<br>-<br>- struct ast_conf_user *user = obj;<br>-    struct ast_data *data_meetme_users = arg;<br>-<br>- data_meetme_user = ast_data_add_node(data_meetme_users, "user");<br>-   if (!data_meetme_user) {<br>-             return 0;<br>-    }<br>-    /* user structure */<br>- ast_data_add_structure(ast_conf_user, data_meetme_user, user);<br>-<br>-    /* user's channel */<br>-     data_meetme_user_channel = ast_data_add_node(data_meetme_user, "channel");<br>- if (!data_meetme_user_channel) {<br>-             return 0;<br>-    }<br>-<br>- ast_channel_data_add_structure(data_meetme_user_channel, user->chan, 1);<br>-<br>-       /* volume structure */<br>-       data_meetme_user_volume = ast_data_add_node(data_meetme_user, "listen-volume");<br>-    if (!data_meetme_user_volume) {<br>-              return 0;<br>-    }<br>-    ast_data_add_int(data_meetme_user_volume, "desired", user->listen.desired);<br>-     ast_data_add_int(data_meetme_user_volume, "actual", user->listen.actual);<br>-<br>-    data_meetme_user_volume = ast_data_add_node(data_meetme_user, "talk-volume");<br>-      if (!data_meetme_user_volume) {<br>-              return 0;<br>-    }<br>-    ast_data_add_int(data_meetme_user_volume, "desired", user->talk.desired);<br>-       ast_data_add_int(data_meetme_user_volume, "actual", user->talk.actual);<br>-<br>-      return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Implements the meetme data provider.<br>- */<br>-static int meetme_data_provider_get(const struct ast_data_search *search,<br>-     struct ast_data *data_root)<br>-{<br>-      struct ast_conference *cnf;<br>-  struct ast_data *data_meetme, *data_meetme_users;<br>-<br>- AST_LIST_LOCK(&confs);<br>-   AST_LIST_TRAVERSE(&confs, cnf, list) {<br>-           data_meetme = ast_data_add_node(data_root, "meetme");<br>-              if (!data_meetme) {<br>-                  continue;<br>-            }<br>-<br>-         ast_data_add_structure(ast_conference, data_meetme, cnf);<br>-<br>-         if (ao2_container_count(cnf->usercontainer)) {<br>-                    data_meetme_users = ast_data_add_node(data_meetme, "users");<br>-                       if (!data_meetme_users) {<br>-                            ast_data_remove_node(data_root, data_meetme);<br>-                                continue;<br>-                    }<br>-<br>-                 ao2_callback(cnf->usercontainer, OBJ_NODATA, user_add_provider_cb, data_meetme_users); <br>-           }<br>-<br>-         if (!ast_data_search_match(search, data_meetme)) {<br>-                   ast_data_remove_node(data_root, data_meetme);<br>-                }<br>-    }<br>-    AST_LIST_UNLOCK(&confs);<br>-<br>-      return 0;<br>-}<br>-<br>-static const struct ast_data_handler meetme_data_provider = {<br>-     .version = AST_DATA_HANDLER_VERSION,<br>- .get = meetme_data_provider_get<br>-};<br>-<br>-static const struct ast_data_entry meetme_data_providers[] = {<br>-     AST_DATA_ENTRY("asterisk/application/meetme/list", &meetme_data_provider),<br>-};<br>-<br>-#ifdef TEST_FRAMEWORK<br>-AST_TEST_DEFINE(test_meetme_data_provider)<br>-{<br>-    struct ast_channel *chan;<br>-    struct ast_conference *cnf;<br>-  struct ast_data *node;<br>-       struct ast_data_query query = {<br>-              .path = "/asterisk/application/meetme/list",<br>-               .search = "list/meetme/confno=9898"<br>-        };<br>-<br>-        switch (cmd) {<br>-       case TEST_INIT:<br>-              info->name = "meetme_get_data_test";<br>-            info->category = "/main/data/app_meetme/list/";<br>-         info->summary = "Meetme data provider unit test";<br>-               info->description =<br>-                       "Tests whether the Meetme data provider implementation works as expected.";<br>-                return AST_TEST_NOT_RUN;<br>-     case TEST_EXECUTE:<br>-           break;<br>-       }<br>-<br>- chan = ast_channel_alloc(0, AST_STATE_DOWN, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, "MeetMeTest");<br>-    if (!chan) {<br>-         ast_test_status_update(test, "Channel allocation failed\n");<br>-               return AST_TEST_FAIL;<br>-        }<br>-<br>- ast_channel_unlock(chan);<br>-<br>- cnf = build_conf("9898", "", "1234", 1, 1, 1, chan, test);<br>-     if (!cnf) {<br>-          ast_test_status_update(test, "Build of test conference 9898 failed\n");<br>-            ast_hangup(chan);<br>-            return AST_TEST_FAIL;<br>-        }<br>-<br>- node = ast_data_get(&query);<br>-     if (!node) {<br>-         ast_test_status_update(test, "Data query for test conference 9898 failed\n");<br>-              dispose_conf(cnf);<br>-           ast_hangup(chan);<br>-            return AST_TEST_FAIL;<br>-        }<br>-<br>- if (strcmp(ast_data_retrieve_string(node, "meetme/confno"), "9898")) {<br>-           ast_test_status_update(test, "Query returned the wrong conference\n");<br>-             dispose_conf(cnf);<br>-           ast_hangup(chan);<br>-            ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- ast_data_free(node);<br>- dispose_conf(cnf);<br>-   ast_hangup(chan);<br>-<br>- return AST_TEST_PASS;<br>-}<br>-#endif<br>-<br> static int unload_module(void)<br> {<br>    int res = 0;<br>@@ -8200,11 +8019,6 @@<br>  res |= ast_unregister_application(app);<br>       res |= ast_unregister_application(slastation_app);<br>    res |= ast_unregister_application(slatrunk_app);<br>-<br>-#ifdef TEST_FRAMEWORK<br>-  AST_TEST_UNREGISTER(test_meetme_data_provider);<br>-#endif<br>-     ast_data_unregister(NULL);<br> <br>         ast_devstate_prov_del("Meetme");<br>    ast_devstate_prov_del("SLA");<br>@@ -8248,11 +8062,6 @@<br>       res |= ast_register_application_xml(app, conf_exec);<br>  res |= ast_register_application_xml(slastation_app, sla_station_exec);<br>        res |= ast_register_application_xml(slatrunk_app, sla_trunk_exec);<br>-<br>-#ifdef TEST_FRAMEWORK<br>-        AST_TEST_REGISTER(test_meetme_data_provider);<br>-#endif<br>-       ast_data_register_multiple(meetme_data_providers, ARRAY_LEN(meetme_data_providers));<br> <br>       res |= ast_devstate_prov_add("Meetme", meetmestate);<br>        res |= ast_devstate_prov_add("SLA", sla_state);<br>diff --git a/apps/app_queue.c b/apps/app_queue.c<br>index b306af1..3f8e136 100644<br>--- a/apps/app_queue.c<br>+++ b/apps/app_queue.c<br>@@ -99,7 +99,6 @@<br> #include "asterisk/taskprocessor.h"<br> #include "asterisk/aoc.h"<br> #include "asterisk/callerid.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/term.h"<br> #include "asterisk/dial.h"<br> #include "asterisk/stasis_channels.h"<br>@@ -10896,275 +10895,6 @@<br>      AST_CLI_DEFINE(handle_queue_reset, "Reset statistics for a queue"),<br> };<br> <br>-/* struct call_queue astdata mapping. */<br>-#define DATA_EXPORT_CALL_QUEUE(MEMBER)                                       \<br>-    MEMBER(call_queue, name, AST_DATA_STRING)                       \<br>-    MEMBER(call_queue, moh, AST_DATA_STRING)                        \<br>-    MEMBER(call_queue, announce, AST_DATA_STRING)                   \<br>-    MEMBER(call_queue, context, AST_DATA_STRING)                    \<br>-    MEMBER(call_queue, membermacro, AST_DATA_STRING)                \<br>-    MEMBER(call_queue, membergosub, AST_DATA_STRING)                \<br>-    MEMBER(call_queue, defaultrule, AST_DATA_STRING)                \<br>-    MEMBER(call_queue, sound_next, AST_DATA_STRING)                 \<br>-    MEMBER(call_queue, sound_thereare, AST_DATA_STRING)             \<br>-    MEMBER(call_queue, sound_calls, AST_DATA_STRING)                \<br>-    MEMBER(call_queue, queue_quantity1, AST_DATA_STRING)            \<br>-    MEMBER(call_queue, queue_quantity2, AST_DATA_STRING)            \<br>-    MEMBER(call_queue, sound_holdtime, AST_DATA_STRING)             \<br>-    MEMBER(call_queue, sound_minutes, AST_DATA_STRING)              \<br>-    MEMBER(call_queue, sound_minute, AST_DATA_STRING)               \<br>-    MEMBER(call_queue, sound_seconds, AST_DATA_STRING)              \<br>-    MEMBER(call_queue, sound_thanks, AST_DATA_STRING)               \<br>-    MEMBER(call_queue, sound_callerannounce, AST_DATA_STRING)       \<br>-    MEMBER(call_queue, sound_reporthold, AST_DATA_STRING)           \<br>-    MEMBER(call_queue, dead, AST_DATA_BOOLEAN)                      \<br>-    MEMBER(call_queue, ringinuse, AST_DATA_BOOLEAN)                 \<br>-    MEMBER(call_queue, announce_to_first_user, AST_DATA_BOOLEAN)    \<br>-    MEMBER(call_queue, setinterfacevar, AST_DATA_BOOLEAN)           \<br>-    MEMBER(call_queue, setqueuevar, AST_DATA_BOOLEAN)               \<br>-    MEMBER(call_queue, setqueueentryvar, AST_DATA_BOOLEAN)          \<br>-    MEMBER(call_queue, reportholdtime, AST_DATA_BOOLEAN)            \<br>-    MEMBER(call_queue, wrapped, AST_DATA_BOOLEAN)                   \<br>-    MEMBER(call_queue, timeoutrestart, AST_DATA_BOOLEAN)            \<br>-    MEMBER(call_queue, announceholdtime, AST_DATA_INTEGER)          \<br>-    MEMBER(call_queue, realtime, AST_DATA_BOOLEAN)                  \<br>-    MEMBER(call_queue, found, AST_DATA_BOOLEAN)                     \<br>-    MEMBER(call_queue, announcepositionlimit, AST_DATA_INTEGER)     \<br>-    MEMBER(call_queue, announcefrequency, AST_DATA_SECONDS)         \<br>-    MEMBER(call_queue, minannouncefrequency, AST_DATA_SECONDS)      \<br>-    MEMBER(call_queue, periodicannouncefrequency, AST_DATA_SECONDS) \<br>-    MEMBER(call_queue, numperiodicannounce, AST_DATA_INTEGER)       \<br>-    MEMBER(call_queue, randomperiodicannounce, AST_DATA_INTEGER)    \<br>-    MEMBER(call_queue, roundingseconds, AST_DATA_SECONDS)           \<br>-    MEMBER(call_queue, holdtime, AST_DATA_SECONDS)                  \<br>-    MEMBER(call_queue, talktime, AST_DATA_SECONDS)                  \<br>-    MEMBER(call_queue, callscompleted, AST_DATA_INTEGER)            \<br>-    MEMBER(call_queue, callsabandoned, AST_DATA_INTEGER)            \<br>-    MEMBER(call_queue, servicelevel, AST_DATA_INTEGER)              \<br>-    MEMBER(call_queue, callscompletedinsl, AST_DATA_INTEGER)        \<br>-    MEMBER(call_queue, monfmt, AST_DATA_STRING)                     \<br>-    MEMBER(call_queue, montype, AST_DATA_INTEGER)                   \<br>-    MEMBER(call_queue, count, AST_DATA_INTEGER)                     \<br>-    MEMBER(call_queue, maxlen, AST_DATA_INTEGER)                    \<br>-    MEMBER(call_queue, wrapuptime, AST_DATA_SECONDS)                \<br>-    MEMBER(call_queue, retry, AST_DATA_SECONDS)                     \<br>-    MEMBER(call_queue, timeout, AST_DATA_SECONDS)                   \<br>-    MEMBER(call_queue, weight, AST_DATA_INTEGER)                    \<br>-    MEMBER(call_queue, autopause, AST_DATA_INTEGER)                 \<br>-    MEMBER(call_queue, timeoutpriority, AST_DATA_INTEGER)           \<br>-    MEMBER(call_queue, rrpos, AST_DATA_INTEGER)                     \<br>-    MEMBER(call_queue, memberdelay, AST_DATA_INTEGER)               \<br>-    MEMBER(call_queue, autofill, AST_DATA_INTEGER)                  \<br>-    MEMBER(call_queue, members, AST_DATA_CONTAINER)<br>-<br>-AST_DATA_STRUCTURE(call_queue, DATA_EXPORT_CALL_QUEUE);<br>-<br>-/* struct member astdata mapping. */<br>-#define DATA_EXPORT_MEMBER(MEMBER)                                     \<br>-    MEMBER(member, interface, AST_DATA_STRING)                      \<br>-    MEMBER(member, state_interface, AST_DATA_STRING)                \<br>-    MEMBER(member, membername, AST_DATA_STRING)                     \<br>-    MEMBER(member, penalty, AST_DATA_INTEGER)                       \<br>-    MEMBER(member, calls, AST_DATA_INTEGER)                         \<br>-    MEMBER(member, dynamic, AST_DATA_INTEGER)                       \<br>-    MEMBER(member, realtime, AST_DATA_INTEGER)                      \<br>-    MEMBER(member, status, AST_DATA_INTEGER)                        \<br>-    MEMBER(member, paused, AST_DATA_BOOLEAN)                        \<br>-    MEMBER(member, rt_uniqueid, AST_DATA_STRING)<br>-<br>-AST_DATA_STRUCTURE(member, DATA_EXPORT_MEMBER);<br>-<br>-#define DATA_EXPORT_QUEUE_ENT(MEMBER)                                            \<br>-    MEMBER(queue_ent, moh, AST_DATA_STRING)                                 \<br>-    MEMBER(queue_ent, announce, AST_DATA_STRING)                            \<br>-    MEMBER(queue_ent, context, AST_DATA_STRING)                             \<br>-    MEMBER(queue_ent, digits, AST_DATA_STRING)                              \<br>-    MEMBER(queue_ent, valid_digits, AST_DATA_INTEGER)                       \<br>-    MEMBER(queue_ent, pos, AST_DATA_INTEGER)                                \<br>-    MEMBER(queue_ent, prio, AST_DATA_INTEGER)                               \<br>-    MEMBER(queue_ent, last_pos_said, AST_DATA_INTEGER)                      \<br>-    MEMBER(queue_ent, last_periodic_announce_time, AST_DATA_INTEGER)        \<br>-    MEMBER(queue_ent, last_periodic_announce_sound, AST_DATA_INTEGER)       \<br>-    MEMBER(queue_ent, last_pos, AST_DATA_INTEGER)                           \<br>-    MEMBER(queue_ent, opos, AST_DATA_INTEGER)                               \<br>-    MEMBER(queue_ent, handled, AST_DATA_INTEGER)                            \<br>-    MEMBER(queue_ent, pending, AST_DATA_INTEGER)                            \<br>-    MEMBER(queue_ent, max_penalty, AST_DATA_INTEGER)                        \<br>-    MEMBER(queue_ent, min_penalty, AST_DATA_INTEGER)                        \<br>-    MEMBER(queue_ent, raise_penalty, AST_DATA_INTEGER)                      \<br>-    MEMBER(queue_ent, linpos, AST_DATA_INTEGER)                             \<br>-    MEMBER(queue_ent, linwrapped, AST_DATA_INTEGER)                         \<br>-    MEMBER(queue_ent, start, AST_DATA_INTEGER)                              \<br>-    MEMBER(queue_ent, expire, AST_DATA_INTEGER)                             \<br>-    MEMBER(queue_ent, cancel_answered_elsewhere, AST_DATA_INTEGER)<br>-<br>-AST_DATA_STRUCTURE(queue_ent, DATA_EXPORT_QUEUE_ENT);<br>-<br>-/*!<br>- * \internal<br>- * \brief Add a queue to the data_root node.<br>- * \param[in] search The search tree.<br>- * \param[in] data_root The main result node.<br>- * \param[in] queue The queue to add.<br>- */<br>-static void queues_data_provider_get_helper(const struct ast_data_search *search,<br>-   struct ast_data *data_root, struct call_queue *queue)<br>-{<br>-    struct ao2_iterator im;<br>-      struct member *member;<br>-       struct queue_ent *qe;<br>-        struct ast_data *data_queue, *data_members = NULL, *enum_node;<br>-       struct ast_data *data_member, *data_callers = NULL, *data_caller, *data_caller_channel;<br>-<br>-   data_queue = ast_data_add_node(data_root, "queue");<br>-        if (!data_queue) {<br>-           return;<br>-      }<br>-<br>- ast_data_add_structure(call_queue, data_queue, queue);<br>-<br>-    ast_data_add_str(data_queue, "strategy", int2strat(queue->strategy));<br>-   ast_data_add_int(data_queue, "membercount", ao2_container_count(queue->members));<br>-<br>-    /* announce position */<br>-      enum_node = ast_data_add_node(data_queue, "announceposition");<br>-     if (!enum_node) {<br>-            return;<br>-      }<br>-    switch (queue->announceposition) {<br>-        case ANNOUNCEPOSITION_LIMIT:<br>-         ast_data_add_str(enum_node, "text", "limit");<br>-            break;<br>-       case ANNOUNCEPOSITION_MORE_THAN:<br>-             ast_data_add_str(enum_node, "text", "more");<br>-             break;<br>-       case ANNOUNCEPOSITION_YES:<br>-           ast_data_add_str(enum_node, "text", "yes");<br>-              break;<br>-       case ANNOUNCEPOSITION_NO:<br>-            ast_data_add_str(enum_node, "text", "no");<br>-               break;<br>-       default:<br>-             ast_data_add_str(enum_node, "text", "unknown");<br>-          break;<br>-       }<br>-    ast_data_add_int(enum_node, "value", queue->announceposition);<br>-<br>-       /* add queue members */<br>-      im = ao2_iterator_init(queue->members, 0);<br>-        while ((member = ao2_iterator_next(&im))) {<br>-              if (!data_members) {<br>-                 data_members = ast_data_add_node(data_queue, "members");<br>-                   if (!data_members) {<br>-                         ao2_ref(member, -1);<br>-                         continue;<br>-                    }<br>-            }<br>-<br>-         data_member = ast_data_add_node(data_members, "member");<br>-           if (!data_member) {<br>-                  ao2_ref(member, -1);<br>-                 continue;<br>-            }<br>-<br>-         ast_data_add_structure(member, data_member, member);<br>-<br>-              ao2_ref(member, -1);<br>- }<br>-    ao2_iterator_destroy(&im);<br>-<br>-    /* include the callers inside the result. */<br>- if (queue->head) {<br>-                for (qe = queue->head; qe; qe = qe->next) {<br>-                    if (!data_callers) {<br>-                         data_callers = ast_data_add_node(data_queue, "callers");<br>-                           if (!data_callers) {<br>-                                 continue;<br>-                            }<br>-                    }<br>-<br>-                 data_caller = ast_data_add_node(data_callers, "caller");<br>-                   if (!data_caller) {<br>-                          continue;<br>-                    }<br>-<br>-                 ast_data_add_structure(queue_ent, data_caller, qe);<br>-<br>-                       /* add the caller channel. */<br>-                        data_caller_channel = ast_data_add_node(data_caller, "channel");<br>-                   if (!data_caller_channel) {<br>-                          continue;<br>-                    }<br>-<br>-                 ast_channel_data_add_structure(data_caller_channel, qe->chan, 1);<br>-         }<br>-    }<br>-<br>- /* if this queue doesn't match remove the added queue. */<br>-        if (!ast_data_search_match(search, data_queue)) {<br>-            ast_data_remove_node(data_root, data_queue);<br>- }<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Callback used to generate the queues tree.<br>- * \param[in] search The search pattern tree.<br>- * \retval NULL on error.<br>- * \retval non-NULL The generated tree.<br>- */<br>-static int queues_data_provider_get(const struct ast_data_search *search,<br>- struct ast_data *data_root)<br>-{<br>-      struct ao2_iterator i;<br>-       struct call_queue *queue, *queue_realtime = NULL;<br>-    struct ast_config *cfg;<br>-<br>-   /* load realtime queues. */<br>-  cfg = ast_load_realtime_multientry("queues", "name LIKE", "%", SENTINEL);<br>-      if (cfg) {<br>-           char *category = NULL;<br>-               while ((category = ast_category_browse(cfg, category))) {<br>-                    const char *queuename = ast_variable_retrieve(cfg, category, "name");<br>-                      if ((queue = find_load_queue_rt_friendly(queuename))) {<br>-                              queue_unref(queue);<br>-                  }<br>-            }<br>-            ast_config_destroy(cfg);<br>-     }<br>-<br>- /* static queues. */<br>- i = ao2_iterator_init(queues, 0);<br>-    while ((queue = ao2_iterator_next(&i))) {<br>-                ao2_lock(queue);<br>-             if (queue->realtime) {<br>-                    queue_realtime = find_load_queue_rt_friendly(queue->name);<br>-                        if (!queue_realtime) {<br>-                               ao2_unlock(queue);<br>-                           queue_unref(queue);<br>-                          continue;<br>-                    }<br>-                    queue_unref(queue_realtime);<br>-         }<br>-<br>-         queues_data_provider_get_helper(search, data_root, queue);<br>-           ao2_unlock(queue);<br>-           queue_unref(queue);<br>-  }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     return 0;<br>-}<br>-<br>-static const struct ast_data_handler queues_data_provider = {<br>-     .version = AST_DATA_HANDLER_VERSION,<br>- .get = queues_data_provider_get<br>-};<br>-<br>-static const struct ast_data_entry queue_data_providers[] = {<br>-      AST_DATA_ENTRY("asterisk/application/queue/list", &queues_data_provider),<br>-};<br>-<br> static struct stasis_message_router *agent_router;<br> static struct stasis_forward *topic_forwarder;<br> <br>@@ -11221,8 +10951,6 @@<br>     ast_custom_function_unregister(&queuegetchannel_function);<br>        ast_custom_function_unregister(&queuewaitingcount_function);<br>      ast_custom_function_unregister(&queuememberpenalty_function);<br>-<br>- ast_data_unregister(NULL);<br> <br>         device_state_sub = stasis_unsubscribe_and_join(device_state_sub);<br> <br>@@ -11301,8 +11029,6 @@<br>         if (queue_persistent_members) {<br>               reload_queue_members();<br>       }<br>-<br>- ast_data_register_multiple(queue_data_providers, ARRAY_LEN(queue_data_providers));<br> <br>         err |= ast_cli_register_multiple(cli_queue, ARRAY_LEN(cli_queue));<br>    err |= ast_register_application_xml(app, queue_exec);<br>diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c<br>index 783cab6..e5fa916 100644<br>--- a/apps/app_voicemail.c<br>+++ b/apps/app_voicemail.c<br>@@ -12914,147 +12914,6 @@<br>     AST_CLI_DEFINE(handle_voicemail_reload, "Reload voicemail configuration"),<br> };<br> <br>-#ifdef IMAP_STORAGE<br>-   #define DATA_EXPORT_VM_USERS(USER)                                      \<br>-            USER(ast_vm_user, context, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, mailbox, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, password, AST_DATA_PASSWORD)                  \<br>-            USER(ast_vm_user, fullname, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, email, AST_DATA_STRING)                       \<br>-            USER(ast_vm_user, emailsubject, AST_DATA_STRING)                \<br>-            USER(ast_vm_user, emailbody, AST_DATA_STRING)                   \<br>-            USER(ast_vm_user, pager, AST_DATA_STRING)                       \<br>-            USER(ast_vm_user, serveremail, AST_DATA_STRING)                 \<br>-            USER(ast_vm_user, fromstring, AST_DATA_STRING)                  \<br>-            USER(ast_vm_user, language, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, zonetag, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, callback, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, dialout, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, uniqueid, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, exit, AST_DATA_STRING)                        \<br>-            USER(ast_vm_user, attachfmt, AST_DATA_STRING)                   \<br>-            USER(ast_vm_user, flags, AST_DATA_UNSIGNED_INTEGER)             \<br>-            USER(ast_vm_user, saydurationm, AST_DATA_INTEGER)               \<br>-            USER(ast_vm_user, maxmsg, AST_DATA_INTEGER)                     \<br>-            USER(ast_vm_user, maxdeletedmsg, AST_DATA_INTEGER)              \<br>-            USER(ast_vm_user, maxsecs, AST_DATA_INTEGER)                    \<br>-            USER(ast_vm_user, imapuser, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, imappassword, AST_DATA_STRING)                \<br>-            USER(ast_vm_user, imapvmshareid, AST_DATA_STRING)               \<br>-            USER(ast_vm_user, volgain, AST_DATA_DOUBLE)<br>-#else<br>-  #define DATA_EXPORT_VM_USERS(USER)                                      \<br>-            USER(ast_vm_user, context, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, mailbox, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, password, AST_DATA_PASSWORD)                  \<br>-            USER(ast_vm_user, fullname, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, email, AST_DATA_STRING)                       \<br>-            USER(ast_vm_user, emailsubject, AST_DATA_STRING)                \<br>-            USER(ast_vm_user, emailbody, AST_DATA_STRING)                   \<br>-            USER(ast_vm_user, pager, AST_DATA_STRING)                       \<br>-            USER(ast_vm_user, serveremail, AST_DATA_STRING)                 \<br>-            USER(ast_vm_user, fromstring, AST_DATA_STRING)                  \<br>-            USER(ast_vm_user, language, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, zonetag, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, callback, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, dialout, AST_DATA_STRING)                     \<br>-            USER(ast_vm_user, uniqueid, AST_DATA_STRING)                    \<br>-            USER(ast_vm_user, exit, AST_DATA_STRING)                        \<br>-            USER(ast_vm_user, attachfmt, AST_DATA_STRING)                   \<br>-            USER(ast_vm_user, flags, AST_DATA_UNSIGNED_INTEGER)             \<br>-            USER(ast_vm_user, saydurationm, AST_DATA_INTEGER)               \<br>-            USER(ast_vm_user, maxmsg, AST_DATA_INTEGER)                     \<br>-            USER(ast_vm_user, maxdeletedmsg, AST_DATA_INTEGER)              \<br>-            USER(ast_vm_user, maxsecs, AST_DATA_INTEGER)                    \<br>-            USER(ast_vm_user, volgain, AST_DATA_DOUBLE)<br>-#endif<br>-<br>-AST_DATA_STRUCTURE(ast_vm_user, DATA_EXPORT_VM_USERS);<br>-<br>-#define DATA_EXPORT_VM_ZONES(ZONE)                        \<br>-    ZONE(vm_zone, name, AST_DATA_STRING)            \<br>-    ZONE(vm_zone, timezone, AST_DATA_STRING)        \<br>-    ZONE(vm_zone, msg_format, AST_DATA_STRING)<br>-<br>-AST_DATA_STRUCTURE(vm_zone, DATA_EXPORT_VM_ZONES);<br>-<br>-/*!<br>- * \internal<br>- * \brief Add voicemail user to the data_root.<br>- * \param[in] search The search tree.<br>- * \param[in] data_root The main result node.<br>- * \param[in] user The voicemail user.<br>- */<br>-static int vm_users_data_provider_get_helper(const struct ast_data_search *search,<br>-    struct ast_data *data_root, struct ast_vm_user *user)<br>-{<br>-      struct ast_data *data_user, *data_zone;<br>-      struct ast_data *data_state;<br>- struct vm_zone *zone = NULL;<br>- int urgentmsg = 0, newmsg = 0, oldmsg = 0;<br>-   char ext_context[256] = "";<br>-<br>-     data_user = ast_data_add_node(data_root, "user");<br>-  if (!data_user) {<br>-            return -1;<br>-   }<br>-<br>- ast_data_add_structure(ast_vm_user, data_user, user);<br>-<br>-     AST_LIST_LOCK(&zones);<br>-   AST_LIST_TRAVERSE(&zones, zone, list) {<br>-          if (!strcmp(zone->name, user->zonetag)) {<br>-                      break;<br>-               }<br>-    }<br>-    AST_LIST_UNLOCK(&zones);<br>-<br>-      /* state */<br>-  data_state = ast_data_add_node(data_user, "state");<br>-        if (!data_state) {<br>-           return -1;<br>-   }<br>-    snprintf(ext_context, sizeof(ext_context), "%s@%s", user->mailbox, user->context);<br>-   inboxcount2(ext_context, &urgentmsg, &newmsg, &oldmsg);<br>-  ast_data_add_int(data_state, "urgentmsg", urgentmsg);<br>-      ast_data_add_int(data_state, "newmsg", newmsg);<br>-    ast_data_add_int(data_state, "oldmsg", oldmsg);<br>-<br>- if (zone) {<br>-          data_zone = ast_data_add_node(data_user, "zone");<br>-          ast_data_add_structure(vm_zone, data_zone, zone);<br>-    }<br>-<br>- if (!ast_data_search_match(search, data_user)) {<br>-             ast_data_remove_node(data_root, data_user);<br>-  }<br>-<br>- return 0;<br>-}<br>-<br>-static int vm_users_data_provider_get(const struct ast_data_search *search,<br>-       struct ast_data *data_root)<br>-{<br>-      struct ast_vm_user *user;<br>-<br>- AST_LIST_LOCK(&users);<br>-   AST_LIST_TRAVERSE(&users, user, list) {<br>-          vm_users_data_provider_get_helper(search, data_root, user);<br>-  }<br>-    AST_LIST_UNLOCK(&users);<br>-<br>-      return 0;<br>-}<br>-<br>-static const struct ast_data_handler vm_users_data_provider = {<br>-   .version = AST_DATA_HANDLER_VERSION,<br>- .get = vm_users_data_provider_get<br>-};<br>-<br>-static const struct ast_data_entry vm_data_providers[] = {<br>-       AST_DATA_ENTRY("asterisk/application/voicemail/list", &vm_users_data_provider)<br>-};<br>-<br> static void poll_subscribed_mailbox(struct mwi_sub *mwi_sub)<br> {<br>       int new = 0, old = 0, urgent = 0;<br>@@ -14997,7 +14856,6 @@<br>    res |= ast_custom_function_unregister(&vm_info_acf);<br>      res |= ast_manager_unregister("VoicemailUsersList");<br>        res |= ast_manager_unregister("VoicemailRefresh");<br>- res |= ast_data_unregister(NULL);<br> #ifdef TEST_FRAMEWORK<br>     res |= AST_TEST_UNREGISTER(test_voicemail_vmsayname);<br>         res |= AST_TEST_UNREGISTER(test_voicemail_msgcount);<br>@@ -15107,7 +14965,6 @@<br>         }<br> <br>  ast_cli_register_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));<br>-  ast_data_register_multiple(vm_data_providers, ARRAY_LEN(vm_data_providers));<br> <br> #ifdef TEST_FRAMEWORK<br>       ast_install_vm_test_functions(vm_test_create_user, vm_test_destroy_user);<br>diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c<br>index 72fbe6e..4f717ff 100644<br>--- a/channels/chan_dahdi.c<br>+++ b/channels/chan_dahdi.c<br>@@ -119,7 +119,6 @@<br> #include "asterisk/devicestate.h"<br> #include "asterisk/paths.h"<br> #include "asterisk/ccss.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/features_config.h"<br> #include "asterisk/bridge.h"<br> #include "asterisk/stasis_channels.h"<br>@@ -790,78 +789,6 @@<br>    "Callwait",<br>         "Threeway"<br> };<br>-<br>-#define DATA_EXPORT_DAHDI_PVT(MEMBER)                                    \<br>-    MEMBER(dahdi_pvt, cid_rxgain, AST_DATA_DOUBLE)                  \<br>-    MEMBER(dahdi_pvt, rxgain, AST_DATA_DOUBLE)                      \<br>-    MEMBER(dahdi_pvt, txgain, AST_DATA_DOUBLE)                      \<br>-    MEMBER(dahdi_pvt, txdrc, AST_DATA_DOUBLE)                       \<br>-    MEMBER(dahdi_pvt, rxdrc, AST_DATA_DOUBLE)                       \<br>-    MEMBER(dahdi_pvt, adsi, AST_DATA_BOOLEAN)                       \<br>-    MEMBER(dahdi_pvt, answeronpolarityswitch, AST_DATA_BOOLEAN)     \<br>-    MEMBER(dahdi_pvt, busydetect, AST_DATA_BOOLEAN)                 \<br>-    MEMBER(dahdi_pvt, callreturn, AST_DATA_BOOLEAN)                 \<br>-    MEMBER(dahdi_pvt, callwaiting, AST_DATA_BOOLEAN)                \<br>-    MEMBER(dahdi_pvt, callwaitingcallerid, AST_DATA_BOOLEAN)        \<br>-    MEMBER(dahdi_pvt, cancallforward, AST_DATA_BOOLEAN)             \<br>-    MEMBER(dahdi_pvt, canpark, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, confirmanswer, AST_DATA_BOOLEAN)              \<br>-    MEMBER(dahdi_pvt, destroy, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, didtdd, AST_DATA_BOOLEAN)                     \<br>-    MEMBER(dahdi_pvt, dialednone, AST_DATA_BOOLEAN)                 \<br>-    MEMBER(dahdi_pvt, dialing, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, digital, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, dnd, AST_DATA_BOOLEAN)                        \<br>-    MEMBER(dahdi_pvt, echobreak, AST_DATA_BOOLEAN)                  \<br>-    MEMBER(dahdi_pvt, echocanbridged, AST_DATA_BOOLEAN)             \<br>-    MEMBER(dahdi_pvt, echocanon, AST_DATA_BOOLEAN)                  \<br>-    MEMBER(dahdi_pvt, faxhandled, AST_DATA_BOOLEAN)                 \<br>-    MEMBER(dahdi_pvt, usefaxbuffers, AST_DATA_BOOLEAN)              \<br>-    MEMBER(dahdi_pvt, bufferoverrideinuse, AST_DATA_BOOLEAN)        \<br>-    MEMBER(dahdi_pvt, firstradio, AST_DATA_BOOLEAN)                 \<br>-    MEMBER(dahdi_pvt, hanguponpolarityswitch, AST_DATA_BOOLEAN)     \<br>-    MEMBER(dahdi_pvt, hardwaredtmf, AST_DATA_BOOLEAN)               \<br>-    MEMBER(dahdi_pvt, hidecallerid, AST_DATA_BOOLEAN)               \<br>-    MEMBER(dahdi_pvt, hidecalleridname, AST_DATA_BOOLEAN)           \<br>-    MEMBER(dahdi_pvt, ignoredtmf, AST_DATA_BOOLEAN)                 \<br>-    MEMBER(dahdi_pvt, immediate, AST_DATA_BOOLEAN)                  \<br>-    MEMBER(dahdi_pvt, inalarm, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, mate, AST_DATA_BOOLEAN)                       \<br>-    MEMBER(dahdi_pvt, outgoing, AST_DATA_BOOLEAN)                   \<br>-    MEMBER(dahdi_pvt, permcallwaiting, AST_DATA_BOOLEAN)            \<br>-    MEMBER(dahdi_pvt, priindication_oob, AST_DATA_BOOLEAN)          \<br>-    MEMBER(dahdi_pvt, priexclusive, AST_DATA_BOOLEAN)               \<br>-    MEMBER(dahdi_pvt, pulse, AST_DATA_BOOLEAN)                      \<br>-    MEMBER(dahdi_pvt, pulsedial, AST_DATA_BOOLEAN)                  \<br>-    MEMBER(dahdi_pvt, restartpending, AST_DATA_BOOLEAN)             \<br>-    MEMBER(dahdi_pvt, restrictcid, AST_DATA_BOOLEAN)                \<br>-    MEMBER(dahdi_pvt, threewaycalling, AST_DATA_BOOLEAN)            \<br>-    MEMBER(dahdi_pvt, transfer, AST_DATA_BOOLEAN)                   \<br>-    MEMBER(dahdi_pvt, use_callerid, AST_DATA_BOOLEAN)               \<br>-    MEMBER(dahdi_pvt, use_callingpres, AST_DATA_BOOLEAN)            \<br>-    MEMBER(dahdi_pvt, usedistinctiveringdetection, AST_DATA_BOOLEAN)        \<br>-    MEMBER(dahdi_pvt, dahditrcallerid, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, transfertobusy, AST_DATA_BOOLEAN)                     \<br>-    MEMBER(dahdi_pvt, mwimonitor_neon, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, mwimonitor_fsk, AST_DATA_BOOLEAN)                     \<br>-    MEMBER(dahdi_pvt, mwimonitor_rpas, AST_DATA_BOOLEAN)                    \<br>-    MEMBER(dahdi_pvt, mwimonitoractive, AST_DATA_BOOLEAN)                   \<br>-    MEMBER(dahdi_pvt, mwisendactive, AST_DATA_BOOLEAN)                      \<br>-    MEMBER(dahdi_pvt, inservice, AST_DATA_BOOLEAN)                          \<br>-    MEMBER(dahdi_pvt, locallyblocked, AST_DATA_UNSIGNED_INTEGER)            \<br>-    MEMBER(dahdi_pvt, remotelyblocked, AST_DATA_UNSIGNED_INTEGER)           \<br>-    MEMBER(dahdi_pvt, manages_span_alarms, AST_DATA_BOOLEAN)                \<br>-    MEMBER(dahdi_pvt, use_smdi, AST_DATA_BOOLEAN)                           \<br>-    MEMBER(dahdi_pvt, context, AST_DATA_STRING)                             \<br>-    MEMBER(dahdi_pvt, defcontext, AST_DATA_STRING)                          \<br>-    MEMBER(dahdi_pvt, description, AST_DATA_STRING)                         \<br>-    MEMBER(dahdi_pvt, exten, AST_DATA_STRING)                               \<br>-    MEMBER(dahdi_pvt, language, AST_DATA_STRING)                            \<br>-    MEMBER(dahdi_pvt, mohinterpret, AST_DATA_STRING)                        \<br>-    MEMBER(dahdi_pvt, mohsuggest, AST_DATA_STRING)                          \<br>-    MEMBER(dahdi_pvt, parkinglot, AST_DATA_STRING)<br>-<br>-AST_DATA_STRUCTURE(dahdi_pvt, DATA_EXPORT_DAHDI_PVT);<br> <br> static struct dahdi_pvt *iflist = NULL;  /*!< Main interface list start */<br> static struct dahdi_pvt *ifend = NULL;   /*!< Main interface list end */<br>@@ -17313,7 +17240,6 @@<br>   ast_manager_unregister("PRIDebugFileSet");<br>  ast_manager_unregister("PRIDebugFileUnset");<br> #endif /* defined(HAVE_PRI) */<br>-      ast_data_unregister(NULL);<br>    ast_channel_unregister(&dahdi_tech);<br> <br>   /* Hangup all interfaces if they have an owner */<br>@@ -19356,163 +19282,6 @@<br> }<br> <br> /*!<br>- * \internal<br>- * \brief Callback used to generate the dahdi status tree.<br>- * \param[in] search The search pattern tree.<br>- * \retval NULL on error.<br>- * \retval non-NULL The generated tree.<br>- */<br>-static int dahdi_status_data_provider_get(const struct ast_data_search *search,<br>-          struct ast_data *data_root)<br>-{<br>-      int ctl, res, span;<br>-  struct ast_data *data_span, *data_alarms;<br>-    struct dahdi_spaninfo s;<br>-<br>-  ctl = open("/dev/dahdi/ctl", O_RDWR);<br>-      if (ctl < 0) {<br>-            ast_log(LOG_ERROR, "No DAHDI found. Unable to open /dev/dahdi/ctl: %s\n", strerror(errno));<br>-                return -1;<br>-   }<br>-    for (span = 1; span < DAHDI_MAX_SPANS; ++span) {<br>-          s.spanno = span;<br>-             res = ioctl(ctl, DAHDI_SPANSTAT, &s);<br>-            if (res) {<br>-                   continue;<br>-            }<br>-<br>-         data_span = ast_data_add_node(data_root, "span");<br>-          if (!data_span) {<br>-                    continue;<br>-            }<br>-            ast_data_add_str(data_span, "description", s.desc);<br>-<br>-             /* insert the alarms status */<br>-               data_alarms = ast_data_add_node(data_span, "alarms");<br>-              if (!data_alarms) {<br>-                  continue;<br>-            }<br>-<br>-         ast_data_add_bool(data_alarms, "BLUE", s.alarms & DAHDI_ALARM_BLUE);<br>-           ast_data_add_bool(data_alarms, "YELLOW", s.alarms & DAHDI_ALARM_YELLOW);<br>-               ast_data_add_bool(data_alarms, "RED", s.alarms & DAHDI_ALARM_RED);<br>-             ast_data_add_bool(data_alarms, "LOOPBACK", s.alarms & DAHDI_ALARM_LOOPBACK);<br>-           ast_data_add_bool(data_alarms, "RECOVER", s.alarms & DAHDI_ALARM_RECOVER);<br>-             ast_data_add_bool(data_alarms, "NOTOPEN", s.alarms & DAHDI_ALARM_NOTOPEN);<br>-<br>-          ast_data_add_int(data_span, "irqmisses", s.irqmisses);<br>-             ast_data_add_int(data_span, "bpviol", s.bpvcount);<br>-         ast_data_add_int(data_span, "crc4", s.crc4count);<br>-          ast_data_add_str(data_span, "framing",        s.lineconfig & DAHDI_CONFIG_D4 ? "D4" :<br>-                                                        s.lineconfig & DAHDI_CONFIG_ESF ? "ESF" :<br>-                                                      s.lineconfig & DAHDI_CONFIG_CCS ? "CCS" :<br>-                                                      "CAS");<br>-            ast_data_add_str(data_span, "coding", s.lineconfig & DAHDI_CONFIG_B8ZS ? "B8ZS" :<br>-                                                    s.lineconfig & DAHDI_CONFIG_HDB3 ? "HDB3" :<br>-                                                    s.lineconfig & DAHDI_CONFIG_AMI ? "AMI" :<br>-                                                      "Unknown");<br>-                ast_data_add_str(data_span, "options",        s.lineconfig & DAHDI_CONFIG_CRC4 ?<br>-                                                       s.lineconfig & DAHDI_CONFIG_NOTOPEN ? "CRC4/YEL" : "CRC4" :<br>-                                                  s.lineconfig & DAHDI_CONFIG_NOTOPEN ? "YEL" : "");<br>-           ast_data_add_str(data_span, "lbo", lbostr[s.lbo]);<br>-<br>-              /* if this span doesn't match remove it. */<br>-              if (!ast_data_search_match(search, data_span)) {<br>-                     ast_data_remove_node(data_root, data_span);<br>-          }<br>-    }<br>-    close(ctl);<br>-<br>-       return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Callback used to generate the dahdi channels tree.<br>- * \param[in] search The search pattern tree.<br>- * \retval NULL on error.<br>- * \retval non-NULL The generated tree.<br>- */<br>-static int dahdi_channels_data_provider_get(const struct ast_data_search *search,<br>-         struct ast_data *data_root)<br>-{<br>-      struct dahdi_pvt *tmp;<br>-       struct ast_data *data_channel;<br>-<br>-    ast_mutex_lock(&iflock);<br>- for (tmp = iflist; tmp; tmp = tmp->next) {<br>-                data_channel = ast_data_add_node(data_root, "channel");<br>-            if (!data_channel) {<br>-                 continue;<br>-            }<br>-<br>-         ast_data_add_structure(dahdi_pvt, data_channel, tmp);<br>-<br>-             /* if this channel doesn't match remove it. */<br>-           if (!ast_data_search_match(search, data_channel)) {<br>-                  ast_data_remove_node(data_root, data_channel);<br>-               }<br>-    }<br>-    ast_mutex_unlock(&iflock);<br>-<br>-    return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Callback used to generate the dahdi channels tree.<br>- * \param[in] search The search pattern tree.<br>- * \retval NULL on error.<br>- * \retval non-NULL The generated tree.<br>- */<br>-static int dahdi_version_data_provider_get(const struct ast_data_search *search,<br>-          struct ast_data *data_root)<br>-{<br>-      int pseudo_fd = -1;<br>-  struct dahdi_versioninfo vi = {<br>-              .version = "Unknown",<br>-              .echo_canceller = "Unknown"<br>-        };<br>-<br>-        if ((pseudo_fd = open("/dev/dahdi/ctl", O_RDONLY)) < 0) {<br>-               ast_log(LOG_ERROR, "Failed to open control file to get version.\n");<br>-               return -1;<br>-   }<br>-<br>- if (ioctl(pseudo_fd, DAHDI_GETVERSION, &vi)) {<br>-           ast_log(LOG_ERROR, "Failed to get DAHDI version: %s\n", strerror(errno));<br>-  }<br>-<br>- close(pseudo_fd);<br>-<br>- ast_data_add_str(data_root, "value", vi.version);<br>-  ast_data_add_str(data_root, "echocanceller", vi.echo_canceller);<br>-<br>-        return 0;<br>-}<br>-<br>-static const struct ast_data_handler dahdi_status_data_provider = {<br>-       .version = AST_DATA_HANDLER_VERSION,<br>- .get = dahdi_status_data_provider_get<br>-};<br>-<br>-static const struct ast_data_handler dahdi_channels_data_provider = {<br>-        .version = AST_DATA_HANDLER_VERSION,<br>- .get = dahdi_channels_data_provider_get<br>-};<br>-<br>-static const struct ast_data_handler dahdi_version_data_provider = {<br>-       .version = AST_DATA_HANDLER_VERSION,<br>- .get = dahdi_version_data_provider_get<br>-};<br>-<br>-static const struct ast_data_entry dahdi_data_providers[] = {<br>-       AST_DATA_ENTRY("asterisk/channel/dahdi/status", &dahdi_status_data_provider),<br>-  AST_DATA_ENTRY("asterisk/channel/dahdi/channels", &dahdi_channels_data_provider),<br>-      AST_DATA_ENTRY("asterisk/channel/dahdi/version", &dahdi_version_data_provider)<br>-};<br>-<br>-/*!<br>  * \brief Load the module<br>  *<br>  * Module loading including tests for configuration or dependencies.<br>@@ -19608,8 +19377,6 @@<br> #endif<br> <br>       ast_cli_register_multiple(dahdi_cli, ARRAY_LEN(dahdi_cli));<br>-  /* register all the data providers */<br>-        ast_data_register_multiple(dahdi_data_providers, ARRAY_LEN(dahdi_data_providers));<br>    memset(round_robin, 0, sizeof(round_robin));<br>  ast_manager_register_xml("DAHDITransfer", 0, action_transfer);<br>      ast_manager_register_xml("DAHDIHangup", 0, action_transferhangup);<br>diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c<br>index d15b55d..f40873e 100644<br>--- a/channels/chan_iax2.c<br>+++ b/channels/chan_iax2.c<br>@@ -106,7 +106,6 @@<br> #include "asterisk/timing.h"<br> #include "asterisk/taskprocessor.h"<br> #include "asterisk/test.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/security_events.h"<br> #include "asterisk/stasis_endpoints.h"<br> #include "asterisk/bridge.h"<br>@@ -1947,19 +1946,6 @@<br> <br>    ao2_ref(cap, -1);<br> <br>- return res;<br>-}<br>-<br>-static int iax2_data_add_codecs(struct ast_data *root, const char *node_name, iax2_format formats)<br>-{<br>-  int res;<br>-     struct ast_format_cap *cap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);<br>-      if (!cap) {<br>-          return -1;<br>-   }<br>-    iax2_format_compatibility_bitfield2cap(formats, cap);<br>-        res = ast_data_add_codecs(root, node_name, cap);<br>-     ao2_ref(cap, -1);<br>     return res;<br> }<br> <br>@@ -14555,129 +14541,6 @@<br> #endif /* IAXTESTS */<br> };<br> <br>-#ifdef TEST_FRAMEWORK<br>-AST_TEST_DEFINE(test_iax2_peers_get)<br>-{<br>-     struct ast_data_query query = {<br>-              .path = "/asterisk/channel/iax2/peers",<br>-            .search = "peers/peer/name=test_peer_data_provider"<br>-        };<br>-   struct ast_data *node;<br>-       struct iax2_peer *peer;<br>-<br>-   switch (cmd) {<br>-               case TEST_INIT:<br>-                      info->name = "iax2_peers_get_data_test";<br>-                        info->category = "/main/data/iax2/peers/";<br>-                      info->summary = "IAX2 peers data providers unit test";<br>-                  info->description =<br>-                               "Tests whether the IAX2 peers data provider implementation works as expected.";<br>-                    return AST_TEST_NOT_RUN;<br>-             case TEST_EXECUTE:<br>-                   break;<br>-       }<br>-<br>- /* build a test peer */<br>-      peer = build_peer("test_peer_data_provider", NULL, NULL, 0);<br>-       if (!peer) {<br>-         return AST_TEST_FAIL;<br>-        }<br>-    peer->expiry= 1010;<br>-       ao2_link(peers, peer);<br>-<br>-    node = ast_data_get(&query);<br>-     if (!node) {<br>-         ao2_unlink(peers, peer);<br>-             peer_unref(peer);<br>-            return AST_TEST_FAIL;<br>-        }<br>-<br>- /* check returned data node. */<br>-      if (strcmp(ast_data_retrieve_string(node, "peer/name"), "test_peer_data_provider")) {<br>-            ao2_unlink(peers, peer);<br>-             peer_unref(peer);<br>-            ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- if (ast_data_retrieve_int(node, "peer/expiry") != 1010) {<br>-          ao2_unlink(peers, peer);<br>-             peer_unref(peer);<br>-            ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- /* release resources */<br>-      ast_data_free(node);<br>-<br>-      ao2_unlink(peers, peer);<br>-     peer_unref(peer);<br>-<br>- return AST_TEST_PASS;<br>-}<br>-<br>-AST_TEST_DEFINE(test_iax2_users_get)<br>-{<br>-      struct ast_data_query query = {<br>-              .path = "/asterisk/channel/iax2/users",<br>-            .search = "users/user/name=test_user_data_provider"<br>-        };<br>-   struct ast_data *node;<br>-       struct iax2_user *user;<br>-<br>-   switch (cmd) {<br>-               case TEST_INIT:<br>-                      info->name = "iax2_users_get_data_test";<br>-                        info->category = "/main/data/iax2/users/";<br>-                      info->summary = "IAX2 users data providers unit test";<br>-                  info->description =<br>-                               "Tests whether the IAX2 users data provider implementation works as expected.";<br>-                    return AST_TEST_NOT_RUN;<br>-             case TEST_EXECUTE:<br>-                   break;<br>-       }<br>-<br>- user = build_user("test_user_data_provider", NULL, NULL, 0);<br>-       if (!user) {<br>-         ast_test_status_update(test, "Failed to build a test user\n");<br>-             return AST_TEST_FAIL;<br>-        }<br>-    user->amaflags = 1010;<br>-    ao2_link(users, user);<br>-<br>-    node = ast_data_get(&query);<br>-     if (!node) {<br>-         ast_test_status_update(test, "The data query to find our test user failed\n");<br>-             ao2_unlink(users, user);<br>-             user_unref(user);<br>-            return AST_TEST_FAIL;<br>-        }<br>-<br>- if (strcmp(ast_data_retrieve_string(node, "user/name"), "test_user_data_provider")) {<br>-            ast_test_status_update(test, "Our data results did not return the test user created in the previous step.\n");<br>-             ao2_unlink(users, user);<br>-             user_unref(user);<br>-            ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- if (ast_data_retrieve_int(node, "user/amaflags/value") != 1010) {<br>-          ast_test_status_update(test, "The amaflags field in our test user was '%d' not the expected value '1010'\n", ast_data_retrieve_int(node, "user/amaflags/value"));<br>-                ao2_unlink(users, user);<br>-             user_unref(user);<br>-            ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- ast_data_free(node);<br>-<br>-      ao2_unlink(users, user);<br>-     user_unref(user);<br>-<br>- return AST_TEST_PASS;<br>-}<br>-#endif<br>-<br> static void cleanup_thread_list(void *head)<br> {<br>       AST_LIST_HEAD(iax2_thread_list, iax2_thread);<br>@@ -14743,11 +14606,6 @@<br>       ast_manager_unregister( "IAXnetstats" );<br>    ast_manager_unregister( "IAXregistry" );<br>    ast_unregister_application(papp);<br>-#ifdef TEST_FRAMEWORK<br>-    AST_TEST_UNREGISTER(test_iax2_peers_get);<br>-    AST_TEST_UNREGISTER(test_iax2_users_get);<br>-#endif<br>-   ast_data_unregister(NULL);<br>    ast_cli_unregister_multiple(cli_iax2, ARRAY_LEN(cli_iax2));<br>   ast_unregister_switch(&iax2_switch);<br>      ast_channel_unregister(&iax2_tech);<br>@@ -14889,191 +14747,6 @@<br>    return -1;<br> }<br> <br>-<br>-#define DATA_EXPORT_IAX2_PEER(MEMBER)                            \<br>-    MEMBER(iax2_peer, name, AST_DATA_STRING)                \<br>-    MEMBER(iax2_peer, username, AST_DATA_STRING)            \<br>-    MEMBER(iax2_peer, secret, AST_DATA_PASSWORD)            \<br>-    MEMBER(iax2_peer, dbsecret, AST_DATA_PASSWORD)          \<br>-    MEMBER(iax2_peer, outkey, AST_DATA_STRING)              \<br>-    MEMBER(iax2_peer, regexten, AST_DATA_STRING)            \<br>-    MEMBER(iax2_peer, context, AST_DATA_STRING)             \<br>-    MEMBER(iax2_peer, peercontext, AST_DATA_STRING)         \<br>-    MEMBER(iax2_peer, mailbox, AST_DATA_STRING)             \<br>-    MEMBER(iax2_peer, mohinterpret, AST_DATA_STRING)        \<br>-    MEMBER(iax2_peer, mohsuggest, AST_DATA_STRING)          \<br>-    MEMBER(iax2_peer, inkeys, AST_DATA_STRING)              \<br>-    MEMBER(iax2_peer, cid_num, AST_DATA_STRING)             \<br>-    MEMBER(iax2_peer, cid_name, AST_DATA_STRING)            \<br>-    MEMBER(iax2_peer, zonetag, AST_DATA_STRING)             \<br>-    MEMBER(iax2_peer, parkinglot, AST_DATA_STRING)          \<br>-    MEMBER(iax2_peer, expiry, AST_DATA_SECONDS)             \<br>-    MEMBER(iax2_peer, callno, AST_DATA_INTEGER)             \<br>-    MEMBER(iax2_peer, lastms, AST_DATA_MILLISECONDS)        \<br>-    MEMBER(iax2_peer, maxms, AST_DATA_MILLISECONDS)         \<br>-    MEMBER(iax2_peer, pokefreqok, AST_DATA_MILLISECONDS)    \<br>-    MEMBER(iax2_peer, pokefreqnotok, AST_DATA_MILLISECONDS) \<br>-    MEMBER(iax2_peer, historicms, AST_DATA_INTEGER)         \<br>-    MEMBER(iax2_peer, smoothing, AST_DATA_BOOLEAN)          \<br>-        MEMBER(iax2_peer, maxcallno, AST_DATA_INTEGER)<br>-<br>-AST_DATA_STRUCTURE(iax2_peer, DATA_EXPORT_IAX2_PEER);<br>-<br>-static int peers_data_provider_get(const struct ast_data_search *search,<br>-  struct ast_data *data_root)<br>-{<br>-      struct ast_data *data_peer;<br>-  struct iax2_peer *peer;<br>-      struct ao2_iterator i;<br>-       char status[20];<br>-     struct ast_str *encmethods = ast_str_alloca(256);<br>-<br>- i = ao2_iterator_init(peers, 0);<br>-     while ((peer = ao2_iterator_next(&i))) {<br>-         data_peer = ast_data_add_node(data_root, "peer");<br>-          if (!data_peer) {<br>-                    peer_unref(peer);<br>-                    continue;<br>-            }<br>-<br>-         ast_data_add_structure(iax2_peer, data_peer, peer);<br>-<br>-               iax2_data_add_codecs(data_peer, "codecs", peer->capability);<br>-<br>-         peer_status(peer, status, sizeof(status));<br>-           ast_data_add_str(data_peer, "status", status);<br>-<br>-          ast_data_add_str(data_peer, "host", ast_sockaddr_stringify_host(&peer->addr));<br>-<br>-           ast_data_add_str(data_peer, "mask", ast_sockaddr_stringify_addr(&peer->mask));<br>-<br>-           ast_data_add_int(data_peer, "port", ast_sockaddr_port(&peer->addr));<br>-<br>-             ast_data_add_bool(data_peer, "trunk", ast_test_flag64(peer, IAX_TRUNK));<br>-<br>-                ast_data_add_bool(data_peer, "dynamic", ast_test_flag64(peer, IAX_DYNAMIC));<br>-<br>-            encmethods_to_str(peer->encmethods, &encmethods);<br>-             ast_data_add_str(data_peer, "encryption", peer->encmethods ? ast_str_buffer(encmethods) : "no");<br>-<br>-           peer_unref(peer);<br>-<br>-         if (!ast_data_search_match(search, data_peer)) {<br>-                     ast_data_remove_node(data_root, data_peer);<br>-          }<br>-    }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     return 0;<br>-}<br>-<br>-#define DATA_EXPORT_IAX2_USER(MEMBER)                                        \<br>-        MEMBER(iax2_user, name, AST_DATA_STRING)                    \<br>-        MEMBER(iax2_user, dbsecret, AST_DATA_PASSWORD)                      \<br>-        MEMBER(iax2_user, accountcode, AST_DATA_STRING)                     \<br>-        MEMBER(iax2_user, mohinterpret, AST_DATA_STRING)            \<br>-        MEMBER(iax2_user, mohsuggest, AST_DATA_STRING)                      \<br>-        MEMBER(iax2_user, inkeys, AST_DATA_STRING)                  \<br>-        MEMBER(iax2_user, language, AST_DATA_STRING)                        \<br>-        MEMBER(iax2_user, cid_num, AST_DATA_STRING)                 \<br>-        MEMBER(iax2_user, cid_name, AST_DATA_STRING)                        \<br>-        MEMBER(iax2_user, parkinglot, AST_DATA_STRING)                      \<br>-        MEMBER(iax2_user, maxauthreq, AST_DATA_INTEGER)                     \<br>-        MEMBER(iax2_user, curauthreq, AST_DATA_INTEGER)<br>-<br>-AST_DATA_STRUCTURE(iax2_user, DATA_EXPORT_IAX2_USER);<br>-<br>-static int users_data_provider_get(const struct ast_data_search *search,<br>- struct ast_data *data_root)<br>-{<br>-      struct ast_data *data_user, *data_authmethods, *data_enum_node;<br>-      struct iax2_user *user;<br>-      struct ao2_iterator i;<br>-       struct ast_str *auth;<br>-        char *pstr = "";<br>-<br>-        if (!(auth = ast_str_create(90))) {<br>-          ast_log(LOG_ERROR, "Unable to create temporary string for storing 'secret'\n");<br>-            return 0;<br>-    }<br>-<br>- i = ao2_iterator_init(users, 0);<br>-     for (; (user = ao2_iterator_next(&i)); user_unref(user)) {<br>-               data_user = ast_data_add_node(data_root, "user");<br>-          if (!data_user) {<br>-                    continue;<br>-            }<br>-<br>-         ast_data_add_structure(iax2_user, data_user, user);<br>-<br>-               iax2_data_add_codecs(data_user, "codecs", user->capability);<br>-<br>-         if (!ast_strlen_zero(user->secret)) {<br>-                     ast_str_set(&auth, 0, "%s", user->secret);<br>-          } else if (!ast_strlen_zero(user->inkeys)) {<br>-                      ast_str_set(&auth, 0, "Key: %s", user->inkeys);<br>-             } else {<br>-                     ast_str_set(&auth, 0, "no secret");<br>-            }<br>-            ast_data_add_password(data_user, "secret", ast_str_buffer(auth));<br>-<br>-               ast_data_add_str(data_user, "context", user->contexts ? user->contexts->context : DEFAULT_CONTEXT);<br>-<br>-            /* authmethods */<br>-            data_authmethods = ast_data_add_node(data_user, "authmethods");<br>-            if (!data_authmethods) {<br>-                     ast_data_remove_node(data_root, data_user);<br>-                  continue;<br>-            }<br>-            ast_data_add_bool(data_authmethods, "rsa", user->authmethods & IAX_AUTH_RSA);<br>-               ast_data_add_bool(data_authmethods, "md5", user->authmethods & IAX_AUTH_MD5);<br>-               ast_data_add_bool(data_authmethods, "plaintext", user->authmethods & IAX_AUTH_PLAINTEXT);<br>-<br>-                /* amaflags */<br>-               data_enum_node = ast_data_add_node(data_user, "amaflags");<br>-         if (!data_enum_node) {<br>-                       ast_data_remove_node(data_root, data_user);<br>-                  continue;<br>-            }<br>-            ast_data_add_int(data_enum_node, "value", user->amaflags);<br>-              ast_data_add_str(data_enum_node, "text", ast_channel_amaflags2string(user->amaflags));<br>-<br>-               ast_data_add_bool(data_user, "access-control", ast_acl_list_is_empty(user->acl) ? 0 : 1);<br>-<br>-            if (ast_test_flag64(user, IAX_CODEC_NOCAP)) {<br>-                        pstr = "REQ only";<br>-         } else if (ast_test_flag64(user, IAX_CODEC_NOPREFS)) {<br>-                       pstr = "disabled";<br>-         } else {<br>-                     pstr = ast_test_flag64(user, IAX_CODEC_USER_FIRST) ? "caller" : "host";<br>-          }<br>-            ast_data_add_str(data_user, "codec-preferences", pstr);<br>-<br>-         if (!ast_data_search_match(search, data_user)) {<br>-                     ast_data_remove_node(data_root, data_user);<br>-          }<br>-    }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     ast_free(auth);<br>-      return 0;<br>-}<br>-<br>-static const struct ast_data_handler peers_data_provider = {<br>-      .version = AST_DATA_HANDLER_VERSION,<br>- .get = peers_data_provider_get<br>-};<br>-<br>-static const struct ast_data_handler users_data_provider = {<br>-        .version = AST_DATA_HANDLER_VERSION,<br>- .get = users_data_provider_get<br>-};<br>-<br>-static const struct ast_data_entry iax2_data_providers[] = {<br>-        AST_DATA_ENTRY("asterisk/channel/iax2/peers", &peers_data_provider),<br>-   AST_DATA_ENTRY("asterisk/channel/iax2/users", &users_data_provider),<br>-};<br>-<br> /*!<br>  * \brief Load the module<br>  *<br>@@ -15173,13 +14846,6 @@<br>           return AST_MODULE_LOAD_DECLINE;<br>       }<br> <br>-#ifdef TEST_FRAMEWORK<br>- AST_TEST_REGISTER(test_iax2_peers_get);<br>-      AST_TEST_REGISTER(test_iax2_users_get);<br>-#endif<br>-<br>-  /* Register AstData providers */<br>-     ast_data_register_multiple(iax2_data_providers, ARRAY_LEN(iax2_data_providers));<br>      ast_cli_register_multiple(cli_iax2, ARRAY_LEN(cli_iax2));<br> <br>  ast_register_application_xml(papp, iax2_prov_app);<br>diff --git a/channels/chan_sip.c b/channels/chan_sip.c<br>index aaeb01e..af82678 100644<br>--- a/channels/chan_sip.c<br>+++ b/channels/chan_sip.c<br>@@ -263,7 +263,6 @@<br> #include "asterisk/threadstorage.h"<br> #include "asterisk/translate.h"<br> #include "asterisk/ast_version.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/aoc.h"<br> #include "asterisk/message.h"<br> #include "sip/include/sip.h"<br>@@ -34530,75 +34529,6 @@<br>      return res;<br> }<br> <br>-AST_TEST_DEFINE(test_sip_peers_get)<br>-{<br>- struct sip_peer *peer;<br>-       struct ast_data *node;<br>-       struct ast_data_query query = {<br>-              .path = "/asterisk/channel/sip/peers",<br>-             .search = "peers/peer/name=test_peer_data_provider"<br>-        };<br>-<br>-        switch (cmd) {<br>-               case TEST_INIT:<br>-                      info->name = "sip_peers_get_data_test";<br>-                 info->category = "/main/data/sip/peers/";<br>-                       info->summary = "SIP peers data providers unit test";<br>-                   info->description =<br>-                               "Tests whether the SIP peers data provider implementation works as expected.";<br>-                     return AST_TEST_NOT_RUN;<br>-             case TEST_EXECUTE:<br>-                   break;<br>-       }<br>-<br>- /* Create the peer that we will retrieve. */<br>- peer = build_peer("test_peer_data_provider", NULL, NULL, 0, 0);<br>-    if (!peer) {<br>-         return AST_TEST_FAIL;<br>-        }<br>-    peer->type = SIP_TYPE_USER;<br>-       peer->call_limit = 10;<br>-    ao2_link(peers, peer);<br>-<br>-    /* retrieve the chan_sip/peers tree and check the created peer. */<br>-   node = ast_data_get(&query);<br>-     if (!node) {<br>-         ao2_unlink(peers, peer);<br>-             ao2_ref(peer, -1);<br>-           return AST_TEST_FAIL;<br>-        }<br>-<br>- /* compare item. */<br>-  if (strcmp(ast_data_retrieve_string(node, "peer/name"), "test_peer_data_provider")) {<br>-            ao2_unlink(peers, peer);<br>-             ao2_ref(peer, -1);<br>-           ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- if (strcmp(ast_data_retrieve_string(node, "peer/type"), "user")) {<br>-               ao2_unlink(peers, peer);<br>-             ao2_ref(peer, -1);<br>-           ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- if (ast_data_retrieve_int(node, "peer/call_limit") != 10) {<br>-                ao2_unlink(peers, peer);<br>-             ao2_ref(peer, -1);<br>-           ast_data_free(node);<br>-         return AST_TEST_FAIL;<br>-        }<br>-<br>- /* release resources */<br>-      ast_data_free(node);<br>-<br>-      ao2_unlink(peers, peer);<br>-     ao2_ref(peer, -1);<br>-<br>-        return AST_TEST_PASS;<br>-}<br>-<br> /*!<br>  * \brief Imitation TCP reception loop<br>  *<br>@@ -35130,170 +35060,6 @@<br> <br> #endif<br> <br>-#define DATA_EXPORT_SIP_PEER(MEMBER)                               \<br>-    MEMBER(sip_peer, name, AST_DATA_STRING)                 \<br>-    MEMBER(sip_peer, secret, AST_DATA_PASSWORD)             \<br>-    MEMBER(sip_peer, md5secret, AST_DATA_PASSWORD)          \<br>-    MEMBER(sip_peer, remotesecret, AST_DATA_PASSWORD)       \<br>-    MEMBER(sip_peer, context, AST_DATA_STRING)              \<br>-    MEMBER(sip_peer, subscribecontext, AST_DATA_STRING)     \<br>-    MEMBER(sip_peer, username, AST_DATA_STRING)             \<br>-    MEMBER(sip_peer, accountcode, AST_DATA_STRING)          \<br>-    MEMBER(sip_peer, tohost, AST_DATA_STRING)               \<br>-    MEMBER(sip_peer, regexten, AST_DATA_STRING)             \<br>-    MEMBER(sip_peer, fromuser, AST_DATA_STRING)             \<br>-    MEMBER(sip_peer, fromdomain, AST_DATA_STRING)           \<br>-    MEMBER(sip_peer, fullcontact, AST_DATA_STRING)          \<br>-    MEMBER(sip_peer, cid_num, AST_DATA_STRING)              \<br>-    MEMBER(sip_peer, cid_name, AST_DATA_STRING)             \<br>-    MEMBER(sip_peer, vmexten, AST_DATA_STRING)              \<br>-    MEMBER(sip_peer, language, AST_DATA_STRING)             \<br>-    MEMBER(sip_peer, mohinterpret, AST_DATA_STRING)         \<br>-    MEMBER(sip_peer, mohsuggest, AST_DATA_STRING)           \<br>-    MEMBER(sip_peer, parkinglot, AST_DATA_STRING)           \<br>-    MEMBER(sip_peer, useragent, AST_DATA_STRING)            \<br>-    MEMBER(sip_peer, mwi_from, AST_DATA_STRING)             \<br>-    MEMBER(sip_peer, engine, AST_DATA_STRING)               \<br>-    MEMBER(sip_peer, unsolicited_mailbox, AST_DATA_STRING)  \<br>-    MEMBER(sip_peer, is_realtime, AST_DATA_BOOLEAN)         \<br>-    MEMBER(sip_peer, host_dynamic, AST_DATA_BOOLEAN)        \<br>-    MEMBER(sip_peer, autoframing, AST_DATA_BOOLEAN)         \<br>-    MEMBER(sip_peer, inuse, AST_DATA_INTEGER)               \<br>-    MEMBER(sip_peer, ringing, AST_DATA_INTEGER)             \<br>-    MEMBER(sip_peer, onhold, AST_DATA_INTEGER)              \<br>-    MEMBER(sip_peer, call_limit, AST_DATA_INTEGER)          \<br>-    MEMBER(sip_peer, t38_maxdatagram, AST_DATA_INTEGER)     \<br>-    MEMBER(sip_peer, maxcallbitrate, AST_DATA_INTEGER)      \<br>-    MEMBER(sip_peer, rtptimeout, AST_DATA_SECONDS)          \<br>-    MEMBER(sip_peer, rtpholdtimeout, AST_DATA_SECONDS)      \<br>-    MEMBER(sip_peer, rtpkeepalive, AST_DATA_SECONDS)        \<br>-    MEMBER(sip_peer, lastms, AST_DATA_MILLISECONDS)         \<br>-    MEMBER(sip_peer, maxms, AST_DATA_MILLISECONDS)          \<br>-    MEMBER(sip_peer, qualifyfreq, AST_DATA_MILLISECONDS)    \<br>-    MEMBER(sip_peer, timer_t1, AST_DATA_MILLISECONDS)       \<br>-    MEMBER(sip_peer, timer_b, AST_DATA_MILLISECONDS)        \<br>-    MEMBER(sip_peer, description, AST_DATA_STRING)<br>-<br>-AST_DATA_STRUCTURE(sip_peer, DATA_EXPORT_SIP_PEER);<br>-<br>-static int peers_data_provider_get(const struct ast_data_search *search,<br>-        struct ast_data *data_root)<br>-{<br>-      struct sip_peer *peer;<br>-       struct ao2_iterator i;<br>-       struct ast_data *data_peer, *data_peer_mailboxes = NULL, *data_peer_mailbox, *enum_node;<br>-     struct ast_data *data_sip_options;<br>-   int total_mailboxes, x;<br>-      struct sip_mailbox *mailbox;<br>-<br>-      i = ao2_iterator_init(peers, 0);<br>-     while ((peer = ao2_iterator_next(&i))) {<br>-         ao2_lock(peer);<br>-<br>-           data_peer = ast_data_add_node(data_root, "peer");<br>-          if (!data_peer) {<br>-                    ao2_unlock(peer);<br>-                    ao2_ref(peer, -1);<br>-                   continue;<br>-            }<br>-<br>-         ast_data_add_structure(sip_peer, data_peer, peer);<br>-<br>-                /* transfer mode */<br>-          enum_node = ast_data_add_node(data_peer, "allowtransfer");<br>-         if (!enum_node) {<br>-                    ao2_unlock(peer);<br>-                    ao2_ref(peer, -1);<br>-                   continue;<br>-            }<br>-            ast_data_add_str(enum_node, "text", transfermode2str(peer->allowtransfer));<br>-             ast_data_add_int(enum_node, "value", peer->allowtransfer);<br>-<br>-           /* transports */<br>-             ast_data_add_str(data_peer, "transports", get_transport_list(peer->transports));<br>-<br>-             /* peer type */<br>-              if ((peer->type & SIP_TYPE_USER) && (peer->type & SIP_TYPE_PEER)) {<br>-                    ast_data_add_str(data_peer, "type", "friend");<br>-           } else if (peer->type & SIP_TYPE_PEER) {<br>-                      ast_data_add_str(data_peer, "type", "peer");<br>-             } else if (peer->type & SIP_TYPE_USER) {<br>-                      ast_data_add_str(data_peer, "type", "user");<br>-             }<br>-<br>-         /* mailboxes */<br>-              total_mailboxes = 0;<br>-         AST_LIST_TRAVERSE(&peer->mailboxes, mailbox, entry) {<br>-                 if (!total_mailboxes) {<br>-                              data_peer_mailboxes = ast_data_add_node(data_peer, "mailboxes");<br>-                           if (!data_peer_mailboxes) {<br>-                                  break;<br>-                               }<br>-                            total_mailboxes++;<br>-                   }<br>-<br>-                 data_peer_mailbox = ast_data_add_node(data_peer_mailboxes, "mailbox");<br>-                     if (!data_peer_mailbox) {<br>-                            continue;<br>-                    }<br>-                    ast_data_add_str(data_peer_mailbox, "id", mailbox->id);<br>-         }<br>-<br>-         /* amaflags */<br>-               enum_node = ast_data_add_node(data_peer, "amaflags");<br>-              if (!enum_node) {<br>-                    ao2_unlock(peer);<br>-                    ao2_ref(peer, -1);<br>-                   continue;<br>-            }<br>-            ast_data_add_int(enum_node, "value", peer->amaflags);<br>-           ast_data_add_str(enum_node, "text", ast_channel_amaflags2string(peer->amaflags));<br>-<br>-            /* sip options */<br>-            data_sip_options = ast_data_add_node(data_peer, "sipoptions");<br>-             if (!data_sip_options) {<br>-                     ao2_unlock(peer);<br>-                    ao2_ref(peer, -1);<br>-                   continue;<br>-            }<br>-            for (x = 0 ; x < ARRAY_LEN(sip_options); x++) {<br>-                   ast_data_add_bool(data_sip_options, sip_options[x].text, peer->sipoptions & sip_options[x].id);<br>-               }<br>-<br>-         /* callingpres */<br>-            enum_node = ast_data_add_node(data_peer, "callingpres");<br>-           if (!enum_node) {<br>-                    ao2_unlock(peer);<br>-                    ao2_ref(peer, -1);<br>-                   continue;<br>-            }<br>-            ast_data_add_int(enum_node, "value", peer->callingpres);<br>-                ast_data_add_str(enum_node, "text", ast_describe_caller_presentation(peer->callingpres));<br>-<br>-            /* codecs */<br>-         ast_data_add_codecs(data_peer, "codecs", peer->caps);<br>-<br>-                if (!ast_data_search_match(search, data_peer)) {<br>-                     ast_data_remove_node(data_root, data_peer);<br>-          }<br>-<br>-         ao2_unlock(peer);<br>-            ao2_ref(peer, -1);<br>-   }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     return 0;<br>-}<br>-<br>-static const struct ast_data_handler peers_data_provider = {<br>-      .version = AST_DATA_HANDLER_VERSION,<br>- .get = peers_data_provider_get<br>-};<br>-<br>-static const struct ast_data_entry sip_data_providers[] = {<br>- AST_DATA_ENTRY("asterisk/channel/sip/peers", &peers_data_provider),<br>-};<br>-<br> static const struct ast_sip_api_tech chan_sip_api_provider = {<br>    .version = AST_SIP_API_VERSION,<br>       .name = "chan_sip",<br>@@ -35414,14 +35180,10 @@<br>      }<br> <br> #ifdef TEST_FRAMEWORK<br>- AST_TEST_REGISTER(test_sip_peers_get);<br>        AST_TEST_REGISTER(test_sip_mwi_subscribe_parse);<br>      AST_TEST_REGISTER(test_tcp_message_fragmentation);<br>    AST_TEST_REGISTER(get_in_brackets_const_test);<br> #endif<br>-<br>-   /* Register AstData providers */<br>-     ast_data_register_multiple(sip_data_providers, ARRAY_LEN(sip_data_providers));<br> <br>     /* Register all CLI functions for SIP */<br>      ast_cli_register_multiple(cli_sip, ARRAY_LEN(cli_sip));<br>@@ -35549,14 +35311,10 @@<br> #ifdef TEST_FRAMEWORK<br>    ast_unregister_application(app_sipsendcustominfo);<br> <br>-        AST_TEST_UNREGISTER(test_sip_peers_get);<br>      AST_TEST_UNREGISTER(test_sip_mwi_subscribe_parse);<br>    AST_TEST_UNREGISTER(test_tcp_message_fragmentation);<br>  AST_TEST_UNREGISTER(get_in_brackets_const_test);<br> #endif<br>-    /* Unregister all the AstData providers */<br>-   ast_data_unregister(NULL);<br>-<br>         /* Unregister CLI commands */<br>         ast_cli_unregister_multiple(cli_sip, ARRAY_LEN(cli_sip));<br> <br>diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h<br>index b3c2b20..e989b16 100644<br>--- a/include/asterisk/_private.h<br>+++ b/include/asterisk/_private.h<br>@@ -44,7 +44,6 @@<br> int ast_file_init(void);         /*!< Provided by file.c */<br> int ast_features_init(void);            /*!< Provided by features.c */<br> void ast_autoservice_init(void);    /*!< Provided by autoservice.c */<br>-int ast_data_init(void);         /*!< Provided by data.c */<br> int ast_http_init(void);                /*!< Provided by http.c */<br> int ast_http_reload(void);              /*!< Provided by http.c */<br> int ast_tps_init(void);                 /*!< Provided by taskprocessor.c */<br>diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h<br>index 005803d..197cc99 100644<br>--- a/include/asterisk/channel.h<br>+++ b/include/asterisk/channel.h<br>@@ -174,7 +174,7 @@<br> #include "asterisk/linkedlists.h"<br> #include "asterisk/stringfields.h"<br> #include "asterisk/datastore.h"<br>-#include "asterisk/data.h"<br>+#include "asterisk/format_cap.h"<br> #include "asterisk/channelstate.h"<br> #include "asterisk/ccss.h"<br> #include "asterisk/framehook.h"<br>@@ -3837,27 +3837,6 @@<br>  * run the subroutine<br>  */<br> int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame);<br>-<br>-/*!<br>- * \brief Insert into an astdata tree, the channel structure.<br>- * \param[in] tree The ast data tree.<br>- * \param[in] chan The channel structure to add to tree.<br>- * \param[in] add_bridged Add the bridged channel to the structure.<br>- * \retval <0 on error.<br>- * \retval 0 on success.<br>- */<br>-int ast_channel_data_add_structure(struct ast_data *tree, struct ast_channel *chan, int add_bridged);<br>-<br>-/*!<br>- * \brief Compare to channel structures using the data api.<br>- * \param[in] tree The search tree generated by the data api.<br>- * \param[in] chan The channel to compare.<br>- * \param[in] structure_name The name of the node of the channel structure.<br>- * \retval 0 The structure matches.<br>- * \retval 1 The structure doesn't matches.<br>- */<br>-int ast_channel_data_cmp_structure(const struct ast_data_search *tree, struct ast_channel *chan,<br>-        const char *structure_name);<br> <br> /*!<br>  * \since 1.8<br>diff --git a/include/asterisk/data.h b/include/asterisk/data.h<br>deleted file mode 100644<br>index d6da1f7..0000000<br>--- a/include/asterisk/data.h<br>+++ /dev/null<br>@@ -1,828 +0,0 @@<br>-/*<br>- * Asterisk -- An open source telephony toolkit.<br>- *<br>- * Copyright (C) 2009, Eliel C. Sardanons (LU1ALY) <eliels@gmail.com><br>- *<br>- * See http://www.asterisk.org for more information about<br>- * the Asterisk project. Please do not directly contact<br>- * any of the maintainers of this project for assistance;<br>- * the project provides a web site, mailing lists and IRC<br>- * channels for your use.<br>- *<br>- * This program is free software, distributed under the terms of<br>- * the GNU General Public License Version 2. See the LICENSE file<br>- * at the top of the source tree.<br>- */<br>-<br>-/*!<br>- * \file<br>- * \brief Data retrieval API.<br>- * \author Brett Bryant <brettbryant@gmail.com><br>- * \author Eliel C. Sardanons (LU1ALY) <eliels@gmail.com><br>- * \arg \ref AstDataRetrieval<br>- */<br>-<br>-#ifndef ASTERISK_DATA_H<br>-#define ASTERISK_DATA_H<br>-<br>-#include "asterisk/frame.h"<br>-#include "asterisk/format_cap.h"<br>-<br>-/*!<br>- * \page AstDataRetrieval The Asterisk DATA retrieval API.<br>- *<br>- * This module implements an abstraction for retrieving asterisk data and<br>- * export it.<br>- *<br>- * \section USAGE<br>- *<br>- * \subsection Provider<br>- *<br>- * \b Register<br>- *<br>- * To register a callback use:<br>- *<br>- * \code<br>- *     static const struct ast_data_handler callback_handler = {<br>- *          .get = callback_handler_get_function,<br>- *      };<br>- *<br>- *    ast_data_register("/node/path", &callback_handler);<br>- * \endcode<br>- *<br>- * If you instead want to register multiple nodes at once use:<br>- * \code<br>- *   static const struct ast_data_handler handler_struct1 = {<br>- *           .get = handler_callback_read,<br>- *      };<br>- * ... other handlers ...<br>- *<br>- *        static const struct ast_data_entry list_providers[] = {<br>- *            AST_DATA_ENTRY("/path1/node1", &handler_struct1),<br>- *            AST_DATA_ENTRY("/path2/node2", &handler_struct2),<br>- *            AST_DATA_ENTRY("/path3/node3", &handler_struct3),<br>- *    };<br>- *<br>- *      ...<br>- *<br>- * ast_data_register_multiple(list_providers, ARRAY_LEN(list_providers));<br>- * \endcode<br>- *<br>- * \b Unregister<br>- *<br>- * To unregister a callback function already registered you can just call:<br>- *<br>- * \code<br>- *     ast_data_unregister(NULL);<br>- * \endcode<br>- * And every node registered by the current module (file) will be unregistered.<br>- * If you want to unregister a specific node use:<br>- *<br>- * \code<br>- *     ast_data_unregister("/node/path");<br>- * \endcode<br>- *<br>- * \b Implementation<br>- *<br>- * A simple callback function implementation:<br>- *<br>- * \code<br>- *        #include <data.h><br>- *<br>- *       struct test_structure {<br>- *            int a;<br>- *             double b;<br>- *  };<br>- *<br>- *    DATA_EXPORT_TEST_STRUCTURE(MEMBER)                      \<br>- *          MEMBER(test_structure, a, AST_DATA_INTEGER)     \<br>- *          MEMBER(test_structure, b, AST_DATA_DOUBLE)<br>- *<br>- *    AST_DATA_STRUCTURE(test_structure, DATA_EXPORT_TEST_STRUCTURE)<br>- *<br>- *        static int my_callback_function(struct ast_data_search *search,<br>- *            struct ast_data *root_node)<br>- *        {<br>- *          struct ast_data *internal_node;<br>- *            struct test_structure ts = {<br>- *                       .a = 10,<br>- *                   .b = 20<br>- *            };<br>- *<br>- *            internal_node = ast_data_add_node(root_node, "test_node");<br>- *               if (!internal_node) {<br>- *                      return -1;<br>- *         }<br>- *<br>- *             ast_data_add_structure(test_structure, internal_node, ts);<br>- *<br>- *            if (!ast_data_search_match(search, internal_node)) {<br>- *                       ast_data_remove_node(root_node, internal_node);<br>- *            }<br>- *<br>- *             return 0;<br>- *  }<br>- *<br>- * \endcode<br>- *<br>- * \subsection Get<br>- *<br>- * \b Getting \b the \b tree<br>- *<br>- * To get the tree you need to create a query, a query is based on three parameters<br>- * a \b path to the provider, a \b search condition and a \b filter condition.<br>- * \code<br>- *  struct ast_data *result;<br>- *   struct ast_data_query query = {<br>- *            .path = "/asterisk/application/app_queue/queues",<br>- *                .search = "/queues/queue/name=queue1",<br>- *           .filter = "/queues/queue/name|wrapuptime|members/member/interface"<br>- *       };<br>- *<br>- *    result = ast_data_get(&query);<br>- * \endcode<br>- *<br>- * After using it you need to release the allocated memory of the returned tree:<br>- * \code<br>- *        ast_data_free(result);<br>- * \endcode<br>- *<br>- * \b Iterate<br>- *<br>- * To retrieve nodes from the tree, it is possible to iterate through the returned<br>- * nodes of the tree using:<br>- * \code<br>- *       struct ast_data_iterator *i;<br>- *       struct ast_data *internal_node;<br>- *<br>- *       i = ast_data_iterator_init(result_tree, "path/node_name");<br>- *       while ((internal_node = ast_data_iterator_next(i))) {<br>- *              ... do something with node ...<br>- *     }<br>- *  ast_data_iterator_end(i);<br>- * \endcode<br>- * node_name is the name of the nodes to retrieve and path is the path to the internal<br>- * nodes to retrieve (if needed).<br>- *<br>- * \b Retrieving<br>- *<br>- * After getting the node you where searching for, you will need to retrieve its value,<br>- * to do that you may use one of the ast_data_retrieve_##type functions:<br>- * \code<br>- *  int a = ast_data_retrieve_int(tree, "path/to/the/node");<br>- * double b = ast_data_retrieve_dbl(tree, "path/to/the/node");<br>- *      unsigned int c = ast_data_retrieve_bool(tree, "path/to/the/node");<br>- *       char *d = ast_data_retrieve_string(tree, "path/to/the/node");<br>- *    struct sockaddr_in e = ast_data_retrieve_ipaddr(tree, "path/to/the/node");<br>- *       unsigned int f = ast_data_retrieve_uint(tree, "path/to/the/node");<br>- *       void *g = ast_data_retrieve_ptr(tree, "path/to/the/node");<br>- * \endcode<br>- *<br>- */<br>-<br>-#if defined(__cplusplus) || defined(c_plusplus)<br>-extern "C" {<br>-#endif<br>-<br>-/*! \brief The data type of the data node. */<br>-enum ast_data_type {<br>-       AST_DATA_CONTAINER,<br>-  AST_DATA_INTEGER,<br>-    AST_DATA_UNSIGNED_INTEGER,<br>-   AST_DATA_DOUBLE,<br>-     AST_DATA_BOOLEAN,<br>-    AST_DATA_STRING,<br>-     AST_DATA_CHARACTER,<br>-  AST_DATA_PASSWORD,<br>-   AST_DATA_IPADDR,<br>-     AST_DATA_TIMESTAMP,<br>-  AST_DATA_SECONDS,<br>-    AST_DATA_MILLISECONDS,<br>-       AST_DATA_POINTER<br>-};<br>-<br>-/*! \brief The Data API structures version. */<br>-#define AST_DATA_HANDLER_VERSION 1<br>-#define AST_DATA_QUERY_VERSION  1<br>-<br>-/*! \brief opaque definition of an ast_data handler, a tree node. */<br>-struct ast_data;<br>-<br>-/*! \brief opaque definition of an ast_data_iterator handler. */<br>-struct ast_data_iterator;<br>-<br>-/*! \brief opaque definition of an ast_data_search structure. */<br>-struct ast_data_search;<br>-<br>-/*! \brief structure retrieved from a node, with the nodes content. */<br>-struct ast_data_retrieve {<br>-   /*! \brief The type of the node retrieved. */<br>-        enum ast_data_type type;<br>-<br>-  union {<br>-              char AST_DATA_CHARACTER;<br>-             char *AST_DATA_STRING;<br>-               char *AST_DATA_PASSWORD;<br>-             int AST_DATA_INTEGER;<br>-                unsigned int AST_DATA_TIMESTAMP;<br>-             unsigned int AST_DATA_SECONDS;<br>-               unsigned int AST_DATA_MILLISECONDS;<br>-          double AST_DATA_DOUBLE;<br>-              unsigned int AST_DATA_UNSIGNED_INTEGER;<br>-              unsigned int AST_DATA_BOOLEAN;<br>-               void *AST_DATA_POINTER;<br>-              struct in_addr AST_DATA_IPADDR;<br>-              void *AST_DATA_CONTAINER;<br>-    } value;<br>-};<br>-<br>-/*!<br>- * \brief The get callback definition.<br>- */<br>-typedef int (*ast_data_get_cb)(const struct ast_data_search *search,<br>- struct ast_data *root);<br>-<br>-/*! \brief The structure of the node handler. */<br>-struct ast_data_handler {<br>-    /*! \brief Structure version. */<br>-     uint32_t version;<br>-    /*! \brief Data get callback implementation. */<br>-      ast_data_get_cb get;<br>-};<br>-<br>-/*! \brief This entries are for multiple registers. */<br>-struct ast_data_entry {<br>-      /*! \brief Path of the node to register. */<br>-  const char *path;<br>-    /*! \brief Data handler structure. */<br>-        const struct ast_data_handler *handler;<br>-};<br>-<br>-#define AST_DATA_ENTRY(__path, __handler) { .path = __path, .handler = __handler }<br>-<br>-/*! \brief A query to the data API is specified in this structure. */<br>-struct ast_data_query {<br>-    /*! \brief Data query version. */<br>-    uint32_t version;<br>-    /*! \brief Path to the node to retrieve. */<br>-  char *path;<br>-  /*! \brief Filter string, return the internal nodes specified here.<br>-   *         Setting it to NULL will return every internal node. */<br>-    char *filter;<br>-        /*! \brief Search condition. */<br>-      char *search;<br>-};<br>-<br>-/*! \brief Map the members of a structure. */<br>-struct ast_data_mapping_structure {<br>-  /*! \brief structure member name. */<br>- const char *name;<br>-    /*! \brief structure member type. */<br>- enum ast_data_type type;<br>-     /*! \brief member getter. */<br>- union {<br>-              char (*AST_DATA_CHARACTER)(void *ptr);<br>-               char *(*AST_DATA_STRING)(void *ptr);<br>-         char *(*AST_DATA_PASSWORD)(void *ptr);<br>-               int (*AST_DATA_INTEGER)(void *ptr);<br>-          int (*AST_DATA_TIMESTAMP)(void *ptr);<br>-                int (*AST_DATA_SECONDS)(void *ptr);<br>-          int (*AST_DATA_MILLISECONDS)(void *ptr);<br>-             double (*AST_DATA_DOUBLE)(void *ptr);<br>-                unsigned int (*AST_DATA_UNSIGNED_INTEGER)(void *ptr);<br>-                unsigned int (*AST_DATA_BOOLEAN)(void *ptr);<br>-         void *(*AST_DATA_POINTER)(void *ptr);<br>-                struct in_addr (*AST_DATA_IPADDR)(void *ptr);<br>-                void *(*AST_DATA_CONTAINER)(void *ptr);<br>-      } get;<br>-};<br>-<br>-/* Generate the structure and the functions to access the members of a structure. */<br>-#define AST_DATA_STRUCTURE(__struct, __name)                                                            \<br>-    __name(__AST_DATA_MAPPING_FUNCTION);                                                            \<br>-    static const struct ast_data_mapping_structure __data_mapping_structure_##__struct[] = {        \<br>-            __name(__AST_DATA_MAPPING_STRUCTURE)                                                    \<br>-    }<br>-<br>-/* Generate the structure to access the members and setup the pointer of the getter. */<br>-#define __AST_DATA_MAPPING_STRUCTURE(__structure, __member, __type)                            \<br>-    { .name = #__member, .get.__type = data_mapping_structure_get_##__structure##__member,  \<br>-    .type = __type },<br>-<br>-/* based on the data type, specifify the type of return value for the getter function. */<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_PASSWORD(__structure, __member)                         \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_PASSWORD, char *)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_STRING(__structure, __member)                         \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_STRING, char *)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_CHARACTER(__structure, __member)                                \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_CHARACTER, char)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_INTEGER(__structure, __member)                         \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_TIMESTAMP(__structure, __member)                          \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_SECONDS(__structure, __member)                            \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_MILLISECONDS(__structure, __member)                       \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_INTEGER, int)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_UNSIGNED_INTEGER(__structure, __member)                   \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_UNSIGNED_INTEGER, unsigned int)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_BOOLEAN(__structure, __member)                          \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_BOOLEAN, unsigned int)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_POINTER(__structure, __member)                           \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_POINTER, void *)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_IPADDR(__structure, __member)                          \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_IPADDR, struct in_addr)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_DOUBLE(__structure, __member)                           \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_DBL, double)<br>-#define __AST_DATA_MAPPING_FUNCTION_AST_DATA_CONTAINER(__structure, __member)                           \<br>-    __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, AST_DATA_CONTAINER, void *)<br>-<br>-#define __AST_DATA_MAPPING_FUNCTION(__structure, __member, __type)             \<br>-    __AST_DATA_MAPPING_FUNCTION_##__type(__structure, __member)<br>-<br>-/* Create the function to retrieve a member of the structure. */<br>-#define __AST_DATA_MAPPING_FUNCTION_TYPE(__structure, __member, __type, __real_type)                \<br>-    static __real_type data_mapping_structure_get_##__structure##__member(void *ptr) {      \<br>-            struct __structure *struct_##__member = (struct __structure *) ptr;             \<br>-            return (__real_type) struct_##__member->__member;                            \<br>-    }<br>-<br>-/*!<br>- * \brief Register a data provider.<br>- * \param[in] path The path of the node to register.<br>- * \param[in] handler The structure defining this node handler.<br>- * \param[in] registrar Who is registering this node.<br>- * \param[in] mod The module registering this handler.<br>- * \see ast_data_unregister<br>- * \retval <0 on error.<br>- * \retval 0 on success.<br>- * \see __ast_data_unregister, __ast_data_register_multiple<br>- */<br>-int __ast_data_register(const char *path, const struct ast_data_handler *handler,<br>-     const char *registrar, struct ast_module *mod);<br>-#define ast_data_register(path, handler) __ast_data_register(path, handler, __FILE__, AST_MODULE_SELF)<br>-#define ast_data_register_core(path, handler) __ast_data_register(path, handler, __FILE__, NULL)<br>-<br>-/*!<br>- * \brief Register multiple data providers at once.<br>- * \param[in] data_entries An array of data_entries structures.<br>- * \param[in] entries The number of entries in the data_entries array.<br>- * \param[in] registrar Who is registering this nodes.<br>- * \param[in] mod The module registering this handlers.<br>- * \retval <0 on error (none of the nodes are being registered on error).<br>- * \retval 0 on success.<br>- * \see __ast_data_register, __ast_data_unregister<br>- */<br>-int __ast_data_register_multiple(const struct ast_data_entry *data_entries,<br>-  size_t entries, const char *registrar, struct ast_module *mod);<br>-#define ast_data_register_multiple(data_entries, entries) \<br>-        __ast_data_register_multiple(data_entries, entries, __FILE__, AST_MODULE_SELF)<br>-#define ast_data_register_multiple_core(data_entries, entries) \<br>-    __ast_data_register_multiple(data_entries, entries, __FILE__, NULL)<br>-<br>-/*!<br>- * \brief Unregister a data provider.<br>- * \param[in] path Which node to unregister, if path is NULL unregister every node<br>- *                 registered by the passed 'registrar'.<br>- * \param[in] registrar Who is trying to unregister this node, only the owner (the<br>- *                      one who registered the node) will be able to unregister it.<br>- * \see ast_data_register<br>- * \retval <0 on error.<br>- * \retval 0 on success.<br>- * \see __ast_data_register, __ast_data_register_multiple<br>- */<br>-int __ast_data_unregister(const char *path, const char *registrar);<br>-#define ast_data_unregister(path) __ast_data_unregister(path, __FILE__)<br>-<br>-/*!<br>- * \brief Check the current generated node to know if it matches the search<br>- *        condition.<br>- * \param[in] search The search condition.<br>- * \param[in] data The AstData node generated.<br>- * \return 1 If the "data" node matches the search condition.<br>- * \return 0 If the "data" node does not matches the search condition.<br>- * \see ast_data_remove_node<br>- */<br>-int ast_data_search_match(const struct ast_data_search *search, struct ast_data *data);<br>-<br>-/*!<br>- * \brief Based on a search tree, evaluate every member of a structure against it.<br>- * \param[in] search The search tree.<br>- * \param[in] mapping The structure mapping.<br>- * \param[in] mapping_len The lenght of the structure mapping.<br>- * \param[in] structure The structure pointer.<br>- * \param[in] structure_name The name of the structure to compare.<br>- * \retval 0 If the structure matches.<br>- * \retval 1 If the structure doesn't match.<br>- */<br>-int __ast_data_search_cmp_structure(const struct ast_data_search *search,<br>-      const struct ast_data_mapping_structure *mapping, size_t mapping_len,<br>-        void *structure, const char *structure_name);<br>-#define ast_data_search_cmp_structure(search, structure_name, structure, structure_name_cmp)            \<br>-    __ast_data_search_cmp_structure(search, __data_mapping_structure_##structure_name,              \<br>-    ARRAY_LEN(__data_mapping_structure_##structure_name), structure, structure_name_cmp)<br>-<br>-/*!<br>- * \brief Retrieve a subtree from the asterisk data API.<br>- * \param[in] query The query structure specifying what nodes to retrieve.<br>- * \retval NULL on error.<br>- * \retval non-NULL The dynamically allocated requested sub-tree (it needs to be<br>- *         released using ast_data_free.<br>- * \see ast_data_free, ast_data_get_xml<br>- */<br>-struct ast_data *ast_data_get(const struct ast_data_query *query);<br>-<br>-#ifdef HAVE_LIBXML2<br>-/*!<br>- * \brief Retrieve a subtree from the asterisk data API in XML format..<br>- * \param[in] query The query structure specifying what nodes to retrieve.<br>- * \retval NULL on error.<br>- * \retval non-NULL The dynamically allocated requested sub-tree (it needs to be<br>- *         released using ast_data_free.<br>- * \see ast_data_free, ast_data_get<br>- */<br>-struct ast_xml_doc *ast_data_get_xml(const struct ast_data_query *query);<br>-#endif<br>-<br>-/*!<br>- * \brief Release the allocated memory of a tree.<br>- * \param[in] root The sub-tree pointer returned by a call to ast_data_get.<br>- * \see ast_data_get<br>- */<br>-void ast_data_free(struct ast_data *root);<br>-<br>-/*!<br>- * \brief Get a node type.<br>- * \param[in] res A pointer to the ast_data result set.<br>- * \param[in] path A path to the node to get the type.<br>- * \return The type of the requested node type.<br>- */<br>-enum ast_data_type ast_data_retrieve_type(struct ast_data *res, const char *path);<br>-<br>-/*!<br>- * \brief Get the node name.<br>- * \param[in] node The node pointer.<br>- * \returns The node name.<br>- */<br>-char *ast_data_retrieve_name(struct ast_data *node);<br>-<br>-/*!<br>- * \brief Add a container child.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_node(struct ast_data *root, const char *childname);<br>-<br>-/*!<br>- * \brief Add an integer node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] value The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_int(struct ast_data *root, const char *childname,<br>- int value);<br>-<br>-/*!<br>- * \brief Add a char node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] value The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_char(struct ast_data *root, const char *childname,<br>-      char value);<br>-<br>-/*!<br>- * \brief Add an unsigned integer node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] value The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_uint(struct ast_data *root, const char *childname,<br>-        unsigned int value);<br>-<br>-/*!<br>- * \brief Add a floating point node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] dbl The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_dbl(struct ast_data *root, const char *childname,<br>-      double dbl);<br>-/*!<br>- * \brief Add a ipv4 address type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] addr The ipv4 address value.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_ipaddr(struct ast_data *root, const char *childname,<br>-        struct in_addr addr);<br>-<br>-/*!<br>- * \brief Add a ptr node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] ptr The pointer value to add.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_ptr(struct ast_data *root, const char *childname,<br>-  void *ptr);<br>-<br>-/*!<br>- * \brief Add a password node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] string The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_password(struct ast_data *root, const char *childname,<br>-     const char *string);<br>-<br>-/*!<br>- * \brief Add a timestamp node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] timestamp The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_timestamp(struct ast_data *root, const char *childname,<br>-       unsigned int timestamp);<br>-<br>-/*!<br>- * \brief Add a seconds node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] seconds The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_seconds(struct ast_data *root, const char *childname,<br>- unsigned int seconds);<br>-<br>-/*!<br>- * \brief Add a milliseconds node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] milliseconds The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_milliseconds(struct ast_data *root, const char *childname,<br>-    unsigned int milliseconds);<br>-<br>-/*!<br>- * \brief Add a string node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] string The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_str(struct ast_data *root, const char *childname,<br>-    const char *string);<br>-<br>-/*!<br>- * \brief Add a boolean node type.<br>- * \param[in] root The root of the ast_data to insert into.<br>- * \param[in] childname The name of the child element to be added.<br>- * \param[in] boolean The value for the new node.<br>- * \retval NULL on error (memory exhaustion only).<br>- * \retval non-NULL a newly allocated node.<br>- */<br>-struct ast_data *ast_data_add_bool(struct ast_data *root, const char *childname,<br>-        unsigned int boolean);<br>-<br>-/*!<br>- * \brief Add a complete structure to a node.<br>- * \param[in] root Where to add the structure.<br>- * \param[in] mapping The structure mapping array.<br>- * \param[in] mapping_len The lenght of the mapping array.<br>- * \param[in] structure The structure pointer.<br>- * \retval 0 on success.<br>- * \retval 1 on error.<br>- */<br>-int __ast_data_add_structure(struct ast_data *root,<br>-  const struct ast_data_mapping_structure *mapping,<br>-    size_t mapping_len, void *structure);<br>-#define ast_data_add_structure(structure_name, root, structure)                         \<br>-    __ast_data_add_structure(root, __data_mapping_structure_##structure_name,       \<br>-            ARRAY_LEN(__data_mapping_structure_##structure_name), structure)<br>-<br>-/*!<br>- * \brief Remove a node that was added using ast_data_add_<br>- * \param[in] root The root node of the node to be removed.<br>- * \param[in] child The node pointer to remove.<br>- */<br>-void ast_data_remove_node(struct ast_data *root, struct ast_data *child);<br>-<br>-/*!<br>- * \brief Initialize an iterator.<br>- * \param[in] tree The returned tree by a call to ast_data_get.<br>- * \param[in] elements Which elements to iterate through.<br>- * \retval NULL on error.<br>- * \retval non-NULL A dinamically allocated iterator structure.<br>- */<br>-struct ast_data_iterator *ast_data_iterator_init(struct ast_data *tree,<br>-    const char *elements);<br>-<br>-/*!<br>- * \brief Release (stop using) an iterator.<br>- * \param[in] iterator The iterator created by ast_data_iterator_start.<br>- * \see ast_data_iterator_start<br>- */<br>-void ast_data_iterator_end(struct ast_data_iterator *iterator);<br>-<br>-/*!<br>- * \brief Get the next node of the tree.<br>- * \param[in] iterator The iterator structure returned by ast_data_iterator_start.<br>- * \retval NULL when no more nodes to return.<br>- * \retval non-NULL A node of the ast_data tree.<br>- * \see ast_data_iterator_start, ast_data_iterator_stop<br>- */<br>-struct ast_data *ast_data_iterator_next(struct ast_data_iterator *iterator);<br>-<br>-/*!<br>- * \brief Retrieve a value from a node in the tree.<br>- * \param[in] tree The structure returned by a call to ast_data_get.<br>- * \param[in] path The path to the node.<br>- * \param[out] content The node content.<br>- * \retval 0 on success.<br>- * \retval <0 on error.<br>- */<br>-int ast_data_retrieve(struct ast_data *tree, const char *path, struct ast_data_retrieve *content);<br>-<br>-/*!<br>- * \brief Retrieve the integer value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline int ast_data_retrieve_int(struct ast_data *tree, const char *path)<br>-{<br>-      struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_INTEGER;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the character value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline char ast_data_retrieve_char(struct ast_data *tree, const char *path)<br>-{<br>-       struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_CHARACTER;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the boolean value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline unsigned int ast_data_retrieve_bool(struct ast_data *tree, const char *path)<br>-{<br>-       struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_BOOLEAN;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the unsigned integer value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline unsigned int ast_data_retrieve_uint(struct ast_data *tree, const char *path)<br>-{<br>-        struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_UNSIGNED_INTEGER;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the password value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline const char *ast_data_retrieve_password(struct ast_data *tree, const char *path)<br>-{<br>-    struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_PASSWORD;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the string value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline const char *ast_data_retrieve_string(struct ast_data *tree, const char *path)<br>-{<br>-        struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_STRING;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the ptr value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline void *ast_data_retrieve_ptr(struct ast_data *tree, const char *path)<br>-{<br>-      struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_POINTER;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the double value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline double ast_data_retrieve_dbl(struct ast_data *tree, const char *path)<br>-{<br>- struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_DOUBLE;<br>-}<br>-<br>-/*!<br>- * \brief Retrieve the ipv4 address value of a node.<br>- * \param[in] tree The tree from where to get the value.<br>- * \param[in] path The node name or path.<br>- * \returns The value of the node.<br>- */<br>-static inline struct in_addr ast_data_retrieve_ipaddr(struct ast_data *tree, const char *path)<br>-{<br>- struct ast_data_retrieve ret;<br>-<br>-     ast_data_retrieve(tree, path, &ret);<br>-<br>-  return ret.value.AST_DATA_IPADDR;<br>-}<br>-<br>-/*!<br>- * \brief Add the codec in the root node based on the format parameter.<br>- * \param[in] root The astdata root node where to add the codec node.<br>- * \param[in] node_name The name of the node where we are going to add the codec.<br>- * \param[in] format The codec allowed.<br>- * \return < 0 on error.<br>- * \return 0 on success.<br>- */<br>-int ast_data_add_codec(struct ast_data *root, const char *node_name, struct ast_format *format);<br>-<br>-/*!<br>- * \brief Add the list of codecs in the root node based on the capability parameter.<br>- * \param[in] root The astdata root node where to add the codecs node.<br>- * \param[in] node_name The name of the node where we are going to add the list of<br>- *                      codecs.<br>- * \param[in] capability The codecs allowed.<br>- * \return < 0 on error.<br>- * \return 0 on success.<br>- */<br>-int ast_data_add_codecs(struct ast_data *root, const char *node_name, struct ast_format_cap *capability);<br>-<br>-#if defined(__cplusplus) || defined(c_plusplus)<br>-}<br>-#endif<br>-<br>-#endif /* ASTERISK_DATA_H */<br>diff --git a/include/asterisk/indications.h b/include/asterisk/indications.h<br>index b02be1f..309954b 100644<br>--- a/include/asterisk/indications.h<br>+++ b/include/asterisk/indications.h<br>@@ -28,7 +28,6 @@<br> <br> #include "asterisk/astobj2.h"<br> #include "asterisk/utils.h"<br>-#include "asterisk/data.h"<br> <br> /*!<br>  * \brief Description of a tone<br>@@ -241,13 +240,5 @@<br>       ao2_ref(ts, +1);<br>      return ts;<br> }<br>-<br>-/*!<br>- * \brief Add a tone_zone structure to the data tree specified.<br>- *<br>- * \retval <0 on error.<br>- * \retval 0 on success.<br>- */<br>-int ast_tone_zone_data_add_structure(struct ast_data *tree, struct ast_tone_zone *zone);<br> <br> #endif /* _ASTERISK_INDICATIONS_H */<br>diff --git a/main/asterisk.c b/main/asterisk.c<br>index 16313ea..3e16d69 100644<br>--- a/main/asterisk.c<br>+++ b/main/asterisk.c<br>@@ -4560,7 +4560,6 @@<br>         check_init(app_init(), "App Core");<br>         check_init(devstate_init(), "Device State Core");<br>   check_init(ast_msg_init(), "Messaging API");<br>-       check_init(ast_data_init(), "Data Retrieval API");<br>  check_init(ast_channels_init(), "Channel");<br>         check_init(ast_endpoint_init(), "Endpoints");<br>       check_init(ast_pickup_init(), "Call Pickup");<br>diff --git a/main/cdr.c b/main/cdr.c<br>index 214af2c..1817e80 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -60,7 +60,6 @@<br> #include "asterisk/config.h"<br> #include "asterisk/cli.h"<br> #include "asterisk/stringfields.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/config_options.h"<br> #include "asterisk/json.h"<br> #include "asterisk/parking.h"<br>diff --git a/main/channel.c b/main/channel.c<br>index c7c2b9d..1134d01 100644<br>--- a/main/channel.c<br>+++ b/main/channel.c<br>@@ -66,7 +66,6 @@<br> #include "asterisk/autochan.h"<br> #include "asterisk/stringfields.h"<br> #include "asterisk/global_datastores.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/channel_internal.h"<br> #include "asterisk/features.h"<br> #include "asterisk/bridge.h"<br>@@ -7566,122 +7565,6 @@<br> <br> /*!<br>  * \internal<br>- * \brief Implements the channels provider.<br>- */<br>-static int data_channels_provider_handler(const struct ast_data_search *search,<br>-    struct ast_data *root)<br>-{<br>-   struct ast_channel *c;<br>-       struct ast_channel_iterator *iter = NULL;<br>-    struct ast_data *data_channel;<br>-<br>-    for (iter = ast_channel_iterator_all_new();<br>-          iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) {<br>-               ast_channel_lock(c);<br>-<br>-              data_channel = ast_data_add_node(root, "channel");<br>-         if (!data_channel) {<br>-                 ast_channel_unlock(c);<br>-                       continue;<br>-            }<br>-<br>-         if (ast_channel_data_add_structure(data_channel, c, 1) < 0) {<br>-                     ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", ast_channel_name(c));<br>-              }<br>-<br>-         ast_channel_unlock(c);<br>-<br>-            if (!ast_data_search_match(search, data_channel)) {<br>-                  ast_data_remove_node(root, data_channel);<br>-            }<br>-    }<br>-    if (iter) {<br>-          ast_channel_iterator_destroy(iter);<br>-  }<br>-<br>- return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Implements the channeltypes provider.<br>- */<br>-static int data_channeltypes_provider_handler(const struct ast_data_search *search,<br>-  struct ast_data *data_root)<br>-{<br>-      struct chanlist *cl;<br>- struct ast_data *data_type;<br>-<br>-       AST_RWLIST_RDLOCK(&backends);<br>-    AST_RWLIST_TRAVERSE(&backends, cl, list) {<br>-               data_type = ast_data_add_node(data_root, "type");<br>-          if (!data_type) {<br>-                    continue;<br>-            }<br>-            ast_data_add_str(data_type, "name", cl->tech->type);<br>-         ast_data_add_str(data_type, "description", cl->tech->description);<br>-           ast_data_add_bool(data_type, "devicestate", cl->tech->devicestate ? 1 : 0);<br>-          ast_data_add_bool(data_type, "presencestate", cl->tech->presencestate ? 1 : 0);<br>-              ast_data_add_bool(data_type, "indications", cl->tech->indicate ? 1 : 0);<br>-             ast_data_add_bool(data_type, "transfer", cl->tech->transfer ? 1 : 0);<br>-                ast_data_add_bool(data_type, "send_digit_begin", cl->tech->send_digit_begin ? 1 : 0);<br>-                ast_data_add_bool(data_type, "send_digit_end", cl->tech->send_digit_end ? 1 : 0);<br>-            ast_data_add_bool(data_type, "call", cl->tech->call ? 1 : 0);<br>-                ast_data_add_bool(data_type, "hangup", cl->tech->hangup ? 1 : 0);<br>-            ast_data_add_bool(data_type, "answer", cl->tech->answer ? 1 : 0);<br>-            ast_data_add_bool(data_type, "read", cl->tech->read ? 1 : 0);<br>-                ast_data_add_bool(data_type, "write", cl->tech->write ? 1 : 0);<br>-              ast_data_add_bool(data_type, "send_text", cl->tech->send_text ? 1 : 0);<br>-              ast_data_add_bool(data_type, "send_image", cl->tech->send_image ? 1 : 0);<br>-            ast_data_add_bool(data_type, "send_html", cl->tech->send_html ? 1 : 0);<br>-              ast_data_add_bool(data_type, "exception", cl->tech->exception ? 1 : 0);<br>-              ast_data_add_bool(data_type, "early_bridge", cl->tech->early_bridge ? 1 : 0);<br>-                ast_data_add_bool(data_type, "fixup", cl->tech->fixup ? 1 : 0);<br>-              ast_data_add_bool(data_type, "setoption", cl->tech->setoption ? 1 : 0);<br>-              ast_data_add_bool(data_type, "queryoption", cl->tech->queryoption ? 1 : 0);<br>-          ast_data_add_bool(data_type, "write_video", cl->tech->write_video ? 1 : 0);<br>-          ast_data_add_bool(data_type, "write_text", cl->tech->write_text ? 1 : 0);<br>-            ast_data_add_bool(data_type, "func_channel_read", cl->tech->func_channel_read ? 1 : 0);<br>-              ast_data_add_bool(data_type, "func_channel_write", cl->tech->func_channel_write ? 1 : 0);<br>-            ast_data_add_bool(data_type, "get_pvt_uniqueid", cl->tech->get_pvt_uniqueid ? 1 : 0);<br>-                ast_data_add_bool(data_type, "cc_callback", cl->tech->cc_callback ? 1 : 0);<br>-<br>-               ast_data_add_codecs(data_type, "capabilities", cl->tech->capabilities);<br>-<br>-           if (!ast_data_search_match(search, data_type)) {<br>-                     ast_data_remove_node(data_root, data_type);<br>-          }<br>-    }<br>-    AST_RWLIST_UNLOCK(&backends);<br>-<br>- return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief /asterisk/core/channels provider.<br>- */<br>-static const struct ast_data_handler channels_provider = {<br>-       .version = AST_DATA_HANDLER_VERSION,<br>- .get = data_channels_provider_handler<br>-};<br>-<br>-/*!<br>- * \internal<br>- * \brief /asterisk/core/channeltypes provider.<br>- */<br>-static const struct ast_data_handler channeltypes_provider = {<br>-  .version = AST_DATA_HANDLER_VERSION,<br>- .get = data_channeltypes_provider_handler<br>-};<br>-<br>-static const struct ast_data_entry channel_providers[] = {<br>-       AST_DATA_ENTRY("/asterisk/core/channels", &channels_provider),<br>- AST_DATA_ENTRY("/asterisk/core/channeltypes", &channeltypes_provider),<br>-};<br>-<br>-/*!<br>- * \internal<br>  * \brief Print channel object key (name).<br>  * \since 12.0.0<br>  *<br>@@ -7879,7 +7762,6 @@<br>         free_external_channelvars(&ami_vars);<br>     free_external_channelvars(&ari_vars);<br> <br>- ast_data_unregister(NULL);<br>    ast_cli_unregister_multiple(cli_channel, ARRAY_LEN(cli_channel));<br>     if (channels) {<br>               ao2_container_unregister("channels");<br>@@ -7903,8 +7785,6 @@<br>        ast_stasis_channels_init();<br> <br>        ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel));<br>-<br>-   ast_data_register_multiple_core(channel_providers, ARRAY_LEN(channel_providers));<br> <br>  ast_plc_reload();<br> <br>diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c<br>index 5e7df89..d31ce94 100644<br>--- a/main/channel_internal_api.c<br>+++ b/main/channel_internal_api.c<br>@@ -40,7 +40,6 @@<br> #include "asterisk/paths.h"<br> #include "asterisk/channel.h"<br> #include "asterisk/channel_internal.h"<br>-#include "asterisk/data.h"<br> #include "asterisk/endpoints.h"<br> #include "asterisk/indications.h"<br> #include "asterisk/stasis_cache_pattern.h"<br>@@ -225,211 +224,6 @@<br> <br> /*! \brief The monotonically increasing integer counter for channel uniqueids */<br> static int uniqueint;<br>-<br>-/* AST_DATA definitions, which will probably have to be re-thought since the channel will be opaque */<br>-<br>-#if 0   /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */<br>-#define DATA_EXPORT_CALLERID(MEMBER)                                \<br>-    MEMBER(ast_callerid, cid_dnid, AST_DATA_STRING)         \<br>-    MEMBER(ast_callerid, cid_num, AST_DATA_STRING)          \<br>-    MEMBER(ast_callerid, cid_name, AST_DATA_STRING)         \<br>-    MEMBER(ast_callerid, cid_ani, AST_DATA_STRING)          \<br>-    MEMBER(ast_callerid, cid_pres, AST_DATA_INTEGER)        \<br>-    MEMBER(ast_callerid, cid_ani2, AST_DATA_INTEGER)        \<br>-    MEMBER(ast_callerid, cid_tag, AST_DATA_STRING)<br>-<br>-AST_DATA_STRUCTURE(ast_callerid, DATA_EXPORT_CALLERID);<br>-#endif<br>-<br>-#define DATA_EXPORT_CHANNEL(MEMBER)                                           \<br>-    MEMBER(ast_channel, blockproc, AST_DATA_STRING)                         \<br>-    MEMBER(ast_channel, appl, AST_DATA_STRING)                              \<br>-    MEMBER(ast_channel, data, AST_DATA_STRING)                              \<br>-    MEMBER(ast_channel, name, AST_DATA_STRING) \<br>- MEMBER(ast_channel, language, AST_DATA_STRING)                          \<br>-    MEMBER(ast_channel, musicclass, AST_DATA_STRING)                        \<br>-    MEMBER(ast_channel, accountcode, AST_DATA_STRING)                       \<br>-    MEMBER(ast_channel, peeraccount, AST_DATA_STRING)                       \<br>-    MEMBER(ast_channel, userfield, AST_DATA_STRING)                         \<br>-    MEMBER(ast_channel, call_forward, AST_DATA_STRING)                      \<br>-    MEMBER(ast_channel, parkinglot, AST_DATA_STRING)                        \<br>-    MEMBER(ast_channel, hangupsource, AST_DATA_STRING)                      \<br>-    MEMBER(ast_channel, dialcontext, AST_DATA_STRING)                       \<br>-    MEMBER(ast_channel, rings, AST_DATA_INTEGER)                            \<br>-    MEMBER(ast_channel, priority, AST_DATA_INTEGER)                         \<br>-    MEMBER(ast_channel, macropriority, AST_DATA_INTEGER)                    \<br>-    MEMBER(ast_channel, adsicpe, AST_DATA_INTEGER)                          \<br>-    MEMBER(ast_channel, fin, AST_DATA_UNSIGNED_INTEGER)                     \<br>-    MEMBER(ast_channel, fout, AST_DATA_UNSIGNED_INTEGER)                    \<br>-    MEMBER(ast_channel, emulate_dtmf_duration, AST_DATA_UNSIGNED_INTEGER)   \<br>-    MEMBER(ast_channel, visible_indication, AST_DATA_INTEGER)               \<br>-    MEMBER(ast_channel, context, AST_DATA_STRING)                           \<br>-    MEMBER(ast_channel, exten, AST_DATA_STRING)                             \<br>-    MEMBER(ast_channel, macrocontext, AST_DATA_STRING)                      \<br>-    MEMBER(ast_channel, macroexten, AST_DATA_STRING)<br>-<br>-AST_DATA_STRUCTURE(ast_channel, DATA_EXPORT_CHANNEL);<br>-<br>-static void channel_data_add_flags(struct ast_data *tree,<br>-   struct ast_channel *chan)<br>-{<br>-        ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEFER_DTMF));<br>-        ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_WRITE_INT));<br>-  ast_data_add_bool(tree, "BLOCKING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING));<br>-    ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_ZOMBIE));<br>-        ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(ast_channel_flags(chan), AST_FLAG_EXCEPTION));<br>-  ast_data_add_bool(tree, "MOH", ast_test_flag(ast_channel_flags(chan), AST_FLAG_MOH));<br>-      ast_data_add_bool(tree, "SPYING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_SPYING));<br>-        ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_AUTOLOOP));<br>-      ast_data_add_bool(tree, "OUTGOING", ast_test_flag(ast_channel_flags(chan), AST_FLAG_OUTGOING));<br>-    ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF));<br>-      ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(ast_channel_flags(chan), AST_FLAG_EMULATE_DTMF));<br>-    ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(ast_channel_flags(chan), AST_FLAG_END_DTMF_ONLY));<br>-  ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(ast_channel_flags(chan), AST_FLAG_MASQ_NOSTREAM));<br>-  ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_HANGUP_RUN));<br>-  ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS));<br>-      ast_data_add_bool(tree, "DISABLE_DEVSTATE_CACHE", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE));<br>-        ast_data_add_bool(tree, "BRIDGE_DUAL_REDIRECT_WAIT", ast_test_flag(ast_channel_flags(chan), AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT));<br>-  ast_data_add_bool(tree, "ORIGINATED", ast_test_flag(ast_channel_flags(chan), AST_FLAG_ORIGINATED));<br>-        ast_data_add_bool(tree, "DEAD", ast_test_flag(ast_channel_flags(chan), AST_FLAG_DEAD));<br>-}<br>-<br>-int ast_channel_data_add_structure(struct ast_data *tree,<br>- struct ast_channel *chan, int add_bridged)<br>-{<br>-       struct ast_data *data_bridged;<br>-       struct ast_data *data_cdr;<br>-   struct ast_data *data_flags;<br>- struct ast_data *data_zones;<br>- struct ast_data *enum_node;<br>-  struct ast_data *data_softhangup;<br>-#if 0       /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */<br>-    struct ast_data *data_callerid;<br>-      char value_str[100];<br>-#endif<br>-<br>-     if (!tree) {<br>-         return -1;<br>-   }<br>-<br>- ast_data_add_structure(ast_channel, tree, chan);<br>-<br>-  if (add_bridged) {<br>-           RAII_VAR(struct ast_channel *, bc, ast_channel_bridge_peer(chan), ast_channel_cleanup);<br>-              if (bc) {<br>-                    data_bridged = ast_data_add_node(tree, "bridged");<br>-                 if (!data_bridged) {<br>-                         return -1;<br>-                   }<br>-                    ast_channel_data_add_structure(data_bridged, bc, 0);<br>-         }<br>-    }<br>-<br>- ast_data_add_str(tree, "uniqueid", ast_channel_uniqueid(chan));<br>-    ast_data_add_str(tree, "linkedid", ast_channel_linkedid(chan));<br>-<br>- ast_data_add_codec(tree, "oldwriteformat", ast_channel_oldwriteformat(chan));<br>-      ast_data_add_codec(tree, "readformat", ast_channel_readformat(chan));<br>-      ast_data_add_codec(tree, "writeformat", ast_channel_writeformat(chan));<br>-    ast_data_add_codec(tree, "rawreadformat", ast_channel_rawreadformat(chan));<br>-        ast_data_add_codec(tree, "rawwriteformat", ast_channel_rawwriteformat(chan));<br>-      ast_data_add_codecs(tree, "nativeformats", ast_channel_nativeformats(chan));<br>-<br>-    /* state */<br>-  enum_node = ast_data_add_node(tree, "state");<br>-      if (!enum_node) {<br>-            return -1;<br>-   }<br>-    ast_data_add_str(enum_node, "text", ast_state2str(ast_channel_state(chan)));<br>-       ast_data_add_int(enum_node, "value", ast_channel_state(chan));<br>-<br>-  /* hangupcause */<br>-    enum_node = ast_data_add_node(tree, "hangupcause");<br>-        if (!enum_node) {<br>-            return -1;<br>-   }<br>-    ast_data_add_str(enum_node, "text", ast_cause2str(ast_channel_hangupcause(chan)));<br>- ast_data_add_int(enum_node, "value", ast_channel_hangupcause(chan));<br>-<br>-    /* amaflags */<br>-       enum_node = ast_data_add_node(tree, "amaflags");<br>-   if (!enum_node) {<br>-            return -1;<br>-   }<br>-    ast_data_add_str(enum_node, "text", ast_channel_amaflags2string(ast_channel_amaflags(chan)));<br>-      ast_data_add_int(enum_node, "value", ast_channel_amaflags(chan));<br>-<br>-       /* transfercapability */<br>-     enum_node = ast_data_add_node(tree, "transfercapability");<br>- if (!enum_node) {<br>-            return -1;<br>-   }<br>-    ast_data_add_str(enum_node, "text", ast_transfercapability2str(ast_channel_transfercapability(chan)));<br>-     ast_data_add_int(enum_node, "value", ast_channel_transfercapability(chan));<br>-<br>-     /* _softphangup */<br>-   data_softhangup = ast_data_add_node(tree, "softhangup");<br>-   if (!data_softhangup) {<br>-              return -1;<br>-   }<br>-    ast_data_add_bool(data_softhangup, "dev", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_DEV);<br>-    ast_data_add_bool(data_softhangup, "asyncgoto", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_ASYNCGOTO);<br>-        ast_data_add_bool(data_softhangup, "shutdown", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_SHUTDOWN);<br>-  ast_data_add_bool(data_softhangup, "timeout", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_TIMEOUT);<br>-    ast_data_add_bool(data_softhangup, "appunload", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_APPUNLOAD);<br>-        ast_data_add_bool(data_softhangup, "explicit", ast_channel_softhangup_internal_flag(chan) & AST_SOFTHANGUP_EXPLICIT);<br>-<br>-       /* channel flags */<br>-  data_flags = ast_data_add_node(tree, "flags");<br>-     if (!data_flags) {<br>-           return -1;<br>-   }<br>-    channel_data_add_flags(data_flags, chan);<br>-<br>- ast_data_add_uint(tree, "timetohangup", ast_channel_whentohangup(chan)->tv_sec);<br>-<br>-#if 0        /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */<br>-    /* callerid */<br>-       data_callerid = ast_data_add_node(tree, "callerid");<br>-       if (!data_callerid) {<br>-                return -1;<br>-   }<br>-    ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid));<br>-    /* insert the callerid ton */<br>-        enum_node = ast_data_add_node(data_callerid, "cid_ton");<br>-   if (!enum_node) {<br>-            return -1;<br>-   }<br>-    ast_data_add_int(enum_node, "value", chan->cid.cid_ton);<br>-        snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s",<br>-         party_number_ton2str(chan->cid.cid_ton),<br>-          party_number_plan2str(chan->cid.cid_ton));<br>-        ast_data_add_str(enum_node, "text", value_str);<br>-#endif<br>-<br>-        /* tone zone */<br>-      if (ast_channel_zone(chan)) {<br>-                data_zones = ast_data_add_node(tree, "zone");<br>-              if (!data_zones) {<br>-                   return -1;<br>-           }<br>-            ast_tone_zone_data_add_structure(data_zones, ast_channel_zone(chan));<br>-        }<br>-<br>- /* insert cdr */<br>-     data_cdr = ast_data_add_node(tree, "cdr");<br>- if (!data_cdr) {<br>-             return -1;<br>-   }<br>-<br>- return 0;<br>-}<br>-<br>-int ast_channel_data_cmp_structure(const struct ast_data_search *tree,<br>-    struct ast_channel *chan, const char *structure_name)<br>-{<br>-    return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name);<br>-}<br> <br> /* ACCESSORS */<br> <br>diff --git a/main/data.c b/main/data.c<br>deleted file mode 100644<br>index 15aca8b..0000000<br>--- a/main/data.c<br>+++ /dev/null<br>@@ -1,3346 +0,0 @@<br>-/*<br>- * Asterisk -- An open source telephony toolkit.<br>- *<br>- * Copyright (C) 2009, Eliel C. Sardanons (LU1ALY) <eliels@gmail.com><br>- *<br>- * See http://www.asterisk.org for more information about<br>- * the Asterisk project. Please do not directly contact<br>- * any of the maintainers of this project for assistance;<br>- * the project provides a web site, mailing lists and IRC<br>- * channels for your use.<br>- *<br>- * This program is free software, distributed under the terms of<br>- * the GNU General Public License Version 2. See the LICENSE file<br>- * at the top of the source tree.<br>- */<br>-<br>-/*! \file<br>- *<br>- * \brief Data retrieval API.<br>- *<br>- * \author Brett Bryant <brettbryant@gmail.com><br>- * \author Eliel C. Sardanons (LU1ALY) <eliels@gmail.com><br>- */<br>-<br>-/*** MODULEINFO<br>-     <support_level>core</support_level><br>- ***/<br>-<br>-#include "asterisk.h"<br>-<br>-#include "asterisk/_private.h"<br>-<br>-#include <regex.h><br>-<br>-#include "asterisk/module.h"<br>-#include "asterisk/utils.h"<br>-#include "asterisk/lock.h"<br>-#include "asterisk/data.h"<br>-#include "asterisk/astobj2.h"<br>-#include "asterisk/xml.h"<br>-#include "asterisk/cli.h"<br>-#include "asterisk/term.h"<br>-#include "asterisk/manager.h"<br>-#include "asterisk/test.h"<br>-#include "asterisk/frame.h"<br>-#include "asterisk/codec.h"<br>-<br>-/*** DOCUMENTATION<br>-     <manager name="DataGet" language="en_US"><br>-          <synopsis><br>-                     Retrieve the data api tree.<br>-          </synopsis><br>-            <syntax><br>-                       <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /><br>-                  <parameter name="Path" required="true" /><br>-                  <parameter name="Search" /><br>-                  <parameter name="Filter" /><br>-          </syntax><br>-              <description><br>-                  <para>Retrieve the data api tree.</para><br>-         </description><br>- </manager><br>- ***/<br>-<br>-#define NUM_DATA_NODE_BUCKETS     59<br>-#define NUM_DATA_RESULT_BUCKETS 59<br>-#define NUM_DATA_SEARCH_BUCKETS 59<br>-#define NUM_DATA_FILTER_BUCKETS 59<br>-<br>-/*! \brief The last compatible version. */<br>-static const uint32_t latest_handler_compatible_version = 0;<br>-<br>-/*! \brief The last compatible version. */<br>-static const uint32_t latest_query_compatible_version = 0;<br>-<br>-/*! \brief Current handler structure version. */<br>-static const uint32_t current_handler_version = AST_DATA_HANDLER_VERSION;<br>-<br>-/*! \brief Current query structure version. */<br>-static const uint32_t current_query_version = AST_DATA_QUERY_VERSION;<br>-<br>-/*! \brief The data tree to be returned by the callbacks and<br>-           managed by functions local to this file. */<br>-struct ast_data {<br>-   enum ast_data_type type;<br>-<br>-  /*! \brief The node content. */<br>-      union {<br>-              int32_t sint;<br>-                uint32_t uint;<br>-               double dbl;<br>-          unsigned int boolean;<br>-                char *str;<br>-           char character;<br>-              struct in_addr ipaddr;<br>-               void *ptr;<br>-   } payload;<br>-<br>-        /*! \brief The filter node that depends on the current node,<br>-  * this is used only when creating the result tree. */<br>-       const struct data_filter *filter;<br>-<br>- /*! \brief The list of nodes inside this node. */<br>-    struct ao2_container *children;<br>-      /*! \brief The name of the node. */<br>-  char name[0];<br>-};<br>-<br>-/*! \brief Type of comparisons allow in the search string. */<br>-enum data_search_comparison {<br>-        DATA_CMP_UNKNOWN,<br>-    DATA_CMP_EQ,    /* =  */<br>-     DATA_CMP_NEQ,   /* != */<br>-     DATA_CMP_GT,    /* >  */<br>-  DATA_CMP_GE,    /* >= */<br>-  DATA_CMP_LT,    /* <  */<br>-  DATA_CMP_LE     /* <= */<br>-};<br>-<br>-/*! \brief The list of nodes with their search requirement. */<br>-struct ast_data_search {<br>-      /*! \brief The value of the comparison. */<br>-   char *value;<br>- /*! \brief The type of comparison. */<br>-        enum data_search_comparison cmp_type;<br>-        /*! \brief reference another node. */<br>-        struct ao2_container *children;<br>-      /*! \brief The name of the node we are trying to compare. */<br>- char name[0];<br>-};<br>-<br>-struct data_filter;<br>-<br>-/*! \brief The filter node. */<br>-struct data_filter {<br>-       /*! \brief node childrens. */<br>-        struct ao2_container *children;<br>-      /*! \brief glob list */<br>-      AST_LIST_HEAD_NOLOCK(glob_list_t, data_filter) glob_list;<br>-    /*! \brief glob list entry */<br>-        AST_LIST_ENTRY(data_filter) list;<br>-    /*! \brief node name. */<br>-     char name[0];<br>-};<br>-<br>-/*! \brief A data container node pointing to the registered handler. */<br>-struct data_provider {<br>-     /*! \brief node content handler. */<br>-  const struct ast_data_handler *handler;<br>-      /*! \brief Module providing this handler. */<br>- struct ast_module *module;<br>-   /*! \brief children nodes. */<br>-        struct ao2_container *children;<br>-      /*! \brief Who registered this node. */<br>-      const char *registrar;<br>-       /*! \brief Node name. */<br>-     char name[0];<br>-};<br>-<br>-/*! \brief This structure is used by the iterator. */<br>-struct ast_data_iterator {<br>-   /*! \brief The internal iterator. */<br>- struct ao2_iterator internal_iterator;<br>-       /*! \brief The last returned node. */<br>-        struct ast_data *last;<br>-       /*! \brief The iterator pattern. */<br>-  const char *pattern;<br>- /*! \brief The compiled patter. */<br>-   regex_t regex_pattern;<br>-       /*! \brief is a regular expression. */<br>-       unsigned int is_pattern:1;<br>-};<br>-<br>-struct {<br>-        /*! \brief The asterisk data main content structure. */<br>-      struct ao2_container *container;<br>-     /*! \brief asterisk data locking mechanism. */<br>-       ast_rwlock_t lock;<br>-} root_data;<br>-<br>-static void __data_result_print_cli(int fd, const struct ast_data *root, uint32_t depth);<br>-<br>-/*!<br>- * \internal<br>- * \brief Common string hash function.<br>- * \see ast_data_init<br>- */<br>-static int data_provider_hash(const void *obj, const int flags)<br>-{<br>-        const struct data_provider *node = obj;<br>-      return ast_str_case_hash(node->name);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Compare two data_provider's.<br>- * \see ast_data_init<br>- */<br>-static int data_provider_cmp(void *obj1, void *obj2, int flags)<br>-{<br>-        struct data_provider *node1 = obj1, *node2 = obj2;<br>-   return strcasecmp(node1->name, node2->name) ? 0 : CMP_MATCH;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Common string hash function for data nodes<br>- */<br>-static int data_result_hash(const void *obj, const int flags)<br>-{<br>-      const struct ast_data *node = obj;<br>-   return ast_str_hash(node->name);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Common string comparison function<br>- */<br>-static int data_result_cmp(void *obj, void *arg, int flags)<br>-{<br>-        struct ast_data *node1 = obj, *node2 = arg;<br>-  return strcasecmp(node1->name, node2->name) ? 0 : CMP_MATCH;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Lock the data registered handlers structure for writing.<br>- * \see data_unlock<br>- */<br>-#define data_write_lock() ast_rwlock_wrlock(&root_data.lock)<br>-<br>-/*!<br>- * \internal<br>- * \brief Lock the data registered handlers structure for reading.<br>- * \see data_unlock<br>- */<br>-#define data_read_lock() ast_rwlock_rdlock(&root_data.lock)<br>-<br>-/*!<br>- * \internal<br>- * \brief Unlock the data registered handlers structure.<br>- */<br>-#define data_unlock() ast_rwlock_unlock(&root_data.lock)<br>-<br>-/*!<br>- * \internal<br>- * \brief Check if a version is compatible with the current core.<br>- * \param[in] structure_version The current structure version.<br>- * \param[in] latest_compatible The latest compatible version.<br>- * \param[in] current The current Data API version.<br>- * \retval 1 If the module is compatible.<br>- * \retval 0 If the module is NOT compatible.<br>- */<br>-static int data_structure_compatible(int structure_version, uint32_t latest_compatible,<br>-        uint32_t current)<br>-{<br>-        if (structure_version >= latest_compatible && structure_version <= current) {<br>-          return 1;<br>-    }<br>-<br>- ast_log(LOG_ERROR, "A module is not compatible with the"<br>-           "current data api version\n");<br>-<br>-  return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Get the next node name in a path (/node1/node2)<br>- *        Avoid null nodes like //node1//node2/node3.<br>- * \param[in] path The path where we are going to search for the next node name.<br>- * \retval The next node name we found inside the given path.<br>- * \retval NULL if there are no more node names.<br>- */<br>-static char *next_node_name(char **path)<br>-{<br>- char *res;<br>-<br>-        do {<br>-         res = strsep(path, "/");<br>-   } while (res && ast_strlen_zero(res));<br>-<br>-    return res;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Release the memory allocated by a call to ao2_alloc.<br>- */<br>-static void data_provider_destructor(void *obj)<br>-{<br>- struct data_provider *provider = obj;<br>-<br>-     ao2_ref(provider->children, -1);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Create a new data node.<br>- * \param[in] name The name of the node we are going to create.<br>- * \param[in] handler The handler registered for this node.<br>- * \param[in] registrar The name of the registrar.<br>- * \retval NULL on error.<br>- * \retval The allocated data node structure.<br>- */<br>-static struct data_provider *data_provider_new(const char *name,<br>-        const struct ast_data_handler *handler, const char *registrar)<br>-{<br>-   struct data_provider *node;<br>-  size_t namelen;<br>-<br>-   namelen = strlen(name) + 1;<br>-<br>-       node = ao2_alloc(sizeof(*node) + namelen, data_provider_destructor);<br>- if (!node) {<br>-         return NULL;<br>- }<br>-<br>- node->handler = handler;<br>-  node->registrar = registrar;<br>-      strcpy(node->name, name);<br>-<br>-      /* initialize the childrens container. */<br>-    if (!(node->children = ao2_container_alloc(NUM_DATA_NODE_BUCKETS,<br>-                 data_provider_hash, data_provider_cmp))) {<br>-           ao2_ref(node, -1);<br>-           return NULL;<br>- }<br>-<br>- return node;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Add a child node named 'name' to the 'parent' node.<br>- * \param[in] parent Where to add the child node.<br>- * \param[in] name The name of the child node.<br>- * \param[in] handler The handler structure.<br>- * \param[in] registrar Who registered this node.<br>- * \retval NULL on error.<br>- * \retval A newly allocated child in parent.<br>- */<br>-static struct data_provider *data_provider_add_child(struct ao2_container *parent,<br>-      const char *name, const struct ast_data_handler *handler, const char *registrar)<br>-{<br>- struct data_provider *child;<br>-<br>-      child = data_provider_new(name, handler, registrar);<br>- if (!child) {<br>-                return NULL;<br>- }<br>-<br>- ao2_link(parent, child);<br>-<br>-  return child;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Find a child node, based on his name.<br>- * \param[in] parent Where to find the node.<br>- * \param[in] name The node name to find.<br>- * \param[in] registrar Also check if the node was being used by this registrar.<br>- * \retval NULL if a node wasn't found.<br>- * \retval The node found.<br>- * \note Remember to decrement the ref count of the returned node after using it.<br>- */<br>-static struct data_provider *data_provider_find(struct ao2_container *parent,<br>-       const char *name, const char *registrar)<br>-{<br>- struct data_provider *find_node, *found;<br>-<br>-  /* XXX avoid allocating a new data node for searching... */<br>-  find_node = data_provider_new(name, NULL, NULL);<br>-     if (!find_node) {<br>-            return NULL;<br>- }<br>-<br>- found = ao2_find(parent, find_node, OBJ_POINTER);<br>-<br>- /* free the created node used for searching. */<br>-      ao2_ref(find_node, -1);<br>-<br>-   if (found && found->registrar && registrar) {<br>-             if (strcmp(found->registrar, registrar)) {<br>-                        /* if the name doesn't match, do not return this node. */<br>-                        ast_debug(1, "Registrar doesn't match, node was registered"<br>-                            " by '%s' and we are searching for '%s'\n",<br>-                                found->registrar, registrar);<br>-                     ao2_ref(found, -1);<br>-                  return NULL;<br>-         }<br>-    }<br>-<br>- return found;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Release a group of nodes.<br>- * \param[in] parent The parent node.<br>- * \param[in] path The path of nodes to release.<br>- * \param[in] registrar Who registered this node.<br>- * \retval <0 on error.<br>- * \retval 0 on success.<br>- * \see data_provider_create<br>- */<br>-static int data_provider_release(struct ao2_container *parent, const char *path,<br>-       const char *registrar)<br>-{<br>-   char *node_name, *rpath;<br>-     struct data_provider *child;<br>- int ret = 0;<br>-<br>-      rpath = ast_strdupa(path);<br>-<br>-        node_name = next_node_name(&rpath);<br>-      if (!node_name) {<br>-            return -1;<br>-   }<br>-<br>- child = data_provider_find(parent, node_name, registrar);<br>-    if (!child) {<br>-                return -1;<br>-   }<br>-<br>- /* if this is not a terminal node. */<br>-        if (!child->handler && rpath) {<br>-           ret = data_provider_release(child->children, rpath, registrar);<br>-   }<br>-<br>- /* if this node is empty, unlink it. */<br>-      if (!ret && !ao2_container_count(child->children)) {<br>-              ao2_unlink(parent, child);<br>-   }<br>-<br>- ao2_ref(child, -1);<br>-<br>-       return ret;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Release every node registered by 'registrar'.<br>- * \param[in] parent The parent node.<br>- * \param[in] registrar<br>- * \see __ast_data_unregister<br>- */<br>-static void data_provider_release_all(struct ao2_container *parent,<br>-      const char *registrar)<br>-{<br>-   struct ao2_iterator i;<br>-       struct data_provider *node;<br>-<br>-       i = ao2_iterator_init(parent, 0);<br>-    while ((node = ao2_iterator_next(&i))) {<br>-         if (!node->handler) {<br>-                     /* this is a non-terminal node, go inside it. */<br>-                     data_provider_release_all(node->children, registrar);<br>-                     if (!ao2_container_count(node->children)) {<br>-                               /* if this node was left empty, unlink it. */<br>-                                ao2_unlink(parent, node);<br>-                    }<br>-            } else {<br>-                     if (!strcmp(node->registrar, registrar)) {<br>-                                /* if the registrars match, release it! */<br>-                           ao2_unlink(parent, node);<br>-                    }<br>-            }<br>-            ao2_ref(node, -1);<br>-   }<br>-    ao2_iterator_destroy(&i);<br>-<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Create the middle nodes for the specified path (asterisk/testnode1/childnode)<br>- * \param[in] parent Where to add the middle nodes structure.<br>- * \param[in] path The path of nodes to add.<br>- * \param[in] registrar Who is trying to create this node provider.<br>- * \retval NULL on error.<br>- * \retval The created node.<br>- * \see data_provider_release<br>- */<br>-static struct data_provider *data_provider_create(struct ao2_container *parent,<br>-       const char *path, const char *registrar)<br>-{<br>- char *rpath, *node_name;<br>-     struct data_provider *child, *ret = NULL;<br>-<br>- rpath = ast_strdupa(path);<br>-<br>-        node_name = next_node_name(&rpath);<br>-      if (!node_name) {<br>-            /* no more nodes to create. */<br>-               return NULL;<br>- }<br>-<br>- child = data_provider_find(parent, node_name, NULL);<br>-<br>-      if (!child) {<br>-                /* nodes without handler are non-terminal nodes. */<br>-          child = data_provider_add_child(parent, node_name, NULL, registrar);<br>- }<br>-<br>- if (rpath) {<br>-         ret = data_provider_create(child->children, rpath, registrar);<br>-            if (ret) {<br>-                   ao2_ref(child, -1);<br>-          }<br>-    }<br>-<br>- return ret ? ret : child;<br>-}<br>-<br>-int __ast_data_register(const char *path, const struct ast_data_handler *handler,<br>- const char *registrar, struct ast_module *mod)<br>-{<br>-   struct data_provider *node;<br>-<br>-       if (!path) {<br>-         return -1;<br>-   }<br>-<br>- /* check if the handler structure is compatible. */<br>-  if (!data_structure_compatible(handler->version,<br>-          latest_handler_compatible_version,<br>-           current_handler_version)) {<br>-          return -1;<br>-   }<br>-<br>- /* create the node structure for the registered handler. */<br>-  data_write_lock();<br>-<br>-        node = data_provider_create(root_data.container, path, registrar);<br>-   if (!node) {<br>-         ast_log(LOG_ERROR, "Unable to create the specified path (%s) "<br>-                     "for '%s'.\n", path, registrar);<br>-           data_unlock();<br>-               return -1;<br>-   }<br>-<br>- if (ao2_container_count(node->children) || node->handler) {<br>-            ast_log(LOG_ERROR, "The node '%s' was already registered. "<br>-                        "We were unable to register '%s' for registrar '%s'.\n",<br>-                   node->name, path, registrar);<br>-             ao2_ref(node, -1);<br>-           data_unlock();<br>-               return -1;<br>-   }<br>-<br>- /* add handler to that node. */<br>-      node->handler = handler;<br>-  node->module = mod;<br>-<br>-    ao2_ref(node, -1);<br>-<br>-        data_unlock();<br>-<br>-    return 0;<br>-}<br>-<br>-int __ast_data_register_multiple(const struct ast_data_entry *data_entries,<br>-       size_t entries, const char *registrar, struct ast_module *mod)<br>-{<br>-   int i, res;<br>-<br>-       for (i = 0; i < entries; i++) {<br>-           res = __ast_data_register(data_entries[i].path, data_entries[i].handler,<br>-                             registrar, mod);<br>-             if (res) {<br>-                   /* unregister all the already registered nodes, and make<br>-                      * this an atomic action. */<br>-                 while ((--i) >= 0) {<br>-                              __ast_data_unregister(data_entries[i].path, registrar);<br>-                      }<br>-                    return -1;<br>-           }<br>-    }<br>-<br>- return 0;<br>-}<br>-<br>-int __ast_data_unregister(const char *path, const char *registrar)<br>-{<br>-    int ret = 0;<br>-<br>-      data_write_lock();<br>-   if (path) {<br>-          ret = data_provider_release(root_data.container, path, registrar);<br>-   } else {<br>-             data_provider_release_all(root_data.container, registrar);<br>-   }<br>-    data_unlock();<br>-<br>-    if (path && ret) {<br>-           ast_log(LOG_ERROR, "Unable to unregister '%s' for '%s'\n",<br>-                 path, registrar);<br>-    }<br>-<br>- return ret;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Is a char used to specify a comparison?<br>- * \param[in] a Character to evaluate.<br>- * \retval 1 It is a char used to specify a comparison.<br>- * \retval 0 It is NOT a char used to specify a comparison.<br>- */<br>-static int data_search_comparison_char(char a)<br>-{<br>-      switch (a) {<br>- case '!':<br>-    case '=':<br>-    case '<':<br>- case '>':<br>-         return 1;<br>-    }<br>-<br>- return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Get the type of comparison.<br>- */<br>-static enum data_search_comparison data_search_comparison_type(const char *comparison)<br>-{<br>-     if (!strcmp(comparison, "=")) {<br>-            return DATA_CMP_EQ;<br>-  } else if (!strcmp(comparison, "!=")) {<br>-            return DATA_CMP_NEQ;<br>- } else if (!strcmp(comparison, "<")) {<br>-          return DATA_CMP_LT;<br>-  } else if (!strcmp(comparison, ">")) {<br>-          return DATA_CMP_GT;<br>-  } else if (!strcmp(comparison, "<=")) {<br>-         return DATA_CMP_LE;<br>-  } else if (!strcmp(comparison, ">=")) {<br>-         return DATA_CMP_GE;<br>-  }<br>-<br>- return DATA_CMP_UNKNOWN;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Common string hash function for data nodes<br>- */<br>-static int data_search_hash(const void *obj, const int flags)<br>-{<br>-        const struct ast_data_search *node = obj;<br>-    return ast_str_hash(node->name);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Common string comparison function<br>- */<br>-static int data_search_cmp(void *obj, void *arg, int flags)<br>-{<br>-        struct ast_data_search *node1 = obj, *node2 = arg;<br>-   return strcasecmp(node1->name, node2->name) ? 0 : CMP_MATCH;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Destroy the ao2 search node.<br>- */<br>-static void data_search_destructor(void *obj)<br>-{<br>-    struct ast_data_search *node = obj;<br>-<br>-       if (node->value) {<br>-                ast_free(node->value);<br>-    }<br>-<br>- ao2_ref(node->children, -1);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Allocate a search node.<br>- * \retval NULL on error.<br>- * \retval non-NULL The allocated search node structure.<br>- */<br>-static struct ast_data_search *data_search_alloc(const char *name)<br>-{<br>-        struct ast_data_search *res;<br>- size_t name_len = strlen(name) + 1;<br>-<br>-       res = ao2_alloc(sizeof(*res) + name_len, data_search_destructor);<br>-    if (!res) {<br>-          return NULL;<br>- }<br>-<br>- res->children = ao2_container_alloc(NUM_DATA_SEARCH_BUCKETS, data_search_hash,<br>-            data_search_cmp);<br>-<br>- if (!res->children) {<br>-             ao2_ref(res, -1);<br>-            return NULL;<br>- }<br>-<br>- strcpy(res->name, name);<br>-<br>-       return res;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Find a child node, based on his name.<br>- * \param[in] parent Where to find the node.<br>- * \param[in] name The node name to find.<br>- * \retval NULL if a node wasn't found.<br>- * \retval The node found.<br>- * \note Remember to decrement the ref count of the returned node after using it.<br>- */<br>-static struct ast_data_search *data_search_find(struct ao2_container *parent,<br>-    const char *name)<br>-{<br>-        struct ast_data_search *find_node, *found;<br>-<br>-        find_node = data_search_alloc(name);<br>- if (!find_node) {<br>-            return NULL;<br>- }<br>-<br>- found = ao2_find(parent, find_node, OBJ_POINTER);<br>-<br>- /* free the created node used for searching. */<br>-      ao2_ref(find_node, -1);<br>-<br>-   return found;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Add a child node named 'name' to the 'parent' node.<br>- * \param[in] parent Where to add the child node.<br>- * \param[in] name The name of the child node.<br>- * \retval NULL on error.<br>- * \retval A newly allocated child in parent.<br>- */<br>-static struct ast_data_search *data_search_add_child(struct ao2_container *parent,<br>-        const char *name)<br>-{<br>-        struct ast_data_search *child;<br>-<br>-    child = data_search_alloc(name);<br>-     if (!child) {<br>-                return NULL;<br>- }<br>-<br>- ao2_link(parent, child);<br>-<br>-  return child;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Create the middle nodes for the specified path (asterisk/testnode1/childnode)<br>- * \param[in] parent Where to add the middle nodes structure.<br>- * \param[in] path The path of nodes to add.<br>- * \retval NULL on error.<br>- * \retval The created node.<br>- */<br>-static struct ast_data_search *data_search_create(struct ao2_container *parent,<br>-        const char *path)<br>-{<br>-        char *rpath, *node_name;<br>-     struct ast_data_search *child = NULL;<br>-        struct ao2_container *current = parent;<br>-<br>-   rpath = ast_strdupa(path);<br>-<br>-        node_name = next_node_name(&rpath);<br>-      while (node_name) {<br>-          child = data_search_find(current, node_name);<br>-                if (!child) {<br>-                        child = data_search_add_child(current, node_name);<br>-           }<br>-            ao2_ref(child, -1);<br>-          current = child->children;<br>-                node_name = next_node_name(&rpath);<br>-      }<br>-<br>- return child;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Allocate a tree with the search string parsed.<br>- * \param[in] search_string The search string.<br>- * \retval NULL on error.<br>- * \retval non-NULL A dynamically allocated search tree.<br>- */<br>-static struct ast_data_search *data_search_generate(const char *search_string)<br>-{<br>-      struct ast_str *name, *value, *comparison;<br>-   char *elements, *search_string_dup, *saveptr;<br>-        int i;<br>-       struct ast_data_search *root, *child;<br>-        enum data_search_comparison cmp_type;<br>-        size_t search_string_len;<br>-<br>- if (!search_string) {<br>-                ast_log(LOG_ERROR, "You must pass a valid search string.\n");<br>-              return NULL;<br>- }<br>-<br>- search_string_len = strlen(search_string);<br>-<br>-        name = ast_str_create(search_string_len);<br>-    if (!name) {<br>-         return NULL;<br>- }<br>-    value = ast_str_create(search_string_len);<br>-   if (!value) {<br>-                ast_free(name);<br>-              return NULL;<br>- }<br>-    comparison = ast_str_create(search_string_len);<br>-      if (!comparison) {<br>-           ast_free(name);<br>-              ast_free(value);<br>-             return NULL;<br>- }<br>-<br>- search_string_dup = ast_strdupa(search_string);<br>-<br>-   /* Create the root node (just used as a container) */<br>-        root = data_search_alloc("/");<br>-     if (!root) {<br>-         ast_free(name);<br>-              ast_free(value);<br>-             ast_free(comparison);<br>-                return NULL;<br>- }<br>-<br>- for (elements = strtok_r(search_string_dup, ",", &saveptr); elements;<br>-          elements = strtok_r(NULL, ",", &saveptr)) {<br>-            /* Parse the name */<br>-         ast_str_reset(name);<br>-         for (i = 0; !data_search_comparison_char(elements[i]) &&<br>-                     elements[i]; i++) {<br>-                  ast_str_append(&name, 0, "%c", elements[i]);<br>-           }<br>-<br>-         /* check if the syntax is ok. */<br>-             if (!data_search_comparison_char(elements[i])) {<br>-                     /* if this is the end of the string, then this is<br>-                     * an error! */<br>-                      ast_log(LOG_ERROR, "Invalid search string!\n");<br>-                    continue;<br>-            }<br>-<br>-         /* parse the comparison string. */<br>-           ast_str_reset(comparison);<br>-           for (; data_search_comparison_char(elements[i]) && elements[i]; i++) {<br>-                       ast_str_append(&comparison, 0, "%c", elements[i]);<br>-             }<br>-<br>-         /* parse the value string. */<br>-                ast_str_reset(value);<br>-                for (; elements[i]; i++) {<br>-                   ast_str_append(&value, 0, "%c", elements[i]);<br>-          }<br>-<br>-         cmp_type = data_search_comparison_type(ast_str_buffer(comparison));<br>-          if (cmp_type == DATA_CMP_UNKNOWN) {<br>-                  ast_log(LOG_ERROR, "Invalid comparison '%s'\n",<br>-                            ast_str_buffer(comparison));<br>-                 continue;<br>-            }<br>-<br>-         /* add this node to the tree. */<br>-             child = data_search_create(root->children, ast_str_buffer(name));<br>-         if (child) {<br>-                 child->cmp_type = cmp_type;<br>-                       child->value = ast_strdup(ast_str_buffer(value));<br>-         }<br>-    }<br>-<br>- ast_free(name);<br>-      ast_free(value);<br>-     ast_free(comparison);<br>-<br>-     return root;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Release the allocated memory for the search tree.<br>- * \param[in] search The search tree root node.<br>- */<br>-static void data_search_release(struct ast_data_search *search)<br>-{<br>- ao2_ref(search, -1);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on the kind of comparison and the result in cmpval, return<br>- *        if it matches.<br>- * \param[in] cmpval A result returned by a strcmp() for example.<br>- * \param[in] comparison_type The kind of comparison (<,>,=,!=,...)<br>- * \retval 1 If the comparison doesn't match.<br>- * \retval 0 If the comparison matches.<br>- */<br>-static inline int data_search_comparison_result(int cmpval,<br>-   enum data_search_comparison comparison_type)<br>-{<br>-     switch (comparison_type) {<br>-   case DATA_CMP_GE:<br>-            if (cmpval >= 0) {<br>-                        return 0;<br>-            }<br>-            break;<br>-       case DATA_CMP_LE:<br>-            if (cmpval <= 0) {<br>-                        return 0;<br>-            }<br>-            break;<br>-       case DATA_CMP_EQ:<br>-            if (cmpval == 0) {<br>-                   return 0;<br>-            }<br>-            break;<br>-       case DATA_CMP_NEQ:<br>-           if (cmpval != 0) {<br>-                   return 0;<br>-            }<br>-            break;<br>-       case DATA_CMP_LT:<br>-            if (cmpval < 0) {<br>-                 return 0;<br>-            }<br>-            break;<br>-       case DATA_CMP_GT:<br>-            if (cmpval > 0) {<br>-                 return 0;<br>-            }<br>-            break;<br>-       case DATA_CMP_UNKNOWN:<br>-               break;<br>-       }<br>-    return 1;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Get an internal node, from the search tree.<br>- * \param[in] node A node container.<br>- * \param[in] path The path to the needed internal node.<br>- * \retval NULL if the internal node is not found.<br>- * \retval non-NULL the internal node with path 'path'.<br>- */<br>-static struct ast_data_search *data_search_get_node(const struct ast_data_search *node,<br>-       const char *path)<br>-{<br>-        char *savepath, *node_name;<br>-  struct ast_data_search *child, *current = (struct ast_data_search *) node;<br>-<br>-        if (!node) {<br>-         return NULL;<br>- }<br>-<br>- savepath = ast_strdupa(path);<br>-        node_name = next_node_name(&savepath);<br>-<br>-        while (node_name) {<br>-          child = data_search_find(current->children, node_name);<br>-           if (current != node) {<br>-                       ao2_ref(current, -1);<br>-                }<br>-            if (!child) {<br>-                        return NULL;<br>-         };<br>-           current = child;<br>-             node_name = next_node_name(&savepath);<br>-   }<br>-<br>- return current;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current string value.<br>- *        .search = "somename=somestring"<br>- *        name = "somename"<br>- *        value is the current value of something and will be evaluated against "somestring".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] value The value to compare.<br>- * \returns The strcmp return value.<br>- */<br>-static int data_search_cmp_string(const struct ast_data_search *root, const char *name,<br>-    char *value)<br>-{<br>-     struct ast_data_search *child;<br>-       enum data_search_comparison cmp_type;<br>-        int ret;<br>-<br>-  child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-<br>- ret = strcmp(value, child->value);<br>-        cmp_type = child->cmp_type;<br>-<br>-    ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result(ret, cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current pointer address value.<br>- *        .search = "something=0x32323232"<br>- *        name = "something"<br>- *        value is the current value of something and will be evaluated against "0x32323232".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] ptr The pointer address to compare.<br>- * \returns The (value - current_value) result.<br>- */<br>-static int data_search_cmp_ptr(const struct ast_data_search *root, const char *name,<br>-    void *ptr)<br>-{<br>-       struct ast_data_search *child;<br>-       enum data_search_comparison cmp_type;<br>-        void *node_ptr;<br>-<br>-   child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-<br>- cmp_type = child->cmp_type;<br>-<br>-    if (sscanf(child->value, "%p", &node_ptr) <= 0) {<br>-                ao2_ref(child, -1);<br>-          return 1;<br>-    }<br>-<br>- ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result((node_ptr - ptr), cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current ipv4 address value.<br>- *        .search = "something=192.168.2.2"<br>- *        name = "something"<br>- *        value is the current value of something and will be evaluated against "192.168.2.2".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] addr The ipv4 address value to compare.<br>- * \returns The (value - current_value) result.<br>- */<br>-static int data_search_cmp_ipaddr(const struct ast_data_search *root, const char *name,<br>- struct in_addr addr)<br>-{<br>-     struct ast_data_search *child;<br>-       enum data_search_comparison cmp_type;<br>-        struct in_addr node_addr;<br>-<br>- child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-    cmp_type = child->cmp_type;<br>-<br>-    inet_aton(child->value, &node_addr);<br>-<br>-       ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result((node_addr.s_addr - addr.s_addr), cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current boolean value.<br>- *        .search = "something=true"<br>- *        name = "something"<br>- *        value is the current value of something and will be evaluated against "true".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] value The boolean value to compare.<br>- * \returns The (value - current_value) result.<br>- */<br>-static int data_search_cmp_bool(const struct ast_data_search *root, const char *name,<br>-  unsigned int value)<br>-{<br>-      struct ast_data_search *child;<br>-       unsigned int node_value;<br>-     enum data_search_comparison cmp_type;<br>-<br>-     child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-<br>- node_value = abs(ast_true(child->value));<br>- cmp_type = child->cmp_type;<br>-<br>-    ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result(value - node_value, cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current double value.<br>- *        .search = "something=222"<br>- *        name = "something"<br>- *        value is the current value of something and will be evaluated against "222".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] value The double value to compare.<br>- * \returns The (value - current_value) result.<br>- */<br>-static int data_search_cmp_dbl(const struct ast_data_search *root, const char *name,<br>-     double value)<br>-{<br>-    struct ast_data_search *child;<br>-       double node_value;<br>-   enum data_search_comparison cmp_type;<br>-<br>-     child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-<br>- node_value = strtod(child->value, NULL);<br>-  cmp_type = child->cmp_type;<br>-<br>-    ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result(value - node_value, cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current unsigned integer value.<br>- *        .search = "something=10"<br>- *        name = "something"<br>- *        value is the current value of something and will be evaluated against "10".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] value The unsigned value to compare.<br>- * \returns The strcmp return value.<br>- */<br>-static int data_search_cmp_uint(const struct ast_data_search *root, const char *name,<br>-     unsigned int value)<br>-{<br>-      struct ast_data_search *child;<br>-       unsigned int node_value;<br>-     enum data_search_comparison cmp_type;<br>-<br>-     child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-<br>- node_value = atoi(child->value);<br>-  cmp_type = child->cmp_type;<br>-<br>-    ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result(value - node_value, cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current signed integer value.<br>- *        .search = "something=10"<br>- *        name = "something"<br>- *        value is the current value of something and will be evaluated against "10".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] value The value to compare.<br>- * \returns The strcmp return value.<br>- */<br>-static int data_search_cmp_int(const struct ast_data_search *root, const char *name,<br>- int value)<br>-{<br>-       struct ast_data_search *child;<br>-       int node_value;<br>-      enum data_search_comparison cmp_type;<br>-<br>-     child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-<br>- node_value = atoi(child->value);<br>-  cmp_type = child->cmp_type;<br>-<br>-    ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result(value - node_value, cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Based on a search tree, evaluate the specified 'name' inside the tree with the<br>- *        current character value.<br>- *        .search = "something=c"<br>- *        name = "something"<br>- *        value is the current value of something and will be evaluated against "c".<br>- * \param[in] root The root node pointer of the search tree.<br>- * \param[in] name The name of the specific.<br>- * \param[in] value The boolean value to compare.<br>- * \returns The (value - current_value) result.<br>- */<br>-static int data_search_cmp_char(const struct ast_data_search *root, const char *name,<br>-    char value)<br>-{<br>-      struct ast_data_search *child;<br>-       char node_value;<br>-     enum data_search_comparison cmp_type;<br>-<br>-     child = data_search_get_node(root, name);<br>-    if (!child) {<br>-                return 0;<br>-    }<br>-<br>- node_value = *(child->value);<br>-     cmp_type = child->cmp_type;<br>-<br>-    ao2_ref(child, -1);<br>-<br>-       return data_search_comparison_result(value - node_value, cmp_type);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Get the member pointer, from a mapping structure, based on its name.<br>- * \XXX We will need to improve performance here!!.<br>- * \retval <0 if the member was not found.<br>- * \retval >=0 The member position in the mapping structure.<br>- */<br>-static inline int data_search_mapping_find(const struct ast_data_mapping_structure *map,<br>-    size_t mapping_len,<br>-  const char *member_name)<br>-{<br>- int i;<br>-<br>-    for (i = 0; i < mapping_len; i++) {<br>-               if (!strcmp(map[i].name, member_name)) {<br>-                     return i;<br>-            }<br>-    }<br>-<br>- return -1;<br>-}<br>-<br>-int __ast_data_search_cmp_structure(const struct ast_data_search *search,<br>-        const struct ast_data_mapping_structure *mapping, size_t mapping_len,<br>-        void *structure, const char *structure_name)<br>-{<br>-     struct ao2_iterator i;<br>-       struct ast_data_search *node, *struct_children;<br>-      int member, notmatch = 0;<br>-<br>- if (!search) {<br>-               return 0;<br>-    }<br>-<br>- struct_children = data_search_get_node(search, structure_name);<br>-      if (!struct_children) {<br>-              return 0;<br>-    }<br>-<br>- i = ao2_iterator_init(struct_children->children, 0);<br>-      while ((node = ao2_iterator_next(&i))) {<br>-         member = data_search_mapping_find(mapping, mapping_len, node->name);<br>-              if (member < 0) {<br>-                 /* the structure member name doesn't match! */<br>-                   ao2_ref(node, -1);<br>-                   ao2_ref(struct_children, -1);<br>-                        ao2_iterator_destroy(&i);<br>-                        return 0;<br>-            }<br>-<br>-         notmatch = 0;<br>-                switch (mapping[member].type) {<br>-              case AST_DATA_PASSWORD:<br>-                      notmatch = data_search_cmp_string(struct_children,<br>-                           node->name,<br>-                               mapping[member].get.AST_DATA_PASSWORD(structure));<br>-                   break;<br>-               case AST_DATA_TIMESTAMP:<br>-                     notmatch = data_search_cmp_uint(struct_children,<br>-                             node->name,<br>-                               mapping[member].get.AST_DATA_TIMESTAMP(structure));<br>-                  break;<br>-               case AST_DATA_SECONDS:<br>-                       notmatch = data_search_cmp_uint(struct_children,<br>-                             node->name,<br>-                               mapping[member].get.AST_DATA_SECONDS(structure));<br>-                    break;<br>-               case AST_DATA_MILLISECONDS:<br>-                  notmatch = data_search_cmp_uint(struct_children,<br>-                             node->name,<br>-                               mapping[member].get.AST_DATA_MILLISECONDS(structure));<br>-                       break;<br>-               case AST_DATA_STRING:<br>-                        notmatch = data_search_cmp_string(struct_children,<br>-                           node->name,<br>-                               mapping[member].get.AST_DATA_STRING(structure));<br>-                     break;<br>-               case AST_DATA_CHARACTER:<br>-                     notmatch = data_search_cmp_char(struct_children,<br>-                             node->name,<br>-                               mapping[member].get.AST_DATA_CHARACTER(structure));<br>-                  break;<br>-               case AST_DATA_INTEGER:<br>-                       notmatch = data_search_cmp_int(struct_children,<br>-                              node->name,<br>-                               mapping[member].get.AST_DATA_INTEGER(structure));<br>-                    break;<br>-               case AST_DATA_BOOLEAN:<br>-                       notmatch = data_search_cmp_bool(struct_children,<br>-                             node->name,<br>-                               mapping[member].get.AST_DATA_BOOLEAN(structure));<br>-                    break;<br>-               case AST_DATA_UNSIGNED_INTEGER:<br>-                      notmatch = data_search_cmp_uint(struct_children,<br>-                             node->name,<br>-                               mapping[member].get.AST_DATA_UNSIGNED_INTEGER(structure));<br>-                   break;<br>-               case AST_DATA_DOUBLE:<br>-                        notmatch = data_search_cmp_dbl(struct_children,<br>-                              node->name,<br>-                               mapping[member].get.AST_DATA_DOUBLE(structure));<br>-                     break;<br>-               case AST_DATA_IPADDR:<br>-                        notmatch = data_search_cmp_ipaddr(struct_children,<br>-                           node->name,<br>-                               mapping[member].get.AST_DATA_IPADDR(structure));<br>-                     break;<br>-               case AST_DATA_POINTER:<br>-                       notmatch = data_search_cmp_ptr(struct_children,<br>-                              node->name,<br>-                               mapping[member].get.AST_DATA_POINTER(structure));<br>-                    break;<br>-               case AST_DATA_CONTAINER:<br>-                     break;<br>-               }<br>-<br>-         ao2_ref(node, -1);<br>-   }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     ao2_ref(struct_children, -1);<br>-<br>-     return notmatch;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Release the memory allocated by a call to ao2_alloc.<br>- */<br>-static void data_result_destructor(void *obj)<br>-{<br>-      struct ast_data *root = obj;<br>-<br>-      switch (root->type) {<br>-     case AST_DATA_PASSWORD:<br>-      case AST_DATA_STRING:<br>-                ast_free(root->payload.str);<br>-              ao2_ref(root->children, -1);<br>-              break;<br>-       case AST_DATA_POINTER:<br>-       case AST_DATA_CHARACTER:<br>-     case AST_DATA_CONTAINER:<br>-     case AST_DATA_INTEGER:<br>-       case AST_DATA_TIMESTAMP:<br>-     case AST_DATA_SECONDS:<br>-       case AST_DATA_MILLISECONDS:<br>-  case AST_DATA_UNSIGNED_INTEGER:<br>-      case AST_DATA_DOUBLE:<br>-        case AST_DATA_BOOLEAN:<br>-       case AST_DATA_IPADDR:<br>-                ao2_ref(root->children, -1);<br>-              break;<br>-       }<br>-}<br>-<br>-static struct ast_data *data_result_create(const char *name)<br>-{<br>-  struct ast_data *res;<br>-        size_t namelen;<br>-<br>-   namelen = ast_strlen_zero(name) ? 1 : strlen(name) + 1;<br>-<br>-   res = ao2_alloc(sizeof(*res) + namelen, data_result_destructor);<br>-     if (!res) {<br>-          return NULL;<br>- }<br>-<br>- strcpy(res->name, namelen ? name : "");<br>-<br>-      /* initialize the children container */<br>-      res->children = ao2_container_alloc(NUM_DATA_RESULT_BUCKETS, data_result_hash,<br>-            data_result_cmp);<br>-    if (!res->children) {<br>-             ao2_ref(res, -1);<br>-            return NULL;<br>- }<br>-<br>- /* set this node as a container. */<br>-  res->type = AST_DATA_CONTAINER;<br>-<br>-        return res;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Find a child node, based on its name.<br>- * \param[in] root The starting point.<br>- * \param[in] name The child name.<br>- * \retval NULL if the node wasn't found.<br>- * \retval non-NULL the node we were looking for.<br>- */<br>-static struct ast_data *data_result_find_child(struct ast_data *root, const char *name)<br>-{<br>-      struct ast_data *found, *find_node;<br>-<br>-       find_node = data_result_create(name);<br>-        if (!find_node) {<br>-            return NULL;<br>- }<br>-<br>- found = ao2_find(root->children, find_node, OBJ_POINTER);<br>-<br>-      /* release the temporary created node used for searching. */<br>- ao2_ref(find_node, -1);<br>-<br>-   return found;<br>-}<br>-<br>-int ast_data_search_match(const struct ast_data_search *search, struct ast_data *data)<br>-{<br>-    struct ao2_iterator i, ii;<br>-   struct ast_data_search *s, *s_child;<br>- struct ast_data *d_child;<br>-    int notmatch = 1;<br>-<br>- if (!search) {<br>-               return 1;<br>-    }<br>-<br>- s_child = data_search_find(search->children, data->name);<br>-      if (!s_child) {<br>-              /* nothing to compare */<br>-             ao2_ref(s_child, -1);<br>-                return 1;<br>-    }<br>-<br>- i = ao2_iterator_init(s_child->children, 0);<br>-      while ((s = ao2_iterator_next(&i))) {<br>-            if (!ao2_container_count(s->children)) {<br>-                  /* compare this search node with every data node */<br>-                  d_child = data_result_find_child(data, s->name);<br>-                  if (!d_child) {<br>-                              ao2_ref(s, -1);<br>-                              notmatch = 1;<br>-                                continue;<br>-                    }<br>-<br>-                 switch (d_child->type) {<br>-                  case AST_DATA_PASSWORD:<br>-                      case AST_DATA_STRING:<br>-                                notmatch = data_search_cmp_string(s_child, d_child->name,<br>-                                 d_child->payload.str);<br>-                            break;<br>-                       case AST_DATA_CHARACTER:<br>-                             notmatch = data_search_cmp_char(s_child, d_child->name,<br>-                                   d_child->payload.character);<br>-                              break;<br>-                       case AST_DATA_INTEGER:<br>-                               notmatch = data_search_cmp_int(s_child, d_child->name,<br>-                                    d_child->payload.sint);<br>-                           break;<br>-                       case AST_DATA_BOOLEAN:<br>-                               notmatch = data_search_cmp_bool(s_child, d_child->name,<br>-                                   d_child->payload.boolean);<br>-                                break;<br>-                       case AST_DATA_UNSIGNED_INTEGER:<br>-                              notmatch = data_search_cmp_uint(s_child, d_child->name,<br>-                                   d_child->payload.uint);<br>-                           break;<br>-                       case AST_DATA_TIMESTAMP:<br>-                     case AST_DATA_SECONDS:<br>-                       case AST_DATA_MILLISECONDS:<br>-                  case AST_DATA_DOUBLE:<br>-                                notmatch = data_search_cmp_uint(s_child, d_child->name,<br>-                                   d_child->payload.dbl);<br>-                            break;<br>-                       case AST_DATA_IPADDR:<br>-                                notmatch = data_search_cmp_ipaddr(s_child, d_child->name,<br>-                                 d_child->payload.ipaddr);<br>-                         break;<br>-                       case AST_DATA_POINTER:<br>-                               notmatch = data_search_cmp_ptr(s_child, d_child->name,<br>-                                    d_child->payload.ptr);<br>-                            break;<br>-                       case AST_DATA_CONTAINER:<br>-                             break;<br>-                       }<br>-                    ao2_ref(d_child, -1);<br>-                } else {<br>-                     ii = ao2_iterator_init(data->children, 0);<br>-                        while ((d_child = ao2_iterator_next(&ii))) {<br>-                             if (strcmp(d_child->name, s->name)) {<br>-                                  ao2_ref(d_child, -1);<br>-                                        continue;<br>-                            }<br>-                            if (!(notmatch = !ast_data_search_match(s_child, d_child))) {<br>-                                        /* do not continue if we have a match. */<br>-                                    ao2_ref(d_child, -1);<br>-                                        break;<br>-                               }<br>-                            ao2_ref(d_child, -1);<br>-                        }<br>-                    ao2_iterator_destroy(&ii);<br>-               }<br>-            ao2_ref(s, -1);<br>-              if (notmatch) {<br>-                      /* do not continue if we don't have a match. */<br>-                  break;<br>-               }<br>-    }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     ao2_ref(s_child, -1);<br>-<br>-     return !notmatch;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Get an internal node, from the result set.<br>- * \param[in] node A node container.<br>- * \param[in] path The path to the needed internal node.<br>- * \retval NULL if the internal node is not found.<br>- * \retval non-NULL the internal node with path 'path'.<br>- */<br>-static struct ast_data *data_result_get_node(struct ast_data *node,<br>-    const char *path)<br>-{<br>-        char *savepath, *node_name;<br>-  struct ast_data *child, *current = node;<br>-<br>-  savepath = ast_strdupa(path);<br>-        node_name = next_node_name(&savepath);<br>-<br>-        while (node_name) {<br>-          child = data_result_find_child(current, node_name);<br>-          if (current != node) {<br>-                       ao2_ref(current, -1);<br>-                }<br>-            if (!child) {<br>-                        return NULL;<br>-         }<br>-            current = child;<br>-             node_name = next_node_name(&savepath);<br>-   }<br>-<br>- /* do not increment the refcount of the returned object. */<br>-  if (current != node) {<br>-               ao2_ref(current, -1);<br>-        }<br>-<br>- return current;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Add a child to the specified root node.<br>- * \param[in] root The root node pointer.<br>- * \param[in] child The child to add to the root node.<br>- */<br>-static void data_result_add_child(struct ast_data *root, struct ast_data *child)<br>-{<br>-    ao2_link(root->children, child);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Common string hash function for data nodes<br>- */<br>-static int data_filter_hash(const void *obj, const int flags)<br>-{<br>-     const struct data_filter *node = obj;<br>-        return ast_str_hash(node->name);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Common string comparison function<br>- */<br>-static int data_filter_cmp(void *obj, void *arg, int flags)<br>-{<br>-        struct data_filter *node1 = obj, *node2 = arg;<br>-       return strcasecmp(node1->name, node2->name) ? 0 : CMP_MATCH;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Destroy a data filter tree.<br>- * \param[in] obj Data filter list to be destroyed.<br>- */<br>-static void data_filter_destructor(void *obj)<br>-{<br>-       struct data_filter *filter = obj, *globres;<br>-<br>-       while ((globres = AST_LIST_REMOVE_HEAD(&(filter->glob_list), list))) {<br>-                ao2_ref(globres, -1);<br>-        }<br>-<br>- ao2_ref(filter->children, -1);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Allocate a filter node.<br>- * \retval NULL on error.<br>- * \retval non-NULL The allocated search node structure.<br>- */<br>-static struct data_filter *data_filter_alloc(const char *name)<br>-{<br>-  char *globname, *token;<br>-      struct data_filter *res, *globfilter;<br>-        size_t name_len = strlen(name) + 1;<br>-<br>-       res = ao2_alloc(sizeof(*res) + name_len, data_filter_destructor);<br>-    if (!res) {<br>-          return NULL;<br>- }<br>-<br>- res->children = ao2_container_alloc(NUM_DATA_FILTER_BUCKETS, data_filter_hash,<br>-            data_filter_cmp);<br>-<br>- if (!res->children) {<br>-             ao2_ref(res, -1);<br>-            return NULL;<br>- }<br>-<br>- strcpy(res->name, name);<br>-<br>-       if (strchr(res->name, '*')) {<br>-             globname = ast_strdupa(res->name);<br>-<br>-             while ((token = strsep(&globname, "*"))) {<br>-                     globfilter = data_filter_alloc(token);<br>-                       AST_LIST_INSERT_TAIL(&(res->glob_list), globfilter, list);<br>-            }<br>-    }<br>-<br>- return res;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Release a filter tree.<br>- * \param[in] filter The filter tree root node.<br>- */<br>-static void data_filter_release(struct data_filter *filter)<br>-{<br>- ao2_ref(filter, -1);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Find a child node, based on his name.<br>- * \param[in] parent Where to find the node.<br>- * \param[in] name The node name to find.<br>- * \retval NULL if a node wasn't found.<br>- * \retval The node found.<br>- * \note Remember to decrement the ref count of the returned node after using it.<br>- */<br>-static struct data_filter *data_filter_find(struct ao2_container *parent,<br>-       const char *name)<br>-{<br>-        int i, olend, orend, globfound;<br>-      size_t name_len = strlen(name), glob_len;<br>-    struct ao2_iterator iter;<br>-    struct data_filter *find_node, *found, *globres;<br>-<br>-  find_node = data_filter_alloc(name);<br>- if (!find_node) {<br>-            return NULL;<br>- }<br>-<br>- found = ao2_find(parent, find_node, OBJ_POINTER);<br>-<br>- /* free the created node used for searching. */<br>-      ao2_ref(find_node, -1);<br>-<br>-   if (found) {<br>-         return found;<br>-        }<br>-<br>- iter = ao2_iterator_init(parent, 0);<br>- while ((found = ao2_iterator_next(&iter))) {<br>-             if (!AST_LIST_EMPTY(&(found->glob_list))) {<br>-                   i = 0;<br>-                       globfound = 1;<br>-<br>-                    olend = ast_strlen_zero(AST_LIST_FIRST(&(found->glob_list))->name);<br>-                        orend = ast_strlen_zero(AST_LIST_LAST(&(found->glob_list))->name);<br>-<br>-                      AST_LIST_TRAVERSE(&(found->glob_list), globres, list) {<br>-                               if (!*globres->name) {<br>-                                    continue;<br>-                            }<br>-<br>-                         glob_len = strlen(globres->name);<br>-<br>-                              if (!i && !olend) {<br>-                                  if (strncasecmp(name, globres->name, glob_len)) {<br>-                                         globfound = 0;<br>-                                               break;<br>-                                       }<br>-<br>-                                 i += glob_len;<br>-                                       continue;<br>-                            }<br>-<br>-                         for (globfound = 0; name_len - i >= glob_len; ++i) {<br>-                                      if (!strncasecmp(name + i, globres->name, glob_len)) {<br>-                                            globfound = 1;<br>-                                               i += glob_len;<br>-                                               break;<br>-                                       }<br>-                            }<br>-<br>-                         if (!globfound) {<br>-                                    break;<br>-                               }<br>-                    }<br>-<br>-                 if (globfound && (i == name_len || orend)) {<br>-                         ao2_iterator_destroy(&iter);<br>-                             return found;<br>-                        }<br>-            }<br>-<br>-         ao2_ref(found, -1);<br>-  }<br>-    ao2_iterator_destroy(&iter);<br>-<br>-  return NULL;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Add a child to the specified node.<br>- * \param[in] root The root node where to add the child.<br>- * \param[in] name The name of the node to add.<br>- * \note Remember to decrement the ref count after using the returned node.<br>- */<br>-static struct data_filter *data_filter_add_child(struct ao2_container *root,<br>-      char *name)<br>-{<br>-      struct data_filter *node;<br>-<br>- node = data_filter_find(root, name);<br>- if (node) {<br>-          return node;<br>- }<br>-<br>- node = data_filter_alloc(name);<br>-      if (!node) {<br>-         return NULL;<br>- }<br>-<br>- ao2_link(root, node);<br>-<br>-     return node;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Add a node to a filter list from a path<br>- * \param[in] Filter list to add the path onto.<br>- * \param[in] The path to add into the filter list.<br>- * \retval NULL on error.<br>- * \retval non-NULL A tree with the wanted nodes.<br>- */<br>-static int data_filter_add_nodes(struct ao2_container *root, char *path)<br>-{<br>-    struct data_filter *node;<br>-    char *savepath, *saveptr, *token, *node_name;<br>-        int ret = 0;<br>-<br>-      if (!path) {<br>-         return 0;<br>-    }<br>-<br>- savepath = ast_strdupa(path);<br>-<br>-     node_name = next_node_name(&savepath);<br>-<br>-        if (!node_name) {<br>-            return 0;<br>-    }<br>-<br>- for (token = strtok_r(node_name, "|", &saveptr);<br>-                       token; token = strtok_r(NULL, "|", &saveptr)) {<br>-                node = data_filter_add_child(root, token);<br>-           if (!node) {<br>-                 continue;<br>-            }<br>-            data_filter_add_nodes(node->children, savepath);<br>-          ret = 1;<br>-             ao2_ref(node, -1);<br>-   }<br>-<br>- return ret;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Generate a filter list based on a filter string provided by the API user.<br>- * \param[in] A filter string to create a filter from.<br>- */<br>-static struct data_filter *data_filter_generate(const char *constfilter)<br>-{<br>-  struct data_filter *filter = NULL;<br>-   char *strfilter, *token, *saveptr;<br>-   int node_added = 0;<br>-<br>-       if (!constfilter) {<br>-          return NULL;<br>- }<br>-<br>- strfilter = ast_strdupa(constfilter);<br>-<br>-     filter = data_filter_alloc("/");<br>-   if (!filter) {<br>-               return NULL;<br>- }<br>-<br>- for (token = strtok_r(strfilter, ",", &saveptr); token;<br>-                        token = strtok_r(NULL, ",", &saveptr)) {<br>-               node_added = data_filter_add_nodes(filter->children, token);<br>-      }<br>-<br>- if (!node_added) {<br>-           ao2_ref(filter, -1);<br>-         return NULL;<br>- }<br>-<br>- return filter;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Generate all the tree from a specified provider.<br>- * \param[in] query The query executed.<br>- * \param[in] root_provider The provider specified in the path of the query.<br>- * \param[in] parent_node_name The root node name.<br>- * \retval NULL on error.<br>- * \retval non-NULL The generated result tree.<br>- */<br>-static struct ast_data *data_result_generate_node(const struct ast_data_query *query,<br>-     const struct data_provider *root_provider,<br>-   const char *parent_node_name,<br>-        const struct ast_data_search *search,<br>-        const struct data_filter *filter)<br>-{<br>-        struct ast_data *generated, *node;<br>-   struct ao2_iterator i;<br>-       struct data_provider *provider;<br>-      struct ast_data_search *search_child = NULL;<br>- struct data_filter *filter_child;<br>-<br>- node = data_result_create(parent_node_name);<br>- if (!node) {<br>-         ast_log(LOG_ERROR, "Unable to allocate '%s' node\n", parent_node_name);<br>-            return NULL;<br>- }<br>-<br>- if (root_provider->module) {<br>-              ast_module_ref(root_provider->module);<br>-    }<br>-<br>- /* if this is a terminal node, just run the callback function. */<br>-    if (root_provider->handler && root_provider->handler->get) {<br>-                node->filter = filter;<br>-            root_provider->handler->get(search, node);<br>-             if (root_provider->module) {<br>-                      ast_module_unref(root_provider->module);<br>-          }<br>-            return node;<br>- }<br>-<br>- if (root_provider->module) {<br>-              ast_module_unref(root_provider->module);<br>-  }<br>-<br>- /* if this is not a terminal node, generate every child node. */<br>-     i = ao2_iterator_init(root_provider->children, 0);<br>-        while ((provider = ao2_iterator_next(&i))) {<br>-             filter_child = NULL;<br>-         generated = NULL;<br>-<br>-         /* get the internal search node. */<br>-          if (search) {<br>-                        search_child = data_search_find(search->children, provider->name);<br>-             }<br>-            /* get the internal filter node. */<br>-          if (filter) {<br>-                        filter_child = data_filter_find(filter->children, provider->name);<br>-             }<br>-<br>-         if (!filter || filter_child) {<br>-                       /* only generate the internal node, if we have something to<br>-                   * generate based on the filtering string. */<br>-                        generated = data_result_generate_node(query, provider,<br>-                               provider->name,<br>-                           search_child, filter_child);<br>-         }<br>-<br>-         /* decrement the refcount of the internal search node. */<br>-            if (search_child) {<br>-                  ao2_ref(search_child, -1);<br>-           }<br>-<br>-         /* decrement the refcount of the internal filter node. */<br>-            if (filter_child) {<br>-                  ao2_ref(filter_child, -1);<br>-           }<br>-<br>-         if (generated) {<br>-                     data_result_add_child(node, generated);<br>-                      ao2_ref(generated, -1);<br>-              }<br>-<br>-         ao2_ref(provider, -1);<br>-       }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     return node;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Generate a result tree based on a query.<br>- * \param[in] query The complete query structure.<br>- * \param[in] search_path The path to retrieve.<br>- * \retval NULL on error.<br>- * \retval non-NULL The generated data result.<br>- */<br>-static struct ast_data *data_result_generate(const struct ast_data_query *query,<br>-    const char *search_path)<br>-{<br>- char *node_name, *tmp_path;<br>-  struct data_provider *provider_child, *tmp_provider_child;<br>-   struct ast_data *result, *result_filtered;<br>-   struct ast_data_search *search = NULL, *search_child = NULL;<br>- struct data_filter *filter = NULL, *filter_child = NULL;<br>-<br>-  if (!search_path) {<br>-          /* generate all the trees?. */<br>-               return NULL;<br>- }<br>-<br>- tmp_path = ast_strdupa(search_path);<br>-<br>-      /* start searching the root node name */<br>-     node_name = next_node_name(&tmp_path);<br>-   if (!node_name) {<br>-            return NULL;<br>- }<br>-    provider_child = data_provider_find(root_data.container, node_name, NULL);<br>-<br>-        /* continue with the rest of the path. */<br>-    while (provider_child) {<br>-             node_name = next_node_name(&tmp_path);<br>-           if (!node_name) {<br>-                    break;<br>-               }<br>-<br>-         tmp_provider_child = data_provider_find(provider_child->children,<br>-                         node_name, NULL);<br>-<br>-         /* release the reference from this child */<br>-          ao2_ref(provider_child, -1);<br>-<br>-              provider_child = tmp_provider_child;<br>- }<br>-<br>- if (!provider_child) {<br>-               ast_log(LOG_ERROR, "Invalid path '%s', '%s' not found.\n",<br>-                         tmp_path, node_name);<br>-                return NULL;<br>- }<br>-<br>- /* generate the search tree. */<br>-      if (query->search) {<br>-              search = data_search_generate(query->search);<br>-             if (search) {<br>-                        search_child = data_search_find(search->children,<br>-                         provider_child->name);<br>-            }<br>-    }<br>-<br>- /* generate the filter tree. */<br>-      if (query->filter) {<br>-              filter = data_filter_generate(query->filter);<br>-             if (filter) {<br>-                        filter_child = data_filter_find(filter->children,<br>-                         provider_child->name);<br>-            }<br>-    }<br>-<br>- result = data_result_generate_node(query, provider_child, provider_child->name,<br>-                   search_child, filter_child);<br>-<br>-      /* release the requested provider. */<br>-        ao2_ref(provider_child, -1);<br>-<br>-      /* release the generated search tree. */<br>-     if (search_child) {<br>-          ao2_ref(search_child, -1);<br>-   }<br>-<br>- if (filter_child) {<br>-          ao2_ref(filter_child, -1);<br>-   }<br>-<br>- if (search) {<br>-                data_search_release(search);<br>- }<br>-<br>- result_filtered = result;<br>-<br>- /* release the generated filter tree. */<br>-     if (filter) {<br>-                data_filter_release(filter);<br>- }<br>-<br>- return result_filtered;<br>-}<br>-<br>-struct ast_data *ast_data_get(const struct ast_data_query *query)<br>-{<br>-       struct ast_data *res;<br>-<br>-     /* check compatibility */<br>-    if (!data_structure_compatible(query->version, latest_query_compatible_version,<br>-           current_query_version)) {<br>-            return NULL;<br>- }<br>-<br>- data_read_lock();<br>-    res = data_result_generate(query, query->path);<br>-   data_unlock();<br>-<br>-    if (!res) {<br>-          ast_log(LOG_ERROR, "Unable to get data from %s\n", query->path);<br>-                return NULL;<br>- }<br>-<br>- return res;<br>-}<br>-<br>-#ifdef HAVE_LIBXML2<br>-/*!<br>- * \internal<br>- * \brief Helper function to move an ast_data tree to xml.<br>- * \param[in] parent_data The initial ast_data node to be passed to xml.<br>- * \param[out] parent_xml The root node to insert the xml.<br>- */<br>-static void data_get_xml_add_child(struct ast_data *parent_data,<br>-  struct ast_xml_node *parent_xml)<br>-{<br>- struct ao2_iterator i;<br>-       struct ast_data *node;<br>-       struct ast_xml_node *child_xml;<br>-      char node_content[256];<br>-<br>-   i = ao2_iterator_init(parent_data->children, 0);<br>-  while ((node = ao2_iterator_next(&i))) {<br>-         child_xml = ast_xml_new_node(node->name);<br>-         if (!child_xml) {<br>-                    ao2_ref(node, -1);<br>-                   continue;<br>-            }<br>-<br>-         switch (node->type) {<br>-             case AST_DATA_CONTAINER:<br>-                     data_get_xml_add_child(node, child_xml);<br>-                     break;<br>-               case AST_DATA_PASSWORD:<br>-                      ast_xml_set_text(child_xml, node->payload.str);<br>-                   break;<br>-               case AST_DATA_TIMESTAMP:<br>-                     snprintf(node_content, sizeof(node_content), "%u",<br>-                         node->payload.uint);<br>-                      ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_SECONDS:<br>-                       snprintf(node_content, sizeof(node_content), "%u",<br>-                         node->payload.uint);<br>-                      ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_MILLISECONDS:<br>-                  snprintf(node_content, sizeof(node_content), "%u",<br>-                         node->payload.uint);<br>-                      ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_STRING:<br>-                        ast_xml_set_text(child_xml, node->payload.str);<br>-                   break;<br>-               case AST_DATA_CHARACTER:<br>-                     snprintf(node_content, sizeof(node_content), "%c",<br>-                         node->payload.character);<br>-                 ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_INTEGER:<br>-                       snprintf(node_content, sizeof(node_content), "%d",<br>-                         node->payload.sint);<br>-                      ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_UNSIGNED_INTEGER:<br>-                      snprintf(node_content, sizeof(node_content), "%u",<br>-                         node->payload.uint);<br>-                      ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_DOUBLE:<br>-                        snprintf(node_content, sizeof(node_content), "%f",<br>-                         node->payload.dbl);<br>-                       ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_BOOLEAN:<br>-                       if (node->payload.boolean) {<br>-                              ast_xml_set_text(child_xml, "true");<br>-                       } else {<br>-                             ast_xml_set_text(child_xml, "false");<br>-                      }<br>-                    break;<br>-               case AST_DATA_POINTER:<br>-                       snprintf(node_content, sizeof(node_content), "%p",<br>-                         node->payload.ptr);<br>-                       ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               case AST_DATA_IPADDR:<br>-                        snprintf(node_content, sizeof(node_content), "%s",<br>-                         ast_inet_ntoa(node->payload.ipaddr));<br>-                     ast_xml_set_text(child_xml, node_content);<br>-                   break;<br>-               }<br>-            ast_xml_add_child(parent_xml, child_xml);<br>-<br>-         ao2_ref(node, -1);<br>-   }<br>-    ao2_iterator_destroy(&i);<br>-<br>-}<br>-<br>-struct ast_xml_doc *ast_data_get_xml(const struct ast_data_query *query)<br>-{<br>-       struct ast_xml_doc *doc;<br>-     struct ast_xml_node *root;<br>-   struct ast_data *res;<br>-<br>-     res = ast_data_get(query);<br>-   if (!res) {<br>-          return NULL;<br>- }<br>-<br>- doc = ast_xml_new();<br>- if (!doc) {<br>-          ast_data_free(res);<br>-          return NULL;<br>- }<br>-<br>- root = ast_xml_new_node(res->name);<br>-       if (!root) {<br>-         ast_xml_close(doc);<br>-  }<br>-<br>- ast_xml_set_root(doc, root);<br>-<br>-      data_get_xml_add_child(res, root);<br>-<br>-        ast_data_free(res);<br>-<br>-       return doc;<br>-}<br>-#endif<br>-<br>-enum ast_data_type ast_data_retrieve_type(struct ast_data *node, const char *path)<br>-{<br>- struct ast_data *internal;<br>-<br>-        internal = data_result_get_node(node, path);<br>- if (!internal) {<br>-             return -1;<br>-   }<br>-<br>- return internal->type;<br>-}<br>-<br>-char *ast_data_retrieve_name(struct ast_data *node)<br>-{<br>-   return node->name;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Insert a child node inside a passed parent node.<br>- * \param root Where we are going to insert the child node.<br>- * \param name The name of the child node to add.<br>- * \param type The type of content inside the child node.<br>- * \param ptr The actual content of the child node.<br>- * \retval NULL on error.<br>- * \retval non-NULL The added child node pointer.<br>- */<br>-static struct ast_data *__ast_data_add(struct ast_data *root, const char *name,<br>-   enum ast_data_type type, void *ptr)<br>-{<br>-      struct ast_data *node;<br>-       struct data_filter *filter, *filter_child = NULL;<br>-<br>- if (!root || !root->children) {<br>-           /* invalid data result node. */<br>-              return NULL;<br>- }<br>-<br>- /* check if we need to add this node, based on the filter. */<br>-        if (root->filter) {<br>-               filter = data_filter_find(root->filter->children, name);<br>-               if (!filter) {<br>-                       return NULL;<br>-         }<br>-            ao2_ref(filter, -1);<br>- }<br>-<br>- node = data_result_create(name);<br>-     if (!node) {<br>-         return NULL;<br>- }<br>-<br>- node->type = type;<br>-<br>-     switch (type) {<br>-      case AST_DATA_BOOLEAN:<br>-               node->payload.boolean = *(unsigned int *) ptr;<br>-            break;<br>-       case AST_DATA_INTEGER:<br>-               node->payload.sint = *(int *) ptr;<br>-                break;<br>-       case AST_DATA_TIMESTAMP:<br>-     case AST_DATA_SECONDS:<br>-       case AST_DATA_MILLISECONDS:<br>-  case AST_DATA_UNSIGNED_INTEGER:<br>-              node->payload.uint = *(unsigned int *) ptr;<br>-               break;<br>-       case AST_DATA_DOUBLE:<br>-                node->payload.dbl = *(double *) ptr;<br>-              break;<br>-       case AST_DATA_PASSWORD:<br>-      case AST_DATA_STRING:<br>-                node->payload.str = (char *) ptr;<br>-         break;<br>-       case AST_DATA_CHARACTER:<br>-             node->payload.character = *(char *) ptr;<br>-          break;<br>-       case AST_DATA_POINTER:<br>-               node->payload.ptr = ptr;<br>-          break;<br>-       case AST_DATA_IPADDR:<br>-                node->payload.ipaddr = *(struct in_addr *) ptr;<br>-           break;<br>-       case AST_DATA_CONTAINER:<br>-             if (root->filter) {<br>-                       filter_child = data_filter_find(root->filter->children, name);<br>-                 if (filter_child) {<br>-                          /* do not increment the refcount because it is not neccesary. */<br>-                             ao2_ref(filter_child, -1);<br>-                   }<br>-            }<br>-            node->filter = filter_child;<br>-              break;<br>-       default:<br>-             break;<br>-       }<br>-<br>- data_result_add_child(root, node);<br>-<br>-        ao2_ref(node, -1);<br>-<br>-        return node;<br>-}<br>-<br>-struct ast_data *ast_data_add_node(struct ast_data *root, const char *name)<br>-{<br>-        return __ast_data_add(root, name, AST_DATA_CONTAINER, NULL);<br>-}<br>-<br>-struct ast_data *ast_data_add_int(struct ast_data *root, const char *name, int value)<br>-{<br>-      return __ast_data_add(root, name, AST_DATA_INTEGER, &value);<br>-}<br>-<br>-struct ast_data *ast_data_add_char(struct ast_data *root, const char *name, char value)<br>-{<br>-        return __ast_data_add(root, name, AST_DATA_CHARACTER, &value);<br>-}<br>-<br>-struct ast_data *ast_data_add_uint(struct ast_data *root, const char *name,<br>-      unsigned int value)<br>-{<br>-      return __ast_data_add(root, name, AST_DATA_UNSIGNED_INTEGER, &value);<br>-}<br>-<br>-struct ast_data *ast_data_add_dbl(struct ast_data *root, const char *childname,<br>-   double dbl)<br>-{<br>-      return __ast_data_add(root, childname, AST_DATA_DOUBLE, &dbl);<br>-}<br>-<br>-struct ast_data *ast_data_add_bool(struct ast_data *root, const char *childname,<br>- unsigned int boolean)<br>-{<br>-    return __ast_data_add(root, childname, AST_DATA_BOOLEAN, &boolean);<br>-}<br>-<br>-struct ast_data *ast_data_add_ipaddr(struct ast_data *root, const char *childname,<br>-  struct in_addr addr)<br>-{<br>-     return __ast_data_add(root, childname, AST_DATA_IPADDR, &addr);<br>-}<br>-<br>-struct ast_data *ast_data_add_ptr(struct ast_data *root, const char *childname,<br>- void *ptr)<br>-{<br>-       return __ast_data_add(root, childname, AST_DATA_POINTER, ptr);<br>-}<br>-<br>-struct ast_data *ast_data_add_timestamp(struct ast_data *root, const char *childname,<br>-        unsigned int timestamp)<br>-{<br>-  return __ast_data_add(root, childname, AST_DATA_TIMESTAMP, &timestamp);<br>-}<br>-<br>-struct ast_data *ast_data_add_seconds(struct ast_data *root, const char *childname,<br>-     unsigned int seconds)<br>-{<br>-    return __ast_data_add(root, childname, AST_DATA_SECONDS, &seconds);<br>-}<br>-<br>-struct ast_data *ast_data_add_milliseconds(struct ast_data *root, const char *childname,<br>-    unsigned int milliseconds)<br>-{<br>-       return __ast_data_add(root, childname, AST_DATA_MILLISECONDS, &milliseconds);<br>-}<br>-<br>-struct ast_data *ast_data_add_password(struct ast_data *root, const char *childname,<br>-      const char *value)<br>-{<br>-       char *name;<br>-  size_t namelen = 1 + (ast_strlen_zero(value) ? 0 : strlen(value));<br>-   struct ast_data *res;<br>-<br>-     if (!(name = ast_malloc(namelen))) {<br>-         return NULL;<br>- }<br>-<br>- strcpy(name, (ast_strlen_zero(value) ? "" : value));<br>-<br>-    res = __ast_data_add(root, childname, AST_DATA_PASSWORD, name);<br>-      if (!res) {<br>-          ast_free(name);<br>-      }<br>-<br>- return res;<br>-}<br>-<br>-struct ast_data *ast_data_add_str(struct ast_data *root, const char *childname,<br>- const char *value)<br>-{<br>-       char *name;<br>-  size_t namelen = 1 + (ast_strlen_zero(value) ? 0 : strlen(value));<br>-   struct ast_data *res;<br>-<br>-     if (!(name = ast_malloc(namelen))) {<br>-         return NULL;<br>- }<br>-<br>- strcpy(name, (ast_strlen_zero(value) ? "" : value));<br>-<br>-    res = __ast_data_add(root, childname, AST_DATA_STRING, name);<br>-        if (!res) {<br>-          ast_free(name);<br>-      }<br>-<br>- return res;<br>-}<br>-<br>-int __ast_data_add_structure(struct ast_data *root,<br>-     const struct ast_data_mapping_structure *mapping, size_t mapping_len,<br>-        void *structure)<br>-{<br>- int i;<br>-<br>-    for (i = 0; i < mapping_len; i++) {<br>-               switch (mapping[i].type) {<br>-           case AST_DATA_INTEGER:<br>-                       ast_data_add_int(root, mapping[i].name,<br>-                              mapping[i].get.AST_DATA_INTEGER(structure));<br>-                 break;<br>-               case AST_DATA_UNSIGNED_INTEGER:<br>-                      ast_data_add_uint(root, mapping[i].name,<br>-                             mapping[i].get.AST_DATA_UNSIGNED_INTEGER(structure));<br>-                        break;<br>-               case AST_DATA_DOUBLE:<br>-                        ast_data_add_dbl(root, mapping[i].name,<br>-                              mapping[i].get.AST_DATA_DOUBLE(structure));<br>-                  break;<br>-               case AST_DATA_BOOLEAN:<br>-                       ast_data_add_bool(root, mapping[i].name,<br>-                             mapping[i].get.AST_DATA_BOOLEAN(structure));<br>-                 break;<br>-               case AST_DATA_PASSWORD:<br>-                      ast_data_add_password(root, mapping[i].name,<br>-                         mapping[i].get.AST_DATA_PASSWORD(structure));<br>-                        break;<br>-               case AST_DATA_TIMESTAMP:<br>-                     ast_data_add_timestamp(root, mapping[i].name,<br>-                                mapping[i].get.AST_DATA_TIMESTAMP(structure));<br>-                       break;<br>-               case AST_DATA_SECONDS:<br>-                       ast_data_add_seconds(root, mapping[i].name,<br>-                          mapping[i].get.AST_DATA_SECONDS(structure));<br>-                 break;<br>-               case AST_DATA_MILLISECONDS:<br>-                  ast_data_add_milliseconds(root, mapping[i].name,<br>-                             mapping[i].get.AST_DATA_MILLISECONDS(structure));<br>-                    break;<br>-               case AST_DATA_STRING:<br>-                        ast_data_add_str(root, mapping[i].name,<br>-                              mapping[i].get.AST_DATA_STRING(structure));<br>-                  break;<br>-               case AST_DATA_CHARACTER:<br>-                     ast_data_add_char(root, mapping[i].name,<br>-                             mapping[i].get.AST_DATA_CHARACTER(structure));<br>-                       break;<br>-               case AST_DATA_CONTAINER:<br>-                     break;<br>-               case AST_DATA_IPADDR:<br>-                        ast_data_add_ipaddr(root, mapping[i].name,<br>-                           mapping[i].get.AST_DATA_IPADDR(structure));<br>-                  break;<br>-               case AST_DATA_POINTER:<br>-                       ast_data_add_ptr(root, mapping[i].name,<br>-                              mapping[i].get.AST_DATA_POINTER(structure));<br>-                 break;<br>-               }<br>-    }<br>-<br>- return 0;<br>-}<br>-<br>-void ast_data_remove_node(struct ast_data *root, struct ast_data *child)<br>-{<br>-      ao2_unlink(root->children, child);<br>-}<br>-<br>-void ast_data_free(struct ast_data *root)<br>-{<br>- /* destroy it, this will destroy all the internal nodes. */<br>-  ao2_ref(root, -1);<br>-}<br>-<br>-struct ast_data_iterator *ast_data_iterator_init(struct ast_data *tree,<br>-  const char *elements)<br>-{<br>-    struct ast_data_iterator *iterator;<br>-  struct ao2_iterator i;<br>-       struct ast_data *internal = tree;<br>-    char *path, *ptr = NULL;<br>-<br>-  if (!elements) {<br>-             return NULL;<br>- }<br>-<br>- /* tree is the node we want to use to iterate? or we are going<br>-        * to iterate thow an internal node? */<br>-      path = ast_strdupa(elements);<br>-<br>-     ptr = strrchr(path, '/');<br>-    if (ptr) {<br>-           *ptr = '\0';<br>-         internal = data_result_get_node(tree, path);<br>-         if (!internal) {<br>-                     return NULL;<br>-         }<br>-    }<br>-<br>- iterator = ast_calloc(1, sizeof(*iterator));<br>- if (!iterator) {<br>-             return NULL;<br>- }<br>-<br>- i = ao2_iterator_init(internal->children, 0);<br>-<br>-  iterator->pattern = (ptr ? strrchr(elements, '/') + 1 : elements);<br>-<br>-     /* is the last node a regular expression?, compile it! */<br>-    if (!regcomp(&(iterator->regex_pattern), iterator->pattern,<br>-                        REG_EXTENDED | REG_NOSUB | REG_ICASE)) {<br>-             iterator->is_pattern = 1;<br>- }<br>-<br>- iterator->internal_iterator = i;<br>-<br>-       return iterator;<br>-}<br>-<br>-void ast_data_iterator_end(struct ast_data_iterator *iterator)<br>-{<br>- /* decrement the reference counter. */<br>-       if (iterator->last) {<br>-             ao2_ref(iterator->last, -1);<br>-      }<br>-<br>- /* release the generated pattern. */<br>- if (iterator->is_pattern) {<br>-               regfree(&(iterator->regex_pattern));<br>-  }<br>-<br>- ao2_iterator_destroy(&(iterator->internal_iterator));<br>-<br>-      ast_free(iterator);<br>-  iterator = NULL;<br>-}<br>-<br>-struct ast_data *ast_data_iterator_next(struct ast_data_iterator *iterator)<br>-{<br>-    struct ast_data *res;<br>-<br>-     if (iterator->last) {<br>-             /* release the last retrieved node reference. */<br>-             ao2_ref(iterator->last, -1);<br>-      }<br>-<br>- while ((res = ao2_iterator_next(&iterator->internal_iterator))) {<br>-             /* if there is no node name pattern specified, return<br>-                 * the next node. */<br>-         if (!iterator->pattern) {<br>-                 break;<br>-               }<br>-<br>-         /* if the pattern is a regular expression, check if this node<br>-                 * matches. */<br>-               if (iterator->is_pattern && !regexec(&(iterator->regex_pattern),<br>-                   res->name, 0, NULL, 0)) {<br>-                 break;<br>-               }<br>-<br>-         /* if there is a pattern specified, check if this node matches<br>-                * the wanted node names. */<br>-         if (!iterator->is_pattern && (iterator->pattern &&<br>-                             !strcasecmp(res->name, iterator->pattern))) {<br>-                  break;<br>-               }<br>-<br>-         ao2_ref(res, -1);<br>-    }<br>-<br>- iterator->last = res;<br>-<br>-  return res;<br>-}<br>-<br>-int ast_data_retrieve(struct ast_data *tree, const char *path,<br>-  struct ast_data_retrieve *content)<br>-{<br>-       struct ast_data *node;<br>-<br>-    if (!content) {<br>-              return -1;<br>-   }<br>-<br>- node = data_result_get_node(tree, path);<br>-     if (!node) {<br>-         ast_log(LOG_ERROR, "Invalid internal node %s\n", path);<br>-            return -1;<br>-   }<br>-<br>- content->type = node->type;<br>-    switch (node->type) {<br>-     case AST_DATA_STRING:<br>-                content->value.AST_DATA_STRING = node->payload.str;<br>-            break;<br>-       case AST_DATA_PASSWORD:<br>-              content->value.AST_DATA_PASSWORD = node->payload.str;<br>-          break;<br>-       case AST_DATA_TIMESTAMP:<br>-             content->value.AST_DATA_TIMESTAMP = node->payload.uint;<br>-                break;<br>-       case AST_DATA_SECONDS:<br>-               content->value.AST_DATA_SECONDS = node->payload.uint;<br>-          break;<br>-       case AST_DATA_MILLISECONDS:<br>-          content->value.AST_DATA_MILLISECONDS = node->payload.uint;<br>-             break;<br>-       case AST_DATA_CHARACTER:<br>-             content->value.AST_DATA_CHARACTER = node->payload.character;<br>-           break;<br>-       case AST_DATA_INTEGER:<br>-               content->value.AST_DATA_INTEGER = node->payload.sint;<br>-          break;<br>-       case AST_DATA_UNSIGNED_INTEGER:<br>-              content->value.AST_DATA_UNSIGNED_INTEGER = node->payload.uint;<br>-         break;<br>-       case AST_DATA_BOOLEAN:<br>-               content->value.AST_DATA_BOOLEAN = node->payload.boolean;<br>-               break;<br>-       case AST_DATA_IPADDR:<br>-                content->value.AST_DATA_IPADDR = node->payload.ipaddr;<br>-         break;<br>-       case AST_DATA_DOUBLE:<br>-                content->value.AST_DATA_DOUBLE = node->payload.dbl;<br>-            break;<br>-       case AST_DATA_CONTAINER:<br>-             break;<br>-       case AST_DATA_POINTER:<br>-               content->value.AST_DATA_POINTER = node->payload.ptr;<br>-           break;<br>-       }<br>-<br>- return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief One color for each node type.<br>- */<br>-static const struct {<br>-        enum ast_data_type type;<br>-     int color;<br>-} data_result_color[] = {<br>-       { AST_DATA_STRING, COLOR_BLUE },<br>-     { AST_DATA_PASSWORD, COLOR_BRBLUE },<br>- { AST_DATA_TIMESTAMP, COLOR_CYAN },<br>-  { AST_DATA_SECONDS, COLOR_MAGENTA },<br>- { AST_DATA_MILLISECONDS, COLOR_BRMAGENTA },<br>-  { AST_DATA_CHARACTER, COLOR_GRAY },<br>-  { AST_DATA_INTEGER, COLOR_RED },<br>-     { AST_DATA_UNSIGNED_INTEGER, COLOR_RED },<br>-    { AST_DATA_DOUBLE, COLOR_RED },<br>-      { AST_DATA_BOOLEAN, COLOR_BRRED },<br>-   { AST_DATA_CONTAINER, COLOR_GREEN },<br>- { AST_DATA_IPADDR, COLOR_BROWN },<br>-    { AST_DATA_POINTER, COLOR_YELLOW },<br>-};<br>-<br>-/*!<br>- * \internal<br>- * \brief Get the color configured for a specific node type.<br>- * \param[in] type The node type.<br>- * \returns The color specified for the passed type.<br>- */<br>-static int data_result_get_color(enum ast_data_type type)<br>-{<br>-     int i;<br>-       for (i = 0; i < ARRAY_LEN(data_result_color); i++) {<br>-              if (data_result_color[i].type == type) {<br>-                     return data_result_color[i].color;<br>-           }<br>-    }<br>-<br>- return COLOR_BLUE;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Print a node to the CLI.<br>- * \param[in] fd The CLI file descriptor.<br>- * \param[in] node The node to print.<br>- * \param[in] depth The actual node depth in the tree.<br>- */<br>-static void data_result_print_cli_node(int fd, const struct ast_data *node, uint32_t depth)<br>-{<br>-     int i;<br>-       struct ast_str *tabs, *output;<br>-<br>-    tabs = ast_str_create(depth * 10 + 1);<br>-       if (!tabs) {<br>-         return;<br>-      }<br>-    ast_str_reset(tabs);<br>- for (i = 0; i < depth; i++) {<br>-             ast_str_append(&tabs, 0, "  ");<br>-        }<br>-<br>- output = ast_str_create(20);<br>- if (!output) {<br>-               ast_free(tabs);<br>-              return;<br>-      }<br>-<br>- ast_str_reset(output);<br>-       ast_term_color_code(&output, data_result_get_color(node->type), 0);<br>-<br>-        switch (node->type) {<br>-     case AST_DATA_POINTER:<br>-               ast_str_append(&output, 0, "%s%s: %p\n", ast_str_buffer(tabs),<br>-                         node->name, node->payload.ptr);<br>-                break;<br>-       case AST_DATA_PASSWORD:<br>-              ast_str_append(&output, 0, "%s%s: \"%s\"\n",<br>-                         ast_str_buffer(tabs),<br>-                                node->name,<br>-                               node->payload.str);<br>-               break;<br>-       case AST_DATA_STRING:<br>-                ast_str_append(&output, 0, "%s%s: \"%s\"\n",<br>-                         ast_str_buffer(tabs),<br>-                                node->name,<br>-                               node->payload.str);<br>-               break;<br>-       case AST_DATA_CHARACTER:<br>-             ast_str_append(&output, 0, "%s%s: \'%c\'\n",<br>-                           ast_str_buffer(tabs),<br>-                                node->name,<br>-                               node->payload.character);<br>-         break;<br>-       case AST_DATA_CONTAINER:<br>-             ast_str_append(&output, 0, "%s%s\n", ast_str_buffer(tabs),<br>-                             node->name);<br>-              break;<br>-       case AST_DATA_TIMESTAMP:<br>-             ast_str_append(&output, 0, "%s%s: %u\n", ast_str_buffer(tabs),<br>-                         node->name,<br>-                               node->payload.uint);<br>-              break;<br>-       case AST_DATA_SECONDS:<br>-               ast_str_append(&output, 0, "%s%s: %u\n", ast_str_buffer(tabs),<br>-                         node->name,<br>-                               node->payload.uint);<br>-              break;<br>-       case AST_DATA_MILLISECONDS:<br>-          ast_str_append(&output, 0, "%s%s: %u\n", ast_str_buffer(tabs),<br>-                         node->name,<br>-                               node->payload.uint);<br>-              break;<br>-       case AST_DATA_INTEGER:<br>-               ast_str_append(&output, 0, "%s%s: %d\n", ast_str_buffer(tabs),<br>-                         node->name,<br>-                               node->payload.sint);<br>-              break;<br>-       case AST_DATA_UNSIGNED_INTEGER:<br>-              ast_str_append(&output, 0, "%s%s: %u\n", ast_str_buffer(tabs),<br>-                         node->name,<br>-                               node->payload.uint);<br>-              break;<br>-       case AST_DATA_DOUBLE:<br>-                ast_str_append(&output, 0, "%s%s: %lf\n", ast_str_buffer(tabs),<br>-                                node->name,<br>-                               node->payload.dbl);<br>-               break;<br>-       case AST_DATA_BOOLEAN:<br>-               ast_str_append(&output, 0, "%s%s: %s\n", ast_str_buffer(tabs),<br>-                         node->name,<br>-                               ((node->payload.boolean) ? "True" : "False"));<br>-                break;<br>-       case AST_DATA_IPADDR:<br>-                ast_str_append(&output, 0, "%s%s: %s\n", ast_str_buffer(tabs),<br>-                         node->name,<br>-                               ast_inet_ntoa(node->payload.ipaddr));<br>-             break;<br>-       }<br>-<br>- ast_free(tabs);<br>-<br>-   ast_term_color_code(&output, 0, 0);<br>-<br>-   ast_cli(fd, "%s", ast_str_buffer(output));<br>-<br>-      ast_free(output);<br>-<br>- if (node->type == AST_DATA_CONTAINER) {<br>-           __data_result_print_cli(fd, node, depth + 1);<br>-        }<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Print out an ast_data tree to the CLI.<br>- * \param[in] fd The CLI file descriptor.<br>- * \param[in] root The root node of the tree.<br>- * \param[in] depth Actual depth.<br>- */<br>-<br>-static void __data_result_print_cli(int fd, const struct ast_data *root, uint32_t depth)<br>-{<br>-     struct ao2_iterator iter;<br>-    struct ast_data *node;<br>-<br>-    if (root->type == AST_DATA_CONTAINER) {<br>-           iter = ao2_iterator_init(root->children, 0);<br>-              while ((node = ao2_iterator_next(&iter))) {<br>-                      data_result_print_cli_node(fd, node, depth + 1);<br>-                     ao2_ref(node, -1);<br>-           }<br>-            ao2_iterator_destroy(&iter);<br>-     } else {<br>-             data_result_print_cli_node(fd, root, depth);<br>- }<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief<br>- * \param[in] fd The CLI file descriptor.<br>- * \param[in] root The root node of the tree.<br>- */<br>-static void data_result_print_cli(int fd, const struct ast_data *root)<br>-{<br>-     ast_cli(fd, COLORIZE_FMT "\n", COLORIZE(data_result_get_color(root->type), 0, root->name));<br>-<br>-       __data_result_print_cli(fd, root, 0);<br>-<br>-     ast_cli(fd, "\n");<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Handle the CLI command "data get".<br>- */<br>-static char *handle_cli_data_get(struct ast_cli_entry *e, int cmd,<br>-         struct ast_cli_args *a)<br>-{<br>-  struct ast_data_query query = {<br>-              .version = AST_DATA_QUERY_VERSION<br>-    };<br>-   struct ast_data *tree;<br>-<br>-    switch (cmd) {<br>-       case CLI_INIT:<br>-               e->command = "data get";<br>-                e->usage = ""<br>-                   "Usage: data get <path> [<search> [<filter>]]\n"<br>-                 "       Get the tree based on a path.\n";<br>-          return NULL;<br>- case CLI_GENERATE:<br>-           return NULL;<br>- }<br>-<br>- if (a->argc < e->args + 1) {<br>-                return CLI_SHOWUSAGE;<br>-        }<br>-<br>- query.path = (char *) a->argv[e->args];<br>-<br>-     if (a->argc > e->args + 1) {<br>-                query.search = (char *) a->argv[e->args + 1];<br>-  }<br>-<br>- if (a->argc > e->args + 2) {<br>-                query.filter = (char *) a->argv[e->args + 2];<br>-  }<br>-<br>- tree = ast_data_get(&query);<br>-     if (!tree) {<br>-         return CLI_FAILURE;<br>-  }<br>-<br>- data_result_print_cli(a->fd, tree);<br>-<br>-    ast_data_free(tree);<br>-<br>-      return CLI_SUCCESS;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Print the list of data providers.<br>- * \param[in] fd The CLI file descriptor.<br>- * \param[in] name The last node visited name.<br>- * \param[in] container The childrens of the last node.<br>- * \param[in] path The path to the current node.<br>- */<br>-static void data_provider_print_cli(int fd, const char *name,<br>-        struct ao2_container *container, struct ast_str *path)<br>-{<br>-   struct ao2_iterator i;<br>-       struct ast_str *current_path;<br>-        struct data_provider *provider;<br>-<br>-   current_path = ast_str_create(60);<br>-   if (!current_path) {<br>-         return;<br>-      }<br>-<br>- ast_str_reset(current_path);<br>- if (path) {<br>-          ast_str_set(&current_path, 0, "%s/%s", ast_str_buffer(path), name);<br>-    } else {<br>-             ast_str_set(&current_path, 0, "%s", name);<br>-     }<br>-<br>- i = ao2_iterator_init(container, 0);<br>- while ((provider = ao2_iterator_next(&i))) {<br>-             if (provider->handler) {<br>-                  /* terminal node, print it. */<br>-                       ast_cli(fd, "%s/%s (", ast_str_buffer(current_path),<br>-                               provider->name);<br>-                  if (provider->handler->get) {<br>-                          ast_cli(fd, "get");<br>-                        }<br>-                    ast_cli(fd, ") [%s]\n", provider->registrar);<br>-           }<br>-            data_provider_print_cli(fd, provider->name, provider->children,<br>-                        current_path);<br>-               ao2_ref(provider, -1);<br>-       }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     ast_free(current_path);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Handle CLI command "data show providers"<br>- */<br>-static char *handle_cli_data_show_providers(struct ast_cli_entry *e, int cmd,<br>-             struct ast_cli_args *a)<br>-{<br>-  switch (cmd) {<br>-       case CLI_INIT:<br>-               e->command = "data show providers";<br>-             e->usage = ""<br>-                   "Usage: data show providers\n"<br>-                     "       Show the list of registered providers\n";<br>-          return NULL;<br>- case CLI_GENERATE:<br>-           return NULL;<br>- }<br>-<br>- data_read_lock();<br>-    data_provider_print_cli(a->fd, "", root_data.container, NULL);<br>-  data_unlock();<br>-<br>-    return CLI_SUCCESS;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Data API CLI commands.<br>- */<br>-static struct ast_cli_entry cli_data[] = {<br>-        AST_CLI_DEFINE(handle_cli_data_get, "Data API get"),<br>-       AST_CLI_DEFINE(handle_cli_data_show_providers, "Show data providers")<br>-};<br>-<br>-/*!<br>- * \internal<br>- * \brief Output a tree to the AMI.<br>- * \param[in] s AMI session.<br>- * \param[in] name The root node name.<br>- * \param[in] container The root container.<br>- * \param[in] path The current path.<br>- */<br>-static void data_result_manager_output(struct mansession *s, const char *name,<br>-       struct ao2_container *container, struct ast_str *path, int id)<br>-{<br>-   struct ao2_iterator i;<br>-       struct ast_str *current_path;<br>-        struct ast_data *node;<br>-       int current_id = id;<br>-<br>-      current_path = ast_str_create(60);<br>-   if (!current_path) {<br>-         return;<br>-      }<br>-<br>- ast_str_reset(current_path);<br>- if (path) {<br>-          ast_str_set(&current_path, 0, "%s.%s", ast_str_buffer(path), name);<br>-    } else {<br>-             ast_str_set(&current_path, 0, "%s", name);<br>-     }<br>-<br>- i = ao2_iterator_init(container, 0);<br>- while ((node = ao2_iterator_next(&i))) {<br>-         /* terminal node, print it. */<br>-               if (node->type != AST_DATA_CONTAINER) {<br>-                   astman_append(s, "%d-%s.%s", id, ast_str_buffer(current_path),<br>-                                     node->name);<br>-              }<br>-            switch (node->type) {<br>-             case AST_DATA_CONTAINER:<br>-                     data_result_manager_output(s, node->name, node->children, current_path, ++current_id);<br>-                 break;<br>-               case AST_DATA_INTEGER:<br>-                       astman_append(s, ": %d\r\n", node->payload.sint);<br>-                       break;<br>-               case AST_DATA_TIMESTAMP:<br>-             case AST_DATA_SECONDS:<br>-               case AST_DATA_MILLISECONDS:<br>-          case AST_DATA_UNSIGNED_INTEGER:<br>-                      astman_append(s, ": %u\r\n", node->payload.uint);<br>-                       break;<br>-               case AST_DATA_PASSWORD:<br>-                      astman_append(s, ": %s\r\n", node->payload.str);<br>-                        break;<br>-               case AST_DATA_STRING:<br>-                        astman_append(s, ": %s\r\n", node->payload.str);<br>-                        break;<br>-               case AST_DATA_CHARACTER:<br>-                     astman_append(s, ": %c\r\n", node->payload.character);<br>-                  break;<br>-               case AST_DATA_IPADDR:<br>-                        astman_append(s, ": %s\r\n", ast_inet_ntoa(node->payload.ipaddr));<br>-                      break;<br>-               case AST_DATA_POINTER:<br>-                       break;<br>-               case AST_DATA_DOUBLE:<br>-                        astman_append(s, ": %f\r\n", node->payload.dbl);<br>-                        break;<br>-               case AST_DATA_BOOLEAN:<br>-                       astman_append(s, ": %s\r\n",<br>-                               (node->payload.boolean ? "True" : "False"));<br>-                  break;<br>-               }<br>-<br>-         ao2_ref(node, -1);<br>-   }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     ast_free(current_path);<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Implements the manager action: "DataGet".<br>- */<br>-static int manager_data_get(struct mansession *s, const struct message *m)<br>-{<br>-   const char *path = astman_get_header(m, "Path");<br>-   const char *search = astman_get_header(m, "Search");<br>-       const char *filter = astman_get_header(m, "Filter");<br>-       const char *id = astman_get_header(m, "ActionID");<br>- struct ast_data *res;<br>-        struct ast_data_query query = {<br>-              .version = AST_DATA_QUERY_VERSION,<br>-           .path = (char *) path,<br>-               .search = (char *) search,<br>-           .filter = (char *) filter,<br>-   };<br>-<br>-        if (ast_strlen_zero(path)) {<br>-         astman_send_error(s, m, "'Path' parameter not specified");<br>-         return 0;<br>-    }<br>-<br>- res = ast_data_get(&query);<br>-      if (!res) {<br>-          astman_send_error(s, m, "No data returned");<br>-               return 0;<br>-    }<br>-<br>- astman_append(s, "Event: DataGet Tree\r\n");<br>-       if (!ast_strlen_zero(id)) {<br>-          astman_append(s, "ActionID: %s\r\n", id);<br>-  }<br>-    data_result_manager_output(s, res->name, res->children, NULL, 0);<br>-      astman_append(s, "\r\n");<br>-<br>-       ast_data_free(res);<br>-<br>-       return RESULT_SUCCESS;<br>-}<br>-<br>-static int data_add_codec(struct ast_data *codecs, struct ast_format *format) {<br>-      struct ast_data *codec;<br>-      struct ast_codec *tmp;<br>-<br>-    tmp = ast_codec_get_by_id(ast_format_get_codec_id(format));<br>-  if (!tmp) {<br>-          return -1;<br>-   }<br>-<br>- codec = ast_data_add_node(codecs, "codec");<br>-        if (!codec) {<br>-                ao2_ref(tmp, -1);<br>-            return -1;<br>-   }<br>-<br>- ast_data_add_str(codec, "name", tmp->name);<br>-     ast_data_add_int(codec, "samplespersecond", tmp->sample_rate);<br>-  ast_data_add_str(codec, "description", tmp->description);<br>-       ast_data_add_int(codec, "frame_length", tmp->minimum_bytes);<br>-    ao2_ref(tmp, -1);<br>-<br>- return 0;<br>-}<br>-<br>-int ast_data_add_codec(struct ast_data *root, const char *node_name, struct ast_format *format)<br>-{<br>-       struct ast_data *codecs;<br>-<br>-  codecs = ast_data_add_node(root, node_name);<br>- if (!codecs) {<br>-               return -1;<br>-   }<br>-<br>- return data_add_codec(codecs, format);<br>-}<br>-<br>-int ast_data_add_codecs(struct ast_data *root, const char *node_name, struct ast_format_cap *cap)<br>-{<br>-        struct ast_data *codecs;<br>-     size_t i;<br>-    size_t count;<br>-<br>-     codecs = ast_data_add_node(root, node_name);<br>- if (!codecs) {<br>-               return -1;<br>-   }<br>-<br>- count = ast_format_cap_count(cap);<br>-   for (i = 0; i < count; ++i) {<br>-             struct ast_format *fmt;<br>-<br>-           fmt = ast_format_cap_get_format(cap, i);<br>-             if (!fmt) {<br>-                  return -1;<br>-           }<br>-<br>-         if (data_add_codec(codecs, fmt)) {<br>-                   ao2_ref(fmt, -1);<br>-                    return -1;<br>-           }<br>-<br>-         ao2_ref(fmt, -1);<br>-    }<br>-<br>- return 0;<br>-}<br>-<br>-#ifdef TEST_FRAMEWORK<br>-<br>-/*!<br>- * \internal<br>- * \brief Structure used to test how to add a complete structure,<br>- *        and how to compare it.<br>- */<br>-struct test_structure {<br>-      int a_int;<br>-   unsigned int b_bool:1;<br>-       char *c_str;<br>- unsigned int a_uint;<br>-};<br>-<br>-/*!<br>- * \internal<br>- * \brief test_structure mapping.<br>- */<br>-#define DATA_EXPORT_TEST_STRUCTURE(MEMBER)                              \<br>-      MEMBER(test_structure, a_int, AST_DATA_INTEGER)                 \<br>-    MEMBER(test_structure, b_bool, AST_DATA_BOOLEAN)                \<br>-    MEMBER(test_structure, c_str, AST_DATA_STRING)                  \<br>-    MEMBER(test_structure, a_uint, AST_DATA_UNSIGNED_INTEGER)<br>-<br>-AST_DATA_STRUCTURE(test_structure, DATA_EXPORT_TEST_STRUCTURE);<br>-<br>-/*!<br>- * \internal<br>- * \brief Callback implementation.<br>- */<br>-static int test_data_full_provider(const struct ast_data_search *search,<br>-         struct ast_data *root)<br>-{<br>-   struct ast_data *test_structure;<br>-     struct test_structure local_test_structure = {<br>-               .a_int = 10,<br>-         .b_bool = 1,<br>-         .c_str = "test string",<br>-            .a_uint = 20<br>- };<br>-<br>-        test_structure = ast_data_add_node(root, "test_structure");<br>-        if (!test_structure) {<br>-               ast_debug(1, "Internal data api error\n");<br>-         return 0;<br>-    }<br>-<br>- /* add the complete structure. */<br>-    ast_data_add_structure(test_structure, test_structure, &local_test_structure);<br>-<br>-        if (!ast_data_search_match(search, test_structure)) {<br>-                ast_data_remove_node(root, test_structure);<br>-  }<br>-<br>- return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief Handler definition for the full provider.<br>- */<br>-static const struct ast_data_handler full_provider = {<br>-   .version = AST_DATA_HANDLER_VERSION,<br>- .get = test_data_full_provider<br>-};<br>-<br>-/*!<br>- * \internal<br>- * \brief Structure used to define multiple providers at once.<br>- */<br>-static const struct ast_data_entry test_providers[] = {<br>- AST_DATA_ENTRY("test/node1/node11/node111", &full_provider)<br>-};<br>-<br>-AST_TEST_DEFINE(test_data_get)<br>-{<br>-       struct ast_data *res, *node;<br>- struct ast_data_iterator *i;<br>- struct ast_data_query query = {<br>-              .version = AST_DATA_QUERY_VERSION,<br>-           .path = "test/node1/node11/node111",<br>-               .search = "node111/test_structure/a_int=10",<br>-               .filter = "node111/test_structure/a*int"<br>-   };<br>-<br>-        switch (cmd) {<br>-       case TEST_INIT:<br>-              info->name = "data_test";<br>-               info->category = "/main/data/";<br>-         info->summary = "Data API unit test";<br>-           info->description =<br>-                       "Tests whether data API get implementation works as expected.";<br>-            return AST_TEST_NOT_RUN;<br>-     case TEST_EXECUTE:<br>-           break;<br>-       }<br>-<br>- ast_data_register_multiple_core(test_providers, ARRAY_LEN(test_providers));<br>-<br>-       res = ast_data_get(&query);<br>-      if (!res) {<br>-          ast_test_status_update(test, "Unable to get tree.");<br>-               ast_data_unregister("test/node1/node11/node111");<br>-          return AST_TEST_FAIL;<br>-        }<br>-<br>- /* initiate the iterator and check for errors. */<br>-    i = ast_data_iterator_init(res, "test_structure/");<br>-        if (!i) {<br>-            ast_test_status_update(test, "Unable to initiate the iterator.");<br>-          ast_data_free(res);<br>-          ast_data_unregister("test/node1/node11/node111");<br>-          return AST_TEST_FAIL;<br>-        }<br>-<br>- /* walk the returned nodes. */<br>-       while ((node = ast_data_iterator_next(i))) {<br>-         if (!strcmp(ast_data_retrieve_name(node), "a_int")) {<br>-                      if (ast_data_retrieve_int(node, "/") != 10) {<br>-                              ast_data_iterator_end(i);<br>-                            ast_data_free(res);<br>-                          ast_data_unregister("test/node1/node11/node111");<br>-                          return AST_TEST_FAIL;<br>-                        }<br>-            } else if (!strcmp(ast_data_retrieve_name(node), "a_uint")) {<br>-                      if (ast_data_retrieve_uint(node, "/") != 20) {<br>-                             ast_data_iterator_end(i);<br>-                            ast_data_free(res);<br>-                          ast_data_unregister("test/node1/node11/node111");<br>-                          return AST_TEST_FAIL;<br>-                        }<br>-            }<br>-    }<br>-<br>- /* finish the iterator. */<br>-   ast_data_iterator_end(i);<br>-<br>- ast_data_free(res);<br>-<br>-       ast_data_unregister("test/node1/node11/node111");<br>-<br>-       return AST_TEST_PASS;<br>-}<br>-<br>-#endif<br>-<br>-/*!<br>- * \internal<br>- * \brief Clean up resources on Asterisk shutdown<br>- */<br>-static void data_shutdown(void)<br>-{<br>-        ast_manager_unregister("DataGet");<br>- ast_cli_unregister_multiple(cli_data, ARRAY_LEN(cli_data));<br>-  ao2_t_ref(root_data.container, -1, "Unref root_data.container in data_shutdown");<br>-  root_data.container = NULL;<br>-  ast_rwlock_destroy(&root_data.lock);<br>-     AST_TEST_UNREGISTER(test_data_get);<br>-}<br>-<br>-int ast_data_init(void)<br>-{<br>-     int res = 0;<br>-<br>-      ast_rwlock_init(&root_data.lock);<br>-<br>-     if (!(root_data.container = ao2_container_alloc(NUM_DATA_NODE_BUCKETS,<br>-               data_provider_hash, data_provider_cmp))) {<br>-           return -1;<br>-   }<br>-<br>- res |= ast_cli_register_multiple(cli_data, ARRAY_LEN(cli_data));<br>-<br>-  res |= ast_manager_register_xml_core("DataGet", 0, manager_data_get);<br>-<br>-   AST_TEST_REGISTER(test_data_get);<br>-<br>- ast_register_cleanup(data_shutdown);<br>-<br>-      return res;<br>-}<br>diff --git a/main/indications.c b/main/indications.c<br>index 0af6668..8940a37 100644<br>--- a/main/indications.c<br>+++ b/main/indications.c<br>@@ -41,22 +41,8 @@<br> #include "asterisk/cli.h"<br> #include "asterisk/module.h"<br> #include "asterisk/astobj2.h"<br>-#include "asterisk/data.h"<br> <br> #include "asterisk/_private.h" /* _init(), _reload() */<br>-<br>-#define DATA_EXPORT_TONE_ZONE(MEMBER)                                  \<br>-    MEMBER(ast_tone_zone, country, AST_DATA_STRING)                 \<br>-    MEMBER(ast_tone_zone, description, AST_DATA_STRING)             \<br>-    MEMBER(ast_tone_zone, nrringcadence, AST_DATA_UNSIGNED_INTEGER)<br>-<br>-AST_DATA_STRUCTURE(ast_tone_zone, DATA_EXPORT_TONE_ZONE);<br>-<br>-#define DATA_EXPORT_TONE_ZONE_SOUND(MEMBER)                 \<br>-    MEMBER(ast_tone_zone_sound, name, AST_DATA_STRING)      \<br>-    MEMBER(ast_tone_zone_sound, data, AST_DATA_STRING)<br>-<br>-AST_DATA_STRUCTURE(ast_tone_zone_sound, DATA_EXPORT_TONE_ZONE_SOUND);<br> <br> /* Globals */<br> static const char config[] = "indications.conf";<br>@@ -1122,33 +1108,6 @@<br> <br>      return (!strcasecmp(zone->country, zone_arg->country)) ?<br>                        CMP_MATCH | CMP_STOP : 0;<br>-}<br>-<br>-int ast_tone_zone_data_add_structure(struct ast_data *tree, struct ast_tone_zone *zone)<br>-{<br>-       struct ast_data *data_zone_sound;<br>-    struct ast_tone_zone_sound *s;<br>-<br>-    ast_data_add_structure(ast_tone_zone, tree, zone);<br>-<br>-        if (AST_LIST_EMPTY(&zone->tones)) {<br>-           return 0;<br>-    }<br>-<br>- data_zone_sound = ast_data_add_node(tree, "tones");<br>-        if (!data_zone_sound) {<br>-              return -1;<br>-   }<br>-<br>- ast_tone_zone_lock(zone);<br>-<br>- AST_LIST_TRAVERSE(&zone->tones, s, entry) {<br>-           ast_data_add_structure(ast_tone_zone_sound, data_zone_sound, s);<br>-     }<br>-<br>- ast_tone_zone_unlock(zone);<br>-<br>-       return 0;<br> }<br> <br> /*!<br>diff --git a/main/pbx.c b/main/pbx.c<br>index ccfba05..2366b72 100644<br>--- a/main/pbx.c<br>+++ b/main/pbx.c<br>@@ -8306,56 +8306,6 @@<br>       ast_free(hint_app);<br> }<br> <br>-/*!<br>- * \internal<br>- * \brief Implements the hints data provider.<br>- */<br>-static int hints_data_provider_get(const struct ast_data_search *search,<br>-     struct ast_data *data_root)<br>-{<br>-      struct ast_data *data_hint;<br>-  struct ast_hint *hint;<br>-       int watchers;<br>-        struct ao2_iterator i;<br>-<br>-    if (ao2_container_count(hints) == 0) {<br>-               return 0;<br>-    }<br>-<br>- i = ao2_iterator_init(hints, 0);<br>-     for (; (hint = ao2_iterator_next(&i)); ao2_ref(hint, -1)) {<br>-              watchers = ao2_container_count(hint->callbacks);<br>-          data_hint = ast_data_add_node(data_root, "hint");<br>-          if (!data_hint) {<br>-                    continue;<br>-            }<br>-            ast_data_add_str(data_hint, "extension", ast_get_extension_name(hint->exten));<br>-          ast_data_add_str(data_hint, "context", ast_get_context_name(ast_get_extension_context(hint->exten)));<br>-           ast_data_add_str(data_hint, "application", ast_get_extension_app(hint->exten));<br>-         ast_data_add_str(data_hint, "state", ast_extension_state2str(hint->laststate));<br>-         ast_data_add_str(data_hint, "presence_state", ast_presence_state2str(hint->last_presence_state));<br>-               ast_data_add_str(data_hint, "presence_subtype", S_OR(hint->last_presence_subtype, ""));<br>-               ast_data_add_str(data_hint, "presence_subtype", S_OR(hint->last_presence_message, ""));<br>-               ast_data_add_int(data_hint, "watchers", watchers);<br>-<br>-              if (!ast_data_search_match(search, data_hint)) {<br>-                     ast_data_remove_node(data_root, data_hint);<br>-          }<br>-    }<br>-    ao2_iterator_destroy(&i);<br>-<br>-     return 0;<br>-}<br>-<br>-static const struct ast_data_handler hints_data_provider = {<br>-      .version = AST_DATA_HANDLER_VERSION,<br>- .get = hints_data_provider_get<br>-};<br>-<br>-static const struct ast_data_entry pbx_data_providers[] = {<br>- AST_DATA_ENTRY("asterisk/core/hints", &hints_data_provider),<br>-};<br>-<br> static int action_extensionstatelist(struct mansession *s, const struct message *m)<br> {<br>  const char *action_id = astman_get_header(m, "ActionID");<br>@@ -8431,7 +8381,6 @@<br>    ast_cli_unregister_multiple(pbx_cli, ARRAY_LEN(pbx_cli));<br>     ast_custom_function_unregister(&exception_function);<br>      ast_custom_function_unregister(&testtime_function);<br>-      ast_data_unregister(NULL);<br> }<br> <br> int load_pbx(void)<br>@@ -8445,7 +8394,6 @@<br> <br>      ast_verb(2, "Registering builtin functions:\n");<br>    ast_cli_register_multiple(pbx_cli, ARRAY_LEN(pbx_cli));<br>-      ast_data_register_multiple_core(pbx_data_providers, ARRAY_LEN(pbx_data_providers));<br>   __ast_custom_function_register(&exception_function, NULL);<br>        __ast_custom_function_register(&testtime_function, NULL);<br> <br>diff --git a/res/res_odbc.c b/res/res_odbc.c<br>index 0b81bc6..24f63a9 100644<br>--- a/res/res_odbc.c<br>+++ b/res/res_odbc.c<br>@@ -61,7 +61,6 @@<br> #include "asterisk/app.h"<br> #include "asterisk/strings.h"<br> #include "asterisk/threadstorage.h"<br>-#include "asterisk/data.h"<br> <br> struct odbc_class<br> {<br>@@ -118,15 +117,6 @@<br>  unsigned int isolation;         /*!< Flags for how the DB should deal with data in other, uncommitted transactions */<br>      char name[0];                   /*!< Name of this transaction ID */<br> };<br>-<br>-#define DATA_EXPORT_ODBC_CLASS(MEMBER)                         \<br>-    MEMBER(odbc_class, name, AST_DATA_STRING)               \<br>-    MEMBER(odbc_class, dsn, AST_DATA_STRING)                \<br>-    MEMBER(odbc_class, username, AST_DATA_STRING)           \<br>-    MEMBER(odbc_class, password, AST_DATA_PASSWORD)         \<br>-    MEMBER(odbc_class, forcecommit, AST_DATA_BOOLEAN)<br>-<br>-AST_DATA_STRUCTURE(odbc_class, DATA_EXPORT_ODBC_CLASS);<br> <br> const char *ast_odbc_isolation2text(int iso)<br> {<br>@@ -971,65 +961,6 @@<br>    return ODBC_SUCCESS;<br> }<br> <br>-/*!<br>- * \internal<br>- * \brief Implements the channels provider.<br>- */<br>-static int data_odbc_provider_handler(const struct ast_data_search *search,<br>-           struct ast_data *root)<br>-{<br>-   struct ao2_iterator aoi;<br>-     struct odbc_class *class;<br>-    struct ast_data *data_odbc_class, *data_odbc_connections;<br>-    struct ast_data *enum_node;<br>-<br>-       aoi = ao2_iterator_init(class_container, 0);<br>- while ((class = ao2_iterator_next(&aoi))) {<br>-              data_odbc_class = ast_data_add_node(root, "class");<br>-                if (!data_odbc_class) {<br>-                      ao2_ref(class, -1);<br>-                  continue;<br>-            }<br>-<br>-         ast_data_add_structure(odbc_class, data_odbc_class, class);<br>-<br>-               data_odbc_connections = ast_data_add_node(data_odbc_class, "connections");<br>-         if (!data_odbc_connections) {<br>-                        ao2_ref(class, -1);<br>-                  continue;<br>-            }<br>-<br>-         /* isolation */<br>-              enum_node = ast_data_add_node(data_odbc_class, "isolation");<br>-               if (!enum_node) {<br>-                    ao2_ref(class, -1);<br>-                  continue;<br>-            }<br>-            ast_data_add_int(enum_node, "value", class->isolation);<br>-         ast_data_add_str(enum_node, "text", ast_odbc_isolation2text(class->isolation));<br>-         ao2_ref(class, -1);<br>-<br>-               if (!ast_data_search_match(search, data_odbc_class)) {<br>-                       ast_data_remove_node(root, data_odbc_class);<br>-         }<br>-    }<br>-    ao2_iterator_destroy(&aoi);<br>-      return 0;<br>-}<br>-<br>-/*!<br>- * \internal<br>- * \brief /asterisk/res/odbc/listprovider.<br>- */<br>-static const struct ast_data_handler odbc_provider = {<br>-    .version = AST_DATA_HANDLER_VERSION,<br>- .get = data_odbc_provider_handler<br>-};<br>-<br>-static const struct ast_data_entry odbc_providers[] = {<br>-  AST_DATA_ENTRY("/asterisk/res/odbc", &odbc_provider),<br>-};<br>-<br> static int reload(void)<br> {<br>     struct odbc_cache_tables *table;<br>@@ -1087,7 +1018,6 @@<br>       if (load_odbc_config() == -1)<br>                 return AST_MODULE_LOAD_DECLINE;<br>       ast_cli_register_multiple(cli_odbc, ARRAY_LEN(cli_odbc));<br>-    ast_data_register_multiple(odbc_providers, ARRAY_LEN(odbc_providers));<br>        ast_log(LOG_NOTICE, "res_odbc loaded.\n");<br>  return 0;<br> }<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/5961">change 5961</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/5961"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I4b2185a83aeb74798b4ad43ff8f89f971096aa83 </div>
<div style="display:none"> Gerrit-Change-Number: 5961 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>