/*
- * "$Id: classes.c,v 1.33 2001/03/15 19:26:22 andy Exp $"
+ * "$Id: classes.c,v 1.34 2001/03/15 20:00:57 andy Exp $"
*
* Printer class routines for the Common UNIX Printing System (CUPS).
*
}
/*
- * If there are no more printers in this class, delete the class...
+ * Recompute the printer type mask as needed...
*/
- if (c->num_printers == 0)
+ if (c->num_printers > 0)
{
- DeletePrinter(c);
- return;
- }
-
- /*
- * Recompute the printer type mask...
- */
-
- type = c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT);
- c->type = ~CUPS_PRINTER_REMOTE;
+ type = c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT);
+ c->type = ~CUPS_PRINTER_REMOTE;
- for (i = 0; i < c->num_printers; i ++)
- c->type &= c->printers[i]->type;
+ for (i = 0; i < c->num_printers; i ++)
+ c->type &= c->printers[i]->type;
- c->type |= type;
+ c->type |= type;
- /*
- * Update the IPP attributes...
- */
+ /*
+ * Update the IPP attributes...
+ */
- SetPrinterAttrs(c);
+ SetPrinterAttrs(c);
+ }
}
DeletePrinterFromClasses(printer_t *p) /* I - Printer to delete */
{
printer_t *c, /* Pointer to current class */
- *prev,
*next; /* Pointer to next class */
* from each class listed...
*/
- for (c = Printers, prev = NULL; c != NULL; prev = c, c = next)
+ for (c = Printers; c != NULL; c = next)
{
next = c->next;
if (c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
DeletePrinterFromClass(c, p);
}
+
+ /*
+ * Then clean out any empty classes...
+ */
+
+ for (c = Printers; c != NULL; c = next)
+ {
+ next = c->next;
+
+ if ((c->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)) &&
+ c->num_printers == 0)
+ DeletePrinter(c);
+ }
}
/*
- * End of "$Id: classes.c,v 1.33 2001/03/15 19:26:22 andy Exp $".
+ * End of "$Id: classes.c,v 1.34 2001/03/15 20:00:57 andy Exp $".
*/
/*
- * "$Id: printers.c,v 1.91 2001/03/15 19:26:23 andy Exp $"
+ * "$Id: printers.c,v 1.92 2001/03/15 20:00:57 andy Exp $"
*
* Printer routines for the Common UNIX Printing System (CUPS).
*
* Remove this printer from any classes...
*/
- DeletePrinterFromClasses(p);
+ if (!(p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT)))
+ DeletePrinterFromClasses(p);
/*
* Free all memory used by the printer...
/*
- * End of "$Id: printers.c,v 1.91 2001/03/15 19:26:23 andy Exp $".
+ * End of "$Id: printers.c,v 1.92 2001/03/15 20:00:57 andy Exp $".
*/