summaryrefslogtreecommitdiff
path: root/source3/rpcclient/rpcclient.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-06 21:08:35 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-06 21:08:35 +0000
commit514be1cf738e913423488b9550522e3991d11360 (patch)
tree708072e47b3951b62dfc9df7affe1f8ba048caf3 /source3/rpcclient/rpcclient.c
parent4dbd1c135ca286f59a5f692abd51a0c78f4cb6a0 (diff)
downloadsamba-514be1cf738e913423488b9550522e3991d11360.tar.gz
samba-514be1cf738e913423488b9550522e3991d11360.tar.bz2
samba-514be1cf738e913423488b9550522e3991d11360.zip
added command-completion printer enum code.
(This used to be commit 6947f8fac7d6d643a265fdcb56b2a390b9a9a1c0)
Diffstat (limited to 'source3/rpcclient/rpcclient.c')
-rw-r--r--source3/rpcclient/rpcclient.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 2231824b95..e9ddbd3f31 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -105,6 +105,7 @@ static void rpcclient_stop(void)
#define COMPL_SAMGRP 4
#define COMPL_SAMALS 5
#define COMPL_SVCLST 6
+#define COMPL_PRTLST 7
/****************************************************************************
This defines the commands supported by this client
@@ -245,7 +246,7 @@ commands[] =
"spoolopen",
cmd_spoolss_open_printer_ex,
"<printer name> Spool Printer Open Test",
- {COMPL_NONE, COMPL_NONE}
+ {COMPL_PRTLST, COMPL_NONE}
},
/*
* server
@@ -1086,6 +1087,47 @@ static char *complete_svcenum(char *text, int state)
return NULL;
}
+static char *complete_printersenum(char *text, int state)
+{
+ static uint32 i = 0;
+ static uint32 num = 0;
+ static PRINTER_INFO_1 **ctr = NULL;
+
+ if (state == 0)
+ {
+ free_print1_array(num, ctr);
+ ctr = NULL;
+ num = 0;
+
+ /* Iterate all users */
+ if (!msrpc_spoolss_enum_printers(smb_cli, 1, &num,
+ (void***)&ctr,
+ NULL))
+ {
+ return NULL;
+ }
+
+ i = 0;
+ }
+
+ for (; i < num; i++)
+ {
+ fstring name;
+ unistr_to_ascii(name, ctr[i]->name.buffer,
+ sizeof(name)-1);
+
+ if (text == NULL || text[0] == 0 ||
+ strnequal(text, name, strlen(text)))
+ {
+ char *copy = strdup(name);
+ i++;
+ return copy;
+ }
+ }
+
+ return NULL;
+}
+
/* Complete an rpcclient command */
static char *complete_cmd(char *text, int state)
@@ -1189,6 +1231,9 @@ static char **completion_fn(char *text, int start, int end)
case COMPL_SVCLST:
return completion_matches(text, complete_svcenum);
+ case COMPL_PRTLST:
+ return completion_matches(text, complete_printersenum);
+
case COMPL_REGKEY:
return completion_matches(text, complete_regenum);