aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_skel.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>1999-10-22 01:49:23 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>1999-10-22 01:49:23 +0000
commit207fef0a48f458ca28b829b025a4ab2eace2a6aa (patch)
tree8f02fa11e00c4e3fcbf9d504c7ae6cda66c7694a /apps/app_skel.c
parent2ec4b6a459e8f18f6c7840ab77317cfd5290710e (diff)
Version 0.1.0 from FTP
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_skel.c')
-rwxr-xr-xapps/app_skel.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/apps/app_skel.c b/apps/app_skel.c
new file mode 100755
index 000000000..fd7594037
--- /dev/null
+++ b/apps/app_skel.c
@@ -0,0 +1,102 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Skeleton application
+ *
+ * Copyright (C) 1999, Adtran Inc. and Linux Support Services, LLC
+ *
+ * Mark Spencer <markster@linux-support.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <asterisk/file.h>
+#include <asterisk/logger.h>
+#include <asterisk/channel.h>
+#include <asterisk/pbx.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+
+#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;
+
+static int skel_exec(struct ast_channel *chan, void *data)
+{
+ int res=0;
+ struct skeluser *u, *ul=NULL;
+ 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);
+ /* 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);
+ 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);
+ return ast_unregister_application(app);
+}
+
+int load_module(void)
+{
+ return ast_register_application(app, skel_exec);
+}
+
+char *description(void)
+{
+ return tdesc;
+}
+
+int usecount(void)
+{
+ int res;
+ pthread_mutex_lock(&skellock);
+ res = usecnt;
+ pthread_mutex_unlock(&skellock);
+ return res;
+}