#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/cdr.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
Go to the source code of this file.
Enumerations | |
enum | { OPT_SETANS = (1 << 0), OPT_SETDISP = (1 << 1), OPT_RESETDEST = (1 << 2), OPT_ENDCDR = (1 << 3), OPT_NORESET = (1 << 4), OPT_KEEPVARS = (1 << 5), OPT_VARSET = (1 << 6), OPT_ANSLOCK = (1 << 7), OPT_DONTOUCH = (1 << 8) } |
enum | { OPT_ARG_VARSET = 0, OPT_ARG_ARRAY_SIZE } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static void | ast_cdr_fork (struct ast_channel *chan, struct ast_flags optflags, char *set) |
static int | forkcdr_exec (struct ast_channel *chan, void *data) |
static int | load_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Fork The CDR into 2 separate entities" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } |
static char * | app = "ForkCDR" |
static struct ast_module_info * | ast_module_info = &__mod_info |
static char * | descrip |
static struct ast_app_option | forkcdr_exec_options [128] = { [ 'a' ] = { .flag = OPT_SETANS }, [ 'A' ] = { .flag = OPT_ANSLOCK }, [ 'd' ] = { .flag = OPT_SETDISP }, [ 'D' ] = { .flag = OPT_RESETDEST }, [ 'e' ] = { .flag = OPT_ENDCDR }, [ 'R' ] = { .flag = OPT_NORESET }, [ 's' ] = { .flag = OPT_VARSET , .arg_index = OPT_ARG_VARSET + 1 }, [ 'T' ] = { .flag = OPT_DONTOUCH }, [ 'v' ] = { .flag = OPT_KEEPVARS },} |
static char * | synopsis |
Definition in file app_forkcdr.c.
anonymous enum |
OPT_SETANS | |
OPT_SETDISP | |
OPT_RESETDEST | |
OPT_ENDCDR | |
OPT_NORESET | |
OPT_KEEPVARS | |
OPT_VARSET | |
OPT_ANSLOCK | |
OPT_DONTOUCH |
Definition at line 126 of file app_forkcdr.c.
00126 { 00127 OPT_SETANS = (1 << 0), 00128 OPT_SETDISP = (1 << 1), 00129 OPT_RESETDEST = (1 << 2), 00130 OPT_ENDCDR = (1 << 3), 00131 OPT_NORESET = (1 << 4), 00132 OPT_KEEPVARS = (1 << 5), 00133 OPT_VARSET = (1 << 6), 00134 OPT_ANSLOCK = (1 << 7), 00135 OPT_DONTOUCH = (1 << 8), 00136 };
anonymous enum |
Definition at line 138 of file app_forkcdr.c.
00138 { 00139 OPT_ARG_VARSET = 0, 00140 /* note: this entry _MUST_ be the last one in the enum */ 00141 OPT_ARG_ARRAY_SIZE, 00142 };
static void __reg_module | ( | void | ) | [static] |
Definition at line 253 of file app_forkcdr.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 253 of file app_forkcdr.c.
static void ast_cdr_fork | ( | struct ast_channel * | chan, | |
struct ast_flags | optflags, | |||
char * | set | |||
) | [static] |
Definition at line 156 of file app_forkcdr.c.
References ast_cdr_append(), ast_cdr_dup(), ast_cdr_end(), AST_CDR_FLAG_ANSLOCKED, AST_CDR_FLAG_CHILD, AST_CDR_FLAG_DONT_TOUCH, AST_CDR_FLAG_KEEP_VARS, AST_CDR_FLAG_LOCKED, ast_cdr_free_vars(), ast_cdr_reset(), ast_cdr_setvar(), ast_set_flag, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_tvzero(), ast_channel::cdr, chan, ast_flags::flags, ast_cdr::next, OPT_ANSLOCK, OPT_DONTOUCH, OPT_ENDCDR, OPT_NORESET, OPT_RESETDEST, OPT_SETANS, and OPT_SETDISP.
00157 { 00158 struct ast_cdr *cdr; 00159 struct ast_cdr *newcdr; 00160 struct ast_flags flags = { AST_CDR_FLAG_KEEP_VARS }; 00161 00162 cdr = chan->cdr; 00163 00164 while (cdr->next) 00165 cdr = cdr->next; 00166 00167 if (!(newcdr = ast_cdr_dup(cdr))) 00168 return; 00169 00170 ast_cdr_append(cdr, newcdr); 00171 00172 if (!ast_test_flag(&optflags, OPT_NORESET)) 00173 ast_cdr_reset(newcdr, &flags); 00174 00175 if (!ast_test_flag(cdr, AST_CDR_FLAG_KEEP_VARS)) 00176 ast_cdr_free_vars(cdr, 0); 00177 00178 if (!ast_strlen_zero(set)) { 00179 char *varname = ast_strdupa(set), *varval; 00180 varval = strchr(varname,'='); 00181 if (varval) { 00182 *varval = 0; 00183 varval++; 00184 ast_cdr_setvar(cdr, varname, varval, 0); 00185 } 00186 } 00187 00188 if (ast_test_flag(&optflags, OPT_SETANS) && !ast_tvzero(cdr->answer)) 00189 newcdr->answer = newcdr->start; 00190 00191 if (ast_test_flag(&optflags, OPT_SETDISP)) 00192 newcdr->disposition = cdr->disposition; 00193 00194 if (ast_test_flag(&optflags, OPT_RESETDEST)) 00195 newcdr->dstchannel[0] = 0; 00196 00197 if (ast_test_flag(&optflags, OPT_ENDCDR)) 00198 ast_cdr_end(cdr); 00199 00200 if (ast_test_flag(&optflags, OPT_ANSLOCK)) 00201 ast_set_flag(cdr, AST_CDR_FLAG_ANSLOCKED); 00202 00203 if (ast_test_flag(&optflags, OPT_DONTOUCH)) 00204 ast_set_flag(cdr, AST_CDR_FLAG_DONT_TOUCH); 00205 00206 ast_set_flag(cdr, AST_CDR_FLAG_CHILD | AST_CDR_FLAG_LOCKED); 00207 }
static int forkcdr_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 209 of file app_forkcdr.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_channel::cdr, chan, ast_flags::flags, LOG_WARNING, and OPT_ARG_ARRAY_SIZE.
Referenced by load_module().
00210 { 00211 int res = 0; 00212 char *argcopy = NULL; 00213 struct ast_flags flags = {0}; 00214 char *opts[OPT_ARG_ARRAY_SIZE]; 00215 AST_DECLARE_APP_ARGS(arglist, 00216 AST_APP_ARG(options); 00217 ); 00218 00219 if (!chan->cdr) { 00220 ast_log(LOG_WARNING, "Channel does not have a CDR\n"); 00221 return 0; 00222 } 00223 00224 argcopy = ast_strdupa(data); 00225 00226 AST_STANDARD_APP_ARGS(arglist, argcopy); 00227 00228 opts[OPT_ARG_VARSET] = 0; 00229 00230 if (!ast_strlen_zero(arglist.options)) 00231 ast_app_parse_options(forkcdr_exec_options, &flags, opts, arglist.options); 00232 00233 if (!ast_strlen_zero(data)) { 00234 int keepvars = ast_test_flag(&flags, OPT_KEEPVARS) ? 1 : 0; 00235 ast_set2_flag(chan->cdr, keepvars, AST_CDR_FLAG_KEEP_VARS); 00236 } 00237 00238 ast_cdr_fork(chan, flags, opts[OPT_ARG_VARSET]); 00239 00240 return res; 00241 }
static int load_module | ( | void | ) | [static] |
Definition at line 248 of file app_forkcdr.c.
References ast_register_application, and forkcdr_exec().
00249 { 00250 return ast_register_application(app, forkcdr_exec, synopsis, descrip); 00251 }
static int unload_module | ( | void | ) | [static] |
Definition at line 243 of file app_forkcdr.c.
References ast_unregister_application().
00244 { 00245 return ast_unregister_application(app); 00246 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Fork The CDR into 2 separate entities" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 253 of file app_forkcdr.c.
char* app = "ForkCDR" [static] |
Definition at line 40 of file app_forkcdr.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 253 of file app_forkcdr.c.
char* descrip [static] |
Definition at line 43 of file app_forkcdr.c.
struct ast_app_option forkcdr_exec_options[128] = { [ 'a' ] = { .flag = OPT_SETANS }, [ 'A' ] = { .flag = OPT_ANSLOCK }, [ 'd' ] = { .flag = OPT_SETDISP }, [ 'D' ] = { .flag = OPT_RESETDEST }, [ 'e' ] = { .flag = OPT_ENDCDR }, [ 'R' ] = { .flag = OPT_NORESET }, [ 's' ] = { .flag = OPT_VARSET , .arg_index = OPT_ARG_VARSET + 1 }, [ 'T' ] = { .flag = OPT_DONTOUCH }, [ 'v' ] = { .flag = OPT_KEEPVARS },} [static] |
Definition at line 154 of file app_forkcdr.c.
char* synopsis [static] |