Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_50753323
TDengine
提交
7e3cd84d
T
TDengine
项目概览
qq_50753323
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7e3cd84d
编写于
8月 08, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1057
上级
a18e287c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
407 addition
and
241 deletion
+407
-241
src/kit/taosdemo/CMakeLists.txt
src/kit/taosdemo/CMakeLists.txt
+1
-0
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+363
-197
src/os/inc/osWindows.h
src/os/inc/osWindows.h
+1
-0
tests/tsim/CMakeLists.txt
tests/tsim/CMakeLists.txt
+0
-4
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+8
-6
tests/tsim/src/simParse.c
tests/tsim/src/simParse.c
+34
-34
未找到文件。
src/kit/taosdemo/CMakeLists.txt
浏览文件 @
7e3cd84d
...
...
@@ -16,4 +16,5 @@ IF (TD_LINUX)
ELSEIF
(
TD_WINDOWS
)
AUX_SOURCE_DIRECTORY
(
. SRC
)
ADD_EXECUTABLE
(
taosdemo
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
taosdemo taos_static
)
ENDIF
()
src/kit/taosdemo/taosdemo.c
浏览文件 @
7e3cd84d
...
...
@@ -15,24 +15,31 @@
#define _GNU_SOURCE
#include <argp.h>
#include <assert.h>
#include <inttypes.h>
#ifndef _ALPINE
#include <error.h>
#endif
#include <pthread.h>
#include <semaphore.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <wordexp.h>
#include <regex.h>
#ifdef LINUX
#include "os.h"
#include <argp.h>
#include <assert.h>
#include <inttypes.h>
#ifndef _ALPINE
#include <error.h>
#endif
#include <pthread.h>
#include <semaphore.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <wordexp.h>
#include <regex.h>
#else
#include <assert.h>
#include <regex.h>
#include <stdio.h>
#include "os.h"
#endif
#include "taos.h"
#include "tutil.h"
...
...
@@ -48,32 +55,6 @@ extern char configDir[];
#define STRING_LEN 60000
#define MAX_PREPARED_RAND 1000000
/* The options we understand. */
static
struct
argp_option
options
[]
=
{
{
0
,
'h'
,
"host"
,
0
,
"The host to connect to TDEngine. Default is localhost."
,
0
},
{
0
,
'p'
,
"port"
,
0
,
"The TCP/IP port number to use for the connection. Default is 0."
,
1
},
{
0
,
'u'
,
"user"
,
0
,
"The TDEngine user name to use when connecting to the server. Default is 'root'."
,
2
},
{
0
,
'P'
,
"password"
,
0
,
"The password to use when connecting to the server. Default is 'taosdata'."
,
3
},
{
0
,
'd'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'm'
,
"table_prefix"
,
0
,
"Table prefix name. Default is 't'."
,
3
},
{
0
,
's'
,
"sql file"
,
0
,
"The select sql file."
,
3
},
{
0
,
'M'
,
0
,
0
,
"Use metric flag."
,
13
},
{
0
,
'o'
,
"outputfile"
,
0
,
"Direct output to the named file. Default is './output.txt'."
,
14
},
{
0
,
'q'
,
"query_mode"
,
0
,
"Query mode--0: SYNC, 1: ASYNC. Default is SYNC."
,
6
},
{
0
,
'b'
,
"type_of_cols"
,
0
,
"The data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."
,
7
},
{
0
,
'w'
,
"length_of_binary"
,
0
,
"The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"
,
8
},
{
0
,
'l'
,
"num_of_cols_per_record"
,
0
,
"The number of columns per record. Default is 3."
,
8
},
{
0
,
'T'
,
"num_of_threads"
,
0
,
"The number of threads. Default is 10."
,
9
},
{
0
,
'r'
,
"num_of_records_per_req"
,
0
,
"The number of records per request. Default is 1000."
,
10
},
{
0
,
't'
,
"num_of_tables"
,
0
,
"The number of tables. Default is 10000."
,
11
},
{
0
,
'n'
,
"num_of_records_per_table"
,
0
,
"The number of records per table. Default is 100000."
,
12
},
{
0
,
'c'
,
"config_directory"
,
0
,
"Configuration directory. Default is '/etc/taos/'."
,
14
},
{
0
,
'x'
,
0
,
0
,
"Insert only flag."
,
13
},
{
0
,
'O'
,
"order"
,
0
,
"Insert mode--0: In order, 1: Out of order. Default is in order."
,
14
},
{
0
,
'R'
,
"rate"
,
0
,
"Out of order data's rate--if order=1 Default 10, min: 0, max: 50."
,
14
},
{
0
,
'D'
,
"delete table"
,
0
,
"Delete data methods——0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database"
,
14
},
{
0
}};
/* Used by main to communicate with parse_opt. */
typedef
struct
DemoArguments
{
char
*
host
;
...
...
@@ -101,143 +82,337 @@ typedef struct DemoArguments {
char
**
arg_list
;
}
SDemoArguments
;
/* Parse a single option. */
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
/* Get the input argument from argp_parse, which we
know is a pointer to our arguments structure. */
SDemoArguments
*
arguments
=
state
->
input
;
wordexp_t
full_path
;
char
**
sptr
;
switch
(
key
)
{
case
'h'
:
arguments
->
host
=
arg
;
break
;
case
'p'
:
arguments
->
port
=
atoi
(
arg
);
break
;
case
'u'
:
arguments
->
user
=
arg
;
break
;
case
'P'
:
arguments
->
password
=
arg
;
break
;
case
'o'
:
arguments
->
output_file
=
arg
;
break
;
case
's'
:
arguments
->
sqlFile
=
arg
;
break
;
case
'q'
:
arguments
->
mode
=
atoi
(
arg
);
break
;
case
'T'
:
arguments
->
num_of_threads
=
atoi
(
arg
);
break
;
case
'r'
:
arguments
->
num_of_RPR
=
atoi
(
arg
);
break
;
case
't'
:
arguments
->
num_of_tables
=
atoi
(
arg
);
break
;
case
'n'
:
arguments
->
num_of_DPT
=
atoi
(
arg
);
break
;
case
'd'
:
arguments
->
database
=
arg
;
break
;
case
'l'
:
arguments
->
num_of_CPR
=
atoi
(
arg
);
break
;
case
'b'
:
sptr
=
arguments
->
datatype
;
if
(
strstr
(
arg
,
","
)
==
NULL
)
{
if
(
strcasecmp
(
arg
,
"INT"
)
!=
0
&&
strcasecmp
(
arg
,
"FLOAT"
)
!=
0
&&
strcasecmp
(
arg
,
"TINYINT"
)
!=
0
&&
strcasecmp
(
arg
,
"BOOL"
)
!=
0
&&
strcasecmp
(
arg
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
arg
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
arg
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
arg
,
"BINARY"
)
&&
strcasecmp
(
arg
,
"NCHAR"
))
{
argp_error
(
state
,
"Invalid data_type!"
);
}
sptr
[
0
]
=
arg
;
}
else
{
int
index
=
0
;
char
*
dupstr
=
strdup
(
arg
);
char
*
running
=
dupstr
;
char
*
token
=
strsep
(
&
running
,
","
);
while
(
token
!=
NULL
)
{
if
(
strcasecmp
(
token
,
"INT"
)
!=
0
&&
strcasecmp
(
token
,
"FLOAT"
)
!=
0
&&
strcasecmp
(
token
,
"TINYINT"
)
!=
0
&&
strcasecmp
(
token
,
"BOOL"
)
!=
0
&&
strcasecmp
(
token
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
token
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
token
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
token
,
"BINARY"
)
&&
strcasecmp
(
token
,
"NCHAR"
))
{
#ifdef LINUX
/* The options we understand. */
static
struct
argp_option
options
[]
=
{
{
0
,
'h'
,
"host"
,
0
,
"The host to connect to TDEngine. Default is localhost."
,
0
},
{
0
,
'p'
,
"port"
,
0
,
"The TCP/IP port number to use for the connection. Default is 0."
,
1
},
{
0
,
'u'
,
"user"
,
0
,
"The TDEngine user name to use when connecting to the server. Default is 'root'."
,
2
},
{
0
,
'P'
,
"password"
,
0
,
"The password to use when connecting to the server. Default is 'taosdata'."
,
3
},
{
0
,
'd'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'm'
,
"table_prefix"
,
0
,
"Table prefix name. Default is 't'."
,
3
},
{
0
,
's'
,
"sql file"
,
0
,
"The select sql file."
,
3
},
{
0
,
'M'
,
0
,
0
,
"Use metric flag."
,
13
},
{
0
,
'o'
,
"outputfile"
,
0
,
"Direct output to the named file. Default is './output.txt'."
,
14
},
{
0
,
'q'
,
"query_mode"
,
0
,
"Query mode--0: SYNC, 1: ASYNC. Default is SYNC."
,
6
},
{
0
,
'b'
,
"type_of_cols"
,
0
,
"The data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."
,
7
},
{
0
,
'w'
,
"length_of_binary"
,
0
,
"The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"
,
8
},
{
0
,
'l'
,
"num_of_cols_per_record"
,
0
,
"The number of columns per record. Default is 3."
,
8
},
{
0
,
'T'
,
"num_of_threads"
,
0
,
"The number of threads. Default is 10."
,
9
},
{
0
,
'r'
,
"num_of_records_per_req"
,
0
,
"The number of records per request. Default is 1000."
,
10
},
{
0
,
't'
,
"num_of_tables"
,
0
,
"The number of tables. Default is 10000."
,
11
},
{
0
,
'n'
,
"num_of_records_per_table"
,
0
,
"The number of records per table. Default is 100000."
,
12
},
{
0
,
'c'
,
"config_directory"
,
0
,
"Configuration directory. Default is '/etc/taos/'."
,
14
},
{
0
,
'x'
,
0
,
0
,
"Insert only flag."
,
13
},
{
0
,
'O'
,
"order"
,
0
,
"Insert mode--0: In order, 1: Out of order. Default is in order."
,
14
},
{
0
,
'R'
,
"rate"
,
0
,
"Out of order data's rate--if order=1 Default 10, min: 0, max: 50."
,
14
},
{
0
,
'D'
,
"delete table"
,
0
,
"Delete data methods——0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database"
,
14
},
{
0
}};
/* Parse a single option. */
static
error_t
parse_opt
(
int
key
,
char
*
arg
,
struct
argp_state
*
state
)
{
/* Get the input argument from argp_parse, which we
know is a pointer to our arguments structure. */
SDemoArguments
*
arguments
=
state
->
input
;
wordexp_t
full_path
;
char
**
sptr
;
switch
(
key
)
{
case
'h'
:
arguments
->
host
=
arg
;
break
;
case
'p'
:
arguments
->
port
=
atoi
(
arg
);
break
;
case
'u'
:
arguments
->
user
=
arg
;
break
;
case
'P'
:
arguments
->
password
=
arg
;
break
;
case
'o'
:
arguments
->
output_file
=
arg
;
break
;
case
's'
:
arguments
->
sqlFile
=
arg
;
break
;
case
'q'
:
arguments
->
mode
=
atoi
(
arg
);
break
;
case
'T'
:
arguments
->
num_of_threads
=
atoi
(
arg
);
break
;
case
'r'
:
arguments
->
num_of_RPR
=
atoi
(
arg
);
break
;
case
't'
:
arguments
->
num_of_tables
=
atoi
(
arg
);
break
;
case
'n'
:
arguments
->
num_of_DPT
=
atoi
(
arg
);
break
;
case
'd'
:
arguments
->
database
=
arg
;
break
;
case
'l'
:
arguments
->
num_of_CPR
=
atoi
(
arg
);
break
;
case
'b'
:
sptr
=
arguments
->
datatype
;
if
(
strstr
(
arg
,
","
)
==
NULL
)
{
if
(
strcasecmp
(
arg
,
"INT"
)
!=
0
&&
strcasecmp
(
arg
,
"FLOAT"
)
!=
0
&&
strcasecmp
(
arg
,
"TINYINT"
)
!=
0
&&
strcasecmp
(
arg
,
"BOOL"
)
!=
0
&&
strcasecmp
(
arg
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
arg
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
arg
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
arg
,
"BINARY"
)
&&
strcasecmp
(
arg
,
"NCHAR"
))
{
argp_error
(
state
,
"Invalid data_type!"
);
}
sptr
[
index
++
]
=
token
;
token
=
strsep
(
&
running
,
","
);
if
(
index
>=
MAX_NUM_DATATYPE
)
break
;
sptr
[
0
]
=
arg
;
}
else
{
int
index
=
0
;
char
*
dupstr
=
strdup
(
arg
);
char
*
running
=
dupstr
;
char
*
token
=
strsep
(
&
running
,
","
);
while
(
token
!=
NULL
)
{
if
(
strcasecmp
(
token
,
"INT"
)
!=
0
&&
strcasecmp
(
token
,
"FLOAT"
)
!=
0
&&
strcasecmp
(
token
,
"TINYINT"
)
!=
0
&&
strcasecmp
(
token
,
"BOOL"
)
!=
0
&&
strcasecmp
(
token
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
token
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
token
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
token
,
"BINARY"
)
&&
strcasecmp
(
token
,
"NCHAR"
))
{
argp_error
(
state
,
"Invalid data_type!"
);
}
sptr
[
index
++
]
=
token
;
token
=
strsep
(
&
running
,
","
);
if
(
index
>=
MAX_NUM_DATATYPE
)
break
;
}
}
}
break
;
case
'w'
:
arguments
->
len_of_binary
=
atoi
(
arg
);
break
;
case
'm'
:
arguments
->
tb_prefix
=
arg
;
break
;
case
'M'
:
arguments
->
use_metric
=
false
;
break
;
case
'x'
:
arguments
->
insert_only
=
false
;
break
;
case
'c'
:
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"Invalid path %s
\n
"
,
arg
);
return
-
1
;
}
taos_options
(
TSDB_OPTION_CONFIGDIR
,
full_path
.
we_wordv
[
0
]);
wordfree
(
&
full_path
);
break
;
case
'O'
:
arguments
->
order
=
atoi
(
arg
);
if
(
arguments
->
order
>
1
||
arguments
->
order
<
0
)
{
arguments
->
order
=
0
;
}
else
if
(
arguments
->
order
==
1
)
{
arguments
->
rate
=
10
;
}
break
;
case
'R'
:
arguments
->
rate
=
atoi
(
arg
);
if
(
arguments
->
order
==
1
&&
(
arguments
->
rate
>
50
||
arguments
->
rate
<=
0
))
{
arguments
->
rate
=
10
;
}
break
;
case
'D'
:
arguments
->
method_of_delete
=
atoi
(
arg
);
if
(
arguments
->
method_of_delete
<
0
||
arguments
->
method_of_delete
>
3
)
{
arguments
->
method_of_delete
=
0
;
}
break
;
case
OPT_ABORT
:
arguments
->
abort
=
1
;
break
;
case
ARGP_KEY_ARG
:
/*arguments->arg_list = &state->argv[state->next-1];
state->next = state->argc;*/
argp_usage
(
state
);
break
;
break
;
case
'w'
:
arguments
->
len_of_binary
=
atoi
(
arg
);
break
;
case
'm'
:
arguments
->
tb_prefix
=
arg
;
break
;
case
'M'
:
arguments
->
use_metric
=
false
;
break
;
case
'x'
:
arguments
->
insert_only
=
false
;
break
;
case
'c'
:
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"Invalid path %s
\n
"
,
arg
);
return
-
1
;
}
taos_options
(
TSDB_OPTION_CONFIGDIR
,
full_path
.
we_wordv
[
0
]);
wordfree
(
&
full_path
);
break
;
case
'O'
:
arguments
->
order
=
atoi
(
arg
);
if
(
arguments
->
order
>
1
||
arguments
->
order
<
0
)
{
arguments
->
order
=
0
;
}
else
if
(
arguments
->
order
==
1
)
{
arguments
->
rate
=
10
;
}
break
;
case
'R'
:
arguments
->
rate
=
atoi
(
arg
);
if
(
arguments
->
order
==
1
&&
(
arguments
->
rate
>
50
||
arguments
->
rate
<=
0
))
{
arguments
->
rate
=
10
;
}
break
;
case
'D'
:
arguments
->
method_of_delete
=
atoi
(
arg
);
if
(
arguments
->
method_of_delete
<
0
||
arguments
->
method_of_delete
>
3
)
{
arguments
->
method_of_delete
=
0
;
}
break
;
case
OPT_ABORT
:
arguments
->
abort
=
1
;
break
;
case
ARGP_KEY_ARG
:
/*arguments->arg_list = &state->argv[state->next-1];
state->next = state->argc;*/
argp_usage
(
state
);
break
;
default:
return
ARGP_ERR_UNKNOWN
;
default:
return
ARGP_ERR_UNKNOWN
;
}
return
0
;
}
return
0
;
}
static
struct
argp
argp
=
{
options
,
parse_opt
,
0
,
0
};
void
parse_args
(
int
argc
,
char
*
argv
[],
SDemoArguments
*
arguments
)
{
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
arguments
);
if
(
arguments
.
abort
)
{
#ifndef _ALPINE
error
(
10
,
0
,
"ABORTED"
);
#else
abort
();
#endif
}
}
#else
void
printHelp
()
{
char
indent
[
10
]
=
" "
;
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"host, The host to connect to TDEngine. Default is localhost."
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"port, The TCP/IP port number to use for the connection. Default is 0."
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"user, The TDEngine user name to use when connecting to the server. Default is 'root'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"password, The password to use when connecting to the server. Default is 'taosdata'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-d"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"database, Destination database. Default is 'test'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-m"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"table_prefix, Table prefix name. Default is 't'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-s"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"sql file, The select sql file."
);
printf
(
"%s%s
\n
"
,
indent
,
"-M"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"meteric, Use metric flag."
);
printf
(
"%s%s
\n
"
,
indent
,
"-o"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"outputfile, Direct output to the named file. Default is './output.txt'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-q"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."
);
printf
(
"%s%s
\n
"
,
indent
,
"-b"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-w"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"
);
printf
(
"%s%s
\n
"
,
indent
,
"-l"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"num_of_cols_per_record, The number of columns per record. Default is 3."
);
printf
(
"%s%s
\n
"
,
indent
,
"-T"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"num_of_threads, The number of threads. Default is 10."
);
printf
(
"%s%s
\n
"
,
indent
,
"-r"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"num_of_records_per_req, The number of records per request. Default is 1000."
);
printf
(
"%s%s
\n
"
,
indent
,
"-t"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"num_of_tables, The number of tables. Default is 10000."
);
printf
(
"%s%s
\n
"
,
indent
,
"-n"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"num_of_records_per_table, The number of records per table. Default is 100000."
);
printf
(
"%s%s
\n
"
,
indent
,
"-c"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"config_directory, Configuration directory. Default is '/etc/taos/'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-x"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"flag, Insert only flag."
);
printf
(
"%s%s
\n
"
,
indent
,
"-O"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"order, Insert mode--0: In order, 1: Out of order. Default is in order."
);
printf
(
"%s%s
\n
"
,
indent
,
"-R"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."
);
printf
(
"%s%s
\n
"
,
indent
,
"-D"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Delete data methods——0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."
);
}
void
parse_args
(
int
argc
,
char
*
argv
[],
SDemoArguments
*
arguments
)
{
char
**
sptr
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
)
{
arguments
->
host
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
arguments
->
port
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-u"
)
==
0
)
{
arguments
->
user
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-P"
)
==
0
)
{
arguments
->
password
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-o"
)
==
0
)
{
arguments
->
output_file
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-s"
)
==
0
)
{
arguments
->
sqlFile
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-q"
)
==
0
)
{
arguments
->
mode
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-T"
)
==
0
)
{
arguments
->
num_of_threads
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-r"
)
==
0
)
{
arguments
->
num_of_RPR
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
)
{
arguments
->
num_of_tables
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-n"
)
==
0
)
{
arguments
->
num_of_DPT
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
arguments
->
database
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-l"
)
==
0
)
{
arguments
->
num_of_CPR
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-b"
)
==
0
)
{
sptr
=
arguments
->
datatype
;
++
i
;
if
(
strstr
(
argv
[
i
],
","
)
==
NULL
)
{
if
(
strcasecmp
(
argv
[
i
],
"INT"
)
!=
0
&&
strcasecmp
(
argv
[
i
],
"FLOAT"
)
!=
0
&&
strcasecmp
(
argv
[
i
],
"TINYINT"
)
!=
0
&&
strcasecmp
(
argv
[
i
],
"BOOL"
)
!=
0
&&
strcasecmp
(
argv
[
i
],
"SMALLINT"
)
!=
0
&&
strcasecmp
(
argv
[
i
],
"BIGINT"
)
!=
0
&&
strcasecmp
(
argv
[
i
],
"DOUBLE"
)
!=
0
&&
strcasecmp
(
argv
[
i
],
"BINARY"
)
&&
strcasecmp
(
argv
[
i
],
"NCHAR"
))
{
fprintf
(
stderr
,
"Invalid data_type!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
}
sptr
[
0
]
=
argv
[
i
];
}
else
{
int
index
=
0
;
char
*
dupstr
=
strdup
(
argv
[
i
]);
char
*
running
=
dupstr
;
char
*
token
=
strsep
(
&
running
,
","
);
while
(
token
!=
NULL
)
{
if
(
strcasecmp
(
token
,
"INT"
)
!=
0
&&
strcasecmp
(
token
,
"FLOAT"
)
!=
0
&&
strcasecmp
(
token
,
"TINYINT"
)
!=
0
&&
strcasecmp
(
token
,
"BOOL"
)
!=
0
&&
strcasecmp
(
token
,
"SMALLINT"
)
!=
0
&&
strcasecmp
(
token
,
"BIGINT"
)
!=
0
&&
strcasecmp
(
token
,
"DOUBLE"
)
!=
0
&&
strcasecmp
(
token
,
"BINARY"
)
&&
strcasecmp
(
token
,
"NCHAR"
))
{
fprintf
(
stderr
,
"Invalid data_type!
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
}
sptr
[
index
++
]
=
token
;
token
=
strsep
(
&
running
,
","
);
if
(
index
>=
MAX_NUM_DATATYPE
)
break
;
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-w"
)
==
0
)
{
arguments
->
len_of_binary
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-m"
)
==
0
)
{
arguments
->
tb_prefix
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-M"
)
==
0
)
{
arguments
->
use_metric
=
false
;
}
else
if
(
strcmp
(
argv
[
i
],
"-x"
)
==
0
)
{
arguments
->
insert_only
=
false
;
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
strcpy
(
configDir
,
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-O"
)
==
0
)
{
arguments
->
order
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
order
>
1
||
arguments
->
order
<
0
)
{
arguments
->
order
=
0
;
}
else
if
(
arguments
->
order
==
1
)
{
arguments
->
rate
=
10
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"-R"
)
==
0
)
{
arguments
->
rate
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
order
==
1
&&
(
arguments
->
rate
>
50
||
arguments
->
rate
<=
0
))
{
arguments
->
rate
=
10
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"-D"
)
==
0
)
{
arguments
->
method_of_delete
=
atoi
(
argv
[
++
i
]);
if
(
arguments
->
method_of_delete
<
0
||
arguments
->
method_of_delete
>
3
)
{
arguments
->
method_of_delete
=
0
;
}
}
else
if
(
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
printHelp
();
exit
(
EXIT_FAILURE
);
}
else
{
fprintf
(
stderr
,
"wrong options
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
}
}
}
#endif
/* ******************************* Structure
* definition******************************* */
...
...
@@ -293,9 +468,6 @@ typedef struct {
* variables******************************* */
char
*
aggreFunc
[]
=
{
"*"
,
"count(*)"
,
"avg(f1)"
,
"sum(f1)"
,
"max(f1)"
,
"min(f1)"
,
"first(f1)"
,
"last(f1)"
};
/* ******************************* Global
* functions******************************* */
static
struct
argp
argp
=
{
options
,
parse_opt
,
0
,
0
};
void
queryDB
(
TAOS
*
taos
,
char
*
command
);
...
...
@@ -368,15 +540,7 @@ int main(int argc, char *argv[]) {
arguments
.
insert_only
=
true
;
// end change
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
arguments
);
if
(
arguments
.
abort
)
{
#ifndef _ALPINE
error
(
10
,
0
,
"ABORTED"
);
#else
abort
();
#endif
}
parse_args
(
argc
,
argv
,
&
arguments
);
enum
MODE
query_mode
=
arguments
.
mode
;
char
*
ip_addr
=
arguments
.
host
;
...
...
@@ -438,7 +602,7 @@ int main(int argc, char *argv[]) {
printf
(
"# Use metric: %s
\n
"
,
use_metric
?
"true"
:
"false"
);
printf
(
"# Datatype of Columns: %s
\n
"
,
dataString
);
printf
(
"# Binary Length(If applicable): %d
\n
"
,
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
||
strcasestr
(
dataString
,
"NCHAR"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
(
strncasecmp
(
dataString
,
"BINARY"
,
6
)
==
0
||
strncasecmp
(
dataString
,
"NCHAR"
,
5
)
==
0
)
?
len_of_binary
:
-
1
);
printf
(
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
printf
(
"# Number of Threads: %d
\n
"
,
threads
);
printf
(
"# Number of Tables: %d
\n
"
,
ntables
);
...
...
@@ -466,7 +630,7 @@ int main(int argc, char *argv[]) {
fprintf
(
fp
,
"# Use metric: %s
\n
"
,
use_metric
?
"true"
:
"false"
);
fprintf
(
fp
,
"# Datatype of Columns: %s
\n
"
,
dataString
);
fprintf
(
fp
,
"# Binary Length(If applicable): %d
\n
"
,
(
strcasestr
(
dataString
,
"BINARY"
)
!=
NULL
||
strcasestr
(
dataString
,
"NCHAR"
)
!=
NULL
)
?
len_of_binary
:
-
1
);
(
strncasecmp
(
dataString
,
"BINARY"
,
6
)
==
0
||
strncasecmp
(
dataString
,
"NCHAR"
,
5
)
==
0
)
?
len_of_binary
:
-
1
);
fprintf
(
fp
,
"# Number of Columns per record: %d
\n
"
,
ncols_per_record
);
fprintf
(
fp
,
"# Number of Threads: %d
\n
"
,
threads
);
fprintf
(
fp
,
"# Number of Tables: %d
\n
"
,
ntables
);
...
...
@@ -753,7 +917,7 @@ void querySqlFile(TAOS* taos, char* sqlFile)
double
t
=
getCurrentTime
();
while
((
read_len
=
g
etline
(
&
line
,
&
line_len
,
fp
))
!=
-
1
)
{
while
((
read_len
=
taosG
etline
(
&
line
,
&
line_len
,
fp
))
!=
-
1
)
{
if
(
read_len
>=
MAX_SQL_SIZE
)
continue
;
line
[
--
read_len
]
=
'\0'
;
...
...
@@ -1035,7 +1199,7 @@ void *syncWrite(void *sarg) {
char
**
data_type
=
winfo
->
datatype
;
int
len_of_binary
=
winfo
->
len_of_binary
;
int
ncols_per_record
=
winfo
->
ncols_per_record
;
srand
(
time
(
NULL
));
srand
(
(
uint32_t
)
time
(
NULL
));
int64_t
time_counter
=
winfo
->
start_time
;
for
(
int
i
=
0
;
i
<
winfo
->
nrecords_per_table
;)
{
for
(
int
tID
=
winfo
->
start_table_id
;
tID
<=
winfo
->
end_table_id
;
tID
++
)
{
...
...
@@ -1049,7 +1213,7 @@ void *syncWrite(void *sarg) {
int
rand_num
=
rand
()
%
100
;
int
len
=
-
1
;
if
(
winfo
->
data_of_order
==
1
&&
rand_num
<
winfo
->
data_of_rate
)
{
long
d
=
tmp_time
-
rand
()
%
1000000
+
rand_num
;
int64_t
d
=
tmp_time
-
rand
()
%
1000000
+
rand_num
;
len
=
generateData
(
data
,
data_type
,
ncols_per_record
,
d
,
len_of_binary
);
}
else
{
len
=
generateData
(
data
,
data_type
,
ncols_per_record
,
tmp_time
+=
1000
,
len_of_binary
);
...
...
@@ -1144,7 +1308,7 @@ void callBack(void *param, TAOS_RES *res, int code) {
int
rand_num
=
rand
()
%
100
;
if
(
tb_info
->
data_of_order
==
1
&&
rand_num
<
tb_info
->
data_of_rate
)
{
long
d
=
tmp_time
-
rand
()
%
1000000
+
rand_num
;
int64_t
d
=
tmp_time
-
rand
()
%
1000000
+
rand_num
;
generateData
(
data
,
datatype
,
ncols_per_record
,
d
,
len_of_binary
);
}
else
{
...
...
@@ -1269,13 +1433,15 @@ int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t times
bool
b
=
rand
()
&
1
;
pstr
+=
sprintf
(
pstr
,
", %s"
,
b
?
"true"
:
"false"
);
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"binary"
)
==
0
)
{
char
s
[
len_of_binary
]
;
char
*
s
=
malloc
(
len_of_binary
)
;
rand_string
(
s
,
len_of_binary
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
free
(
s
);
}
else
if
(
strcasecmp
(
data_type
[
i
%
c
],
"nchar"
)
==
0
)
{
char
s
[
len_of_binary
]
;
char
*
s
=
malloc
(
len_of_binary
)
;
rand_string
(
s
,
len_of_binary
);
pstr
+=
sprintf
(
pstr
,
",
\"
%s
\"
"
,
s
);
free
(
s
);
}
if
(
pstr
-
res
>
MAX_DATA_SIZE
)
{
...
...
@@ -1286,7 +1452,7 @@ int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t times
pstr
+=
sprintf
(
pstr
,
")"
);
return
pstr
-
res
;
return
(
int32_t
)(
pstr
-
res
)
;
}
static
const
char
charset
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567890"
;
...
...
src/os/inc/osWindows.h
浏览文件 @
7e3cd84d
...
...
@@ -42,6 +42,7 @@
#include "msvcProcess.h"
#include "msvcDirect.h"
#include "msvcFcntl.h"
#include "msvcStdio.h"
#include "sys/msvcStat.h"
#include "sys/msvcTypes.h"
...
...
tests/tsim/CMakeLists.txt
浏览文件 @
7e3cd84d
...
...
@@ -4,10 +4,6 @@ INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/cJson/inc
)
INCLUDE_DIRECTORIES
(
inc
)
IF
(
TD_WINDOWS
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/pthread
)
ENDIF
()
AUX_SOURCE_DIRECTORY
(
src SRC
)
ADD_EXECUTABLE
(
tsim
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
tsim taos_static trpc tutil pthread cJson
)
tests/tsim/src/simExe.c
浏览文件 @
7e3cd84d
...
...
@@ -313,7 +313,9 @@ bool simExecuteSystemCmd(SScript *script, char *option) {
simError
(
"script:%s, failed to execute %s , code %d, errno:%d %s, repeatTimes:%d"
,
script
->
fileName
,
buf
,
code
,
errno
,
strerror
(
errno
),
repeatTimes
);
taosMsleep
(
1000
);
#ifdef LINUX
signal
(
SIGCHLD
,
SIG_DFL
);
#endif
if
(
repeatTimes
++
>=
10
)
{
exit
(
0
);
}
...
...
@@ -418,14 +420,14 @@ void simVisuallizeOption(SScript *script, char *src, char *dst) {
var
=
strchr
(
src
,
'$'
);
if
(
var
==
NULL
)
break
;
if
(
var
&&
((
var
-
src
-
1
)
>
0
)
&&
*
(
var
-
1
)
==
'\\'
)
{
srcLen
=
var
-
src
-
1
;
srcLen
=
(
int
)(
var
-
src
-
1
)
;
memcpy
(
dst
+
dstLen
,
src
,
srcLen
);
dstLen
+=
srcLen
;
src
=
var
;
break
;
}
srcLen
=
var
-
src
;
srcLen
=
(
int
)(
var
-
src
)
;
memcpy
(
dst
+
dstLen
,
src
,
srcLen
);
dstLen
+=
srcLen
;
...
...
@@ -433,7 +435,7 @@ void simVisuallizeOption(SScript *script, char *src, char *dst) {
value
=
simGetVariable
(
script
,
token
,
tokenLen
);
strcpy
(
dst
+
dstLen
,
value
);
dstLen
+=
strlen
(
value
);
dstLen
+=
(
int
)
strlen
(
value
);
}
strcpy
(
dst
+
dstLen
,
src
);
...
...
@@ -455,9 +457,9 @@ void simCloseNativeConnect(SScript *script) {
void
simCloseTaosdConnect
(
SScript
*
script
)
{
if
(
simAsyncQuery
)
{
return
simCloseRestFulConnect
(
script
);
simCloseRestFulConnect
(
script
);
}
else
{
return
simCloseNativeConnect
(
script
);
simCloseNativeConnect
(
script
);
}
}
// {"status":"succ","code":0,"desc":"/KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04"}
...
...
@@ -575,7 +577,7 @@ int simExecuteRestFulCommand(SScript *script, char *command) {
while
(
!
feof
(
fp
))
{
int
availSize
=
mallocSize
-
alreadyReadSize
;
int
len
=
fread
(
content
+
alreadyReadSize
,
1
,
availSize
,
fp
);
int
len
=
(
int
)
fread
(
content
+
alreadyReadSize
,
1
,
availSize
,
fp
);
if
(
len
>=
availSize
)
{
alreadyReadSize
+=
len
;
mallocSize
*=
2
;
...
...
tests/tsim/src/simParse.c
浏览文件 @
7e3cd84d
...
...
@@ -105,7 +105,7 @@ void simAddCmdIntoHash(SCommand *pCmd) {
int
hash
;
SCommand
*
node
;
hash
=
simHashCmd
(
pCmd
->
name
,
strlen
(
pCmd
->
name
));
hash
=
simHashCmd
(
pCmd
->
name
,
(
int
)
strlen
(
pCmd
->
name
));
node
=
cmdHashList
[
hash
];
pCmd
->
next
=
node
;
cmdHashList
[
hash
]
=
pCmd
;
...
...
@@ -199,7 +199,7 @@ SScript *simParseScript(char *fileName) {
if
(
fgets
(
buffer
,
sizeof
(
buffer
),
fd
)
==
NULL
)
continue
;
lineNum
++
;
int
cmdlen
=
strlen
(
buffer
);
int
cmdlen
=
(
int
)
strlen
(
buffer
);
if
(
buffer
[
cmdlen
-
1
]
==
'\r'
||
buffer
[
cmdlen
-
1
]
==
'\n'
)
buffer
[
cmdlen
-
1
]
=
0
;
rest
=
buffer
;
...
...
@@ -294,10 +294,10 @@ int simCheckExpression(char *exp) {
rest
=
paGetToken
(
rest
,
&
op
,
&
opLen
);
if
(
opLen
==
0
)
return
rest
-
exp
;
if
(
opLen
==
0
)
return
(
int
)(
rest
-
exp
)
;
/* if it is key word "then" */
if
(
strncmp
(
op
,
"then"
,
4
)
==
0
)
return
op
-
exp
;
if
(
strncmp
(
op
,
"then"
,
4
)
==
0
)
return
(
int
)(
op
-
exp
)
;
rest
=
paGetToken
(
rest
,
&
op2
,
&
op2Len
);
if
(
op2Len
==
0
)
{
...
...
@@ -312,7 +312,7 @@ int simCheckExpression(char *exp) {
if
(
op
[
0
]
==
'+'
||
op
[
0
]
==
'-'
||
op
[
0
]
==
'*'
||
op
[
0
]
==
'/'
||
op
[
0
]
==
'.'
)
{
return
rest
-
exp
;
return
(
int
)(
rest
-
exp
)
;
}
return
-
1
;
...
...
@@ -655,7 +655,7 @@ bool simParsePrintCmd(char *rest, SCommand *pCmd, int lineNum) {
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_PRINT
;
cmdLine
[
numOfLines
].
lineNum
=
lineNum
;
cmdLine
[
numOfLines
].
optionOffset
=
optionOffset
;
expLen
=
strlen
(
rest
);
expLen
=
(
int
)
strlen
(
rest
);
memcpy
(
optionBuffer
+
optionOffset
,
rest
,
expLen
);
optionOffset
+=
expLen
+
1
;
*
(
optionBuffer
+
optionOffset
-
1
)
=
0
;
...
...
@@ -690,7 +690,7 @@ bool simParseSqlCmd(char *rest, SCommand *pCmd, int lineNum) {
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_SQL
;
cmdLine
[
numOfLines
].
lineNum
=
lineNum
;
cmdLine
[
numOfLines
].
optionOffset
=
optionOffset
;
expLen
=
strlen
(
rest
);
expLen
=
(
int
)
strlen
(
rest
);
memcpy
(
optionBuffer
+
optionOffset
,
rest
,
expLen
);
optionOffset
+=
expLen
+
1
;
*
(
optionBuffer
+
optionOffset
-
1
)
=
0
;
...
...
@@ -706,7 +706,7 @@ bool simParseSqlErrorCmd(char *rest, SCommand *pCmd, int lineNum) {
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_SQL_ERROR
;
cmdLine
[
numOfLines
].
lineNum
=
lineNum
;
cmdLine
[
numOfLines
].
optionOffset
=
optionOffset
;
expLen
=
strlen
(
rest
);
expLen
=
(
int
)
strlen
(
rest
);
memcpy
(
optionBuffer
+
optionOffset
,
rest
,
expLen
);
optionOffset
+=
expLen
+
1
;
*
(
optionBuffer
+
optionOffset
-
1
)
=
0
;
...
...
@@ -728,7 +728,7 @@ bool simParseSystemCmd(char *rest, SCommand *pCmd, int lineNum) {
cmdLine
[
numOfLines
].
cmdno
=
SIM_CMD_SYSTEM
;
cmdLine
[
numOfLines
].
lineNum
=
lineNum
;
cmdLine
[
numOfLines
].
optionOffset
=
optionOffset
;
expLen
=
strlen
(
rest
);
expLen
=
(
int
)
strlen
(
rest
);
memcpy
(
optionBuffer
+
optionOffset
,
rest
,
expLen
);
optionOffset
+=
expLen
+
1
;
*
(
optionBuffer
+
optionOffset
-
1
)
=
0
;
...
...
@@ -840,14 +840,14 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_EXP
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"exp"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
NULL
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteExpCmd
;
cmdno
=
SIM_CMD_IF
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"if"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseIfCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -855,7 +855,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_ELIF
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"elif"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseElifCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -863,7 +863,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_ELSE
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"else"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseElseCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -871,7 +871,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_ENDI
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"endi"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseEndiCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -879,7 +879,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_WHILE
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"while"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseWhileCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -887,7 +887,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_ENDW
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"endw"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseEndwCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -895,7 +895,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_SWITCH
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"switch"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseSwitchCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -903,7 +903,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_CASE
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"case"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseCaseCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -911,7 +911,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_DEFAULT
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"default"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseDefaultCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -919,7 +919,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_BREAK
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"break"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseBreakCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -927,7 +927,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_CONTINUE
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"continue"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseContinueCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -935,7 +935,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_ENDS
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"ends"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseEndsCmd
;
simCmdList
[
cmdno
].
executeCmd
=
NULL
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -943,7 +943,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_SLEEP
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"sleep"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseSleepCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteSleepCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -951,7 +951,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_GOTO
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"goto"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseGotoCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteGotoCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -959,7 +959,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_RUN
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"run"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseRunCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteRunCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -967,7 +967,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_RUN_BACK
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"run_back"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseRunBackCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteRunBackCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -975,7 +975,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_SYSTEM
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"system"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseSystemCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteSystemCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -983,7 +983,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_SYSTEM_CONTENT
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"system_content"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseSystemContentCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteSystemContentCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -991,7 +991,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_PRINT
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"print"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParsePrintCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecutePrintCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -999,7 +999,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_SQL
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"sql"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseSqlCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteSqlCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -1007,7 +1007,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_SQL_ERROR
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"sql_error"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseSqlErrorCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteSqlErrorCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -1015,7 +1015,7 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_SQL_SLOW
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"sql_slow"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseSqlSlowCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteSqlSlowCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
@@ -1024,14 +1024,14 @@ void simInitsimCmdList() {
cmdno
=
SIM_CMD_TEST
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"test"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
NULL
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteTestCmd
;
cmdno
=
SIM_CMD_RETURN
;
simCmdList
[
cmdno
].
cmdno
=
cmdno
;
strcpy
(
simCmdList
[
cmdno
].
name
,
"return"
);
simCmdList
[
cmdno
].
nlen
=
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
nlen
=
(
int
)
strlen
(
simCmdList
[
cmdno
].
name
);
simCmdList
[
cmdno
].
parseCmd
=
simParseReturnCmd
;
simCmdList
[
cmdno
].
executeCmd
=
simExecuteReturnCmd
;
simAddCmdIntoHash
(
&
(
simCmdList
[
cmdno
]));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录