summaryrefslogtreecommitdiffabout
path: root/lib
authorSergey Poznyakoff <gray@gnu.org.ua>2005-03-13 11:36:28 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2005-03-13 11:36:28 (GMT)
commit844f53102f0232825c0681db3a4438a0db8cef6d (patch) (side-by-side diff)
tree5616995f2527a815b81ad3b8a40c6d9d7010c667 /lib
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
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/mailcap.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/mailcap.c b/lib/mailcap.c
index 350ae74..a4f805b 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.