]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r4083: consolidate printer searches to use find_service rather than for loops
authorGerald Carter <jerry@samba.org>
Mon, 6 Dec 2004 19:25:25 +0000 (19:25 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:53:31 +0000 (10:53 -0500)
source/rpc_server/srv_spoolss_nt.c
source/smbd/lanman.c

index fad5555cea164c627065d2aee72ca163c7d1d2b4..aba7e6c22fd380fecae0920b5dea17bec790a49f 100644 (file)
@@ -512,24 +512,14 @@ static BOOL set_printer_hnd_name(Printer_entry *Printer, char *handlename)
 
        /* Search all sharenames first as this is easier than pulling 
           the printer_info_2 off of disk */
-
-       for (snum=0; !found && snum<n_services; snum++) {
-
-               if ( !(lp_snum_ok(snum) && lp_print_ok(snum) ) )
-                       continue;
-               
-               /* ------ sharename ------ */
-
-               fstrcpy(sname, lp_servicename(snum));
-
-               DEBUGADD(10, ("share: %s\n",sname));
-               
-               if ( strequal(sname, aprinter) ) {
-                       found = True;
-               }
+       
+       snum = find_service(aprinter);
+       
+       if ( lp_snum_ok(snum) && lp_print_ok(snum) ) {
+               found = True;
+               fstrcpy( sname, aprinter );
        }
 
-       
        /* do another loop to look for printernames */
        
        for (snum=0; !found && snum<n_services; snum++) {
index 5f4c0cec52cf48bebedfee0fe5f1429f78c35513..7d5e0f5ad2a76771d1c90c4b27068b6652f705eb 100644 (file)
@@ -760,18 +760,10 @@ static BOOL api_DosPrintQGetInfo(connection_struct *conn,
                return(True);
        }
  
-       snum = lp_servicenumber(QueueName);
-       if (snum < 0 && pcap_printername_ok(QueueName,NULL)) {
-               int pnum = lp_servicenumber(PRINTERS_NAME);
-               if (pnum >= 0) {
-                       lp_add_printer(QueueName,pnum);
-                       snum = lp_servicenumber(QueueName);
-               }
-       }
-  
-       if (snum < 0 || !VALID_SNUM(snum))
-               return(False);
-
+       snum = find_service(QueueName);
+       if ( !(lp_snum_ok(snum) && lp_print_ok(snum)) )
+               return False;
+               
        if (uLevel==52) {
                count = get_printerdrivernumber(snum);
                DEBUG(3,("api_DosPrintQGetInfo: Driver files count: %d\n",count));
@@ -3048,20 +3040,18 @@ static BOOL api_WPrintJobEnumerate(connection_struct *conn,uint16 vuid, char *pa
   DEBUG(3,("WPrintJobEnumerate uLevel=%d name=%s\n",uLevel,name));
 
   /* check it's a supported variant */
-  if (strcmp(str1,"zWrLeh") != 0) return False;
-  if (uLevel > 2) return False;        /* defined only for uLevel 0,1,2 */
-  if (!check_printjob_info(&desc,uLevel,str2)) return False;
-
-  snum = lp_servicenumber(name);
-  if (snum < 0 && pcap_printername_ok(name,NULL)) {
-    int pnum = lp_servicenumber(PRINTERS_NAME);
-    if (pnum >= 0) {
-      lp_add_printer(name,pnum);
-      snum = lp_servicenumber(name);
-    }
-  }
+  if (strcmp(str1,"zWrLeh") != 0) 
+    return False;
+    
+  if (uLevel > 2) 
+    return False;      /* defined only for uLevel 0,1,2 */
+    
+  if (!check_printjob_info(&desc,uLevel,str2)) 
+    return False;
 
-  if (snum < 0 || !VALID_SNUM(snum)) return(False);
+  snum = find_service(name);
+  if ( !(lp_snum_ok(snum) && lp_print_ok(snum)) )
+    return False;
 
   count = print_queue_status(snum,&queue,&status);
   if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt);
@@ -3164,16 +3154,8 @@ static BOOL api_WPrintDestGetInfo(connection_struct *conn,uint16 vuid, char *par
   if (strcmp(str1,"zWrLh") != 0) return False;
   if (!check_printdest_info(&desc,uLevel,str2)) return False;
 
-  snum = lp_servicenumber(PrinterName);
-  if (snum < 0 && pcap_printername_ok(PrinterName,NULL)) {
-    int pnum = lp_servicenumber(PRINTERS_NAME);
-    if (pnum >= 0) {
-      lp_add_printer(PrinterName,pnum);
-      snum = lp_servicenumber(PrinterName);
-    }
-  }
-
-  if (snum < 0) {
+  snum = find_service(PrinterName);
+  if ( !(lp_snum_ok(snum) && lp_print_ok(snum)) ) {
     *rdata_len = 0;
     desc.errcode = NERR_DestNotFound;
     desc.neededlen = 0;