aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjeremy <jeremy@f38db490-d61c-443f-a65b-d21fe96a405b>2004-01-11 03:23:05 +0000
committerjeremy <jeremy@f38db490-d61c-443f-a65b-d21fe96a405b>2004-01-11 03:23:05 +0000
commit1e95d9f6d07e3095fe03886a354e365e6e0cd29e (patch)
tree049baba6d719dc0dc88fa2a52d61748b1f33ec44 /apps
parent3cf6141b4b8a21f1378b3c676187655e4db5b467 (diff)
Add application to log user data to the CDRs
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1926 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-xapps/Makefile2
-rwxr-xr-xapps/app_setcdruserfield.c108
2 files changed, 109 insertions, 1 deletions
diff --git a/apps/Makefile b/apps/Makefile
index e5a50c050..e1f22a18d 100755
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -24,7 +24,7 @@ APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
app_authenticate.so app_softhangup.so app_lookupblacklist.so \
app_waitforring.so app_privacy.so app_db.so app_chanisavail.so \
app_enumlookup.so app_transfer.so app_setcidnum.so app_cdr.so \
- app_hasnewvoicemail.so app_sayunixtime.so app_cut.so app_read.so
+ app_hasnewvoicemail.so app_sayunixtime.so app_cut.so app_read.so app_setcdruserfield.so
ifneq (${OSARCH},Darwin)
APPS+=app_intercom.so
diff --git a/apps/app_setcdruserfield.c b/apps/app_setcdruserfield.c
new file mode 100755
index 000000000..19eb1d4e3
--- /dev/null
+++ b/apps/app_setcdruserfield.c
@@ -0,0 +1,108 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Applictions connected with CDR engine
+ *
+ * Copyright (C) 2003, Digium
+ *
+ * Justin Huff <jjhuff@mspin.net>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+#include <sys/types.h>
+#include <asterisk/channel.h>
+#include <asterisk/cdr.h>
+#include <asterisk/module.h>
+#include <asterisk/pbx.h>
+#include <asterisk/logger.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+
+static char *tdesc = "CDR user field apps";
+
+static char *setcdruserfield_descrip =
+ "SetCDRUserField(value): Set the CDR user field to value\n";
+
+static char *setcdruserfield_app = "SetCDRUserField";
+static char *setcdruserfield_synopsis = "Set the CDR user field";
+
+static char *appendcdruserfield_descrip =
+ "AppendCDRUserField(value): Append value to the CDR user field\n";
+
+static char *appendcdruserfield_app = "AppendCDRUserField";
+static char *appendcdruserfield_synopsis = "Append to the CDR user field";
+
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
+static int setcdruserfield_exec(struct ast_channel *chan, void *data)
+{
+ struct localuser *u;
+ int res = 0;
+
+ LOCAL_USER_ADD(u)
+ if (chan->cdr && data)
+ {
+ ast_cdr_setuserfield(chan, (char*)data);
+ }
+
+ LOCAL_USER_REMOVE(u);
+
+ return res;
+}
+
+static int appendcdruserfield_exec(struct ast_channel *chan, void *data)
+{
+ struct localuser *u;
+ int res = 0;
+
+ LOCAL_USER_ADD(u)
+ if (chan->cdr && data)
+ {
+ ast_cdr_appenduserfield(chan, (char*)data);
+ }
+
+ LOCAL_USER_REMOVE(u);
+
+ return res;
+}
+
+int unload_module(void)
+{
+ int res;
+ STANDARD_HANGUP_LOCALUSERS;
+ res = ast_unregister_application(setcdruserfield_app);
+ res |= ast_unregister_application(appendcdruserfield_app);
+ return res;
+}
+
+int load_module(void)
+{
+ int res;
+ res = ast_register_application(setcdruserfield_app, setcdruserfield_exec, setcdruserfield_synopsis, setcdruserfield_descrip);
+ res |= ast_register_application(appendcdruserfield_app, appendcdruserfield_exec, appendcdruserfield_synopsis, appendcdruserfield_descrip);
+
+ return res;
+}
+
+char *description(void)
+{
+ return tdesc;
+}
+
+int usecount(void)
+{
+ int res;
+ STANDARD_USECOUNT(res);
+ return res;
+}
+
+char *key()
+{
+ return ASTERISK_GPL_KEY;
+}