summaryrefslogtreecommitdiff
path: root/include/asterisk/stringfields.h
diff options
context:
space:
mode:
authorTerry Wilson <twilson@digium.com>2012-06-01 16:33:25 +0000
committerTerry Wilson <twilson@digium.com>2012-06-01 16:33:25 +0000
commitd54717c39e62f4cc8b290ac4836c4d4469d87c24 (patch)
tree5a765e82be880f3b8c2407133fbcc15c4b4349d0 /include/asterisk/stringfields.h
parent463f9d729aed1a5ed538aa3deed1a3fed9462111 (diff)
Add new config-parsing framework
This framework adds a way to register the various options in a config file with Asterisk and to handle loading and reloading of that config in a consistent and atomic manner. Review: https://reviewboard.asterisk.org/r/1873/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368181 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/stringfields.h')
-rw-r--r--include/asterisk/stringfields.h36
1 files changed, 19 insertions, 17 deletions
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index 86e265beb..b5fdf9c8e 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -310,25 +310,27 @@ void __ast_string_field_release_active(struct ast_string_field_pool *pool_head,
\brief Set a field to a simple string value
\param x Pointer to a structure containing fields
\param ptr Pointer to a field within the structure
- \param data String value to be copied into the field
+ \param data String value to be copied into the field
\return nothing
*/
-#define ast_string_field_ptr_set(x, ptr, data) do { \
- const char *__d__ = (data); \
- size_t __dlen__ = (__d__) ? strlen(__d__) + 1 : 1; \
- ast_string_field *__p__ = (ast_string_field *) (ptr); \
- if (__dlen__ == 1) { \
- __ast_string_field_release_active((x)->__field_mgr_pool, *__p__); \
- *__p__ = __ast_string_field_empty; \
- } else if ((__dlen__ <= AST_STRING_FIELD_ALLOCATION(*__p__)) || \
- (!__ast_string_field_ptr_grow(&(x)->__field_mgr, &(x)->__field_mgr_pool, __dlen__, __p__)) || \
- (*__p__ = __ast_string_field_alloc_space(&(x)->__field_mgr, &(x)->__field_mgr_pool, __dlen__))) { \
- if (*__p__ != (*ptr)) { \
- __ast_string_field_release_active((x)->__field_mgr_pool, (*ptr)); \
- } \
- memcpy(* (void **) __p__, __d__, __dlen__); \
- } \
- } while (0)
+#define ast_string_field_ptr_set(x, ptr, data) ast_string_field_ptr_set_by_fields((x)->__field_mgr_pool, (x)->__field_mgr, ptr, data)
+
+#define ast_string_field_ptr_set_by_fields(field_mgr_pool, field_mgr, ptr, data) do { \
+ const char *__d__ = (data); \
+ size_t __dlen__ = (__d__) ? strlen(__d__) + 1 : 1; \
+ ast_string_field *__p__ = (ast_string_field *) (ptr); \
+ if (__dlen__ == 1) { \
+ __ast_string_field_release_active(field_mgr_pool, *__p__); \
+ *__p__ = __ast_string_field_empty; \
+ } else if ((__dlen__ <= AST_STRING_FIELD_ALLOCATION(*__p__)) || \
+ (!__ast_string_field_ptr_grow(&field_mgr, &field_mgr_pool, __dlen__, __p__)) || \
+ (*__p__ = __ast_string_field_alloc_space(&field_mgr, &field_mgr_pool, __dlen__))) { \
+ if (*__p__ != (*ptr)) { \
+ __ast_string_field_release_active(field_mgr_pool, (*ptr)); \
+ } \
+ memcpy(* (void **) __p__, __d__, __dlen__); \
+ } \
+ } while (0)
/*!
\brief Set a field to a simple string value