mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	Version 0.2.0 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@484 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		
							
								
								
									
										84
									
								
								apps/app_datetime.c
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										84
									
								
								apps/app_datetime.c
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| /* | ||||
|  * Asterisk -- A telephony toolkit for Linux. | ||||
|  * | ||||
|  * Time of day - Report the time of day | ||||
|  *  | ||||
|  * Copyright (C) 1999, Mark Spencer | ||||
|  * | ||||
|  * Mark Spencer <markster@linux-support.net> | ||||
|  * | ||||
|  * This program is free software, distributed under the terms of | ||||
|  * the GNU General Public License | ||||
|  */ | ||||
|  | ||||
| #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 <stdlib.h> | ||||
| #include <unistd.h> | ||||
| #include <string.h> | ||||
| #include <stdlib.h> | ||||
|  | ||||
| #include <pthread.h> | ||||
|  | ||||
|  | ||||
| static char *tdesc = "Date and Time"; | ||||
|  | ||||
| static char *app = "DateTime"; | ||||
|  | ||||
| static char *synopsis = "Say the date and time"; | ||||
|  | ||||
| static char *descrip =  | ||||
| "  DateTime():  Says the current date and time.  Returns -1 on hangup or 0\n" | ||||
| "otherwise.\n"; | ||||
|  | ||||
| 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) | ||||
| { | ||||
| 	STANDARD_HANGUP_LOCALUSERS; | ||||
| 	return ast_unregister_application(app); | ||||
| } | ||||
|  | ||||
| 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; | ||||
| } | ||||
| @@ -100,11 +100,10 @@ static int milliwatt_exec(struct ast_channel *chan, void *data) | ||||
| { | ||||
|  | ||||
| 	struct localuser *u; | ||||
| 	struct ast_frame *f; | ||||
| 	LOCAL_USER_ADD(u); | ||||
| 	ast_set_write_format(chan, AST_FORMAT_ULAW); | ||||
| 	ast_set_read_format(chan, AST_FORMAT_ULAW); | ||||
| 	if (chan->state != AST_STATE_UP) | ||||
| 	if (chan->_state != AST_STATE_UP) | ||||
| 	{ | ||||
| 		ast_answer(chan); | ||||
| 	} | ||||
|   | ||||
| @@ -63,7 +63,7 @@ static int playback_exec(struct ast_channel *chan, void *data) | ||||
| 	if (options && !strcasecmp(options, "noanswer")) | ||||
| 		option_noanswer = 1; | ||||
| 	LOCAL_USER_ADD(u); | ||||
| 	if (chan->state != AST_STATE_UP) { | ||||
| 	if (chan->_state != AST_STATE_UP) { | ||||
| 		if (option_skip) { | ||||
| 			/* At the user's option, skip if the line is not up */ | ||||
| 			LOCAL_USER_REMOVE(u); | ||||
| @@ -77,8 +77,10 @@ static int playback_exec(struct ast_channel *chan, void *data) | ||||
| 		res = ast_streamfile(chan, tmp, chan->language); | ||||
| 		if (!res)  | ||||
| 			res = ast_waitstream(chan, ""); | ||||
| 		else | ||||
| 		else { | ||||
| 			ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data); | ||||
| 			res = 0; | ||||
| 		} | ||||
| 		ast_stopstream(chan); | ||||
| 	} | ||||
| 	LOCAL_USER_REMOVE(u); | ||||
|   | ||||
| @@ -247,7 +247,7 @@ time_t	t; | ||||
| 		if (channel->ani) free(channel->ani); | ||||
| 		channel->ani = NULL; | ||||
| 	} | ||||
| 	if (channel->state == AST_STATE_UP) | ||||
| 	if (channel->_state == AST_STATE_UP) | ||||
| 	if (debug) printf("@@@@ Autodial:Line is Up\n"); | ||||
| 	if (option_verbose > 2) | ||||
| 	ast_verbose(VERBOSE_PREFIX_3 "Qcall waiting for answer on %s\n", | ||||
| @@ -274,7 +274,7 @@ time_t	t; | ||||
| 			if (f->subclass == AST_CONTROL_ANSWER) | ||||
| 			   { | ||||
| 				if (debug) printf("@@@@ qcall_do:Phone Answered\n"); | ||||
| 				if (channel->state == AST_STATE_UP) | ||||
| 				if (channel->_state == AST_STATE_UP) | ||||
| 				   { | ||||
| 					unlink(fname); | ||||
| 					if (option_verbose > 2) | ||||
|   | ||||
| @@ -95,7 +95,7 @@ static int record_exec(struct ast_channel *chan, void *data) | ||||
|  | ||||
| 	LOCAL_USER_ADD(u); | ||||
|  | ||||
| 	if (chan->state != AST_STATE_UP) { | ||||
| 	if (chan->_state != AST_STATE_UP) { | ||||
| 		res = ast_answer(chan); /* Shouldn't need this, but checking to see if channel is already answered | ||||
| 					 * Theoretically asterisk should already have answered before running the app */ | ||||
| 	} | ||||
|   | ||||
| @@ -45,7 +45,7 @@ static int zapateller_exec(struct ast_channel *chan, void *data) | ||||
| 	 | ||||
| 	LOCAL_USER_ADD(u); | ||||
| 	ast_stopstream(chan); | ||||
| 	if (chan->state != AST_STATE_UP) { | ||||
| 	if (chan->_state != AST_STATE_UP) { | ||||
| 		if (data && !strcasecmp(data, "answer"))  | ||||
| 			res = ast_answer(chan); | ||||
| 		if (!res) { | ||||
|   | ||||
| @@ -125,7 +125,7 @@ static void run_ras(struct ast_channel *chan, char *args) | ||||
| 			res = wait4(pid, &status, WNOHANG, NULL); | ||||
| 			if (!res) { | ||||
| 				/* Check for hangup */ | ||||
| 				if (chan->softhangup && !signalled) { | ||||
| 				if (chan->_softhangup && !signalled) { | ||||
| 					ast_log(LOG_DEBUG, "Channel '%s' hungup.  Signalling RAS at %d to die...\n", chan->name, pid); | ||||
| 					kill(pid, SIGTERM); | ||||
| 					signalled=1; | ||||
| @@ -182,7 +182,7 @@ static int zapras_exec(struct ast_channel *chan, void *data) | ||||
| 	LOCAL_USER_ADD(u); | ||||
| 	strncpy(args, data, sizeof(args) - 1); | ||||
| 	/* Answer the channel if it's not up */ | ||||
| 	if (chan->state != AST_STATE_UP) | ||||
| 	if (chan->_state != AST_STATE_UP) | ||||
| 		ast_answer(chan); | ||||
| 	if (strcasecmp(chan->type, "Zap")) { | ||||
| 		/* If it's not a zap channel, we're done.  Wait a couple of | ||||
|   | ||||
		Reference in New Issue
	
	Block a user