diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 4a54dc6e3c..77db70357d 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -16,16 +16,15 @@ * at the top of the source tree. */ -/*! \file - * +/*! + * \file + * \author Mark Spencer * \brief Comedian Mail - Voicemail System * - * \author Mark Spencer + * \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 @@ c-client (http://www.washington.edu/imap/ * \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 @@ c-client (http://www.washington.edu/imap/ no - ***/ +***/ #include "asterisk.h" @@ -912,7 +909,7 @@ static void apply_option(struct ast_vm_user *vmu, const char *var, const char *v 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_realtime(struct ast_vm_user *ivm, const cha 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 int reset_user_pw(const char *context, const char *mailbox, const char *n */ 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 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) 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(struct ast_vm_user *vmu, const char *newpassword) 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 @@ static void vm_imap_delete(int msgnum, struct ast_vm_user *vmu) /* 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 @@ static int imap_retrieve_file(const char *dir, const int msgnum, const char *mai } 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 @@ static int imap_retrieve_file(const char *dir, const int msgnum, const char *mai 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 @@ static int messagecount(const char *context, const char *mailbox, const char *fo } /* 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 @@ static int messagecount(const char *context, const char *mailbox, const char *fo } /* 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 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i 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 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i /* 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 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i 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 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i 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 @@ static int inboxcount2(const char *mailbox_context, int *urgentmsgs, int *newmsg 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 @@ static int inboxcount2(const char *mailbox_context, int *urgentmsgs, int *newmsg 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 @@ static int has_voicemail(const char *mailbox, const char *folder) } } } - if ((context= strchr(tmp, '@'))) + if ((context = strchr(tmp, '@'))) *context++ = '\0'; else context = "default"; @@ -2175,14 +2172,14 @@ static int init_mailstream(struct vm_state *vms, int box) 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 @@ static int init_mailstream(struct vm_state *vms, int box) 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 @@ static int init_mailstream(struct vm_state *vms, int box) /* 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 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box) 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 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box) /* 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 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box) 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 @@ void mm_list(MAILSTREAM * stream, int delim, char *mailbox, long attributes) 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_list(MAILSTREAM * stream, int delim, char *mailbox, long attributes) 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 @@ void mm_log(char *string, long errflg) { 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 @@ static struct vm_state *create_vm_state_from_user(struct ast_vm_user *vmu) 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 @@ static struct vm_state *create_vm_state_from_user(struct ast_vm_user *vmu) 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 @@ static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, const char 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 @@ static void vmstate_insert(struct vm_state *vms) 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 @@ static void vmstate_insert(struct vm_state *vms) 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 @@ static int save_body(BODY *body, struct vm_state *vms, char *section, char *form 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 @@ static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data) 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 @@ static int retrieve_file(char *dir, int msgnum) { 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 @@ static int retrieve_file(char *dir, int msgnum) 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 @@ static int retrieve_file(char *dir, int msgnum) *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 @@ static int retrieve_file(char *dir, int msgnum) } 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 @@ static int retrieve_file(char *dir, int msgnum) } if (f) fprintf(f, "[message]\n"); - for (x=0;xdir), 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); + 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); + 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 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms 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 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms *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 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms 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 @@ static int store_file(char *dir, char *mailboxuser, char *mailboxcontext, int ms 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 @@ static void rename_file(char *sdir, int smsg, char *mailboxuser, char *mailboxco 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 @@ static void rename_file(char *sfn, char *dfn) { 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 @@ static int inbuf(struct baseio *bio, FILE *fi) 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 @@ static int inbuf(struct baseio *bio, FILE *fi) return 0; } - bio->iolen= l; - bio->iocp= 0; + bio->iolen = l; + bio->iocp = 0; return 1; } @@ -3778,13 +3775,13 @@ static int inchar(struct baseio *bio, FILE *fi) 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; + bio->linelength = 0; } - if (putc(((unsigned char)c),so) == EOF) + if (putc(((unsigned char) c), so) == EOF) return -1; bio->linelength++; @@ -3807,7 +3804,7 @@ static int base_encode(char *filename, FILE *so) '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 @@ static int base_encode(char *filename, FILE *so) while (!hiteof){ unsigned char igroup[3], ogroup[4]; - int c,n; + int c, n; - igroup[0]= igroup[1]= igroup[2]= 0; + memset(igroup, 0, sizeof(igroup)); - for (n= 0;n<3;n++) { + for (n = 0; n < 3; n++) { if ((c = inchar(&bio, fi)) == EOF) { - hiteof= 1; + hiteof = 1; break; } - igroup[n]= (unsigned char)c; + 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 > 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 < 3) { + ogroup[3] = '='; - if (n<2) - ogroup[2]= '='; + if (n < 2) + ogroup[2] = '='; } - for (i= 0;i<4;i++) + 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 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in } } - fprintf(p, "Message-ID: " ENDL, msgnum + 1, (unsigned int)ast_random(), mailbox, (int)getpid(), host); + fprintf(p, "Message-ID: " 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 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in } 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 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in 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 add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format, 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ /* 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ /* 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ 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 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ 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 @@ leave_vm_out: #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 @@ static int save_to_folder(struct ast_vm_user *vmu, struct vm_state *vms, int msg } /* 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_logo(unsigned char *buf) 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 @@ static int adsi_load_vmail(struct ast_channel *chan, int *useadsi) #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_begin(struct ast_channel *chan, int *useadsi) 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_login(struct ast_channel *chan) 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_password(struct ast_channel *chan) 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_folders(struct ast_channel *chan, int start, char *label) 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 @@ static void adsi_message(struct ast_channel *chan, struct vm_state *vms) 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 @@ static void adsi_message(struct ast_channel *chan, struct vm_state *vms) 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_message(struct ast_channel *chan, struct vm_state *vms) 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 @@ static void adsi_delete(struct ast_channel *chan, struct vm_state *vms) 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 @@ static void adsi_status(struct ast_channel *chan, struct vm_state *vms) { 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 @@ static void adsi_status(struct ast_channel *chan, struct vm_state *vms) 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 @@ static void adsi_status2(struct ast_channel *chan, struct vm_state *vms) { 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 @@ static void adsi_status2(struct ast_channel *chan, struct vm_state *vms) 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_clear(struct ast_channel *chan) 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 @@ static int get_folder(struct ast_channel *chan, int start) 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 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, 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 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, 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 notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, 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 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st 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 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st break; case '2': use_directory = 1; - done=1; + done = 1; break; case '*': cmd = 't'; @@ -6529,9 +6528,9 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st 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 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v /* 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); /* Can't think of how other diffs might be helpful, but I'm sure somebody will think of something. */ @@ -6786,21 +6785,21 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v if (the_zone) { res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, the_zone->msg_format, the_zone->timezone); } - else if (!strcasecmp(chan->language,"pl")) /* POLISH syntax */ + else if (!strcasecmp(chan->language, "pl")) /* POLISH syntax */ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q HM", NULL); - else if (!strcasecmp(chan->language,"se")) /* SWEDISH syntax */ + else if (!strcasecmp(chan->language, "se")) /* SWEDISH syntax */ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' dB 'digits/at' k 'and' M", NULL); - else if (!strcasecmp(chan->language,"no")) /* NORWEGIAN syntax */ + else if (!strcasecmp(chan->language, "no")) /* NORWEGIAN syntax */ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q 'digits/at' HM", NULL); - else if (!strcasecmp(chan->language,"de")) /* GERMAN syntax */ + else if (!strcasecmp(chan->language, "de")) /* GERMAN syntax */ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Q 'digits/at' HM", NULL); - else if (!strcasecmp(chan->language,"nl")) /* DUTCH syntax */ + else if (!strcasecmp(chan->language, "nl")) /* DUTCH syntax */ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/nl-om' HM", NULL); - else if (!strcasecmp(chan->language,"it")) /* ITALIAN syntax */ + else if (!strcasecmp(chan->language, "it")) /* ITALIAN syntax */ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' 'digits/hours' k 'digits/e' M 'digits/minutes'", NULL); - else if (!strcasecmp(chan->language,"gr")) + else if (!strcasecmp(chan->language, "gr")) res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q H 'digits/kai' M ", NULL); - else if (!strcasecmp(chan->language,"pt_BR")) + else if (!strcasecmp(chan->language, "pt_BR")) res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' Ad 'digits/pt-de' B 'digits/pt-de' Y 'digits/pt-as' HM ", NULL); else if (!strncasecmp(chan->language, "zh", 2)) /* CHINESE (Taiwan) syntax */ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "qR 'vm-received'", NULL); @@ -6889,8 +6888,8 @@ static int play_message_duration(struct ast_channel *chan, struct vm_state *vms, return res; /* Convert from seconds to minutes */ - durations=atoi(duration); - durationm=(durations / 60); + durations = atoi(duration); + durationm = (durations / 60); ast_debug(1, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm); @@ -7028,8 +7027,8 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc category = ast_variable_retrieve(msg_cfg, "message", "category"); context = ast_variable_retrieve(msg_cfg, "message", "context"); - if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */ - context = ast_variable_retrieve(msg_cfg, "message","macrocontext"); + if (!strncasecmp("macro", context, 5)) /* Macro names in contexts are useless for our needs */ + context = ast_variable_retrieve(msg_cfg, "message", "macrocontext"); if (!res) { res = play_message_category(chan, category); } @@ -7120,8 +7119,8 @@ static int imap_delete_old_greeting (char *dir, struct vm_state *vms) } filename = strsep(&attachment, "."); if (!strcmp(filename, file)) { - sprintf (arg,"%d", i+1); - mail_setflag (vms->mailstream,arg,"\\DELETED"); + sprintf(arg, "%d", i + 1); + mail_setflag(vms->mailstream, arg, "\\DELETED"); } } mail_expunge(vms->mailstream); @@ -7200,7 +7199,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu) vms->curmsg++; make_file(fn2, sizeof(fn2), vms->curdir, vms->curmsg); if (strcmp(vms->fn, fn2)) { - RENAME(vms->curdir, x, vmu->mailbox,vmu->context, vms->curdir, vms->curmsg, vms->fn, fn2); + RENAME(vms->curdir, x, vmu->mailbox, vmu->context, vms->curdir, vms->curmsg, vms->fn, fn2); } } else if ((!strcasecmp(vms->curbox, "INBOX") || !strcasecmp(vms->curbox, "Urgent")) && vms->heard[x] && ast_test_flag(vmu, VM_MOVEHEARD) && !vms->deleted[x]) { /* Move to old folder before deleting */ @@ -7240,9 +7239,9 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu) ast_unlock_path(vms->curdir); #else if (vms->deleted) { - for (x=0;x < vmu->maxmsg;x++) { + for (x = 0; x < vmu->maxmsg; x++) { if (vms->deleted[x]) { - ast_debug(3,"IMAP delete of %d\n",x); + ast_debug(3, "IMAP delete of %d\n", x); DELETE(vms->curdir, x, vms->fn, vmu); } } @@ -7271,7 +7270,7 @@ static int vm_play_folder_name_gr(struct ast_channel *chan, char *box) buf = alloca(strlen(box)+2); strcpy(buf, box); - strcat(buf,"s"); + strcat(buf, "s"); if (!strcasecmp(box, "vm-INBOX") || !strcasecmp(box, "vm-Old")){ cmd = ast_play_and_wait(chan, buf); /* "NEA / PALIA" */ @@ -7750,7 +7749,7 @@ static int vm_intro_se(struct ast_channel *chan, struct vm_state *vms) } /* NORWEGIAN syntax */ -static int vm_intro_no(struct ast_channel *chan,struct vm_state *vms) +static int vm_intro_no(struct ast_channel *chan, struct vm_state *vms) { /* Introduce messages they have */ int res; @@ -7794,7 +7793,7 @@ static int vm_intro_no(struct ast_channel *chan,struct vm_state *vms) } /* GERMAN syntax */ -static int vm_intro_de(struct ast_channel *chan,struct vm_state *vms) +static int vm_intro_de(struct ast_channel *chan, struct vm_state *vms) { /* Introduce messages they have */ int res; @@ -7843,7 +7842,7 @@ static int vm_intro_de(struct ast_channel *chan,struct vm_state *vms) } /* SPANISH syntax */ -static int vm_intro_es(struct ast_channel *chan,struct vm_state *vms) +static int vm_intro_es(struct ast_channel *chan, struct vm_state *vms) { /* Introduce messages they have */ int res; @@ -7896,7 +7895,7 @@ return res; } /* BRAZILIAN PORTUGUESE syntax */ -static int vm_intro_pt_BR(struct ast_channel *chan,struct vm_state *vms) { +static int vm_intro_pt_BR(struct ast_channel *chan, struct vm_state *vms) { /* Introduce messages they have */ int res; if (!vms->oldmessages && !vms->newmessages && !vms->urgentmessages) { @@ -7941,7 +7940,7 @@ static int vm_intro_pt_BR(struct ast_channel *chan,struct vm_state *vms) { } /* FRENCH syntax */ -static int vm_intro_fr(struct ast_channel *chan,struct vm_state *vms) +static int vm_intro_fr(struct ast_channel *chan, struct vm_state *vms) { /* Introduce messages they have */ int res; @@ -7984,7 +7983,7 @@ static int vm_intro_fr(struct ast_channel *chan,struct vm_state *vms) } /* DUTCH syntax */ -static int vm_intro_nl(struct ast_channel *chan,struct vm_state *vms) +static int vm_intro_nl(struct ast_channel *chan, struct vm_state *vms) { /* Introduce messages they have */ int res; @@ -8035,7 +8034,7 @@ static int vm_intro_nl(struct ast_channel *chan,struct vm_state *vms) } /* PORTUGUESE syntax */ -static int vm_intro_pt(struct ast_channel *chan,struct vm_state *vms) +static int vm_intro_pt(struct ast_channel *chan, struct vm_state *vms) { /* Introduce messages they have */ int res; @@ -8098,7 +8097,7 @@ static int vm_intro_pt(struct ast_channel *chan,struct vm_state *vms) * vm-no : no ( no messages ) */ -static int vm_intro_cz(struct ast_channel *chan,struct vm_state *vms) +static int vm_intro_cz(struct ast_channel *chan, struct vm_state *vms) { int res; res = ast_play_and_wait(chan, "vm-youhave"); @@ -8372,7 +8371,7 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct char newpassword2[80] = ""; char prefile[PATH_MAX] = ""; unsigned char buf[256]; - int bytes=0; + int bytes = 0; if (ast_adsi_available(chan)) { bytes += adsi_logo(buf + bytes); @@ -8392,7 +8391,7 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct newpassword[0] = '\0'; if (cmd < 0 || cmd == 't' || cmd == '#') return cmd; - cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#"); + cmd = ast_readstring(chan, newpassword + strlen(newpassword), sizeof(newpassword) - 1, 2000, 10000, "#"); if (cmd < 0 || cmd == 't' || cmd == '#') return cmd; cmd = check_password(vmu, newpassword); /* perform password validation */ @@ -8422,12 +8421,12 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd)) vm_change_password_shell(vmu, newpassword); - ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); + ast_debug(1, "User %s set password to %s of length %d\n", vms->username, newpassword, (int) strlen(newpassword)); cmd = ast_play_and_wait(chan, vm_passchanged); /* If forcename is set, have the user record their name */ if (ast_test_flag(vmu, VM_FORCENAME)) { - snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); + snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); if (ast_fileexists(prefile, NULL, NULL) < 1) { cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); if (cmd < 0 || cmd == 't' || cmd == '#') @@ -8437,14 +8436,14 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct /* If forcegreetings is set, have the user record their greetings */ if (ast_test_flag(vmu, VM_FORCEGREET)) { - snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); + snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); if (ast_fileexists(prefile, NULL, NULL) < 1) { cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); if (cmd < 0 || cmd == 't' || cmd == '#') return cmd; } - snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); + snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); if (ast_fileexists(prefile, NULL, NULL) < 1) { cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); if (cmd < 0 || cmd == 't' || cmd == '#') @@ -8464,7 +8463,7 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct char newpassword2[80] = ""; char prefile[PATH_MAX] = ""; unsigned char buf[256]; - int bytes=0; + int bytes = 0; if (ast_adsi_available(chan)) { bytes += adsi_logo(buf + bytes); @@ -8479,16 +8478,16 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct retries = 0; switch (cmd) { case '1': /* Record your unavailable message */ - snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); - cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); + snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username); + cmd = play_record_review(chan, "vm-rec-unv", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); break; case '2': /* Record your busy message */ - snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); - cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); + snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username); + cmd = play_record_review(chan, "vm-rec-busy", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); break; case '3': /* Record greeting */ - snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); - cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); + snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username); + cmd = play_record_review(chan, "vm-rec-name", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms, NULL); break; case '4': /* manage the temporary greeting */ cmd = vm_tempgreeting(chan, vmu, vms, fmtc, record_gain); @@ -8505,7 +8504,7 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct else { if (cmd < 0) break; - if ((cmd = ast_readstring(chan,newpassword + strlen(newpassword),sizeof(newpassword)-1,2000,10000,"#")) < 0) { + if ((cmd = ast_readstring(chan, newpassword + strlen(newpassword), sizeof(newpassword) - 1, 2000, 10000, "#")) < 0) { break; } } @@ -8523,7 +8522,7 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct if (cmd < 0) break; - if ((cmd = ast_readstring(chan,newpassword2 + strlen(newpassword2),sizeof(newpassword2)-1,2000,10000,"#")) < 0) { + if ((cmd = ast_readstring(chan, newpassword2 + strlen(newpassword2), sizeof(newpassword2) - 1, 2000, 10000, "#")) < 0) { break; } } @@ -8537,7 +8536,8 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd)) vm_change_password_shell(vmu, newpassword); - ast_debug(1,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); + ast_debug(1, "User %s set password to %s of length %d\n", + vms->username, newpassword, (int) strlen(newpassword)); cmd = ast_play_and_wait(chan, vm_passchanged); break; case '*': @@ -8555,7 +8555,7 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct cmd = ast_play_and_wait(chan, "vm-options"); } if (!cmd) { - cmd = ast_waitfordigit(chan,6000); + cmd = ast_waitfordigit(chan, 6000); } if (!cmd) { retries++; @@ -8630,7 +8630,7 @@ static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, st ast_fileexists(prefile, NULL, NULL) > 0 ? /* XXX always true ? */ "vm-tempgreeting2" : "vm-tempgreeting"); if (!cmd) - cmd = ast_waitfordigit(chan,6000); + cmd = ast_waitfordigit(chan, 6000); if (!cmd) retries++; if (retries > 3) @@ -8654,7 +8654,7 @@ static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, st */ static int vm_browse_messages_gr(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) { - int cmd=0; + int cmd = 0; if (vms->lastmsg > -1) { cmd = play_message(chan, vmu, vms); @@ -8706,7 +8706,7 @@ static int vm_browse_messages_he(struct ast_channel *chan, struct vm_state *vms, */ static int vm_browse_messages_en(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) { - int cmd=0; + int cmd = 0; if (vms->lastmsg > -1) { cmd = play_message(chan, vmu, vms); @@ -8734,7 +8734,7 @@ static int vm_browse_messages_en(struct ast_channel *chan, struct vm_state *vms, */ static int vm_browse_messages_it(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) { - int cmd=0; + int cmd; if (vms->lastmsg > -1) { cmd = play_message(chan, vmu, vms); @@ -8760,7 +8760,7 @@ static int vm_browse_messages_it(struct ast_channel *chan, struct vm_state *vms, */ static int vm_browse_messages_es(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) { - int cmd=0; + int cmd; if (vms->lastmsg > -1) { cmd = play_message(chan, vmu, vms); @@ -8786,7 +8786,7 @@ static int vm_browse_messages_es(struct ast_channel *chan, struct vm_state *vms, */ static int vm_browse_messages_pt(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) { - int cmd=0; + int cmd; if (vms->lastmsg > -1) { cmd = play_message(chan, vmu, vms); @@ -8812,7 +8812,7 @@ static int vm_browse_messages_pt(struct ast_channel *chan, struct vm_state *vms, */ static int vm_browse_messages_zh(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu) { - int cmd=0; + int cmd; if (vms->lastmsg > -1) { cmd = play_message(chan, vmu, vms); @@ -8864,7 +8864,7 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_ struct ast_vm_user *res_vmu, const char *context, const char *prefix, int skipuser, int max_logins, int silent) { - int useadsi=0, valid=0, logretries=0; + int useadsi = 0, valid = 0, logretries = 0; char password[AST_MAX_EXTENSION]="", *passptr; struct ast_vm_user vmus, *vmu = NULL; @@ -8889,7 +8889,7 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_ if (chan->cid.cid_num) { ast_copy_string(mailbox, chan->cid.cid_num, mailbox_size); } else { - ast_verb(3,"Username not entered\n"); + ast_verb(3, "Username not entered\n"); return -1; } } @@ -8903,7 +8903,7 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_ ast_copy_string(mailbox, fullusername, mailbox_size); } - ast_debug(1, "Before find user for mailbox %s\n",mailbox); + ast_debug(1, "Before find user for mailbox %s\n", mailbox); vmu = find_user(&vmus, context, mailbox); if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) { /* saved password is blank, so don't bother asking */ @@ -8965,8 +8965,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) /* XXX This is, admittedly, some pretty horrendous code. For some reason it just seemed a lot easier to do with GOTO's. I feel like I'm back in my GWBASIC days. XXX */ - int res=-1; - int cmd=0; + int res = -1; + int cmd = 0; int valid = 0; char prefixstr[80] =""; char ext_context[256]=""; @@ -8975,7 +8975,7 @@ static int vm_execmain(struct ast_channel *chan, const char *data) int skipuser = 0; struct vm_state vms; struct ast_vm_user *vmu = NULL, vmus; - char *context=NULL; + char *context = NULL; int silentexit = 0; struct ast_flags flags = { 0 }; signed char record_gain = 0; @@ -9121,20 +9121,20 @@ static int vm_execmain(struct ast_channel *chan, const char *data) if (res == ERROR_LOCK_PATH) goto out; vms.oldmessages = vms.lastmsg + 1; - ast_debug(1, "Number of old messages: %d\n",vms.oldmessages); + ast_debug(1, "Number of old messages: %d\n", vms.oldmessages); /* check INBOX */ res = open_mailbox(&vms, vmu, NEW_FOLDER); if (res == ERROR_LOCK_PATH) goto out; vms.newmessages = vms.lastmsg + 1; - ast_debug(1, "Number of new messages: %d\n",vms.newmessages); + ast_debug(1, "Number of new messages: %d\n", vms.newmessages); /* Start in Urgent */ in_urgent = 1; res = open_mailbox(&vms, vmu, 11); /*11 is the Urgent folder */ if (res == ERROR_LOCK_PATH) goto out; vms.urgentmessages = vms.lastmsg + 1; - ast_debug(1, "Number of urgent messages: %d\n",vms.urgentmessages); + ast_debug(1, "Number of urgent messages: %d\n", vms.urgentmessages); /* Select proper mailbox FIRST!! */ if (play_auto) { @@ -9193,12 +9193,12 @@ static int vm_execmain(struct ast_channel *chan, const char *data) } } #ifdef IMAP_STORAGE - ast_debug(3, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit); + ast_debug(3, "Checking quotas: comparing %u to %u\n", vms.quota_usage, vms.quota_limit); if (vms.quota_limit && vms.quota_usage >= vms.quota_limit) { ast_debug(1, "*** QUOTA EXCEEDED!!\n"); cmd = ast_play_and_wait(chan, "vm-mailboxfull"); } - ast_debug(3, "Checking quotas: User has %d messages and limit is %d.\n",(vms.newmessages + vms.oldmessages),vmu->maxmsg); + ast_debug(3, "Checking quotas: User has %d messages and limit is %d.\n", (vms.newmessages + vms.oldmessages), vmu->maxmsg); if ((vms.newmessages + vms.oldmessages) >= vmu->maxmsg) { ast_log(AST_LOG_WARNING, "No more messages possible. User has %d messages and limit is %d.\n", (vms.newmessages + vms.oldmessages), vmu->maxmsg); cmd = ast_play_and_wait(chan, "vm-mailboxfull"); @@ -9312,8 +9312,8 @@ static int vm_execmain(struct ast_channel *chan, const char *data) goto out; } } else - cmd = ast_play_and_wait(chan,"vm-sorry"); - cmd='t'; + cmd = ast_play_and_wait(chan, "vm-sorry"); + cmd = 't'; break; case '*': /* Return to main menu */ @@ -9335,11 +9335,11 @@ static int vm_execmain(struct ast_channel *chan, const char *data) cmd = ast_play_and_wait(chan, "vm-tomakecall"); } if (ast_test_flag(vmu, VM_SVMAIL) && !cmd) - cmd=ast_play_and_wait(chan, "vm-leavemsg"); + cmd = ast_play_and_wait(chan, "vm-leavemsg"); if (!cmd) cmd = ast_play_and_wait(chan, "vm-starmain"); if (!cmd) - cmd = ast_waitfordigit(chan,6000); + cmd = ast_waitfordigit(chan, 6000); if (!cmd) vms.repeats++; if (vms.repeats > 3) @@ -9369,7 +9369,7 @@ static int vm_execmain(struct ast_channel *chan, const char *data) res = open_mailbox(&vms, vmu, 11); /* Open Urgent folder */ if (res == ERROR_LOCK_PATH) goto out; - ast_debug(1, "No more new messages, opened INBOX and got %d Urgent messages\n",vms.lastmsg + 1); + ast_debug(1, "No more new messages, opened INBOX and got %d Urgent messages\n", vms.lastmsg + 1); vms.curmsg = vms.lastmsg; if (vms.lastmsg < 0) cmd = ast_play_and_wait(chan, "vm-nomore"); @@ -9398,7 +9398,7 @@ static int vm_execmain(struct ast_channel *chan, const char *data) res = open_mailbox(&vms, vmu, NEW_FOLDER); if (res == ERROR_LOCK_PATH) goto out; - ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); + ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1; if (vms.lastmsg < 0) { cmd = ast_play_and_wait(chan, "vm-nomore"); @@ -9460,7 +9460,7 @@ static int vm_execmain(struct ast_channel *chan, const char *data) res = open_mailbox(&vms, vmu, NEW_FOLDER); if (res == ERROR_LOCK_PATH) goto out; - ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); + ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1; if (vms.lastmsg < 0) cmd = ast_play_and_wait(chan, "vm-nomore"); @@ -9497,7 +9497,7 @@ static int vm_execmain(struct ast_channel *chan, const char *data) res = open_mailbox(&vms, vmu, NEW_FOLDER); if (res == ERROR_LOCK_PATH) goto out; - ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); + ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1; if (vms.lastmsg < 0) cmd = ast_play_and_wait(chan, "vm-nomore"); @@ -9570,7 +9570,7 @@ static int vm_execmain(struct ast_channel *chan, const char *data) res = open_mailbox(&vms, vmu, NEW_FOLDER); if (res == ERROR_LOCK_PATH) goto out; - ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n",vms.lastmsg + 1); + ast_debug(1, "No more urgent messages, opened INBOX and got %d new messages\n", vms.lastmsg + 1); vms.curmsg = -1; if (vms.lastmsg < 0) cmd = ast_play_and_wait(chan, "vm-nomore"); @@ -9638,12 +9638,12 @@ out: } #ifdef IMAP_STORAGE /* expunge message - use UID Expunge if supported on IMAP server*/ - ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup); + ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n", deleted, expungeonhangup); if (vmu && deleted == 1 && expungeonhangup == 1 && vms.mailstream != NULL) { 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); @@ -9817,7 +9817,7 @@ static int vm_box_exists(struct ast_channel *chan, const char *data) if (!dep_warning) { dep_warning = 1; - ast_log(AST_LOG_WARNING, "MailboxExists is deprecated. Please use ${MAILBOX_EXISTS(%s)} instead.\n", (char *)data); + ast_log(AST_LOG_WARNING, "MailboxExists is deprecated. Please use ${MAILBOX_EXISTS(%s)} instead.\n", (char *) data); } box = ast_strdupa(data); @@ -9866,7 +9866,7 @@ static struct ast_custom_function mailbox_exists_acf = { static int vmauthenticate(struct ast_channel *chan, const char *data) { - char *s, *user=NULL, *context=NULL, mailbox[AST_MAX_EXTENSION] = ""; + char *s, *user = NULL, *context = NULL, mailbox[AST_MAX_EXTENSION] = ""; struct ast_vm_user vmus; char *options = NULL; int silent = 0, skipuser = 0; @@ -10498,11 +10498,11 @@ static int load_config(int reload) ast_copy_string(imapparentfolder, "\0", sizeof(imapparentfolder)); #endif /* set audio control prompts */ - strcpy(listen_control_forward_key,DEFAULT_LISTEN_CONTROL_FORWARD_KEY); - strcpy(listen_control_reverse_key,DEFAULT_LISTEN_CONTROL_REVERSE_KEY); - strcpy(listen_control_pause_key,DEFAULT_LISTEN_CONTROL_PAUSE_KEY); - strcpy(listen_control_restart_key,DEFAULT_LISTEN_CONTROL_RESTART_KEY); - strcpy(listen_control_stop_key,DEFAULT_LISTEN_CONTROL_STOP_KEY); + strcpy(listen_control_forward_key, DEFAULT_LISTEN_CONTROL_FORWARD_KEY); + strcpy(listen_control_reverse_key, DEFAULT_LISTEN_CONTROL_REVERSE_KEY); + strcpy(listen_control_pause_key, DEFAULT_LISTEN_CONTROL_PAUSE_KEY); + strcpy(listen_control_restart_key, DEFAULT_LISTEN_CONTROL_RESTART_KEY); + strcpy(listen_control_stop_key, DEFAULT_LISTEN_CONTROL_STOP_KEY); /* Free all the users structure */ free_vm_users(); @@ -10595,10 +10595,10 @@ static int load_config(int reload) /* External password changing command */ if ((val = ast_variable_retrieve(cfg, "general", "externpass"))) { - ast_copy_string(ext_pass_cmd,val,sizeof(ext_pass_cmd)); + ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd)); pwdchange = PWDCHANGE_EXTERNAL; } else if ((val = ast_variable_retrieve(cfg, "general", "externpassnotify"))) { - ast_copy_string(ext_pass_cmd,val,sizeof(ext_pass_cmd)); + ast_copy_string(ext_pass_cmd, val, sizeof(ext_pass_cmd)); pwdchange = PWDCHANGE_EXTERNAL | PWDCHANGE_INTERNAL; } @@ -10613,13 +10613,13 @@ static int load_config(int reload) if ((val = ast_variable_retrieve(cfg, "general", "imapserver"))) { ast_copy_string(imapserver, val, sizeof(imapserver)); } else { - ast_copy_string(imapserver,"localhost", sizeof(imapserver)); + ast_copy_string(imapserver, "localhost", sizeof(imapserver)); } /* IMAP server port */ if ((val = ast_variable_retrieve(cfg, "general", "imapport"))) { ast_copy_string(imapport, val, sizeof(imapport)); } else { - ast_copy_string(imapport,"143", sizeof(imapport)); + ast_copy_string(imapport, "143", sizeof(imapport)); } /* IMAP server flags */ if ((val = ast_variable_retrieve(cfg, "general", "imapflags"))) { @@ -10646,7 +10646,7 @@ static int load_config(int reload) if ((val = ast_variable_retrieve(cfg, "general", "imapfolder"))) { ast_copy_string(imapfolder, val, sizeof(imapfolder)); } else { - ast_copy_string(imapfolder,"INBOX", sizeof(imapfolder)); + ast_copy_string(imapfolder, "INBOX", sizeof(imapfolder)); } if ((val = ast_variable_retrieve(cfg, "general", "imapparentfolder"))) { ast_copy_string(imapparentfolder, val, sizeof(imapparentfolder)); @@ -10827,14 +10827,14 @@ static int load_config(int reload) while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */ q++; ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x])); - ast_debug(1,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]); + ast_debug(1, "VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]); } else { cidinternalcontexts[x][0] = '\0'; } } } if (!(val = ast_variable_retrieve(cfg, "general", "review"))){ - ast_debug(1,"VM Review Option disabled globally\n"); + ast_debug(1, "VM Review Option disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_REVIEW); @@ -10854,43 +10854,43 @@ static int load_config(int reload) ast_set2_flag((&globalflags), ast_true(val), VM_MESSAGEWRAP); if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){ - ast_debug(1,"VM Operator break disabled globally\n"); + ast_debug(1, "VM Operator break disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_OPERATOR); if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) { - ast_debug(1,"VM CID Info before msg disabled globally\n"); + ast_debug(1, "VM CID Info before msg disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_SAYCID); - if (!(val = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){ - ast_debug(1,"Send Voicemail msg disabled globally\n"); + if (!(val = ast_variable_retrieve(cfg, "general", "sendvoicemail"))){ + ast_debug(1, "Send Voicemail msg disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_SVMAIL); if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) { - ast_debug(1,"ENVELOPE before msg enabled globally\n"); + ast_debug(1, "ENVELOPE before msg enabled globally\n"); val = "yes"; } ast_set2_flag((&globalflags), ast_true(val), VM_ENVELOPE); if (!(val = ast_variable_retrieve(cfg, "general", "moveheard"))) { - ast_debug(1,"Move Heard enabled globally\n"); + ast_debug(1, "Move Heard enabled globally\n"); val = "yes"; } ast_set2_flag((&globalflags), ast_true(val), VM_MOVEHEARD); if (!(val = ast_variable_retrieve(cfg, "general", "forward_urgent_auto"))) { - ast_debug(1,"Autoset of Urgent flag on forwarded Urgent messages disabled globally\n"); + ast_debug(1, "Autoset of Urgent flag on forwarded Urgent messages disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_FWDURGAUTO); if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) { - ast_debug(1,"Duration info before msg enabled globally\n"); + ast_debug(1, "Duration info before msg enabled globally\n"); val = "yes"; } ast_set2_flag((&globalflags), ast_true(val), VM_SAYDURATION); @@ -10905,7 +10905,7 @@ static int load_config(int reload) } if (!(val = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) { - ast_debug(1,"We are not going to skip to the next msg after save/delete\n"); + ast_debug(1, "We are not going to skip to the next msg after save/delete\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_SKIPAFTERCMD); @@ -11189,7 +11189,7 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, ast_verb(3, "Destination number will be entered manually\n"); while (retries < 3 && cmd != 't') { destination[1] = '\0'; - destination[0] = cmd = ast_play_and_wait(chan,"vm-enter-num-to-call"); + destination[0] = cmd = ast_play_and_wait(chan, "vm-enter-num-to-call"); if (!cmd) destination[0] = cmd = ast_play_and_wait(chan, "vm-then-pound"); if (!cmd) @@ -11209,7 +11209,7 @@ static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, ast_verb(3, "User hit '*' to cancel outgoing call\n"); return 0; } - if ((cmd = ast_readstring(chan,destination + strlen(destination),sizeof(destination)-1,6000,10000,"#")) < 0) + if ((cmd = ast_readstring(chan, destination + strlen(destination), sizeof(destination) - 1, 6000, 10000, "#")) < 0) retries++; else cmd = 't'; @@ -11267,7 +11267,7 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg); /* Retrieve info from VM attribute file */ - snprintf(filename,sizeof(filename), "%s.txt", vms->fn); + snprintf(filename, sizeof(filename), "%s.txt", vms->fn); RETRIEVE(vms->curdir, vms->curmsg, vmu->mailbox, vmu->context); msg_cfg = ast_config_load(filename, config_flags); DISPOSE(vms->curdir, vms->curmsg); @@ -11284,8 +11284,8 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s cid = ast_strdupa(ast_variable_retrieve(msg_cfg, "message", "callerid")); context = ast_variable_retrieve(msg_cfg, "message", "context"); - if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */ - context = ast_variable_retrieve(msg_cfg, "message","macrocontext"); + if (!strncasecmp("macro", context, 5)) /* Macro names in contexts are useless for our needs */ + context = ast_variable_retrieve(msg_cfg, "message", "macrocontext"); switch (option) { case 3: /* Play message envelope */ if (!res)