2019-07-11 08:36:16 +00:00
|
|
|
/*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2022-04-20 11:44:25 +00:00
|
|
|
#ifndef _TD_SHELL_INT_H_
|
|
|
|
|
#define _TD_SHELL_INT_H_
|
2019-07-11 08:36:16 +00:00
|
|
|
|
2021-12-17 07:49:27 +00:00
|
|
|
#include "os.h"
|
2020-02-14 15:18:14 +00:00
|
|
|
#include "taosdef.h"
|
2022-04-21 13:09:43 +00:00
|
|
|
#include "taoserror.h"
|
2025-03-20 14:54:29 +00:00
|
|
|
#include "taos.h"
|
|
|
|
|
#include "tcommon.h"
|
2022-04-21 13:09:43 +00:00
|
|
|
#include "tconfig.h"
|
|
|
|
|
#include "tglobal.h"
|
2022-04-24 03:19:06 +00:00
|
|
|
#include "trpc.h"
|
2022-04-21 13:09:43 +00:00
|
|
|
#include "ttypes.h"
|
|
|
|
|
#include "tutil.h"
|
2025-03-20 14:54:29 +00:00
|
|
|
#include "tversion.h"
|
|
|
|
|
#include "version.h"
|
|
|
|
|
#include "../../inc/pub.h"
|
2019-07-11 08:36:16 +00:00
|
|
|
|
2025-03-20 14:54:29 +00:00
|
|
|
#define SHELL_WS_TIMEOUT 30
|
|
|
|
|
#define SHELL_WS_DSN_BUFF 256
|
|
|
|
|
#define SHELL_WS_DSN_MASK 10
|
2022-04-21 13:09:43 +00:00
|
|
|
#define SHELL_MAX_HISTORY_SIZE 1000
|
|
|
|
|
#define SHELL_MAX_COMMAND_SIZE 1048586
|
|
|
|
|
#define SHELL_HISTORY_FILE ".taos_history"
|
|
|
|
|
#define SHELL_DEFAULT_RES_SHOW_NUM 100
|
|
|
|
|
#define SHELL_DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30
|
2022-04-24 03:19:06 +00:00
|
|
|
#define SHELL_MAX_PKG_LEN 2 * 1024 * 1024
|
|
|
|
|
#define SHELL_MIN_PKG_LEN 1
|
|
|
|
|
#define SHELL_DEF_PKG_LEN 1024
|
|
|
|
|
#define SHELL_MAX_PKG_NUM 1 * 1024 * 1024
|
|
|
|
|
#define SHELL_MIN_PKG_NUM 1
|
|
|
|
|
#define SHELL_DEF_PKG_NUM 100
|
2023-06-13 10:00:52 +00:00
|
|
|
#define SHELL_FLOAT_WIDTH 20
|
|
|
|
|
#define SHELL_DOUBLE_WIDTH 25
|
2021-02-24 10:43:48 +00:00
|
|
|
|
2025-03-20 14:54:29 +00:00
|
|
|
#define ERROR_CODE_DETAIL \
|
|
|
|
|
"\r\n\r\nTo view possible causes and suggested actions for error codes, see \r\n\"Error Code Reference\" in the " \
|
|
|
|
|
"TDengine online documentation.\r\n"
|
2022-04-20 11:44:25 +00:00
|
|
|
typedef struct {
|
2022-04-21 13:09:43 +00:00
|
|
|
char* hist[SHELL_MAX_HISTORY_SIZE];
|
|
|
|
|
char file[TSDB_FILENAME_LEN];
|
2022-04-20 11:44:25 +00:00
|
|
|
int32_t hstart;
|
|
|
|
|
int32_t hend;
|
2020-05-18 02:23:39 +00:00
|
|
|
} SShellHistory;
|
2019-07-11 08:36:16 +00:00
|
|
|
|
2022-04-20 11:44:25 +00:00
|
|
|
typedef struct {
|
|
|
|
|
const char* host;
|
|
|
|
|
const char* user;
|
|
|
|
|
const char* auth;
|
|
|
|
|
const char* database;
|
|
|
|
|
const char* cfgdir;
|
|
|
|
|
const char* commands;
|
2022-04-21 13:09:43 +00:00
|
|
|
const char* netrole;
|
2022-04-22 09:59:41 +00:00
|
|
|
char file[PATH_MAX];
|
2025-02-14 03:35:37 +00:00
|
|
|
char password[TSDB_USET_PASSWORD_LONGLEN];
|
2022-04-20 11:44:25 +00:00
|
|
|
bool is_gen_auth;
|
2023-12-30 08:44:52 +00:00
|
|
|
bool is_bi_mode;
|
2022-04-20 11:44:25 +00:00
|
|
|
bool is_raw_time;
|
|
|
|
|
bool is_version;
|
|
|
|
|
bool is_dump_config;
|
|
|
|
|
bool is_check;
|
|
|
|
|
bool is_startup;
|
|
|
|
|
bool is_help;
|
2022-04-28 01:43:08 +00:00
|
|
|
int32_t port;
|
2022-04-20 11:44:25 +00:00
|
|
|
int32_t pktLen;
|
|
|
|
|
int32_t pktNum;
|
2022-04-21 13:09:43 +00:00
|
|
|
int32_t displayWidth;
|
2022-04-20 11:44:25 +00:00
|
|
|
int32_t abort;
|
2022-07-23 01:35:00 +00:00
|
|
|
char* dsn;
|
|
|
|
|
int32_t timeout;
|
2025-03-20 14:54:29 +00:00
|
|
|
int8_t connMode;
|
|
|
|
|
bool port_inputted;
|
2022-04-20 11:44:25 +00:00
|
|
|
} SShellArgs;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2025-03-20 14:54:29 +00:00
|
|
|
const char* clientVersion;
|
|
|
|
|
char cusName[32];
|
|
|
|
|
char promptHeader[32];
|
|
|
|
|
char promptContinue[32];
|
2022-04-21 13:09:43 +00:00
|
|
|
const char* osname;
|
|
|
|
|
int32_t promptSize;
|
2023-02-22 07:16:16 +00:00
|
|
|
char programVersion[256];
|
2022-04-21 13:09:43 +00:00
|
|
|
} SShellOsDetails;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
SShellArgs args;
|
|
|
|
|
SShellHistory history;
|
|
|
|
|
SShellOsDetails info;
|
|
|
|
|
TAOS* conn;
|
|
|
|
|
TdThread pid;
|
|
|
|
|
tsem_t cancelSem;
|
2022-08-22 07:22:49 +00:00
|
|
|
bool exit;
|
2022-04-20 11:44:25 +00:00
|
|
|
} SShellObj;
|
|
|
|
|
|
2022-09-07 02:16:00 +00:00
|
|
|
typedef struct {
|
|
|
|
|
char *buffer;
|
|
|
|
|
char *command;
|
|
|
|
|
uint32_t commandSize;
|
|
|
|
|
uint32_t bufferSize;
|
|
|
|
|
uint32_t cursorOffset;
|
|
|
|
|
uint32_t screenOffset;
|
|
|
|
|
uint32_t endOffset;
|
|
|
|
|
} SShellCmd;
|
|
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
// shellArguments.c
|
2022-04-20 11:44:25 +00:00
|
|
|
int32_t shellParseArgs(int32_t argc, char* argv[]);
|
|
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
// shellCommand.c
|
|
|
|
|
int32_t shellReadCommand(char* command);
|
2025-05-17 02:53:42 +00:00
|
|
|
int32_t shellCountPrefixOnes(uint8_t c);
|
2022-04-21 13:09:43 +00:00
|
|
|
|
|
|
|
|
// shellEngine.c
|
2025-03-14 05:32:13 +00:00
|
|
|
int32_t shellExecute(int argc, char *argv[]);
|
2022-07-23 01:35:00 +00:00
|
|
|
int32_t shellCalcColWidth(TAOS_FIELD *field, int32_t precision);
|
|
|
|
|
void shellPrintHeader(TAOS_FIELD *fields, int32_t *width, int32_t num_fields);
|
|
|
|
|
void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t length, int32_t precision);
|
2022-08-30 09:21:38 +00:00
|
|
|
void shellDumpFieldToFile(TdFilePtr pFile, const char *val, TAOS_FIELD *field, int32_t length, int32_t precision);
|
2025-03-20 14:54:29 +00:00
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
// shellUtil.c
|
|
|
|
|
int32_t shellCheckIntSize();
|
|
|
|
|
void shellPrintVersion();
|
2022-04-22 09:59:41 +00:00
|
|
|
void shellPrintHelp();
|
2022-04-21 13:09:43 +00:00
|
|
|
void shellGenerateAuth();
|
|
|
|
|
void shellDumpConfig();
|
|
|
|
|
void shellCheckServerStatus();
|
|
|
|
|
bool shellRegexMatch(const char* s, const char* reg, int32_t cflags);
|
2025-03-20 14:54:29 +00:00
|
|
|
int32_t getDsnEnv();
|
2022-04-21 13:29:21 +00:00
|
|
|
void shellExit();
|
2025-08-26 14:05:29 +00:00
|
|
|
void trimStr(char *srcInfo, char *removeStr);
|
2019-07-11 08:36:16 +00:00
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
// shellNettest.c
|
|
|
|
|
void shellTestNetWork();
|
2019-07-11 08:36:16 +00:00
|
|
|
|
2022-04-21 13:09:43 +00:00
|
|
|
// shellMain.c
|
2022-04-20 11:44:25 +00:00
|
|
|
extern SShellObj shell;
|
2025-03-24 13:19:30 +00:00
|
|
|
extern char configDirShell[PATH_MAX];
|
2019-07-11 08:36:16 +00:00
|
|
|
|
2022-04-20 11:44:25 +00:00
|
|
|
#endif /*_TD_SHELL_INT_H_*/
|