Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
105531ca
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
105531ca
编写于
3月 10, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-3143] <fix>: make taosdemo works on Windows. fix macro definition.
上级
f217e7a4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
35 addition
and
29 deletion
+35
-29
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+35
-29
未找到文件。
src/kit/taosdemo/taosdemo.c
浏览文件 @
105531ca
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
#include <stdio.h>
#include <stdio.h>
#include "os.h"
#include "os.h"
#ifdef
TD_
WINDOWS
#ifdef WINDOWS
#include <winsock2.h>
#include <winsock2.h>
typedef
unsigned
__int32
uint32_t
;
typedef
unsigned
__int32
uint32_t
;
...
@@ -1597,7 +1597,7 @@ static void printfQuerySystemInfo(TAOS * taos) {
...
@@ -1597,7 +1597,7 @@ static void printfQuerySystemInfo(TAOS * taos) {
}
}
void
ERROR_EXIT
(
const
char
*
msg
)
{
perror
(
msg
);
exit
(
0
);
}
void
ERROR_EXIT
(
const
char
*
msg
)
{
perror
(
msg
);
exit
(
-
1
);
}
int
postProceSql
(
char
*
host
,
uint16_t
port
,
char
*
sqlstr
)
int
postProceSql
(
char
*
host
,
uint16_t
port
,
char
*
sqlstr
)
{
{
...
@@ -1636,38 +1636,19 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
...
@@ -1636,38 +1636,19 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
size_t
encoded_len
=
4
*
((
userpass_buf_len
+
2
)
/
3
);
size_t
encoded_len
=
4
*
((
userpass_buf_len
+
2
)
/
3
);
char
base64_buf
[
INPUT_BUF_LEN
];
char
base64_buf
[
INPUT_BUF_LEN
];
memset
(
base64_buf
,
0
,
INPUT_BUF_LEN
);
#ifdef WINDOWS
for
(
int
n
=
0
,
m
=
0
;
n
<
userpass_buf_len
;)
{
uint32_t
oct_a
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
oct_b
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
oct_c
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
triple
=
(
oct_a
<<
0x10
)
+
(
oct_b
<<
0x08
)
+
oct_c
;
base64_buf
[
m
++
]
=
base64
[(
triple
>>
3
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
2
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
1
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
0
*
6
)
&
0x3f
];
}
for
(
int
l
=
0
;
l
<
mod_table
[
userpass_buf_len
%
3
];
l
++
)
base64_buf
[
encoded_len
-
1
-
l
]
=
'='
;
debugPrint
(
"%s() LN%d: auth string base64 encoded: %s
\n
"
,
__func__
,
__LINE__
,
base64_buf
);
char
*
auth
=
base64_buf
;
#ifdef TD_WINDOWS
WSADATA
wsaData
;
WSADATA
wsaData
;
WSAStartup
(
MAKEWORD
(
2
,
1
),
&
wsaData
);
WSAStartup
(
MAKEWORD
(
2
,
2
),
&
wsaData
);
SOCKET
sockfd
;
SOCKET
sockfd
;
#else
#else
int
sockfd
;
int
sockfd
;
#endif
#endif
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
sockfd
<
0
)
{
if
(
sockfd
<
0
)
{
#ifdef WINDOWS
fprintf
(
stderr
,
"Could not create socket : %d"
,
WSAGetLastError
());
#endif
debugPrint
(
"%s() LN%d sockfd=%d
\n
"
,
__func__
,
__LINE__
,
sockfd
);
free
(
request_buf
);
free
(
request_buf
);
ERROR_EXIT
(
"ERROR opening socket"
);
ERROR_EXIT
(
"ERROR opening socket"
);
}
}
...
@@ -1692,11 +1673,36 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
...
@@ -1692,11 +1673,36 @@ int postProceSql(char* host, uint16_t port, char* sqlstr)
memcpy
(
&
serv_addr
.
sin_addr
.
s_addr
,
server
->
h_addr
,
server
->
h_length
);
memcpy
(
&
serv_addr
.
sin_addr
.
s_addr
,
server
->
h_addr
,
server
->
h_length
);
#endif
#endif
if
(
connect
(
sockfd
,(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
))
<
0
)
{
int
retConn
=
connect
(
sockfd
,(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
));
debugPrint
(
"%s() LN%d connect() return %d
\n
"
,
__func__
,
__LINE__
,
retConn
);
if
(
retConn
<
0
)
{
free
(
request_buf
);
free
(
request_buf
);
ERROR_EXIT
(
"ERROR connecting"
);
ERROR_EXIT
(
"ERROR connecting"
);
}
}
memset
(
base64_buf
,
0
,
INPUT_BUF_LEN
);
for
(
int
n
=
0
,
m
=
0
;
n
<
userpass_buf_len
;)
{
uint32_t
oct_a
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
oct_b
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
oct_c
=
n
<
userpass_buf_len
?
(
unsigned
char
)
userpass_buf
[
n
++
]
:
0
;
uint32_t
triple
=
(
oct_a
<<
0x10
)
+
(
oct_b
<<
0x08
)
+
oct_c
;
base64_buf
[
m
++
]
=
base64
[(
triple
>>
3
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
2
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
1
*
6
)
&
0x3f
];
base64_buf
[
m
++
]
=
base64
[(
triple
>>
0
*
6
)
&
0x3f
];
}
for
(
int
l
=
0
;
l
<
mod_table
[
userpass_buf_len
%
3
];
l
++
)
base64_buf
[
encoded_len
-
1
-
l
]
=
'='
;
debugPrint
(
"%s() LN%d: auth string base64 encoded: %s
\n
"
,
__func__
,
__LINE__
,
base64_buf
);
char
*
auth
=
base64_buf
;
int
r
=
snprintf
(
request_buf
,
int
r
=
snprintf
(
request_buf
,
req_buf_len
,
req_buf_len
,
req_fmt
,
url
,
host
,
rest_port
,
req_fmt
,
url
,
host
,
rest_port
,
...
@@ -4435,7 +4441,7 @@ static void* syncWriteWithStb(void *sarg) {
...
@@ -4435,7 +4441,7 @@ static void* syncWriteWithStb(void *sarg) {
}
}
len
+=
retLen
;
len
+=
retLen
;
verbosePrint
(
"%s() LN%d retLen=%d len=%d k=%d buffer=%s
\n
"
,
__func__
,
__LINE__
,
retLen
,
len
,
k
,
buffer
);
verbosePrint
(
"%s() LN%d retLen=%d len=%d k=%d
\n
buffer=%s
\n
"
,
__func__
,
__LINE__
,
retLen
,
len
,
k
,
buffer
);
tblInserted
++
;
tblInserted
++
;
k
++
;
k
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录