~davewalker/ubuntu/maverick/asterisk/lp_705014

« back to all changes in this revision

Viewing changes to apps/app_setcallerid.c

  • Committer: Bazaar Package Importer
  • Author(s): Kilian Krause
  • Date: 2005-03-09 22:09:05 UTC
  • mto: (1.2.1 upstream) (8.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20050309220905-9afy6hcpw96xbr6j
Tags: upstream-1.0.6
ImportĀ upstreamĀ versionĀ 1.0.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#include <asterisk/module.h>
20
20
#include <asterisk/translate.h>
21
21
#include <asterisk/image.h>
 
22
#include <asterisk/callerid.h>
22
23
#include <string.h>
23
24
#include <stdlib.h>
24
 
#include <pthread.h>
 
25
 
 
26
static char *app2 = "SetCallerPres";
 
27
 
 
28
static char *synopsis2 = "Set CallerID Presentation";
 
29
 
 
30
STANDARD_LOCAL_USER;
 
31
 
 
32
LOCAL_USER_DECL;
 
33
 
 
34
static struct {
 
35
        int val;
 
36
        char *name;
 
37
} preses[] = {
 
38
        {  AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened" },
 
39
        {  AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen" },
 
40
        {  AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen" },
 
41
        {  AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed" },
 
42
        {  AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED     , "prohib_not_screened" },
 
43
        {  AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen" },
 
44
        {  AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen" },
 
45
        {  AST_PRES_PROHIB_NETWORK_NUMBER, "prohib" },
 
46
        {  AST_PRES_NUMBER_NOT_AVAILABLE, "unavailable" },
 
47
};
 
48
 
 
49
static char *descrip2 = 
 
50
"  SetCallerPres(presentation): Set Caller*ID presentation on\n"
 
51
"a call to a new value.  Sets ANI as well if a flag is used.\n"
 
52
"Always returns 0.  Valid presentations are:\n"
 
53
"\n"
 
54
"      allowed_not_screened    : Presentation Allowed, Not Screened\n"
 
55
"      allowed_passed_screen   : Presentation Allowed, Passed Screen\n" 
 
56
"      allowed_failed_screen   : Presentation Allowed, Failed Screen\n" 
 
57
"      allowed                 : Presentation Allowed, Network Number\n"
 
58
"      prohib_not_screened     : Presentation Prohibited, Not Screened\n" 
 
59
"      prohib_passed_screen    : Presentation Prohibited, Passed Screen\n"
 
60
"      prohib_failed_screen    : Presentation Prohibited, Failed Screen\n"
 
61
"      prohib                  : Presentation Prohibited, Network Number\n"
 
62
"      unavailable             : Number Unavailable\n"
 
63
"\n"
 
64
;
 
65
 
 
66
static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
 
67
{
 
68
        int res = 0;
 
69
        char tmp[256] = "";
 
70
        struct localuser *u;
 
71
        int x;
 
72
        char *opts;
 
73
        int pres = -1;
 
74
        if (data)
 
75
                strncpy(tmp, (char *)data, sizeof(tmp) - 1);
 
76
        opts = strchr(tmp, '|');
 
77
        if (opts) {
 
78
                *opts = '\0';
 
79
                opts++;
 
80
        }
 
81
        for (x=0;x<sizeof(preses) / sizeof(preses[0]);x++) {
 
82
                if (!strcasecmp(preses[x].name, tmp)) {
 
83
                        pres = preses[x].val;
 
84
                        break;
 
85
                }
 
86
        }
 
87
        if (pres < 0) {
 
88
                ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n", tmp);
 
89
                return 0;
 
90
        }
 
91
        LOCAL_USER_ADD(u);
 
92
        chan->callingpres = pres;
 
93
        LOCAL_USER_REMOVE(u);
 
94
        return res;
 
95
}
 
96
 
 
97
 
25
98
 
26
99
static char *tdesc = "Set CallerID Application";
27
100
 
33
106
"  SetCallerID(clid[|a]): Set Caller*ID on a call to a new\n"
34
107
"value.  Sets ANI as well if a flag is used.  Always returns 0\n";
35
108
 
36
 
STANDARD_LOCAL_USER;
37
 
 
38
 
LOCAL_USER_DECL;
39
 
 
40
109
static int setcallerid_exec(struct ast_channel *chan, void *data)
41
110
{
42
111
        int res = 0;
62
131
int unload_module(void)
63
132
{
64
133
        STANDARD_HANGUP_LOCALUSERS;
 
134
        ast_unregister_application(app2);
65
135
        return ast_unregister_application(app);
66
136
}
67
137
 
68
138
int load_module(void)
69
139
{
 
140
        ast_register_application(app2, setcallerid_pres_exec, synopsis2, descrip2);
70
141
        return ast_register_application(app, setcallerid_exec, synopsis, descrip);
71
142
}
72
143