Remove pthread.h from source. We should be using asterisk/lock.h everywhere instead...
[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 <asterisk/lock.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <string.h>
24 #include <stdlib.h>
25
26 static char *synopsis = "Soft Hangup Application";
27
28 static char *tdesc = "Hangs up the requested channel";
29
30 static char *desc = "  SoftHangup(Technology/resource)\n"
31 "Hangs up the requested channel.  Always returns 0\n";
32
33 static char *app = "SoftHangup";
34
35 STANDARD_LOCAL_USER;
36
37 LOCAL_USER_DECL;
38
39 static int softhangup_exec(struct ast_channel *chan, void *data)
40 {
41         struct localuser *u;
42         struct ast_channel *c=NULL;
43         if (!data) {
44                 ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
45                 return 0;
46         }
47         LOCAL_USER_ADD(u);
48         c = ast_channel_walk_locked(NULL);
49         while (c) {
50                 if (!strcasecmp(c->name, data)) {
51                         ast_softhangup(c, AST_SOFTHANGUP_EXPLICIT);
52                         ast_mutex_unlock(&c->lock);
53                         break;
54                 }
55                 ast_mutex_unlock(&c->lock);
56                 c = ast_channel_walk_locked(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 }