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部署 ➜ ...
随机推荐
- 让Tomcat支持中文路径名和中文文件名
http://hdwangyi.iteye.com/blog/107709 Tomcat是Java开发者使用得较多的一个Web服务器,因为它占用资源小,运行速度快等特点,深受Java Web程序员的喜 ...
- Linux系统下UDP发送和接收广播消息小样例
[cpp] view plaincopy // 发送端 #include <iostream> #include <stdio.h> #include <sys/sock ...
- hadoop错误ERROR namenode.NameNode (NameNode.javamain(1657)) - Failed to start namenode java.net.BindException:Port in use:host1:50070
解决方法: 1.通过lsof -i:50070(lsof可以通过yum install lsof安装)查看,发现是mysql被占用了 2.修改mysql端口 从/usr/share/mysql/my- ...
- Reactor构架模式--转载
原文:http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece76310468a3b404380143c86964868d4e419ce3b464 ...
- java 对象的this使用 java方法中参数传递特性 方法的递归
一.this关键字,使用的情形,以及如何使用. 1.使用的情形 类中的方法体中使用this --初始化该对象 类的构造器中使用this --引用,调用该方法的对象 2.不写this,调用 只要方法或 ...
- HDU2053.JAVA
Switch Game Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- Java获取当前目录方法整理
假设项目路径是E:\Workspaces\MyProgram\FilePath 1.使用System.getProperty("user.dir"),获得项目的根路径,返回Stri ...
- Redis Windows版安装及简单使用
1.Redis简介及优势 Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库. 特点: Redis支持数据的持久化,可以将内存中的数据保存在磁盘中,重启的时候可以再次 ...
- [图文]centos6.3搭建FTP服务器教程
我一开始是参照这个教程做的 http://www.linuxren.net/better/centos63-ftp.html 可是问题总是免不了的,我遇到几个问题. 一开始使用terminal的时候一 ...
- phpMyAdmin教程 之 创建新用户/导入/导出数据库
盗用了被人的教程. 需要看就点击进去吧.复制过来实在是过意不去 http://www.wpdaxue.com/phpmyadmin-import-export-database.html