[asterisk-commits] eliel: branch group/data_api_gsoc2009 r206093 - in /team/group/data_api_gsoc2...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 13 08:34:10 CDT 2009
Author: eliel
Date: Mon Jul 13 08:34:06 2009
New Revision: 206093
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=206093
Log:
Make the mapping mechanism support bitfields.
Modified:
team/group/data_api_gsoc2009/apps/app_queue.c
team/group/data_api_gsoc2009/include/asterisk/data.h
team/group/data_api_gsoc2009/main/data.c
Modified: team/group/data_api_gsoc2009/apps/app_queue.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/apps/app_queue.c?view=diff&rev=206093&r1=206092&r2=206093
==============================================================================
--- team/group/data_api_gsoc2009/apps/app_queue.c (original)
+++ team/group/data_api_gsoc2009/apps/app_queue.c Mon Jul 13 08:34:06 2009
@@ -7389,74 +7389,86 @@
AST_CLI_DEFINE(handle_queue_reset, "Reset statistics for a queue"),
};
-static const struct ast_data_structure_mapping data_structure_call_queue[] =
-{
- AST_DATA_STRUCTURE_MEMBER(name, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(moh, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(announce, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(context, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(membermacro, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(membergosub, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(defaultrule, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_next, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_thereare, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_calls, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(queue_quantity1, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(queue_quantity2, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_holdtime, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_minutes, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_minute, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_seconds, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_thanks, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_callerannounce, AST_DATA_STRING, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(sound_reporthold, AST_DATA_STRING, struct call_queue),
-
- /* XXX Missing bit fields. Adding them manually */
-
- AST_DATA_STRUCTURE_MEMBER(announcepositionlimit, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(announcefrequency, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(minannouncefrequency, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(periodicannouncefrequency, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(numperiodicannounce, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(randomperiodicannounce, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(roundingseconds, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(holdtime, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(talktime, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(callscompleted, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(callsabandoned, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(servicelevel, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(callscompletedinsl, AST_DATA_INTEGER, struct call_queue),
-
- AST_DATA_STRUCTURE_MEMBER_ADDITIONAL(monfmt, AST_DATA_CHAR, struct call_queue, 8),
-
- AST_DATA_STRUCTURE_MEMBER(montype, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(count, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(maxlen, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(wrapuptime, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(retry, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(timeout, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(weight, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(autopause, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(timeoutpriority, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(rrpos, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(memberdelay, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(autofill, AST_DATA_INTEGER, struct call_queue),
- AST_DATA_STRUCTURE_MEMBER(membercount, AST_DATA_INTEGER, struct call_queue),
-};
-
-static const struct ast_data_structure_mapping data_structure_member[] =
-{
- AST_DATA_STRUCTURE_MEMBER_ADDITIONAL(interface, AST_DATA_CHAR, struct member, 80),
- AST_DATA_STRUCTURE_MEMBER_ADDITIONAL(state_interface, AST_DATA_CHAR, struct member, 80),
- AST_DATA_STRUCTURE_MEMBER_ADDITIONAL(membername, AST_DATA_CHAR, struct member, 80),
- AST_DATA_STRUCTURE_MEMBER(penalty, AST_DATA_INTEGER, struct member),
- AST_DATA_STRUCTURE_MEMBER(calls, AST_DATA_INTEGER, struct member),
- AST_DATA_STRUCTURE_MEMBER(dynamic, AST_DATA_INTEGER, struct member),
- AST_DATA_STRUCTURE_MEMBER(realtime, AST_DATA_INTEGER, struct member),
- AST_DATA_STRUCTURE_MEMBER(status, AST_DATA_INTEGER, struct member),
- AST_DATA_STRUCTURE_MEMBER(paused, AST_DATA_INTEGER, struct member),
- AST_DATA_STRUCTURE_MEMBER(rt_uniqueid, AST_DATA_STRING, struct member),
-};
+/* struct call_queue astdata mapping. */
+#define DATA_EXPORT_CALL_QUEUE(MEMBER) \
+ MEMBER(call_queue, name, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, moh, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, announce, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, context, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, membermacro, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, membergosub, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, defaultrule, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_next, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_thereare, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_calls, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, queue_quantity1, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, queue_quantity2, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_holdtime, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_minutes, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_minute, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_seconds, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_thanks, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_callerannounce, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, sound_reporthold, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, dead, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, eventwhencalled, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, ringinuse, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, setinterfacevar, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, setqueuevar, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, setqueueentryvar, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, reportholdtime, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, wrapped, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, timeoutrestart, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, announceholdtime, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, announceposition, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, strategy, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, maskmemberstatus, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, realtime, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, found, AST_DATA_BOOLEAN, unsigned int) \
+ MEMBER(call_queue, announcepositionlimit, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, announcefrequency, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, minannouncefrequency, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, periodicannouncefrequency, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, numperiodicannounce, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, randomperiodicannounce, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, roundingseconds, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, holdtime, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, talktime, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, callscompleted, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, callsabandoned, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, servicelevel, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, callscompletedinsl, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, monfmt, AST_DATA_STRING, char *) \
+ MEMBER(call_queue, montype, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, count, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, maxlen, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, wrapuptime, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, retry, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, timeout, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, weight, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, autopause, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, timeoutpriority, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, rrpos, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, memberdelay, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, autofill, AST_DATA_INTEGER, int) \
+ MEMBER(call_queue, membercount, AST_DATA_INTEGER, int)
+
+AST_DATA_STRUCTURE(call_queue, DATA_EXPORT_CALL_QUEUE);
+
+/* struct member astdata mapping. */
+#define DATA_EXPORT_MEMBER(MEMBER) \
+ MEMBER(member, interface, AST_DATA_STRING, char *) \
+ MEMBER(member, state_interface, AST_DATA_STRING, char *) \
+ MEMBER(member, membername, AST_DATA_STRING, char *) \
+ MEMBER(member, penalty, AST_DATA_INTEGER, int) \
+ MEMBER(member, calls, AST_DATA_INTEGER, int) \
+ MEMBER(member, dynamic, AST_DATA_INTEGER, int) \
+ MEMBER(member, realtime, AST_DATA_INTEGER, int) \
+ MEMBER(member, status, AST_DATA_INTEGER, int) \
+ MEMBER(member, paused, AST_DATA_INTEGER, int) \
+ MEMBER(member, rt_uniqueid, AST_DATA_STRING, char *)
+
+AST_DATA_STRUCTURE(member, DATA_EXPORT_MEMBER);
/*!
* \internal
@@ -7485,26 +7497,7 @@
continue;
}
- ast_data_add_structure(data_queue, data_structure_call_queue,
- ARRAY_LEN(data_structure_call_queue), queue);
-
-
- /* bit fields not supported in add_structure */
- ast_data_add_bool(data_queue, "dead", queue->dead);
- ast_data_add_bool(data_queue, "eventwhencalled", queue->eventwhencalled);
- ast_data_add_bool(data_queue, "ringinuse", queue->ringinuse);
- ast_data_add_bool(data_queue, "setinterfacevar", queue->setinterfacevar);
- ast_data_add_bool(data_queue, "setqueuevar", queue->setqueuevar);
- ast_data_add_bool(data_queue, "setqueueentryvar", queue->setqueueentryvar);
- ast_data_add_bool(data_queue, "reportholdtime", queue->reportholdtime);
- ast_data_add_bool(data_queue, "wrapped", queue->wrapped);
- ast_data_add_bool(data_queue, "timeoutrestart", queue->timeoutrestart);
- ast_data_add_int(data_queue, "announceholdtime", queue->announceholdtime);
- ast_data_add_int(data_queue, "announceposition", queue->announceposition);
- ast_data_add_int(data_queue, "strategy", queue->strategy);
- ast_data_add_bool(data_queue, "maskmemberstatus", queue->maskmemberstatus);
- ast_data_add_bool(data_queue, "realtime", queue->realtime);
- ast_data_add_bool(data_queue, "found", queue->found);
+ ast_data_add_structure(call_queue, data_queue, queue);
if (queue->members) {
data_members = ast_data_add_node(data_queue, "members");
@@ -7522,8 +7515,7 @@
continue;
}
- ast_data_add_structure(data_member, data_structure_member,
- ARRAY_LEN(data_structure_member), member);
+ ast_data_add_structure(member, data_member, member);
ao2_ref(member, -1);
}
}
Modified: team/group/data_api_gsoc2009/include/asterisk/data.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/include/asterisk/data.h?view=diff&rev=206093&r1=206092&r2=206093
==============================================================================
--- team/group/data_api_gsoc2009/include/asterisk/data.h (original)
+++ team/group/data_api_gsoc2009/include/asterisk/data.h Mon Jul 13 08:34:06 2009
@@ -84,7 +84,6 @@
AST_DATA_DOUBLE,
AST_DATA_BOOLEAN,
AST_DATA_STRING,
- AST_DATA_CHAR,
AST_DATA_IPADDR,
AST_DATA_POINTER
};
@@ -144,26 +143,36 @@
);
};
-#define AST_DATA_STRUCTURE_MEMBER(__name, __type, __structure) { .name = #__name, \
- .offset = offsetof(__structure, __name), .type = __type }
-#define AST_DATA_STRUCTURE_MEMBER_ADDITIONAL(__name, __type, __structure, __additional) \
- { .name = #__name, .offset = offsetof(__structure, __name), \
- .type = __type, .additional = (void *)__additional }
-#define AST_DATA_STRUCTURE_MEMBER_BIT(__name, __structure) { .name = #__name, \
- .type = AST_DATA_BOOLEAN,
-
-struct ast_data_structure_mapping {
- /*! \brief The name of the structure member. */
+/*! \brief Map the members of a structure. */
+struct ast_data_mapping_structure {
const char *name;
- /*! \brief The offset of the member inside the structure. */
- size_t offset;
- /*! \brief The type of the member. */
enum ast_data_type type;
- /*! \brief Additional type specification. (depends of the type) */
- void *additional;
- /*! \brief bitfield access, only used if the type is boolean. */
- int (*bitfield)(void *structure);
+ union {
+ char *(*AST_DATA_STRING)(void *ptr);
+ int (*AST_DATA_INTEGER)(void *ptr);
+ double (*AST_DATA_DOUBLE)(void *ptr);
+ unsigned int (*AST_DATA_UNSIGNED_INTEGER)(void *ptr);
+ unsigned int (*AST_DATA_BOOLEAN)(void *ptr);
+ void *(*AST_DATA_POINTER)(void *ptr);
+ struct in_addr (*AST_DATA_IPADDR)(void *ptr);
+ } get;
};
+
+#define AST_DATA_STRUCTURE(__struct, __name) \
+ __name(__AST_DATA_MAPPING_FUNCTION); \
+ struct ast_data_mapping_structure __data_mapping_structure_##__struct[] = { \
+ __name(__AST_DATA_MAPPING_STRUCTURE) \
+ }
+
+#define __AST_DATA_MAPPING_STRUCTURE(__structure, __member, __type, __real_type) \
+ { .name = #__member, .get.__type = data_mapping_structure_get_##__structure##__member, \
+ .type = __type },
+
+#define __AST_DATA_MAPPING_FUNCTION(__structure, __member, __type, __real_type) \
+ static __real_type data_mapping_structure_get_##__structure##__member(void *ptr) { \
+ struct __structure *struct_##__member = (struct __structure *) ptr; \
+ return (__real_type) struct_##__member->__member; \
+ }
/*!
* \brief Register a data provider.
@@ -226,7 +235,7 @@
* \param[in] value The value to compare.
* \returns The strcmp return value.
*/
-int ast_data_search_cmp_string(const struct ast_data_search *root, const char *name, void *value);
+int ast_data_search_cmp_string(const struct ast_data_search *root, const char *name, char *value);
/*!
* \brief Based on a search tree, evaluate the specified 'name' inside the tree with the
@@ -239,7 +248,7 @@
* \param[in] value The value to compare.
* \returns The strcmp return value.
*/
-int ast_data_search_cmp_int(const struct ast_data_search *root, const char *name, void *value);
+int ast_data_search_cmp_int(const struct ast_data_search *root, const char *name, int value);
/*!
* \brief Based on a search tree, evaluate every member of a structure against it.
@@ -249,7 +258,7 @@
* \param[in] structure The structure pointer.
*/
int ast_data_search_cmp_structure(struct ast_data_search *search,
- struct ast_data_structure_mapping *mapping, size_t mapping_len,
+ struct ast_data_mapping_structure *mapping, size_t mapping_len,
void *structure);
/*!
@@ -369,11 +378,19 @@
/*!
* \brief
- * XXX-document this
- */
-int ast_data_add_structure(struct ast_data *root,
- const struct ast_data_structure_mapping *mapping, size_t mapping_len,
+ * \param[in] root
+ * \param[in] mapping
+ * \param[in] mapping_len
+ * \param[in] structure
+ * \retval 0
+ * \retval 1
+ */
+int __ast_data_add_structure(struct ast_data *root,
+ const struct ast_data_mapping_structure *mapping, size_t mapping_len,
void *structure);
+#define ast_data_add_structure(structure_name, root, structure) \
+ __ast_data_add_structure(root, __data_mapping_structure_##structure_name, \
+ ARRAY_LEN(__data_mapping_structure_##structure_name), structure)
/*!
* \brief Initialize an iterator.
Modified: team/group/data_api_gsoc2009/main/data.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/main/data.c?view=diff&rev=206093&r1=206092&r2=206093
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Mon Jul 13 08:34:06 2009
@@ -580,7 +580,6 @@
case AST_DATA_POINTER:
ast_debug(1, " (pointer): %p\n", node->payload.ptr);
break;
- case AST_DATA_CHAR:
case AST_DATA_STRING:
ast_debug(1, " (string)[%u]: \"%s\"", (unsigned int)strlen(node->payload.str), node->payload.str);
break;
@@ -986,7 +985,7 @@
return data_search_get_node(child, savepath);
}
-int ast_data_search_cmp_string(const struct ast_data_search *root, const char *name, void *value)
+int ast_data_search_cmp_string(const struct ast_data_search *root, const char *name, char *value)
{
struct ast_data_search *child;
enum data_search_comparison cmp_type;
@@ -997,7 +996,7 @@
return 0;
}
- ret = strcmp((const char *) value, child->value);
+ ret = strcmp(value, child->value);
cmp_type = child->cmp_type;
ao2_ref(child, -1);
@@ -1005,7 +1004,7 @@
return data_search_comparison_result(ret, cmp_type);
}
-int ast_data_search_cmp_int(const struct ast_data_search *root, const char *name, void *value)
+int ast_data_search_cmp_int(const struct ast_data_search *root, const char *name, int value)
{
struct ast_data_search *child;
int node_value;
@@ -1021,11 +1020,11 @@
ao2_ref(child, -1);
- return data_search_comparison_result(node_value - (int)value, cmp_type);
+ return data_search_comparison_result(node_value - value, cmp_type);
}
int ast_data_search_cmp_structure(struct ast_data_search *search,
- struct ast_data_structure_mapping *mapping, size_t mapping_len,
+ struct ast_data_mapping_structure *mapping, size_t mapping_len,
void *structure)
{
struct ao2_iterator i;
@@ -1062,7 +1061,6 @@
case AST_DATA_DOUBLE:
case AST_DATA_BOOLEAN:
case AST_DATA_IPADDR:
- case AST_DATA_CHAR:
break;
}
}
@@ -1537,9 +1535,6 @@
ast_xml_set_text(child_xml, "false");
}
break;
- case AST_DATA_CHAR:
- ast_xml_set_text(child_xml, node->payload.str);
- break;
case AST_DATA_POINTER:
break;
case AST_DATA_IPADDR:
@@ -1700,52 +1695,39 @@
return __ast_data_add(root, childname, AST_DATA_STRING, name);
}
-int ast_data_add_structure(struct ast_data *root,
- const struct ast_data_structure_mapping *mapping, size_t mapping_len,
+int __ast_data_add_structure(struct ast_data *root,
+ const struct ast_data_mapping_structure *mapping, size_t mapping_len,
void *structure)
{
- int i, a;
- struct ast_str *tmp;
+ int i;
for (i = 0; i < mapping_len; i++) {
switch (mapping[i].type) {
case AST_DATA_INTEGER:
ast_data_add_int(root, mapping[i].name,
- *((int *)(structure + mapping[i].offset)));
+ mapping[i].get.AST_DATA_INTEGER(structure));
break;
case AST_DATA_UNSIGNED_INTEGER:
ast_data_add_uint(root, mapping[i].name,
- *((unsigned int *)(structure + mapping[i].offset)));
+ mapping[i].get.AST_DATA_UNSIGNED_INTEGER(structure));
break;
case AST_DATA_DOUBLE:
ast_data_add_dbl(root, mapping[i].name,
- *((double *)(structure + mapping[i].offset)));
+ mapping[i].get.AST_DATA_DOUBLE(structure));
break;
case AST_DATA_BOOLEAN:
ast_data_add_bool(root, mapping[i].name,
- *((unsigned int *)(structure + mapping[i].offset)));
+ mapping[i].get.AST_DATA_BOOLEAN(structure));
break;
case AST_DATA_STRING:
ast_data_add_str(root, mapping[i].name,
- *((const char **)(structure + mapping[i].offset)));
- break;
- case AST_DATA_CHAR:
- tmp = ast_str_create((int) mapping[i].additional + 1);
- if (!tmp) {
- break;
- }
- for (a = 0; a < (int) mapping[i].additional; a++) {
- ast_str_append(&tmp, 0, "%c",
- *((const char *)(structure + mapping[i].offset + a)));
- }
- ast_data_add_str(root, mapping[i].name, ast_str_buffer(tmp));
- ast_free(tmp);
+ mapping[i].get.AST_DATA_STRING(structure));
break;
case AST_DATA_CONTAINER:
break;
case AST_DATA_IPADDR:
ast_data_add_str(root, mapping[i].name,
- ast_inet_ntoa(*((struct in_addr *)(structure + mapping[i].offset))));
+ ast_inet_ntoa(mapping[i].get.AST_DATA_IPADDR(structure)));
break;
case AST_DATA_POINTER:
break;
More information about the asterisk-commits
mailing list