summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-10-31 04:19:58 +0000
committerLuke Leighton <lkcl@samba.org>1999-10-31 04:19:58 +0000
commitce31503de55ffeaa6e694b9177890943442e41c0 (patch)
treea903bdb65c890f93c891d8a7bac65690ac20bdba
parentdbda98047df356cb854176982db156971d19466a (diff)
downloadsamba-ce31503de55ffeaa6e694b9177890943442e41c0.tar.gz
samba-ce31503de55ffeaa6e694b9177890943442e41c0.tar.bz2
samba-ce31503de55ffeaa6e694b9177890943442e41c0.zip
command-line completion for new svcinfo command
(This used to be commit 5ca07721ba1f71d831ca89851e9fc23a41f40194)
-rw-r--r--source3/rpcclient/cmd_svcctl.c9
-rw-r--r--source3/rpcclient/rpcclient.c46
2 files changed, 48 insertions, 7 deletions
diff --git a/source3/rpcclient/cmd_svcctl.c b/source3/rpcclient/cmd_svcctl.c
index 1693823ea6..6af58035c5 100644
--- a/source3/rpcclient/cmd_svcctl.c
+++ b/source3/rpcclient/cmd_svcctl.c
@@ -187,12 +187,6 @@ BOOL msrpc_svc_enum(struct client_info *info,
} while (res1 && dos_error == ERRmoredata);
- if (res1 && dos_error == 0x0 && (*num_svcs) > 0 && (*svcs) != NULL)
- {
- report(out_hnd,"Services\n");
- report(out_hnd,"--------\n");
- }
-
for (i = 0; i < (*num_svcs) && (*svcs) != NULL && res1; i++)
{
fstring svc_name;
@@ -234,6 +228,9 @@ void cmd_svc_enum(struct client_info *info)
request_info = strequal(tmp, "-i");
}
+ report(out_hnd,"Services\n");
+ report(out_hnd,"--------\n");
+
msrpc_svc_enum(info, &svcs, &num_svcs,
request_info ? NULL : svc_display_svc_info,
request_info ? svc_display_query_svc_cfg : NULL);
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 44adf4417b..50f77b35a1 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -103,6 +103,7 @@ static void rpcclient_stop(void)
#define COMPL_REGKEY 1
#define COMPL_SAMUSR 3
#define COMPL_SAMGRP 4
+#define COMPL_SVCLST 5
/****************************************************************************
This defines the commands supported by this client
@@ -142,7 +143,7 @@ commands[] =
"svcinfo",
cmd_svc_info,
"<service> Service Information",
- {COMPL_NONE, COMPL_NONE}
+ {COMPL_SVCLST, COMPL_NONE}
},
/*
@@ -954,6 +955,46 @@ static char *complete_samenum_grp(char *text, int state)
return NULL;
}
+static char *complete_svcenum(char *text, int state)
+{
+ static uint32 i = 0;
+ static uint32 num_svcs = 0;
+ static ENUM_SRVC_STATUS *svc = NULL;
+
+ if (state == 0)
+ {
+ free(svc);
+ svc = NULL;
+ num_svcs = 0;
+
+ /* Iterate all users */
+ if (msrpc_svc_enum(&cli_info, &svc, &num_svcs,
+ NULL, NULL) == 0)
+ {
+ return NULL;
+ }
+
+ i = 0;
+ }
+
+ for (; i < num_svcs; i++)
+ {
+ fstring svc_name;
+ unistr_to_ascii(svc_name, svc[i].uni_srvc_name.buffer,
+ sizeof(svc_name)-1);
+
+ if (text == NULL || text[0] == 0 ||
+ strnequal(text, svc_name, strlen(text)))
+ {
+ char *name = strdup(svc_name);
+ i++;
+ return name;
+ }
+ }
+
+ return NULL;
+}
+
/* Complete an rpcclient command */
static char *complete_cmd(char *text, int state)
@@ -1051,6 +1092,9 @@ static char **completion_fn(char *text, int start, int end)
case COMPL_SAMUSR:
return completion_matches(text, complete_samenum_usr);
+ case COMPL_SVCLST:
+ return completion_matches(text, complete_svcenum);
+
case COMPL_REGKEY:
return completion_matches(text, complete_regenum);