/*
- * "$Id: classes.c 6318 2007-03-06 04:36:55Z mike $"
+ * "$Id: classes.c 7608 2008-05-21 01:37:21Z mike $"
*
* Printer class routines for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* Contents:
*
c = (cupsd_printer_t *)cupsArrayNext(ImplicitPrinters))
if (c->num_printers == 0)
{
- cupsArrayRemove(ImplicitPrinters, c);
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Deleting implicit class \"%s\"...",
+ c->name);
cupsdDeletePrinter(c, 0);
}
}
return (NULL);
}
+ if (c->num_printers == 0)
+ return (NULL);
+
+ /*
+ * Make sure that the last printer is also a valid index into the printer
+ * array. If not, reset the last printer to 0...
+ */
+
+ if (c->last_printer >= c->num_printers)
+ c->last_printer = 0;
+
/*
* Loop through the printers in the class and return the first idle
* printer... We keep track of the last printer that we used so that
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "</Class>"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!p)
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
else if (!strcasecmp(line, "AuthInfoRequired"))
{
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
else if ((temp = cupsdFindPrinter(value)) == NULL)
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.",
linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "StateMessage"))
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.",
linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "Shared"))
else
{
cupsdLogMessage(CUPSD_LOG_ERROR,
- "Syntax error on line %d of printers.conf.",
+ "Syntax error on line %d of classes.conf.",
linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "JobSheets"))
valueptr ++);
if (*valueptr)
- *valueptr++ = '\0';
+ *valueptr = '\0';
cupsdSetString(&p->job_sheets[1], value);
}
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "AllowUser"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "DenyUser"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "QuotaPeriod"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "PageLimit"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "KLimit"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "OpPolicy"))
{
if (value)
- cupsdSetString(&p->op_policy, value);
+ {
+ cupsd_policy_t *pol; /* Policy */
+
+
+ if ((pol = cupsdFindPolicy(value)) != NULL)
+ {
+ cupsdSetString(&p->op_policy, value);
+ p->op_policy_ptr = pol;
+ }
+ else
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad policy \"%s\" on line %d of classes.conf",
+ value, linenum);
+ }
else
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else if (!strcasecmp(line, "ErrorPolicy"))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Syntax error on line %d of classes.conf.", linenum);
- return;
+ break;
}
}
else
cupsFilePrintf(fp, "JobSheets %s %s\n", pclass->job_sheets[0],
pclass->job_sheets[1]);
- for (i = 0; i < pclass->num_printers; i ++)
- cupsFilePrintf(fp, "Printer %s\n", pclass->printers[i]->name);
+ for (i = 0; i < pclass->num_users; i ++)
+ {
+ if ((ptr = strchr(pclass->users[i], '#')) != NULL)
+ {
+ /*
+ * Need to quote the first # in the user string...
+ */
+
+ cupsFilePrintf(fp, "%sUser ", pclass->deny_users ? "Deny" : "Allow");
+ cupsFileWrite(fp, pclass->users[i], ptr - pclass->users[i]);
+ cupsFilePutChar(fp, '\\');
+ cupsFilePuts(fp, ptr);
+ cupsFilePutChar(fp, '\n');
+ }
+ else
+ cupsFilePrintf(fp, "%sUser %s\n",
+ pclass->deny_users ? "Deny" : "Allow",
+ pclass->users[i]);
+ }
cupsFilePrintf(fp, "QuotaPeriod %d\n", pclass->quota_period);
cupsFilePrintf(fp, "PageLimit %d\n", pclass->page_limit);
/*
- * End of "$Id: classes.c 6318 2007-03-06 04:36:55Z mike $".
+ * End of "$Id: classes.c 7608 2008-05-21 01:37:21Z mike $".
*/