#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk.h"
#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"
Include dependency graph for app_datetime.c:
Go to the source code of this file.
Functions | |
static int | datetime_exec (struct ast_channel *chan, void *data) |
char * | description (void) |
Provides a description of the module. | |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
static char * | app = "DateTime" |
static char * | descrip |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | synopsis = "Say the date and time" |
static char * | tdesc = "Date and Time" |
Definition in file app_datetime.c.
|
Definition at line 55 of file app_datetime.c. References ast_channel::_state, ast_answer(), ast_say_datetime(), AST_STATE_UP, localuser::chan, ast_channel::language, LOCAL_USER_ADD, LOCAL_USER_REMOVE, and t. Referenced by load_module(). 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 }
|
|
Provides a description of the module.
Definition at line 86 of file app_datetime.c. 00087 { 00088 return tdesc; 00089 }
|
|
Returns the ASTERISK_GPL_KEY. This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:
char *key(void) { return ASTERISK_GPL_KEY; }
Definition at line 98 of file app_datetime.c. References ASTERISK_GPL_KEY. 00099 { 00100 return ASTERISK_GPL_KEY; 00101 }
|
|
Initialize the module. Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
Definition at line 81 of file app_datetime.c. References ast_register_application(), and datetime_exec(). 00082 { 00083 return ast_register_application(app, datetime_exec, synopsis, descrip); 00084 }
|
|
Cleanup all module structures, sockets, etc. This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).
Definition at line 70 of file app_datetime.c. References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS. 00071 { 00072 int res; 00073 00074 res = ast_unregister_application(app); 00075 00076 STANDARD_HANGUP_LOCALUSERS; 00077 00078 return res; 00079 }
|
|
Provides a usecount. This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.
Definition at line 91 of file app_datetime.c. References STANDARD_USECOUNT. 00092 { 00093 int res; 00094 STANDARD_USECOUNT(res); 00095 return res; 00096 }
|
|
Definition at line 44 of file app_datetime.c. |
|
Initial value:
" DateTime(): This application will say the current date and time.\n"
Definition at line 48 of file app_datetime.c. |
|
Definition at line 53 of file app_datetime.c. |
|
Definition at line 51 of file app_datetime.c. |
|
Definition at line 46 of file app_datetime.c. |
|
Definition at line 42 of file app_datetime.c. |