From d54717c39e62f4cc8b290ac4836c4d4469d87c24 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Fri, 1 Jun 2012 16:33:25 +0000 Subject: 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 --- include/asterisk/stringfields.h | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'include/asterisk/stringfields.h') 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 -- cgit v1.2.3