2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Anthony Minessale anthmct@yahoo.com
5 * Development of this app Sponsered/Funded by TAAN Softworks Corp
7 * See http://www.asterisk.org for more information about
8 * the Asterisk project. Please do not directly contact
9 * any of the maintainers of this project for assistance;
10 * the project provides a web site, mailing lists and IRC
11 * channels for your use.
13 * This program is free software, distributed under the terms of
14 * the GNU General Public License Version 2. See the LICENSE file
15 * at the top of the source tree.
20 * \brief Fork CDR application
22 * \author Anthony Minessale anthmct@yahoo.com
24 * \note Development of this app Sponsored/Funded by TAAN Softworks Corp
26 * \ingroup applications
31 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
33 #include "asterisk/file.h"
34 #include "asterisk/channel.h"
35 #include "asterisk/pbx.h"
36 #include "asterisk/cdr.h"
37 #include "asterisk/module.h"
39 static char *app
= "ForkCDR";
40 static char *synopsis
=
41 "Forks the Call Data Record";
42 static char *descrip
=
43 " ForkCDR([options]): Causes the Call Data Record to fork an additional\n"
44 "cdr record starting from the time of the fork call\n"
46 " v - If the option is passed all cdr variables will be passed along also.\n";
49 static void ast_cdr_fork(struct ast_channel
*chan
)
52 struct ast_cdr
*newcdr
;
53 struct ast_flags flags
= { AST_CDR_FLAG_KEEP_VARS
};
60 if (!(newcdr
= ast_cdr_dup(cdr
)))
63 ast_cdr_append(cdr
, newcdr
);
64 ast_cdr_reset(newcdr
, &flags
);
66 if (!ast_test_flag(cdr
, AST_CDR_FLAG_KEEP_VARS
))
67 ast_cdr_free_vars(cdr
, 0);
69 ast_set_flag(cdr
, AST_CDR_FLAG_CHILD
| AST_CDR_FLAG_LOCKED
);
72 static int forkcdr_exec(struct ast_channel
*chan
, void *data
)
77 ast_log(LOG_WARNING
, "Channel does not have a CDR\n");
81 if (!ast_strlen_zero(data
))
82 ast_set2_flag(chan
->cdr
, strchr(data
, 'v'), AST_CDR_FLAG_KEEP_VARS
);
89 static int unload_module(void)
91 return ast_unregister_application(app
);
94 static int load_module(void)
96 return ast_register_application(app
, forkcdr_exec
, synopsis
, descrip
);
99 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Fork The CDR into 2 separate entities");