mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
Add application to log user data to the CDRs
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1926 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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
|
||||
|
108
apps/app_setcdruserfield.c
Executable file
108
apps/app_setcdruserfield.c
Executable file
@@ -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;
|
||||
}
|
21
cdr.c
21
cdr.c
@@ -345,6 +345,27 @@ int ast_cdr_setaccount(struct ast_channel *chan, char *account)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_cdr_setuserfield(struct ast_channel *chan, char *userfield)
|
||||
{
|
||||
struct ast_cdr *cdr = chan->cdr;
|
||||
|
||||
if (cdr)
|
||||
strncpy(cdr->userfield, userfield, sizeof(cdr->userfield) - 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_cdr_appenduserfield(struct ast_channel *chan, char *userfield)
|
||||
{
|
||||
struct ast_cdr *cdr = chan->cdr;
|
||||
|
||||
if (cdr)
|
||||
{
|
||||
int len = strlen(cdr->userfield);
|
||||
strncpy(cdr->userfield+len, userfield, sizeof(cdr->userfield) - len - 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_cdr_update(struct ast_channel *c)
|
||||
{
|
||||
struct ast_cdr *cdr = c->cdr;
|
||||
|
@@ -28,7 +28,9 @@
|
||||
//! AMA Flags
|
||||
#define AST_CDR_OMIT (1)
|
||||
#define AST_CDR_BILLING (2)
|
||||
#define AST_CDR_DOCUMENTATION (3)
|
||||
#define AST_CDR_DOCUMENTATION (3)
|
||||
|
||||
#define AST_MAX_USER_FIELD 256
|
||||
|
||||
struct ast_channel;
|
||||
|
||||
@@ -70,6 +72,8 @@ struct ast_cdr {
|
||||
int posted;
|
||||
/* Unique Channel Identifier */
|
||||
char uniqueid[32];
|
||||
/* User field */
|
||||
char userfield[AST_MAX_USER_FIELD];
|
||||
};
|
||||
|
||||
typedef int (*ast_cdrbe)(struct ast_cdr *cdr);
|
||||
@@ -224,6 +228,12 @@ extern void ast_cdr_reset(struct ast_cdr *cdr, int post);
|
||||
extern char *ast_cdr_flags2str(int flags);
|
||||
|
||||
extern int ast_cdr_setaccount(struct ast_channel *chan, char *account);
|
||||
|
||||
|
||||
extern int ast_cdr_setuserfield(struct ast_channel *chan, char *userfield);
|
||||
extern int ast_cdr_appenduserfield(struct ast_channel *chan, char *userfield);
|
||||
|
||||
|
||||
/* Update CDR on a channel */
|
||||
extern int ast_cdr_update(struct ast_channel *chan);
|
||||
|
||||
|
Reference in New Issue
Block a user