diff --git a/binding/c/xdb_searcher.c b/binding/c/xdb_searcher.c index 8b9f996..53f9af6 100644 --- a/binding/c/xdb_searcher.c +++ b/binding/c/xdb_searcher.c @@ -6,9 +6,36 @@ // @Author Lion // @Date 2022/06/27 -#include "sys/time.h" #include "xdb_searcher.h" +// for Linux +#ifdef XDB_LINUX +#include "sys/time.h" +#endif + +// @Note: since 2023/10/13 to compatible with the windows system +#ifdef XDB_WINDOWS +#include +XDB_PRIVATE(int) gettimeofday(struct timeval* tp, void* tzp) { + time_t clock; + struct tm tm; + SYSTEMTIME wtm; + GetLocalTime(&wtm); + tm.tm_year = wtm.wYear - 1900; + tm.tm_mon = wtm.wMonth - 1; + tm.tm_mday = wtm.wDay; + tm.tm_hour = wtm.wHour; + tm.tm_min = wtm.wMinute; + tm.tm_sec = wtm.wSecond; + tm.tm_isdst = -1; + clock = mktime(&tm); + tp->tv_sec = clock; + tp->tv_usec = wtm.wMilliseconds * 1000; + return (0); +} +#endif + + // internal function prototype define XDB_PRIVATE(int) read(xdb_searcher_t *, long offset, char *, size_t length);