diff options
author | Christian Hesse <mail@eworm.de> | 2015-08-14 16:50:56 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2015-08-17 14:25:08 +0200 |
commit | f5c83d7b5ddceb03e1c6bda2e43c48500c7da9f5 (patch) | |
tree | 7c14ef706458087fabc88ad307a70cdb22df367c /ui-plain.c | |
parent | 73ef8567f04c2dea8fbf83213b28e0cd1dff98f3 (diff) | |
download | cgit-f5c83d7b5ddceb03e1c6bda2e43c48500c7da9f5.tar.gz cgit-f5c83d7b5ddceb03e1c6bda2e43c48500c7da9f5.tar.xz |
move get_mimetype_from_file() to shared
Signed-off-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'ui-plain.c')
-rw-r--r-- | ui-plain.c | 40 |
1 files changed, 0 insertions, 40 deletions
@@ -16,46 +16,6 @@ struct walk_tree_context { int match; }; -static char *get_mimetype_from_file(const char *filename, const char *ext) -{ - static const char *delimiters; - char *result; - FILE *fd; - char line[1024]; - char *mimetype; - char *token; - - if (!filename) - return NULL; - - fd = fopen(filename, "r"); - if (!fd) - return NULL; - - delimiters = " \t\r\n"; - result = NULL; - - /* loop over all lines in the file */ - while (!result && fgets(line, sizeof(line), fd)) { - mimetype = strtok(line, delimiters); - - /* skip empty lines and comment lines */ - if (!mimetype || (mimetype[0] == '#')) - continue; - - /* loop over all extensions of mimetype */ - while ((token = strtok(NULL, delimiters))) { - if (!strcasecmp(ext, token)) { - result = xstrdup(mimetype); - break; - } - } - } - fclose(fd); - - return result; -} - static int print_object(const unsigned char *sha1, const char *path) { enum object_type type; |