Add commonly used include headers
[asterisk/asterisk.git] / apps / app_softhangup.c
1 /*
2  * Asterisk -- A telephony toolkit for Linux.
3  *
4  * SoftHangup application
5  * 
6  * Copyright (C) 1999, Mark Spencer
7  *
8  * Mark Spencer <markster@linux-support.net>
9  *
10  * This program is free software, distributed under the terms of
11  * the GNU General Public License
12  */
13
14 #include <sys/types.h>
15 #include <asterisk/file.h>
16 #include <asterisk/logger.h>
17 #include <asterisk/channel.h>
18 #include <asterisk/pbx.h>
19 #include <asterisk/module.h>
20 #include <stdlib.h>
21 #include <unistd.h>
22 #include <string.h>
23 #include <stdlib.h>
24
25 #include <pthread.h>
26
27
28 static char *synopsis = "Soft Hangup Application";
29
30 static char *tdesc = "Hangs up the requested channel";
31
32 static char *desc = "  SoftHangup(Technology/resource)\n"
33 "Hangs up the requested channel.  Always returns 0\n";
34
35 static char *app = "SoftHangup";
36
37 STANDARD_LOCAL_USER;
38
39 LOCAL_USER_DECL;
40
41 static int softhangup_exec(struct ast_channel *chan, void *data)
42 {
43         struct localuser *u;
44         struct ast_channel *c=NULL;
45         if (!data) {
46                 ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
47                 return 0;
48         }
49         LOCAL_USER_ADD(u);
50         c = ast_channel_walk(NULL);
51         while (c) {
52                 if (!strcasecmp(c->name, data)) {
53                         ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
54                         break;
55                 }
56                 c = ast_channel_walk(c);
57         }
58         LOCAL_USER_REMOVE(u);
59
60         return 0;
61 }
62
63 int unload_module(void)
64 {
65         STANDARD_HANGUP_LOCALUSERS;
66         return ast_unregister_application(app);
67 }
68
69 int load_module(void)
70 {
71         return ast_register_application(app, softhangup_exec, synopsis, desc);
72 }
73
74 char *description(void)
75 {
76         return tdesc;
77 }
78
79 int usecount(void)
80 {
81         int res;
82         STANDARD_USECOUNT(res);
83         return res;
84 }
85
86 char *key()
87 {
88         return ASTERISK_GPL_KEY;
89 }