summaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-07-15 11:34:25 +0200
committerVijay Bellur <vijay@gluster.com>2011-09-12 06:21:04 -0700
commit36059b73949a1eee32a3b2aa16b09263628ff050 (patch)
tree15fba87ddf2d617dbc177fefaf29fce6b729f16a /cli
parente139eeeb627368112aa1341d2f0ef6770dd7078e (diff)
Revert "cli: gluster --version implementation"
This reverts commit e93b270e8d09fc9d36a39b22987d3a172197e73b. Conflicts: cli/src/cli.c Change-Id: Ibc0f6f752f713b15afc8b5458be5045ecb21235e BUG: 3242 Reviewed-on: http://review.gluster.com/91 Reviewed-by: Vijay Bellur <vijay@gluster.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'cli')
-rw-r--r--cli/src/cli.c74
1 files changed, 15 insertions, 59 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index 858c7091b8d..d362cd11a53 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -78,9 +78,6 @@
extern int connected;
/* using argp for command line parsing */
-static char gf_doc[] = "";
-
-static char argp_doc[] = "";
const char *argp_program_version = "" \
PACKAGE_NAME" "PACKAGE_VERSION" built on "__DATE__" "__TIME__ \
@@ -93,10 +90,7 @@ const char *argp_program_version = "" \
const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">";
-static struct argp_option gf_options[] = {
- {0, 0, 0, 0, "Basic options:"},
- {0, }
-};
+
struct rpc_clnt *global_rpc;
@@ -105,39 +99,6 @@ rpc_clnt_prog_t *cli_rpc_prog;
extern struct rpc_clnt_program cli_prog;
-static error_t
-parse_opts (int key, char *arg, struct argp_state *argp_state)
-{
- struct cli_state *state = NULL;
- char **argv = NULL;
-
- state = argp_state->input;
-
- switch (key) {
- case ARGP_KEY_ARG:
- if (!state->argc) {
- argv = calloc (state->argc + 2,
- sizeof (*state->argv));
- } else {
- argv = realloc (state->argv, (state->argc + 2) *
- sizeof (*state->argv));
- }
- if (!argv)
- return -1;
-
- state->argv = argv;
-
- argv[state->argc] = strdup (arg);
- if (!argv[state->argc])
- return -1;
- state->argc++;
- argv[state->argc] = NULL;
-
- break;
- }
-
- return 0;
-}
@@ -394,29 +355,24 @@ parse_cmdline (int argc, char *argv[], struct cli_state *state)
int i = 0;
int j = 0;
char *opt = NULL;
- struct argp argp = { 0,};
- argp.options = gf_options;
- argp.parser = parse_opts;
- argp.args_doc = argp_doc;
- argp.doc = gf_doc;
+ state->argc=argc-1;
+ state->argv=&argv[1];
- for (i = 0; i < argc; i++) {
- opt = strtail (argv[i], "--");
+ for (i = 0; i < state->argc; i++) {
+ opt = strtail (state->argv[i], "--");
if (opt) {
ret = cli_opt_parse (opt, state);
if (ret == -1) {
- break;
+ cli_out ("unrecognized option --%s", opt);
+ return ret;
}
- for (j = i; j < argc - 1; j++)
- argv[j] = argv[j + 1];
- argc--;
+ for (j = i; j < state->argc - 1; j++)
+ state->argv[j] = state->argv[j + 1];
+ state->argc--;
}
}
- ret = argp_parse (&argp, argc, argv,
- ARGP_IN_ORDER, NULL, state);
-
return ret;
}
@@ -632,6 +588,11 @@ main (int argc, char *argv[])
int ret = -1;
glusterfs_ctx_t *ctx = NULL;
+ if (geteuid ()) {
+ printf ("Only super user can run this command\n");
+ return EPERM;
+ }
+
ret = glusterfs_globals_init ();
if (ret)
return ret;
@@ -655,11 +616,6 @@ main (int argc, char *argv[])
if (ret)
goto out;
- if (geteuid ()) {
- printf ("Only super user can run this command\n");
- return EPERM;
- }
-
ret = logging_init (ctx);
if (ret)
goto out;