4bc45e7cac57cb4c156689990509913b5" /* Copyright (c) 2006-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #ifndef __CLI_H__ #define __CLI_H__ #include "rpc-clnt.h" #include "glusterfs.h" #include "protocol-common.h" #include "logging.h" #include "quota-common-utils.h" #include "cli1-xdr.h" #if (HAVE_LIB_XML) #include #include #endif #define DEFAULT_EVENT_POOL_SIZE 16384 #define CLI_GLUSTERD_PORT 24007 #define CLI_DEFAULT_CONN_TIMEOUT 120 #define CLI_DEFAULT_CMD_TIMEOUT 120 #define CLI_TEN_MINUTES_TIMEOUT 600 //Longer timeout for volume top #define DEFAULT_CLI_LOG_FILE_DIRECTORY DATADIR "/log/glusterfs" #define CLI_VOL_STATUS_BRICK_LEN 43 #define CLI_TAB_LENGTH 8 #define CLI_BRICK_STATUS_LINE_LEN 78 /* Geo-rep command positional arguments' index */ #define GEO_REP_CMD_INDEX 1 #define GEO_REP_CMD_CONFIG_INDEX 4 enum argp_option_keys { ARGP_DEBUG_KEY = 133, ARGP_PORT_KEY = 'p', }; typedef enum { COLD_BRICK_COUNT, COLD_TYPE, COLD_DIST_COUNT, COLD_REPLICA_COUNT, COLD_ARBITER_COUNT, COLD_DISPERSE_COUNT, COLD_REDUNDANCY_COUNT, HOT_BRICK_COUNT, HOT_TYPE, HOT_REPLICA_COUNT, MAX } values; #define GLUSTER_MODE_SCRIPT (1 << 0) #define GLUSTER_MODE_ERR_FATAL (1 << 1) #define GLUSTER_MODE_XML (1 << 2) #define GLUSTER_MODE_WIGNORE (1 << 3) #define GLUSTERD_GET_QUOTA_AUX_MOUNT_PATH(abspath, volname, path) \ snprintf (abspath, sizeof (abspath)-1, \ DEFAULT_VAR_RUN_DIRECTORY"/%s%s", volname, path); struct cli_state; struct cli_cmd_word; struct cli_cmd_tree; struct cli_cmd; extern char *cli_vol_type_str[]; extern char *cli_vol_status_str[]; extern char *cli_vol_task_status_str[]; typedef int (cli_cmd_cbk_t)(struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount); typedef void (cli_cmd_reg_cbk_t)( struct cli_cmd *this); typedef int (cli_cmd_match_t)(struct cli_cmd_word *word); typedef int (cli_cmd_filler_t)(struct cli_cmd_word *word); struct cli_cmd_word { struct cli_cmd_tree *tree; const char *word; cli_cmd_filler_t *filler; cli_cmd_match_t *match; cli_cmd_cbk_t *cbkfn; const char *desc; const char *pattern; int nextwords_cnt; struct cli_cmd_word **nextwords; }; struct cli_cmd_tree { struct cli_state *state; struct cli_cmd_word root; }; struct cli_state { int argc; char **argv; char debug; /* for events dispatching */ glusterfs_ctx_t *ctx; /* registry of known commands */ struct cli_cmd_tree tree; /* the thread which "executes" the command in non-interactive mode */ /* also the thread which reads from stdin in non-readline mode */ pthread_t input; /* terminal I/O */ const char *prompt; int rl_enabled; int