[asterisk-commits] tilghman: branch tilghman/res_odbc_astobj2 r101988 - in /team/tilghman/res_od...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 1 16:36:24 CST 2008


Author: tilghman
Date: Fri Feb  1 16:36:24 2008
New Revision: 101988

URL: http://svn.digium.com/view/asterisk?view=rev&rev=101988
Log:
Merged revisions 101819,101821,101823-101824,101869,101873,101895,101943 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r101819 | russell | 2008-02-01 11:26:31 -0600 (Fri, 01 Feb 2008) | 12 lines

Merged revisions 101818 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r101818 | russell | 2008-02-01 11:23:47 -0600 (Fri, 01 Feb 2008) | 4 lines

Don't overwrite the last character of a line if it's not a newline.  This would
happen if the last line in the file doesn't have a newline.
(pointed out by Qwell)

........

................
r101821 | russell | 2008-02-01 11:28:06 -0600 (Fri, 01 Feb 2008) | 8 lines

Blocked revisions 101820 via svnmerge

........
r101820 | russell | 2008-02-01 11:27:02 -0600 (Fri, 01 Feb 2008) | 1 line

off by one error
........

................
r101823 | qwell | 2008-02-01 11:44:32 -0600 (Fri, 01 Feb 2008) | 3 lines

Move an feof() call to before the fgets().
This would have exited the loop early if you had an authentication file with no newline at the end.

................
r101824 | tilghman | 2008-02-01 12:08:44 -0600 (Fri, 01 Feb 2008) | 2 lines

Clarify the pooling functionality by changing the config file keyword

................
r101869 | qwell | 2008-02-01 12:24:52 -0600 (Fri, 01 Feb 2008) | 1 line

Comparison, not set :)  Thanks mvanbaak.
................
r101873 | tilghman | 2008-02-01 12:45:31 -0600 (Fri, 01 Feb 2008) | 7 lines

Fix multi, when using the LIKE query.
(closes issue #11889)
 Reported by: jmls
 Patches: 
       res_config_curl.patch uploaded by jmls (license 141)
 Tested by: jmls

................
r101895 | tilghman | 2008-02-01 13:44:39 -0600 (Fri, 01 Feb 2008) | 10 lines

Merged revisions 101894 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r101894 | tilghman | 2008-02-01 13:36:12 -0600 (Fri, 01 Feb 2008) | 2 lines

Change detection of getifaddrs to use AST_C_COMPILE_CHECK, backported from trunk (as suggested by kpfleming)

........

................
r101943 | tilghman | 2008-02-01 16:12:55 -0600 (Fri, 01 Feb 2008) | 16 lines

Merged revisions 101942 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r101942 | tilghman | 2008-02-01 15:54:28 -0600 (Fri, 01 Feb 2008) | 8 lines

Fix the VM_DUR variable for forwarded voicemail, and fixed several other bugs
while I'm in the area.
(closes issue #11615)
 Reported by: jamessan
 Patches: 
       20071226__bug11615__2.diff.txt uploaded by Corydon76 (license 14)
 Tested by: Corydon76, jamessan

........

................

Modified:
    team/tilghman/res_odbc_astobj2/   (props changed)
    team/tilghman/res_odbc_astobj2/apps/app_authenticate.c
    team/tilghman/res_odbc_astobj2/apps/app_voicemail.c
    team/tilghman/res_odbc_astobj2/configs/res_odbc.conf.sample
    team/tilghman/res_odbc_astobj2/configure
    team/tilghman/res_odbc_astobj2/configure.ac
    team/tilghman/res_odbc_astobj2/include/asterisk/autoconfig.h.in
    team/tilghman/res_odbc_astobj2/res/res_config_curl.c
    team/tilghman/res_odbc_astobj2/res/res_odbc.c

Propchange: team/tilghman/res_odbc_astobj2/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/tilghman/res_odbc_astobj2/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/tilghman/res_odbc_astobj2/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/tilghman/res_odbc_astobj2/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Feb  1 16:36:24 2008
@@ -1,1 +1,1 @@
-/trunk:1-101814
+/trunk:1-101986

Modified: team/tilghman/res_odbc_astobj2/apps/app_authenticate.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/res_odbc_astobj2/apps/app_authenticate.c?view=diff&rev=101988&r1=101987&r2=101988
==============================================================================
--- team/tilghman/res_odbc_astobj2/apps/app_authenticate.c (original)
+++ team/tilghman/res_odbc_astobj2/apps/app_authenticate.c Fri Feb  1 16:36:24 2008
@@ -148,15 +148,19 @@
 			}
 
 			for (;;) {
-				fgets(buf, sizeof(buf), f);
+				size_t len;
 
 				if (feof(f))
 					break;
 
+				fgets(buf, sizeof(buf), f);
+
 				if (ast_strlen_zero(buf))
 					continue;
 
-				buf[strlen(buf) - 1] = '\0';
+				len = strlen(buf) - 1;
+				if (buf[len - 1] == '\n')
+					buf[len - 1] = '\0';
 
 				if (ast_test_flag(&flags, OPT_MULTIPLE)) {
 					md5secret = buf;

Modified: team/tilghman/res_odbc_astobj2/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/res_odbc_astobj2/apps/app_voicemail.c?view=diff&rev=101988&r1=101987&r2=101988
==============================================================================
--- team/tilghman/res_odbc_astobj2/apps/app_voicemail.c (original)
+++ team/tilghman/res_odbc_astobj2/apps/app_voicemail.c Fri Feb  1 16:36:24 2008
@@ -454,7 +454,7 @@
 #define STORE(a,b,c,d,e,f,g,h,i)
 #define EXISTS(a,b,c,d) (ast_fileexists(c, NULL, d) > 0)
 #define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
-#define COPY(a,b,c,d,e,f,g,h) (copy_file(g,h));
+#define COPY(a,b,c,d,e,f,g,h) (copy_plain_file(g,h));
 #define DELETE(a,b,c) (vm_delete(c))
 #endif
 #endif
@@ -1624,6 +1624,7 @@
 	}
 	rename(stxt, dtxt);
 }
+#endif
 
 static int copy(char *infile, char *outfile)
 {
@@ -1675,7 +1676,7 @@
 #endif
 }
 
-static void copy_file(char *frompath, char *topath)
+static void copy_plain_file(char *frompath, char *topath)
 {
 	char frompath2[PATH_MAX], topath2[PATH_MAX];
 	struct ast_variable *tmp, *var = NULL;
@@ -1716,6 +1717,8 @@
 	copy(frompath2, topath2);
 	ast_variables_destroy(var);
 }
+
+#ifndef IMAP_STORAGE
 /*! \brief
  * A negative return value indicates an error.
  * \note Should always be called with a lock already set on dir.
@@ -2329,7 +2332,7 @@
 		"Cust5",
 		"Deleted",
 	};
-	return (id >= 0 && id < (sizeof(msgs) / sizeof(msgs[0]))) ? msgs[id] : "Unknown";
+	return (id >= 0 && id < (sizeof(msgs) / sizeof(msgs[0]))) ? msgs[id] : "tmp";
 }
 #ifdef IMAP_STORAGE
 static int folder_int(const char *folder)
@@ -4058,9 +4061,26 @@
 			     char *context, signed char record_gain, long *duration, struct vm_state *vms)
 {
 	int cmd = 0;
-	int retries = 0;
+	int retries = 0, prepend_duration = 0, already_recorded = 0;
 	signed char zero_gain = 0;
 	struct ast_flags config_flags = { CONFIG_FLAG_NOCACHE };
+	struct ast_config *msg_cfg;
+	const char *duration_str;
+	char msgfile[PATH_MAX], backup[PATH_MAX];
+	char textfile[PATH_MAX];
+
+	/* Must always populate duration correctly */
+	make_file(msgfile, sizeof(msgfile), curdir, curmsg);
+	strcpy(textfile, msgfile);
+	strcpy(backup, msgfile);
+	strncat(textfile, ".txt", sizeof(textfile) - 1);
+	strncat(backup, "-bak", sizeof(backup) - 1);
+
+	msg_cfg = ast_config_load(textfile, config_flags);
+
+	*duration = 0;
+	if ((duration_str = ast_variable_retrieve(msg_cfg, "message", "duration")))
+		*duration = atoi(duration_str);
 
 	while ((cmd >= 0) && (cmd != 't') && (cmd != '*')) {
 		if (cmd)
@@ -4069,16 +4089,7 @@
 		case '1': 
 			/* prepend a message to the current message, update the metadata and return */
 		{
-			char msgfile[PATH_MAX];
-			char textfile[PATH_MAX];
-			int prepend_duration = 0;
-			struct ast_config *msg_cfg;
-			const char *duration_str;
-
-			make_file(msgfile, sizeof(msgfile), curdir, curmsg);
-			strcpy(textfile, msgfile);
-			strncat(textfile, ".txt", sizeof(textfile) - 1);
-			*duration = 0;
+			prepend_duration = 0;
 
 			/* if we can't read the message metadata, stop now */
 			if (!(msg_cfg = ast_config_load(textfile, config_flags))) {
@@ -4086,32 +4097,33 @@
 				break;
 			}
 
+			/* Back up the original file, so we can retry the prepend */
+			if (already_recorded)
+				ast_filecopy(backup, msgfile, NULL);
+			else
+				ast_filecopy(msgfile, backup, NULL);
+			already_recorded = 1;
+
 			if (record_gain)
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
 
 			cmd = ast_play_and_prepend(chan, NULL, msgfile, 0, vmfmts, &prepend_duration, 1, silencethreshold, maxsilence);
 			if (record_gain)
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
-
-			
-			if ((duration_str = ast_variable_retrieve(msg_cfg, "message", "duration")))
-				*duration = atoi(duration_str);
 
 			if (prepend_duration) {
 				struct ast_category *msg_cat;
 				/* need enough space for a maximum-length message duration */
 				char duration_str[12];
 
-				*duration += prepend_duration;
+				prepend_duration += *duration;
 				msg_cat = ast_category_get(msg_cfg, "message");
-				snprintf(duration_str, sizeof(duration_str), "%ld", *duration);
+				snprintf(duration_str, sizeof(duration_str), "%d", prepend_duration);
 				if (!ast_variable_update(msg_cat, "duration", duration_str, NULL, 0)) {
 					config_text_file_save(textfile, msg_cfg, "app_voicemail");
-					STORE(curdir, vmu->mailbox, context, curmsg, chan, vmu, vmfmts, *duration, vms);
+					STORE(curdir, vmu->mailbox, context, curmsg, chan, vmu, vmfmts, prepend_duration, vms);
 				}
 			}
-
-			ast_config_destroy(msg_cfg);
 
 			break;
 		}
@@ -4135,6 +4147,13 @@
 				cmd = 't';
 		}
 	}
+
+	ast_config_destroy(msg_cfg);
+	if (already_recorded)
+		ast_filedelete(backup, NULL);
+	if (prepend_duration)
+		*duration = prepend_duration;
+
 	if (cmd == 't' || cmd == 'S')
 		cmd = 0;
 	return cmd;
@@ -4389,19 +4408,34 @@
 		leave_options.record_gain = record_gain;
 		cmd = leave_voicemail(chan, mailbox, &leave_options);
 	} else {
-
 		/* Forward VoiceMail */
 		long duration = 0;
+		char origmsgfile[PATH_MAX], msgfile[PATH_MAX];
+		struct vm_state vmstmp;
 #ifdef IMAP_STORAGE
 		char *myserveremail = serveremail;
 		char buf[1024] = "";
 		int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
 #endif
+
+		memcpy(&vmstmp, vms, sizeof(vmstmp));
+
+		make_file(origmsgfile, sizeof(origmsgfile), dir, curmsg);
+		create_dirpath(vmstmp.curdir, sizeof(vmstmp.curdir), sender->context, vmstmp.username, "tmp");
+		make_file(msgfile, sizeof(msgfile), vmstmp.curdir, curmsg);
+
  		RETRIEVE(dir, curmsg, sender->mailbox, context);
-		cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, vms);
+
+		/* Alter a surrogate file, only */
+		copy_plain_file(origmsgfile, msgfile);
+
+		cmd = vm_forwardoptions(chan, sender, vmstmp.curdir, curmsg, vmfmts, S_OR(context, "default"), record_gain, &duration, &vmstmp);
 		if (!cmd) {
 			AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) {
 #ifdef IMAP_STORAGE
+				char *myserveremail;
+				int attach_user_voicemail;
+
  				/* Need to get message content */
 	 			ast_debug(3, "Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", vms->curmsg, vms->msgArray[vms->curmsg]);
  				if (!vms->msgArray[vms->curmsg]) {
@@ -4465,7 +4499,7 @@
 				sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, fmt, duration, attach_user_voicemail, chan, NULL);
 
 #else
-				copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir);
+				copy_message(chan, sender, -1, curmsg, duration, vmtmp, fmt, vmstmp.curdir);
 #endif
 				saved_messages++;
 				AST_LIST_REMOVE_CURRENT(list);
@@ -4486,6 +4520,9 @@
 				res = ast_play_and_wait(chan, "vm-msgsaved");
 			}	
 		}
+
+		/* Remove surrogate file */
+		DELETE(tmpdir, curmsg, msgfile);
 	}
 
 	/* If anything failed above, we still have this list to free */

Modified: team/tilghman/res_odbc_astobj2/configs/res_odbc.conf.sample
URL: http://svn.digium.com/view/asterisk/team/tilghman/res_odbc_astobj2/configs/res_odbc.conf.sample?view=diff&rev=101988&r1=101987&r2=101988
==============================================================================
--- team/tilghman/res_odbc_astobj2/configs/res_odbc.conf.sample (original)
+++ team/tilghman/res_odbc_astobj2/configs/res_odbc.conf.sample Fri Feb  1 16:36:24 2008
@@ -4,8 +4,9 @@
 ; Note that all environmental variables can be seen by all connections,
 ; so you can't have different values for different connections.
 [ENV]
-INFORMIXSERVER => my_special_database
-INFORMIXDIR => /opt/informix
+;INFORMIXSERVER => my_special_database
+;INFORMIXDIR => /opt/informix
+;ORACLE_HOME => /home/oracle
 
 ; All other sections are arbitrary names for database connections.
 
@@ -15,6 +16,7 @@
 ;username => myuser
 ;password => mypass
 pre-connect => yes
+;
 ; What should we execute to ensure that our connection is still alive?  The
 ; statement should return a non-zero value in the first field of its first
 ; record.  The default is "select 1".
@@ -34,17 +36,18 @@
 ;idlecheck => 3600
 
 ; Certain servers, such as MS SQL Server and Sybase use the TDS protocol, which
-; limits the number of active queries per connection to 1.  By setting up pools
-; of connections, Asterisk can be made to work with these servers.
+; limits the number of active queries per connection to 1.  By telling res_odbc
+; not to share connections, Asterisk can be made to work with these servers.
 [sqlserver]
 enabled => no
 dsn => mickeysoft
-pooling => yes
+share_connections => no
 limit => 5
 username => oscar
 password => thegrouch
 pre-connect => yes
 sanitysql => select count(*) from systables
+;
 ; Many databases have a default of '\' to escape special characters.  MS SQL
 ; Server does not.
 backslash_is_escape => no

Modified: team/tilghman/res_odbc_astobj2/configure.ac
URL: http://svn.digium.com/view/asterisk/team/tilghman/res_odbc_astobj2/configure.ac?view=diff&rev=101988&r1=101987&r2=101988
==============================================================================
--- team/tilghman/res_odbc_astobj2/configure.ac (original)
+++ team/tilghman/res_odbc_astobj2/configure.ac Fri Feb  1 16:36:24 2008
@@ -572,7 +572,7 @@
 AST_EXT_LIB_CHECK([FLOOR], [m], [floor])
 AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
 
-AST_EXT_LIB_CHECK([GETIFADDRS], [c], [getifaddrs], [ifaddrs.h])
+AST_C_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h])
 
 GSM_INTERNAL="yes"
 AC_SUBST(GSM_INTERNAL)

Modified: team/tilghman/res_odbc_astobj2/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/view/asterisk/team/tilghman/res_odbc_astobj2/include/asterisk/autoconfig.h.in?view=diff&rev=101988&r1=101987&r2=101988
==============================================================================
--- team/tilghman/res_odbc_astobj2/include/asterisk/autoconfig.h.in (original)
+++ team/tilghman/res_odbc_astobj2/include/asterisk/autoconfig.h.in Fri Feb  1 16:36:24 2008
@@ -297,10 +297,10 @@
 /* Define to 1 if you have the `gethostname' function. */
 #undef HAVE_GETHOSTNAME
 
-/* Define this to indicate the ${GETIFADDRS_DESCRIP} library */
+/* Define if your system has the GETIFADDRS headers. */
 #undef HAVE_GETIFADDRS
 
-/* Define to indicate the ${GETIFADDRS_DESCRIP} library version */
+/* Define GETIFADDRS headers version */
 #undef HAVE_GETIFADDRS_VERSION
 
 /* Define to 1 if you have the `getloadavg' function. */

Modified: team/tilghman/res_odbc_astobj2/res/res_config_curl.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/res_odbc_astobj2/res/res_config_curl.c?view=diff&rev=101988&r1=101987&r2=101988
==============================================================================
--- team/tilghman/res_odbc_astobj2/res/res_config_curl.c (original)
+++ team/tilghman/res_odbc_astobj2/res/res_config_curl.c Fri Feb  1 16:36:24 2008
@@ -77,7 +77,7 @@
 		return NULL;
 	}
 
-	ast_str_set(&query, 0, "${CURL(%s,", url);
+	ast_str_set(&query, 0, "${CURL(%s/single,", url);
 
 	for (i = 0; (newparam = va_arg(ap, const char *)); i++) {
 		newval = va_arg(ap, const char *);
@@ -155,8 +155,12 @@
 
 	for (i = 0; (newparam = va_arg(ap, const char *)); i++) {
 		newval = va_arg(ap, const char *);
-		if (i == 0)
+		if (i == 0) {
+			char *op;
 			initfield = ast_strdupa(newparam);
+			if ((op = strchr(initfield, ' ')))
+				*op = '\0';
+		}
 		ast_uri_encode(newparam, buf1, sizeof(buf1), EncodeSpecialChars);
 		ast_uri_encode(newval, buf2, sizeof(buf2), EncodeSpecialChars);
 		ast_str_append(&query, 0, "%s%s=%s", i > 0 ? "&" : "", buf1, buf2);

Modified: team/tilghman/res_odbc_astobj2/res/res_odbc.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/res_odbc_astobj2/res/res_odbc.c?view=diff&rev=101988&r1=101987&r2=101988
==============================================================================
--- team/tilghman/res_odbc_astobj2/res/res_odbc.c (original)
+++ team/tilghman/res_odbc_astobj2/res/res_odbc.c Fri Feb  1 16:36:24 2008
@@ -275,6 +275,10 @@
 			for (v = ast_variable_browse(config, cat); v; v = v->next) {
 				if (!strcasecmp(v->name, "pooling")) {
 					if (ast_true(v->value))
+						pooling = 1;
+				} else if (!strncasecmp(v->name, "share", 5)) {
+					/* "shareconnections" is a little clearer in meaning than "pooling" */
+					if (ast_false(v->value))
 						pooling = 1;
 				} else if (!strcasecmp(v->name, "limit")) {
 					sscanf(v->value, "%d", &limit);




More information about the asterisk-commits mailing list