2002-07-12 09:03:50 +00:00
|
|
|
/*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2002-07-12 09:03:50 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* Copyright (C) 1999 - 2005, Digium, Inc.
|
|
|
|
*
|
|
|
|
* Mark Spencer <markster@digium.com>
|
2002-07-12 09:03:50 +00:00
|
|
|
*
|
2005-09-14 20:46:50 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
2002-07-12 09:03:50 +00:00
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
2005-09-14 20:46:50 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
|
|
|
* \brief Time of day - Report the time of day
|
2005-09-14 20:46:50 +00:00
|
|
|
*
|
2005-11-06 15:09:47 +00:00
|
|
|
* \ingroup applications
|
2002-07-12 09:03:50 +00:00
|
|
|
*/
|
|
|
|
|
2005-11-08 19:47:56 +00:00
|
|
|
#include <stdio.h>
|
2005-06-06 22:39:32 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/lock.h"
|
|
|
|
#include "asterisk/file.h"
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/say.h"
|
2002-07-12 09:03:50 +00:00
|
|
|
|
|
|
|
static char *tdesc = "Date and Time";
|
|
|
|
|
|
|
|
static char *app = "DateTime";
|
|
|
|
|
|
|
|
static char *synopsis = "Say the date and time";
|
|
|
|
|
|
|
|
static char *descrip =
|
2005-11-11 13:34:38 +00:00
|
|
|
" DateTime(): This application will say the current date and time.\n";
|
2002-07-12 09:03:50 +00:00
|
|
|
|
|
|
|
STANDARD_LOCAL_USER;
|
|
|
|
|
|
|
|
LOCAL_USER_DECL;
|
|
|
|
|
|
|
|
static int datetime_exec(struct ast_channel *chan, void *data)
|
|
|
|
{
|
|
|
|
int res=0;
|
|
|
|
time_t t;
|
|
|
|
struct localuser *u;
|
|
|
|
LOCAL_USER_ADD(u);
|
|
|
|
time(&t);
|
|
|
|
if (chan->_state != AST_STATE_UP)
|
|
|
|
res = ast_answer(chan);
|
|
|
|
if (!res)
|
|
|
|
res = ast_say_datetime(chan, t, "", chan->language);
|
|
|
|
LOCAL_USER_REMOVE(u);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int unload_module(void)
|
|
|
|
{
|
2005-10-18 22:52:21 +00:00
|
|
|
int res;
|
|
|
|
|
|
|
|
res = ast_unregister_application(app);
|
|
|
|
|
2002-07-12 09:03:50 +00:00
|
|
|
STANDARD_HANGUP_LOCALUSERS;
|
2005-10-18 22:52:21 +00:00
|
|
|
|
|
|
|
return res;
|
2002-07-12 09:03:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int load_module(void)
|
|
|
|
{
|
|
|
|
return ast_register_application(app, datetime_exec, synopsis, descrip);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *description(void)
|
|
|
|
{
|
|
|
|
return tdesc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usecount(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
STANDARD_USECOUNT(res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *key()
|
|
|
|
{
|
|
|
|
return ASTERISK_GPL_KEY;
|
|
|
|
}
|