#ifndef MACROS_H_
#define MACROS_H_
//=============Tracker分割符号===============
#define JOINSYMBOL "&"
#define EQUALSYMBOL "="
#define ENDSYMBOL "\r\n"
//===========以下三个宏,只能同时打开一个===============
#define USESENDFILE 1 // 使用sendfile发送文件
//#define USENEON 1 // 使用neon库发送文件(需要在Makefile中加入对neon库)
//#define USECURL 1 // 使用curl发送文件
// // 如果以上不使用,默认使用的socket write方法
//============================
//=========文件每次发送数量(2M)=======
#define MAXFILEBLACK 1024*200
//=========文件读取时每块读取数量=====
#define MAXREADFILE 8192
//=========发送失败循环尝试循环次数===========
#define LOOPNUMBER 3
//=========尝试sleep时间=======
//#define SLEEPTIME 1000*1000
#define SLEEPTIME 100*1000
/* URI ABNF from RFC 3986: */
#define PS (0x0001) /* "+" */
#define PC (0x0002) /* "%" */
#define DS (0x0004) /* "-" */
#define DT (0x0008) /* "." */
#define US (0x0010) /* "_" */
#define TD (0x0020) /* "~" */
#define FS (0x0040) /* "/" */
#define CL (0x0080) /* ":" */
#define AT (0x0100) /* "@" */
#define QU (0x0200) /* "?" */
#define DG (0x0400) /* DIGIT */
#define AL (0x0800) /* ALPHA */
#define GD (0x1000) /* gen-delims = "#" / "[" / "]"
* ... except ":", "/", "@", and "?" */
#define SD (0x2000) /* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
* / "*" / "+" / "," / ";" / "="
* ... except "+" which is PS */
#define OT (0x4000) /* others */
#define URI_ALPHA (AL)
#define URI_DIGIT (DG)
/* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" */
#define URI_UNRESERVED (AL | DG | DS | DT | US | TD)
/* scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ) */
#define URI_SCHEME (AL | DG | PS | DS | DT)
/* real sub-delims definition, including "+" */
#define URI_SUBDELIM (PS | SD)
/* real gen-delims definition, including ":", "/", "@" and "?" */
#define URI_GENDELIM (GD | CL | FS | AT | QU)
/* userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) */
#define URI_USERINFO (URI_UNRESERVED | PC | URI_SUBDELIM | CL)
/* pchar = unreserved / pct-encoded / sub-delims / ":" / "@" */
#define URI_PCHAR (URI_UNRESERVED | PC | URI_SUBDELIM | CL | AT)
/* invented: segchar = pchar / "/" */
#define URI_SEGCHAR (URI_PCHAR | FS)
/* query = *( pchar / "/" / "?" ) */
#define URI_QUERY (URI_PCHAR | FS | QU)
/* fragment == query */
#define URI_FRAGMENT URI_QUERY
/* any characters which should be path-escaped: */
#define URI_ESCAPE ((URI_GENDELIM & ~(FS)) | URI_SUBDELIM | OT | PC)
static const unsigned int uri_chars[256] = {
/* 0xXX x0 x2 x4 x6 x8 xA xC xE */
/* 0x */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* 1x */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* 2x */ OT, SD, OT, GD, SD, PC, SD, SD, SD, SD, SD, PS, SD, DS, DT, FS,
/* 3x */ DG, DG, DG, DG, DG, DG, DG, DG, DG, DG, CL, SD, OT, SD, OT, QU,
/* 4x */ AT, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL,
/* 5x */ AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, GD, OT, GD, OT, US,
/* 6x */ OT, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL,
/* 7x */ AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, AL, OT, OT, OT, TD, OT,
/* 8x */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* 9x */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* Ax */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* Bx */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* Cx */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* Dx */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* Ex */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT,
/* Fx */ OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT, OT
};
#define uri_lookup(ch) (uri_chars[(unsigned char)ch])
#endif /* ----- #ifndefendif MACROS_H_ ----- */
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
前一段时间开发一个WebDAV的客户端,主要是接受发送文件。因为只需要上传下载文件,所以不想使用curl这样重量级的库,所以,基于以上原因自己编写封装一个类,利用socket完成对文件的上传和下载,还可以使用内核函数sendfile实现文件上传时的“零拷贝”。在本例中,同样也给出使用 curl方式对文件进行上传操作的方法。针对WebDav的开发还有一个专门的库neon,同样这里也给出使用neon库完成文件上传操作的方法。
资源推荐
资源详情
资源评论
收起资源包目录
socket.rar (11个子文件)
socket
Logging.h 644B
UUri.h 1KB
Putfile.h 1KB
UUri.cc 5KB
Base.h 696B
USocket.h 873B
USocket.cc 4KB
Putfile.cc 9KB
Client.cc 815B
Makefile 606B
Macros.h 4KB
共 11 条
- 1
资源评论
逸学堂
- 粉丝: 1106
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功