allows the table field to be configurable for
authorMatt O'Gorman <mogorman@digium.com>
Wed, 8 Mar 2006 22:12:20 +0000 (22:12 +0000)
committerMatt O'Gorman <mogorman@digium.com>
Wed, 8 Mar 2006 22:12:20 +0000 (22:12 +0000)
cdr_tds.conf.  patch provided by bug 6629 with
minor change.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@12475 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr/cdr_tds.c
configs/cdr_tds.conf.sample

index 14aa9b2..bc1be7e 100644 (file)
@@ -89,6 +89,7 @@ static char *name = "mssql";
 static char *config = "cdr_tds.conf";
 
 static char *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *charset = NULL, *language = NULL;
+static char *table = NULL;
 
 static int connected = 0;
 
@@ -135,7 +136,7 @@ static int tds_log(struct ast_cdr *cdr)
 
        sprintf(
                sqlcmd,
-               "INSERT INTO cdr "
+               "INSERT INTO %s "
                "("
                        "accountcode, "
                        "src, "
@@ -175,6 +176,7 @@ static int tds_log(struct ast_cdr *cdr)
                        "'%s', "        /* amaflags */
                        "'%s'"          /* uniqueid */
                ")",
+               table,
                accountcode,
                src,
                dst,
@@ -415,6 +417,7 @@ static int tds_unload_module(void)
        if (password) free(password);
        if (charset) free(charset);
        if (language) free(language);
+       if (table) free(table);
 
        return 0;
 }
@@ -475,6 +478,13 @@ static int tds_load_module(void)
        else
                language = strdup("us_english");
 
+       ptr = ast_variable_retrieve(cfg,"global","table");
+       if (ptr == NULL) {
+               ast_log(LOG_DEBUG,"cdr_tds: table not specified.  Assuming cdr\n");
+               ptr = "cdr";
+       }
+       table = strdup(ptr);
+
        ast_config_destroy(cfg);
 
        mssql_connect();
index 9fffec0..d8c7d07 100644 (file)
@@ -7,3 +7,5 @@
 ;user=mangUsr
 ;password=
 ;charset=BIG5
+;table=cdr
+