diff --git a/include/ssocket.h b/include/ssocket.h index f2084c7..ff52aed 100644 --- a/include/ssocket.h +++ b/include/ssocket.h @@ -107,6 +107,7 @@ static inline int sock_connect(SOCKET sock, const char* connect_ip, unsigned sho static inline int sock_bind(SOCKET sock, const char* server_ip, unsigned short port); static inline int sock_bindlisten(SOCKET sock, const char* server_ip, unsigned short port); static inline int sock_accpet(SOCKET sock, SOCKET* client, char** accept_ip, unsigned short* port); +static inline int _sock(SOCKET* sock, int af, int type); static inline int make_sock_tcp4(SOCKET* sock) { return _sock(sock, AF_INET, SOCK_STREAM); } static inline int make_sock_tcp6(SOCKET* sock) { return _sock(sock, AF_INET6, SOCK_STREAM); } static inline int make_sock_udp4(SOCKET* sock) { return _sock(sock, AF_INET, SOCK_DGRAM); } @@ -119,7 +120,6 @@ static inline int _connect(SOCKET sock, struct addrinfo* resaddr); static inline int _bind(SOCKET sock, struct addrinfo* resaddr); static inline int _bindlisten(SOCKET sock, struct addrinfo* resaddr); static inline int _accept(SOCKET sock, SOCKET* client, struct addrinfo* inf); -static inline int _sock(SOCKET* sock, int af, int type); //not recommand and it will be remove static inline int make_sock(SOCKET* sock) { return make_sock_tcp4(sock); }; diff --git a/src/ini.c b/src/ini.c index c90d99a..123445a 100644 --- a/src/ini.c +++ b/src/ini.c @@ -3,23 +3,22 @@ #include #if _OS_WIN - -#elif _OS_LINUX -#include -#else -#error "Not Supported Operator System" -#endif - #ifndef strcasecmp #define strcasecmp _stricmp #endif #ifndef strncasecmp #define strncasecmp _strnicmp #endif +#elif _OS_LINUX +#include +#else +#error "Not Supported Operator System" +#endif + #define INI_BUFFER_SIZE 512 -inline INICHAR* _ini_skip_leading(const INICHAR* str) +static inline INICHAR* _ini_skip_leading(const INICHAR* str) { assert(str != NULL); while ('\0' < *str && *str <= ' ') @@ -27,7 +26,7 @@ inline INICHAR* _ini_skip_leading(const INICHAR* str) return (INICHAR*)str; } -inline INICHAR* _ini_skip_trailing(const INICHAR* str, const INICHAR* base) +static inline INICHAR* _ini_skip_trailing(const INICHAR* str, const INICHAR* base) { assert(str != NULL); assert(base != NULL); @@ -36,7 +35,7 @@ inline INICHAR* _ini_skip_trailing(const INICHAR* str, const INICHAR* base) return (INICHAR*)str; } -inline INICHAR* _ini_str_skip_trailing(INICHAR* str) +static inline INICHAR* _ini_str_skip_trailing(INICHAR* str) { INICHAR* ptr = _ini_skip_trailing(strchr(str, '\0'), str); assert(ptr != NULL); diff --git a/src/log.c b/src/log.c index a3cdcb9..405f10f 100644 --- a/src/log.c +++ b/src/log.c @@ -4,7 +4,16 @@ #include #include +#if _OS_WIN #define LOG_COLOR(code) \033[##code##m + +#elif _OS_LINUX +#define LOG_COLOR(code) \x1b\x5b##code##m + +#else +#error "Not Supported Operator System" +#endif + #define LOG_COLOR_TRACE LOG_COLOR(94) #define LOG_COLOR_DEBUG LOG_COLOR(36) #define LOG_COLOR_INFO LOG_COLOR(32) diff --git a/test/project/CMakeLists.txt b/test/project/CMakeLists.txt index 355c8ba..60c4c78 100644 --- a/test/project/CMakeLists.txt +++ b/test/project/CMakeLists.txt @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.22.1) project(proj) -set(EXECUTABLE_OUTPUT_PATH ../../) +set(EXECUTABLE_OUTPUT_PATH ../) set(C_STANDARD 99) set(C_STANDARD_REQUIRED TRUE) set(C_EXTENSIONS FALSE) -add_subdirectory(server_proj server) -add_subdirectory(client_proj client) +add_subdirectory(./server_proj server) +add_subdirectory(./client_proj client) add_subdirectory(../../ zzylib) # cmake .. # cmake --build . \ No newline at end of file diff --git a/test/project/client_proj/client_proj.c b/test/project/client_proj/client_proj.c index 60eeadf..647d865 100644 --- a/test/project/client_proj/client_proj.c +++ b/test/project/client_proj/client_proj.c @@ -51,7 +51,7 @@ void receive_message(void* param) } void end(void) { - shutdown(cfd, SHUT_WD); + shutdown(cfd, SHUT_WR); close_sock(cfd); } @@ -99,7 +99,7 @@ CONNECT: log_head_info_ex(buf, BUFFER_SIZE, "command", g_mask); tprintf(&std_mutex, buf); tprintf(&std_mutex, "client exit... press enter to continue\n"); - shutdown(cfd, SHUT_WD); + shutdown(cfd, SHUT_WR); if(getchar()); exit(-1); } diff --git a/test/project/server_proj/server_proj.c b/test/project/server_proj/server_proj.c index 7ea91bd..da57998 100644 --- a/test/project/server_proj/server_proj.c +++ b/test/project/server_proj/server_proj.c @@ -63,7 +63,7 @@ void receive_message(void* param) } log_head_info_ex(buf, BUFFER_SIZE, "receive", g_mask); tprintf(&std_mutex, buf); - shutdown(sock, SHUT_WD); + shutdown(sock, SHUT_WR); tprintf(&std_mutex, "socket <%d> exit\n", sock); for(int i = 0; i < CLIENT_SIZE; i++) { if(cfds[i] == sock) { @@ -118,7 +118,7 @@ void acceptfunc(void* param) { } void end(void) { - shutdown(sfd, SHUT_WD); + shutdown(sfd, SHUT_WR); close_sock(sfd); for (int i = 0; i < CLIENT_SIZE; i++) { if (cfds[i] != 0) {