summaryrefslogtreecommitdiffstats
path: root/mx.c
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1998-06-16 20:59:20 +0000
committerThomas Roessler <roessler@does-not-exist.org>1998-06-16 20:59:20 +0000
commitfc9fb9a7fa23e0353098871276e0c5417191891a (patch)
tree302c307726fe9815da148cf74529123c9c348fed /mx.c
parent338c64a4f6615fd001f986d20060bb44a1c6d74e (diff)
Avoid pointless error messages from mx_get_magic() when
called from an mx_open_mailbox_append() on a non-existing mailbox.
Diffstat (limited to 'mx.c')
-rw-r--r--mx.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/mx.c b/mx.c
index b405bf4a..8147a64e 100644
--- a/mx.c
+++ b/mx.c
@@ -367,6 +367,16 @@ FILE *mx_open_file_lock (const char *path, const char *mode)
* 0 not a mailbox
* -1 error
*/
+
+#ifdef USE_IMAP
+
+static int mx_is_imap(const char *p)
+{
+ return p && (*p == '{');
+}
+
+#endif
+
int mx_get_magic (const char *path)
{
struct stat st;
@@ -375,7 +385,7 @@ int mx_get_magic (const char *path)
FILE *f;
#ifdef USE_IMAP
- if (*path == '{')
+ if(mx_is_imap(path))
return M_IMAP;
#endif /* USE_IMAP */
@@ -467,18 +477,21 @@ int mx_set_magic (const char *s)
static int mx_open_mailbox_append (CONTEXT *ctx)
{
+ struct stat sb;
+
ctx->append = 1;
- ctx->magic = mx_get_magic (ctx->path);
#ifdef USE_IMAP
- if (ctx->magic == M_IMAP)
- {
+
+ if(mx_is_imap(ctx))
return imap_open_mailbox_append (ctx);
- }
- else
+
#endif
- if (access (ctx->path, W_OK) == 0)
+
+ if(stat(ctx->path, &sb) == 0)
{
+ ctx->magic = mx_get_magic (ctx->path);
+
switch (ctx->magic)
{
case 0: