/*
- * "$Id: classes.c 177 2006-06-21 00:20:03Z jlovell $"
+ * "$Id: classes.c 6649 2007-07-11 21:46:42Z mike $"
*
* Printer class routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 1997-2006 by Easy Software Products, all rights reserved.
+ * 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:
*
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_DEBUG, "Loading class %s...", value);
- p = cupsdAddClass(value);
+ /*
+ * Since prior classes may have implicitly defined this class,
+ * see if it already exists...
+ */
+
+ if ((p = cupsdFindDest(value)) != NULL)
+ {
+ p->type = CUPS_PRINTER_CLASS;
+ cupsdSetStringf(&p->uri, "ipp://%s:%d/classes/%s", ServerName,
+ LocalPort, value);
+ cupsdSetString(&p->error_policy, "retry-job");
+ }
+ else
+ p = cupsdAddClass(value);
+
p->accepting = 1;
p->state = IPP_PRINTER_IDLE;
"Syntax error on line %d of classes.conf.", linenum);
return;
}
+ else if (!strcasecmp(line, "AuthInfoRequired"))
+ {
+ if (!cupsdSetAuthInfoRequired(p, value, NULL))
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "Bad AuthInfoRequired on line %d of classes.conf.",
+ linenum);
+ }
else if (!strcasecmp(line, "Info"))
{
if (value)
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,
time_t curtime; /* Current time */
struct tm *curdate; /* Current date */
cups_option_t *option; /* Current option */
+ const char *ptr; /* Pointer into info/location */
/*
else
cupsFilePrintf(fp, "<Class %s>\n", pclass->name);
+ if (pclass->num_auth_info_required > 0)
+ {
+ cupsFilePrintf(fp, "AuthInfoRequired %s", pclass->auth_info_required[0]);
+ for (i = 1; i < pclass->num_auth_info_required; i ++)
+ cupsFilePrintf(fp, ",%s", pclass->auth_info_required[i]);
+ cupsFilePutChar(fp, '\n');
+ }
+
if (pclass->info)
- cupsFilePrintf(fp, "Info %s\n", pclass->info);
+ {
+ if ((ptr = strchr(pclass->info, '#')) != NULL)
+ {
+ /*
+ * Need to quote the first # in the info string...
+ */
+
+ cupsFilePuts(fp, "Info ");
+ cupsFileWrite(fp, pclass->info, ptr - pclass->info);
+ cupsFilePutChar(fp, '\\');
+ cupsFilePuts(fp, ptr);
+ cupsFilePutChar(fp, '\n');
+ }
+ else
+ cupsFilePrintf(fp, "Info %s\n", pclass->info);
+ }
if (pclass->location)
- cupsFilePrintf(fp, "Location %s\n", pclass->location);
+ {
+ if ((ptr = strchr(pclass->info, '#')) != NULL)
+ {
+ /*
+ * Need to quote the first # in the location string...
+ */
+
+ cupsFilePuts(fp, "Location ");
+ cupsFileWrite(fp, pclass->location, ptr - pclass->location);
+ cupsFilePutChar(fp, '\\');
+ cupsFilePuts(fp, ptr);
+ cupsFilePutChar(fp, '\n');
+ }
+ else
+ cupsFilePrintf(fp, "Location %s\n", pclass->location);
+ }
if (pclass->state == IPP_PRINTER_STOPPED)
{
/*
- * End of "$Id: classes.c 177 2006-06-21 00:20:03Z jlovell $".
+ * End of "$Id: classes.c 6649 2007-07-11 21:46:42Z mike $".
*/