aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-27 17:53:48 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-27 17:53:48 +0000
commit03bbccee125c7d4b6f8020d089bb1be9a5dde6e5 (patch)
tree6a23c1f8b86a0d3d96c2301133402a109d8333e1
parent7f522f36e698a01bb39aa033e7d0334223ebed86 (diff)
Bug 5237 - Optional filename argument
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7656 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_dictate.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/apps/app_dictate.c b/apps/app_dictate.c
index 91a1650ea..dfa1c4f34 100644
--- a/apps/app_dictate.c
+++ b/apps/app_dictate.c
@@ -47,7 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static char *tdesc = "Virtual Dictation Machine";
static char *app = "Dictate";
static char *synopsis = "Virtual Dictation Machine";
-static char *desc = " Dictate([<base_dir>])\n"
+static char *desc = " Dictate([<base_dir>[|<filename>]])\n"
"Start dictation machine using optional base dir for files.\n";
@@ -80,7 +80,7 @@ static int play_and_wait(struct ast_channel *chan, char *file, char *digits)
static int dictate_exec(struct ast_channel *chan, void *data)
{
- char *mydata, *argv[2], *path = NULL, filein[256];
+ char *mydata, *argv[3], *path = NULL, filein[256], *filename = "";
char dftbase[256];
char *base;
struct ast_flags flags = {0};
@@ -112,7 +112,9 @@ static int dictate_exec(struct ast_channel *chan, void *data)
} else {
base = dftbase;
}
-
+ if (argc && argv[1]) {
+ filename = argv[1];
+ }
oldr = chan->readformat;
if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
@@ -122,13 +124,17 @@ static int dictate_exec(struct ast_channel *chan, void *data)
ast_answer(chan);
ast_safe_sleep(chan, 200);
- for(res = 0; !res;) {
- if (ast_app_getdata(chan, "dictate/enter_filename", filein, sizeof(filein), 0) ||
- ast_strlen_zero(filein)) {
- res = -1;
- break;
+ for (res = 0; !res;) {
+ if (ast_strlen_zero(filename)) {
+ if (ast_app_getdata(chan, "dictate/enter_filename", filein, sizeof(filein), 0) ||
+ ast_strlen_zero(filein)) {
+ res = -1;
+ break;
+ }
+ } else {
+ ast_copy_string(filein, filename, sizeof(filein));
+ filename = "";
}
-
mkdir(base, 0755);
len = strlen(base) + strlen(filein) + 2;
if (!path || len > maxlen) {