From 9bc5317b13713e60b0dbbc96e1af993f6a5f39c9 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Fri, 5 May 2006 20:58:30 +0000 Subject: [PATCH] MIME: Re-arrange Let get_mime_type_name return an option instead of a name, and rename it to get_mime_type_option. --- src/mime/backend/default.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/mime/backend/default.c b/src/mime/backend/default.c index 0715c32fc..4e77e557b 100644 --- a/src/mime/backend/default.c +++ b/src/mime/backend/default.c @@ -143,8 +143,8 @@ get_content_type_default(unsigned char *extension) return NULL; } -static unsigned char * -get_mime_type_name(unsigned char *type) +static struct option * +get_mime_type_option(unsigned char *type) { struct string name; int oldlength; @@ -159,8 +159,13 @@ get_mime_type_name(unsigned char *type) /* Search for end of the base type. */ pos = strchr(pos, '/'); if (pos) { + struct option *opt; + *pos = '.'; - return name.source; + opt = get_opt_rec_real(config_options, name.source); + done_string(&name); + + return opt; } } @@ -171,13 +176,9 @@ get_mime_type_name(unsigned char *type) static inline struct option * get_mime_handler_option(unsigned char *type, int xwin) { - struct option *opt; - unsigned char *name = get_mime_type_name(type); + struct option *opt = get_mime_type_option(type); + unsigned char *name; - if (!name) return NULL; - - opt = get_opt_rec_real(config_options, name); - mem_free(name); if (!opt) return NULL; name = straconcat("mime.handler.", opt->value.string, @@ -197,17 +198,10 @@ get_mime_handler_default(unsigned char *type, int have_x) if (opt_tree) { unsigned char *desc = ""; - unsigned char *mt = get_mime_type_name(type); + struct option *opt = get_mime_type_option(type); /* Try to find some description to assing to @name */ - if (mt) { - struct option *opt; - - opt = get_opt_rec_real(config_options, mt); - mem_free(mt); - - if (opt) desc = opt->value.string; - } + if (opt) desc = opt->value.string; return init_mime_handler(get_opt_str_tree(opt_tree, "program"), desc, default_mime_module.name,