From 2f25e5118fde9be14275e9ffb1edb210d231dac3 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 6 Jan 2002 09:03:48 +0000 Subject: Converted enumprinters and enumports cmd functions to use WERROR values returned from cli functions. They are converted to NTSTATUS codes using the error map functions. Do buffer size loop checks by setting offered = 0 and using the return value of needed in the next call. (This used to be commit 4efbdda3fcfd1fad2f2b8909d250735382497836) --- source3/rpcclient/cmd_spoolss.c | 71 ++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 32 deletions(-) (limited to 'source3') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 7daa336cc67..a945e117225 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -298,11 +298,10 @@ static NTSTATUS cmd_spoolss_enum_printers(struct cli_state *cli, TALLOC_CTX *mem_ctx, int argc, char **argv) { - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + WERROR result; uint32 info_level = 1; PRINTER_INFO_CTR ctr; - int returned; - uint32 i = 0; + uint32 i = 0, num_printers, needed; if (argc > 2) { @@ -316,35 +315,38 @@ static NTSTATUS cmd_spoolss_enum_printers(struct cli_state *cli, /* Enumerate printers -- Should we enumerate types other than PRINTER_ENUM_LOCAL? Maybe accept as a parameter? --jerry */ + ZERO_STRUCT(ctr); - result = cli_spoolss_enum_printers(cli, mem_ctx, PRINTER_ENUM_LOCAL, - info_level, &returned, &ctr); - if (NT_STATUS_IS_OK(result)) - { - if (!returned) + result = cli_spoolss_enum_printers( + cli, mem_ctx, 0, &needed, PRINTER_ENUM_LOCAL, + info_level, &num_printers, &ctr); + + if (W_ERROR_V(result) == ERRinsufficientbuffer) + result = cli_spoolss_enum_printers( + cli, mem_ctx, needed, NULL, PRINTER_ENUM_LOCAL, + info_level, &num_printers, &ctr); + + if (W_ERROR_IS_OK(result)) { + if (!num_printers) printf ("No Printers printers returned.\n"); switch(info_level) { case 0: - for (i=0; i