summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-03-13 11:36:28 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-03-13 11:36:28 +0000
commit844f53102f0232825c0681db3a4438a0db8cef6d (patch)
tree5616995f2527a815b81ad3b8a40c6d9d7010c667
parente54f8c21f123dacc17fa4b5d8876eb47afb2f0d1 (diff)
downloadmailutils-844f53102f0232825c0681db3a4438a0db8cef6d.tar.gz
mailutils-844f53102f0232825c0681db3a4438a0db8cef6d.tar.bz2
(mime_context_fill): Return integer code
(display_stream_mailcap): Bail out if mime_context_fill returns 1
-rw-r--r--lib/mailcap.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/mailcap.c b/lib/mailcap.c
index 350ae74c4..a4f805b54 100644
--- a/lib/mailcap.c
+++ b/lib/mailcap.c
@@ -56,7 +56,7 @@ struct mime_context
#define DEBUG(c,l,f) if ((c)->debug_level > (l)) printf f
-static void
+static int
mime_context_fill (struct mime_context *ctx, const char *file,
stream_t input, header_t hdr, const char *no_ask,
int interactive, int dry_run, int debug_level)
@@ -66,7 +66,9 @@ mime_context_fill (struct mime_context *ctx, const char *file,
memset (ctx, 0, sizeof *ctx);
ctx->input = input;
ctx->hdr = hdr;
- header_aget_value (hdr, MU_HEADER_CONTENT_TYPE, &ctx->content_type_buffer);
+ if (header_aget_value (hdr, MU_HEADER_CONTENT_TYPE,
+ &ctx->content_type_buffer))
+ return 1;
ctx->content_type = strtok_r (ctx->content_type_buffer, ";", &sp);
ctx->temp_file = file ? strdup (file) : NULL;
ctx->unlink_temp_file = 0;
@@ -97,6 +99,7 @@ mime_context_fill (struct mime_context *ctx, const char *file,
list_append (ctx->no_ask_types, p);
}
}
+ return 0;
}
static void
@@ -650,6 +653,9 @@ display_stream_mailcap (const char *ident, stream_t stream, header_t hdr,
struct mime_context ctx;
int rc = 1;
+ if (mime_context_fill (&ctx, ident, stream, hdr,
+ no_ask, interactive, dry_run, debug_level))
+ return 1;
mailcap_path = getenv ("MAILCAP");
if (!mailcap_path)
{
@@ -661,8 +667,6 @@ display_stream_mailcap (const char *ident, stream_t stream, header_t hdr,
mailcap_path = strdup (mailcap_path);
obstack_init (&expand_stack);
- mime_context_fill (&ctx, ident, stream, hdr, no_ask, interactive, dry_run,
- debug_level);
for (p = strtok_r (mailcap_path, ":", &sp); p; p = strtok_r (NULL, ":", &sp))
{
@@ -670,8 +674,8 @@ display_stream_mailcap (const char *ident, stream_t stream, header_t hdr,
break;
}
- mime_context_release (&ctx);
obstack_free (&expand_stack, NULL);
free (mailcap_path);
+ mime_context_release (&ctx);
return rc;
}

Return to:

Send suggestions and report system problems to the System administrator.