|
7 | 7 | #include <windows.h> |
8 | 8 | #include <algorithm> |
9 | 9 | #pragma comment(lib, "ws2_32") |
10 | | - #define close closesocket |
11 | 10 | typedef struct iovec { void* iov_base; size_t iov_len; } iovec; |
12 | 11 | inline __int64 writev(int sock, struct iovec* iov, int cnt) { |
13 | 12 | __int64 r = send(sock, (const char*)iov->iov_base, iov->iov_len, 0); |
|
19 | 18 | #include <sys/socket.h> |
20 | 19 | #include <netinet/in.h> |
21 | 20 | #include <arpa/inet.h> |
| 21 | + #define closesocket close |
22 | 22 | #endif |
23 | 23 |
|
24 | 24 | #define FMT_BUF_LEN 25 // double 24 bytes, int64_t 21 bytes |
@@ -50,7 +50,7 @@ namespace influxdb_cpp { |
50 | 50 | if(src[pos] == ' ') |
51 | 51 | out += "+"; |
52 | 52 | else { |
53 | | - out += '%'; |
| 53 | + out += '%'; |
54 | 54 | out += to_hex((unsigned char)src[pos] >> 4); |
55 | 55 | out += to_hex((unsigned char)src[pos] & 0xF); |
56 | 56 | } |
@@ -140,7 +140,7 @@ namespace influxdb_cpp { |
140 | 140 | if(sendto(sock, &lines_[0], lines_.length(), 0, (struct sockaddr *)&addr, sizeof(addr)) < (int)lines_.length()) |
141 | 141 | ret = -3; |
142 | 142 |
|
143 | | - close(sock); |
| 143 | + closesocket(sock); |
144 | 144 | return ret; |
145 | 145 | } |
146 | 146 | void _escape(const std::string& src, const char* escape_seq) { |
@@ -203,17 +203,17 @@ namespace influxdb_cpp { |
203 | 203 | return -2; |
204 | 204 |
|
205 | 205 | if(connect(sock, (struct sockaddr*)(&addr), sizeof(addr)) < 0) { |
206 | | - close(sock); |
| 206 | + closesocket(sock); |
207 | 207 | return -3; |
208 | 208 | } |
209 | 209 |
|
210 | 210 | header.resize(len = 0x100); |
211 | 211 |
|
212 | 212 | for(;;) { |
213 | 213 | iv[0].iov_len = snprintf(&header[0], len, |
214 | | - "%s /%s?db=%s&u=%s&p=%s%s HTTP/1.1\r\nHost: %s\r\nContent-Length: %zd\r\n\r\n", |
| 214 | + "%s /%s?db=%s&u=%s&p=%s%s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n", |
215 | 215 | method, uri, si.db_.c_str(), si.usr_.c_str(), si.pwd_.c_str(), |
216 | | - querystring.c_str(), si.host_.c_str(), body.length()); |
| 216 | + querystring.c_str(), si.host_.c_str(), (int)body.length()); |
217 | 217 | if((int)iv[0].iov_len > len) |
218 | 218 | header.resize(len *= 2); |
219 | 219 | else |
@@ -283,7 +283,7 @@ namespace influxdb_cpp { |
283 | 283 | } |
284 | 284 | ret_code = -11; |
285 | 285 | END: |
286 | | - close(sock); |
| 286 | + closesocket(sock); |
287 | 287 | return ret_code / 100 == 2 ? 0 : ret_code; |
288 | 288 | #undef _NO_MORE |
289 | 289 | #undef _GET_NEXT_CHAR |
|
0 commit comments