[svn-commits] twilson: branch group/manager_http_auth r164411 - in /team/group/manager_http...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Dec 15 12:51:58 CST 2008


Author: twilson
Date: Mon Dec 15 12:51:57 2008
New Revision: 164411

URL: http://svn.digium.com/view/asterisk?view=rev&rev=164411
Log:
Fix ast_str breakage and svnmerge/automerge, etc.
Merged revisions 163991,164028,164054,164083,164137,164168,164202-164203,164205,164208,164257,164268,164270,164272,164309,164312,164344,164349 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r163991 | tilghman | 2008-12-13 02:36:35 -0600 (Sat, 13 Dec 2008) | 1 line
  
  Merge ast_str_opaque branch (discontinue usage of ast_str internals)
................
  r164028 | mvanbaak | 2008-12-13 07:26:13 -0600 (Sat, 13 Dec 2008) | 2 lines
  
  nuke another use of the ast_str internals.
................
  r164054 | seanbright | 2008-12-13 12:25:58 -0600 (Sat, 13 Dec 2008) | 1 line
  
  Use ast_str_strlen() instead of recalculating the string length.
................
  r164083 | tilghman | 2008-12-13 17:24:09 -0600 (Sat, 13 Dec 2008) | 15 lines
  
  Blocked revisions 164082 via svnmerge
  
  ........
    r164082 | tilghman | 2008-12-13 17:22:02 -0600 (Sat, 13 Dec 2008) | 9 lines
    
    Change the default calldurationlimit from the special value 0 to -1, so we
    can better detect an exceptional case.  This follows on to the changes made
    in revision 156386.  Related to issue #13851.
    (closes issue #13974)
     Reported by: paradise
     Patches: 
           20081208__bug13974.diff.txt uploaded by Corydon76 (license 14)
     Tested by: file, blitzrage, ZX81
  ........
................
  r164137 | seanbright | 2008-12-14 09:26:37 -0600 (Sun, 14 Dec 2008) | 1 line
  
  Use a \picture instead of ASCII art.
................
  r164168 | tilghman | 2008-12-14 12:16:28 -0600 (Sun, 14 Dec 2008) | 2 lines
  
  Don't pass a negative to an unsigned type and expect things to work correctly.
................
  r164202 | russell | 2008-12-15 08:40:08 -0600 (Mon, 15 Dec 2008) | 2 lines
  
  Fix build WRT ast_str_opaque
................
  r164203 | russell | 2008-12-15 08:40:24 -0600 (Mon, 15 Dec 2008) | 39 lines
  
  Merged revisions 164201 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
  r164201 | russell | 2008-12-15 08:31:37 -0600 (Mon, 15 Dec 2008) | 31 lines
  
  Handle a case where a call can be bridged to a channel that is still ringing.
  
  The issue that was reported was about a case where a RINGING channel got 
  redirected to an extension to pick up a call from parking.  Once the parked 
  call got taken out of parking, it heard silence until the other side answered.  
  Ideally, the caller that was parked would get a ringing indication.  This patch
  fixes this case so that the caller receives ringback once it comes out of 
  parking until the other side answers.
  
  The fixes are:
  
   - Make sure we remember that a channel was an outgoing channel when doing 
     a masquerade.  This prevents an erroneous ast_answer() call on the channel,
     which causes a bogus 200 OK to be sent in the case of SIP.
  
   - Add some additional comments to explain related parts of code.
  
   - Update the handling of the ast_channel visible_indication field.  Storing 
     values that are not stateful is pointless.  Control frames that are events 
     or commands should be ignored.
  
   - When a bridge first starts, check to see if the peer channel needs to be 
     given ringing indication because the calling side is still ringing.
  
   - Rework ast_indicate_data() a bit for the sake of readability.
  
  (closes issue #13747)
  Reported by: davidw
  Tested by: russell
  Review: http://reviewboard.digium.com/r/90/
  
  ........
................
  r164205 | file | 2008-12-15 09:06:38 -0600 (Mon, 15 Dec 2008) | 10 lines
  
  Blocked revisions 164204 via svnmerge
  
  ........
    r164204 | file | 2008-12-15 11:05:08 -0400 (Mon, 15 Dec 2008) | 4 lines
    
    Can we try not to assign an unsigned int to -1?
    (closes issue #14074)
    Reported by: wetwired
  ........
................
  r164208 | file | 2008-12-15 09:21:23 -0600 (Mon, 15 Dec 2008) | 2 lines
  
  Update to work with new ast_str changes.
................
  r164257 | file | 2008-12-15 09:41:22 -0600 (Mon, 15 Dec 2008) | 4 lines
  
  Make app_fax compatible with newer versions of spandsp. This remains backwards compatible with earlier versions though so do not fret.
  (closes issue #14073)
  Reported by: seandarcy
................
  r164268 | mmichelson | 2008-12-15 10:10:43 -0600 (Mon, 15 Dec 2008) | 17 lines
  
  Fix up a few issues with regards to queues
  
  * Fix reference counting used in the __queues_show function
  * Add code to be sure that the "queue show" command does not
    print information for a realtime queue which has been deleted
    from the backend
  * Add a missing unref to the realtime queue loading function for
    the case where a queue is in the module's container but has been
    deleted from the realtime backend
  
  (closes issue #14033)
  Reported by: cristiandimache
  Patches:
        14033.patch uploaded by putnopvut (license 60)
  Tested by: cristiandimache
................
  r164270 | mmichelson | 2008-12-15 10:16:47 -0600 (Mon, 15 Dec 2008) | 4 lines
  
  Fix a compile warning and a logic error that could have been bad
  for non-realtime queues
................
  r164272 | russell | 2008-12-15 10:17:55 -0600 (Mon, 15 Dec 2008) | 8 lines
  
  When a reload is issued, always process the configuration for dundi.conf.
  
  The reason is that a reload can be used to refresh DNS lookups for defined peers.
  Even if the config file hasn't changed, we want to process it for that purpose.
  
  (closes issue #13776)
  Reported by: kombjuder
................
  r164309 | russell | 2008-12-15 11:21:38 -0600 (Mon, 15 Dec 2008) | 2 lines
  
  Fix a couple more build issues related to ast_str_opaque
................
  r164312 | file | 2008-12-15 11:24:28 -0600 (Mon, 15 Dec 2008) | 4 lines
  
  Use ast_seekstream to return the file stream back to the beginning instead of directly seeking to zero. This is because some audio formats have headers at the front that need to be skipped, which will be done by the format module.
  (closes issue #14079)
  Reported by: elguero
................
  r164344 | file | 2008-12-15 11:46:32 -0600 (Mon, 15 Dec 2008) | 10 lines
  
  Blocked revisions 164343 via svnmerge
  
  ........
    r164343 | file | 2008-12-15 13:43:59 -0400 (Mon, 15 Dec 2008) | 4 lines
    
    Use autoconf logic to determine whether the system has timersub or not. Do not blindly assume Solaris does not.
    (closes issue #13838)
    Reported by: ano
  ........
................
  r164349 | tilghman | 2008-12-15 12:09:58 -0600 (Mon, 15 Dec 2008) | 4 lines
  
  When querying for the structure of the CDR table, remove the schema, if it
  exists.
  (Closes issue #14058)
................

Added:
    team/group/manager_http_auth/main/strings.c
      - copied unchanged from r164349, trunk/main/strings.c
Modified:
    team/group/manager_http_auth/   (props changed)
    team/group/manager_http_auth/apps/app_chanisavail.c
    team/group/manager_http_auth/apps/app_dumpchan.c
    team/group/manager_http_auth/apps/app_externalivr.c
    team/group/manager_http_auth/apps/app_fax.c
    team/group/manager_http_auth/apps/app_followme.c
    team/group/manager_http_auth/apps/app_jack.c
    team/group/manager_http_auth/apps/app_meetme.c
    team/group/manager_http_auth/apps/app_queue.c
    team/group/manager_http_auth/apps/app_voicemail.c
    team/group/manager_http_auth/cdr/cdr_adaptive_odbc.c
    team/group/manager_http_auth/cdr/cdr_manager.c
    team/group/manager_http_auth/cdr/cdr_pgsql.c
    team/group/manager_http_auth/cdr/cdr_sqlite3_custom.c
    team/group/manager_http_auth/channels/chan_dahdi.c
    team/group/manager_http_auth/channels/chan_sip.c
    team/group/manager_http_auth/channels/h323/ast_h323.cxx
    team/group/manager_http_auth/channels/iax2-parser.c
    team/group/manager_http_auth/configure
    team/group/manager_http_auth/configure.ac
    team/group/manager_http_auth/doc/tex/cdrdriver.tex
    team/group/manager_http_auth/funcs/func_curl.c
    team/group/manager_http_auth/funcs/func_odbc.c
    team/group/manager_http_auth/funcs/func_realtime.c
    team/group/manager_http_auth/funcs/func_strings.c
    team/group/manager_http_auth/include/asterisk/app.h
    team/group/manager_http_auth/include/asterisk/autoconfig.h.in
    team/group/manager_http_auth/include/asterisk/cdr.h
    team/group/manager_http_auth/include/asterisk/pbx.h
    team/group/manager_http_auth/include/asterisk/strings.h
    team/group/manager_http_auth/include/asterisk/tcptls.h
    team/group/manager_http_auth/include/asterisk/threadstorage.h
    team/group/manager_http_auth/main/Makefile
    team/group/manager_http_auth/main/app.c
    team/group/manager_http_auth/main/asterisk.c
    team/group/manager_http_auth/main/cdr.c
    team/group/manager_http_auth/main/channel.c
    team/group/manager_http_auth/main/cli.c
    team/group/manager_http_auth/main/config.c
    team/group/manager_http_auth/main/features.c
    team/group/manager_http_auth/main/file.c
    team/group/manager_http_auth/main/http.c
    team/group/manager_http_auth/main/logger.c
    team/group/manager_http_auth/main/manager.c
    team/group/manager_http_auth/main/pbx.c
    team/group/manager_http_auth/main/tcptls.c
    team/group/manager_http_auth/main/translate.c
    team/group/manager_http_auth/main/utils.c
    team/group/manager_http_auth/main/xmldoc.c
    team/group/manager_http_auth/pbx/pbx_dundi.c
    team/group/manager_http_auth/res/res_agi.c
    team/group/manager_http_auth/res/res_clialiases.c
    team/group/manager_http_auth/res/res_config_curl.c
    team/group/manager_http_auth/res/res_config_ldap.c
    team/group/manager_http_auth/res/res_config_odbc.c
    team/group/manager_http_auth/res/res_config_pgsql.c
    team/group/manager_http_auth/res/res_config_sqlite.c
    team/group/manager_http_auth/res/res_http_post.c
    team/group/manager_http_auth/res/snmp/agent.c
    team/group/manager_http_auth/utils/Makefile
    team/group/manager_http_auth/utils/check_expr.c
    team/group/manager_http_auth/utils/hashtest.c
    team/group/manager_http_auth/utils/hashtest2.c
    team/group/manager_http_auth/utils/refcounter.c

Propchange: team/group/manager_http_auth/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/manager_http_auth/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/group/manager_http_auth/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/manager_http_auth/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Dec 15 12:51:57 2008
@@ -1,1 +1,1 @@
-/trunk:1-163961
+/trunk:1-164349

Modified: team/group/manager_http_auth/apps/app_chanisavail.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_chanisavail.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_chanisavail.c (original)
+++ team/group/manager_http_auth/apps/app_chanisavail.c Mon Dec 15 12:51:57 2008
@@ -160,13 +160,13 @@
 				status = inuse = ast_device_state(trychan);
 			}
 			if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) {
-					ast_str_append(&tmp_availchan, 0, "%s%s", tmp_availchan->used ? "&" : "", tempchan->name);
+					ast_str_append(&tmp_availchan, 0, "%s%s", ast_str_strlen(tmp_availchan) ? "&" : "", tempchan->name);
 					
 					snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);
-					ast_str_append(&tmp_availorig, 0, "%s%s", tmp_availorig->used ? "&" : "", tmp);
+					ast_str_append(&tmp_availorig, 0, "%s%s", ast_str_strlen(tmp_availorig) ? "&" : "", tmp);
 
 					snprintf(tmp, sizeof(tmp), "%d", status);
-					ast_str_append(&tmp_availstat, 0, "%s%s", tmp_availstat->used ? "&" : "", tmp);
+					ast_str_append(&tmp_availstat, 0, "%s%s", ast_str_strlen(tmp_availstat) ? "&" : "", tmp);
 
 					ast_hangup(tempchan);
 					tempchan = NULL;
@@ -176,16 +176,16 @@
 					}
 			} else {
 				snprintf(tmp, sizeof(tmp), "%d", status);
-				ast_str_append(&tmp_availstat, 0, "%s%s", tmp_availstat->used ? "&" : "", tmp);
+				ast_str_append(&tmp_availstat, 0, "%s%s", ast_str_strlen(tmp_availstat) ? "&" : "", tmp);
 			}
 			cur = rest;
 		} while (cur);
 	}
 
-	pbx_builtin_setvar_helper(chan, "AVAILCHAN", tmp_availchan->str);
+	pbx_builtin_setvar_helper(chan, "AVAILCHAN", ast_str_buffer(tmp_availchan));
 	/* Store the originally used channel too */
-	pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", tmp_availorig->str);
-	pbx_builtin_setvar_helper(chan, "AVAILSTATUS", tmp_availstat->str);
+	pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", ast_str_buffer(tmp_availorig));
+	pbx_builtin_setvar_helper(chan, "AVAILSTATUS", ast_str_buffer(tmp_availstat));
 
 	return 0;
 }

Modified: team/group/manager_http_auth/apps/app_dumpchan.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_dumpchan.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_dumpchan.c (original)
+++ team/group/manager_http_auth/apps/app_dumpchan.c Mon Dec 15 12:51:57 2008
@@ -35,6 +35,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/channel.h"
+#include "asterisk/app.h"
 
 /*** DOCUMENTATION
 	<application name="DumpChan" language="en_US">
@@ -148,7 +149,7 @@
 
 static int dumpchan_exec(struct ast_channel *chan, void *data)
 {
-	struct ast_str *vars = ast_str_alloca(BUFSIZ * 4); /* XXX very large! */
+	struct ast_str *vars = ast_str_thread_get(&global_app_buf, 16);
 	char info[1024];
 	int level = 0;
 	static char *line = "================================================================================";
@@ -156,10 +157,11 @@
 	if (!ast_strlen_zero(data))
 		level = atoi(data);
 
-	pbx_builtin_serialize_variables(chan, &vars);
-	serialize_showchan(chan, info, sizeof(info));
-	if (option_verbose >= level)
-		ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, vars->str, line);
+	if (option_verbose >= level) {
+		serialize_showchan(chan, info, sizeof(info));
+		pbx_builtin_serialize_variables(chan, &vars);
+		ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n", chan->name, line, info, ast_str_buffer(vars), line);
+	}
 
 	return 0;
 }

Modified: team/group/manager_http_auth/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_externalivr.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_externalivr.c (original)
+++ team/group/manager_http_auth/apps/app_externalivr.c Mon Dec 15 12:51:57 2008
@@ -122,8 +122,8 @@
 		ast_str_append(&tmp, 0, ",%s", data);
 	}
 
-	fprintf(handle, "%s\n", tmp->str);
-	ast_debug(1, "sent '%s'\n", tmp->str);
+	fprintf(handle, "%s\n", ast_str_buffer(tmp));
+	ast_debug(1, "sent '%s'\n", ast_str_buffer(tmp));
 }
 
 static void *gen_alloc(struct ast_channel *chan, void *params)
@@ -276,7 +276,7 @@
 
 		ast_str_append(&newstring, 0, "%s=%s,", variable, value);
 		ast_channel_unlock(chan);
-		ast_copy_string(outbuf, newstring->str, outbuflen);
+		ast_copy_string(outbuf, ast_str_buffer(newstring), outbuflen);
 	}
 }
 
@@ -659,7 +659,8 @@
  				continue;
   
 			if (input[0] == 'P') {
- 				send_eivr_event(eivr_events, 'P', args->str, chan);
+				struct ast_str *tmp = (struct ast_str *) args;
+ 				send_eivr_event(eivr_events, 'P', ast_str_buffer(tmp), chan);
 			} else if ( input[0] == 'T' ) {
 				ast_chan_log(LOG_WARNING, chan, "Answering channel if needed and starting generator\n");
 				if (chan->_state != AST_STATE_UP) {

Modified: team/group/manager_http_auth/apps/app_fax.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_fax.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_fax.c (original)
+++ team/group/manager_http_auth/apps/app_fax.c Mon Dec 15 12:51:57 2008
@@ -29,6 +29,9 @@
 #include <tiffio.h>
 
 #include <spandsp.h>
+#ifdef HAVE_SPANDSP_EXPOSE_H
+#include <spandsp/expose.h>
+#endif
 #include <spandsp/version.h>
 
 #include "asterisk/lock.h"

Modified: team/group/manager_http_auth/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_followme.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_followme.c (original)
+++ team/group/manager_http_auth/apps/app_followme.c Mon Dec 15 12:51:57 2008
@@ -960,9 +960,8 @@
 		}
 		/* This one has to exist; it was part of the query */
 		ordstr = ast_variable_retrieve(cfg, catg, "ordinal");
-		ast_str_make_space(&str, strlen(numstr) + 1);
-		ast_copy_string(str->str, numstr, str->len);
-		if ((cur = create_followme_number(str->str, timeout, atoi(ordstr)))) {
+		ast_str_set(&str, 0, "%s", numstr);
+		if ((cur = create_followme_number(ast_str_buffer(str), timeout, atoi(ordstr)))) {
 			AST_LIST_INSERT_TAIL(&new->numbers, cur, entry);
 		}
 	}

Modified: team/group/manager_http_auth/apps/app_jack.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_jack.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_jack.c (original)
+++ team/group/manager_http_auth/apps/app_jack.c Mon Dec 15 12:51:57 2008
@@ -182,7 +182,7 @@
 			ast_str_append(&str, 0, ", %s", jack_status_to_str((1 << i)));
 	}
 	
-	ast_log(LOG_NOTICE, "%s: %s\n", prefix, str->str);
+	ast_log(LOG_NOTICE, "%s: %s\n", prefix, ast_str_buffer(str));
 }
 
 static int alloc_resampler(struct jack_data *jack_data, int input)

Modified: team/group/manager_http_auth/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_meetme.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_meetme.c (original)
+++ team/group/manager_http_auth/apps/app_meetme.c Mon Dec 15 12:51:57 2008
@@ -1260,7 +1260,7 @@
 			min = ((now - cnf->start) % 3600) / 60;
 			sec = (now - cnf->start) % 60;
 			if (!concise) {
-				ast_cli(a->fd, MC_DATA_FORMAT, cnf->confno, cnf->users, cmdline->str, hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No");
+				ast_cli(a->fd, MC_DATA_FORMAT, cnf->confno, cnf->users, ast_str_buffer(cmdline), hr, min, sec, cnf->isdynamic ? "Dynamic" : "Static", cnf->locked ? "Yes" : "No");
 			} else {
 				ast_cli(a->fd, "%s!%d!%d!%02d:%02d:%02d!%d!%d\n",
 					cnf->confno,
@@ -1345,9 +1345,9 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_debug(1, "Cmdline: %s\n", cmdline->str);
-
-	admin_exec(NULL, cmdline->str);
+	ast_debug(1, "Cmdline: %s\n", ast_str_buffer(cmdline));
+
+	admin_exec(NULL, ast_str_buffer(cmdline));
 	ast_free(cmdline);
 
 	return CLI_SUCCESS;
@@ -1435,9 +1435,9 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_debug(1, "Cmdline: %s\n", cmdline->str);
-
-	admin_exec(NULL, cmdline->str);
+	ast_debug(1, "Cmdline: %s\n", ast_str_buffer(cmdline));
+
+	admin_exec(NULL, ast_str_buffer(cmdline));
 	ast_free(cmdline);
 
 	return CLI_SUCCESS;
@@ -4615,7 +4615,7 @@
 	ast_set_flag(&conf_flags, 
 		CONFFLAG_QUIET | CONFFLAG_MARKEDEXIT | CONFFLAG_PASS_DTMF | CONFFLAG_SLA_STATION);
 	answer_trunk_chan(trunk_ref->chan);
-	conf = build_conf(conf_name->str, "", "", 0, 0, 1, trunk_ref->chan);
+	conf = build_conf(ast_str_buffer(conf_name), "", "", 0, 0, 1, trunk_ref->chan);
 	if (conf) {
 		conf_run(trunk_ref->chan, conf, conf_flags.flags, NULL);
 		dispose_conf(conf);
@@ -4625,7 +4625,7 @@
 	if (ast_atomic_dec_and_test((int *) &trunk_ref->trunk->active_stations) &&
 		trunk_ref->state != SLA_TRUNK_STATE_ONHOLD_BYME) {
 		ast_str_append(&conf_name, 0, ",K");
-		admin_exec(NULL, conf_name->str);
+		admin_exec(NULL, ast_str_buffer(conf_name));
 		trunk_ref->trunk->hold_stations = 0;
 		sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL);
 	}

Modified: team/group/manager_http_auth/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_queue.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_queue.c (original)
+++ team/group/manager_http_auth/apps/app_queue.c Mon Dec 15 12:51:57 2008
@@ -1691,6 +1691,7 @@
 			/* Delete if unused (else will be deleted when last caller leaves). */
 			ao2_unlink(queues, q);
 			ao2_unlock(q);
+			queue_unref(q);
 		}
 		return NULL;
 	}
@@ -2284,7 +2285,7 @@
 /*! \brief convert "\n" to "\nVariable: " ready for manager to use */
 static char *vars2manager(struct ast_channel *chan, char *vars, size_t len)
 {
-	struct ast_str *buf = ast_str_alloca(len + 1);
+	struct ast_str *buf = ast_str_thread_get(&global_app_buf, len + 1);
 	char *tmp;
 
 	if (pbx_builtin_serialize_variables(chan, &buf)) {
@@ -2292,7 +2293,7 @@
 
 		/* convert "\n" to "\nVariable: " */
 		strcpy(vars, "Variable: ");
-		tmp = buf->str;
+		tmp = ast_str_buffer(buf);
 
 		for (i = 0, j = 10; (i < len - 1) && (j < len - 1); i++, j++) {
 			vars[j] = tmp[i];
@@ -2601,12 +2602,12 @@
 	if (qe->parent->randomperiodicannounce) {
 		qe->last_periodic_announce_sound = ((unsigned long) ast_random()) % qe->parent->numperiodicannounce;
 	} else if (qe->last_periodic_announce_sound >= qe->parent->numperiodicannounce || 
-		ast_strlen_zero(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]->str)) {
+		ast_str_strlen(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]) == 0) {
 		qe->last_periodic_announce_sound = 0;
 	}
 	
 	/* play the announcement */
-	res = play_file(qe->chan, qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]->str);
+	res = play_file(qe->chan, ast_str_buffer(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]));
 
 	if ((res > 0 && !valid_exit(qe, res)) || res < 0)
 		res = 0;
@@ -5697,14 +5698,20 @@
 		return CLI_SHOWUSAGE;
 
 	if (argc == 3)	{ /* specific queue */
-		load_realtime_queue(argv[2]);
-	}
-	else if (ast_check_realtime("queues")) {
+		if ((q = load_realtime_queue(argv[2]))) {
+			queue_unref(q);
+		}
+	} else if (ast_check_realtime("queues")) {
+		/* This block is to find any queues which are defined in realtime but
+		 * which have not yet been added to the in-core container
+		 */
 		struct ast_config *cfg = ast_load_realtime_multientry("queues", "name LIKE", "%", SENTINEL);
 		char *queuename;
 		if (cfg) {
 			for (queuename = ast_category_browse(cfg, NULL); !ast_strlen_zero(queuename); queuename = ast_category_browse(cfg, queuename)) {
-				load_realtime_queue(queuename);
+				if ((q = load_realtime_queue(queuename))) {
+					queue_unref(q);
+				}
 			}
 			ast_config_destroy(cfg);
 		}
@@ -5714,8 +5721,20 @@
 	ao2_lock(queues);
 	while ((q = ao2_iterator_next(&queue_iter))) {
 		float sl;
+		struct call_queue *realtime_queue = NULL;
 
 		ao2_lock(q);
+		/* This check is to make sure we don't print information for realtime
+		 * queues which have been deleted from realtime but which have not yet
+		 * been deleted from the in-core container
+		 */
+		if (q->realtime && !(realtime_queue = load_realtime_queue(q->name))) {
+			ao2_unlock(q);
+			queue_unref(q);
+			continue;
+		} else if (q->realtime) {
+			queue_unref(realtime_queue);
+		}
 		if (argc == 3 && strcasecmp(q->name, argv[2])) {
 			ao2_unlock(q);
 			queue_unref(q);
@@ -5734,7 +5753,7 @@
 		ast_str_append(&out, 0, ") in '%s' strategy (%ds holdtime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds",
 			int2strat(q->strategy), q->holdtime, q->weight,
 			q->callscompleted, q->callsabandoned,sl,q->servicelevel);
-		do_print(s, fd, out->str);
+		do_print(s, fd, ast_str_buffer(out));
 		if (!ao2_container_count(q->members))
 			do_print(s, fd, "   No Members");
 		else {
@@ -5759,7 +5778,7 @@
 						mem->calls, (long) (time(NULL) - mem->lastcall));
 				else
 					ast_str_append(&out, 0, " has taken no calls yet");
-				do_print(s, fd, out->str);
+				do_print(s, fd, ast_str_buffer(out));
 				ao2_ref(mem, -1);
 			}
 		}
@@ -5774,19 +5793,11 @@
 				ast_str_set(&out, 0, "      %d. %s (wait: %ld:%2.2ld, prio: %d)",
 					pos++, qe->chan->name, (long) (now - qe->start) / 60,
 					(long) (now - qe->start) % 60, qe->prio);
-				do_print(s, fd, out->str);
+				do_print(s, fd, ast_str_buffer(out));
 			}
 		}
 		do_print(s, fd, "");	/* blank line between entries */
 		ao2_unlock(q);
-		if (q->realtime || argc == 3) {
-			/* If a queue is realtime, then that means we used load_realtime_queue() above
-			 * to get its information. This means we have an extra reference we need to
-			 * remove at this point. If a specific queue was requested, then it also needs
-			 * to be unreffed here even if it is not a realtime queue.
-			 */
-			queue_unref(q);
-		}
 		queue_unref(q); /* Unref the iterator's reference */
 	}
 	ao2_unlock(queues);
@@ -5795,7 +5806,7 @@
 			ast_str_set(&out, 0, "No such queue: %s.", argv[2]);
 		else
 			ast_str_set(&out, 0, "No queues.");
-		do_print(s, fd, out->str);
+		do_print(s, fd, ast_str_buffer(out));
 	}
 	return CLI_SUCCESS;
 }

Modified: team/group/manager_http_auth/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/apps/app_voicemail.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/apps/app_voicemail.c (original)
+++ team/group/manager_http_auth/apps/app_voicemail.c Mon Dec 15 12:51:57 2008
@@ -10196,12 +10196,12 @@
 	AST_LIST_UNLOCK(&zones);
 }
 
-static char *substitute_escapes(const char *value)
-{
-	char *current, *result;
+static const char *substitute_escapes(const char *value)
+{
+	char *current;
 
 	/* Add 16 for fudge factor */
-	struct ast_str *str = ast_str_create(strlen(value) + 16);
+	struct ast_str *str = ast_str_thread_get(&global_app_buf, strlen(value) + 16);
 
 	/* Substitute strings \r, \n, and \t into the appropriate characters */
 	for (current = (char *) value; *current; current++) {
@@ -10235,10 +10235,7 @@
 		}
 	}
 
-	result = ast_strdup(str->str);
-	ast_free(str);
-
-	return result;
+	return ast_str_buffer(str);
 }
 
 static int load_config(int reload)
@@ -10858,13 +10855,13 @@
 			emailsubject = ast_strdup(val);
 		}
 		if ((val = ast_variable_retrieve(cfg, "general", "emailbody"))) {
-			emailbody = substitute_escapes(val);
+			emailbody = ast_strdup(substitute_escapes(val));
 		}
 		if ((val = ast_variable_retrieve(cfg, "general", "pagersubject"))) {
 			pagersubject = ast_strdup(val);
 		}
 		if ((val = ast_variable_retrieve(cfg, "general", "pagerbody"))) {
-			pagerbody = substitute_escapes(val);
+			pagerbody = ast_strdup(substitute_escapes(val));
 		}
 		AST_LIST_UNLOCK(&users);
 		ast_config_destroy(cfg);

Modified: team/group/manager_http_auth/cdr/cdr_adaptive_odbc.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/cdr/cdr_adaptive_odbc.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/cdr/cdr_adaptive_odbc.c (original)
+++ team/group/manager_http_auth/cdr/cdr_adaptive_odbc.c Mon Dec 15 12:51:57 2008
@@ -317,8 +317,8 @@
 #define LENGTHEN_BUF1(size)														\
 			do {																\
 				/* Lengthen buffer, if necessary */								\
-				if (sql->used + size + 1 > sql->len) {                          \
-					if (ast_str_make_space(&sql, ((sql->len + size + 1) / 512 + 1) * 512) != 0) { \
+				if (ast_str_strlen(sql) + size + 1 > ast_str_size(sql)) {       \
+					if (ast_str_make_space(&sql, ((ast_str_size(sql) + size + 1) / 512 + 1) * 512) != 0) { \
 						ast_log(LOG_ERROR, "Unable to allocate sufficient memory.  Insert CDR '%s:%s' failed.\n", tableptr->connection, tableptr->table); \
 						ast_free(sql);											\
 						ast_free(sql2);											\
@@ -330,8 +330,8 @@
 
 #define LENGTHEN_BUF2(size)														\
 			do {																\
-				if (sql2->used + size + 1 > sql2->len) {                        \
-					if (ast_str_make_space(&sql2, ((sql2->len + size + 3) / 512 + 1) * 512) != 0) { \
+				if (ast_str_strlen(sql2) + size + 1 > ast_str_size(sql2)) {     \
+					if (ast_str_make_space(&sql2, ((ast_str_size(sql2) + size + 3) / 512 + 1) * 512) != 0) { \
 						ast_log(LOG_ERROR, "Unable to allocate sufficient memory.  Insert CDR '%s:%s' failed.\n", tableptr->connection, tableptr->table); \
 						ast_free(sql);											\
 						ast_free(sql2);											\
@@ -368,12 +368,13 @@
 	}
 
 	AST_LIST_TRAVERSE(&odbc_tables, tableptr, list) {
+		int first = 1;
 		ast_str_set(&sql, 0, "INSERT INTO %s (", tableptr->table);
 		ast_str_set(&sql2, 0, " VALUES (");
 
 		/* No need to check the connection now; we'll handle any failure in prepare_and_execute */
 		if (!(obj = ast_odbc_request_obj(tableptr->connection, 0))) {
-			ast_log(LOG_WARNING, "cdr_adaptive_odbc: Unable to retrieve database handle for '%s:%s'.  CDR failed: %s\n", tableptr->connection, tableptr->table, sql->str);
+			ast_log(LOG_WARNING, "cdr_adaptive_odbc: Unable to retrieve database handle for '%s:%s'.  CDR failed: %s\n", tableptr->connection, tableptr->table, ast_str_buffer(sql));
 			continue;
 		}
 
@@ -442,11 +443,11 @@
 						}
 					}
 
-					ast_str_append(&sql, 0, "%s,", entry->name);
+					ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 					LENGTHEN_BUF2(strlen(colptr));
 
 					/* Encode value, with escaping */
-					ast_str_append(&sql2, 0, "'");
+					ast_str_append(&sql2, 0, "%s'", first ? "" : ",");
 					for (tmp = colptr; *tmp; tmp++) {
 						if (*tmp == '\'') {
 							ast_str_append(&sql2, 0, "''");
@@ -456,7 +457,7 @@
 							ast_str_append(&sql2, 0, "%c", *tmp);
 						}
 					}
-					ast_str_append(&sql2, 0, "',");
+					ast_str_append(&sql2, 0, "'");
 					break;
 				case SQL_TYPE_DATE:
 					{
@@ -469,16 +470,16 @@
 							(month == 2 && year % 4 == 0 && day > 29) ||
 							(month == 2 && year % 4 != 0 && day > 28)) {
 							ast_log(LOG_WARNING, "CDR variable %s is not a valid date ('%s').\n", entry->name, colptr);
-							break;
+							continue;
 						}
 
 						if (year > 0 && year < 100) {
 							year += 2000;
 						}
 
-						ast_str_append(&sql, 0, "%s,", entry->name);
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(17);
-						ast_str_append(&sql2, 0, "{ d '%04d-%02d-%02d' },", year, month, day);
+						ast_str_append(&sql2, 0, "%s{ d '%04d-%02d-%02d' }", first ? "" : ",", year, month, day);
 					}
 					break;
 				case SQL_TYPE_TIME:
@@ -488,12 +489,12 @@
 
 						if ((count != 2 && count != 3) || hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) {
 							ast_log(LOG_WARNING, "CDR variable %s is not a valid time ('%s').\n", entry->name, colptr);
-							break;
-						}
-
-						ast_str_append(&sql, 0, "%s,", entry->name);
+							continue;
+						}
+
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(15);
-						ast_str_append(&sql2, 0, "{ t '%02d:%02d:%02d' },", hour, minute, second);
+						ast_str_append(&sql2, 0, "%s{ t '%02d:%02d:%02d' }", first ? "" : ",", hour, minute, second);
 					}
 					break;
 				case SQL_TYPE_TIMESTAMP:
@@ -511,16 +512,16 @@
 							(month == 2 && year % 4 != 0 && day > 28) ||
 							hour > 23 || minute > 59 || second > 59 || hour < 0 || minute < 0 || second < 0) {
 							ast_log(LOG_WARNING, "CDR variable %s is not a valid timestamp ('%s').\n", entry->name, colptr);
-							break;
+							continue;
 						}
 
 						if (year > 0 && year < 100) {
 							year += 2000;
 						}
 
-						ast_str_append(&sql, 0, "%s,", entry->name);
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(26);
-						ast_str_append(&sql2, 0, "{ ts '%04d-%02d-%02d %02d:%02d:%02d' },", year, month, day, hour, minute, second);
+						ast_str_append(&sql2, 0, "%s{ ts '%04d-%02d-%02d %02d:%02d:%02d' }", first ? "" : ",", year, month, day, hour, minute, second);
 					}
 					break;
 				case SQL_INTEGER:
@@ -528,12 +529,12 @@
 						int integer = 0;
 						if (sscanf(colptr, "%d", &integer) != 1) {
 							ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
-							break;
-						}
-
-						ast_str_append(&sql, 0, "%s,", entry->name);
+							continue;
+						}
+
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(12);
-						ast_str_append(&sql2, 0, "%d,", integer);
+						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
 					break;
 				case SQL_BIGINT:
@@ -541,12 +542,12 @@
 						long long integer = 0;
 						if (sscanf(colptr, "%lld", &integer) != 1) {
 							ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
-							break;
-						}
-
-						ast_str_append(&sql, 0, "%s,", entry->name);
+							continue;
+						}
+
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(24);
-						ast_str_append(&sql2, 0, "%lld,", integer);
+						ast_str_append(&sql2, 0, "%s%lld", first ? "" : ",", integer);
 					}
 					break;
 				case SQL_SMALLINT:
@@ -554,12 +555,12 @@
 						short integer = 0;
 						if (sscanf(colptr, "%hd", &integer) != 1) {
 							ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
-							break;
-						}
-
-						ast_str_append(&sql, 0, "%s,", entry->name);
+							continue;
+						}
+
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(6);
-						ast_str_append(&sql2, 0, "%d,", integer);
+						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
 					break;
 				case SQL_TINYINT:
@@ -567,12 +568,12 @@
 						char integer = 0;
 						if (sscanf(colptr, "%hhd", &integer) != 1) {
 							ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
-							break;
-						}
-
-						ast_str_append(&sql, 0, "%s,", entry->name);
+							continue;
+						}
+
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(4);
-						ast_str_append(&sql2, 0, "%d,", integer);
+						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
 					break;
 				case SQL_BIT:
@@ -580,14 +581,14 @@
 						char integer = 0;
 						if (sscanf(colptr, "%hhd", &integer) != 1) {
 							ast_log(LOG_WARNING, "CDR variable %s is not an integer.\n", entry->name);
-							break;
+							continue;
 						}
 						if (integer != 0)
 							integer = 1;
 
-						ast_str_append(&sql, 0, "%s,", entry->name);
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(2);
-						ast_str_append(&sql2, 0, "%d,", integer);
+						ast_str_append(&sql2, 0, "%s%d", first ? "" : ",", integer);
 					}
 					break;
 				case SQL_NUMERIC:
@@ -596,12 +597,12 @@
 						double number = 0.0;
 						if (sscanf(colptr, "%lf", &number) != 1) {
 							ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);
-							break;
-						}
-
-						ast_str_append(&sql, 0, "%s,", entry->name);
+							continue;
+						}
+
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(entry->decimals);
-						ast_str_append(&sql2, 0, "%*.*lf,", entry->decimals, entry->radix, number);
+						ast_str_append(&sql2, 0, "%s%*.*lf", first ? "" : ",", entry->decimals, entry->radix, number);
 					}
 					break;
 				case SQL_FLOAT:
@@ -611,35 +612,37 @@
 						double number = 0.0;
 						if (sscanf(colptr, "%lf", &number) != 1) {
 							ast_log(LOG_WARNING, "CDR variable %s is not an numeric type.\n", entry->name);
-							break;
-						}
-
-						ast_str_append(&sql, 0, "%s,", entry->name);
+							continue;
+						}
+
+						ast_str_append(&sql, 0, "%s%s", first ? "" : ",", entry->name);
 						LENGTHEN_BUF2(entry->decimals);
-						ast_str_append(&sql2, 0, "%lf,", number);
+						ast_str_append(&sql2, 0, "%s%lf", first ? "" : ",", number);
 					}
 					break;
 				default:
 					ast_log(LOG_WARNING, "Column type %d (field '%s:%s:%s') is unsupported at this time.\n", entry->type, tableptr->connection, tableptr->table, entry->name);
+					continue;
 				}
+				first = 0;
 			}
 		}
 
 		/* Concatenate the two constructed buffers */
-		LENGTHEN_BUF1(sql2->used);
-		sql->str[sql->used - 1] = ')';
-		sql2->str[sql2->used - 1] = ')';
-		ast_str_append(&sql, 0, "%s", sql2->str);
-
-		ast_verb(11, "[%s]\n", sql->str);
-
-		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, sql->str);
+		LENGTHEN_BUF1(ast_str_strlen(sql2));
+		ast_str_append(&sql, 0, ")");
+		ast_str_append(&sql2, 0, ")");
+		ast_str_append(&sql, 0, "%s", ast_str_buffer(sql2));
+
+		ast_verb(11, "[%s]\n", ast_str_buffer(sql));
+
+		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, ast_str_buffer(sql));
 		if (stmt) {
 			SQLRowCount(stmt, &rows);
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
 		}
 		if (rows == 0) {
-			ast_log(LOG_WARNING, "cdr_adaptive_odbc: Insert failed on '%s:%s'.  CDR failed: %s\n", tableptr->connection, tableptr->table, sql->str);
+			ast_log(LOG_WARNING, "cdr_adaptive_odbc: Insert failed on '%s:%s'.  CDR failed: %s\n", tableptr->connection, tableptr->table, ast_str_buffer(sql));
 		}
 early_release:
 		ast_odbc_release_obj(obj);
@@ -647,11 +650,11 @@
 	AST_RWLIST_UNLOCK(&odbc_tables);
 
 	/* Next time, just allocate buffers that are that big to start with. */
-	if (sql->used > maxsize) {
-		maxsize = sql->used;
-	}
-	if (sql2->used > maxsize2) {
-		maxsize2 = sql2->used;
+	if (ast_str_strlen(sql) > maxsize) {
+		maxsize = ast_str_strlen(sql);
+	}
+	if (ast_str_strlen(sql2) > maxsize2) {
+		maxsize2 = ast_str_strlen(sql2);
 	}
 
 	ast_free(sql);

Modified: team/group/manager_http_auth/cdr/cdr_manager.c
URL: http://svn.digium.com/view/asterisk/team/group/manager_http_auth/cdr/cdr_manager.c?view=diff&rev=164411&r1=164410&r2=164411
==============================================================================
--- team/group/manager_http_auth/cdr/cdr_manager.c (original)
+++ team/group/manager_http_auth/cdr/cdr_manager.c Mon Dec 15 12:51:57 2008
@@ -95,7 +95,7 @@
 			v = ast_variable_browse(cfg, cat);
 			while (v) {
 				if (customfields && !ast_strlen_zero(v->name) && !ast_strlen_zero(v->value)) {
-					if( (customfields->used + strlen(v->value) + strlen(v->name) + 14) < customfields->len) {
+					if ((ast_str_strlen(customfields) + strlen(v->value) + strlen(v->name) + 14) < ast_str_size(customfields)) {
 						ast_str_append(&customfields, -1, "%s: ${CDR(%s)}\r\n", v->value, v->name);
 						ast_log(LOG_NOTICE, "Added mapping %s: ${CDR(%s)}\n", v->value, v->name);
 					} else {
@@ -145,10 +145,10 @@
 
 	buf[0] = 0;
 	/* Custom fields handling */
-	if (customfields != NULL && customfields->used > 0) {
+	if (customfields != NULL && ast_str_strlen(customfields)) {
 		memset(&dummy, 0, sizeof(dummy));
 		dummy.cdr = cdr;
-		pbx_substitute_variables_helper(&dummy, customfields->str, buf, sizeof(buf) - 1);
+		pbx_substitute_variables_helper(&dummy, ast_str_buffer(customfields), buf, sizeof(buf) - 1);
 	}
 
 	manager_event(EVENT_FLAG_CDR, "Cdr",


[... 4750 lines stripped ...]



More information about the svn-commits mailing list