aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_skel.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2000-01-02 20:59:00 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2000-01-02 20:59:00 +0000
commit999d3524e27900ec85d461f644d0e2fde138fca4 (patch)
tree53bb1d4c35295fea70d6179bfa71cd1e10d402df /apps/app_skel.c
parent2137f5008cf14c94312348e272f9b38df43233e1 (diff)
Version 0.1.2 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@152 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_skel.c')
-rwxr-xr-xapps/app_skel.c50
1 files changed, 9 insertions, 41 deletions
diff --git a/apps/app_skel.c b/apps/app_skel.c
index e766d1142..419b8f40a 100755
--- a/apps/app_skel.c
+++ b/apps/app_skel.c
@@ -15,6 +15,7 @@
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
+#include <asterisk/module.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -22,63 +23,32 @@
#include <pthread.h>
-static pthread_mutex_t skellock = PTHREAD_MUTEX_INITIALIZER;
-
-static int usecnt=0;
static char *tdesc = "Trivial skeleton Application";
static char *app = "skel";
-struct skeluser {
- struct ast_channel *chan;
- struct skeluser *next;
-} *users = NULL;
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
static int skel_exec(struct ast_channel *chan, void *data)
{
int res=0;
- struct skeluser *u, *ul=NULL;
+ struct localuser *u;
if (!data) {
ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
return -1;
}
- if (!(u=malloc(sizeof(struct skeluser)))) {
- ast_log(LOG_WARNING, "Out of memory\n");
- return -1;
- }
- pthread_mutex_lock(&skellock);
- u->chan = chan;
- u->next = users;
- users = u;
- usecnt++;
- pthread_mutex_unlock(&skellock);
+ LOCAL_USER_ADD(u);
/* Do our thing here */
- pthread_mutex_lock(&skellock);
- u = users;
- while(u) {
- if (ul)
- ul->next = u->next;
- else
- users = u->next;
- u = u->next;
- }
- usecnt--;
- pthread_mutex_unlock(&skellock);
+ LOCAL_USER_REMOVE(u);
return res;
}
int unload_module(void)
{
- struct skeluser *u;
- pthread_mutex_lock(&skellock);
- u = users;
- while(u) {
- /* Hang up anybody who is using us */
- ast_softhangup(u->chan);
- u = u->next;
- }
- pthread_mutex_unlock(&skellock);
+ STANDARD_HANGUP_LOCALUSERS;
return ast_unregister_application(app);
}
@@ -95,8 +65,6 @@ char *description(void)
int usecount(void)
{
int res;
- pthread_mutex_lock(&skellock);
- res = usecnt;
- pthread_mutex_unlock(&skellock);
+ STANDARD_USECOUNT(res);
return res;
}