00001 /* 00002 * Asterisk -- An open source telephony toolkit. 00003 * 00004 * Copyright (C) 1999 - 2005, Digium, Inc. 00005 * 00006 * Mark Spencer <markster@digium.com> 00007 * 00008 * See http://www.asterisk.org for more information about 00009 * the Asterisk project. Please do not directly contact 00010 * any of the maintainers of this project for assistance; 00011 * the project provides a web site, mailing lists and IRC 00012 * channels for your use. 00013 * 00014 * This program is free software, distributed under the terms of 00015 * the GNU General Public License Version 2. See the LICENSE file 00016 * at the top of the source tree. 00017 */ 00018 00019 /*! \file 00020 * \brief Time of day - Report the time of day 00021 * 00022 * \ingroup applications 00023 */ 00024 00025 #include <stdio.h> 00026 #include <stdlib.h> 00027 #include <unistd.h> 00028 #include <string.h> 00029 00030 #include "asterisk.h" 00031 00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $") 00033 00034 #include "asterisk/lock.h" 00035 #include "asterisk/file.h" 00036 #include "asterisk/logger.h" 00037 #include "asterisk/channel.h" 00038 #include "asterisk/pbx.h" 00039 #include "asterisk/module.h" 00040 #include "asterisk/say.h" 00041 00042 static char *tdesc = "Date and Time"; 00043 00044 static char *app = "DateTime"; 00045 00046 static char *synopsis = "Say the date and time"; 00047 00048 static char *descrip = 00049 " DateTime(): This application will say the current date and time.\n"; 00050 00051 STANDARD_LOCAL_USER; 00052 00053 LOCAL_USER_DECL; 00054 00055 static int datetime_exec(struct ast_channel *chan, void *data) 00056 { 00057 int res=0; 00058 time_t t; 00059 struct localuser *u; 00060 LOCAL_USER_ADD(u); 00061 time(&t); 00062 if (chan->_state != AST_STATE_UP) 00063 res = ast_answer(chan); 00064 if (!res) 00065 res = ast_say_datetime(chan, t, "", chan->language); 00066 LOCAL_USER_REMOVE(u); 00067 return res; 00068 } 00069 00070 int unload_module(void) 00071 { 00072 int res; 00073 00074 res = ast_unregister_application(app); 00075 00076 STANDARD_HANGUP_LOCALUSERS; 00077 00078 return res; 00079 } 00080 00081 int load_module(void) 00082 { 00083 return ast_register_application(app, datetime_exec, synopsis, descrip); 00084 } 00085 00086 char *description(void) 00087 { 00088 return tdesc; 00089 } 00090 00091 int usecount(void) 00092 { 00093 int res; 00094 STANDARD_USECOUNT(res); 00095 return res; 00096 } 00097 00098 char *key() 00099 { 00100 return ASTERISK_GPL_KEY; 00101 }