aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_sayunixtime.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-15 00:33:07 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-15 00:33:07 +0000
commit987242db6a6728ad66fb358f775cd490cdef96a3 (patch)
treefa1f483fb886da6f31d60eecc54aa66519d90cfc /apps/app_sayunixtime.c
parent15db46a445a4d6d71993475369b4a4906861f362 (diff)
update app to use args parser
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@10106 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_sayunixtime.c')
-rw-r--r--apps/app_sayunixtime.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/apps/app_sayunixtime.c b/apps/app_sayunixtime.c
index ad96c6d6f..9e0a0747d 100644
--- a/apps/app_sayunixtime.c
+++ b/apps/app_sayunixtime.c
@@ -2,6 +2,7 @@
* Asterisk -- An open source telephony toolkit.
*
* Copyright (c) 2003 Tilghman Lesher. All rights reserved.
+ * Copyright (c) 2006 Digium, Inc.
*
* Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>
*
@@ -40,7 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/say.h"
-
+#include "asterisk/app.h"
static char *tdesc = "Say time";
@@ -72,34 +73,39 @@ LOCAL_USER_DECL;
static int sayunixtime_exec(struct ast_channel *chan, void *data)
{
- int res=0;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(timeval);
+ AST_APP_ARG(timezone);
+ AST_APP_ARG(format);
+ );
+ char *parse;
+ int res = 0;
struct localuser *u;
- char *s,*zone=NULL,*timec,*format;
time_t unixtime;
- s = ast_strdupa(data);
- if (!s)
- return data ? -1 : 0;
+ if (!data)
+ return 0;
+
+ if (!(parse = ast_strdupa(data)))
+ return -1;
+
LOCAL_USER_ADD(u);
- format = "c"; /* default datetime */
+ args.format = "c"; /* default datetime */
- timec = strsep(&s,"|");
- ast_get_time_t(timec, &unixtime, time(NULL));
- if (s) {
- zone = strsep(&s,"|");
- if (ast_strlen_zero(zone))
- zone = NULL;
- }
- if (s) /* override format */
- format = s;
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ ast_get_time_t(args.timeval, &unixtime, time(NULL));
if (chan->_state != AST_STATE_UP)
res = ast_answer(chan);
+
if (!res)
- res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY, chan->language, format, zone);
+ res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY,
+ chan->language, args.format, args.timezone);
LOCAL_USER_REMOVE(u);
+
return res;
}