226 struct timeval time = { 0 };
240 if (sscanf(tempbuf,
"%ld.%ld", &tv_sec, &tv_usec) == 2) {
241 time.tv_sec = tv_sec;
242 time.tv_usec = tv_usec;
268 output = payload->
data;
273 payload->
cmd, payload->
cmd);
296 && (!strcasecmp(
"billsec",
args.variable) || !strcasecmp(
"duration",
args.variable))) {
310 snprintf(tempbuf,
sizeof(tempbuf),
"%lf", delta);
313 if (!strcasecmp(
"start",
args.variable)
314 || !strcasecmp(
"end",
args.variable)
315 || !strcasecmp(
"answer",
args.variable)) {
316 struct timeval fmt_time;
322 if (sscanf(tempbuf,
"%ld.%ld", &tv_sec, &tv_usec) != 2) {
328 fmt_time.tv_sec = tv_sec;
329 fmt_time.tv_usec = tv_usec;
331 ast_strftime(tempbuf,
sizeof(tempbuf),
"%Y-%m-%d %T", &tm);
335 }
else if (!strcasecmp(
"disposition",
args.variable)) {
338 if (sscanf(tempbuf,
"%8d", &disposition) != 1) {
344 }
else if (!strcasecmp(
"amaflags",
args.variable)) {
347 if (sscanf(tempbuf,
"%8d", &
amaflags) != 1) {
377 || !payload->
value) {
392 && strcasecmp(
args.variable,
"peeraccount")
393 && strcasecmp(
args.variable,
"amaflags"));
395 if (!strcasecmp(
args.variable,
"userfield")) {
422 payload->
cmd, payload->
cmd);
427 payload->
cmd, payload->
cmd);
433 if (!strcasecmp(
"party_a",
args.variable)) {
435 }
else if (!strcasecmp(
"disable",
args.variable)) {
462 if (!cdr_read_message_type()) {
472 payload->chan = chan;
474 payload->arguments = parse;
475 payload->
data = &output;
539 if (!strcasecmp(
args.variable,
"accountcode")) {
540 ast_log(
LOG_WARNING,
"Using the %s function to set 'accountcode' is deprecated. Please use the CHANNEL function instead.\n",
543 ast_channel_accountcode_set(chan,
value);
547 if (!strcasecmp(
args.variable,
"amaflags")) {
550 ast_log(
LOG_WARNING,
"Using the %s function to set 'amaflags' is deprecated. Please use the CHANNEL function instead.\n",
552 if (isdigit(*
value)) {
564 if (!strcasecmp(
args.variable,
"peeraccount")) {
565 ast_log(
LOG_WARNING,
"The 'peeraccount' setting is not supported. Please set the 'accountcode' on the appropriate channel using the CHANNEL function.\n");
570 if (!cdr_write_message_type()) {
571 ast_log(
LOG_WARNING,
"Failed to manipulate CDR for channel %s: message type not available\n",
580 payload->
chan = chan;
588 ast_log(
LOG_WARNING,
"Failed to manipulate CDR for channel %s: unable to create message\n",
624 if (!cdr_prop_write_message_type()) {
634 payload->chan = chan;
636 payload->arguments = parse;
637 payload->value =
value;
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ao2_alloc(data_size, destructor_fn)
void ast_cdr_setuserfield(const char *channel_name, const char *userfield)
Set CDR user field for channel (stored in CDR)
struct stasis_message_router * ast_cdr_message_router(void)
Return the message router for the CDR engine.
int ast_cdr_clear_property(const char *channel_name, enum ast_cdr_options option)
Clear a property on a CDR for a channel.
int ast_cdr_setvar(const char *channel_name, const char *name, const char *value)
Set a variable on a CDR.
void ast_cdr_format_var(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int raw)
Format a CDR variable from an already posted CDR.
ast_cdr_options
CDR manipulation options. Certain function calls will manipulate the state of a CDR object based on t...
@ AST_CDR_FLAG_DISABLE_ALL
int ast_cdr_getvar(const char *channel_name, const char *name, char *value, size_t length)
Retrieve a CDR variable from a channel's current CDR.
const char * ast_cdr_disp2str(int disposition)
Disposition to a string.
int ast_cdr_set_property(const char *channel_name, enum ast_cdr_options option)
Set a property on a CDR for a channel.
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_lock(chan)
struct ast_cdr * ast_channel_cdr(const struct ast_channel *chan)
const char * ast_channel_amaflags2string(enum ama_flags flags)
Convert the enum representation of an AMA flag to a string representation.
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
enum ama_flags ast_channel_string2amaflag(const char *flag)
Convert a string to a detail record AMA flag.
#define ast_channel_unlock(chan)
static void cdr_read_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
STASIS_MESSAGE_TYPE_DEFN_LOCAL(cdr_read_message_type)
static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static const struct ast_app_option cdr_func_options[128]
static void cdr_prop_write_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static struct ast_custom_function cdr_prop_function
static int cdr_prop_write(struct ast_channel *chan, const char *cmd, char *parse, const char *value)
static void cdr_write_callback(void *data, struct stasis_subscription *sub, struct stasis_message *message)
static int cdr_write(struct ast_channel *chan, const char *cmd, char *arguments, const char *value)
static struct timeval cdr_retrieve_time(struct ast_channel *chan, const char *time_name)
static int load_module(void)
static int unload_module(void)
static struct ast_custom_function cdr_function
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
struct ast_tm * ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone)
Timezone-independent version of localtime_r(3).
int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm)
Special version of strftime(3) that handles fractions of a second. Takes the same arguments as strfti...
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Core PBX routines and definitions.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static struct stasis_message_router * router
struct stasis_forward * sub
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_message_router_remove(struct stasis_message_router *router, struct stasis_message_type *message_type)
Remove a route from a message router.
int stasis_message_router_add(struct stasis_message_router *router, struct stasis_message_type *message_type, stasis_subscription_cb callback, void *data)
Add a route to a message router.
void stasis_message_router_publish_sync(struct stasis_message_router *router, struct stasis_message *message)
Publish a message to a message router's subscription synchronously.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure used to handle boolean flags.
struct ast_channel * chan
int64_t ast_tvdiff_us(struct timeval end, struct timeval start)
Computes the difference (in microseconds) between two struct timeval instances.
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_set_flag(p, flag)