Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Move the mimetype lookup into ui-plain.c
Diffstat (limited to 'source/shared.c')
-rw-r--r--source/shared.c49
1 file changed, 0 insertions, 49 deletions
diff --git a/source/shared.c b/source/shared.c
index c3867f6..5c5e65c 100644
--- a/source/shared.c
+++ b/source/shared.c
@@ -564,55 +564,6 @@ char *cgit_expand_macros(const char *text)
return result;
}
-char *cgit_get_mimetype_for_filename(const char *filename)
-{
- const char *ext;
- char *type, line[1024];
- struct string_list fields = STRING_LIST_INIT_NODUP;
- size_t i;
- FILE *file;
- struct string_list_item *entry;
-
- if (!filename)
- return NULL;
-
- ext = strrchr(filename, '.');
- if (!ext)
- return NULL;
- ++ext;
- if (!ext[0])
- return NULL;
- entry = string_list_lookup(&ctx.cfg.mimetypes, ext);
- if (entry)
- return xstrdup(entry->util);
-
- if (!ctx.cfg.mimetype_file)
- return NULL;
- file = fopen(ctx.cfg.mimetype_file, "r");
- if (!file)
- return NULL;
- while (fgets(line, sizeof(line), file)) {
- // A line of a mime.types file is one type followed by every
- // extension that maps to it.
- string_list_split_in_place(&fields, line, " \t\r\n", -1);
- string_list_remove_empty_items(&fields, 0);
- if (!fields.nr || fields.items[0].string[0] == '#') {
- string_list_clear(&fields, 0);
- continue;
- }
- type = fields.items[0].string;
- for (i = 1; i < fields.nr; i++) {
- if (!strcasecmp(ext, fields.items[i].string)) {
- fclose(file);
- return xstrdup(type);
- }
- }
- string_list_clear(&fields, 0);
- }
- fclose(file);
- return NULL;
-}
-
int cgit_readme_is_tracked(const char *readme)
{
const char *colon = strchr(readme, ':');