Skip to content

Commit

Permalink
s3-rpcclient: use rpccli_spoolss_enumprinterdataex wrapper.
Browse files Browse the repository at this point in the history
Guenther
  • Loading branch information
gd committed Mar 18, 2009
1 parent ab85fc7 commit 8c3ef2d
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions source3/rpcclient/cmd_spoolss.c
Original file line number Diff line number Diff line change
Expand Up @@ -2545,17 +2545,15 @@ static WERROR cmd_spoolss_enum_data_ex( struct rpc_pipe_client *cli,
WERROR result;
uint32 i;
const char *printername;
const char *keyname = NULL;
POLICY_HND hnd;
REGVAL_CTR *ctr = NULL;
uint32_t count;
struct spoolss_PrinterEnumValues *info;

if (argc != 3) {
printf("Usage: %s printername <keyname>\n", argv[0]);
return WERR_OK;
}

keyname = argv[2];

/* Open printer handle */

RPCCLIENT_PRINTERNAME(printername, cli, argv[1]);
Expand All @@ -2564,28 +2562,32 @@ static WERROR cmd_spoolss_enum_data_ex( 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 subkeys */

if ( !(ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) )
return WERR_NOMEM;

result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx, &hnd, keyname, ctr);

if (!W_ERROR_IS_OK(result))
result = rpccli_spoolss_enumprinterdataex(cli, mem_ctx,
&hnd,
argv[2],
0,
&count,
&info);
if (!W_ERROR_IS_OK(result)) {
goto done;

for (i=0; i < ctr->num_values; i++) {
display_reg_value(*(ctr->values[i]));
}

TALLOC_FREE( ctr );
for (i=0; i < count; i++) {
display_printer_data(info[i].value_name,
info[i].type,
info[i].data);
}

done:
if (is_valid_policy_hnd(&hnd))
done:
if (is_valid_policy_hnd(&hnd)) {
rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
}

return result;
}
Expand Down

0 comments on commit 8c3ef2d

Please sign in to comment.