[asterisk-commits] seanbright: branch seanbright/resolve-shadow-warnings r126347 - in /team/sean...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jun 29 08:39:50 CDT 2008


Author: seanbright
Date: Sun Jun 29 08:39:50 2008
New Revision: 126347

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126347
Log:
Merged revisions 126226,126274,126308-126312,126319 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r126226 | seanbright | 2008-06-28 17:28:16 -0400 (Sat, 28 Jun 2008) | 8 lines

Merge in changes from my cdr-tds-conversion branch.  This changes the internal
implementation from using the volatile libtds, to using the db-lib front end.
The unintended side effect of this is that we support (at least) versions 0.62
through 0.82 of the FreeTDS distribution without any #ifdef ugliness.

(closes issue #12844)
Reported by: jcollie

........
r126274 | seanbright | 2008-06-29 08:06:46 -0400 (Sun, 29 Jun 2008) | 6 lines

Quote column names when inserting CDRs into postgres to avoid conflicts
with reserved words.

(closes issue #12947)
Reported by: panolex

........
r126308 | rizzo | 2008-06-29 08:45:59 -0400 (Sun, 29 Jun 2008) | 2 lines

make this compile after ast_frame's data field changed to a union

........
r126309 | rizzo | 2008-06-29 08:53:45 -0400 (Sun, 29 Jun 2008) | 6 lines

accept any name starting with X11 for X11 grabbers - this lets
you have multiple active instances of this grabber;

require v4l device names to start with '/dev/' - prevents some useless
attempt to open a file as a device.

........
r126310 | rizzo | 2008-06-29 08:59:26 -0400 (Sun, 29 Jun 2008) | 4 lines

add some defines and fields in preparation for the import of
the video source switching support


........
r126311 | rizzo | 2008-06-29 09:02:54 -0400 (Sun, 29 Jun 2008) | 3 lines

implement a 'toggle' option for 'console mute' and 'console unmute'


........
r126312 | seanbright | 2008-06-29 09:11:55 -0400 (Sun, 29 Jun 2008) | 4 lines

While we're at it, escape all the columns in our TDS queries as well.  Double
quotes seems to be more standard than square brackets (Sybase and SQL Server
both support them).

........
r126319 | seanbright | 2008-06-29 09:20:01 -0400 (Sun, 29 Jun 2008) | 2 lines

This was bogus, need to find a better way.

........

Modified:
    team/seanbright/resolve-shadow-warnings/   (props changed)
    team/seanbright/resolve-shadow-warnings/UPGRADE.txt
    team/seanbright/resolve-shadow-warnings/cdr/cdr_pgsql.c
    team/seanbright/resolve-shadow-warnings/cdr/cdr_tds.c
    team/seanbright/resolve-shadow-warnings/channels/chan_oss.c
    team/seanbright/resolve-shadow-warnings/channels/console_video.c
    team/seanbright/resolve-shadow-warnings/channels/console_video.h
    team/seanbright/resolve-shadow-warnings/channels/vcodecs.c
    team/seanbright/resolve-shadow-warnings/channels/vgrabbers.c
    team/seanbright/resolve-shadow-warnings/configure
    team/seanbright/resolve-shadow-warnings/configure.ac

Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Jun 29 08:39:50 2008
@@ -1,1 +1,1 @@
-/trunk:1-126214
+/trunk:1-126346

Modified: team/seanbright/resolve-shadow-warnings/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/UPGRADE.txt?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/UPGRADE.txt (original)
+++ team/seanbright/resolve-shadow-warnings/UPGRADE.txt Sun Jun 29 08:39:50 2008
@@ -155,6 +155,9 @@
   possible values the systemname prefix could be.  In the past, if the
   systemname was too long, the uniqueid would have been truncated.
 
+* The cdr_tds module now supports all versions of FreeTDS that contain
+  the db-lib frontend.
+
 Formats:
 
 * format_wav: The GAIN preprocessor definition and source code that used it

Modified: team/seanbright/resolve-shadow-warnings/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/cdr/cdr_pgsql.c?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/cdr/cdr_pgsql.c (original)
+++ team/seanbright/resolve-shadow-warnings/cdr/cdr_pgsql.c Sun Jun 29 08:39:50 2008
@@ -146,8 +146,8 @@
 			if (!value) {
 				if (cur->notnull && !cur->hasdefault) {
 					/* Field is NOT NULL (but no default), must include it anyway */
-					LENGTHEN_BUF1(strlen(cur->name));
-					lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
+					LENGTHEN_BUF1(strlen(cur->name) + 2);
+					lensql += snprintf(sql + lensql, sizesql - lensql, "\"%s\",", cur->name);
 					LENGTHEN_BUF2(3);
 					strcat(sql2, "'',");
 					lensql2 += 3;
@@ -155,8 +155,8 @@
 				continue;
 			}
 			
-			LENGTHEN_BUF1(strlen(cur->name));
-			lensql += snprintf(sql + lensql, sizesql - lensql, "%s,", cur->name);
+			LENGTHEN_BUF1(strlen(cur->name) + 2);
+			lensql += snprintf(sql + lensql, sizesql - lensql, "\"%s\",", cur->name);
 
 			if (strcmp(cur->name, "start") == 0 || strcmp(cur->name, "calldate") == 0) {
 				if (strncmp(cur->type, "int", 3) == 0) {

Modified: team/seanbright/resolve-shadow-warnings/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/cdr/cdr_tds.c?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/cdr/cdr_tds.c (original)
+++ team/seanbright/resolve-shadow-warnings/cdr/cdr_tds.c Sun Jun 29 08:39:50 2008
@@ -66,82 +66,76 @@
 #include <time.h>
 #include <math.h>
 
-#include <tds.h>
-#include <tdsconvert.h>
-#include <ctype.h>
-
 #include "asterisk/config.h"
 #include "asterisk/channel.h"
 #include "asterisk/cdr.h"
 #include "asterisk/module.h"
 
-#ifdef FREETDS_PRE_0_62
-#warning "You have older TDS, you should upgrade!"
-#endif
+#include <sqlfront.h>
+#include <sybdb.h>
 
 #define DATE_FORMAT "%Y/%m/%d %T"
 
-static char *name = "mssql";
+static char *name = "FreeTDS (MSSQL)";
 static char *config = "cdr_tds.conf";
 
 struct cdr_tds_config {
 	AST_DECLARE_STRING_FIELDS(
 		AST_STRING_FIELD(hostname);
-		AST_STRING_FIELD(dbname);
-		AST_STRING_FIELD(dbuser);
+		AST_STRING_FIELD(database);
+		AST_STRING_FIELD(username);
 		AST_STRING_FIELD(password);
 		AST_STRING_FIELD(table);
 		AST_STRING_FIELD(charset);
 		AST_STRING_FIELD(language);
 	);
-	TDSSOCKET *tds;
-	TDSLOGIN *login;
-	TDSCONTEXT *context;
+	DBPROCESS *dbproc;
 	unsigned int connected:1;
-	ast_mutex_t lock;
 };
 
+AST_MUTEX_DEFINE_STATIC(tds_lock);
+
 static struct cdr_tds_config *settings;
 
 static char *anti_injection(const char *, int);
-static void get_date(char *, struct timeval);
+static void get_date(char *, size_t len, struct timeval);
 
 static int mssql_connect(void);
 static int mssql_disconnect(void);
 
-static void cdr_tds_config_destroy(void);
-
 static int tds_log(struct ast_cdr *cdr)
 {
-	char sqlcmd[2048], start[80], answer[80], end[80];
+	char start[80], answer[80], end[80];
 	char *accountcode, *src, *dst, *dcontext, *clid, *channel, *dstchannel, *lastapp, *lastdata, *uniqueid;
-	int res = 0;
-	int retried = 0;
-#ifdef FREETDS_PRE_0_62
-	TDS_INT result_type;
-#endif
-
-	ast_mutex_lock(&settings->lock);
-
-	memset(sqlcmd, 0, 2048);
+	RETCODE erc;
+	int res = -1;
 
 	accountcode = anti_injection(cdr->accountcode, 20);
-	src = anti_injection(cdr->src, 80);
-	dst = anti_injection(cdr->dst, 80);
-	dcontext = anti_injection(cdr->dcontext, 80);
-	clid = anti_injection(cdr->clid, 80);
-	channel = anti_injection(cdr->channel, 80);
-	dstchannel = anti_injection(cdr->dstchannel, 80);
-	lastapp = anti_injection(cdr->lastapp, 80);
-	lastdata = anti_injection(cdr->lastdata, 80);
-	uniqueid = anti_injection(cdr->uniqueid, 32);
-
-	get_date(start, cdr->start);
-	get_date(answer, cdr->answer);
-	get_date(end, cdr->end);
-
-	sprintf(
-		sqlcmd,
+	src         = anti_injection(cdr->src, 80);
+	dst         = anti_injection(cdr->dst, 80);
+	dcontext    = anti_injection(cdr->dcontext, 80);
+	clid        = anti_injection(cdr->clid, 80);
+	channel     = anti_injection(cdr->channel, 80);
+	dstchannel  = anti_injection(cdr->dstchannel, 80);
+	lastapp     = anti_injection(cdr->lastapp, 80);
+	lastdata    = anti_injection(cdr->lastdata, 80);
+	uniqueid    = anti_injection(cdr->uniqueid, 32);
+
+	get_date(start, sizeof(start), cdr->start);
+	get_date(answer, sizeof(answer), cdr->answer);
+	get_date(end, sizeof(end), cdr->end);
+
+	ast_mutex_lock(&tds_lock);
+
+	/* Ensure that we are connected */
+	if (!settings->connected) {
+		if (mssql_connect()) {
+			/* Connect failed */
+			goto done;
+		}
+	}
+
+	erc = dbfcmd(settings->dbproc,
 		"INSERT INTO %s "
 		"("
 			"accountcode, "
@@ -202,27 +196,26 @@
 		uniqueid
 	);
 
-	do {
-		if (!settings->connected) {
-			if (mssql_connect())
-				ast_log(LOG_ERROR, "Failed to reconnect to SQL database.\n");
-			else
-				ast_log(LOG_WARNING, "Reconnected to SQL database.\n");
-
-			retried = 1;	/* note that we have now tried */
-		}
-
-#ifdef FREETDS_PRE_0_62
-		if (!settings->connected || (tds_submit_query(settings->tds, sqlcmd) != TDS_SUCCEED) || (tds_process_simple_query(settings->tds, &result_type) != TDS_SUCCEED || result_type != TDS_CMD_SUCCEED))
-#else
-		if (!settings->connected || (tds_submit_query(settings->tds, sqlcmd) != TDS_SUCCEED) || (tds_process_simple_query(settings->tds) != TDS_SUCCEED))
-#endif
-		{
-			ast_log(LOG_ERROR, "Failed to insert Call Data Record into SQL database.\n");
-
-			mssql_disconnect();	/* this is ok even if we are already disconnected */
-		}
-	} while (!settings->connected && !retried);
+	if (erc == FAIL) {
+		ast_log(LOG_ERROR, "Failed to build INSERT statement, no CDR was logged.\n");
+		goto done;
+	}
+
+	if (dbsqlexec(settings->dbproc) == FAIL) {
+		ast_log(LOG_ERROR, "Failed to execute INSERT statement, no CDR was logged.\n");
+		goto done;
+	}
+
+	/* Consume any results we might get back (this is more of a sanity check than
+	 * anything else, since an INSERT shouldn't return results). */
+	while (dbresults(settings->dbproc) != NO_MORE_RESULTS) {
+		while (dbnextrow(settings->dbproc) != NO_MORE_ROWS);
+	}
+
+	res = 0;
+
+done:
+	ast_mutex_unlock(&tds_lock);
 
 	ast_free(accountcode);
 	ast_free(src);
@@ -235,9 +228,7 @@
 	ast_free(lastdata);
 	ast_free(uniqueid);
 
-	ast_mutex_unlock(&settings->lock);
-
-	return res;
+	return 0;
 }
 
 static char *anti_injection(const char *str, int len)
@@ -274,39 +265,23 @@
 	return buf;
 }
 
-static void get_date(char *dateField, struct timeval calldate)
-{
-	struct ast_tm tm;
-	char buf[80];
-
+static void get_date(char *dateField, size_t len, struct timeval calldate)
+{
 	/* To make sure we have date variable if not insert null to SQL */
 	if (!ast_tvzero(tv)) {
+		struct ast_tm tm;
 		ast_localtime(&calldate, &tm, NULL);
-		ast_strftime(buf, 80, DATE_FORMAT, &tm);
-		sprintf(dateField, "'%s'", buf);
-	} else {
-		strcpy(dateField, "null");
+		ast_strftime(dateField, len, "'" DATE_FORMAT "'", &tm);
+	} else {
+		ast_copy_string(dateField, "null", len);
 	}
 }
 
 static int mssql_disconnect(void)
 {
-	if (!settings)
-		return 0;
-	
-	if (settings->tds) {
-		tds_free_socket(settings->tds);
-		settings->tds = NULL;
-	}
-
-	if (settings->context) {
-		tds_free_context(settings->context);
-		settings->context = NULL;
-	}
-
-	if (settings->login) {
-		tds_free_login(settings->login);
-		settings->login = NULL;
+	if (settings->dbproc) {
+		dbclose(settings->dbproc);
+		settings->dbproc = NULL;
 	}
 
 	settings->connected = 0;
@@ -316,218 +291,227 @@
 
 static int mssql_connect(void)
 {
-#if (defined(FREETDS_0_63) || defined(FREETDS_0_64))
-	TDSCONNECTION *connection = NULL;
-#else
-	TDSCONNECTINFO *connection = NULL;
-#endif
-	char query[128];
-
-	/* Connect to M$SQL Server */
-	if (!(settings->login = tds_alloc_login())) {
-		ast_log(LOG_ERROR, "tds_alloc_login() failed.\n");
+	LOGINREC *login;
+
+	if ((login = dblogin()) == NULL) {
+		ast_log(LOG_ERROR, "Unable to allocate login structure for db-lib\n");
 		return -1;
 	}
 
-	tds_set_server(settings->login, settings->hostname);
-	tds_set_user(settings->login, settings->dbuser);
-	tds_set_passwd(settings->login, settings->password);
-	tds_set_app(settings->login, "TSQL");
-	tds_set_library(settings->login, "TDS-Library");
-#ifndef FREETDS_PRE_0_62
-	tds_set_client_charset(settings->login, settings->charset);
-#endif
-	tds_set_language(settings->login, settings->language);
-	tds_set_packet(settings->login, 512);
-	tds_set_version(settings->login, 7, 0);
-
-#ifdef FREETDS_0_64
-	if (!(settings->context = tds_alloc_context(NULL)))
-#else
-	if (!(settings->context = tds_alloc_context()))
-#endif
-	{
-		ast_log(LOG_ERROR, "tds_alloc_context() failed.\n");
-		goto connect_fail;
-	}
-
-	if (!(settings->tds = tds_alloc_socket(settings->context, 512))) {
-		ast_log(LOG_ERROR, "tds_alloc_socket() failed.\n");
-		goto connect_fail;
-	}
-
-	tds_set_parent(settings->tds, NULL);
-	connection = tds_read_config_info(settings->tds, settings->login, settings->context->locale);
-	if (!connection) {
-		ast_log(LOG_ERROR, "tds_read_config() failed.\n");
-		goto connect_fail;
-	}
-
-	if (tds_connect(settings->tds, connection) == TDS_FAIL) {
-		ast_log(LOG_ERROR, "Failed to connect to MSSQL server.\n");
-		settings->tds = NULL;	/* freed by tds_connect() on error */
-#if (defined(FREETDS_0_63) || defined(FREETDS_0_64))
-		tds_free_connection(connection);
-#else
-		tds_free_connect(connection);
-#endif
-		connection = NULL;
-		goto connect_fail;
-	}
-#if (defined(FREETDS_0_63) || defined(FREETDS_0_64))
-	tds_free_connection(connection);
-#else
-	tds_free_connect(connection);
-#endif
-	connection = NULL;
-
-	sprintf(query, "USE %s", settings->dbname);
-#ifdef FREETDS_PRE_0_62
-	if ((tds_submit_query(settings->tds, query) != TDS_SUCCEED) || (tds_process_simple_query(settings->tds, &result_type) != TDS_SUCCEED || result_type != TDS_CMD_SUCCEED))
-#else
-	if ((tds_submit_query(settings->tds, query) != TDS_SUCCEED) || (tds_process_simple_query(settings->tds) != TDS_SUCCEED))
-#endif
-	{
-		ast_log(LOG_ERROR, "Could not change database (%s)\n", settings->dbname);
-		goto connect_fail;
+	DBSETLAPP(login,     "TSQL");
+	DBSETLUSER(login,    settings->username);
+	DBSETLPWD(login,     settings->password);
+	DBSETLCHARSET(login, settings->charset);
+	DBSETLNATLANG(login, settings->language);
+
+	if ((settings->dbproc = dbopen(login, (char *) settings->hostname)) == NULL) {
+		ast_log(LOG_ERROR, "Unable to connect to %s\n", settings->hostname);
+		dbloginfree(login);
+		return -1;
+	}
+
+	dbloginfree(login);
+
+	if (dbuse(settings->dbproc, (char *) settings->database) == FAIL) {
+		ast_log(LOG_ERROR, "Unable to select database %s\n", settings->database);
+		goto failed;
+	}
+
+	if (dbfcmd(settings->dbproc, "SELECT 1 FROM [%s]", settings->table) == FAIL) {
+		ast_log(LOG_ERROR, "Unable to build query while verifying the existence of table '%s'\n", settings->table);
+		goto failed;
+	}
+
+	if (dbsqlexec(settings->dbproc) == FAIL) {
+		ast_log(LOG_ERROR, "Unable to verify existence of table '%s'\n", settings->table);
+		goto failed;
+	}
+
+	/* Consume the result set (we don't really care about the result, though) */
+	while (dbresults(settings->dbproc) != NO_MORE_RESULTS) {
+		while (dbnextrow(settings->dbproc) != NO_MORE_ROWS);
 	}
 
 	settings->connected = 1;
+
 	return 0;
 
-connect_fail:
-	mssql_disconnect();
+failed:
+	dbclose(settings->dbproc);
+	settings->dbproc = NULL;
 	return -1;
 }
 
-static void cdr_tds_config_destroy(void)
-{
-	if (settings)
-	{
-		ast_mutex_destroy(&settings->lock);
+static int tds_unload_module(void)
+{
+	if (settings) {
+		ast_mutex_lock(&tds_lock);
+		mssql_disconnect();
+		ast_mutex_unlock(&tds_lock);
+
 		ast_string_field_free_memory(settings);
-		ast_free(settings);	
-	}
-}
-
-static int tds_unload_module(void)
-{
-	mssql_disconnect();
+		ast_free(settings);
+	}
 
 	ast_cdr_unregister(name);
 
-	cdr_tds_config_destroy();
+	dbexit();
 
 	return 0;
 }
 
+static int tds_error_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
+{
+	ast_log(LOG_ERROR, "%s (%d)\n", dberrstr, dberr);
+
+	if (oserr != DBNOERR) {
+		ast_log(LOG_ERROR, "%s (%d)\n", oserrstr, oserr);
+	}
+
+	return INT_CANCEL;
+}
+
+static int tds_message_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line)
+{
+	ast_debug(1, "Msg %d, Level %d, State %d, Line %d\n", msgno, severity, msgstate, line);
+	ast_log(LOG_NOTICE, "%s\n", msgtext);
+
+	return 0;
+}
+
 static int tds_load_module(int reload)
 {
 	struct ast_config *cfg;
-	struct ast_variable *var;
 	const char *ptr = NULL;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 
 	cfg = ast_config_load(config, config_flags);
 	if (!cfg) {
-		ast_log(LOG_NOTICE, "Unable to load config for MSSQL CDRs: %s\n", config);
+		ast_log(LOG_NOTICE, "Unable to load TDS config for CDRs: %s\n", config);
 		return 0;
 	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
 		return 0;
 
-	var = ast_variable_browse(cfg, "global");
-	if (!var) /* nothing configured */ {
+	if (!ast_variable_browse(cfg, "global")) {
+		/* nothing configured */
 		ast_config_destroy(cfg);
 		return 0;
 	}
 
-	if (reload) {
-		ast_string_field_init(settings, 0);
-	} else {
-		settings = ast_calloc(1, sizeof(*settings));
-
-		if (!settings || ast_string_field_init(settings, 256)) {
-			if (settings) {
-				ast_free(settings);
-				settings = NULL;
-			}
-			ast_config_destroy(cfg);
-			return 0;
+	ast_mutex_lock(&tds_lock);
+
+	/* Clear out any existing settings */
+	ast_string_field_init(settings, 0);
+
+	ptr = ast_variable_retrieve(cfg, "global", "hostname");
+	if (ptr) {
+		ast_string_field_set(settings, hostname, ptr);
+	} else {
+		ast_log(LOG_ERROR, "Failed to connect: Database server hostname not specified.\n");
+		goto failed;
+	}
+
+	ptr = ast_variable_retrieve(cfg, "global", "dbname");
+	if (ptr) {
+		ast_string_field_set(settings, database, ptr);
+	} else {
+		ast_log(LOG_ERROR, "Failed to connect: Database dbname not specified.\n");
+		goto failed;
+	}
+
+	ptr = ast_variable_retrieve(cfg, "global", "user");
+	if (ptr) {
+		ast_string_field_set(settings, username, ptr);
+	} else {
+		ast_log(LOG_ERROR, "Failed to connect: Database dbuser not specified.\n");
+		goto failed;
+	}
+
+	ptr = ast_variable_retrieve(cfg, "global", "password");
+	if (ptr) {
+		ast_string_field_set(settings, password, ptr);
+	} else {
+		ast_log(LOG_ERROR, "Failed to connect: Database password not specified.\n");
+		goto failed;
+	}
+
+	ptr = ast_variable_retrieve(cfg, "global", "charset");
+	if (ptr) {
+		ast_string_field_set(settings, charset, ptr);
+	} else {
+		ast_string_field_set(settings, charset, "iso_1");
+	}
+
+	ptr = ast_variable_retrieve(cfg, "global", "language");
+	if (ptr) {
+		ast_string_field_set(settings, language, ptr);
+	} else {
+		ast_string_field_set(settings, language, "us_english");
+	}
+
+	ptr = ast_variable_retrieve(cfg, "global", "table");
+	if (ptr) {
+		ast_string_field_set(settings, table, ptr);
+	} else {
+		ast_log(LOG_NOTICE, "Table name not specified, using 'cdr' by default.\n");
+		ast_string_field_set(settings, table, "cdr");
+	}
+
+	mssql_disconnect();
+
+	if (mssql_connect()) {
+		/* We failed to connect (mssql_connect takes care of logging it) */
+		goto failed;
+	}
+
+	ast_mutex_unlock(&tds_lock);
+	ast_config_destroy(cfg);
+
+	return 1;
+
+failed:
+	ast_mutex_unlock(&tds_lock);
+	ast_config_destroy(cfg);
+
+	return 0;
+}
+
+static int reload(void)
+{
+	return tds_load_module(1);
+}
+
+static int load_module(void)
+{
+	if (dbinit() == FAIL) {
+		ast_log(LOG_ERROR, "Failed to initialize FreeTDS db-lib\n");
+		return AST_MODULE_LOAD_DECLINE;
+	}
+
+	dberrhandle(tds_error_handler);
+	dbmsghandle(tds_message_handler);
+
+	settings = ast_calloc(1, sizeof(*settings));
+
+	if (!settings || ast_string_field_init(settings, 256)) {
+		if (settings) {
+			ast_free(settings);
+			settings = NULL;
 		}
-
-		ast_mutex_init(&settings->lock);
-	}
-
-	ptr = ast_variable_retrieve(cfg, "global", "hostname");
-	if (ptr) {
-		ast_string_field_set(settings, hostname, ptr);
-	} else {
-		ast_log(LOG_ERROR, "Database server hostname not specified.\n");
-	}
-
-	ptr = ast_variable_retrieve(cfg, "global", "dbname");
-	if (ptr) {
-		ast_string_field_set(settings, dbname, ptr);
-	} else {
-		ast_log(LOG_ERROR, "Database dbname not specified.\n");
-	}
-
-	ptr = ast_variable_retrieve(cfg, "global", "user");
-	if (ptr) {
-		ast_string_field_set(settings, dbuser, ptr);
-	} else {
-		ast_log(LOG_ERROR, "Database dbuser not specified.\n");
-	}
-
-	ptr = ast_variable_retrieve(cfg, "global", "password");
-	if (ptr) {
-		ast_string_field_set(settings, password, ptr);
-	} else {
-		ast_log(LOG_ERROR, "Database password not specified.\n");
-	}
-
-	ptr = ast_variable_retrieve(cfg, "global", "charset");
-	if (ptr) {
-		ast_string_field_set(settings, charset, ptr);
-	} else {
-		ast_string_field_set(settings, charset, "iso_1");
-	}
-
-	ptr = ast_variable_retrieve(cfg, "global", "language");
-	if (ptr) {
-		ast_string_field_set(settings, language, ptr);
-	} else {
-		ast_string_field_set(settings, language, "us_english");
-	}
-
-	ptr = ast_variable_retrieve(cfg, "global", "table");
-	if (ptr) {
-		ast_string_field_set(settings, table, ptr);
-	} else {	
-		ast_debug(1, "Table not specified.  Assuming 'cdr'\n");
-		ast_string_field_set(settings, table, "cdr");
-	}
-
-	ast_config_destroy(cfg);
-
-	ast_mutex_lock(&settings->lock);
-	mssql_disconnect();
-	mssql_connect();
-	ast_mutex_unlock(&settings->lock);
-
-	return 1;
-}
-
-static int reload(void)
-{
-	return tds_load_module(1);
-}
-
-static int load_module(void)
-{
-	if (!tds_load_module(0))
+		dbexit();
 		return AST_MODULE_LOAD_DECLINE;
+	}
+
+	if (!tds_load_module(0)) {
+		ast_string_field_free_memory(settings);
+		ast_free(settings);
+		settings = NULL;
+		dbexit();
+		return AST_MODULE_LOAD_DECLINE;
+	}
+
 	ast_cdr_register(name, ast_module_info->description, tds_log);
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 
@@ -536,7 +520,7 @@
 	return tds_unload_module();
 }
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "MSSQL CDR Backend",
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "FreeTDS CDR Backend",
 		.load = load_module,
 		.unload = unload_module,
 		.reload = reload,

Modified: team/seanbright/resolve-shadow-warnings/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/chan_oss.c?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/chan_oss.c (original)
+++ team/seanbright/resolve-shadow-warnings/channels/chan_oss.c Sun Jun 29 08:39:50 2008
@@ -1125,25 +1125,32 @@
 {
 	struct chan_oss_pvt *o = find_desc(oss_active);
 	char *s;
+	int toggle = 0;
 	
 	if (cmd == CLI_INIT) {
-		e->command = "console {mute|unmute}";
+		e->command = "console {mute|unmute} [toggle]";
 		e->usage =
-			"Usage: console {mute|unmute}\n"
+			"Usage: console {mute|unmute} [toggle]\n"
 			"       Mute/unmute the microphone.\n";
 		return NULL;
 	} else if (cmd == CLI_GENERATE)
 		return NULL;
 
-	if (a->argc != e->args)
+	if (a->argc > e->args)
 		return CLI_SHOWUSAGE;
-	s = a->argv[e->args-1];
+	if (a->argc == e->args) {
+		if (strcasecmp(a->argv[e->args-1], "toggle"))
+			return CLI_SHOWUSAGE;
+		toggle = 1;
+	}
+	s = a->argv[e->args-2];
 	if (!strcasecmp(s, "mute"))
-		o->mute = 1;
+		o->mute = toggle ? ~o->mute : 1;
 	else if (!strcasecmp(s, "unmute"))
-		o->mute = 0;
+		o->mute = toggle ? ~o->mute : 0;
 	else
 		return CLI_SHOWUSAGE;
+	ast_cli(a->fd, "Console mic is %s\n", o->mute ? "off" : "on");
 	return CLI_SUCCESS;
 }
 

Modified: team/seanbright/resolve-shadow-warnings/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/console_video.c?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/console_video.c (original)
+++ team/seanbright/resolve-shadow-warnings/channels/console_video.c Sun Jun 29 08:39:50 2008
@@ -608,11 +608,11 @@
 	}
 	v->next_seq++;
 
-	if (f->data == NULL || f->datalen < 2) {
+	if (f->data.ptr == NULL || f->datalen < 2) {
 		ast_log(LOG_WARNING, "empty video frame, discard\n");
 		return 0;
 	}
-	if (v->d_callbacks->dec_decap(v->dec_in_cur, f->data, f->datalen)) {
+	if (v->d_callbacks->dec_decap(v->dec_in_cur, f->data.ptr, f->datalen)) {
 		ast_log(LOG_WARNING, "error in dec_decap, enter discard\n");
 		v->discard = 1;
 	}

Modified: team/seanbright/resolve-shadow-warnings/channels/console_video.h
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/console_video.h?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/console_video.h (original)
+++ team/seanbright/resolve-shadow-warnings/channels/console_video.h Sun Jun 29 08:39:50 2008
@@ -43,6 +43,13 @@
 
 #endif	/* HAVE_VIDEO_CONSOLE and others */
 
+#define	SRC_WIN_W	80	/* width of video thumbnails */
+#define	SRC_WIN_H	60	/* height of video thumbnails */
+/* we only support a limited number of video sources in the GUI,
+ * because we need screen estate to switch between them.
+ */
+#define	MAX_VIDEO_SOURCES	9
+
 /*
  * In many places we use buffers to store the raw frames (but not only),
  * so here is a structure to keep all the info. data = NULL means the
@@ -60,6 +67,11 @@
 	int	w;	/* size */ 
 	int	h;
 	int	pix_fmt;
+	/* offsets and size of the copy in Picture-in-Picture mode */
+	int	win_x;
+	int	win_y;
+	int	win_w;
+	int	win_h;
 };
 
 void fbuf_free(struct fbuf_t *);
@@ -103,6 +115,7 @@
 	DRAG_DIALED,	/* dialed number */
 	DRAG_INPUT,	/* input window */
 	DRAG_MESSAGE,	/* message window */
+	DRAG_PIP,	/* picture in picture */
 };
 
 /*! \brief support for drag actions */
@@ -123,5 +136,8 @@
 /*! \brief reset the board to blank */
 int reset_board(struct board *b);
 
+/*! \brief deallocates memory space for a board */
+void delete_board(struct board *b);
+
 #endif /* CONSOLE_VIDEO_H */
 /* end of file */

Modified: team/seanbright/resolve-shadow-warnings/channels/vcodecs.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/vcodecs.c?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/vcodecs.c (original)
+++ team/seanbright/resolve-shadow-warnings/channels/vcodecs.c Sun Jun 29 08:39:50 2008
@@ -240,7 +240,7 @@
 		return NULL;
 	}
 	memcpy(data+head, start, len);
-	f->data = data;
+	f->data.ptr = data;
 	f->mallocd = AST_MALLOCD_DATA | AST_MALLOCD_HDR;
 	//f->has_timing_info = 1;
 	//f->ts = ast_tvdiff_ms(ast_tvnow(), out->ts);
@@ -393,7 +393,7 @@
 		if (!f)
 			break;
 
-		data = f->data;
+		data = f->data.ptr;
 		if (h == 0) {	/* we start with a psc */
 			data[0] |= 0x04;	// set P == 1, and we are done
 		} else {	/* no psc, create a header */
@@ -647,7 +647,7 @@
 
 		if (!f)
 			break;
-		bcopy(h, f->data, 4);	/* copy the h263 header */
+		bcopy(h, f->data.ptr, 4);	/* copy the h263 header */
 		/* XXX to do: if not aligned, fix sbit and ebit,
 		 * then move i back by 1 for the next frame
 		 */
@@ -801,7 +801,7 @@
 			break;
 		/* recompute header with I=0, V=1 */
 		h[0] = ( (sbit & 7) << 5 ) | ( (ebit & 7) << 2 ) | 1;
-		bcopy(h, f->data, 4);	/* copy the h261 header */
+		bcopy(h, f->data.ptr, 4);	/* copy the h261 header */
 		if (ebit)	/* not aligned, restart from previous byte */
 			i--;
 		sbit = (8 - ebit) & 7;
@@ -1021,7 +1021,7 @@
 		size -= frag_size;	/* skip this data block */
 		start += frag_size;
 
-		data = f->data;
+		data = f->data.ptr;
 		data[0] = hdr[0];
 		data[1] = hdr[1] | (size == 0 ? 0x40 : 0);	/* end bit if we are done */
 		hdr[1] &= ~0x80;	/* clear start bit for subsequent frames */

Modified: team/seanbright/resolve-shadow-warnings/channels/vgrabbers.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/vgrabbers.c?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/vgrabbers.c (original)
+++ team/seanbright/resolve-shadow-warnings/channels/vgrabbers.c Sun Jun 29 08:39:50 2008
@@ -79,7 +79,8 @@
 	struct grab_x11_desc *v;
 	struct fbuf_t *b;
 
-	if (strcasecmp(name, "X11"))
+	/* all names starting with X11 identify this grabber */
+	if (strncasecmp(name, "X11", 3))
 		return NULL;	/* not us */
 	v = ast_calloc(1, sizeof(*v));
 	if (v == NULL)
@@ -205,6 +206,9 @@
 	struct grab_v4l1_desc *v;
 	struct fbuf_t *b;
 
+	/* name should be something under /dev/ */
+	if (strncmp(dev, "/dev/", 5)) 
+		return NULL;
 	fd = open(dev, O_RDONLY | O_NONBLOCK);
 	if (fd < 0) {
 		ast_log(LOG_WARNING, "error opening camera %s\n", dev);

Modified: team/seanbright/resolve-shadow-warnings/configure.ac
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/configure.ac?view=diff&rev=126347&r1=126346&r2=126347
==============================================================================
--- team/seanbright/resolve-shadow-warnings/configure.ac (original)
+++ team/seanbright/resolve-shadow-warnings/configure.ac Sun Jun 29 08:39:50 2008
@@ -1398,34 +1398,7 @@
 
 AST_EXT_TOOL_CHECK([GMIME], [gmime])
 
-AST_EXT_LIB_CHECK([FREETDS], [tds], [tds_version], [tds.h])
-if test "${PBX_FREETDS}" != "0";
-then
-    if test "${FREETDS_DIR}x" = "x";
-    then
-        for tds_dir in /usr /usr/local;
-        do
-            if test -f "${tds_dir}/include/tdsver.h";
-            then
-                FREETDS_DIR="${tds_dir}"
-            fi
-        done
-    fi
-    case `${GREP} TDS_VERSION_NO ${FREETDS_DIR:-/usr}/include/tdsver.h` in
-    *0.64*)
-        FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_64"
-	;;
-    *0.63*)
-        FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_63"
-	;;
-    *0.62*)
-        FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_0_62"
-	;;
-    *)
-        FREETDS_INCLUDE="${FREETDS_INCLUDE} -DFREETDS_PRE_0_62"
-	;;
-    esac
-fi
+AST_EXT_LIB_CHECK([FREETDS], [sybdb], [dbinit], [sybdb.h])
 
 AST_EXT_LIB_CHECK([TERMCAP], [termcap], [tgetent], [])
 




More information about the asterisk-commits mailing list