s3-spoolss: use snum_is_shared_printer (allows to make code a little easier to
authorGünther Deschner <gd@samba.org>
Tue, 10 Mar 2009 23:28:18 +0000 (00:28 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 13 Mar 2009 08:25:24 +0000 (09:25 +0100)
read).

Guenther

source3/rpc_server/srv_spoolss_nt.c

index f323ca95995ba07f0ccd9d126f43db74ccedac95..78d3bd6bbede762dda8d4c8195333fcc3c4d9272 100644 (file)
@@ -4616,38 +4616,40 @@ static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
        *count = 0;
 
        for (snum=0; snum<n_services; snum++) {
-               if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum) ) {
 
-                       NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
-                       struct spoolss_PrinterInfo1 info1;
+               NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
+               struct spoolss_PrinterInfo1 info1;
 
-                       DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
-
-                       result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
-                       if (!W_ERROR_IS_OK(result)) {
-                               continue;
-                       }
+               if (!snum_is_shared_printer(snum)) {
+                       continue;
+               }
 
-                       result = construct_printer_info1(info, ntprinter, flags, &info1, snum);
-                       free_a_printer(&ntprinter,2);
-                       if (!W_ERROR_IS_OK(result)) {
-                               continue;
-                       }
+               DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
 
-                       info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
-                                                   union spoolss_PrinterInfo,
-                                                   *count + 1);
-                       if (!info) {
-                               DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
-                               result = WERR_NOMEM;
-                               goto out;
-                       }
+               result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
+               if (!W_ERROR_IS_OK(result)) {
+                       continue;
+               }
 
-                       DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *count));
+               result = construct_printer_info1(info, ntprinter, flags, &info1, snum);
+               free_a_printer(&ntprinter,2);
+               if (!W_ERROR_IS_OK(result)) {
+                       continue;
+               }
 
-                       info[*count].info1 = info1;
-                       (*count)++;
+               info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+                                           union spoolss_PrinterInfo,
+                                           *count + 1);
+               if (!info) {
+                       DEBUG(2,("enum_all_printers_info_1: failed to enlarge printers buffer!\n"));
+                       result = WERR_NOMEM;
+                       goto out;
                }
+
+               DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_1\n", *count));
+
+               info[*count].info1 = info1;
+               (*count)++;
        }
 
  out:
@@ -4813,39 +4815,41 @@ static WERROR enum_all_printers_info_2(TALLOC_CTX *mem_ctx,
        *count = 0;
 
        for (snum=0; snum<n_services; snum++) {
-               if (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum)) {
 
-                       struct spoolss_PrinterInfo2 info2;
-                       NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
+               struct spoolss_PrinterInfo2 info2;
+               NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
 
-                       DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
+               if (!snum_is_shared_printer(snum)) {
+                       continue;
+               }
 
-                       result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
-                       if (!W_ERROR_IS_OK(result)) {
-                               continue;
-                       }
+               DEBUG(4,("Found a printer in smb.conf: %s[%x]\n", lp_servicename(snum), snum));
 
-                       result = construct_printer_info2(info, ntprinter, &info2, snum);
-                       free_a_printer(&ntprinter, 2);
-                       if (!W_ERROR_IS_OK(result)) {
-                               continue;
-                       }
+               result = get_a_printer(NULL, &ntprinter, 2, lp_const_servicename(snum));
+               if (!W_ERROR_IS_OK(result)) {
+                       continue;
+               }
 
-                       info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
-                                                   union spoolss_PrinterInfo,
-                                                   *count + 1);
-                       if (!info) {
-                               DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
-                               result = WERR_NOMEM;
-                               goto out;
-                       }
+               result = construct_printer_info2(info, ntprinter, &info2, snum);
+               free_a_printer(&ntprinter, 2);
+               if (!W_ERROR_IS_OK(result)) {
+                       continue;
+               }
 
-                       DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *count + 1));
+               info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
+                                           union spoolss_PrinterInfo,
+                                           *count + 1);
+               if (!info) {
+                       DEBUG(2,("enum_all_printers_info_2: failed to enlarge printers buffer!\n"));
+                       result = WERR_NOMEM;
+                       goto out;
+               }
 
-                       info[*count].info2 = info2;
+               DEBUG(4,("ReAlloced memory for [%d] PRINTER_INFO_2\n", *count + 1));
 
-                       (*count)++;
-               }
+               info[*count].info2 = info2;
+
+               (*count)++;
        }
 
  out: