[asterisk-commits] dvossel: branch dvossel/hd_confbridge r309254 - in /team/dvossel/hd_confbridg...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 2 13:40:30 CST 2011


Author: dvossel
Date: Wed Mar  2 13:40:28 2011
New Revision: 309254

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=309254
Log:
Revised user, bridge, and menu find API functions

Modified:
    team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
    team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h

Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=309254&r1=309253&r2=309254
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Wed Mar  2 13:40:28 2011
@@ -267,7 +267,7 @@
 }
 static char *handle_cli_confbridge_list_user_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	const struct user_profile *u_profile = NULL;
+	struct user_profile u_profile;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -286,26 +286,25 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	if (!(u_profile = conf_find_user_profile(a->argv[4]))) {
+	if (!(conf_find_user_profile(a->argv[4], &u_profile))) {
 		ast_cli(a->fd, "No conference user profile named '%s' found!\n", a->argv[4]);
 		return CLI_SUCCESS;
 	}
 
 	ast_cli(a->fd,"--------------------------------------------\n");
 	ast_cli(a->fd,"Name:              %s\n",
-		u_profile->name);
+		u_profile.name);
 	ast_cli(a->fd,"Admin:             %s\n",
-		u_profile->flags & USER_OPT_ADMIN ?
+		u_profile.flags & USER_OPT_ADMIN ?
 		"true" : "false");
 	ast_cli(a->fd,"Marked User:       %s\n",
-		u_profile->flags & USER_OPT_MARKEDUSER ?
+		u_profile.flags & USER_OPT_MARKEDUSER ?
 		"true" : "false");
 	ast_cli(a->fd,"Start Muted:       %s\n",
-		u_profile->flags & USER_OPT_STARTMUTED?
+		u_profile.flags & USER_OPT_STARTMUTED?
 		"true" : "false");
 	ast_cli(a->fd,"\n");
 
-	ao2_ref((struct user_profile *) u_profile, -1);
 	return CLI_SUCCESS;
 }
 
@@ -332,7 +331,7 @@
 }
 static char *handle_cli_confbridge_list_bridge_profiles(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	const struct bridge_profile *b_profile = NULL;
+	struct bridge_profile b_profile;
 	char tmp[64];
 
 	switch (cmd) {
@@ -352,34 +351,33 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	if (!(b_profile = conf_find_bridge_profile(a->argv[4]))) {
+	if (!(conf_find_bridge_profile(a->argv[4], &b_profile))) {
 		ast_cli(a->fd, "No conference bridge profile named '%s' found!\n", a->argv[4]);
 		return CLI_SUCCESS;
 	}
 
 	ast_cli(a->fd,"--------------------------------------------\n");
-	ast_cli(a->fd,"Name:                 %s\n", b_profile->name);
-	if (b_profile->internal_sample_rate) {
-		snprintf(tmp, sizeof(tmp), "%d", b_profile->internal_sample_rate);
+	ast_cli(a->fd,"Name:                 %s\n", b_profile.name);
+	if (b_profile.internal_sample_rate) {
+		snprintf(tmp, sizeof(tmp), "%d", b_profile.internal_sample_rate);
 	} else {
 		snprintf(tmp, sizeof(tmp), "auto");
 	}
 	ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp);
 	ast_cli(a->fd,"MOH When Empty:       %s\n",
-		b_profile->flags & BRIDGE_OPT_MUSICONHOLD ?
+		b_profile.flags & BRIDGE_OPT_MUSICONHOLD ?
 		"enabled" : "disabled");
 	ast_cli(a->fd,"Wait Marked:          %s\n",
-		b_profile->flags & BRIDGE_OPT_WAITMARKED ?
+		b_profile.flags & BRIDGE_OPT_WAITMARKED ?
 		"enabled" : "disabled");
 	ast_cli(a->fd,"Quiet:                %s\n",
-		b_profile->flags & BRIDGE_OPT_QUIET ?
+		b_profile.flags & BRIDGE_OPT_QUIET ?
 		"enabled" : "disabled");
 	ast_cli(a->fd,"Announce User Count:  %s\n",
-		b_profile->flags & BRIDGE_OPT_ANNOUNCEUSERCOUNT ?
+		b_profile.flags & BRIDGE_OPT_ANNOUNCEUSERCOUNT ?
 		"enabled" : "disabled");
 	ast_cli(a->fd,"\n");
 
-	ao2_ref((struct bridge_profile *) b_profile, -1);
 	return CLI_SUCCESS;
 }
 
@@ -406,7 +404,7 @@
 }
 static char *handle_cli_confbridge_list_menus(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	const struct conf_menu *menu = NULL;
+	struct conf_menu menu;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -425,14 +423,13 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	if (!(menu = conf_find_menu(a->argv[3]))) {
+	if (!(conf_find_menu(a->argv[3], &menu))) {
 		ast_cli(a->fd, "No conference menu named '%s' found!\n", a->argv[3]);
 		return CLI_SUCCESS;
 	}
-	ast_cli(a->fd,"Name: %s\n", menu->name);
+	ast_cli(a->fd,"Name: %s\n", menu.name);
 	ast_cli(a->fd,"\n");
 
-	ao2_ref((struct conf_menu *) menu, -1);
 	return CLI_SUCCESS;
 }
 
@@ -533,26 +530,53 @@
 	return 0;
 }
 
-const struct user_profile *conf_find_user_profile(const char *user_profile_name)
+const struct user_profile *conf_find_user_profile(const char *user_profile_name, struct user_profile *result)
 {
 	struct user_profile tmp;
+	struct user_profile *tmp2;
 	ast_copy_string(tmp.name, user_profile_name, sizeof(tmp.name));
 
-	return ao2_find(user_profiles, &tmp, OBJ_POINTER);
-
-}
-const struct bridge_profile *conf_find_bridge_profile(const char *bridge_profile_name)
+	if (!(tmp2 = ao2_find(user_profiles, &tmp, OBJ_POINTER))) {
+		return NULL;
+	}
+	ao2_lock(tmp2);
+	memcpy(result, tmp2, sizeof(*result));
+	ao2_unlock(tmp2);
+	ao2_ref(tmp2, -1);
+
+	return result;
+}
+
+const struct bridge_profile *conf_find_bridge_profile(const char *bridge_profile_name, struct bridge_profile *result)
 {
 	struct bridge_profile tmp;
+	struct bridge_profile *tmp2;
 	ast_copy_string(tmp.name, bridge_profile_name, sizeof(tmp.name));
 
-	return ao2_find(bridge_profiles, &tmp, OBJ_POINTER);
-}
-
-const struct conf_menu *conf_find_menu(const char *menu_name)
+	if (!(tmp2 = ao2_find(bridge_profiles, &tmp, OBJ_POINTER))) {
+		return NULL;
+	}
+	ao2_lock(tmp2);
+	memcpy(result, tmp2, sizeof(*result));
+	ao2_unlock(tmp2);
+	ao2_ref(tmp2, -1);
+
+	return result;
+}
+
+const struct conf_menu *conf_find_menu(const char *menu_name, struct conf_menu *result)
 {
 	struct conf_menu tmp;
+	struct conf_menu *tmp2;
 	ast_copy_string(tmp.name, menu_name, sizeof(tmp.name));
 
-	return ao2_find(menus, &tmp, OBJ_POINTER);
-}
+	if (!(tmp2 = ao2_find(menus, &tmp, OBJ_POINTER))) {
+		return NULL;
+	}
+	ao2_lock(tmp2);
+	memcpy(result, tmp2, sizeof(*result));
+	ao2_unlock(tmp2);
+	ao2_ref(tmp2, -1);
+
+	return result;
+}

Modified: team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h?view=diff&rev=309254&r1=309253&r2=309254
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Wed Mar  2 13:40:28 2011
@@ -111,35 +111,27 @@
 void conf_destroy_config(void);
 
 /*!
- * \brief find a user profile given a user profile's name.
- *
- * \note User profile is an AO2 object and must have ref count
- * decremented after being found.
+ * \brief find a user profile given a user profile's name and store
+ * that profile in result structure.
  *
  * \retval user profile on success
  * \retval NULL on failure
  */
-const struct user_profile *conf_find_user_profile(const char *user_profile_name);
+const struct user_profile *conf_find_user_profile(const char *user_profile_name, struct user_profile *result);
 
 /*!
  * \brief find a bridge profile given a bridge profile's name.
  *
- * \note Bridge profile is an AO2 object and must have ref count
- * decremented after being found.
- *
  * \retval Bridge profile on success
  * \retval NULL on failure
  */
-const struct bridge_profile *conf_find_bridge_profile(const char *bridge_profile_name);
+const struct bridge_profile *conf_find_bridge_profile(const char *bridge_profile_name, struct bridge_profile *result);
 
 /*!
  * \brief find a conference DTMF menu given the menu's name
  *
- * \note The conference menu is an AO2 object and must have ref count
- * decremented after being found.
- *
  * \retval menu on success
  * \retval NULL on failure
  */
-const struct conf_menu *conf_find_menu(const char *menu_name);
+const struct conf_menu *conf_find_menu(const char *menu_name, struct conf_menu *result);
 #endif




More information about the asterisk-commits mailing list