app_lookupcidname.c patch

Hello,

This is a small patch for app_lookupcidname.c, that allows someone to have different caller id names lists on the same server (in case you need to set the caller name differently or have different lists in different context or places). The patch does not change the default behavior (if no argument is specified, it still uses the “cidname” key). If you call the function by Lookupcidname(key) instead of just Lookupcidname, it will search the caller name into /key/number instead of /cidname/number.

--- t/asterisk-1.2.9.1/apps/app_lookupcidname.c 2005-11-29 20:24:39.000000000 +0200
+++ asterisk-1.2.9.1/apps/app_lookupcidname.c   2006-07-14 21:08:33.000000000 +0300
@@ -65,11 +65,25 @@
 lookupcidname_exec (struct ast_channel *chan, void *data)
 {
   char dbname[64];
+  char dbkey[64];
+  char logmsg[256];
   struct localuser *u;
 
+
+  if (ast_strlen_zero(data)) {
+     ast_log(LOG_WARNING, "LookupCIDName: using default key 'cidname'\n");
+     strncpy(dbkey, "cidname", sizeof(dbkey) - 1);
+  } else {
+     strncpy(dbkey, data, sizeof(dbkey) - 1);
+     strncpy(logmsg, "LookupCIDName: using key '", 255);
+     strncat(logmsg, dbkey, 255-strnlen(logmsg, 255));
+     strncat(logmsg, "'\n", 255-strnlen(logmsg, 255)); 
+     ast_log(LOG_WARNING, logmsg);
+  }
+
   LOCAL_USER_ADD (u);
   if (chan->cid.cid_num) {
-       if (!ast_db_get ("cidname", chan->cid.cid_num, dbname, sizeof (dbname))) {
+       if (!ast_db_get (dbkey, chan->cid.cid_num, dbname, sizeof (dbname))) {
                ast_set_callerid (chan, NULL, dbname, NULL);
                  if (option_verbose > 2)
                    ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID name to %s\n",