Bug # 1503: Add Peter's fix to include "accountcode" support to MySQL based IAX-Friends
authorMalcolm Davenport <malcolmd@digium.com>
Thu, 29 Apr 2004 20:09:05 +0000 (20:09 +0000)
committerMalcolm Davenport <malcolmd@digium.com>
Thu, 29 Apr 2004 20:09:05 +0000 (20:09 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2823 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c
contrib/scripts/iax-friends.sql

index 9cfb628..230d0c2 100755 (executable)
@@ -1901,7 +1901,7 @@ static struct iax2_user *mysql_user(char *user)
                MYSQL_ROW rowval;
                name = alloca(strlen(user) * 2 + 1);
                mysql_real_escape_string(mysql, name, user, strlen(user));
                MYSQL_ROW rowval;
                name = alloca(strlen(user) * 2 + 1);
                mysql_real_escape_string(mysql, name, user, strlen(user));
-               snprintf(query, sizeof(query), "SELECT name, secret, context, ipaddr, port, regseconds FROM iaxfriends WHERE name=\"%s\"", name);
+               snprintf(query, sizeof(query), "SELECT name, secret, context, ipaddr, port, regseconds, accountcode FROM iaxfriends WHERE name=\"%s\"", name);
                ast_mutex_lock(&mysqllock);
                mysql_query(mysql, query);
                if ((result = mysql_store_result(mysql))) {
                ast_mutex_lock(&mysqllock);
                mysql_query(mysql, query);
                if ((result = mysql_store_result(mysql))) {
@@ -1915,6 +1915,8 @@ static struct iax2_user *mysql_user(char *user)
                                                        strncpy(p->secret, rowval[x], sizeof(p->secret));
                                                } else if (!strcasecmp(fields[x].name, "context")) {
                                                        strncpy(p->contexts->context, rowval[x], sizeof(p->contexts->context) - 1);
                                                        strncpy(p->secret, rowval[x], sizeof(p->secret));
                                                } else if (!strcasecmp(fields[x].name, "context")) {
                                                        strncpy(p->contexts->context, rowval[x], sizeof(p->contexts->context) - 1);
+                                               } else if (!strcasecmp(fields[x].name, "accountcode")) {
+                                                       strncpy(p->accountcode, rowval[x], sizeof(p->accountcode));
                                                }
                                        }
                                }
                                                }
                                        }
                                }
index d919ab1..717a27d 100755 (executable)
@@ -9,6 +9,7 @@ CREATE TABLE `iaxfriends` (
   `ipaddr` varchar(20) NOT NULL default '',
   `port` int(6) NOT NULL default '0',
   `regseconds` int(11) NOT NULL default '0',
   `ipaddr` varchar(20) NOT NULL default '',
   `port` int(6) NOT NULL default '0',
   `regseconds` int(11) NOT NULL default '0',
+  `accountcode` varchar(20) NOT NULL default '', 
   PRIMARY KEY  (`name`)
 ) TYPE=MyISAM;
 
   PRIMARY KEY  (`name`)
 ) TYPE=MyISAM;