http server v0.1_mime.c
#include <string.h>
#include "mime.h" static STR_MIME_MAP mime_map[]= { MIME_MAP(MIME_STR_GEN) }; void get_mime_type(const char* filename, EN_MIME_TYPE* filetype)
{
int i =;
for(i=; i<= MIME_ELSE; i++)
{
if(strstr(filename, mime_map[i].extension))
{
*filetype = (EN_MIME_TYPE)i;
break;
}
if( i == MIME_ELSE)
*filetype = MIME_ELSE;
} } char* get_resp_type(EN_MIME_TYPE filetype)
{
if(filetype > MIME_ELSE || filetype < )
return NULL; return mime_map[filetype].mimetype;
}
#ifndef __MIME__H
#define __MIME__H #define MIME_MAP(xx)\
xx(HTML, ".html", "text/html\n")\
xx(HTM, ".htm", "text/html\n")\
xx(XML, ".xml", "text/xml\n")\
xx(IMAGE_GIF, ".gif", "image/gif\n")\
xx(IMAGE_JPG, ".jpg", "image/jpeg\n")\
xx(IMAGE_PNG, ".png", "image/png\n")\
xx(TEXT, ".txt", "text/html\n")\
xx(MP3, ".mp3", "audio/x-mpeg\n")\
xx(ELSE, "*", "text/plain\n")\ #define MIME_ENUM_GEN(n, s, t) MIME_##n, #define MIME_STR_GEN(n, s, t) {MIME_##n, s, t}, typedef enum en_mine_type
{
MIME_MAP(MIME_ENUM_GEN)
}EN_MIME_TYPE; typedef struct str_mime_map
{
EN_MIME_TYPE entype;
char* extension;
char* mimetype;
}STR_MIME_MAP; void get_mime_type(const char* filename, EN_MIME_TYPE* filetype); char* get_resp_type(EN_MIME_TYPE filetype);
//typedef struct str_mime_map STR_MIME_MAP; #endif
http server v0.1_mime.c的更多相关文章
- http server v0.1_http_reponse.c
#include <string.h> #include <sys/stat.h> #include <sys/mman.h> #include <fcntl ...
- http server v0.1_http_server.c
/**************************************************************** filename: http_server.c author: xx ...
- http server v0.1_http_parse.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include "mime.h&q ...
- http server v0.1_http_webapp.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h&g ...
- 用FileZilla Server开FTP
FileZilla(教程)是经典的开源FTP解决方案,包括FileZilla客户端和FileZilla Server.其中,FileZilla Server的功能比起商业软件FTP Serv-U毫不逊 ...
- DNS隧道之DNS2TCP实现——dns2tcpc必须带server IP才可以,此外ssh可以穿过墙的,设置代理上网
我自己的命令: server端: dns2tcpd -F -d 1 -f ./dns2tcpd.conf 输出: 09:08:59 : Debug options.c:97 Add resource ...
- docker 下 安装rancher 笔记
sudo yum update 更新系统环境 curl -sSL https://get.docker.com/ | sh 安装最新docker版本 systemctl start docker.se ...
- 容器基础(七): 使用docker compose部署程序
配置 在上一节的基础上, 增加如下的docker-compose.yml文件, 然后用docker-compose up命令启动容器进行部署: version: " services: s ...
- 容器基础(八): 使用docker swarm部署程序
环境 基于上一节的env/server:v0.1, env/worker:v0.1镜像, 在基于debian8.2的两台机器上测试部署docker swarm. docker service部署 ➜ ...
随机推荐
- 指纹增强程序Hong_enhancement
本算法是基于Lin Hong et al 的论文“Fingerprint ImageEnhancement: Algorithm and Performance Evaluation”编写而成.其中一 ...
- Java的finally理解
1.为什么要用finally 先看一个没有finally的异常处理try-catch语句: 如果count为要使用到的资源,而且用完要求释放此资源.那么我们能够把释放资源的语句放到try-catch后 ...
- uva-10487 - Closest Sums
暴力枚举后去重最后二分加推断找答案 #include<iostream> #include<map> #include<string> #include<cs ...
- java 使用线程做一个简单的ATM存取款实例.(转)
线程 Thread 类,和 Runable 接口 比较两者的特点和应用领域. 可以,直接继承线程Thread类.该方法编写简单,可以直接操作线程,适用于单重继承情况,因而不能在继承其他类 实现Runn ...
- GCC内嵌汇编
http://blog.csdn.net/mydo/article/details/8279924
- MapReduce链接作业
对于简单的分析程序,我们只需一个MapReduce就能搞定,然而对于比较复杂的分析程序,我们可能需要多个Job或者多个Map或者Reduce进行计算.下面我们来说说多个Job或者多个MapReduce ...
- android获取其他应用权限(修改状态)
这两天老大发话说要我研究一下安卓安全软件的功能,先抽取了一个小模块,研究权限管理 一开始就去packagemanager 去看发现有几个方法: 就先去看了一下IPackagemanager 里面的方法 ...
- Linux平台的boost安装全解
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...
- UIWindow详解
UIScreen(屏幕),UIWindow(窗口),UIView(视图)是iOS的几个基本界面元素.其中UIWindow(窗口)和UIView(视图)是为iPhone应用程序构造用户界面的可视组件.U ...
- Setup Tensorflow with GPU on Mac OSX 10.11
Setup Tensorflow with GPU on OSX 10.11 环境描述 电脑:MacBook Pro 15.6 CPU: 2.7GHz 显卡: GT 650m 系统:OSX 10.11 ...