Sat Apr 12 07:12:32 2008

Asterisk developer's documentation


app_sayunixtime.c File Reference

SayUnixTime application. More...

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/say.h"
#include "asterisk/app.h"

Include dependency graph for app_sayunixtime.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Say time")
static int load_module (void)
static int sayunixtime_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static char * app_datetime = "DateTime"
static char * app_sayunixtime = "SayUnixTime"
static char * datetime_descrip
static char * sayunixtime_descrip
static char * sayunixtime_synopsis = "Says a specified time in a custom format"


Detailed Description

SayUnixTime application.

Author:
Tilghman Lesher <app_sayunixtime__200309@the-tilghman.com>

Definition in file app_sayunixtime.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Say time"   
)

static int load_module ( void   )  [static]

static int sayunixtime_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 69 of file app_sayunixtime.c.

References ast_channel::_state, ast_answer(), AST_APP_ARG, AST_DECLARE_APP_ARGS, AST_DIGIT_ANY, ast_get_time_t(), ast_module_user_add, ast_module_user_remove, ast_say_date_with_format, AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, format, and parse().

Referenced by load_module().

00070 {
00071    AST_DECLARE_APP_ARGS(args,
00072               AST_APP_ARG(timeval);
00073               AST_APP_ARG(timezone);
00074               AST_APP_ARG(format);
00075    );
00076    char *parse;
00077    int res = 0;
00078    struct ast_module_user *u;
00079    time_t unixtime;
00080    
00081    if (!data)
00082       return 0;
00083 
00084    parse = ast_strdupa(data);
00085 
00086    u = ast_module_user_add(chan);
00087 
00088    AST_STANDARD_APP_ARGS(args, parse);
00089 
00090    ast_get_time_t(args.timeval, &unixtime, time(NULL), NULL);
00091 
00092    if (chan->_state != AST_STATE_UP)
00093       res = ast_answer(chan);
00094 
00095    if (!res)
00096       res = ast_say_date_with_format(chan, unixtime, AST_DIGIT_ANY,
00097                       chan->language, args.format, args.timezone);
00098 
00099    ast_module_user_remove(u);
00100 
00101    return res;
00102 }

static int unload_module ( void   )  [static]

Definition at line 104 of file app_sayunixtime.c.

References ast_module_user_hangup_all, and ast_unregister_application().

00105 {
00106    int res;
00107    
00108    res = ast_unregister_application(app_sayunixtime);
00109    res |= ast_unregister_application(app_datetime);
00110 
00111    ast_module_user_hangup_all();
00112    
00113    return res;
00114 }


Variable Documentation

char* app_datetime = "DateTime" [static]

Definition at line 47 of file app_sayunixtime.c.

char* app_sayunixtime = "SayUnixTime" [static]

Definition at line 46 of file app_sayunixtime.c.

char* datetime_descrip [static]

Definition at line 59 of file app_sayunixtime.c.

char* sayunixtime_descrip [static]

Definition at line 51 of file app_sayunixtime.c.

char* sayunixtime_synopsis = "Says a specified time in a custom format" [static]

Definition at line 49 of file app_sayunixtime.c.


Generated on Sat Apr 12 07:12:32 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.5