mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
MIME: get_mime_type_option: Re-arrange
More option API usage, less string manipulation.
This commit is contained in:
parent
9bc5317b13
commit
386684fe50
@ -146,23 +146,21 @@ get_content_type_default(unsigned char *extension)
|
|||||||
static struct option *
|
static struct option *
|
||||||
get_mime_type_option(unsigned char *type)
|
get_mime_type_option(unsigned char *type)
|
||||||
{
|
{
|
||||||
|
struct option *opt;
|
||||||
struct string name;
|
struct string name;
|
||||||
int oldlength;
|
|
||||||
|
opt = get_opt_rec_real(config_options, "mime.type");
|
||||||
|
if (!opt) return NULL;
|
||||||
|
|
||||||
if (!init_string(&name)) return NULL;
|
if (!init_string(&name)) return NULL;
|
||||||
|
|
||||||
add_to_string(&name, "mime.type.");
|
|
||||||
oldlength = name.length;
|
|
||||||
if (add_optname_to_string(&name, type, strlen(type))) {
|
if (add_optname_to_string(&name, type, strlen(type))) {
|
||||||
unsigned char *pos = name.source + oldlength;
|
|
||||||
|
|
||||||
/* Search for end of the base type. */
|
/* Search for end of the base type. */
|
||||||
pos = strchr(pos, '/');
|
unsigned char *pos = strchr(name.source, '/');
|
||||||
if (pos) {
|
|
||||||
struct option *opt;
|
|
||||||
|
|
||||||
|
if (pos) {
|
||||||
*pos = '.';
|
*pos = '.';
|
||||||
opt = get_opt_rec_real(config_options, name.source);
|
opt = get_opt_rec_real(opt, name.source);
|
||||||
done_string(&name);
|
done_string(&name);
|
||||||
|
|
||||||
return opt;
|
return opt;
|
||||||
|
Loading…
Reference in New Issue
Block a user