shellInt.h 3.0 KB
Newer Older
H
hzcheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

16 17
#ifndef _TD_SHELL_INT_H_
#define _TD_SHELL_INT_H_
H
hzcheng 已提交
18

S
Shengliang Guan 已提交
19 20
#include "os.h"
#include "taos.h"
S
slguan 已提交
21
#include "taosdef.h"
22 23 24
#include "taoserror.h"
#include "tconfig.h"
#include "tglobal.h"
25
#include "trpc.h"
26 27
#include "ttypes.h"
#include "tutil.h"
H
hzcheng 已提交
28

29 30 31 32 33
#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
34 35 36 37 38 39
#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
D
fix bug  
dapan1121 已提交
40

41
typedef struct {
42 43
  char*   hist[SHELL_MAX_HISTORY_SIZE];
  char    file[TSDB_FILENAME_LEN];
44 45
  int32_t hstart;
  int32_t hend;
46
} SShellHistory;
H
hzcheng 已提交
47

48 49 50 51 52 53 54
typedef struct {
  const char* host;
  const char* user;
  const char* auth;
  const char* database;
  const char* cfgdir;
  const char* commands;
55
  const char* netrole;
56
  char        file[PATH_MAX];
57
  char        password[TSDB_USET_PASSWORD_LEN];
58 59 60 61 62 63 64
  bool        is_gen_auth;
  bool        is_raw_time;
  bool        is_version;
  bool        is_dump_config;
  bool        is_check;
  bool        is_startup;
  bool        is_help;
65
  int32_t     port;
66 67
  int32_t     pktLen;
  int32_t     pktNum;
68
  int32_t     displayWidth;
69 70 71 72
  int32_t     abort;
} SShellArgs;

typedef struct {
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
  const char* clientVersion;
  const char* promptHeader;
  const char* promptContinue;
  const char* osname;
  int32_t     promptSize;
  char        programVersion[32];
} SShellOsDetails;

typedef struct {
  SShellArgs      args;
  SShellHistory   history;
  SShellOsDetails info;
  TAOS*           conn;
  TdThread        pid;
  tsem_t          cancelSem;
88 89
} SShellObj;

90
// shellArguments.c
91 92
int32_t shellParseArgs(int32_t argc, char* argv[]);

93 94 95 96 97 98 99 100 101
// shellCommand.c
int32_t shellReadCommand(char* command);

// shellEngine.c
int32_t shellExecute();

// shellUtil.c
int32_t shellCheckIntSize();
void    shellPrintVersion();
102
void    shellPrintHelp();
103 104 105 106
void    shellGenerateAuth();
void    shellDumpConfig();
void    shellCheckServerStatus();
bool    shellRegexMatch(const char* s, const char* reg, int32_t cflags);
107
void    shellExit();
H
hzcheng 已提交
108

109 110
// shellNettest.c
void shellTestNetWork();
H
hzcheng 已提交
111

112
// shellMain.c
113
extern SShellObj shell;
H
hzcheng 已提交
114

115
#endif /*_TD_SHELL_INT_H_*/