* at the top of the source tree.
*/
-/*! \file
- *
+/*!
+ * \file
+ * \author Mark Spencer <markster@digium.com>
* \brief Comedian Mail - Voicemail System
*
- * \author Mark Spencer <markster@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
* \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
<defaultenabled>no</defaultenabled>
</member>
</category>
- ***/
+***/
#include "asterisk.h"
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);
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))
*/
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;
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;
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 */
/* 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);
}
}
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;
}
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. */
}
/* 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);
}
}
/* 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);
}
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;
/* 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 */
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) {
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);
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;
context++;
} else {
context = "default";
- mailboxnc = (char *)mailbox_context;
+ mailboxnc = (char *) mailbox_context;
}
if (newmsgs) {
if ((*newmsgs = messagecount(context, mailboxnc, imapfolder)) < 0)
}
}
}
- if ((context= strchr(tmp, '@')))
+ if ((context = strchr(tmp, '@')))
*context++ = '\0';
else
context = "default";
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;
}
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);
/* 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);
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");
/* 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);
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);
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)
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)
{
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:
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));
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));
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;
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;
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);
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;
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);
{
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]="";
SQLSMALLINT nullable;
SQLULEN colsize;
SQLLEN colsize2;
- FILE *f=NULL;
+ FILE *f = NULL;
char rowdata[80];
char fn[PATH_MAX];
char full_fn[PATH_MAX];
*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
}
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);
}
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);
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);
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);
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);
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);
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);
+ 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);
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 = "" };
*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
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;
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);
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);
{
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")) {
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;
return 0;
}
- bio->iolen= l;
- bio->iocp= 0;
+ bio->iolen = l;
+ bio->iocp = 0;
return 1;
}
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++;
'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;
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;
}
}
- 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);
}
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);
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);
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];
/* 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");
/* 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 */
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");
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);
#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);
}
/* 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
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];
#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);
}
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;
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;
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;
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];
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));
}
}
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;
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];
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;
{
unsigned char buf[256] = "";
char buf1[256] = "", buf2[256] = "";
- int bytes=0;
+ int bytes = 0;
unsigned char keys[8];
int x;
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;
{
unsigned char buf[256] = "";
char buf1[256] = "", buf2[256] = "";
- int bytes=0;
+ int bytes = 0;
unsigned char keys[8];
int x;
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;
static void adsi_goodbye(struct ast_channel *chan)
{
unsigned char buf[256];
- int bytes=0;
+ int bytes = 0;
if (!ast_adsi_available(chan))
return;
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" */
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
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)
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]="";
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;
break;
case '2':
use_directory = 1;
- done=1;
+ done = 1;
break;
case '*':
cmd = 't';
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) {
/* 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. */
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);
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);
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);
}
}
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);
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 */
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);
}
}
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" */
}
/* 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;
}
/* 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;
}
/* 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;
}
/* 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) {
}
/* 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;
}
/* 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;
}
/* 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;
* 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");
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);
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 */
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 == '#')
/* 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 == '#')
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);
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);
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;
}
}
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;
}
}
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 '*':
cmd = ast_play_and_wait(chan, "vm-options");
}
if (!cmd) {
- cmd = ast_waitfordigit(chan,6000);
+ cmd = ast_waitfordigit(chan, 6000);
}
if (!cmd) {
retries++;
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)
*/
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);
*/
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);
*/
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);
*/
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);
*/
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);
*/
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);
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;
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;
}
}
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 */
/* 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]="";
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;
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) {
}
}
#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");
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 */
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)
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");
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");
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");
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");
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");
}
#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);
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);
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;
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();
/* 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;
}
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"))) {
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));
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);
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);
}
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);
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)
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';
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);
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)