summaryrefslogtreecommitdiff
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2008-02-06 03:05:00 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2008-02-06 03:05:00 +0000
commitee3cc80284a808678cfd33c3d35939e11c8dad44 (patch)
treea07c75ad7d72f7d94c7d80d92c6aa3e00c2627f5 /apps/app_voicemail.c
parent267220d043f34665df53036268bb3c7a30d3f13f (diff)
Merged revisions 102576 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r102576 | tilghman | 2008-02-05 18:26:02 -0600 (Tue, 05 Feb 2008) | 4 lines Move around some defines to unbreak ODBC storage. (closes issue #11932) Reported by: snuffy ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@102602 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index be3e5db3d..8d169061b 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1626,6 +1626,41 @@ static void rename_file(char *sfn, char *dfn)
}
#endif
+#ifndef IMAP_STORAGE
+/*! \brief
+ * A negative return value indicates an error.
+ * \note Should always be called with a lock already set on dir.
+ */
+static int last_message_index(struct ast_vm_user *vmu, char *dir)
+{
+ int x;
+ unsigned char map[MAXMSGLIMIT] = "";
+ DIR *msgdir;
+ struct dirent *msgdirent;
+ int msgdirint;
+
+ /* Reading the entire directory into a file map scales better than
+ * doing a stat repeatedly on a predicted sequence. I suspect this
+ * is partially due to stat(2) internally doing a readdir(2) itself to
+ * find each file. */
+ msgdir = opendir(dir);
+ while ((msgdirent = readdir(msgdir))) {
+ if (sscanf(msgdirent->d_name, "msg%d", &msgdirint) == 1 && msgdirint < MAXMSGLIMIT)
+ map[msgdirint] = 1;
+ }
+ closedir(msgdir);
+
+ for (x = 0; x < vmu->maxmsg; x++) {
+ if (map[x] == 0)
+ break;
+ }
+
+ return x - 1;
+}
+
+#endif /*#ifndef IMAP_STORAGE*/
+#endif /*#else of #ifdef ODBC_STORAGE*/
+
static int copy(char *infile, char *outfile)
{
int ifd;
@@ -1718,41 +1753,6 @@ static void copy_plain_file(char *frompath, char *topath)
ast_variables_destroy(var);
}
-#ifndef IMAP_STORAGE
-/*! \brief
- * A negative return value indicates an error.
- * \note Should always be called with a lock already set on dir.
- */
-static int last_message_index(struct ast_vm_user *vmu, char *dir)
-{
- int x;
- unsigned char map[MAXMSGLIMIT] = "";
- DIR *msgdir;
- struct dirent *msgdirent;
- int msgdirint;
-
- /* Reading the entire directory into a file map scales better than
- * doing a stat repeatedly on a predicted sequence. I suspect this
- * is partially due to stat(2) internally doing a readdir(2) itself to
- * find each file. */
- msgdir = opendir(dir);
- while ((msgdirent = readdir(msgdir))) {
- if (sscanf(msgdirent->d_name, "msg%d", &msgdirint) == 1 && msgdirint < MAXMSGLIMIT)
- map[msgdirint] = 1;
- }
- closedir(msgdir);
-
- for (x = 0; x < vmu->maxmsg; x++) {
- if (map[x] == 0)
- break;
- }
-
- return x - 1;
-}
-
-#endif /*#ifndef IMAP_STORAGE*/
-#endif /*#else of #ifdef ODBC_STORAGE*/
-#ifndef ODBC_STORAGE
static int vm_delete(char *file)
{
char *txt;
@@ -1770,7 +1770,6 @@ static int vm_delete(char *file)
unlink(txt);
return ast_filedelete(file, NULL);
}
-#endif
static int inbuf(struct baseio *bio, FILE *fi)
{
@@ -4521,7 +4520,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
}
/* Remove surrogate file */
- DELETE(tmpdir, curmsg, msgfile);
+ vm_delete(msgfile);
}
/* If anything failed above, we still have this list to free */