]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add support for implicit classes of regular classes.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 24 Jan 2003 17:55:06 +0000 (17:55 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Fri, 24 Jan 2003 17:55:06 +0000 (17:55 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@3140 7a7537e8-13f0-0310-91df-b6672ffda945

CHANGES.txt
scheduler/classes.c
scheduler/dirsvc.c
scheduler/printers.c
scheduler/printers.h

index d07a4b381eb19917f5ab15f7a5705bdeaafe66c5..18e93abf3f27da19b05ee116efd0f7cfd8e8510c 100644 (file)
@@ -3,6 +3,8 @@ CHANGES.txt - 01/24/2003
 
 CHANGES IN CUPS V1.1.19
 
+       - Implicit classes are now created from identical
+         printer classes on the network.
        - The lp command now supports a "-H restart" option to
          restart previously printed jobs.  This functionality
          only works if you have enabled the PreserveJobFiles
index e295c74b4b25d54614ca1f3c572dcc86743758b5..4f961588874bd59d300e7ead871db705fafdc350 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: classes.c,v 1.44 2002/12/17 19:00:14 swdev Exp $"
+ * "$Id: classes.c,v 1.45 2003/01/24 17:55:05 mike Exp $"
  *
  *   Printer class routines for the Common UNIX Printing System (CUPS).
  *
@@ -301,19 +301,15 @@ printer_t *                       /* O - Matching class or NULL */
 FindClass(const char *name)    /* I - Name of class */
 {
   printer_t    *c;             /* Current class/printer */
+  int          diff;           /* Difference */
 
 
   for (c = Printers; c != NULL; c = c->next)
-    switch (strcasecmp(name, c->name))
-    {
-      case 0 : /* name == c->name */
-          if (c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
-           return (c);
-      case 1 : /* name > c->name */
-          break;
-      case -1 : /* name < c->name */
-          return (NULL);
-    }
+    if ((diff = strcasecmp(name, c->name)) == 0 &&
+        (c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)))
+      return (c);                              /* name == c->name */
+    else if (diff < 0)                         /* name < c->name */
+      return (NULL);
 
   return (NULL);
 }
@@ -691,5 +687,5 @@ SaveAllClasses(void)
 
 
 /*
- * End of "$Id: classes.c,v 1.44 2002/12/17 19:00:14 swdev Exp $".
+ * End of "$Id: classes.c,v 1.45 2003/01/24 17:55:05 mike Exp $".
  */
index e6f92b5c110755dc4b118dc23194e41e81988a60..373808efdfc75a7083a186c181585ebe031ebc20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: dirsvc.c,v 1.104 2003/01/15 04:15:49 mike Exp $"
+ * "$Id: dirsvc.c,v 1.105 2003/01/24 17:55:05 mike Exp $"
  *
  *   Directory services routines for the Common UNIX Printing System (CUPS).
  *
@@ -370,10 +370,10 @@ ProcessBrowseData(const char   *uri,      /* I - URI of printer/class */
       next = p->next;
 
      /*
-      * Skip classes...
+      * Skip implicit classes...
       */
 
-      if (p->type & (CUPS_PRINTER_IMPLICIT | CUPS_PRINTER_CLASS))
+      if (p->type & CUPS_PRINTER_IMPLICIT)
       {
         len = 0;
         continue;
@@ -393,7 +393,7 @@ ProcessBrowseData(const char   *uri,        /* I - URI of printer/class */
        * we have a class, and if this printer is a member...
        */
 
-        if ((pclass = FindPrinter(name)) == NULL)
+        if ((pclass = FindDest(name)) == NULL)
        {
         /*
          * Need to add the class...
@@ -447,7 +447,7 @@ ProcessBrowseData(const char   *uri,        /* I - URI of printer/class */
        name[len] = '\0';
        offset    = 0;
 
-       if ((pclass = FindPrinter(name)) != NULL &&
+       if ((pclass = FindDest(name)) != NULL &&
            !(pclass->type & CUPS_PRINTER_IMPLICIT))
        {
         /*
@@ -456,7 +456,7 @@ ProcessBrowseData(const char   *uri,        /* I - URI of printer/class */
          * the "ImplicitAnyClasses"...
          */
 
-          if (ImplicitAnyClasses)
+          if (ImplicitAnyClasses && len < (sizeof(name) - 4))
          {
           /*
            * Add "Any" to the class name...
@@ -1855,5 +1855,5 @@ UpdateSLPBrowse(void)
 
 
 /*
- * End of "$Id: dirsvc.c,v 1.104 2003/01/15 04:15:49 mike Exp $".
+ * End of "$Id: dirsvc.c,v 1.105 2003/01/24 17:55:05 mike Exp $".
  */
index 56b14bfddc254627ca4c212907ba5f4a131e372d..76e7a4fead93c4be37694a579b25285a2532fbb6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.c,v 1.134 2002/12/17 19:00:18 swdev Exp $"
+ * "$Id: printers.c,v 1.135 2003/01/24 17:55:06 mike Exp $"
  *
  *   Printer routines for the Common UNIX Printing System (CUPS).
  *
@@ -403,6 +403,27 @@ DeletePrinterFilters(printer_t *p) /* I - Printer to remove from */
 }
 
 
+/*
+ * 'FindDest()' - Find a destination in the list.
+ */
+
+printer_t *                    /* O - Destination in list */
+FindDest(const char *name)     /* I - Name of printer or class to find */
+{
+  printer_t    *p;             /* Current destination */
+  int          diff;           /* Difference */
+
+
+  for (p = Printers; p != NULL; p = p->next)
+    if ((diff = strcasecmp(name, p->name)) == 0)/* name == p->name */
+      return (p);
+    else if (diff < 0)                         /* name < p->name */
+      return (NULL);
+
+  return (NULL);
+}
+
+
 /*
  * 'FindPrinter()' - Find a printer in the list.
  */
@@ -411,19 +432,15 @@ printer_t *                       /* O - Printer in list */
 FindPrinter(const char *name)  /* I - Name of printer to find */
 {
   printer_t    *p;             /* Current printer */
+  int          diff;           /* Difference */
 
 
   for (p = Printers; p != NULL; p = p->next)
-    switch (strcasecmp(name, p->name))
-    {
-      case 0 : /* name == p->name */
-          if (!(p->type & CUPS_PRINTER_CLASS))
-           return (p);
-      case 1 : /* name > p->name */
-          break;
-      case -1 : /* name < p->name */
-          return (NULL);
-    }
+    if ((diff = strcasecmp(name, p->name)) == 0 &&
+        !(p->type & CUPS_PRINTER_CLASS))       /* name == p->name */
+      return (p);
+    else if (diff < 0)                         /* name < p->name */
+      return (NULL);
 
   return (NULL);
 }
@@ -2101,5 +2118,5 @@ write_irix_state(printer_t *p)    /* I - Printer to update */
 
 
 /*
- * End of "$Id: printers.c,v 1.134 2002/12/17 19:00:18 swdev Exp $".
+ * End of "$Id: printers.c,v 1.135 2003/01/24 17:55:06 mike Exp $".
  */
index 45a394dcc4e587dbde14207ffb3b466342ba6465..dc38dbb4fd2db0c31eaeefe09f04ec05fcf7e09e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: printers.h,v 1.27 2002/12/17 19:00:18 swdev Exp $"
+ * "$Id: printers.h,v 1.28 2003/01/24 17:55:06 mike Exp $"
  *
  *   Printer definitions for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -95,6 +95,7 @@ extern quota_t                *AddQuota(printer_t *p, const char *username);
 extern void            DeleteAllPrinters(void);
 extern void            DeletePrinter(printer_t *p);
 extern void            DeletePrinterFilters(printer_t *p);
+extern printer_t       *FindDest(const char *name);
 extern printer_t       *FindPrinter(const char *name);
 extern quota_t         *FindQuota(printer_t *p, const char *username);
 extern void            FreePrinterUsers(printer_t *p);
@@ -115,5 +116,5 @@ extern void         WritePrintcap(void);
 
 
 /*
- * End of "$Id: printers.h,v 1.27 2002/12/17 19:00:18 swdev Exp $".
+ * End of "$Id: printers.h,v 1.28 2003/01/24 17:55:06 mike Exp $".
  */