ithewei 4 years ago
parent
commit
b7de4447ad
4 changed files with 37 additions and 5 deletions
  1. 2 0
      base/hdef.h
  2. 3 4
      cpputil/hfile.h
  3. 31 0
      examples/README.md
  4. 1 1
      examples/tinyproxyd.c

+ 2 - 0
base/hdef.h

@@ -27,6 +27,7 @@
 #define BITGET(i, n) ((i) & (1u << (n)))
 #endif
 
+/*
 #ifndef CR
 #define CR      '\r'
 #endif
@@ -38,6 +39,7 @@
 #ifndef CRLF
 #define CRLF    "\r\n"
 #endif
+*/
 
 #define FLOAT_PRECISION     1e-6
 #define FLOAT_EQUAL_ZERO(f) (ABS(f) < FLOAT_PRECISION)

+ 3 - 4
cpputil/hfile.h

@@ -4,7 +4,6 @@
 #include <string> // for std::string
 
 #include "hplatform.h" // for stat
-#include "hdef.h" // for LF, CR
 #include "hbuf.h" // for HBuf
 
 class HFile {
@@ -86,14 +85,14 @@ public:
         str.clear();
         char ch;
         while (fread(&ch, 1, 1, fp)) {
-            if (ch == LF) {
+            if (ch == '\n') {
                 // unix: LF
                 return true;
             }
-            if (ch == CR) {
+            if (ch == '\r') {
                 // dos: CRLF
                 // read LF
-                if (fread(&ch, 1, 1, fp) && ch != LF) {
+                if (fread(&ch, 1, 1, fp) && ch != '\n') {
                     // mac: CR
                     fseek(fp, -1, SEEK_CUR);
                 }

+ 31 - 0
examples/README.md

@@ -0,0 +1,31 @@
+## 目录结构
+
+```
+.
+├── consul/                 consul服务注册与发现
+├── httpd/                  HTTP服务端
+├── jsonrpc/                json RPC示例
+├── multi-thread/           多线程网络编程示例
+├── nmap/                   网络扫描工具
+├── protorpc/               protobuf RPC示例
+├── qt/                     在qt里使用libhv示例
+├── curl.cpp                HTTP请求工具
+├── hloop_test.c            事件循环测试代码
+├── hmain_test.cpp          命令行程序示例代码
+├── htimer_test.c           定时器测试代码
+├── http_client_test.c      HTTP客户端测试代码
+├── http_server_test.c      HTTP服务端测试代码
+├── nc.c                    网络连接工具
+├── tcp_chat_server.c       TCP聊天服务
+├── tcp_echo_server.c       TCP回显服务
+├── tcp_proxy_server.c      TCP代理服务
+├── tinyhttpd.c             微型HTTP服务
+├── tinyproxyd.c            微型HTTP代理服务
+├── udp_echo_server.c       UDP回显服务
+├── udp_proxy_server.c      UDP代理服务
+├── websocket_client_test.c WebSocket客户端测试代码
+├── websocket_server_test.c WebSocket服务端测试代码
+├── wget.cpp                HTTP文件下载工具
+└── wrk.cpp                 HTTP压测工具
+
+```

+ 1 - 1
examples/tinyproxyd.c

@@ -461,7 +461,7 @@ int main(int argc, char** argv) {
     }
     proxy_port = atoi(argv[1]);
     if (argc > 2) {
-        thread_num = atoi(argv[3]);
+        thread_num = atoi(argv[2]);
     } else {
         thread_num = get_ncpu();
     }