提交 ee82eb60 编写于 作者: S slguan

TD-992 cmake file for w64

上级 d012c3eb
......@@ -183,7 +183,7 @@ SJoinSupporter* tscCreateJoinSupporter(SSqlObj* pSql, SSubqueryState* pState, in
pSupporter->uid = pTableMetaInfo->pTableMeta->id.uid;
assert (pSupporter->uid != 0);
getTmpfilePath("join-", pSupporter->path);
taosGetTmpfilePath("join-", pSupporter->path);
pSupporter->f = fopen(pSupporter->path, "w");
// todo handle error
......@@ -773,7 +773,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
// continue to retrieve ts-comp data from vnode
if (!pRes->completed) {
getTmpfilePath("ts-join", pSupporter->path);
taosGetTmpfilePath("ts-join", pSupporter->path);
pSupporter->f = fopen(pSupporter->path, "w");
pRes->row = pRes->numOfRows;
......@@ -797,7 +797,7 @@ static void tsCompRetrieveCallback(void* param, TAOS_RES* tres, int32_t numOfRow
tscResetForNextRetrieve(&pSql->res);
assert(pSupporter->f == NULL);
getTmpfilePath("ts-join", pSupporter->path);
taosGetTmpfilePath("ts-join", pSupporter->path);
// TODO check for failure
pSupporter->f = fopen(pSupporter->path, "w");
......
......@@ -318,7 +318,7 @@ void taosRandStr(char* str, int32_t size);
uint32_t trand(void);
// TAOS_OS_FUNC_FILE
void getTmpfilePath(const char *fileNamePrefix, char *dstPath);
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath);
int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstPath);
// USE_LIBICONV
......
此差异已折叠。
......@@ -19,7 +19,7 @@
#ifndef TAOS_OS_FUNC_FILE
void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
const char* tdengineTmpFileNamePrefix = "tdengine-";
char tmpPath[PATH_MAX];
......@@ -37,6 +37,8 @@ void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand);
}
#endif
// rename file name
int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstPath) {
int32_t ts = taosGetTimestampSec();
......@@ -64,5 +66,3 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
return rename(fullPath, *dstPath);
}
#endif
\ No newline at end of file
......@@ -102,6 +102,7 @@ void taosUninitTimer() {
#endif
#ifndef TAOS_OS_FUNC_SLEEP
/*
to make taosMsleep work,
signal SIGALRM shall be blocked in the calling thread,
......@@ -128,4 +129,6 @@ void taosMsleep(int mseconds) {
select(0, NULL, NULL, NULL, &timeout);
/* pthread_sigmask(SIG_UNBLOCK, &set, NULL); */
}
\ No newline at end of file
}
#endif
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <WS2tcpip.h>
#include <IPHlpApi.h>
#include <winsock2.h>
#include <stdio.h>
#include <string.h>
#include <ws2def.h>
#include <tchar.h>
void taosWinSocketInit() {
static char flag = 0;
if (flag == 0) {
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD(1, 1);
if (WSAStartup(wVersionRequested, &wsaData) == 0) {
flag = 1;
}
}
}
int taosSetNonblocking(SOCKET sock, int on) {
u_long mode;
if (on) {
mode = 1;
ioctlsocket(sock, FIONBIO, &mode);
}
else {
mode = 0;
ioctlsocket(sock, FIONBIO, &mode);
}
return 0;
}
int taosGetPrivateIp(char *const ip) {
PIP_ADAPTER_ADDRESSES pAddresses = 0;
IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = 0;
ULONG outBufLen = 0;
DWORD dwRetVal = 0;
char buff[100];
DWORD bufflen = 100;
int i;
int flag = -1;
taosWinSocketInit();
GetAdaptersAddresses(AF_UNSPEC, 0, NULL, pAddresses, &outBufLen);
pAddresses = (IP_ADAPTER_ADDRESSES *)malloc(outBufLen);
if ((dwRetVal = GetAdaptersAddresses(AF_INET, GAA_FLAG_SKIP_ANYCAST, NULL, pAddresses, &outBufLen)) == NO_ERROR) {
while (pAddresses) {
if (wcsstr(pAddresses->FriendlyName, L"Loopback") != 0) {
pAddresses = pAddresses->Next;
continue;
}
if (pAddresses->OperStatus == IfOperStatusUp) {
//printf("%s, Status: active\n", pAddresses->FriendlyName);
}
else {
//printf("%s, Status: deactive\n", pAddresses->FriendlyName);
pAddresses = pAddresses->Next;
continue;
}
PIP_ADAPTER_UNICAST_ADDRESS pUnicast = pAddresses->FirstUnicastAddress;
for (i = 0; pUnicast != NULL; i++) {
if (pUnicast->Address.lpSockaddr->sa_family == AF_INET) {
struct sockaddr_in *sa_in = (struct sockaddr_in *)pUnicast->Address.lpSockaddr;
strcpy(ip, inet_ntop(AF_INET, &(sa_in->sin_addr), buff, bufflen));
flag = 0;
//printf("%s\n", ip);
}
else if (pUnicast->Address.lpSockaddr->sa_family == AF_INET6) {
struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)pUnicast->Address.lpSockaddr;
strcpy(ip, inet_ntop(AF_INET6, &(sa_in6->sin6_addr), buff, bufflen));
flag = 0;
//printf("%s\n", ip);
}
else {
}
pUnicast = pUnicast->Next;
}
pAddresses = pAddresses->Next;
}
}
else {
LPVOID lpMsgBuf;
printf("Call to GetAdaptersAddresses failed.\n");
if (FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwRetVal,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) & lpMsgBuf,
0,
NULL)) {
printf("\tError: %s", lpMsgBuf);
}
LocalFree(lpMsgBuf);
}
free(pAddresses);
return flag;
}
......@@ -21,38 +21,6 @@
#include "tulog.h"
#include "tutil.h"
bool taosCheckPthreadValid(pthread_t thread) {
return thread.p != NULL;
}
void taosResetPthread(pthread_t *thread) {
thread->p = 0;
}
int64_t taosGetPthreadId() {
#ifdef PTW32_VERSION
return pthread_getw32threadid_np(pthread_self());
#else
return (int64_t)pthread_self();
#endif
}
int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optlen) {
if (level == SOL_SOCKET && optname == TCP_KEEPCNT) {
return 0;
}
if (level == SOL_TCP && optname == TCP_KEEPIDLE) {
return 0;
}
if (level == SOL_TCP && optname == TCP_KEEPINTVL) {
return 0;
}
return setsockopt(socketfd, level, optname, optval, optlen);
}
// add
char interlocked_add_fetch_8(char volatile* ptr, char val) {
#ifdef _TD_GO_DLL_
......@@ -202,209 +170,3 @@ __int64 interlocked_fetch_xor_64(__int64 volatile* ptr, __int64 val) {
#endif
void taosPrintOsInfo() {}
void taosGetSystemTimezone() {
// get and set default timezone
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
if (cfg_timezone && cfg_timezone->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *tz = getenv("TZ");
if (tz == NULL || strlen(tz) == 0) {
strcpy(tsTimezone, "not configured");
}
else {
strcpy(tsTimezone, tz);
}
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("timezone not configured, use default");
}
}
void taosGetSystemLocale() {
// get and set default locale
SGlobalCfg *cfg_locale = taosGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) {
tstrncpy(tsLocale, locale, sizeof(tsLocale));
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("locale not configured, set to default:%s", tsLocale);
}
}
SGlobalCfg *cfg_charset = taosGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
strcpy(tsCharset, "cp936");
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("charset not configured, set to default:%s", tsCharset);
}
}
void taosGetSystemInfo() {
taosGetSystemTimezone();
taosGetSystemLocale();
}
void taosKillSystem() {
exit(0);
}
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no moretokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
char *strsep(char **stringp, const char *delim) {
char *s;
const char *spanp;
int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
char *getpass(const char *prefix) {
static char passwd[TSDB_KEY_LEN] = {0};
printf("%s", prefix);
scanf("%s", passwd);
char n = getchar();
return passwd;
}
int flock(int fd, int option) {
return 0;
}
int fsync(int filedes) {
return 0;
}
int sigaction(int sig, struct sigaction *d, void *p) {
return 0;
}
int wordexp(const char *words, wordexp_t *pwordexp, int flags) {
pwordexp->we_offs = 0;
pwordexp->we_wordc = 1;
pwordexp->we_wordv = (char **)(pwordexp->wordPos);
pwordexp->we_wordv[0] = (char *)words;
return 0;
}
void wordfree(wordexp_t *pwordexp) {}
void taosGetDisk() {}
bool taosSkipSocketCheck() {
return false;
}
#define _SEND_FILE_STEP_ 1000
int fsendfile(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count) {
fseek(in_file, (int32_t)(*offset), 0);
int writeLen = 0;
uint8_t buffer[_SEND_FILE_STEP_] = { 0 };
for (int len = 0; len < (count - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
size_t rlen = fread(buffer, 1, _SEND_FILE_STEP_, in_file);
if (rlen <= 0) {
return writeLen;
}
else if (rlen < _SEND_FILE_STEP_) {
fwrite(buffer, 1, rlen, out_file);
return (int)(writeLen + rlen);
}
else {
fwrite(buffer, 1, _SEND_FILE_STEP_, in_file);
writeLen += _SEND_FILE_STEP_;
}
}
int remain = count - writeLen;
if (remain > 0) {
size_t rlen = fread(buffer, 1, remain, in_file);
if (rlen <= 0) {
return writeLen;
}
else {
fwrite(buffer, 1, remain, out_file);
writeLen += remain;
}
}
return writeLen;
}
int32_t BUILDIN_CLZL(uint64_t val) {
unsigned long r = 0;
_BitScanReverse64(&r, val);
return (int)(r >> 3);
}
int32_t BUILDIN_CLZ(uint32_t val) {
unsigned long r = 0;
_BitScanReverse(&r, val);
return (int)(r >> 3);
}
int32_t BUILDIN_CTZL(uint64_t val) {
unsigned long r = 0;
_BitScanForward64(&r, val);
return (int)(r >> 3);
}
int32_t BUILDIN_CTZ(uint32_t val) {
unsigned long r = 0;
_BitScanForward(&r, val);
return (int)(r >> 3);
}
char *strndup(const char *s, size_t n) {
int len = strlen(s);
if (len >= n) {
len = n;
}
char *r = calloc(len + 1, 1);
memcpy(r, s, len);
r[len] = 0;
return r;
}
void taosSetCoreDump() {}
#ifdef _TD_GO_DLL_
int64_t tsosStr2int64(char *str) {
char *endptr = NULL;
return strtoll(str, &endptr, 10);
}
uint64_t htonll(uint64_t val)
{
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
}
#endif
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tulog.h"
#include "tsystem.h"
void taosSetCoreDump() {}
\ No newline at end of file
......@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
void getTmpfilePath(const char *fileNamePrefix, char *dstPath) {
void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
const char* tdengineTmpFileNamePrefix = "tdengine-";
char tmpPath[PATH_MAX];
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
#define _SEND_FILE_STEP_ 1000
int taosTSendFileImp(FILE* out_file, FILE* in_file, int64_t* offset, int32_t count) {
fseek(in_file, (int32_t)(*offset), 0);
int writeLen = 0;
uint8_t buffer[_SEND_FILE_STEP_] = { 0 };
for (int len = 0; len < (count - _SEND_FILE_STEP_); len += _SEND_FILE_STEP_) {
size_t rlen = fread(buffer, 1, _SEND_FILE_STEP_, in_file);
if (rlen <= 0) {
return writeLen;
}
else if (rlen < _SEND_FILE_STEP_) {
fwrite(buffer, 1, rlen, out_file);
return (int)(writeLen + rlen);
}
else {
fwrite(buffer, 1, _SEND_FILE_STEP_, in_file);
writeLen += _SEND_FILE_STEP_;
}
}
int remain = count - writeLen;
if (remain > 0) {
size_t rlen = fread(buffer, 1, remain, in_file);
if (rlen <= 0) {
return writeLen;
}
else {
fwrite(buffer, 1, remain, out_file);
writeLen += remain;
}
}
return writeLen;
}
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
#ifdef _TD_GO_DLL_
int64_t tsosStr2int64(char *str) {
char *endptr = NULL;
return strtoll(str, &endptr, 10);
}
uint64_t htonll(uint64_t val)
{
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
}
#endif
\ No newline at end of file
......@@ -13,27 +13,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
void *taosInitTcpClient(char *ip, uint16_t port, char *label, int num, void *fp, void *shandle) {
tError("InitTcpClient not support in windows");
return 0;
int32_t BUILDIN_CLZL(uint64_t val) {
unsigned long r = 0;
_BitScanReverse64(&r, val);
return (int)(r >> 3);
}
void taosCloseTcpClientConnection(void *chandle) {
tError("CloseTcpClientConnection not support in windows");
int32_t BUILDIN_CLZ(uint32_t val) {
unsigned long r = 0;
_BitScanReverse(&r, val);
return (int)(r >> 3);
}
void *taosOpenTcpClientConnection(void *shandle, void *thandle, char *ip, uint16_t port) {
tError("OpenTcpClientConnection not support in windows");
return 0;
int32_t BUILDIN_CTZL(uint64_t val) {
unsigned long r = 0;
_BitScanForward64(&r, val);
return (int)(r >> 3);
}
int taosSendTcpClientData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
tError("SendTcpClientData not support in windows");
return 0;
}
void taosCleanUpTcpClient(void *chandle) {
tError("SendTcpClientData not support in windows");
int32_t BUILDIN_CTZ(uint32_t val) {
unsigned long r = 0;
_BitScanForward(&r, val);
return (int)(r >> 3);
}
......@@ -16,42 +16,41 @@
#include <winsock2.h>
void taosFreeMsgHdr(void *hdr) {
WSAMSG *msgHdr = (WSAMSG *)hdr;
free(msgHdr->lpBuffers);
WSAMSG *msgHdr = (WSAMSG *)hdr;
free(msgHdr->lpBuffers);
}
int taosMsgHdrSize(void *hdr) {
WSAMSG *msgHdr = (WSAMSG *)hdr;
return msgHdr->dwBufferCount;
WSAMSG *msgHdr = (WSAMSG *)hdr;
return msgHdr->dwBufferCount;
}
void taosSendMsgHdr(void *hdr, int fd) {
WSAMSG *msgHdr = (WSAMSG *)hdr;
DWORD len;
WSAMSG *msgHdr = (WSAMSG *)hdr;
DWORD len;
WSASendMsg(fd, msgHdr, 0, &len, 0, 0);
msgHdr->dwBufferCount = 0;
WSASendMsg(fd, msgHdr, 0, &len, 0, 0);
msgHdr->dwBufferCount = 0;
}
void taosInitMsgHdr(void **hdr, void *dest, int maxPkts) {
WSAMSG *msgHdr = (WSAMSG *)malloc(sizeof(WSAMSG));
memset(msgHdr, 0, sizeof(WSAMSG));
*hdr = msgHdr;
// see ws2def.h
// the size of LPSOCKADDR and sockaddr_in * is same, so it's safe
msgHdr->name = (LPSOCKADDR)dest;
msgHdr->namelen = sizeof(struct sockaddr_in);
int size = sizeof(WSABUF) * maxPkts;
msgHdr->lpBuffers = (LPWSABUF)malloc(size);
memset(msgHdr->lpBuffers, 0, size);
msgHdr->dwBufferCount = 0;
WSAMSG *msgHdr = (WSAMSG *)malloc(sizeof(WSAMSG));
memset(msgHdr, 0, sizeof(WSAMSG));
*hdr = msgHdr;
// see ws2def.h
// the size of LPSOCKADDR and sockaddr_in * is same, so it's safe
msgHdr->name = (LPSOCKADDR)dest;
msgHdr->namelen = sizeof(struct sockaddr_in);
int size = sizeof(WSABUF) * maxPkts;
msgHdr->lpBuffers = (LPWSABUF)malloc(size);
memset(msgHdr->lpBuffers, 0, size);
msgHdr->dwBufferCount = 0;
}
void taosSetMsgHdrData(void *hdr, char *data, int dataLen) {
WSAMSG *msgHdr = (WSAMSG *)hdr;
msgHdr->lpBuffers[msgHdr->dwBufferCount].buf = data;
msgHdr->lpBuffers[msgHdr->dwBufferCount].len = dataLen;
msgHdr->dwBufferCount++;
WSAMSG *msgHdr = (WSAMSG *)hdr;
msgHdr->lpBuffers[msgHdr->dwBufferCount].buf = data;
msgHdr->lpBuffers[msgHdr->dwBufferCount].len = dataLen;
msgHdr->dwBufferCount++;
}
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
bool taosCheckPthreadValid(pthread_t thread) { return thread.p != NULL; }
void taosResetPthread(pthread_t *thread) { thread->p = 0; }
int64_t taosGetPthreadId() {
#ifdef PTW32_VERSION
return pthread_getw32threadid_np(pthread_self());
#else
return (int64_t)pthread_self();
#endif
}
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <WS2tcpip.h>
#include <IPHlpApi.h>
#include <winsock2.h>
#include <stdio.h>
#include <string.h>
#include <ws2def.h>
#include <tchar.h>
void taosWinSocketInit() {
static char flag = 0;
if (flag == 0) {
WORD wVersionRequested;
WSADATA wsaData;
wVersionRequested = MAKEWORD(1, 1);
if (WSAStartup(wVersionRequested, &wsaData) == 0) {
flag = 1;
}
}
}
int taosSetNonblocking(SOCKET sock, int on) {
u_long mode;
if (on) {
mode = 1;
ioctlsocket(sock, FIONBIO, &mode);
} else {
mode = 0;
ioctlsocket(sock, FIONBIO, &mode);
}
return 0;
}
void taosBlockSIGPIPE() {}
int taosSetSockOpt(int socketfd, int level, int optname, void *optval, int optlen) {
if (level == SOL_SOCKET && optname == TCP_KEEPCNT) {
return 0;
}
if (level == SOL_TCP && optname == TCP_KEEPIDLE) {
return 0;
}
if (level == SOL_TCP && optname == TCP_KEEPINTVL) {
return 0;
}
return setsockopt(socketfd, level, optname, optval, optlen);
}
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no moretokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
char *strsep(char **stringp, const char *delim) {
char *s;
const char *spanp;
int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
char *getpass(const char *prefix) {
static char passwd[TSDB_KEY_LEN] = {0};
printf("%s", prefix);
scanf("%s", passwd);
char n = getchar();
return passwd;
}
char *strndup(const char *s, size_t n) {
int len = strlen(s);
if (len >= n) {
len = n;
}
char *r = calloc(len + 1, 1);
memcpy(r, s, len);
r[len] = 0;
return r;
}
#ifdef _TD_GO_DLL_
int64_t tsosStr2int64(char *str) {
char *endptr = NULL;
return strtoll(str, &endptr, 10);
}
uint64_t htonll(uint64_t val)
{
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
}
#endif
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "tconfig.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
static void taosGetSystemTimezone() {
// get and set default timezone
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
if (cfg_timezone && cfg_timezone->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *tz = getenv("TZ");
if (tz == NULL || strlen(tz) == 0) {
strcpy(tsTimezone, "not configured");
} else {
strcpy(tsTimezone, tz);
}
cfg_timezone->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("timezone not configured, use default");
}
}
static void taosGetSystemLocale() {
// get and set default locale
SGlobalCfg *cfg_locale = taosGetConfigOption("locale");
if (cfg_locale && cfg_locale->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
char *locale = setlocale(LC_CTYPE, "chs");
if (locale != NULL) {
tstrncpy(tsLocale, locale, sizeof(tsLocale));
cfg_locale->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("locale not configured, set to default:%s", tsLocale);
}
}
SGlobalCfg *cfg_charset = taosGetConfigOption("charset");
if (cfg_charset && cfg_charset->cfgStatus < TAOS_CFG_CSTATUS_DEFAULT) {
strcpy(tsCharset, "cp936");
cfg_charset->cfgStatus = TAOS_CFG_CSTATUS_DEFAULT;
uInfo("charset not configured, set to default:%s", tsCharset);
}
}
void taosPrintOsInfo() {}
void taosKillSystem() {
uError("function taosKillSystem, exit!");
exit(0);
}
void taosGetSystemInfo() {
taosGetSystemTimezone();
taosGetSystemLocale();
}
bool taosGetDisk() { return true; }
bool taosGetProcIO(float *readKB, float *writeKB) {
*readKB = 0;
*writeKB = 0;
return true;
}
bool taosGetBandSpeed(float *bandSpeedKb) {
*bandSpeedKb = 0;
return true;
}
bool taosGetCpuUsage(float *sysCpuUsage, float *procCpuUsage) {
*sysCpuUsage = 0;
*procCpuUsage = 0;
return true;
}
bool taosGetProcMemory(float *memoryUsedMB) {
*memoryUsedMB = 0;
return true;
}
bool taosGetSysMemory(float *memoryUsedMB) {
*memoryUsedMB = 0;
return true;
}
int taosSystem(const char *cmd) {
uError("taosSystem not support");
return -1;
}
int flock(int fd, int option) {
return 0;
}
int fsync(int filedes) {
return 0;
}
int sigaction(int sig, struct sigaction *d, void *p) {
return 0;
}
\ No newline at end of file
......@@ -22,8 +22,7 @@
typedef void (*win_timer_f)(int signo);
void WINAPI taosWinOnTimer(UINT wTimerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dwl, DWORD_PTR dw2)
{
void WINAPI taosWinOnTimer(UINT wTimerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dwl, DWORD_PTR dw2) {
win_timer_f callback = *((win_timer_f *)&dwUser);
if (callback != NULL) {
callback(0);
......@@ -48,7 +47,3 @@ void taosUninitTimer() {
void taosMsleep(int mseconds) {
Sleep(mseconds);
}
void sleep(int mseconds) {
taosMsleep(mseconds);
}
\ No newline at end of file
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no moretokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
char *strsep(char **stringp, const char *delim) {
char *s;
const char *spanp;
int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
char *getpass(const char *prefix) {
static char passwd[TSDB_KEY_LEN] = {0};
printf("%s", prefix);
scanf("%s", passwd);
char n = getchar();
return passwd;
}
int flock(int fd, int option) {
return 0;
}
int fsync(int filedes) {
return 0;
}
int sigaction(int sig, struct sigaction *d, void *p) {
return 0;
}
int wordexp(const char *words, wordexp_t *pwordexp, int flags) {
pwordexp->we_offs = 0;
pwordexp->we_wordc = 1;
pwordexp->we_wordv = (char **)(pwordexp->wordPos);
pwordexp->we_wordv[0] = (char *)words;
return 0;
}
void wordfree(wordexp_t *pwordexp) {}
char *strndup(const char *s, size_t n) {
int len = strlen(s);
if (len >= n) {
len = n;
}
char *r = calloc(len + 1, 1);
memcpy(r, s, len);
r[len] = 0;
return r;
}
void taosSetCoreDump() {}
#ifdef _TD_GO_DLL_
int64_t tsosStr2int64(char *str) {
char *endptr = NULL;
return strtoll(str, &endptr, 10);
}
uint64_t htonll(uint64_t val)
{
return (((uint64_t) htonl(val)) << 32) + htonl(val >> 32);
}
#endif
\ No newline at end of file
......@@ -13,22 +13,21 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "os.h"
#include "taosdef.h"
#include "tglobal.h"
#include "ttimer.h"
#include "tulog.h"
#include "tutil.h"
void taosCloseTcpServerConnection(void *chandle) {
tError("CloseTcpServerConnection not support in windows");
}
void taosCleanUpTcpServer(void *handle) {
tError("CleanUpTcpServer not support in windows");
}
void *taosInitTcpServer(char *ip, uint16_t port, char *label, int numOfThreads, void *fp, void *shandle) {
tError("InitTcpServer not support in windows");
int wordexp(const char *words, wordexp_t *pwordexp, int flags) {
pwordexp->we_offs = 0;
pwordexp->we_wordc = 1;
pwordexp->we_wordv = (char **)(pwordexp->wordPos);
pwordexp->we_wordv[0] = (char *)words;
return 0;
}
int taosSendTcpServerData(unsigned int ip, uint16_t port, char *data, int len, void *chandle) {
tError("SendTcpServerData not support in windows");
return 0;
}
void wordfree(wordexp_t *pwordexp) {}
......@@ -38,7 +38,7 @@ tExtMemBuffer* createExtMemBuffer(int32_t inMemSize, int32_t elemSize, int32_t p
pMemBuffer->numOfElemsPerPage = (pMemBuffer->pageSize - sizeof(tFilePage)) / pMemBuffer->nElemSize;
char name[MAX_TMPFILE_PATH_LENGTH] = {0};
getTmpfilePath("extbuf", name);
taosGetTmpfilePath("extbuf", name);
pMemBuffer->path = strdup(name);
uDebug("create tmp file:%s", pMemBuffer->path);
......
......@@ -39,7 +39,7 @@ int32_t createDiskbasedResultBuffer(SDiskbasedResultBuf** pResultBuf, int32_t ro
pResBuf->all = taosHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false);
char path[PATH_MAX] = {0};
getTmpfilePath("qbuf", path);
taosGetTmpfilePath("qbuf", path);
pResBuf->path = strdup(path);
pResBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t));
......
......@@ -21,7 +21,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
return NULL;
}
getTmpfilePath("join", pTSBuf->path);
taosGetTmpfilePath("join", pTSBuf->path);
pTSBuf->f = fopen(pTSBuf->path, "w+");
if (pTSBuf->f == NULL) {
free(pTSBuf);
......
......@@ -766,7 +766,7 @@ TEST(testCase, getTempFilePath_test) {
char path[4096] = {0};
memset(path, 1, 4096);
getTmpfilePath("new_tmp", path);
taosGetTmpfilePath("new_tmp", path);
printf("%s\n", path);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册