1 Star 0 Fork 0

Aurora/Linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Common.hpp 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
Aurora 提交于 2025-07-13 00:44 +08:00 . 完整版httpserver
#pragma once
#include <iostream>
#include <string>
#define Die(code) \
do \
{ \
exit(code); \
} while (0)
#define CONV(v) (struct sockaddr *)(v)
enum
{
USAGE_ERR = 1, // 使用错误
SOCKET_ERR, // 创建套接字错误
BIND_ERR, // 绑定错误
LISTEN_ERR // 监听失败
};
const int gdefaultsockfd = -1;
const int gbacklog = 8;
// 1.正常字符串 2.out空串&&返回值是true 3.out空串&&返回值是false
bool ParseOneLine(std::string &str,std::string *out,const std::string &sep)
{
auto pos = str.find(sep);
if(pos == std::string::npos) return false;
*out = str.substr(0,pos);
str.erase(0,pos+sep.size());
return true;
}
// Connection: keep-alive
bool SplitString(const std::string &header,const std::string &sep,std::string *key,std::string *value)
{
auto pos = header.find(sep);
if(pos == std::string::npos) return false;
*key = header.substr(0,pos);
*value = header.substr(pos + sep.size());
return true;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/Axurea/linux.git
git@gitee.com:Axurea/linux.git
Axurea
linux
Linux
master

搜索帮助