summaryrefslogtreecommitdiff
path: root/comms
diff options
context:
space:
mode:
authorjnemeth <jnemeth>2013-08-08 00:45:10 +0000
committerjnemeth <jnemeth>2013-08-08 00:45:10 +0000
commitd9a1f5bf47d87f24f300f05cebe654b3da2279a7 (patch)
treea28c7cc8f211904e98c3ca5001f87385be250971 /comms
parentc2b27c5f9a06b0bc6baecaba7c811a3a40b2bdde (diff)
downloadpkgsrc-d9a1f5bf47d87f24f300f05cebe654b3da2279a7.tar.gz
Add patches to convert RAII_VAR to a method that doesn't use nested
functions, thus making Asterisk portable to all C compilers. The patches from joerg@ (with one missing file added by myself).
Diffstat (limited to 'comms')
-rw-r--r--comms/asterisk/Makefile5
-rw-r--r--comms/asterisk/distinfo15
-rw-r--r--comms/asterisk/patches/patch-apps_app__confbridge.c18
-rw-r--r--comms/asterisk/patches/patch-apps_app__skel.c54
-rw-r--r--comms/asterisk/patches/patch-apps_confbridge_conf__config__parser.c125
-rw-r--r--comms/asterisk/patches/patch-channels_chan__motif.c32
-rw-r--r--comms/asterisk/patches/patch-include_asterisk_utils.h18
-rw-r--r--comms/asterisk/patches/patch-main_config__options.c48
-rw-r--r--comms/asterisk/patches/patch-main_manager.c21
-rw-r--r--comms/asterisk/patches/patch-main_named__acl.c60
-rw-r--r--comms/asterisk/patches/patch-main_udptl.c31
-rw-r--r--comms/asterisk/patches/patch-res_res__xmpp.c430
-rw-r--r--comms/asterisk/patches/patch-tests_test__abstract__jb.c80
-rw-r--r--comms/asterisk/patches/patch-tests_test__config.c27
14 files changed, 956 insertions, 8 deletions
diff --git a/comms/asterisk/Makefile b/comms/asterisk/Makefile
index 7b1a0ce0ee3..6c507f3b2be 100644
--- a/comms/asterisk/Makefile
+++ b/comms/asterisk/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.96 2013/07/21 06:55:53 jnemeth Exp $
+# $NetBSD: Makefile,v 1.97 2013/08/08 00:45:10 jnemeth Exp $
#
# NOTE: when updating this package, there are two places that sound
# tarballs need to be checked
@@ -7,6 +7,7 @@ DISTNAME= asterisk-11.5.0
DIST_SUBDIR= ${PKGNAME_NOREV}
DISTFILES= ${DEFAULT_DISTFILES}
EXTRACT_ONLY= ${DISTNAME}.tar.gz
+PKGREVISION= 1
CATEGORIES= comms net audio
MASTER_SITES= http://downloads.asterisk.org/pub/telephony/asterisk/ \
http://downloads.asterisk.org/pub/telephony/asterisk/old-releases/ \
@@ -140,7 +141,7 @@ SUBST_STAGE.atomics= post-configure
SUBST_FILES.atomics= include/asterisk/autoconfig.h
SUBST_SED.atomics= -e "s|^\#define HAVE_GCC_ATOMICS 1|\#undef HAVE_GCC_ATOMICS|"
-# XXX gross hack, IP_PKTINFO in NetBSD isn't compatible with Linux
+# XXX gross hack, IP_PKTINFO in NetBSD isn't compatible with anything else
SUBST_CLASSES+= pktinfo
SUBST_STAGE.pktinfo= post-configure
SUBST_FILES.pktinfo= include/asterisk/autoconfig.h
diff --git a/comms/asterisk/distinfo b/comms/asterisk/distinfo
index 27fa4a5cec5..8cbd8ca6788 100644
--- a/comms/asterisk/distinfo
+++ b/comms/asterisk/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.58 2013/07/21 06:55:53 jnemeth Exp $
+$NetBSD: distinfo,v 1.59 2013/08/08 00:45:10 jnemeth Exp $
SHA1 (asterisk-11.5.0/asterisk-11.5.0.tar.gz) = def6629cb8716bf6fa2d1f267f7c2a44882fca46
RMD160 (asterisk-11.5.0/asterisk-11.5.0.tar.gz) = a450f82bb66469222275b16143b2c45f6097d759
@@ -7,11 +7,15 @@ SHA1 (asterisk-11.5.0/asterisk-extra-sounds-en-gsm-1.4.13.tar.gz) = 3aac6cf4a07c
RMD160 (asterisk-11.5.0/asterisk-extra-sounds-en-gsm-1.4.13.tar.gz) = 5dc9696c54d2233cf74835fe7ccd2c1791f20041
Size (asterisk-11.5.0/asterisk-extra-sounds-en-gsm-1.4.13.tar.gz) = 4407925 bytes
SHA1 (patch-Makefile) = ed581d46026e8e89ed8be374c7085efca19911d2
+SHA1 (patch-apps_app__confbridge.c) = c815905994355a19c32e8e3e2eb5dc9f1679eb29
SHA1 (patch-apps_app__dial.c) = 0f78d2571af88384a2d472ece08bf4b06f9ad211
SHA1 (patch-apps_app__followme.c) = a54e08d0dd0b6ff12281d4b7b8447707c1cbe20a
SHA1 (patch-apps_app__queue.c) = 5bdb602a709060a1ffca688830930f1ca6bc5841
+SHA1 (patch-apps_app__skel.c) = e661a53b61d36343c54be7ad9ea6cde6cb10f180
SHA1 (patch-apps_app__sms.c) = d89b27a9df04d4da98d562241c07d25d182baefc
+SHA1 (patch-apps_confbridge_conf__config__parser.c) = 42d5a6e2ce837111d06fa9154c7f66403cb83553
SHA1 (patch-build__tools_mkpkgconfig) = 2bd3c0e24bc6d721cc234feb19b64a57106fcbe4
+SHA1 (patch-channels_chan__motif.c) = db6c97ba02a441633338d492032d78cd86f094f5
SHA1 (patch-channels_chan__oss.c) = fccfa6fca010294ed2d3ab87fc31f436d67f49fa
SHA1 (patch-configure) = 88619fe9072ff69ed8da0a1917ac3852d10998a4
SHA1 (patch-configure.ac) = 2fdae524cfc95f152b86a32405b80f6edae6fa20
@@ -22,20 +26,27 @@ SHA1 (patch-include_asterisk_endian.h) = 41c1a9a9e02fe394bc9261f5559e931b1378ea2
SHA1 (patch-include_asterisk_inline__api.h) = ff43d14e2608dd08d7d03799dfe9847f9f7f5666
SHA1 (patch-include_asterisk_lock.h) = 8147210ae994f95a1d730beb85a6488dc9653cc4
SHA1 (patch-include_asterisk_strings.h) = fc5987a98429ca470f7e9bdcf170d49b0c1f3407
+SHA1 (patch-include_asterisk_utils.h) = bb606542498d65268a59aa12e1116ccf3e592135
SHA1 (patch-main_Makefile) = 5f9238a528d2b96777e17a4ac6d3e7876dfffb98
SHA1 (patch-main_acl.c) = 1eac532a15127c25981d2db9462a8ccce2c58620
SHA1 (patch-main_asterisk.c) = df7bcdaeb2fc90f9fdc1b16388fbb5cf7eba141c
+SHA1 (patch-main_config__options.c) = e49a946da99546684e8988ca4301bcacbb415987
SHA1 (patch-main_features.c) = 1c11207c60ce53c1101141e07ae04d0ddb838450
-SHA1 (patch-main_manager.c) = 4ca84daac55a39a04c49e018e8b036b92e9b7117
+SHA1 (patch-main_manager.c) = 754c77f373bff93cbd33e907823effc12824dd45
+SHA1 (patch-main_named__acl.c) = 48c23ed0e558299679bbfc9e564383f9f7dd181f
SHA1 (patch-main_netsock.c) = 015796266b9806425180c9bb05a1907116ef086d
SHA1 (patch-main_sched.c) = 73759369470b575e73ca78f9cff096ebb477c9b1
SHA1 (patch-main_stdtime_localtime.c) = 1a5fe07f174fc81d1a59e08a8e5768e99ec46da1
+SHA1 (patch-main_udptl.c) = d575d0c6b6fc1eae9623dfd2c27609e74d25a38c
SHA1 (patch-main_utils.c) = e509c0ea81624b7404a535a3e8be563ce58039f6
SHA1 (patch-pbx_pbx__dundi.c) = 2823c48d64d2b96abb5cf627045d17282629521b
SHA1 (patch-res_pjproject_aconfigure) = 0095894c5daac2dec6a9ec745c0ecb8d46c0b73a
SHA1 (patch-res_pjproject_aconfigure.ac) = cbabe4a5f1888e180c93404324ddb96728dc20b9
SHA1 (patch-res_pjproject_build.symbian_makedef.sh) = 37781fe307564ad827e9be67f507f84230ebf299
+SHA1 (patch-res_res__xmpp.c) = 456a69a763b280a0e735899689de1facd1cd5a62
SHA1 (patch-sounds_Makefile) = 792c2e25e1c8334fe8c9038b8b630376a5894c31
+SHA1 (patch-tests_test__abstract__jb.c) = 42cfa303fc2e399aa9fe3bebf51464d0776e171c
+SHA1 (patch-tests_test__config.c) = fa049dc1fedb8a0c898afa6848406d191acb54d3
SHA1 (patch-tests_test__locale.c) = e8419bed77d4787356adf8bc81893bea2adb48f4
SHA1 (patch-utils_Makefile) = e776da1fe1233a1f6933256f530f3bfff026de25
SHA1 (patch-utils_db1-ast_include_db.h) = 94ec413fe6a6154d65c43bdde2b26644d8bb5dac
diff --git a/comms/asterisk/patches/patch-apps_app__confbridge.c b/comms/asterisk/patches/patch-apps_app__confbridge.c
new file mode 100644
index 00000000000..0c6c039892c
--- /dev/null
+++ b/comms/asterisk/patches/patch-apps_app__confbridge.c
@@ -0,0 +1,18 @@
+$NetBSD: patch-apps_app__confbridge.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- apps/app_confbridge.c.orig 2013-03-04 20:03:09.000000000 +0000
++++ apps/app_confbridge.c
+@@ -2137,10 +2137,12 @@ static char *complete_confbridge_name(co
+ return res;
+ }
+
++RAII_DECL(struct conference_bridge *, bridge, ao2_cleanup);
++
+ static char *complete_confbridge_participant(const char *bridge_name, const char *line, const char *word, int pos, int state)
+ {
+ int which = 0;
+- RAII_VAR(struct conference_bridge *, bridge, NULL, ao2_cleanup);
++ RAII_VAR(struct conference_bridge *, bridge, NULL);
+ struct conference_bridge tmp;
+ struct conference_bridge_user *participant;
+ char *res = NULL;
diff --git a/comms/asterisk/patches/patch-apps_app__skel.c b/comms/asterisk/patches/patch-apps_app__skel.c
new file mode 100644
index 00000000000..bd480dbbea3
--- /dev/null
+++ b/comms/asterisk/patches/patch-apps_app__skel.c
@@ -0,0 +1,54 @@
+$NetBSD: patch-apps_app__skel.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- apps/app_skel.c.orig 2012-06-07 20:32:07.000000000 +0000
++++ apps/app_skel.c
+@@ -315,13 +315,17 @@ static void play_files_helper(struct ast
+ }
+ }
+
++RAII_DECL(struct skel_config *, cfg, ao2_cleanup);
++RAII_DECL(struct skel_level *, level, ao2_cleanup);
++RAII_DECL(struct skel_current_game *, game, ao2_cleanup);
++
+ static int app_exec(struct ast_channel *chan, const char *data)
+ {
+ int win = 0;
+ uint32_t guesses;
+- RAII_VAR(struct skel_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct skel_level *, level, NULL, ao2_cleanup);
+- RAII_VAR(struct skel_current_game *, game, NULL, ao2_cleanup);
++ RAII_VAR(struct skel_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct skel_level *, level, NULL);
++ RAII_VAR(struct skel_current_game *, game, NULL);
+ char *parse, *opts[OPTION_ARG_ARRAY_SIZE];
+ struct ast_flags flags;
+ AST_DECLARE_APP_ARGS(args,
+@@ -459,8 +463,8 @@ static void *skel_level_find(struct ao2_
+ */
+ static void *skel_find_or_create_state(const char *category)
+ {
+- RAII_VAR(struct skel_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct skel_level *, level, NULL, ao2_cleanup);
++ RAII_VAR(struct skel_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct skel_level *, level, NULL);
+ if (!cfg || !cfg->levels || !(level = ao2_find(cfg->levels, category, OBJ_KEY))) {
+ return skel_state_alloc(category);
+ }
+@@ -531,7 +535,7 @@ error:
+
+ static char *handle_skel_show_config(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct skel_config *, cfg, NULL, ao2_cleanup);
++ RAII_VAR(struct skel_config *, cfg, NULL);
+
+ switch(cmd) {
+ case CLI_INIT:
+@@ -591,7 +595,7 @@ static char *handle_skel_show_games(stru
+
+ static char *handle_skel_show_levels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct skel_config *, cfg, NULL, ao2_cleanup);
++ RAII_VAR(struct skel_config *, cfg, NULL);
+ struct ao2_iterator iter;
+ struct skel_level *level;
+
diff --git a/comms/asterisk/patches/patch-apps_confbridge_conf__config__parser.c b/comms/asterisk/patches/patch-apps_confbridge_conf__config__parser.c
new file mode 100644
index 00000000000..c3c545d4f35
--- /dev/null
+++ b/comms/asterisk/patches/patch-apps_confbridge_conf__config__parser.c
@@ -0,0 +1,125 @@
+$NetBSD: patch-apps_confbridge_conf__config__parser.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- apps/confbridge/conf_config_parser.c.orig 2013-02-26 15:24:35.000000000 +0000
++++ apps/confbridge/conf_config_parser.c
+@@ -613,6 +613,8 @@ static int add_menu_entry(struct conf_me
+ return 0;
+ }
+
++RAII_DECL(struct confbridge_cfg *, cfg, ao2_cleanup);
++
+ static char *complete_user_profile_name(const char *line, const char *word, int pos, int state)
+ {
+ int which = 0;
+@@ -620,7 +622,7 @@ static char *complete_user_profile_name(
+ int wordlen = strlen(word);
+ struct ao2_iterator i;
+ struct user_profile *u_profile = NULL;
+- RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle));
+
+ if (!cfg) {
+ return NULL;
+@@ -644,7 +646,7 @@ static char *handle_cli_confbridge_show_
+ {
+ struct ao2_iterator it;
+ struct user_profile *u_profile;
+- RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, NULL);
+
+ switch (cmd) {
+ case CLI_INIT:
+@@ -770,7 +772,7 @@ static char *complete_bridge_profile_nam
+ int wordlen = strlen(word);
+ struct ao2_iterator i;
+ struct bridge_profile *b_profile = NULL;
+- RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle));
+
+ if (!cfg) {
+ return NULL;
+@@ -794,7 +796,7 @@ static char *handle_cli_confbridge_show_
+ {
+ struct ao2_iterator it;
+ struct bridge_profile *b_profile;
+- RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, NULL);
+
+ switch (cmd) {
+ case CLI_INIT:
+@@ -936,7 +938,7 @@ static char *complete_menu_name(const ch
+ int wordlen = strlen(word);
+ struct ao2_iterator i;
+ struct conf_menu *menu = NULL;
+- RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle));
+
+ if (!cfg) {
+ return NULL;
+@@ -960,7 +962,7 @@ static char *handle_cli_confbridge_show_
+ {
+ struct ao2_iterator it;
+ struct conf_menu *menu;
+- RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, NULL);
+
+ switch (cmd) {
+ case CLI_INIT:
+@@ -989,10 +991,12 @@ static char *handle_cli_confbridge_show_
+ return CLI_SUCCESS;
+ }
+
++RAII_DECL(struct conf_menu *, menu, ao2_cleanup);
++
+ static char *handle_cli_confbridge_show_menu(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct conf_menu *, menu, NULL, ao2_cleanup);
+- RAII_VAR(struct confbridge_cfg *, cfg, NULL, ao2_cleanup);
++ RAII_VAR(struct conf_menu *, menu, NULL);
++ RAII_VAR(struct confbridge_cfg *, cfg, NULL);
+ struct conf_menu_entry *menu_entry = NULL;
+ struct conf_menu_action *menu_action = NULL;
+
+@@ -1285,10 +1289,13 @@ static int menu_option_handler(const str
+ return 0;
+ }
+
++RAII_DECL(struct user_profile *, user_profile, ao2_cleanup);
++RAII_DECL(struct bridge_profile *, bridge_profile, ao2_cleanup);
++
+ static int verify_default_profiles(void)
+ {
+- RAII_VAR(struct user_profile *, user_profile, NULL, ao2_cleanup);
+- RAII_VAR(struct bridge_profile *, bridge_profile, NULL, ao2_cleanup);
++ RAII_VAR(struct user_profile *, user_profile, NULL);
++ RAII_VAR(struct bridge_profile *, bridge_profile, NULL);
+ struct confbridge_cfg *cfg = aco_pending_config(&cfg_info);
+
+ if (!cfg) {
+@@ -1400,7 +1407,7 @@ const struct user_profile *conf_find_use
+ struct user_profile *tmp2;
+ struct ast_datastore *datastore = NULL;
+ struct func_confbridge_data *b_data = NULL;
+- RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle));
+
+ if (!cfg) {
+ return NULL;
+@@ -1454,7 +1461,7 @@ const struct bridge_profile *conf_find_b
+ struct bridge_profile *tmp2;
+ struct ast_datastore *datastore = NULL;
+ struct func_confbridge_data *b_data = NULL;
+- RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle));
+
+ if (!cfg) {
+ return NULL;
+@@ -1558,7 +1565,7 @@ int conf_set_menu_to_user(const char *me
+ {
+ struct conf_menu *menu;
+ struct conf_menu_entry *menu_entry = NULL;
+- RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle), ao2_cleanup);
++ RAII_VAR(struct confbridge_cfg *, cfg, ao2_global_obj_ref(cfg_handle));
+
+ if (!cfg) {
+ return -1;
diff --git a/comms/asterisk/patches/patch-channels_chan__motif.c b/comms/asterisk/patches/patch-channels_chan__motif.c
new file mode 100644
index 00000000000..1b693532baa
--- /dev/null
+++ b/comms/asterisk/patches/patch-channels_chan__motif.c
@@ -0,0 +1,32 @@
+$NetBSD: patch-channels_chan__motif.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- channels/chan_motif.c.orig 2012-12-09 01:22:56.000000000 +0000
++++ channels/chan_motif.c
+@@ -337,11 +337,14 @@ static struct jingle_endpoint_state *jin
+ return state;
+ }
+
++RAII_DECL(struct jingle_config *, cfg, ao2_cleanup);
++RAII_DECL(struct jingle_endpoint *, endpoint, ao2_cleanup);
++
+ /*! \brief State find/create function */
+ static struct jingle_endpoint_state *jingle_endpoint_state_find_or_create(const char *category)
+ {
+- RAII_VAR(struct jingle_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct jingle_endpoint *, endpoint, NULL, ao2_cleanup);
++ RAII_VAR(struct jingle_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct jingle_endpoint *, endpoint, NULL);
+
+ if (!cfg || !cfg->endpoints || !(endpoint = jingle_endpoint_find(cfg->endpoints, category))) {
+ return jingle_endpoint_state_create();
+@@ -1729,8 +1732,8 @@ static int jingle_hangup(struct ast_chan
+ /*! \brief Function called by core to create a new outgoing Jingle session */
+ static struct ast_channel *jingle_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause)
+ {
+- RAII_VAR(struct jingle_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct jingle_endpoint *, endpoint, NULL, ao2_cleanup);
++ RAII_VAR(struct jingle_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct jingle_endpoint *, endpoint, NULL);
+ char *dialed, target[200] = "";
+ struct ast_xmpp_buddy *buddy;
+ struct jingle_session *session;
diff --git a/comms/asterisk/patches/patch-include_asterisk_utils.h b/comms/asterisk/patches/patch-include_asterisk_utils.h
new file mode 100644
index 00000000000..f04380ca7b4
--- /dev/null
+++ b/comms/asterisk/patches/patch-include_asterisk_utils.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-include_asterisk_utils.h,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- include/asterisk/utils.h.orig 2013-04-30 13:46:53.000000000 +0000
++++ include/asterisk/utils.h
+@@ -926,10 +926,9 @@ char *ast_utils_which(const char *binary
+ * }
+ * \encode
+ */
+-#define RAII_VAR(vartype, varname, initval, dtor) \
+- /* Prototype needed due to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36774 */ \
+- auto void _dtor_ ## varname (vartype * v); \
+- void _dtor_ ## varname (vartype * v) { dtor(*v); } \
++#define RAII_DECL(vartype, varname, dtor) \
++ static void _dtor_ ## varname (vartype * v) { dtor(*v); }
++#define RAII_VAR(vartype, varname, initval) \
+ vartype varname __attribute__((cleanup(_dtor_ ## varname))) = (initval)
+
+ #endif /* _ASTERISK_UTILS_H */
diff --git a/comms/asterisk/patches/patch-main_config__options.c b/comms/asterisk/patches/patch-main_config__options.c
new file mode 100644
index 00000000000..5638ca3310e
--- /dev/null
+++ b/comms/asterisk/patches/patch-main_config__options.c
@@ -0,0 +1,48 @@
+$NetBSD: patch-main_config__options.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- main/config_options.c.orig 2012-10-02 01:27:19.000000000 +0000
++++ main/config_options.c
+@@ -343,8 +343,10 @@ static int is_preload(struct aco_file *f
+ return 0;
+ }
+
++RAII_DECL(void *, new_item, ao2_cleanup);
++
+ static int process_category(struct ast_config *cfg, struct aco_info *info, struct aco_file *file, const char *cat, int preload) {
+- RAII_VAR(void *, new_item, NULL, ao2_cleanup);
++ RAII_VAR(void *, new_item, NULL);
+ struct aco_type *type;
+ /* For global types, field is the global option struct. For non-global, it is the container for items.
+ * We do not grab a reference to these objects, as the info already holds references to them. This
+@@ -556,9 +558,12 @@ end:
+ ao2_cleanup(info->internal->pending);
+ return res;
+ }
++
++RAII_DECL(struct aco_option *, opt, ao2_cleanup);
++
+ int aco_process_var(struct aco_type *type, const char *cat, struct ast_variable *var, void *obj)
+ {
+- RAII_VAR(struct aco_option *, opt, aco_option_find(type, var->name), ao2_cleanup);
++ RAII_VAR(struct aco_option *, opt, aco_option_find(type, var->name));
+ if (opt && opt->deprecated && !ast_strlen_zero(opt->aliased_to)) {
+ const char *alias = ast_strdupa(opt->aliased_to);
+ ast_log(LOG_WARNING, "At line %d of %s option '%s' is deprecated. Use '%s' instead\n", var->lineno, var->file, var->name, alias);
+@@ -682,6 +687,8 @@ void aco_info_destroy(struct aco_info *i
+ }
+ }
+
++RAII_DECL(struct ast_variable *, var, ast_variables_destroy);
++
+ int aco_set_defaults(struct aco_type *type, const char *category, void *obj)
+ {
+ struct aco_option *opt;
+@@ -690,7 +697,7 @@ int aco_set_defaults(struct aco_type *ty
+ iter = ao2_iterator_init(type->internal->opts, 0);
+
+ while ((opt = ao2_iterator_next(&iter))) {
+- RAII_VAR(struct ast_variable *, var, NULL, ast_variables_destroy);
++ RAII_VAR(struct ast_variable *, var, NULL);
+
+ if (ast_strlen_zero(opt->default_val)) {
+ ao2_ref(opt, -1);
diff --git a/comms/asterisk/patches/patch-main_manager.c b/comms/asterisk/patches/patch-main_manager.c
index ae94e2aeebd..4a4bcf345e6 100644
--- a/comms/asterisk/patches/patch-main_manager.c
+++ b/comms/asterisk/patches/patch-main_manager.c
@@ -1,8 +1,8 @@
-$NetBSD: patch-main_manager.c,v 1.1 2012/12/11 08:22:49 jnemeth Exp $
+$NetBSD: patch-main_manager.c,v 1.2 2013/08/08 00:45:10 jnemeth Exp $
---- main/manager.c.orig 2012-10-17 19:22:46.000000000 +0000
+--- main/manager.c.orig 2013-05-13 14:26:57.000000000 +0000
+++ main/manager.c
-@@ -1827,7 +1827,7 @@ static char *handle_showmanconn(struct a
+@@ -1850,7 +1850,7 @@ static char *handle_showmanconn(struct a
struct mansession_session *session;
time_t now = time(NULL);
#define HSMCONN_FORMAT1 " %-15.15s %-55.55s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n"
@@ -11,7 +11,7 @@ $NetBSD: patch-main_manager.c,v 1.1 2012/12/11 08:22:49 jnemeth Exp $
int count = 0;
struct ao2_iterator i;
-@@ -1848,7 +1848,7 @@ static char *handle_showmanconn(struct a
+@@ -1871,7 +1871,7 @@ static char *handle_showmanconn(struct a
i = ao2_iterator_init(sessions, 0);
while ((session = ao2_iterator_next(&i))) {
ao2_lock(session);
@@ -20,3 +20,16 @@ $NetBSD: patch-main_manager.c,v 1.1 2012/12/11 08:22:49 jnemeth Exp $
count++;
ao2_unlock(session);
unref_mansession(session);
+@@ -7203,9 +7203,11 @@ static char *handle_manager_show_events(
+ return CLI_SUCCESS;
+ }
+
++RAII_DECL(struct ao2_container *, events, ao2_cleanup);
++
+ static char *handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct ao2_container *, events, NULL, ao2_cleanup);
++ RAII_VAR(struct ao2_container *, events, NULL);
+ struct ao2_iterator it_events;
+ struct ast_xml_doc_item *item, *temp;
+ int length;
diff --git a/comms/asterisk/patches/patch-main_named__acl.c b/comms/asterisk/patches/patch-main_named__acl.c
new file mode 100644
index 00000000000..aebd8a79403
--- /dev/null
+++ b/comms/asterisk/patches/patch-main_named__acl.c
@@ -0,0 +1,60 @@
+$NetBSD: patch-main_named__acl.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- main/named_acl.c.orig 2012-12-06 17:28:35.000000000 +0000
++++ main/named_acl.c
+@@ -309,11 +309,15 @@ static struct named_acl *named_acl_find_
+ return acl;
+ }
+
++RAII_DECL(struct named_acl_config *, cfg, ao2_cleanup);
++RAII_DECL(struct named_acl *, named_acl, ao2_cleanup);
++RAII_DECL(struct named_acl *, realtime_acl, ao2_cleanup);
++
+ struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined) {
+ struct ast_ha *ha = NULL;
+
+- RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct named_acl *, named_acl, NULL, ao2_cleanup);
++ RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct named_acl *, named_acl, NULL);
+
+ if (is_realtime) {
+ *is_realtime = 0;
+@@ -333,7 +337,7 @@ struct ast_ha *ast_named_acl_find(const
+
+ /* If a named ACL couldn't be retrieved locally, we need to try realtime storage. */
+ if (!named_acl) {
+- RAII_VAR(struct named_acl *, realtime_acl, NULL, ao2_cleanup);
++ RAII_VAR(struct named_acl *, realtime_acl, NULL);
+
+ /* Attempt to create from realtime */
+ if ((realtime_acl = named_acl_find_realtime(name))) {
+@@ -441,8 +445,8 @@ static void cli_display_named_acl(int fd
+ int ha_index = 0;
+ int is_realtime = 0;
+
+- RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct named_acl *, named_acl, NULL, ao2_cleanup);
++ RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct named_acl *, named_acl, NULL);
+
+ /* If the configuration or the configuration's named_acl_list is unavailable, abort. */
+ if ((!cfg) || (!cfg->named_acl_list)) {
+@@ -481,7 +485,7 @@ static void cli_display_named_acl_list(i
+ {
+ struct ao2_iterator i;
+ void *o;
+- RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals));
+
+ ast_cli(fd, "\nacl\n---\n");
+
+@@ -503,7 +507,7 @@ static void cli_display_named_acl_list(i
+ /* \brief ACL command show <name> */
+ static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals));
+ int length;
+ int which;
+ struct ao2_iterator i;
diff --git a/comms/asterisk/patches/patch-main_udptl.c b/comms/asterisk/patches/patch-main_udptl.c
new file mode 100644
index 00000000000..34554223ce8
--- /dev/null
+++ b/comms/asterisk/patches/patch-main_udptl.c
@@ -0,0 +1,31 @@
+$NetBSD: patch-main_udptl.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- main/udptl.c.orig 2012-12-11 21:12:26.000000000 +0000
++++ main/udptl.c
+@@ -952,6 +952,8 @@ unsigned int ast_udptl_get_far_max_ifp(s
+ return udptl->far_max_ifp;
+ }
+
++RAII_DECL(struct udptl_config *, cfg, ao2_cleanup);
++
+ struct ast_udptl *ast_udptl_new_with_bindaddr(struct ast_sched_context *sched, struct io_context *io, int callbackmode, struct ast_sockaddr *addr)
+ {
+ struct ast_udptl *udptl;
+@@ -959,7 +961,7 @@ struct ast_udptl *ast_udptl_new_with_bin
+ int startplace;
+ int i;
+ long int flags;
+- RAII_VAR(struct udptl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct udptl_config *, cfg, ao2_global_obj_ref(globals));
+
+ if (!cfg || !cfg->general) {
+ ast_log(LOG_ERROR, "Could not access global udptl options!\n");
+@@ -1352,7 +1354,7 @@ static char *handle_cli_udptl_set_debug(
+
+ static char *handle_cli_show_config(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct udptl_config *, cfg, NULL, ao2_cleanup);
++ RAII_VAR(struct udptl_config *, cfg, NULL);
+
+ switch (cmd) {
+ case CLI_INIT:
diff --git a/comms/asterisk/patches/patch-res_res__xmpp.c b/comms/asterisk/patches/patch-res_res__xmpp.c
new file mode 100644
index 00000000000..24df78da5e7
--- /dev/null
+++ b/comms/asterisk/patches/patch-res_res__xmpp.c
@@ -0,0 +1,430 @@
+$NetBSD: patch-res_res__xmpp.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- res/res_xmpp.c.orig 2013-04-16 23:27:51.000000000 +0000
++++ res/res_xmpp.c
+@@ -510,11 +510,14 @@ static void *xmpp_config_find(struct ao2
+ return ao2_find(tmp_container, category, OBJ_KEY);
+ }
+
++RAII_DECL(struct xmpp_config *, cfg, ao2_cleanup);
++RAII_DECL(struct ast_xmpp_client_config *, clientcfg, ao2_cleanup);
++
+ /*! \brief Look up existing client or create a new one */
+ static void *xmpp_client_find_or_create(const char *category)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+
+ if (!cfg || !cfg->clients || !(clientcfg = xmpp_config_find(cfg->clients, category))) {
+ return xmpp_client_alloc(category);
+@@ -602,11 +605,13 @@ error:
+ return NULL;
+ }
+
++RAII_DECL(struct ast_xmpp_client_config *, oldclientcfg, ao2_cleanup);
++
+ static int xmpp_config_prelink(void *newitem)
+ {
+ struct ast_xmpp_client_config *clientcfg = newitem;
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, oldclientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, oldclientcfg, NULL);
+
+ if (ast_strlen_zero(clientcfg->user)) {
+ ast_log(LOG_ERROR, "No user specified on client '%s'\n", clientcfg->name);
+@@ -642,7 +647,7 @@ static int xmpp_config_prelink(void *new
+
+ static void xmpp_config_post_apply(void)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
+
+ ao2_callback(cfg->clients, OBJ_NODATA | OBJ_MULTIPLE, xmpp_client_config_post_apply, NULL);
+ }
+@@ -728,8 +733,8 @@ static int xmpp_is_secure(struct ast_xmp
+
+ struct ast_xmpp_client *ast_xmpp_client_find(const char *name)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+
+ if (!cfg || !cfg->clients || !(clientcfg = xmpp_config_find(cfg->clients, name))) {
+ return NULL;
+@@ -757,8 +762,8 @@ void ast_xmpp_client_unlock(struct ast_x
+ /*! \brief Internal function used to send a message to a user or chatroom */
+ static int xmpp_client_send_message(struct ast_xmpp_client *client, int group, const char *nick, const char *address, const char *message)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ int res = 0;
+ char from[XMPP_MAX_JIDLEN];
+ iks *message_packet;
+@@ -821,8 +826,8 @@ done:
+
+ static int xmpp_client_set_group_presence(struct ast_xmpp_client *client, const char *room, int level, const char *nick)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ int res = 0;
+ iks *presence = NULL, *x = NULL;
+ char from[XMPP_MAX_JIDLEN], roomid[XMPP_MAX_JIDLEN];
+@@ -892,8 +897,8 @@ void ast_xmpp_increment_mid(char *mid)
+ */
+ static iks* xmpp_pubsub_iq_create(struct ast_xmpp_client *client, const char *type)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ iks *request;
+
+ if (!cfg || !cfg->clients || !(clientcfg = xmpp_config_find(cfg->clients, client->name)) ||
+@@ -925,7 +930,7 @@ static iks* xmpp_pubsub_iq_create(struct
+ static iks* xmpp_pubsub_build_publish_skeleton(struct ast_xmpp_client *client, const char *node,
+ const char *event_type, unsigned int cachable)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
+ iks *request, *pubsub, *publish, *item;
+
+ if (!cfg || !cfg->global || !(request = xmpp_pubsub_iq_create(client, "set"))) {
+@@ -1151,7 +1156,7 @@ static void xmpp_pubsub_publish_mwi(stru
+ static void xmpp_pubsub_publish_device_state(struct ast_xmpp_client *client, const char *device,
+ const char *device_state, unsigned int cachable)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
+ iks *request, *state;
+ char eid_str[20], cachable_str[2];
+
+@@ -1263,7 +1268,7 @@ static void xmpp_pubsub_unsubscribe(stru
+ */
+ static void xmpp_pubsub_subscribe(struct ast_xmpp_client *client, const char *node)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
+ iks *request = xmpp_pubsub_iq_create(client, "set");
+ iks *pubsub, *subscribe;
+
+@@ -1369,7 +1374,7 @@ static int xmpp_pubsub_handle_event(void
+
+ static int xmpp_pubsub_handle_error(void *data, ikspak *pak)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
+ char *node_name, *error;
+ int error_num;
+ iks *orig_request, *orig_pubsub = iks_find(pak->x, "pubsub");
+@@ -1442,8 +1447,8 @@ static int xmpp_pubsub_handle_error(void
+ */
+ static void xmpp_init_event_distribution(struct ast_xmpp_client *client)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+
+ if (!cfg || !cfg->clients || !(clientcfg = xmpp_config_find(cfg->clients, client->name))) {
+ return;
+@@ -1497,8 +1502,8 @@ static int xmpp_resource_immediate(void
+ */
+ static int xmpp_status_exec(struct ast_channel *chan, const char *data)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_buddy *buddy;
+ struct ast_xmpp_resource *resource;
+ char *s = NULL, status[2];
+@@ -1576,8 +1581,8 @@ static int xmpp_status_exec(struct ast_c
+ */
+ static int acf_jabberstatus_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buflen)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_buddy *buddy;
+ struct ast_xmpp_resource *resource;
+ int stat = 7;
+@@ -1649,8 +1654,8 @@ static struct ast_custom_function jabber
+ */
+ static int xmpp_join_exec(struct ast_channel *chan, const char *data)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ char *s, nick[XMPP_MAX_RESJIDLEN];
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(sender);
+@@ -1708,8 +1713,8 @@ static int xmpp_join_exec(struct ast_cha
+ */
+ static int xmpp_leave_exec(struct ast_channel *chan, const char *data)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ char *s, nick[XMPP_MAX_RESJIDLEN];
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(sender);
+@@ -1769,8 +1774,8 @@ static int xmpp_leave_exec(struct ast_ch
+ */
+ static int xmpp_send_exec(struct ast_channel *chan, const char *data)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ char *s;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(sender);
+@@ -1810,8 +1815,8 @@ static int xmpp_send_exec(struct ast_cha
+ */
+ static int xmpp_sendgroup_exec(struct ast_channel *chan, const char *data)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ char *s, nick[XMPP_MAX_RESJIDLEN];
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(sender);
+@@ -1863,8 +1868,8 @@ static int xmpp_sendgroup_exec(struct as
+ */
+ static int acf_jabberreceive_read(struct ast_channel *chan, const char *name, char *data, char *buf, size_t buflen)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ char *parse = NULL;
+ int timeout, jidlen, resourcelen, found = 0;
+ struct timeval start;
+@@ -2022,8 +2027,8 @@ static struct ast_custom_function jabber
+ */
+ static int delete_old_messages(struct ast_xmpp_client *client, char *from)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ int deleted = 0, isold = 0;
+ struct ast_xmpp_message *message = NULL;
+
+@@ -2056,8 +2061,8 @@ static int delete_old_messages(struct as
+
+ static int xmpp_send_cb(const struct ast_msg *msg, const char *to, const char *from)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ char *sender, *dest;
+ int res;
+
+@@ -2181,8 +2186,8 @@ static int xmpp_client_subscribe_user(vo
+ /*! \brief Hook function called when roster is received from server */
+ static int xmpp_roster_hook(void *data, ikspak *pak)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_client *client = data;
+ iks *item;
+
+@@ -2239,8 +2244,8 @@ static int xmpp_roster_hook(void *data,
+ /*! \brief Internal function which changes the presence status of an XMPP client */
+ static void xmpp_client_set_presence(struct ast_xmpp_client *client, const char *to, const char *from, int level, const char *desc)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ iks *presence = NULL, *cnode = NULL, *priority = NULL;
+ char priorityS[10];
+
+@@ -2367,8 +2372,8 @@ static int xmpp_client_service_discovery
+ /*! \brief Hook function called when client finishes authenticating with the server */
+ static int xmpp_connect_hook(void *data, ikspak *pak)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_client *client = data;
+ iks *roster;
+
+@@ -2405,8 +2410,8 @@ static int xmpp_connect_hook(void *data,
+ /*! \brief Logging hook function */
+ static void xmpp_log_hook(void *data, const char *xmpp, size_t size, int incoming)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_client *client = data;
+
+ if (!ast_strlen_zero(xmpp)) {
+@@ -2750,8 +2755,8 @@ static int xmpp_component_authenticate(s
+ /*! \brief Hook function called when component receives a service discovery get message */
+ static int xmpp_component_service_discovery_get_hook(void *data, ikspak *pak)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_client *client = data;
+ iks *iq = NULL, *query = NULL, *identity = NULL, *disco = NULL, *reg = NULL, *commands = NULL, *gateway = NULL;
+ iks *version = NULL, *vcard = NULL, *search = NULL, *item = NULL;
+@@ -2837,8 +2842,8 @@ done:
+ /*! \brief Hook function called when the component is queried about registration */
+ static int xmpp_component_register_get_hook(void *data, ikspak *pak)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_client *client = data;
+ iks *iq = NULL, *query = NULL, *error = NULL, *notacceptable = NULL, *instructions = NULL;
+ struct ast_xmpp_buddy *buddy;
+@@ -2945,8 +2950,8 @@ done:
+ /*! \brief Hook function called when we receive a service discovery items request */
+ static int xmpp_component_service_discovery_items_hook(void *data, ikspak *pak)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_client *client = data;
+ iks *iq = NULL, *query = NULL, *item = NULL, *feature = NULL;
+ char *node;
+@@ -3295,8 +3300,8 @@ static int xmpp_pak_s10n(struct ast_xmpp
+ /*! \brief Action hook for when things occur */
+ static int xmpp_action_hook(void *data, int type, iks *node)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ struct ast_xmpp_client *client = data;
+ ikspak *pak;
+ int i;
+@@ -3405,8 +3410,8 @@ int ast_xmpp_client_disconnect(struct as
+ /*! \brief Internal function used to reconnect an XMPP client to its server */
+ static int xmpp_client_reconnect(struct ast_xmpp_client *client)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ int res = IKS_NET_NOCONN;
+
+ if (!cfg || !cfg->clients || !(clientcfg = xmpp_config_find(cfg->clients, client->name))) {
+@@ -3569,8 +3574,8 @@ static void *xmpp_client_thread(void *da
+ } else if (res == IKS_NET_TLSFAIL) {
+ ast_log(LOG_ERROR, "JABBER: Failure in TLS.\n");
+ } else if (!client->timeout && client->state == XMPP_STATE_CONNECTED) {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+
+ if (cfg && cfg->clients && (clientcfg = xmpp_config_find(cfg->clients, client->name))) {
+ res = ast_test_flag(&clientcfg->flags, XMPP_KEEPALIVE) ? xmpp_client_send_raw_message(client, " ") : IKS_OK;
+@@ -3667,8 +3672,8 @@ static int xmpp_client_config_post_apply
+ */
+ static int manager_jabber_send(struct mansession *s, const struct message *m)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ const char *id = astman_get_header(m, "ActionID");
+ const char *jabber = astman_get_header(m, "Jabber");
+ const char *screenname = astman_get_header(m, "ScreenName");
+@@ -3794,8 +3799,8 @@ static void xmpp_pubsub_request_nodes(st
+ static char *xmpp_cli_list_pubsub_nodes(struct ast_cli_entry *e, int cmd, struct
+ ast_cli_args *a)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ const char *name = NULL, *collection = NULL;
+
+ switch (cmd) {
+@@ -3880,8 +3885,8 @@ static void xmpp_pubsub_purge_nodes(stru
+ static char *xmpp_cli_purge_pubsub_nodes(struct ast_cli_entry *e, int cmd, struct
+ ast_cli_args *a)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ const char *name;
+
+ switch (cmd) {
+@@ -3925,8 +3930,8 @@ static char *xmpp_cli_purge_pubsub_nodes
+ static char *xmpp_cli_delete_pubsub_node(struct ast_cli_entry *e, int cmd, struct
+ ast_cli_args *a)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ const char *name;
+
+ switch (cmd) {
+@@ -3962,8 +3967,8 @@ static char *xmpp_cli_delete_pubsub_node
+ */
+ static char *xmpp_cli_create_collection(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ const char *name, *collection_name;
+
+ switch (cmd) {
+@@ -4002,8 +4007,8 @@ static char *xmpp_cli_create_collection(
+ */
+ static char *xmpp_cli_create_leafnode(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
+- RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL, ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
++ RAII_VAR(struct ast_xmpp_client_config *, clientcfg, NULL);
+ const char *name, *collection_name, *leaf_name;
+
+ switch (cmd) {
+@@ -4078,7 +4083,7 @@ static char *xmpp_do_set_debug(struct as
+ */
+ static char *xmpp_show_clients(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
+ struct ao2_iterator i;
+ struct ast_xmpp_client_config *clientcfg;
+
+@@ -4154,7 +4159,7 @@ static char *xmpp_show_clients(struct as
+ */
+ static char *xmpp_show_buddies(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+ {
+- RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
++ RAII_VAR(struct xmpp_config *, cfg, ao2_global_obj_ref(globals));
+ struct ao2_iterator i;
+ struct ast_xmpp_client_config *clientcfg;
+
diff --git a/comms/asterisk/patches/patch-tests_test__abstract__jb.c b/comms/asterisk/patches/patch-tests_test__abstract__jb.c
new file mode 100644
index 00000000000..bd26fd6d409
--- /dev/null
+++ b/comms/asterisk/patches/patch-tests_test__abstract__jb.c
@@ -0,0 +1,80 @@
+$NetBSD: patch-tests_test__abstract__jb.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- tests/test_abstract_jb.c.orig 2012-07-23 21:15:26.000000000 +0000
++++ tests/test_abstract_jb.c
+@@ -177,8 +177,11 @@ static struct ast_jb default_jb = {
+ * \param type_name The enum type of the jitter buffer to create
+ * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
+ */
++
++RAII_DECL(struct ast_jb *, jb, dispose_jitterbuffer);
++
+ #define test_create_nominal(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, create)) {\
+- RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
++ RAII_VAR(struct ast_jb *, jb, &default_jb); \
+ const struct ast_jb_impl *impl; \
+ struct ast_jb_conf conf; \
+ \
+@@ -213,12 +216,16 @@ static struct ast_jb default_jb = {
+ * \param type_name The enum type of the jitter buffer to create
+ * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
+ */
++
++RAII_DECL(struct ast_frame *, expected_frame, dispose_frame);
++RAII_DECL(struct ast_frame *, actual_frame, dispose_frame);
++
+ #define test_put_first(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, put_first)) {\
+- RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
++ RAII_VAR(struct ast_jb *, jb, &default_jb); \
+ const struct ast_jb_impl *impl; \
+ struct ast_jb_conf conf; \
+- RAII_VAR(struct ast_frame *, expected_frame, NULL, dispose_frame); \
+- RAII_VAR(struct ast_frame *, actual_frame, NULL, dispose_frame); \
++ RAII_VAR(struct ast_frame *, expected_frame, NULL); \
++ RAII_VAR(struct ast_frame *, actual_frame, NULL); \
+ int res; \
+ \
+ switch (cmd) { \
+@@ -270,11 +277,11 @@ static struct ast_jb default_jb = {
+ * \param literal_type_name The literal name of the type - "fixed" or "adaptive"
+ */
+ #define test_put(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, put)) {\
+- RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
++ RAII_VAR(struct ast_jb *, jb, &default_jb); \
+ const struct ast_jb_impl *impl; \
+ struct ast_jb_conf conf; \
+- RAII_VAR(struct ast_frame *, expected_frame, NULL, dispose_frame); \
+- RAII_VAR(struct ast_frame *, actual_frame, NULL, dispose_frame); \
++ RAII_VAR(struct ast_frame *, expected_frame, NULL); \
++ RAII_VAR(struct ast_frame *, actual_frame, NULL); \
+ int res; \
+ long next; \
+ int i; \
+@@ -333,10 +340,10 @@ static struct ast_jb default_jb = {
+ * \param overflow_limit The number of frames at which we expect the buffer to overflow
+ */
+ #define test_put_overflow(type_name, literal_type_name, overflow_limit) AST_TEST_DEFINE(TEST_NAME(type_name, put_overflow)) {\
+- RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
++ RAII_VAR(struct ast_jb *, jb, &default_jb); \
+ const struct ast_jb_impl *impl; \
+ struct ast_jb_conf conf; \
+- RAII_VAR(struct ast_frame *, expected_frame, NULL, dispose_frame); \
++ RAII_VAR(struct ast_frame *, expected_frame, NULL); \
+ int res; \
+ int i; \
+ \
+@@ -398,11 +405,11 @@ static struct ast_jb default_jb = {
+ * \param synch_limit The synchronization limit for this particular type of jitter buffer
+ */
+ #define test_put_out_of_order(type_name, literal_type_name, synch_limit) AST_TEST_DEFINE(TEST_NAME(type_name, put_out_of_order)) {\
+- RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
++ RAII_VAR(struct ast_jb *, jb, &default_jb); \
+ const struct ast_jb_impl *impl; \
+ struct ast_jb_conf conf; \
+- RAII_VAR(struct ast_frame *, actual_frame, NULL, dispose_frame); \
+- RAII_VAR(struct ast_frame *, expected_frame, NULL, dispose_frame); \
++ RAII_VAR(struct ast_frame *, actual_frame, NULL); \
++ RAII_VAR(struct ast_frame *, expected_frame, NULL); \
+ int res; \
+ long next; \
+ int i; \
diff --git a/comms/asterisk/patches/patch-tests_test__config.c b/comms/asterisk/patches/patch-tests_test__config.c
new file mode 100644
index 00000000000..a5e4c7ec3e1
--- /dev/null
+++ b/comms/asterisk/patches/patch-tests_test__config.c
@@ -0,0 +1,27 @@
+$NetBSD: patch-tests_test__config.c,v 1.1 2013/08/08 00:45:10 jnemeth Exp $
+
+--- tests/test_config.c.orig 2012-07-12 21:43:09.000000000 +0000
++++ tests/test_config.c
+@@ -753,15 +753,19 @@ CONFIG_INFO_STANDARD(cfg_info, global_ob
+ .files = ACO_FILES(&config_test_conf),
+ );
+
++RAII_DECL(struct test_config *, cfg, ao2_cleanup);
++RAII_DECL(struct test_item *, item, ao2_cleanup);
++RAII_DECL(struct test_item *, item_defaults, ao2_cleanup);
++
+ AST_TEST_DEFINE(config_options_test)
+ {
+ int res = AST_TEST_PASS, x, error;
+ struct test_item defaults = { 0, }, configs = { 0, };
+ struct test_item *arr[4];
+ struct ast_sockaddr acl_allow = {{ 0, }}, acl_fail = {{ 0, }};
+- RAII_VAR(struct test_config *, cfg, NULL, ao2_cleanup);
+- RAII_VAR(struct test_item *, item, NULL, ao2_cleanup);
+- RAII_VAR(struct test_item *, item_defaults, NULL, ao2_cleanup);
++ RAII_VAR(struct test_config *, cfg, NULL);
++ RAII_VAR(struct test_item *, item, NULL);
++ RAII_VAR(struct test_item *, item_defaults, NULL);
+
+ switch (cmd) {
+ case TEST_INIT: