[asterisk-commits] seanbright: trunk r204622 - /trunk/apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 1 11:06:21 CDT 2009


Author: seanbright
Date: Wed Jul  1 11:06:18 2009
New Revision: 204622

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=204622
Log:
A bunch of CODING_GUIDELINES related fixes.  Not even close to done.

Modified:
    trunk/apps/app_voicemail.c

Modified: trunk/apps/app_voicemail.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=204622&r1=204621&r2=204622
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Wed Jul  1 11:06:18 2009
@@ -16,16 +16,15 @@
  * at the top of the source tree.
  */
 
-/*! \file
- *
+/*!
+ * \file
+ * \author Mark Spencer <markster at digium.com>
  * \brief Comedian Mail - Voicemail System
  *
- * \author Mark Spencer <markster at digium.com>
+ * \extref unixODBC (http://www.unixodbc.org/)
+ * \extref A source distribution of University of Washington's IMAP c-client
+ *         (http://www.washington.edu/imap/)
  *
- * \extref Unixodbc - http://www.unixodbc.org
- * \extref A source distribution of University of Washington's IMAP
-c-client (http://www.washington.edu/imap/
- * 
  * \par See also
  * \arg \ref Config_vm
  * \note For information about voicemail IMAP storage, read doc/imapstorage.txt
@@ -33,11 +32,9 @@
  * \note This module requires res_adsi to load. This needs to be optional
  * during compilation.
  *
- *
- *
- * \note  This file is now almost impossible to work with, due to all \#ifdefs.
- *        Feels like the database code before realtime. Someone - please come up
- *        with a plan to clean this up.
+ * \note This file is now almost impossible to work with, due to all \#ifdefs.
+ *       Feels like the database code before realtime. Someone - please come up
+ *       with a plan to clean this up.
  */
 
 /*** MODULEINFO
@@ -66,7 +63,7 @@
 		<defaultenabled>no</defaultenabled>
 	</member>
 </category>
- ***/
+***/
 
 #include "asterisk.h"
 
@@ -912,7 +909,7 @@
 		ast_set2_flag(vmu, ast_true(value), VM_DELETE);	
 	} else if (!strcasecmp(var, "saycid")){
 		ast_set2_flag(vmu, ast_true(value), VM_SAYCID);	
-	} else if (!strcasecmp(var,"sendvoicemail")){
+	} else if (!strcasecmp(var, "sendvoicemail")){
 		ast_set2_flag(vmu, ast_true(value), VM_SVMAIL);	
 	} else if (!strcasecmp(var, "review")){
 		ast_set2_flag(vmu, ast_true(value), VM_REVIEW);
@@ -1223,7 +1220,7 @@
 static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *context, const char *mailbox)
 {
 	/* This function could be made to generate one from a database, too */
-	struct ast_vm_user *vmu=NULL, *cur;
+	struct ast_vm_user *vmu = NULL, *cur;
 	AST_LIST_LOCK(&users);
 
 	if (!context && !ast_test_flag((&globalflags), VM_SEARCH))
@@ -1286,11 +1283,11 @@
  */
 static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
 {
-	struct ast_config   *cfg=NULL;
-	struct ast_variable *var=NULL;
-	struct ast_category *cat=NULL;
-	char *category=NULL, *value=NULL, *new=NULL;
-	const char *tmp=NULL;
+	struct ast_config   *cfg = NULL;
+	struct ast_variable *var = NULL;
+	struct ast_category *cat = NULL;
+	char *category = NULL, *value = NULL, *new = NULL;
+	const char *tmp = NULL;
 	struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS };
 	if (!change_password_realtime(vmu, newpassword))
 		return;
@@ -1303,13 +1300,13 @@
 					ast_log(AST_LOG_WARNING, "We could not find the mailbox.\n");
 					break;
 				}
-				value = strstr(tmp,",");
+				value = strstr(tmp, ",");
 				if (!value) {
 					ast_log(AST_LOG_WARNING, "variable has bad format.\n");
 					break;
 				}
 				new = alloca((strlen(value)+strlen(newpassword)+1));
-				sprintf(new,"%s%s", newpassword, value);
+				sprintf(new, "%s%s", newpassword, value);
 				if (!(cat = ast_category_get(cfg, category))) {
 					ast_log(AST_LOG_WARNING, "Failed to get category structure.\n");
 					break;
@@ -1357,7 +1354,7 @@
 static void vm_change_password_shell(struct ast_vm_user *vmu, char *newpassword)
 {
 	char buf[255];
-	snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->mailbox,newpassword);
+	snprintf(buf, sizeof(buf), "%s %s %s %s", ext_pass_cmd, vmu->context, vmu->mailbox, newpassword);
 	if (!ast_safe_system(buf)) {
 		ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
 		/* Reset the password in memory, too */
@@ -1493,15 +1490,15 @@
 	/* this may be an index into vms->msgArray based on the msgnum. */
 	messageNum = vms->msgArray[msgnum];
 	if (messageNum == 0) {
-		ast_log(LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n",msgnum,messageNum);
+		ast_log(LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n", msgnum, messageNum);
 		return;
 	}
 	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum);
+		ast_log(LOG_DEBUG, "deleting msgnum %d, which is mailbox message %lu\n", msgnum, messageNum);
 	/* delete message */
-	snprintf (arg, sizeof(arg), "%lu",messageNum);
+	snprintf (arg, sizeof(arg), "%lu", messageNum);
 	ast_mutex_lock(&vms->lock);
-	mail_setflag (vms->mailstream,arg,"\\DELETED");
+	mail_setflag (vms->mailstream, arg, "\\DELETED");
 	ast_mutex_unlock(&vms->lock);
 }
 
@@ -1623,9 +1620,9 @@
 	}
 
 	if (option_debug > 2)
-		ast_log (LOG_DEBUG,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", msgnum, vms->msgArray[msgnum]);
+		ast_log(LOG_DEBUG, "Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", msgnum, vms->msgArray[msgnum]);
 	if (vms->msgArray[msgnum] == 0) {
-		ast_log (LOG_WARNING,"Trying to access unknown message\n");
+		ast_log(LOG_WARNING, "Trying to access unknown message\n");
 		res = -1;
 		goto exit;
 	}
@@ -1636,13 +1633,13 @@
 	ast_mutex_unlock(&vms->lock);
 	/* empty string means no valid header */
 	if (ast_strlen_zero(header_content)) {
-		ast_log (LOG_ERROR,"Could not fetch header for message number %ld\n",vms->msgArray[msgnum]);
+		ast_log(LOG_ERROR, "Could not fetch header for message number %ld\n", vms->msgArray[msgnum]);
 		res = -1;
 		goto exit;
 	}
 
 	ast_mutex_lock(&vms->lock);
-	mail_fetchstructure (vms->mailstream,vms->msgArray[msgnum],&body);
+	mail_fetchstructure(vms->mailstream, vms->msgArray[msgnum], &body);
 	ast_mutex_unlock(&vms->lock);
 
 	/* We have the body, now we extract the file name of the first attachment. */
@@ -1777,7 +1774,7 @@
 	}
 
 	/* check if someone is accessing this box right now... */
-	vms_p = get_vm_state_by_imapuser(vmu->imapuser,1);
+	vms_p = get_vm_state_by_imapuser(vmu->imapuser, 1);
 	if (!vms_p) {
 		vms_p = get_vm_state_by_mailbox(mailbox, context, 1);
 	}
@@ -1795,7 +1792,7 @@
 	}
 
 	/* add one if not there... */
-	vms_p = get_vm_state_by_imapuser(vmu->imapuser,0);
+	vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0);
 	if (!vms_p) {
 		vms_p = get_vm_state_by_mailbox(mailbox, context, 0);
 	}
@@ -1861,7 +1858,7 @@
 	char introfn[PATH_MAX];
 	char mailbox[256];
 	char *stringp;
-	FILE *p=NULL;
+	FILE *p = NULL;
 	char tmp[80] = "/tmp/astmail-XXXXXX";
 	long len;
 	void *buf;
@@ -1873,7 +1870,7 @@
 	/* Set urgent flag for IMAP message */
 	if (!ast_strlen_zero(flag) && !strcmp(flag, "Urgent")) {
 		ast_debug(3, "Setting message flag \\\\FLAGGED.\n");
-		imap_flags="\\FLAGGED";
+		imap_flags = "\\FLAGGED";
 	}
 	
 	/* Attach only the first format */
@@ -1942,7 +1939,7 @@
 			return -1;
 		}
 	}
-	((char *)buf)[len] = '\0';
+	((char *) buf)[len] = '\0';
 	INIT(&str, mail_string, buf, len);
 	ret = init_mailstream(vms, NEW_FOLDER);
 	if (ret == 0) {
@@ -1955,7 +1952,7 @@
 		unlink(tmp);
 		ast_free(buf);
 	} else {
-		ast_log(LOG_ERROR, "Could not initialize mailstream for %s\n",mailbox);
+		ast_log(LOG_ERROR, "Could not initialize mailstream for %s\n", mailbox);
 		fclose(p);
 		unlink(tmp);
 		ast_free(buf);
@@ -1997,7 +1994,7 @@
 	if (urgentmsgs)
 		*urgentmsgs = 0;
 
-	ast_debug(3,"Mailbox is set to %s\n",mailbox_context);
+	ast_debug(3, "Mailbox is set to %s\n", mailbox_context);
 	/* If no mailbox, return immediately */
 	if (ast_strlen_zero(mailbox_context))
 		return 0;
@@ -2030,7 +2027,7 @@
 		context++;
 	} else {
 		context = "default";
-		mailboxnc = (char *)mailbox_context;
+		mailboxnc = (char *) mailbox_context;
 	}
 	if (newmsgs) {
 		if ((*newmsgs = messagecount(context, mailboxnc, imapfolder)) < 0)
@@ -2075,7 +2072,7 @@
 			}
 		}
 	}
-	if ((context= strchr(tmp, '@')))
+	if ((context = strchr(tmp, '@')))
 		*context++ = '\0';
 	else
 		context = "default";
@@ -2175,14 +2172,14 @@
 	char tmp[256];
 	
 	if (!vms) {
-		ast_log (LOG_ERROR,"vm_state is NULL!\n");
+		ast_log(LOG_ERROR, "vm_state is NULL!\n");
 		return -1;
 	}
 	if (option_debug > 2)
-		ast_log (LOG_DEBUG,"vm_state user is:%s\n",vms->imapuser);
+		ast_log(LOG_DEBUG, "vm_state user is:%s\n", vms->imapuser);
 	if (vms->mailstream == NIL || !vms->mailstream) {
 		if (option_debug)
-			ast_log (LOG_DEBUG,"mailstream not set.\n");
+			ast_log(LOG_DEBUG, "mailstream not set.\n");
 	} else {
 		stream = vms->mailstream;
 	}
@@ -2204,7 +2201,7 @@
 		stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
 		ast_mutex_unlock(&vms->lock);
 		if (stream == NIL) {
-			ast_log (LOG_ERROR, "Can't connect to imap server %s\n", tmp);
+			ast_log(LOG_ERROR, "Can't connect to imap server %s\n", tmp);
 			return -1;
 		}
 		get_mailbox_delimiter(stream);
@@ -2216,7 +2213,7 @@
 	/* Now connect to the target folder */
 	imap_mailbox_name(tmp, sizeof(tmp), vms, box, 1);
 	if (option_debug > 2)
-		ast_log (LOG_DEBUG,"Before mail_open, server: %s, box:%d\n", tmp, box);
+		ast_log(LOG_DEBUG, "Before mail_open, server: %s, box:%d\n", tmp, box);
 	ast_mutex_lock(&vms->lock);
 	vms->mailstream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
 	ast_mutex_unlock(&vms->lock);
@@ -2239,8 +2236,8 @@
 		urgent = 1;
 	}
 
-	ast_copy_string(vms->imapuser,vmu->imapuser, sizeof(vms->imapuser));
-	ast_debug(3,"Before init_mailstream, user is %s\n",vmu->imapuser);
+	ast_copy_string(vms->imapuser, vmu->imapuser, sizeof(vms->imapuser));
+	ast_debug(3, "Before init_mailstream, user is %s\n", vmu->imapuser);
 
 	if ((ret = init_mailstream(vms, box)) || !vms->mailstream) {
 		ast_log(AST_LOG_ERROR, "Could not initialize mailstream\n");
@@ -2252,7 +2249,7 @@
 	/* Check Quota */
 	if  (box == 0)  {
 		ast_debug(3, "Mailbox name set to: %s, about to check quotas\n", mbox(box));
-		check_quota(vms,(char *)mbox(box));
+		check_quota(vms, (char *) mbox(box));
 	}
 
 	ast_mutex_lock(&vms->lock);
@@ -2281,7 +2278,7 @@
 		pgm->unseen = 0;
 	}
 
-	ast_debug(3,"Before mail_search_full, user is %s\n",vmu->imapuser);
+	ast_debug(3, "Before mail_search_full, user is %s\n", vmu->imapuser);
 
 	vms->vmArrayIndex = 0;
 	mail_search_full (vms->mailstream, NULL, pgm, NIL);
@@ -2391,7 +2388,7 @@
 		delimiter = delim;
 	}
 
-	ast_debug(5, "Delimiter set to %c and mailbox %s\n",delim, mailbox);
+	ast_debug(5, "Delimiter set to %c and mailbox %s\n", delim, mailbox);
 	if (attributes & LATT_NOINFERIORS)
 		ast_debug(5, "no inferiors\n");
 	if (attributes & LATT_NOSELECT)
@@ -2405,7 +2402,7 @@
 
 void mm_lsub(MAILSTREAM * stream, int delim, char *mailbox, long attributes)
 {
-	ast_debug(5, "Delimiter set to %c and mailbox %s\n",delim, mailbox);
+	ast_debug(5, "Delimiter set to %c and mailbox %s\n", delim, mailbox);
 	if (attributes & LATT_NOINFERIORS)
 		ast_debug(5, "no inferiors\n");
 	if (attributes & LATT_NOSELECT)
@@ -2438,7 +2435,7 @@
 {
 	switch ((short) errflg) {
 		case NIL:
-			ast_debug(1,"IMAP Info: %s\n", string);
+			ast_debug(1, "IMAP Info: %s\n", string);
 			break;
 		case PARSE:
 		case WARN:
@@ -2589,7 +2586,7 @@
 		return vms_p;
 	}
 	if (option_debug > 4)
-		ast_log(AST_LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser);
+		ast_log(AST_LOG_DEBUG, "Adding new vmstate for %s\n", vmu->imapuser);
 	if (!(vms_p = ast_calloc(1, sizeof(*vms_p))))
 		return NULL;
 	ast_copy_string(vms_p->imapuser, vmu->imapuser, sizeof(vms_p->imapuser));
@@ -2597,7 +2594,7 @@
 	ast_copy_string(vms_p->context, vmu->context, sizeof(vms_p->context));
 	vms_p->mailstream = NIL; /* save for access from interactive entry point */
 	if (option_debug > 4)
-		ast_log(AST_LOG_DEBUG,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
+		ast_log(AST_LOG_DEBUG, "Copied %s to %s\n", vmu->imapuser, vms_p->imapuser);
 	vms_p->updated = 1;
 	/* set mailbox to INBOX! */
 	ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox));
@@ -2666,7 +2663,7 @@
 
 		ast_debug(3, "comparing mailbox %s@%s (i=%d) to vmstate mailbox %s@%s (i=%d)\n", mailbox, local_context, interactive, vlist->vms->username, vlist->vms->context, vlist->vms->interactive);
 		
-		if (!strcmp(vlist->vms->username,mailbox) && !strcmp(vlist->vms->context, local_context) && vlist->vms->interactive == interactive) {
+		if (!strcmp(vlist->vms->username, mailbox) && !strcmp(vlist->vms->context, local_context) && vlist->vms->interactive == interactive) {
 			ast_debug(3, "Found it!\n");
 			AST_LIST_UNLOCK(&vmstates);
 			return vlist->vms;
@@ -2690,7 +2687,7 @@
 	if (vms->interactive == 1) {
 		altvms = get_vm_state_by_mailbox(vms->username, vms->context, 0);
 		if (altvms) {	
-			ast_debug(3, "Duplicate mailbox %s, copying message info...\n",vms->username);
+			ast_debug(3, "Duplicate mailbox %s, copying message info...\n", vms->username);
 			vms->newmessages = altvms->newmessages;
 			vms->oldmessages = altvms->oldmessages;
 			vms->vmArrayIndex = altvms->vmArrayIndex;
@@ -2713,7 +2710,7 @@
 	
 	v->vms = vms;
 
-	ast_debug(3, "Inserting vm_state for user:%s, mailbox %s\n",vms->imapuser,vms->username);
+	ast_debug(3, "Inserting vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username);
 
 	AST_LIST_LOCK(&vmstates);
 	AST_LIST_INSERT_TAIL(&vmstates, v, list);
@@ -2803,7 +2800,7 @@
 	if (body_content != NIL) {
 		snprintf(filename, sizeof(filename), "%s.%s", fn, format);
 		/* ast_debug(1,body_content); */
-		body_decoded = rfc822_base64((unsigned char *)body_content, len, &newlen);
+		body_decoded = rfc822_base64((unsigned char *) body_content, len, &newlen);
  		/* If the body of the file is empty, return an error */
 		if (!newlen) {
 			return -1;
@@ -2883,7 +2880,7 @@
 		ast_log(AST_LOG_WARNING, "SQL Alloc Handle failed!\n");
 		return NULL;
 	}
-	res = SQLPrepare(stmt, (unsigned char *)gps->sql, SQL_NTS);
+	res = SQLPrepare(stmt, (unsigned char *) gps->sql, SQL_NTS);
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 		ast_log(AST_LOG_WARNING, "SQL Prepare failed![%s]\n", gps->sql);
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
@@ -2913,10 +2910,10 @@
 {
 	int x = 0;
 	int res;
-	int fd=-1;
+	int fd = -1;
 	size_t fdlen = 0;
 	void *fdm = MAP_FAILED;
-	SQLSMALLINT colcount=0;
+	SQLSMALLINT colcount = 0;
 	SQLHSTMT stmt;
 	char sql[PATH_MAX];
 	char fmt[80]="";
@@ -2928,7 +2925,7 @@
 	SQLSMALLINT nullable;
 	SQLULEN colsize;
 	SQLLEN colsize2;
-	FILE *f=NULL;
+	FILE *f = NULL;
 	char rowdata[80];
 	char fn[PATH_MAX];
 	char full_fn[PATH_MAX];
@@ -2945,7 +2942,7 @@
 			*c = '\0';
 		if (!strcasecmp(fmt, "wav49"))
 			strcpy(fmt, "WAV");
-		snprintf(msgnums, sizeof(msgnums),"%d", msgnum);
+		snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
 		if (msgnum > -1)
 			make_file(fn, sizeof(fn), dir, msgnum);
 		else
@@ -2960,7 +2957,7 @@
 		}
 		
 		snprintf(full_fn, sizeof(full_fn), "%s.%s", fn, fmt);
-		snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE dir=? AND msgnum=?",odbc_table);
+		snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE dir=? AND msgnum=?", odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt) {
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -2994,10 +2991,10 @@
 		}
 		if (f) 
 			fprintf(f, "[message]\n");
-		for (x=0;x<colcount;x++) {
+		for (x = 0; x < colcount; x++) {
 			rowdata[0] = '\0';
 			collen = sizeof(coltitle);
-			res = SQLDescribeCol(stmt, x + 1, (unsigned char *)coltitle, sizeof(coltitle), &collen, 
+			res = SQLDescribeCol(stmt, x + 1, (unsigned char *) coltitle, sizeof(coltitle), &collen, 
 						&datatype, &colsize, &decimaldigits, &nullable);
 			if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 				ast_log(AST_LOG_WARNING, "SQL Describe Column error!\n[%s]\n\n", sql);
@@ -3087,7 +3084,7 @@
 	struct odbc_obj *obj;
 	obj = ast_odbc_request_obj(odbc_database, 0);
 	if (obj) {
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=?",odbc_table);
+		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=?", odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt) {
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -3142,7 +3139,7 @@
 	obj = ast_odbc_request_obj(odbc_database, 0);
 	if (obj) {
 		snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
-		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=? AND msgnum=?",odbc_table);
+		snprintf(sql, sizeof(sql), "SELECT COUNT(*) FROM %s WHERE dir=? AND msgnum=?", odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt) {
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -3212,7 +3209,7 @@
 	obj = ast_odbc_request_obj(odbc_database, 0);
 	if (obj) {
 		snprintf(msgnums, sizeof(msgnums), "%d", smsg);
-		snprintf(sql, sizeof(sql), "DELETE FROM %s WHERE dir=? AND msgnum=?",odbc_table);
+		snprintf(sql, sizeof(sql), "DELETE FROM %s WHERE dir=? AND msgnum=?", odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt)
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -3250,7 +3247,7 @@
 	if (obj) {
 		snprintf(msgnums, sizeof(msgnums), "%d", smsg);
 		snprintf(msgnumd, sizeof(msgnumd), "%d", dmsg);
-		snprintf(sql, sizeof(sql), "INSERT INTO %s (dir, msgnum, context, macrocontext, callerid, origtime, duration, recording, mailboxuser, mailboxcontext, flag) SELECT ?,?,context,macrocontext,callerid,origtime,duration,recording,flag,?,? FROM %s WHERE dir=? AND msgnum=?",odbc_table,odbc_table);
+		snprintf(sql, sizeof(sql), "INSERT INTO %s (dir, msgnum, context, macrocontext, callerid, origtime, duration, recording, mailboxuser, mailboxcontext, flag) SELECT ?,?,context,macrocontext,callerid,origtime,duration,recording,flag,?,? FROM %s WHERE dir=? AND msgnum=?", odbc_table, odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt)
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s] (You probably don't have MySQL 4.1 or later installed)\n\n", sql);
@@ -3293,21 +3290,21 @@
 		return NULL;
 	}
 
-	SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->dir), 0, (void *)data->dir, 0, NULL);
-	SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msgnums), 0, (void *)data->msgnums, 0, NULL);
-	SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, data->datalen, 0, (void *)data->data, data->datalen, &data->indlen);
-	SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->context), 0, (void *)data->context, 0, NULL);
-	SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->macrocontext), 0, (void *)data->macrocontext, 0, NULL);
-	SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->callerid), 0, (void *)data->callerid, 0, NULL);
-	SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->origtime), 0, (void *)data->origtime, 0, NULL);
-	SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *)data->duration, 0, NULL);
-	SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *)data->mailboxuser, 0, NULL);
-	SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *)data->mailboxcontext, 0, NULL);
-	SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *)data->flag, 0, NULL);
+	SQLBindParameter(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->dir), 0, (void *) data->dir, 0, NULL);
+	SQLBindParameter(stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->msgnums), 0, (void *) data->msgnums, 0, NULL);
+	SQLBindParameter(stmt, 3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, data->datalen, 0, (void *) data->data, data->datalen, &data->indlen);
+	SQLBindParameter(stmt, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->context), 0, (void *) data->context, 0, NULL);
+	SQLBindParameter(stmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->macrocontext), 0, (void *) data->macrocontext, 0, NULL);
+	SQLBindParameter(stmt, 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->callerid), 0, (void *) data->callerid, 0, NULL);
+	SQLBindParameter(stmt, 7, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->origtime), 0, (void *) data->origtime, 0, NULL);
+	SQLBindParameter(stmt, 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->duration), 0, (void *) data->duration, 0, NULL);
+	SQLBindParameter(stmt, 9, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxuser), 0, (void *) data->mailboxuser, 0, NULL);
+	SQLBindParameter(stmt, 10, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->mailboxcontext), 0, (void *) data->mailboxcontext, 0, NULL);
+	SQLBindParameter(stmt, 11, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->flag), 0, (void *) data->flag, 0, NULL);
 	if (!ast_strlen_zero(data->category)) {
-		SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *)data->category, 0, NULL);
-	}
-	res = SQLExecDirect(stmt, (unsigned char *)data->sql, SQL_NTS);
+		SQLBindParameter(stmt, 12, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(data->category), 0, (void *) data->category, 0, NULL);
+	}
+	res = SQLExecDirect(stmt, (unsigned char *) data->sql, SQL_NTS);
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 		ast_log(AST_LOG_WARNING, "SQL Direct Execute failed!\n");
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
@@ -3343,7 +3340,7 @@
 	char full_fn[PATH_MAX];
 	char fmt[80]="";
 	char *c;
-	struct ast_config *cfg=NULL;
+	struct ast_config *cfg = NULL;
 	struct odbc_obj *obj;
 	struct insert_data idata = { .sql = sql, .msgnums = msgnums, .dir = dir, .mailboxuser = mailboxuser, .mailboxcontext = mailboxcontext,
 		.context = "", .macrocontext = "", .callerid = "", .origtime = "", .duration = "", .category = "", .flag = "" };
@@ -3362,7 +3359,7 @@
 			*c = '\0';
 		if (!strcasecmp(fmt, "wav49"))
 			strcpy(fmt, "WAV");
-		snprintf(msgnums, sizeof(msgnums),"%d", msgnum);
+		snprintf(msgnums, sizeof(msgnums), "%d", msgnum);
 		if (msgnum > -1)
 			make_file(fn, sizeof(fn), dir, msgnum);
 		else
@@ -3402,7 +3399,7 @@
 		fdlen = lseek(fd, 0, SEEK_END);
 		lseek(fd, 0, SEEK_SET);
 		printf("Length is %zd\n", fdlen);
-		fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED,fd, 0);
+		fdm = mmap(NULL, fdlen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 		if (fdm == MAP_FAILED) {
 			ast_log(AST_LOG_WARNING, "Memory map failed!\n");
 			res = -1;
@@ -3412,9 +3409,9 @@
 		idata.datalen = idata.indlen = fdlen;
 
 		if (!ast_strlen_zero(idata.category)) 
-			snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag,category) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)",odbc_table); 
+			snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag,category) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", odbc_table); 
 		else
-			snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag) VALUES (?,?,?,?,?,?,?,?,?,?,?)",odbc_table);
+			snprintf(sql, sizeof(sql), "INSERT INTO %s (dir,msgnum,recording,context,macrocontext,callerid,origtime,duration,mailboxuser,mailboxcontext,flag) VALUES (?,?,?,?,?,?,?,?,?,?,?)", odbc_table);
 
 		if ((stmt = ast_odbc_direct_execute(obj, insert_data_cb, &idata))) {
 			SQLFreeHandle (SQL_HANDLE_STMT, stmt);
@@ -3463,7 +3460,7 @@
 	if (obj) {
 		snprintf(msgnums, sizeof(msgnums), "%d", smsg);
 		snprintf(msgnumd, sizeof(msgnumd), "%d", dmsg);
-		snprintf(sql, sizeof(sql), "UPDATE %s SET dir=?, msgnum=?, mailboxuser=?, mailboxcontext=? WHERE dir=? AND msgnum=?",odbc_table);
+		snprintf(sql, sizeof(sql), "UPDATE %s SET dir=?, msgnum=?, mailboxuser=?, mailboxcontext=? WHERE dir=? AND msgnum=?", odbc_table);
 		stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
 		if (!stmt)
 			ast_log(AST_LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
@@ -3547,7 +3544,7 @@
 {
 	char stxt[PATH_MAX];
 	char dtxt[PATH_MAX];
-	ast_filerename(sfn,dfn,NULL);
+	ast_filerename(sfn, dfn, NULL);
 	snprintf(stxt, sizeof(stxt), "%s.txt", sfn);
 	snprintf(dtxt, sizeof(dtxt), "%s.txt", dfn);
 	if (ast_check_realtime("voicemail_data")) {
@@ -3745,7 +3742,7 @@
 	if (bio->ateof)
 		return 0;
 
-	if ((l = fread(bio->iobuf,1,BASEMAXINLINE,fi)) <= 0) {
+	if ((l = fread(bio->iobuf, 1, BASEMAXINLINE, fi)) <= 0) {
 		if (ferror(fi))
 			return -1;
 
@@ -3753,8 +3750,8 @@
 		return 0;
 	}
 
-	bio->iolen= l;
-	bio->iocp= 0;
+	bio->iolen = l;
+	bio->iocp = 0;
 
 	return 1;
 }
@@ -3778,13 +3775,13 @@
 static int ochar(struct baseio *bio, int c, FILE *so)
 {
 	if (bio->linelength >= BASELINELEN) {
-		if (fputs(eol,so) == EOF)
+		if (fputs(eol, so) == EOF)
 			return -1;
 
-		bio->linelength= 0;
-	}
-
-	if (putc(((unsigned char)c),so) == EOF)
+		bio->linelength = 0;
+	}
+
+	if (putc(((unsigned char) c), so) == EOF)
 		return -1;
 
 	bio->linelength++;
@@ -3807,7 +3804,7 @@
 		'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
 		'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0',
 		'1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'};
-	int i,hiteof= 0;
+	int i, hiteof = 0;
 	FILE *fi;
 	struct baseio bio;
 
@@ -3821,40 +3818,40 @@
 
 	while (!hiteof){
 		unsigned char igroup[3], ogroup[4];
-		int c,n;
-
-		igroup[0]= igroup[1]= igroup[2]= 0;
-
-		for (n= 0;n<3;n++) {
+		int c, n;
+
+		memset(igroup, 0, sizeof(igroup));
+
+		for (n = 0; n < 3; n++) {
 			if ((c = inchar(&bio, fi)) == EOF) {
-				hiteof= 1;
+				hiteof = 1;
 				break;
 			}
 
-			igroup[n]= (unsigned char)c;
-		}
-
-		if (n> 0) {
-			ogroup[0]= dtable[igroup[0]>>2];
-			ogroup[1]= dtable[((igroup[0]&3)<<4) | (igroup[1]>>4)];
-			ogroup[2]= dtable[((igroup[1]&0xF)<<2) | (igroup[2]>>6)];
-			ogroup[3]= dtable[igroup[2]&0x3F];
-
-			if (n<3) {
-				ogroup[3]= '=';
-
-				if (n<2)
-					ogroup[2]= '=';
-			}
-
-			for (i= 0;i<4;i++)
+			igroup[n] = (unsigned char) c;
+		}
+
+		if (n > 0) {
+			ogroup[0]= dtable[igroup[0] >> 2];
+			ogroup[1]= dtable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)];
+			ogroup[2]= dtable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)];
+			ogroup[3]= dtable[igroup[2] & 0x3F];
+
+			if (n < 3) {
+				ogroup[3] = '=';
+
+				if (n < 2)
+					ogroup[2] = '=';
+			}
+
+			for (i = 0; i < 4; i++)
 				ochar(&bio, ogroup[i], so);
 		}
 	}
 
 	fclose(fi);
 	
-	if (fputs(eol,so)==EOF)
+	if (fputs(eol, so) == EOF)
 		return 0;
 
 	return 1;
@@ -4183,7 +4180,8 @@
 		}
 	}
 
-	fprintf(p, "Message-ID: <Asterisk-%d-%d-%s-%d@%s>" ENDL, msgnum + 1, (unsigned int)ast_random(), mailbox, (int)getpid(), host);
+	fprintf(p, "Message-ID: <Asterisk-%d-%d-%s-%d@%s>" ENDL, msgnum + 1,
+		(unsigned int) ast_random(), mailbox, (int) getpid(), host);
 	if (imap) {
 		/* additional information needed for IMAP searching */
 		fprintf(p, "X-Asterisk-VM-Message-Num: %d" ENDL, msgnum + 1);
@@ -4209,7 +4207,7 @@
 		}
 		fprintf(p, "X-Asterisk-VM-Message-Type: %s" ENDL, msgnum > -1 ? "Message" : greeting_attachment);
 		fprintf(p, "X-Asterisk-VM-Orig-date: %s" ENDL, date);
-		fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long)time(NULL));
+		fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long) time(NULL));
 	}
 	if (!ast_strlen_zero(cidnum)) {
 		fprintf(p, "X-Asterisk-CallerID: %s" ENDL, enc_cidnum);
@@ -4220,7 +4218,8 @@
 	fprintf(p, "MIME-Version: 1.0" ENDL);
 	if (attach_user_voicemail) {
 		/* Something unique. */
-		snprintf(bound, sizeof(bound), "----voicemail_%d%s%d%d", msgnum + 1, mailbox, (int)getpid(), (unsigned int)ast_random());
+		snprintf(bound, sizeof(bound), "----voicemail_%d%s%d%d", msgnum + 1, mailbox,
+			(int) getpid(), (unsigned int) ast_random());
 
 		fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"" ENDL, bound);
 		fprintf(p, ENDL ENDL "This is a multi-part message in MIME format." ENDL ENDL);
@@ -4360,7 +4359,7 @@
 
 static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *attach2, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, const char *flag)
 {
-	FILE *p=NULL;
+	FILE *p = NULL;
 	char tmp[80] = "/tmp/astmail-XXXXXX";
 	char tmp2[256];
 
@@ -5330,7 +5329,7 @@
 		
 		/* here is a big difference! We add one to it later */
 		msgnum = newmsgs + oldmsgs;
-		ast_debug(3, "Messagecount set to %d\n",msgnum);
+		ast_debug(3, "Messagecount set to %d\n", msgnum);
 		snprintf(fn, sizeof(fn), "%s/imap/msg%s%04d", VM_SPOOL_DIR, vmu->mailbox, msgnum);
 		/* set variable for compatibility */
 		pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE");
@@ -5383,9 +5382,9 @@
 		/* Store information in real-time storage */
 		if (ast_check_realtime("voicemail_data")) {
 			snprintf(priority, sizeof(priority), "%d", chan->priority);
-			snprintf(origtime, sizeof(origtime), "%ld", (long)time(NULL));
+			snprintf(origtime, sizeof(origtime), "%ld", (long) time(NULL));
 			get_date(date, sizeof(date));
-			ast_store_realtime("voicemail_data", "origmailbox", ext, "context", chan->context, "macrocontext", chan->macrocontext, "exten", chan->exten, "priority", priority, "callerchan", chan->name, "callerid", ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"), "origdate", date, "origtime", origtime, "category", S_OR(category,""), "filename", tmptxtfile, SENTINEL);
+			ast_store_realtime("voicemail_data", "origmailbox", ext, "context", chan->context, "macrocontext", chan->macrocontext, "exten", chan->exten, "priority", priority, "callerchan", chan->name, "callerid", ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"), "origdate", date, "origtime", origtime, "category", S_OR(category, ""), "filename", tmptxtfile, SENTINEL);
 		}
 
 		/* Store information */
@@ -5414,7 +5413,7 @@
 				chan->priority,
 				chan->name,
 				ast_callerid_merge(callerid, sizeof(callerid), S_OR(chan->cid.cid_name, NULL), S_OR(chan->cid.cid_num, NULL), "Unknown"),
-				date, (long)time(NULL),
+				date, (long) time(NULL),
 				category ? category : "");
 		} else
 			ast_log(AST_LOG_WARNING, "Error opening text file for output\n");
@@ -5504,7 +5503,7 @@
 						int x;
 						/* It's easier just to try to make it than to check for its existence */
 						create_dirpath(urgdir, sizeof(urgdir), vmu->context, ext, "Urgent");
-						ast_debug(5, "Created an Urgent message, moving file from %s to %s.\n",sfn,dfn);
+						ast_debug(5, "Created an Urgent message, moving file from %s to %s.\n", sfn, dfn);
 						x = last_message_index(vmu, urgdir) + 1;
 						make_file(sfn, sizeof(sfn), dir, msgnum);
 						make_file(dfn, sizeof(dfn), urgdir, x);
@@ -5544,12 +5543,12 @@
 
 #ifdef IMAP_STORAGE
 	/* expunge message - use UID Expunge if supported on IMAP server*/
-	ast_debug(3, "*** Checking if we can expunge, expungeonhangup set to %d\n",expungeonhangup);
+	ast_debug(3, "*** Checking if we can expunge, expungeonhangup set to %d\n", expungeonhangup);
 	if (expungeonhangup == 1) {
 		ast_mutex_lock(&vms->lock);
 #ifdef HAVE_IMAP_TK2006
 		if (LEVELUIDPLUS (vms->mailstream)) {
-			mail_expunge_full(vms->mailstream,NIL,EX_UID);
+			mail_expunge_full(vms->mailstream, NIL, EX_UID);
 		} else 
 #endif
 			mail_expunge(vms->mailstream);
@@ -5596,12 +5595,12 @@
 	}
 	/* Create the folder if it don't exist */
 	imap_mailbox_name(mailbox, sizeof(mailbox), vms, box, 1); /* Get the full mailbox name */
-	ast_debug(5, "Checking if folder exists: %s\n",mailbox);
+	ast_debug(5, "Checking if folder exists: %s\n", mailbox);
 	if (mail_create(vms->mailstream, mailbox) == NIL) 
 		ast_debug(5, "Folder exists.\n");
 	else
-		ast_log(AST_LOG_NOTICE, "Folder %s created!\n",mbox(box));
-	res = !mail_copy(vms->mailstream, sequence, (char *)mbox(box));
+		ast_log(AST_LOG_NOTICE, "Folder %s created!\n", mbox(box));
+	res = !mail_copy(vms->mailstream, sequence, (char *) mbox(box));
 	ast_mutex_unlock(&vms->lock);
 	return res;
 #else
@@ -5658,7 +5657,7 @@
 static int adsi_load_vmail(struct ast_channel *chan, int *useadsi)
 {
 	unsigned char buf[256];
-	int bytes=0;
+	int bytes = 0;
 	int x;
 	char num[5];
 
@@ -5733,7 +5732,7 @@
 #endif
 
 	bytes = 0;
-	for (x=0;x<5;x++) {
+	for (x = 0; x < 5; x++) {
 		snprintf(num, sizeof(num), "%d", x);
 		bytes += ast_adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 12 + x, mbox(x), mbox(x), num, 1);
 	}
@@ -5804,13 +5803,13 @@
 static void adsi_login(struct ast_channel *chan)
 {
 	unsigned char buf[256];
-	int bytes=0;
+	int bytes = 0;
 	unsigned char keys[8];
 	int x;
 	if (!ast_adsi_available(chan))
 		return;
 
-	for (x=0;x<8;x++)
+	for (x = 0; x < 8; x++)
 		keys[x] = 0;
 	/* Set one key for next */
 	keys[3] = ADSI_KEY_APPS + 3;
@@ -5830,13 +5829,13 @@
 static void adsi_password(struct ast_channel *chan)
 {
 	unsigned char buf[256];
-	int bytes=0;
+	int bytes = 0;
 	unsigned char keys[8];
 	int x;
 	if (!ast_adsi_available(chan))
 		return;
 
-	for (x=0;x<8;x++)
+	for (x = 0; x < 8; x++)
 		keys[x] = 0;
 	/* Set one key for next */
 	keys[3] = ADSI_KEY_APPS + 3;
@@ -5852,14 +5851,14 @@
 static void adsi_folders(struct ast_channel *chan, int start, char *label)
 {
 	unsigned char buf[256];
-	int bytes=0;
+	int bytes = 0;
 	unsigned char keys[8];
-	int x,y;
+	int x, y;
 
 	if (!ast_adsi_available(chan))
 		return;
 
-	for (x=0;x<5;x++) {
+	for (x = 0; x < 5; x++) {
 		y = ADSI_KEY_APPS + 12 + start + x;
 		if (y > ADSI_KEY_APPS + 12 + 4)
 			y = 0;
@@ -5880,15 +5879,15 @@
 
 static void adsi_message(struct ast_channel *chan, struct vm_state *vms)
 {
-	int bytes=0;
+	int bytes = 0;
 	unsigned char buf[256]; 
 	char buf1[256], buf2[256];
 	char fn2[PATH_MAX];
 
-	char cid[256]="";
+	char cid[256] = "";
 	char *val;
 	char *name, *num;
-	char datetime[21]="";
+	char datetime[21] = "";
 	FILE *f;
 
 	unsigned char keys[8];
@@ -5903,18 +5902,18 @@
 	f = fopen(fn2, "r");
 	if (f) {
 		while (!feof(f)) {	
-			if (!fgets((char *)buf, sizeof(buf), f)) {
+			if (!fgets((char *) buf, sizeof(buf), f)) {
 				continue;
 			}
 			if (!feof(f)) {
-				char *stringp=NULL;
-				stringp = (char *)buf;
+				char *stringp = NULL;
+				stringp = (char *) buf;
 				strsep(&stringp, "=");
 				val = strsep(&stringp, "=");
 				if (!ast_strlen_zero(val)) {
-					if (!strcmp((char *)buf, "callerid"))
+					if (!strcmp((char *) buf, "callerid"))
 						ast_copy_string(cid, val, sizeof(cid));
-					if (!strcmp((char *)buf, "origdate"))
+					if (!strcmp((char *) buf, "origdate"))
 						ast_copy_string(datetime, val, sizeof(datetime));
 				}
 			}
@@ -5922,7 +5921,7 @@
 		fclose(f);
 	}
 	/* New meaning for keys */
-	for (x=0;x<5;x++)
+	for (x = 0; x < 5; x++)
 		keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
 	keys[6] = 0x0;
 	keys[7] = 0x0;
@@ -5975,7 +5974,7 @@
 
 static void adsi_delete(struct ast_channel *chan, struct vm_state *vms)
 {
-	int bytes=0;
+	int bytes = 0;
 	unsigned char buf[256];
 	unsigned char keys[8];
 
@@ -5985,7 +5984,7 @@
 		return;
 
 	/* New meaning for keys */
-	for (x=0;x<5;x++)
+	for (x = 0; x < 5; x++)
 		keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 6 + x);
 
 	keys[6] = 0x0;
@@ -6022,7 +6021,7 @@
 {
 	unsigned char buf[256] = "";
 	char buf1[256] = "", buf2[256] = "";
-	int bytes=0;
+	int bytes = 0;
 	unsigned char keys[8];
 	int x;
 
@@ -6050,7 +6049,7 @@
 	bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_LEFT, 0, buf2, "");
 	bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
 
-	for (x=0;x<6;x++)
+	for (x = 0; x < 6; x++)
 		keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
 	keys[6] = 0;
 	keys[7] = 0;
@@ -6069,7 +6068,7 @@
 {
 	unsigned char buf[256] = "";
 	char buf1[256] = "", buf2[256] = "";
-	int bytes=0;
+	int bytes = 0;
 	unsigned char keys[8];
 	int x;
 
@@ -6079,7 +6078,7 @@
 		return;
 
 	/* Original command keys */
-	for (x=0;x<6;x++)
+	for (x = 0; x < 6; x++)
 		keys[x] = ADSI_KEY_SKT | (ADSI_KEY_APPS + x);
 
 	keys[6] = 0;
@@ -6124,7 +6123,7 @@
 static void adsi_goodbye(struct ast_channel *chan)
 {
 	unsigned char buf[256];
-	int bytes=0;
+	int bytes = 0;
 
 	if (!ast_adsi_available(chan))
 		return;
@@ -6149,7 +6148,7 @@
 	d = ast_play_and_wait(chan, "vm-press");	/* "Press" */
 	if (d)
 		return d;
-	for (x = start; x< 5; x++) {	/* For all folders */
+	for (x = start; x < 5; x++) {	/* For all folders */
 		if ((d = ast_say_number(chan, x, AST_DIGIT_ANY, chan->language, NULL)))
 			return d;
 		d = ast_play_and_wait(chan, "vm-for");	/* "for" */
@@ -6252,7 +6251,7 @@
 			strncat(vms->introfn, "intro", sizeof(vms->introfn));
 			res = ast_play_and_wait(chan, INTRO);
 			res = ast_play_and_wait(chan, "beep");
-			res = play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vm_fmts, 1, vmu, (int *)duration, NULL, record_gain, vms, flag);
+			res = play_record_review(chan, NULL, vms->introfn, vmu->maxsecs, vm_fmts, 1, vmu, (int *) duration, NULL, record_gain, vms, flag);
 			cmd = 't';
 #else
 
@@ -6313,13 +6312,13 @@
 			cmd = '*';
 			break;
 		default: 
-			cmd = ast_play_and_wait(chan,"vm-forwardoptions");
+			cmd = ast_play_and_wait(chan, "vm-forwardoptions");
 				/* "Press 1 to prepend a message or 2 to forward the message without prepending" */
 			if (!cmd)
-				cmd = ast_play_and_wait(chan,"vm-starmain");
+				cmd = ast_play_and_wait(chan, "vm-starmain");
 				/* "press star to return to the main menu" */
 			if (!cmd)
-				cmd = ast_waitfordigit(chan,6000);
+				cmd = ast_waitfordigit(chan, 6000);
 			if (!cmd)
 				retries++;
 			if (retries > 3)
@@ -6478,7 +6477,7 @@
 static int forward_message(struct ast_channel *chan, char *context, struct vm_state *vms, struct ast_vm_user *sender, char *fmt, int is_new_message, signed char record_gain, int urgent)
 {
 #ifdef IMAP_STORAGE
-	int todircount=0;
+	int todircount = 0;
 	struct vm_state *dstvms;
 #endif
 	char username[70]="";
@@ -6510,7 +6509,7 @@
 		if (ast_test_flag((&globalflags), VM_DIRECFORWARD)) {
 			int done = 0;
 			int retries = 0;
-			cmd=0;
+			cmd = 0;
 			while ((cmd >= 0) && !done ){
 				if (cmd)
 					retries = 0;
@@ -6521,7 +6520,7 @@
 					break;
 				case '2': 
 					use_directory = 1;
-					done=1;
+					done = 1;
 					break;
 				case '*': 
 					cmd = 't';
@@ -6529,9 +6528,9 @@
 					break;
 				default: 
 					/* Press 1 to enter an extension press 2 to use the directory */
-					cmd = ast_play_and_wait(chan,"vm-forward");
+					cmd = ast_play_and_wait(chan, "vm-forward");
 					if (!cmd)
-						cmd = ast_waitfordigit(chan,3000);
+						cmd = ast_waitfordigit(chan, 3000);
 					if (!cmd)
 						retries++;
 					if (retries > 3) {
@@ -6776,9 +6775,9 @@
 
 	/* Day difference */
 	if (time_now.tm_year == time_then.tm_year)
-		snprintf(temp,sizeof(temp),"%d",time_now.tm_yday);
+		snprintf(temp, sizeof(temp), "%d", time_now.tm_yday);
 	else
-		snprintf(temp,sizeof(temp),"%d",(time_now.tm_year - time_then.tm_year) * 365 + (time_now.tm_yday - time_then.tm_yday));
+		snprintf(temp, sizeof(temp), "%d", (time_now.tm_year - time_then.tm_year) * 365 + (time_now.tm_yday - time_then.tm_yday));
 	pbx_builtin_setvar_helper(chan, "DIFF_DAY", temp);
 

[... 709 lines stripped ...]



More information about the asterisk-commits mailing list