/*!
* \brief Determines the highest message number in use for a given user and mailbox folder.
- * \param vmu
* \param dir the folder the mailbox folder to look for messages. Used to construct the SQL where clause.
*
* This method is used when mailboxes are stored in an ODBC back end.
* Typical use to set the msgnum would be to take the value returned from this method and add one to it.
*
* \return the value of zero or greater to indicate the last message index in use, -1 to indicate none.
-
*/
-static int last_message_index(struct ast_vm_user *vmu, char *dir)
+static int last_message_index(char *dir)
{
int x = -1;
int res;
/*!
* \brief Determines the highest message number in use for a given user and mailbox folder.
- * \param vmu
* \param dir the folder the mailbox folder to look for messages. Used to construct the SQL where clause.
*
* This method is used when mailboxes are stored on the filesystem. (not ODBC and not IMAP).
* \note Should always be called with a lock already set on dir.
* \return the value of zero or greaterto indicate the last message index in use, -1 to indicate none.
*/
-static int last_message_index(struct ast_vm_user *vmu, char *dir)
+static int last_message_index(char *dir)
{
int x;
unsigned char map[MAXMSGLIMIT] = "";
}
closedir(msgdir);
- for (x = 0; x < vmu->maxmsg; x++) {
- if (map[x] == 1) {
- stopcount--;
- } else if (map[x] == 0 && !stopcount) {
- break;
- }
+ for (x = 0; x < MAXMSGLIMIT && stopcount; x++) {
+ stopcount -= map[x];
}
return x - 1;
if (vm_lock_path(todir))
return ERROR_LOCK_PATH;
- recipmsgnum = last_message_index(recip, todir) + 1;
+ recipmsgnum = last_message_index(todir) + 1;
if (recipmsgnum < recip->maxmsg - (imbox ? 0 : inprocess_count(vmu->mailbox, vmu->context, 0))) {
make_file(topath, sizeof(topath), todir, recipmsgnum);
#ifndef ODBC_STORAGE
return -1;
}
- msgnum = last_message_index(recipient, dir) + 1;
+ msgnum = last_message_index(dir) + 1;
#endif
/* Lock the directory receiving the voicemail since we want it to still exist when we attempt to copy the voicemail.
}
} else {
#ifndef IMAP_STORAGE
- msgnum = last_message_index(vmu, dir) + 1;
+ msgnum = last_message_index(dir) + 1;
#endif
make_file(fn, sizeof(fn), dir, msgnum);
return ERROR_LOCK_PATH;
}
- for (x = 0, dest = 0; dest != stopcount && x < vmu->maxmsg + 10; x++) {
+ for (x = 0, dest = 0; dest != stopcount && x < MAXMSGLIMIT; x++) {
make_file(sfn, sizeof(sfn), dir, x);
if (EXISTS(dir, x, sfn, NULL)) {
if (vm_lock_path(ddir))
return ERROR_LOCK_PATH;
- x = last_message_index(vmu, ddir) + 1;
+ x = last_message_index(ddir) + 1;
if (box == 10 && x >= vmu->maxdeletedmsg) { /* "Deleted" folder*/
x--;
return ERROR_LOCK_PATH;
}
- /* for local storage, checks directory for messages up to maxmsg limit */
- last_msg = last_message_index(vmu, vms->curdir);
+ /* for local storage, checks directory for messages up to MAXMSGLIMIT */
+ last_msg = last_message_index(vms->curdir);
ast_unlock_path(vms->curdir);
if (last_msg < -1) {
}
/* update count as message may have arrived while we've got mailbox open */
- last_msg_idx = last_message_index(vmu, vms->curdir);
+ last_msg_idx = last_message_index(vms->curdir);
if (last_msg_idx != vms->lastmsg) {
ast_log(AST_LOG_NOTICE, "%d messages received after mailbox opened.\n", last_msg_idx - vms->lastmsg);
}