mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-23 06:13:49 +00:00
Add initial support for native win32 platform
Should be built against MinGW, and please note that only ss-local is ported due to lack win32 support of libasyncns. And libev doesn't support IOCP but only supports select
This commit is contained in:
+43
-2
@@ -1,6 +1,9 @@
|
||||
#ifndef _UTILS_H
|
||||
#define _UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef ANDROID
|
||||
|
||||
#include <android/log.h>
|
||||
@@ -12,6 +15,27 @@
|
||||
|
||||
#define STR(x) #x
|
||||
#define TOSTR(x) STR(x)
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define TIME_FORMAT "%Y-%m-%d %H:%M:%S"
|
||||
|
||||
#define LOGD(format, ...) do {\
|
||||
time_t now = time(NULL);\
|
||||
char timestr[20];\
|
||||
strftime(timestr, 20, TIME_FORMAT, localtime(&now));\
|
||||
fprintf(stderr, " %s INFO: " format "\n", timestr, ##__VA_ARGS__);}\
|
||||
while(0)
|
||||
|
||||
#define LOGE(format, ...) do {\
|
||||
time_t now = time(NULL);\
|
||||
char timestr[20];\
|
||||
strftime(timestr, 20, TIME_FORMAT, localtime(&now));\
|
||||
fprintf(stderr, " %s ERROR: " format "\n", timestr, ##__VA_ARGS__);}\
|
||||
while(0)
|
||||
|
||||
#else
|
||||
|
||||
#define TIME_FORMAT "%F %T"
|
||||
|
||||
#define LOGD(format, ...) do {\
|
||||
@@ -28,13 +52,30 @@ while(0)
|
||||
fprintf(stderr, "\e[01;35m %s ERROR: \e[0m" format "\n", timestr, ##__VA_ARGS__);}\
|
||||
while(0)
|
||||
|
||||
#endif
|
||||
/* _WIN32 */
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
#ifdef ERROR
|
||||
#undef ERROR
|
||||
#endif
|
||||
#define ERROR(s) ss_error(s)
|
||||
|
||||
char *ss_itoa(int i);
|
||||
|
||||
#else
|
||||
|
||||
void ERROR(const char *s);
|
||||
char *itoa(int i);
|
||||
|
||||
#endif
|
||||
|
||||
void FATAL(const char *msg);
|
||||
void ERROR(const char *s);
|
||||
void usage(void);
|
||||
void demonize(const char* path);
|
||||
char *itoa(int i);
|
||||
char *ss_strndup(const char *s, size_t n);
|
||||
|
||||
#endif // _UTILS_H
|
||||
|
||||
Reference in New Issue
Block a user