diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-10-06 19:32:52 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:15:18 -0500 |
commit | 9d8d4f24b1c31ecfd9284cff9de20760c78e3d29 (patch) | |
tree | b24af5427ee56d810d7d5f1bbd277920537a45a0 | |
parent | 80b4e7ae7da2c91b776bb1e0d36c08c3145dc0c8 (diff) | |
download | samba-9d8d4f24b1c31ecfd9284cff9de20760c78e3d29.tar.gz samba-9d8d4f24b1c31ecfd9284cff9de20760c78e3d29.tar.bz2 samba-9d8d4f24b1c31ecfd9284cff9de20760c78e3d29.zip |
r19156: Make enumprinters use the share iterators.
Volker
(This used to be commit 9b1759617ce7841a78d9f792254a9e4fa814858f)
-rw-r--r-- | source3/rpc_server/srv_spoolss_nt.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 32cd5766af..b6af6b0b80 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -4342,29 +4342,27 @@ static BOOL construct_printer_info_7(Printer_entry *print_hnd, static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - int snum; int i; - int n_services=lp_numservices(); + struct share_iterator *shares; + struct share_params *printer; PRINTER_INFO_1 *printers=NULL; WERROR result = WERR_OK; DEBUG(4,("enum_all_printers_info_1\n")); - for (snum=0; snum<n_services; snum++) { - PRINTER_INFO_1 current_prt; - struct share_params params; - params.service = snum; + if (!(shares = share_list_all(NULL))) { + DEBUG(5, ("Could not list printers\n")); + return WERR_ACCESS_DENIED; + } - if (!lp_browseable(snum) || !lp_snum_ok(snum) || - !lp_print_ok(snum) ) { - continue; - } + while ((printer = next_printer(shares)) != NULL) { + PRINTER_INFO_1 current_prt; - DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", - lp_servicename(snum), snum)); + DEBUG(4,("Found a printer in smb.conf: %s\n", + lp_servicename(printer->service))); if (!construct_printer_info_1(NULL, flags, ¤t_prt, - ¶ms)) { + printer)) { continue; } @@ -4373,6 +4371,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 DEBUG(2,("enum_all_printers_info_1: failed to enlarge " "printers buffer!\n")); *returned=0; + TALLOC_FREE(shares); return WERR_NOMEM; } DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", @@ -4381,6 +4380,7 @@ static WERROR enum_all_printers_info_1(uint32 flags, RPC_BUFFER *buffer, uint32 memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_1)); (*returned)++; + TALLOC_FREE(printer); } /* check the required size. */ @@ -4405,6 +4405,7 @@ out: /* clear memory */ SAFE_FREE(printers); + TALLOC_FREE(shares); if ( !W_ERROR_IS_OK(result) ) *returned = 0; @@ -4542,27 +4543,27 @@ static WERROR enum_all_printers_info_1_network(fstring name, RPC_BUFFER *buffer, static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { - int snum; int i; - int n_services=lp_numservices(); + struct share_iterator *shares; + struct share_params *printer; PRINTER_INFO_2 *printers=NULL; WERROR result = WERR_OK; *returned = 0; - for (snum=0; snum<n_services; snum++) { + if (!(shares = share_list_all(NULL))) { + DEBUG(5, ("Could not list printers\n")); + return WERR_ACCESS_DENIED; + } + + while ((printer = next_printer(shares)) != NULL) { PRINTER_INFO_2 current_prt; - struct share_params params; - params.service = snum; - if (!lp_browseable(snum) || !lp_snum_ok(snum) || - !lp_print_ok(snum) ) { - continue; - } - DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", - lp_servicename(snum), snum)); + + DEBUG(4,("Found a printer in smb.conf: %s\n", + lp_servicename(printer->service))); if (!construct_printer_info_2(NULL, ¤t_prt, - ¶ms)) { + printer)) { continue; } if ( !(printers=SMB_REALLOC_ARRAY(printers, PRINTER_INFO_2, @@ -4570,6 +4571,7 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 DEBUG(2,("enum_all_printers_info_2: failed to enlarge " "printers buffer!\n")); *returned = 0; + TALLOC_FREE(shares); return WERR_NOMEM; } @@ -4579,6 +4581,7 @@ static WERROR enum_all_printers_info_2(RPC_BUFFER *buffer, uint32 offered, uint3 memcpy(&printers[*returned], ¤t_prt, sizeof(PRINTER_INFO_2)); (*returned)++; + TALLOC_FREE(printer); } /* check the required size. */ @@ -4606,6 +4609,7 @@ out: free_devmode(printers[i].devmode); SAFE_FREE(printers); + TALLOC_FREE(shares); if ( !W_ERROR_IS_OK(result) ) *returned = 0; |