mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-04 03:20:33 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user