1 // File Name: _get_file_type.c
2 // Author: jiujue
3 // Created Time: 2019年04月06日 星期六 19时14分07秒
4
5
6 #include "head.h"
7
8 const char *get_file_type(const char *name)
9 {
10 char* dot;
11
12
13 dot = strrchr(name, '.');
14 if (dot == NULL)
15 return "text/plain; charset=utf-8";
16 if (strcmp(dot, ".html") == 0 || strcmp(dot, ".htm") == 0)
17 return "text/html; charset=utf-8";
18 if (strcmp(dot, ".jpg") == 0 || strcmp(dot, ".jpeg") == 0)
19 return "image/jpeg";
20 if (strcmp(dot, ".gif") == 0)
21 return "image/gif";
22 if (strcmp(dot, ".png") == 0)
23 return "image/png";
24 if (strcmp(dot, ".css") == 0)
25 return "text/css";
26 if (strcmp(dot, ".au") == 0)
27 return "audio/basic";
28 if (strcmp( dot, ".wav" ) == 0)
29 return "audio/wav";
30 if (strcmp(dot, ".avi") == 0)
31 return "video/x-msvideo";
32 if (strcmp(dot, ".mov") == 0 || strcmp(dot, ".qt") == 0)
33 return "video/quicktime";
34 if (strcmp(dot