X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-hreq.c;h=3a47766f61e3ca1a3f0a689b24e73c8c2096d1ab;hb=3e3a29fa49ec494800a4aa866d84fba4eaa8261b;hp=5f44cba4753cb7b26cb15251dea713510ea6126a;hpb=66591b304b2f47d501342e9a84b2fe3a6121ab9c;p=src%2Fapp-framework-binder.git diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 5f44cba4..3a47766f 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -271,33 +271,38 @@ static const char *mimetype_fd_name(int fd, const char *filename) const char *extension = strrchr(filename, '.'); if (extension) { static const char *const known[][2] = { - { ".js", "text/javascript" }, - { ".html", "text/html" }, + /* keep it sorted for dichotomic search */ { ".css", "text/css" }, + { ".gif", "image/gif" }, + { ".html", "text/html" }, + { ".htm", "text/html" }, { ".ico", "image/x-icon"}, - /* TODO: CHECK ME { ".ico", "image/vnd.microsoft.icon" }, */ + { ".jpeg", "image/jpeg" }, { ".jpg", "image/jpeg" }, + { ".js", "text/javascript" }, + { ".json", "application/json" }, + { ".mp3", "audio/mpeg" }, { ".png", "image/png" }, { ".svg", "image/svg+xml" }, { ".ttf", "application/x-font-ttf"}, - { ".htm", "text/html" }, - { ".xml", "application/xml" }, { ".txt", "text/plain" }, { ".wav", "audio/x-wav" }, - { ".xhtml", "application/xhtml+xml" }, { ".xht", "application/xhtml+xml" }, - { ".gif", "image/gif" }, - { ".png", "image/png" }, - { ".mp3", "audio/mpeg" }, - { NULL, NULL } + { ".xhtml", "application/xhtml+xml" }, + { ".xml", "application/xml" } }; - int i = 0; - while (known[i][0]) { - if (!strcasecmp(extension, known[i][0])) { + int i, c, l = 0, u = sizeof known / sizeof *known; + while (l < u) { + i = (l + u) >> 1; + c = strcasecmp(extension, known[i][0]); + if (!c) { result = known[i][1]; break; } - i++; + if (c < 0) + u = i; + else + l = i + 1; } } #endif