mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-03 20:38:59 +00:00 
			
		
		
		
	clean up function to be more consistent with coding guidelines
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6808 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		@@ -140,18 +140,27 @@ struct ast_custom_function len_function = {
 | 
			
		||||
 | 
			
		||||
static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) 
 | 
			
		||||
{
 | 
			
		||||
	char *format, *epoch, *timezone;
 | 
			
		||||
	char *format, *epoch, *timezone = NULL;
 | 
			
		||||
	long epochi;
 | 
			
		||||
	struct tm time;
 | 
			
		||||
 | 
			
		||||
	if (data) {
 | 
			
		||||
	buf[0] = '\0';
 | 
			
		||||
 | 
			
		||||
	if (!data) {
 | 
			
		||||
		ast_log(LOG_ERROR, "Asterisk function STRFTIME() requires an argument.\n");
 | 
			
		||||
		return buf;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	format = ast_strdupa(data);
 | 
			
		||||
		if (format) {
 | 
			
		||||
	if (!format) {
 | 
			
		||||
		ast_log(LOG_ERROR, "Out of memory\n");
 | 
			
		||||
		return buf;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	epoch = strsep(&format, "|");
 | 
			
		||||
	timezone = strsep(&format, "|");
 | 
			
		||||
 | 
			
		||||
			if (epoch && !ast_strlen_zero(epoch) && sscanf(epoch, "%ld", &epochi) == 1) {
 | 
			
		||||
			} else {
 | 
			
		||||
	if (!epoch || ast_strlen_zero(epoch) || !sscanf(epoch, "%ld", &epochi)) {
 | 
			
		||||
		struct timeval tv = ast_tvnow();
 | 
			
		||||
		epochi = tv.tv_sec;
 | 
			
		||||
	}
 | 
			
		||||
@@ -162,20 +171,12 @@ static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char
 | 
			
		||||
		format = "%c";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
			buf[0] = '\0';
 | 
			
		||||
	if (!strftime(buf, len, format, &time)) {
 | 
			
		||||
		ast_log(LOG_WARNING, "C function strftime() output nothing?!!\n");
 | 
			
		||||
	}
 | 
			
		||||
	buf[len - 1] = '\0';
 | 
			
		||||
 | 
			
		||||
	return buf;
 | 
			
		||||
		} else {
 | 
			
		||||
			ast_log(LOG_ERROR, "Out of memory\n");
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		ast_log(LOG_ERROR, "Asterisk function STRFTIME() requires an argument.\n");
 | 
			
		||||
	}
 | 
			
		||||
	return "";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef BUILTIN_FUNC
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user