summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-03-16 15:11:04 +0100
committerGünther Deschner <gd@samba.org>2009-03-17 12:07:40 +0100
commit3e16ede0c2c73134201948e4018f6acefdca039c (patch)
treee1a2892496a0530d54c3868c6c77c0a396a2b210
parent4ea46d69bbb7651b213c5b0674f4f9fb05059acd (diff)
downloadsamba-3e16ede0c2c73134201948e4018f6acefdca039c.tar.gz
samba-3e16ede0c2c73134201948e4018f6acefdca039c.tar.bz2
samba-3e16ede0c2c73134201948e4018f6acefdca039c.zip
s3-rpcclient: use rpccli_spoolss_EnumPrinterData in enumdata command.
Guenther
-rw-r--r--source3/rpcclient/cmd_spoolss.c76
1 files changed, 58 insertions, 18 deletions
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 7a077fd460..d0fc862ea1 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -2446,14 +2446,22 @@ done:
/****************************************************************************
****************************************************************************/
-static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
- TALLOC_CTX *mem_ctx, int argc,
- const char **argv)
+static WERROR cmd_spoolss_enum_data(struct rpc_pipe_client *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
{
WERROR result;
- uint32 i=0, val_needed, data_needed;
+ NTSTATUS status;
+ uint32_t i = 0;
const char *printername;
POLICY_HND hnd;
+ uint32_t value_offered = 0;
+ const char *value_name = NULL;
+ uint32_t value_needed;
+ enum winreg_Type type;
+ uint8_t *data = NULL;
+ uint32_t data_offered = 0;
+ uint32_t data_needed;
if (argc != 2) {
printf("Usage: %s printername\n", argv[0]);
@@ -2468,28 +2476,60 @@ static WERROR cmd_spoolss_enum_data( struct rpc_pipe_client *cli,
printername,
SEC_FLAG_MAXIMUM_ALLOWED,
&hnd);
- if (!W_ERROR_IS_OK(result))
+ if (!W_ERROR_IS_OK(result)) {
goto done;
+ }
/* Enumerate data */
- result = rpccli_spoolss_enumprinterdata(cli, mem_ctx, &hnd, i, 0, 0,
- &val_needed, &data_needed,
- NULL);
- while (W_ERROR_IS_OK(result)) {
- REGISTRY_VALUE value;
- result = rpccli_spoolss_enumprinterdata(
- cli, mem_ctx, &hnd, i++, val_needed,
- data_needed, 0, 0, &value);
- if (W_ERROR_IS_OK(result))
- display_reg_value(value);
- }
- if (W_ERROR_V(result) == ERRnomoreitems)
+ status = rpccli_spoolss_EnumPrinterData(cli, mem_ctx,
+ &hnd,
+ i,
+ value_name,
+ value_offered,
+ &value_needed,
+ &type,
+ data,
+ data_offered,
+ &data_needed,
+ &result);
+
+ data_offered = data_needed;
+ value_offered = value_needed;
+ data = talloc_zero_array(mem_ctx, uint8_t, data_needed);
+ value_name = talloc_zero_array(mem_ctx, char, value_needed);
+
+ while (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(result)) {
+
+ status = rpccli_spoolss_EnumPrinterData(cli, mem_ctx,
+ &hnd,
+ i++,
+ value_name,
+ value_offered,
+ &value_needed,
+ &type,
+ data,
+ data_offered,
+ &data_needed,
+ &result);
+ if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(result)) {
+ REGISTRY_VALUE v;
+ fstrcpy(v.valuename, value_name);
+ v.type = type;
+ v.size = data_offered;
+ v.data_p = data;
+ display_reg_value(v);
+ }
+ }
+
+ if (W_ERROR_V(result) == ERRnomoreitems) {
result = W_ERROR(ERRsuccess);
+ }
done:
- if (is_valid_policy_hnd(&hnd))
+ if (is_valid_policy_hnd(&hnd)) {
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
+ }
return result;
}