diff options
author | root <root@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-09-08 00:02:42 +0000 |
---|---|---|
committer | root <root@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-09-08 00:02:42 +0000 |
commit | 0345676c7e2b9a8463e8d9b7ea692ed4ca7f2ec3 (patch) | |
tree | 39d30c1e5ef21070a148f5945ab9830c55b6d071 /apps | |
parent | 0dc5240868da6abae79d839e3cfa890233ce251f (diff) |
automerge commit
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2-netsec@42372 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_record.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/apps/app_record.c b/apps/app_record.c index 85310ea70..3101e22f4 100644 --- a/apps/app_record.c +++ b/apps/app_record.c @@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/dsp.h" #include "asterisk/utils.h" #include "asterisk/options.h" +#include "asterisk/app.h" static char *tdesc = "Trivial Record Application"; @@ -183,8 +184,35 @@ static int record_exec(struct ast_channel *chan, void *data) /* these are to allow the use of the %d in the config file for a wild card of sort to create a new file with the inputed name scheme */ if (percentflag) { + AST_DECLARE_APP_ARGS(fname, + AST_APP_ARG(piece)[100]; + ); + char *tmp2 = ast_strdupa(filename); + char countstring[15]; + int i; + + /* Separate each piece out by the format specifier */ + /* AST_NONSTANDARD_APP_ARGS(fname, tmp2, '%'); */ + fname.argc = ast_app_separate_args(tmp2, '%', fname.argv, (sizeof(fname) - sizeof(fname.argc)) / sizeof(fname.argv[0])); do { - snprintf(tmp, sizeof(tmp), filename, count); + int tmplen; + /* First piece has no leading percent, so it's copied verbatim */ + ast_copy_string(tmp, fname.piece[0], sizeof(tmp)); + tmplen = strlen(tmp); + for (i = 1; i < fname.argc; i++) { + if (fname.piece[i][0] == 'd') { + /* Substitute the count */ + snprintf(countstring, sizeof(countstring), "%d", count); + ast_copy_string(tmp + tmplen, countstring, sizeof(tmp) - tmplen); + tmplen += strlen(countstring); + } else if (tmplen + 2 < sizeof(tmp)) { + /* Unknown format specifier - just copy it verbatim */ + tmp[tmplen++] = '%'; + tmp[tmplen++] = fname.piece[i][0]; + } + /* Copy the remaining portion of the piece */ + ast_copy_string(tmp + tmplen, &(fname.piece[i][1]), sizeof(tmp) - tmplen); + } count++; } while ( ast_fileexists(tmp, ext, chan->language) != -1 ); pbx_builtin_setvar_helper(chan, "RECORDED_FILE", tmp); |