static void ast_cdr_clone(struct ast_cdr *cdr) { struct ast_cdr *newcdr = ast_cdr_alloc(); memcpy(newcdr,cdr,sizeof(struct ast_cdr)); ast_cdr_append(cdr,newcdr); gettimeofday(&newcdr->start, NULL); memset(&newcdr->answer, 0, sizeof(newcdr->answer)); ast_cdr_add_flag(cdr,AST_CDR_FLAG_CHILD|AST_CDR_FLAG_LOCKED); }
static int start_monitor_exec(struct ast_channel *chan, void *data) { char *arg = NULL; char *format = NULL; char *fname_base = NULL; char *options = NULL; char *delay = NULL; char *urlprefix = NULL; char tmp[256]; int joinfiles = 0; int waitforbridge = 0; int res = 0; /* Parse arguments. */ if (!ast_strlen_zero((char*)data)) { arg = ast_strdupa((char*)data); format = arg; fname_base = strchr(arg, '|'); if (fname_base) { *fname_base = 0; fname_base++; if ((options = strchr(fname_base, '|'))) { *options = 0; options++; if (strchr(options, 'm')) joinfiles = 1; if (strchr(options, 'b')) waitforbridge = 1; } } arg = strchr(format,':'); if (arg) { *arg++ = 0; urlprefix = arg; } } if (urlprefix) { snprintf(tmp,sizeof(tmp) - 1,"%s/%s.%s",urlprefix,fname_base, ((strcmp(format,"gsm")) ? "wav" : "gsm")); if (!chan->cdr && !(chan->cdr = ast_cdr_alloc())) return -1; ast_cdr_setuserfield(chan, tmp); } if (waitforbridge) { /* We must remove the "b" option if listed. In principle none of the following could give NULL results, but we check just to be pedantic. Reconstructing with checks for 'm' option does not work if we end up adding more options than 'm' in the future. */ delay = ast_strdupa(data); options = strrchr(delay, '|'); if (options) { arg = strchr(options, 'b'); if (arg) { *arg = 'X'; pbx_builtin_setvar_helper(chan,"AUTO_MONITOR",delay); } } return 0; } res = ast_monitor_start(chan, format, fname_base, 1); if (res < 0) res = ast_monitor_change_fname(chan, fname_base, 1); ast_monitor_setjoinfiles(chan, joinfiles); return res; }