use the proper variable type for these unixODBC API calls, eliminating warnings on...
[asterisk-bristuff.git] / apps / app_lookupcidname.c
blob5a0042a2992bef7183d8402e58d362f26cd3bee1
1 /*
2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
19 /*! \file
21 * \brief App to set callerid name from database, based on directory number
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
28 #include "asterisk.h"
30 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <string.h>
36 #include "asterisk/lock.h"
37 #include "asterisk/file.h"
38 #include "asterisk/logger.h"
39 #include "asterisk/options.h"
40 #include "asterisk/channel.h"
41 #include "asterisk/pbx.h"
42 #include "asterisk/module.h"
43 #include "asterisk/translate.h"
44 #include "asterisk/image.h"
45 #include "asterisk/callerid.h"
46 #include "asterisk/astdb.h"
48 static char *app = "LookupCIDName";
50 static char *synopsis = "Look up CallerID Name from local database";
52 static char *descrip =
53 " LookupCIDName: Looks up the Caller*ID number on the active\n"
54 "channel in the Asterisk database (family 'cidname') and sets the\n"
55 "Caller*ID name. Does nothing if no Caller*ID was received on the\n"
56 "channel. This is useful if you do not subscribe to Caller*ID\n"
57 "name delivery, or if you want to change the names on some incoming\n"
58 "calls.\n";
61 static int lookupcidname_exec (struct ast_channel *chan, void *data)
63 char dbname[64];
64 struct ast_module_user *u;
65 static int dep_warning = 0;
67 u = ast_module_user_add(chan);
68 if (!dep_warning) {
69 dep_warning = 1;
70 ast_log(LOG_WARNING, "LookupCIDName is deprecated. Please use ${DB(cidname/${CALLERID(num)})} instead.\n");
72 if (chan->cid.cid_num) {
73 if (!ast_db_get ("cidname", chan->cid.cid_num, dbname, sizeof (dbname))) {
74 ast_set_callerid (chan, NULL, dbname, NULL);
75 if (option_verbose > 2)
76 ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID name to %s\n",
77 dbname);
80 ast_module_user_remove(u);
82 return 0;
85 static int unload_module(void)
87 int res;
89 res = ast_unregister_application (app);
91 ast_module_user_hangup_all();
93 return res;
96 static int load_module(void)
98 return ast_register_application (app, lookupcidname_exec, synopsis, descrip);
101 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Look up CallerID Name from local database");