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:
Linus Yang
2013-09-09 20:59:22 +08:00
parent df1b991d11
commit 21b9258d77
18 changed files with 490 additions and 47 deletions
+43 -2
View File
@@ -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