[asterisk-commits] dlee: branch dlee/endpoints r386925 - in /team/dlee/endpoints: ./ addons/ app...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 30 01:02:48 CDT 2013


Author: dlee
Date: Tue Apr 30 01:02:43 2013
New Revision: 386925

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386925
Log:
Merged revisions 386266-386879 from http://svn.asterisk.org/svn/asterisk/trunk

Added:
    team/dlee/endpoints/channels/chan_gulp.c
      - copied unchanged from r386879, trunk/channels/chan_gulp.c
    team/dlee/endpoints/configs/res_sip.conf.sample
      - copied unchanged from r386879, trunk/configs/res_sip.conf.sample
    team/dlee/endpoints/configs/statsd.conf.sample
      - copied unchanged from r386879, trunk/configs/statsd.conf.sample
    team/dlee/endpoints/include/asterisk/res_sip.h
      - copied unchanged from r386879, trunk/include/asterisk/res_sip.h
    team/dlee/endpoints/include/asterisk/res_sip_pubsub.h
      - copied unchanged from r386879, trunk/include/asterisk/res_sip_pubsub.h
    team/dlee/endpoints/include/asterisk/res_sip_session.h
      - copied unchanged from r386879, trunk/include/asterisk/res_sip_session.h
    team/dlee/endpoints/include/asterisk/statsd.h
      - copied unchanged from r386879, trunk/include/asterisk/statsd.h
    team/dlee/endpoints/res/res_chan_stats.c
      - copied unchanged from r386879, trunk/res/res_chan_stats.c
    team/dlee/endpoints/res/res_sip/   (props changed)
      - copied from r386879, trunk/res/res_sip/
    team/dlee/endpoints/res/res_sip.c
      - copied unchanged from r386879, trunk/res/res_sip.c
    team/dlee/endpoints/res/res_sip.exports.in
      - copied unchanged from r386879, trunk/res/res_sip.exports.in
    team/dlee/endpoints/res/res_sip_acl.c
      - copied unchanged from r386879, trunk/res/res_sip_acl.c
    team/dlee/endpoints/res/res_sip_authenticator_digest.c
      - copied unchanged from r386879, trunk/res/res_sip_authenticator_digest.c
    team/dlee/endpoints/res/res_sip_caller_id.c
      - copied unchanged from r386879, trunk/res/res_sip_caller_id.c
    team/dlee/endpoints/res/res_sip_dtmf_info.c
      - copied unchanged from r386879, trunk/res/res_sip_dtmf_info.c
    team/dlee/endpoints/res/res_sip_endpoint_identifier_constant.c
      - copied unchanged from r386879, trunk/res/res_sip_endpoint_identifier_constant.c
    team/dlee/endpoints/res/res_sip_endpoint_identifier_ip.c
      - copied unchanged from r386879, trunk/res/res_sip_endpoint_identifier_ip.c
    team/dlee/endpoints/res/res_sip_endpoint_identifier_user.c
      - copied unchanged from r386879, trunk/res/res_sip_endpoint_identifier_user.c
    team/dlee/endpoints/res/res_sip_logger.c
      - copied unchanged from r386879, trunk/res/res_sip_logger.c
    team/dlee/endpoints/res/res_sip_mwi.c
      - copied unchanged from r386879, trunk/res/res_sip_mwi.c
    team/dlee/endpoints/res/res_sip_nat.c
      - copied unchanged from r386879, trunk/res/res_sip_nat.c
    team/dlee/endpoints/res/res_sip_outbound_authenticator_digest.c
      - copied unchanged from r386879, trunk/res/res_sip_outbound_authenticator_digest.c
    team/dlee/endpoints/res/res_sip_outbound_registration.c
      - copied unchanged from r386879, trunk/res/res_sip_outbound_registration.c
    team/dlee/endpoints/res/res_sip_pubsub.c
      - copied unchanged from r386879, trunk/res/res_sip_pubsub.c
    team/dlee/endpoints/res/res_sip_pubsub.exports.in
      - copied unchanged from r386879, trunk/res/res_sip_pubsub.exports.in
    team/dlee/endpoints/res/res_sip_registrar.c
      - copied unchanged from r386879, trunk/res/res_sip_registrar.c
    team/dlee/endpoints/res/res_sip_rfc3326.c
      - copied unchanged from r386879, trunk/res/res_sip_rfc3326.c
    team/dlee/endpoints/res/res_sip_sdp_rtp.c
      - copied unchanged from r386879, trunk/res/res_sip_sdp_rtp.c
    team/dlee/endpoints/res/res_sip_session.c
      - copied unchanged from r386879, trunk/res/res_sip_session.c
    team/dlee/endpoints/res/res_sip_session.exports.in
      - copied unchanged from r386879, trunk/res/res_sip_session.exports.in
    team/dlee/endpoints/res/res_sorcery_realtime.c
      - copied unchanged from r386879, trunk/res/res_sorcery_realtime.c
    team/dlee/endpoints/res/res_statsd.c
      - copied unchanged from r386879, trunk/res/res_statsd.c
    team/dlee/endpoints/res/res_statsd.exports.in
      - copied unchanged from r386879, trunk/res/res_statsd.exports.in
    team/dlee/endpoints/tests/test_sorcery_realtime.c
      - copied unchanged from r386879, trunk/tests/test_sorcery_realtime.c
Modified:
    team/dlee/endpoints/   (props changed)
    team/dlee/endpoints/CHANGES
    team/dlee/endpoints/addons/res_config_mysql.c
    team/dlee/endpoints/apps/app_confbridge.c
    team/dlee/endpoints/apps/app_queue.c
    team/dlee/endpoints/apps/confbridge/conf_config_parser.c
    team/dlee/endpoints/channels/Makefile
    team/dlee/endpoints/channels/chan_sip.c
    team/dlee/endpoints/configure
    team/dlee/endpoints/include/asterisk/autoconfig.h.in
    team/dlee/endpoints/include/asterisk/config.h
    team/dlee/endpoints/include/asterisk/doxygen/commits.h
    team/dlee/endpoints/include/asterisk/sorcery.h
    team/dlee/endpoints/include/asterisk/srv.h
    team/dlee/endpoints/include/asterisk/threadpool.h
    team/dlee/endpoints/include/asterisk/utils.h
    team/dlee/endpoints/main/astobj2.c
    team/dlee/endpoints/main/channel.c
    team/dlee/endpoints/main/config.c
    team/dlee/endpoints/main/features.c
    team/dlee/endpoints/main/loader.c
    team/dlee/endpoints/main/sorcery.c
    team/dlee/endpoints/main/taskprocessor.c
    team/dlee/endpoints/main/threadpool.c
    team/dlee/endpoints/main/uuid.c
    team/dlee/endpoints/res/Makefile
    team/dlee/endpoints/res/res_config_curl.c
    team/dlee/endpoints/res/res_config_ldap.c
    team/dlee/endpoints/res/res_config_odbc.c
    team/dlee/endpoints/res/res_config_pgsql.c
    team/dlee/endpoints/res/res_config_sqlite.c
    team/dlee/endpoints/res/res_config_sqlite3.c
    team/dlee/endpoints/res/res_sorcery_config.c
    team/dlee/endpoints/res/res_stasis.c
    team/dlee/endpoints/res/stasis_http/resource_asterisk.h
    team/dlee/endpoints/res/stasis_http/resource_bridges.h
    team/dlee/endpoints/res/stasis_http/resource_channels.h
    team/dlee/endpoints/res/stasis_http/resource_endpoints.h
    team/dlee/endpoints/res/stasis_http/resource_events.h
    team/dlee/endpoints/res/stasis_http/resource_playback.h
    team/dlee/endpoints/res/stasis_http/resource_recordings.h
    team/dlee/endpoints/res/stasis_http/resource_sounds.h
    team/dlee/endpoints/rest-api-templates/stasis_http_resource.h.mustache
    team/dlee/endpoints/rest-api-templates/swagger_model.py
    team/dlee/endpoints/sounds/Makefile
    team/dlee/endpoints/tests/test_sorcery.c

Propchange: team/dlee/endpoints/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/dlee/endpoints/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Apr 30 01:02:43 2013
@@ -1,1 +1,1 @@
-/trunk:1-386236
+/trunk:1-386924

Modified: team/dlee/endpoints/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/dlee/endpoints/CHANGES?view=diff&rev=386925&r1=386924&r2=386925
==============================================================================
--- team/dlee/endpoints/CHANGES (original)
+++ team/dlee/endpoints/CHANGES Tue Apr 30 01:02:43 2013
@@ -147,9 +147,17 @@
    If no resources exist or all are unavailable the device state is considered
    to be unavailable.
 
+Sorcery
+------------------
+ * All future modules which utilize Sorcery for object persistence must have a
+   column named "id" within their schema when using the Sorcery realtime module.
+   This column must be able to contain a string of up to 128 characters in length.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 10 to Asterisk 11 --------------------
 ------------------------------------------------------------------------------
+
+
 
 Build System
 -------------------
@@ -294,6 +302,9 @@
    state_interface has been set.
 
  * Add queue monitoring hints.  exten => 8501,hint,Queue:markq.
+
+ * App_queue will now play periodic announcements for the caller that
+   holds the first position in the queue while waiting for answer.
 
 SayUnixTime
 ------------------

Modified: team/dlee/endpoints/addons/res_config_mysql.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/endpoints/addons/res_config_mysql.c?view=diff&rev=386925&r1=386924&r2=386925
==============================================================================
--- team/dlee/endpoints/addons/res_config_mysql.c (original)
+++ team/dlee/endpoints/addons/res_config_mysql.c Tue Apr 30 01:02:43 2013
@@ -316,7 +316,7 @@
 	return orig;
 }
 
-static struct ast_variable *realtime_mysql(const char *database, const char *table, va_list ap)
+static struct ast_variable *realtime_mysql(const char *database, const char *table, const struct ast_variable *rt_fields)
 {
 	struct mysql_conn *dbh;
 	MYSQL_RES *result;
@@ -328,7 +328,7 @@
 	char *stringp;
 	char *chunk;
 	char *op;
-	const char *newparam, *newval;
+	const struct ast_variable *field = rt_fields;
 	struct ast_variable *var=NULL, *prev=NULL;
 
 	if (!(dbh = find_database(database, 0))) {
@@ -343,7 +343,7 @@
 	}
 
 	/* Get the first parameter and first value in our list of passed paramater/value pairs */
-	if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *)))  {
+	if (!field) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
 		release_database(dbh);
 		return NULL;
@@ -358,21 +358,20 @@
 	/* Create the first part of the query using the first parameter/value pairs we just extracted
 	   If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
 
-	if (!strchr(newparam, ' ')) 
+	if (!strchr(field->name, ' ')) 
 		op = " ="; 
 	else 
 		op = "";
 
-	ESCAPE_STRING(buf, newval);
-	ast_str_set(&sql, 0, "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, ast_str_buffer(buf));
-	while ((newparam = va_arg(ap, const char *))) {
-		newval = va_arg(ap, const char *);
-		if (!strchr(newparam, ' ')) 
+	ESCAPE_STRING(buf, field->value);
+	ast_str_set(&sql, 0, "SELECT * FROM %s WHERE %s%s '%s'", table, field->name, op, ast_str_buffer(buf));
+	while ((field = field->next)) {
+		if (!strchr(field->name, ' ')) 
 			op = " ="; 
 		else
 			op = "";
-		ESCAPE_STRING(buf, newval);
-		ast_str_append(&sql, 0, " AND %s%s '%s'", newparam, op, ast_str_buffer(buf));
+		ESCAPE_STRING(buf, field->value);
+		ast_str_append(&sql, 0, " AND %s%s '%s'", field->name, op, ast_str_buffer(buf));
 	}
 
 	ast_debug(1, "MySQL RealTime: Retrieve SQL: %s\n", ast_str_buffer(sql));
@@ -417,7 +416,7 @@
 	return var;
 }
 
-static struct ast_config *realtime_multi_mysql(const char *database, const char *table, va_list ap)
+static struct ast_config *realtime_multi_mysql(const char *database, const char *table, const struct ast_variable *rt_fields)
 {
 	struct mysql_conn *dbh;
 	MYSQL_RES *result;
@@ -430,7 +429,7 @@
 	char *stringp;
 	char *chunk;
 	char *op;
-	const char *newparam, *newval;
+	const struct ast_variable *field = rt_fields;
 	struct ast_variable *var = NULL;
 	struct ast_config *cfg = NULL;
 	struct ast_category *cat = NULL;
@@ -454,14 +453,14 @@
 	}
 
 	/* Get the first parameter and first value in our list of passed paramater/value pairs */
-	if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *)))  {
+	if (!field) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
 		ast_config_destroy(cfg);
 		release_database(dbh);
 		return NULL;
 	}
 
-	initfield = ast_strdupa(newparam);
+	initfield = ast_strdupa(field->name);
 	if ((op = strchr(initfield, ' '))) {
 		*op = '\0';
 	}
@@ -476,18 +475,17 @@
 	/* Create the first part of the query using the first parameter/value pairs we just extracted
 	   If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
 
-	if (!strchr(newparam, ' '))
+	if (!strchr(field->name, ' '))
 		op = " =";
 	else
 		op = "";
 
-	ESCAPE_STRING(buf, newval);
-	ast_str_set(&sql, 0, "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, ast_str_buffer(buf));
-	while ((newparam = va_arg(ap, const char *))) {
-		newval = va_arg(ap, const char *);
-		if (!strchr(newparam, ' ')) op = " ="; else op = "";
-		ESCAPE_STRING(buf, newval);
-		ast_str_append(&sql, 0, " AND %s%s '%s'", newparam, op, ast_str_buffer(buf));
+	ESCAPE_STRING(buf, field->value);
+	ast_str_set(&sql, 0, "SELECT * FROM %s WHERE %s%s '%s'", table, field->name, op, ast_str_buffer(buf));
+	while ((field = field->next)) {
+		if (!strchr(field->name, ' ')) op = " ="; else op = "";
+		ESCAPE_STRING(buf, field->value);
+		ast_str_append(&sql, 0, " AND %s%s '%s'", field->name, op, ast_str_buffer(buf));
 	}
 
 	if (initfield) {
@@ -540,11 +538,11 @@
 	return cfg;
 }
 
-static int update_mysql(const char *database, const char *tablename, const char *keyfield, const char *lookup, va_list ap)
+static int update_mysql(const char *database, const char *tablename, const char *keyfield, const char *lookup, const struct ast_variable *rt_fields)
 {
 	struct mysql_conn *dbh;
 	my_ulonglong numrows;
-	const char *newparam, *newval;
+	const struct ast_variable *field = rt_fields;
 	struct ast_str *sql = ast_str_thread_get(&sql_buf, 100), *buf = ast_str_thread_get(&scratch_buf, 100);
 	struct tables *table;
 	struct columns *column = NULL;
@@ -574,7 +572,7 @@
 	}
 
 	/* Get the first parameter and first value in our list of passed paramater/value pairs */
-	if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *)))  {
+	if (!field) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Realtime update requires at least 1 parameter and 1 value to update.\n");
 		release_table(table);
 		release_database(dbh);
@@ -582,8 +580,8 @@
 	}
 
 	/* Check that the column exists in the table */
-	if (!(column = find_column(table, newparam))) {
-		ast_log(LOG_ERROR, "MySQL RealTime: Updating column '%s', but that column does not exist within the table '%s' (first pair MUST exist)!\n", newparam, tablename);
+	if (!(column = find_column(table, field->name))) {
+		ast_log(LOG_ERROR, "MySQL RealTime: Updating column '%s', but that column does not exist within the table '%s' (first pair MUST exist)!\n", field->name, tablename);
 		release_table(table);
 		release_database(dbh);
 		return -1;
@@ -599,29 +597,27 @@
 	/* Create the first part of the query using the first parameter/value pairs we just extracted
 	   If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
 
-	ESCAPE_STRING(buf, newval);
-	ast_str_set(&sql, 0, "UPDATE %s SET `%s` = '%s'", tablename, newparam, ast_str_buffer(buf));
+	ESCAPE_STRING(buf, field->value);
+	ast_str_set(&sql, 0, "UPDATE %s SET `%s` = '%s'", tablename, field->name, ast_str_buffer(buf));
 
 	/* If the column length isn't long enough, give a chance to lengthen it. */
 	if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) {
-		internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
-	}
-
-	while ((newparam = va_arg(ap, const char *))) {
-		newval = va_arg(ap, const char *);
-
+		internal_require(database, tablename, field->name, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
+	}
+
+	while ((field = field->next)) {
 		/* If the column is not within the table, then skip it */
-		if (!(column = find_column(table, newparam))) {
-			ast_log(LOG_WARNING, "Attempted to update column '%s' in table '%s', but column does not exist!\n", newparam, tablename);
+		if (!(column = find_column(table, field->name))) {
+			ast_log(LOG_WARNING, "Attempted to update column '%s' in table '%s', but column does not exist!\n", field->name, tablename);
 			continue;
 		}
 
-		ESCAPE_STRING(buf, newval);
-		ast_str_append(&sql, 0, ", `%s` = '%s'", newparam, ast_str_buffer(buf));
+		ESCAPE_STRING(buf, field->value);
+		ast_str_append(&sql, 0, ", `%s` = '%s'", field->value, ast_str_buffer(buf));
 
 		/* If the column length isn't long enough, give a chance to lengthen it. */
 		if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) {
-			internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
+			internal_require(database, tablename, field->name, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
 		}
 	}
 
@@ -653,12 +649,12 @@
 	return (int)numrows;
 }
 
-static int update2_mysql(const char *database, const char *tablename, va_list ap)
+static int update2_mysql(const char *database, const char *tablename, const struct ast_variable *lookup_fields, const struct ast_variable *update_fields)
 {
 	struct mysql_conn *dbh;
 	my_ulonglong numrows;
 	int first;
-	const char *newparam, *newval;
+	const struct ast_variable *field;
 	struct ast_str *sql = ast_str_thread_get(&sql_buf, 100), *buf = ast_str_thread_get(&scratch_buf, 100);
 	struct ast_str *where = ast_str_thread_get(&sql2_buf, 100);
 	struct tables *table;
@@ -697,51 +693,38 @@
 	}
 
 	first = 1;
-	while ((newparam = va_arg(ap, const char *))) {
-		if (!(column = find_column(table, newparam))) {
-			ast_log(LOG_ERROR, "Updating on column '%s', but that column does not exist within the table '%s'!\n", newparam, tablename);
+	for (field = lookup_fields; field; field = field->next) {
+		if (!(column = find_column(table, field->name))) {
+			ast_log(LOG_ERROR, "Updating on column '%s', but that column does not exist within the table '%s'!\n", field->name, tablename);
 			release_table(table);
 			release_database(dbh);
 			return -1;
 		}
-		if (!(newval = va_arg(ap, const char *))) {
-			ast_log(LOG_ERROR, "Invalid arguments: no value specified for column '%s' on '%s@%s'\n", newparam, tablename, database);
-			release_table(table);
-			release_database(dbh);
-			return -1;
-		}
-		ESCAPE_STRING(buf, newval);
-		ast_str_append(&where, 0, "%s `%s` = '%s'", first ? "" : " AND", newparam, ast_str_buffer(buf));
+		ESCAPE_STRING(buf, field->value);
+		ast_str_append(&where, 0, "%s `%s` = '%s'", first ? "" : " AND", field->name, ast_str_buffer(buf));
 		first = 0;
 
 		/* If the column length isn't long enough, give a chance to lengthen it. */
 		if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) {
-			internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
+			internal_require(database, tablename, field->name, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
 		}
 	}
 
 	first = 1;
-	while ((newparam = va_arg(ap, const char *))) {
-		if (!(newval = va_arg(ap, const char *))) {
-			ast_log(LOG_ERROR, "Invalid arguments: no value specified for column '%s' on '%s@%s'\n", newparam, tablename, database);
-			release_table(table);
-			release_database(dbh);
-			return -1;
-		}
-
+	for (field = update_fields; field; field = field->next) {
 		/* If the column is not within the table, then skip it */
-		if (!(column = find_column(table, newparam))) {
-			ast_log(LOG_WARNING, "Attempted to update column '%s' in table '%s', but column does not exist!\n", newparam, tablename);
+		if (!(column = find_column(table, field->name))) {
+			ast_log(LOG_WARNING, "Attempted to update column '%s' in table '%s', but column does not exist!\n", field->name, tablename);
 			continue;
 		}
 
-		ESCAPE_STRING(buf, newval);
-		ast_str_append(&sql, 0, "%s `%s` = '%s'", first ? "" : ",", newparam, ast_str_buffer(buf));
+		ESCAPE_STRING(buf, field->value);
+		ast_str_append(&sql, 0, "%s `%s` = '%s'", first ? "" : ",", field->name, ast_str_buffer(buf));
 		first = 0;
 
 		/* If the column length isn't long enough, give a chance to lengthen it. */
 		if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) {
-			internal_require(database, tablename, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
+			internal_require(database, tablename, field->name, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
 		}
 	}
 
@@ -773,14 +756,14 @@
 	return (int)numrows;
 }
  
-static int store_mysql(const char *database, const char *table, va_list ap)
+static int store_mysql(const char *database, const char *table, const struct ast_variable *rt_fields)
 {
 	struct mysql_conn *dbh;
 	my_ulonglong insertid;
 	struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
 	struct ast_str *sql2 = ast_str_thread_get(&sql2_buf, 16);
 	struct ast_str *buf = ast_str_thread_get(&scratch_buf, 16);
-	const char *newparam, *newval;
+	const struct ast_variable *field = rt_fields;
 
 	if (!(dbh = find_database(database, 1))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: '%s' (check res_mysql.conf)\n", database);
@@ -793,7 +776,7 @@
 		return -1;
 	}
 	/* Get the first parameter and first value in our list of passed paramater/value pairs */
-	if (!(newparam = va_arg(ap, const char *)) || !(newval = va_arg(ap, const char *))) {
+	if (!field) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Realtime storage requires at least 1 parameter and 1 value to search on.\n");
 		release_database(dbh);
 		return -1;
@@ -805,20 +788,17 @@
 	}
 	/* Create the first part of the query using the first parameter/value pairs we just extracted
 		If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
-	ESCAPE_STRING(buf, newval);
-	ast_str_set(&sql, 0, "INSERT INTO %s (`%s`", table, newparam);
+	ESCAPE_STRING(buf, field->value);
+	ast_str_set(&sql, 0, "INSERT INTO %s (`%s`", table, field->name);
 	ast_str_set(&sql2, 0, ") VALUES ('%s'", ast_str_buffer(buf));
 
-	internal_require(database, table, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
-
-	while ((newparam = va_arg(ap, const char *))) {
-		if ((newval = va_arg(ap, const char *))) {
-			ESCAPE_STRING(buf, newval);
-		} else {
-			ast_str_reset(buf);
-		}
-		if (internal_require(database, table, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL) == 0) {
-			ast_str_append(&sql, 0, ", `%s`", newparam);
+	internal_require(database, table, field->name, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
+
+	while ((field = field->next)) {
+		ESCAPE_STRING(buf, field->value);
+
+		if (internal_require(database, table, field->name, RQ_CHAR, ast_str_strlen(buf), SENTINEL) == 0) {
+			ast_str_append(&sql, 0, ", `%s`", field->name);
 			ast_str_append(&sql2, 0, ", '%s'", ast_str_buffer(buf));
 		}
 	}
@@ -846,13 +826,13 @@
 	return (int)insertid;
 }
 
-static int destroy_mysql(const char *database, const char *table, const char *keyfield, const char *lookup, va_list ap)
+static int destroy_mysql(const char *database, const char *table, const char *keyfield, const char *lookup, const struct ast_variable *rt_fields)
 {
 	struct mysql_conn *dbh;
 	my_ulonglong numrows;
 	struct ast_str *sql = ast_str_thread_get(&sql_buf, 16);
 	struct ast_str *buf = ast_str_thread_get(&scratch_buf, 16);
-	const char *newparam, *newval;
+	const struct ast_variable *field;
 
 	if (!(dbh = find_database(database, 1))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Invalid database specified: '%s' (check res_mysql.conf)\n", database);
@@ -884,10 +864,9 @@
 	   If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
 	ESCAPE_STRING(buf, lookup);
 	ast_str_set(&sql, 0, "DELETE FROM %s WHERE `%s` = '%s'", table, keyfield, ast_str_buffer(buf));
-	while ((newparam = va_arg(ap, const char *))) {
-		newval = va_arg(ap, const char *);
-		ESCAPE_STRING(buf, newval);
-		ast_str_append(&sql, 0, " AND `%s` = '%s'", newparam, ast_str_buffer(buf));
+	for (field = rt_fields; field; field = field->next) {
+		ESCAPE_STRING(buf, field->value);
+		ast_str_append(&sql, 0, " AND `%s` = '%s'", field->name, ast_str_buffer(buf));
 	}
 
 	ast_debug(1, "MySQL RealTime: Delete SQL: %s\n", ast_str_buffer(sql));

Modified: team/dlee/endpoints/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/endpoints/apps/app_confbridge.c?view=diff&rev=386925&r1=386924&r2=386925
==============================================================================
--- team/dlee/endpoints/apps/app_confbridge.c (original)
+++ team/dlee/endpoints/apps/app_confbridge.c Tue Apr 30 01:02:43 2013
@@ -317,14 +317,47 @@
 static int conference_bridge_hash_cb(const void *obj, const int flags)
 {
 	const struct confbridge_conference *conference = obj;
-	return ast_str_case_hash(conference->name);
+	const char *name = obj;
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = conference->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
 }
 
 /*! \brief Comparison function used for conference bridges container */
 static int conference_bridge_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct confbridge_conference *conference0 = obj, *conference1 = arg;
-	return (!strcasecmp(conference0->name, conference1->name) ? CMP_MATCH | CMP_STOP : 0);
+	const struct confbridge_conference *left = obj;
+	const struct confbridge_conference *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
 }
 
 const char *conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
@@ -1233,12 +1266,9 @@
  */
 static struct confbridge_conference *join_conference_bridge(const char *conference_name, struct confbridge_user *user)
 {
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	struct post_join_action *action;
-	struct confbridge_conference tmp;
 	int max_members_reached = 0;
-
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
 
 	/* We explictly lock the conference bridges container ourselves so that other callers can not create duplicate conferences at the same */
 	ao2_lock(conference_bridges);
@@ -1246,8 +1276,7 @@
 	ast_debug(1, "Trying to find conference bridge '%s'\n", conference_name);
 
 	/* Attempt to find an existing conference bridge */
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
-
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (conference && conference->b_profile.max_members) {
 		max_members_reached = conference->b_profile.max_members > conference->activeusers ? 0 : 1;
 	}
@@ -2225,7 +2254,7 @@
 static char *complete_confbridge_name(const char *line, const char *word, int pos, int state)
 {
 	int which = 0;
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	char *res = NULL;
 	int wordlen = strlen(word);
 	struct ao2_iterator iter;
@@ -2244,17 +2273,15 @@
 	return res;
 }
 
-static char *complete_confbridge_participant(const char *bridge_name, const char *line, const char *word, int pos, int state)
+static char *complete_confbridge_participant(const char *conference_name, const char *line, const char *word, int pos, int state)
 {
 	int which = 0;
 	RAII_VAR(struct confbridge_conference *, conference, NULL, ao2_cleanup);
-	struct confbridge_conference tmp;
 	struct confbridge_user *user;
 	char *res = NULL;
 	int wordlen = strlen(word);
 
-	ast_copy_string(tmp.name, bridge_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return NULL;
 	}
@@ -2280,8 +2307,7 @@
 
 static char *handle_cli_confbridge_kick(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -2304,8 +2330,7 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[2], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 		return CLI_SUCCESS;
@@ -2395,10 +2420,8 @@
 
 	if (a->argc == 3) {
 		struct confbridge_user *user;
-		struct confbridge_conference tmp;
-
-		ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
-		conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+
+		conference = ao2_find(conference_bridges, a->argv[2], OBJ_KEY);
 		if (!conference) {
 			ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 			return CLI_SUCCESS;
@@ -2428,12 +2451,10 @@
  */
 static int generic_lock_unlock_helper(int lock, const char *conference_name)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int res = 0;
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return -1;
 	}
@@ -2455,12 +2476,11 @@
  */
 static int generic_mute_unmute_helper(int mute, const char *conference_name, const char *chan_name)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
-	struct confbridge_user *user = NULL;
+	struct confbridge_conference *conference;
+	struct confbridge_user *user;
 	int res = 0;
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return -1;
 	}
@@ -2607,8 +2627,7 @@
 static char *handle_cli_confbridge_start_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	const char *rec_file = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -2633,8 +2652,7 @@
 		rec_file = a->argv[4];
 	}
 
-	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[3], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "Conference not found.\n");
 		return CLI_FAILURE;
@@ -2665,8 +2683,7 @@
 
 static char *handle_cli_confbridge_stop_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int ret;
 
 	switch (cmd) {
@@ -2686,8 +2703,7 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[3], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "Conference not found.\n");
 		return CLI_SUCCESS;
@@ -2754,7 +2770,6 @@
 	const char *conference_name = astman_get_header(m, "Conference");
 	struct confbridge_user *user;
 	struct confbridge_conference *conference;
-	struct confbridge_conference tmp;
 	char id_text[80];
 	int total = 0;
 
@@ -2770,8 +2785,7 @@
 		astman_send_error(s, m, "No active conferences.");
 		return 0;
 	}
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -2804,7 +2818,7 @@
 static int action_confbridgelistrooms(struct mansession *s, const struct message *m)
 {
 	const char *actionid = astman_get_header(m, "ActionID");
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	struct ao2_iterator iter;
 	char id_text[512] = "";
 	int totalitems = 0;
@@ -2930,8 +2944,7 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *channel = astman_get_header(m, "Channel");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int found = 0;
 
 	if (ast_strlen_zero(conference_name)) {
@@ -2943,8 +2956,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -2965,8 +2977,7 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *recordfile = astman_get_header(m, "RecordFile");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -2977,8 +2988,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3011,8 +3021,7 @@
 static int action_confbridgestoprecord(struct mansession *s, const struct message *m)
 {
 	const char *conference_name = astman_get_header(m, "Conference");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -3023,8 +3032,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3048,9 +3056,8 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *channel = astman_get_header(m, "Channel");
-	struct confbridge_user *user = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_user *user;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -3065,8 +3072,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3095,10 +3101,9 @@
 
 static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
-	char *parse = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_user *user = NULL;
-	struct confbridge_conference tmp;
+	char *parse;
+	struct confbridge_conference *conference;
+	struct confbridge_user *user;
 	int count = 0;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(type);
@@ -3114,12 +3119,7 @@
 	if (ast_strlen_zero(args.confno) || ast_strlen_zero(args.type)) {
 		return -1;
 	}
-	if (!ao2_container_count(conference_bridges)) {
-		snprintf(buf, len, "0");
-		return 0;
-	}
-	ast_copy_string(tmp.name, args.confno, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, args.confno, OBJ_KEY);
 	if (!conference) {
 		snprintf(buf, len, "0");
 		return 0;
@@ -3210,33 +3210,34 @@
 /*! \brief Called when module is being unloaded */
 static int unload_module(void)
 {
-	int res = ast_unregister_application(app);
+	ast_unregister_application(app);
 
 	ast_custom_function_unregister(&confbridge_function);
 	ast_custom_function_unregister(&confbridge_info_function);
 
-	ast_cli_unregister_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+	ast_cli_unregister_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));
+
+	ast_manager_unregister("ConfbridgeList");
+	ast_manager_unregister("ConfbridgeListRooms");
+	ast_manager_unregister("ConfbridgeMute");
+	ast_manager_unregister("ConfbridgeUnmute");
+	ast_manager_unregister("ConfbridgeKick");
+	ast_manager_unregister("ConfbridgeUnlock");
+	ast_manager_unregister("ConfbridgeLock");
+	ast_manager_unregister("ConfbridgeStartRecord");
+	ast_manager_unregister("ConfbridgeStopRecord");
+	ast_manager_unregister("ConfbridgeSetSingleVideoSrc");
 
 	/* Get rid of the conference bridges container. Since we only allow dynamic ones none will be active. */
-	ao2_ref(conference_bridges, -1);
+	ao2_cleanup(conference_bridges);
+	conference_bridges = NULL;
 
 	conf_destroy_config();
 
 	ast_channel_unregister(&record_tech);
 	record_tech.capabilities = ast_format_cap_destroy(record_tech.capabilities);
 
-	res |= ast_manager_unregister("ConfbridgeList");
-	res |= ast_manager_unregister("ConfbridgeListRooms");
-	res |= ast_manager_unregister("ConfbridgeMute");
-	res |= ast_manager_unregister("ConfbridgeUnmute");
-	res |= ast_manager_unregister("ConfbridgeKick");
-	res |= ast_manager_unregister("ConfbridgeUnlock");
-	res |= ast_manager_unregister("ConfbridgeLock");
-	res |= ast_manager_unregister("ConfbridgeStartRecord");
-	res |= ast_manager_unregister("ConfbridgeStopRecord");
-	res |= ast_manager_unregister("ConfbridgeSetSingleVideoSrc");
-
-	return res;
+	return 0;
 }
 
 /*!
@@ -3257,30 +3258,33 @@
 		ast_log(LOG_ERROR, "Unable to load config. Not loading module.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if ((ast_custom_function_register(&confbridge_function))) {
-		return AST_MODULE_LOAD_FAILURE;
-	}
-	if ((ast_custom_function_register(&confbridge_info_function))) {
-		return AST_MODULE_LOAD_FAILURE;
-	}
+
 	if (!(record_tech.capabilities = ast_format_cap_alloc())) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all(record_tech.capabilities);
 	if (ast_channel_register(&record_tech)) {
 		ast_log(LOG_ERROR, "Unable to register ConfBridge recorder.\n");
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
+
 	/* Create a container to hold the conference bridges */
-	if (!(conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS, conference_bridge_hash_cb, conference_bridge_cmp_cb))) {
+	conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS,
+		conference_bridge_hash_cb, conference_bridge_cmp_cb);
+	if (!conference_bridges) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	if (ast_register_application_xml(app, confbridge_exec)) {
-		ao2_ref(conference_bridges, -1);
-		return AST_MODULE_LOAD_FAILURE;
-	}
-
-	res |= ast_cli_register_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+
+	res |= ast_register_application_xml(app, confbridge_exec);
+
+	res |= ast_custom_function_register(&confbridge_function);
+	res |= ast_custom_function_register(&confbridge_info_function);
+
+	res |= ast_cli_register_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));
+
 	res |= ast_manager_register_xml("ConfbridgeList", EVENT_FLAG_REPORTING, action_confbridgelist);
 	res |= ast_manager_register_xml("ConfbridgeListRooms", EVENT_FLAG_REPORTING, action_confbridgelistrooms);

[... 4125 lines stripped ...]



More information about the asterisk-commits mailing list