/*
- * "$Id: printers.c 7968 2008-09-19 23:03:01Z mike $"
+ * "$Id$"
*
* Printer routines for the CUPS scheduler.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2012 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* load_ppd() - Load a cached PPD file, updating the cache as
* needed.
* new_media_col() - Create a media-col collection value.
- * write_irix_config() - Update the config files used by the IRIX
- * desktop tools.
- * write_irix_state() - Update the status files used by IRIX printing
- * desktop tools.
* write_xml_string() - Write a string with XML escaping.
*/
#ifdef HAVE_SYS_VFS_H
# include <sys/vfs.h>
#endif /* HAVE_SYS_VFS_H */
+#ifdef __APPLE__
+# include <asl.h>
+#endif /* __APPLE__ */
/*
static void delete_printer_filters(cupsd_printer_t *p);
static void dirty_printer(cupsd_printer_t *p);
static void load_ppd(cupsd_printer_t *p);
+static void log_ipp_conformance(cupsd_printer_t *p, const char *reason);
static ipp_t *new_media_col(_pwg_size_t *size, const char *source,
const char *type);
-#ifdef __sgi
-static void write_irix_config(cupsd_printer_t *p);
-static void write_irix_state(cupsd_printer_t *p);
-#endif /* __sgi */
static void write_xml_string(cups_file_t *fp, const char *s);
"cupsdAddPrinter: Adding %s to Printers", p->name);
cupsArrayAdd(Printers, p);
- if (!ImplicitPrinters)
- ImplicitPrinters = cupsArrayNew(compare_printers, NULL);
-
/*
* Return the new printer...
*/
"multiple-document-handling",
"number-up",
"output-bin",
- "output-mode",
"orientation-requested",
"page-ranges",
+ "print-color-mode",
"print-quality",
"printer-resolution",
"sides"
"multiple-document-handling",
"number-up",
"output-bin",
- "output-mode",
"orientation-requested",
"page-ranges",
+ "print-color-mode",
"print-quality",
"printer-resolution",
"sides"
ippAddBoolean(CommonData, IPP_TAG_PRINTER, "job-ids-supported", 1);
/* job-k-octets-supported */
- ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
- "job-k-octets-supported", k_supported);
+ ippAddRange(CommonData, IPP_TAG_PRINTER, "job-k-octets-supported", 0,
+ k_supported);
/* job-priority-supported */
ippAddInteger(CommonData, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
/* operations-supported */
ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_ENUM,
- "operations-supported",
- sizeof(ops) / sizeof(ops[0]) + JobFiles - 1, ops);
+ "operations-supported", sizeof(ops) / sizeof(ops[0]), ops);
/* orientation-requested-supported */
ippAddIntegers(CommonData, IPP_TAG_PRINTER, IPP_TAG_ENUM,
{
int i, /* Looping var */
changed = 0; /* Class changed? */
-#ifdef __sgi
- char filename[1024]; /* Interface script filename */
-#endif /* __sgi */
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdDeletePrinter(p=%p(%s), update=%d)",
update ? "Job stopped due to printer being deleted." :
"Job stopped.");
- /*
- * If this printer is the next for browsing, point to the next one...
- */
-
- if (p == BrowseNext)
- {
- cupsArrayFind(Printers, p);
- BrowseNext = (cupsd_printer_t *)cupsArrayNext(Printers);
- }
-
/*
* Remove the printer from the list...
*/
"cupsdDeletePrinter: Removing %s from Printers", p->name);
cupsArrayRemove(Printers, p);
- if (p->type & CUPS_PRINTER_IMPLICIT)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdDeletePrinter: Removing %s from ImplicitPrinters",
- p->name);
- cupsArrayRemove(ImplicitPrinters, p);
- }
-
- /*
- * Remove the dummy interface/icon/option files under IRIX...
- */
-
-#ifdef __sgi
- snprintf(filename, sizeof(filename), "/var/spool/lp/interface/%s", p->name);
- unlink(filename);
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/gui_interface/ELF/%s.gui",
- p->name);
- unlink(filename);
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/activeicons/%s", p->name);
- unlink(filename);
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.config", p->name);
- unlink(filename);
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.status", p->name);
- unlink(filename);
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/member/%s", p->name);
- unlink(filename);
-#endif /* __sgi */
-
/*
* If p is the default printer, assign a different one...
*/
if (p == DefaultPrinter)
- {
DefaultPrinter = NULL;
- if (UseNetworkDefault)
- {
- /*
- * Find the first network default printer and use it...
- */
-
- cupsd_printer_t *dp; /* New default printer */
-
-
- for (dp = (cupsd_printer_t *)cupsArrayFirst(Printers);
- dp;
- dp = (cupsd_printer_t *)cupsArrayNext(Printers))
- if (dp != p && (dp->type & CUPS_PRINTER_DEFAULT))
- {
- DefaultPrinter = dp;
- break;
- }
- }
- }
-
/*
* Remove this printer from any classes...
*/
- if (!(p->type & CUPS_PRINTER_IMPLICIT))
- {
- changed = cupsdDeletePrinterFromClasses(p);
+ changed = cupsdDeletePrinterFromClasses(p);
- /*
- * Deregister from any browse protocols...
- */
+ /*
+ * Deregister from any browse protocols...
+ */
- cupsdDeregisterPrinter(p, 1);
- }
+ cupsdDeregisterPrinter(p, 1);
/*
* Free all memory used by the printer...
cupsdClearString(&p->alert);
cupsdClearString(&p->alert_description);
-#ifdef HAVE_DNSSD
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
cupsdClearString(&p->pdl);
-#endif /* HAVE_DNSSD */
+ cupsdClearString(&p->reg_name);
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
cupsArrayDelete(p->filetypes);
- if (p->browse_attrs)
- free(p->browse_attrs);
-
cupsFreeOptions(p->num_options, p->options);
free(p);
"cupsdRenamePrinter: Removing %s from Printers", p->name);
cupsArrayRemove(Printers, p);
- if (p->type & CUPS_PRINTER_IMPLICIT)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdRenamePrinter: Removing %s from ImplicitPrinters",
- p->name);
- cupsArrayRemove(ImplicitPrinters, p);
- }
-
/*
* Rename the printer type...
*/
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdRenamePrinter: Adding %s to Printers", p->name);
cupsArrayAdd(Printers, p);
-
- if (p->type & CUPS_PRINTER_IMPLICIT)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG2,
- "cupsdRenamePrinter: Adding %s to ImplicitPrinters",
- p->name);
- cupsArrayAdd(ImplicitPrinters, p);
- }
}
printer = (cupsd_printer_t *)cupsArrayNext(Printers))
{
/*
- * Skip remote destinations and printer classes...
+ * Skip printer classes...
*/
- if ((printer->type & CUPS_PRINTER_DISCOVERED) ||
- (printer->type & CUPS_PRINTER_CLASS) ||
- (printer->type & CUPS_PRINTER_IMPLICIT))
+ if (printer->type & CUPS_PRINTER_CLASS)
continue;
/*
(long)printer->marker_time);
cupsFilePuts(fp, "</Printer>\n");
-
-#ifdef __sgi
- /*
- * Make IRIX desktop & printer status happy
- */
-
- write_irix_state(printer);
-#endif /* __sgi */
}
cupsdCloseCreatedConfFile(fp, filename);
ipp_attribute_t *attr; /* Attribute */
int i, /* Looping var */
count; /* Number of values */
- char *ptr; /* Pointer into value */
+ char *ptr, /* Pointer into value */
+ *start, /* Start of value */
+ quote; /* Quote character */
ipp_tag_t value_tag; /* Value tag for this attribute */
* Count the number of values...
*/
- for (count = 1, ptr = value;
- (ptr = strchr(ptr, ',')) != NULL;
- ptr ++, count ++);
+ for (count = 1, quote = '\0', ptr = value;
+ *ptr;
+ ptr ++)
+ {
+ if (*ptr == quote)
+ quote = '\0';
+ else if (quote)
+ continue;
+ else if (*ptr == '\\' && ptr[1])
+ ptr ++;
+ else if (*ptr == '\'' || *ptr == '\"')
+ quote = *ptr;
+ else if (*ptr == ',')
+ count ++;
+ }
/*
* Then add or update the attribute as needed...
return;
}
- for (i = 0; i < count; i ++)
+ for (i = 0, quote = '\0', ptr = value; i < count; i ++)
{
- if ((ptr = strchr(value, ',')) != NULL)
- *ptr++ = '\0';
+ for (start = ptr; *ptr; ptr ++)
+ {
+ if (*ptr == quote)
+ *ptr = quote = '\0';
+ else if (quote)
+ continue;
+ else if (*ptr == '\\' && ptr[1])
+ _cups_strcpy(ptr, ptr + 1);
+ else if (*ptr == '\'' || *ptr == '\"')
+ {
+ quote = *ptr;
- attr->values[i].string.text = _cupsStrAlloc(value);
+ if (ptr == start)
+ start ++;
+ else
+ _cups_strcpy(ptr, ptr + 1);
+ }
+ else if (*ptr == ',')
+ {
+ *ptr++ = '\0';
+ break;
+ }
+ }
- if (ptr)
- value = ptr;
+ attr->values[i].string.text = _cupsStrAlloc(start);
}
}
}
void
cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
{
- int i, /* Looping var */
- length; /* Length of browse attributes */
+ int i; /* Looping var */
char resource[HTTP_MAX_URI]; /* Resource portion of URI */
- int num_air; /* Number of auth-info-required values */
- const char * const *air; /* auth-info-required values */
cupsd_location_t *auth; /* Pointer to authentication element */
const char *auth_supported; /* Authentication supported */
ipp_t *oldattrs; /* Old printer attributes */
ipp_attribute_t *attr; /* Attribute data */
- cups_option_t *option; /* Current printer option */
char *name, /* Current user/group name */
*filter; /* Current filter */
- static const char * const air_none[] =
- { /* No authentication */
- "none"
- };
- static const char * const air_userpass[] =
- { /* Basic/Digest authentication */
- "username",
- "password"
- };
DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
*/
auth_supported = "requesting-user-name";
- num_air = 1;
- air = air_none;
-
- if (p->num_auth_info_required > 0 && strcmp(p->auth_info_required[0], "none"))
- {
- num_air = p->num_auth_info_required;
- air = p->auth_info_required;
- }
- else if ((p->type & CUPS_PRINTER_AUTHENTICATED) &&
- (p->type & CUPS_PRINTER_DISCOVERED))
- {
- num_air = 2;
- air = air_userpass;
- }
if (p->type & CUPS_PRINTER_CLASS)
snprintf(resource, sizeof(resource), "/classes/%s", p->name);
if ((auth_type = auth->type) == CUPSD_AUTH_DEFAULT)
- auth_type = DefaultAuthType;
+ auth_type = cupsdDefaultAuthType();
if (auth_type == CUPSD_AUTH_BASIC || auth_type == CUPSD_AUTH_BASICDIGEST)
auth_supported = "basic";
auth_supported = "negotiate";
#endif /* HAVE_GSSAPI */
- if (!(p->type & CUPS_PRINTER_DISCOVERED))
- {
- if (auth_type != CUPSD_AUTH_NONE)
- p->type |= CUPS_PRINTER_AUTHENTICATED;
- else
- p->type &= ~CUPS_PRINTER_AUTHENTICATED;
- }
+ if (auth_type != CUPSD_AUTH_NONE)
+ p->type |= CUPS_PRINTER_AUTHENTICATED;
+ else
+ p->type &= ~CUPS_PRINTER_AUTHENTICATED;
}
- else if (!(p->type & CUPS_PRINTER_DISCOVERED))
+ else
p->type &= ~CUPS_PRINTER_AUTHENTICATED;
/*
for (i = 0, name = (char *)cupsArrayFirst(p->users);
name;
i ++, name = (char *)cupsArrayNext(p->users))
- attr->values[i].string.text = _cupsStrRetain(name);
+ attr->values[i].string.text = _cupsStrAlloc(name);
}
ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
"job-k-limit", p->k_limit);
ippAddInteger(p->attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
"job-page-limit", p->page_limit);
- ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "auth-info-required", num_air, NULL, air);
+ if (p->num_auth_info_required > 0 && strcmp(p->auth_info_required[0], "none"))
+ ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "auth-info-required", p->num_auth_info_required, NULL,
+ p->auth_info_required);
- if (cupsArrayCount(Banners) > 0 && !(p->type & CUPS_PRINTER_DISCOVERED))
+ if (cupsArrayCount(Banners) > 0)
{
/*
* Setup the job-sheets-default attribute...
p->raw = 0;
p->remote = 0;
- if (p->type & CUPS_PRINTER_DISCOVERED)
+ /*
+ * Assign additional attributes depending on whether this is a printer
+ * or class...
+ */
+
+ if (p->type & CUPS_PRINTER_CLASS)
{
+ p->raw = 1;
+ p->type &= ~CUPS_PRINTER_OPTIONS;
+
/*
- * Tell the client this is a remote printer of some type...
+ * Add class-specific attributes...
*/
- if (strchr(p->uri, '?'))
+ ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
+ "printer-make-and-model", NULL, "Local Printer Class");
+ ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL,
+ "file:///dev/null");
+
+ if (p->num_printers > 0)
{
/*
- * Strip trailing "?options" from URI...
+ * Add a list of member names; URIs are added in copy_printer_attrs...
*/
- char *ptr; /* Pointer into URI */
+ attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME,
+ "member-names", p->num_printers, NULL, NULL);
+ p->type |= CUPS_PRINTER_OPTIONS;
- strlcpy(resource, p->uri, sizeof(resource));
- if ((ptr = strchr(resource, '?')) != NULL)
- *ptr = '\0';
+ for (i = 0; i < p->num_printers; i ++)
+ {
+ if (attr != NULL)
+ attr->values[i].string.text = _cupsStrAlloc(p->printers[i]->name);
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
- "printer-uri-supported", NULL, resource);
+ p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type;
+ }
}
- else
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
- "printer-uri-supported", NULL, p->uri);
-
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "printer-more-info",
- NULL, p->uri);
-
- if (p->make_model)
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
- "printer-make-and-model", NULL, p->make_model);
-
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL,
- p->uri);
-
- p->raw = 1;
- p->remote = 1;
}
else
{
/*
- * Assign additional attributes depending on whether this is a printer
- * or class...
+ * Add printer-specific attributes...
*/
- if (p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
- {
- p->raw = 1;
- p->type &= ~CUPS_PRINTER_OPTIONS;
-
- /*
- * Add class-specific attributes...
- */
-
- if ((p->type & CUPS_PRINTER_IMPLICIT) && p->num_printers > 0 &&
- p->printers[0]->make_model)
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
- "printer-make-and-model", NULL, p->printers[0]->make_model);
- else
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_TEXT,
- "printer-make-and-model", NULL, "Local Printer Class");
+ ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL,
+ p->sanitized_device_uri);
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL,
- "file:///dev/null");
+ /*
+ * Assign additional attributes from the PPD file (if any)...
+ */
- if (p->num_printers > 0)
- {
- /*
- * Add a list of member names; URIs are added in copy_printer_attrs...
- */
+ load_ppd(p);
- attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_NAME,
- "member-names", p->num_printers, NULL, NULL);
- p->type |= CUPS_PRINTER_OPTIONS;
+ /*
+ * Add filters for printer...
+ */
- for (i = 0; i < p->num_printers; i ++)
- {
- if (attr != NULL)
- attr->values[i].string.text = _cupsStrRetain(p->printers[i]->name);
+ cupsdSetPrinterReasons(p, "-cups-missing-filter-warning,"
+ "cups-insecure-filter-warning");
- p->type &= ~CUPS_PRINTER_OPTIONS | p->printers[i]->type;
- }
- }
+ if (p->pc && p->pc->filters)
+ {
+ for (filter = (char *)cupsArrayFirst(p->pc->filters);
+ filter;
+ filter = (char *)cupsArrayNext(p->pc->filters))
+ add_printer_filter(p, p->filetype, filter);
}
- else
+ else if (!(p->type & CUPS_PRINTER_REMOTE))
{
- /*
- * Add printer-specific attributes...
- */
+ char interface[1024]; /* Interface script */
- ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL,
- p->sanitized_device_uri);
- /*
- * Assign additional attributes from the PPD file (if any)...
- */
-
- load_ppd(p);
-
- /*
- * Add filters for printer...
- */
-
- cupsdSetPrinterReasons(p, "-cups-missing-filter-warning,"
- "cups-insecure-filter-warning");
-
- if (p->pc && p->pc->filters)
+ snprintf(interface, sizeof(interface), "%s/interfaces/%s", ServerRoot,
+ p->name);
+ if (!access(interface, X_OK))
{
- for (filter = (char *)cupsArrayFirst(p->pc->filters);
- filter;
- filter = (char *)cupsArrayNext(p->pc->filters))
- add_printer_filter(p, p->filetype, filter);
+ /*
+ * Yes, we have a System V style interface script; use it!
+ */
+
+ snprintf(interface, sizeof(interface), "*/* 0 %s/interfaces/%s",
+ ServerRoot, p->name);
+ add_printer_filter(p, p->filetype, interface);
}
- else if (!(p->type & CUPS_PRINTER_REMOTE))
+ else
{
- char interface[1024]; /* Interface script */
-
-
- snprintf(interface, sizeof(interface), "%s/interfaces/%s", ServerRoot,
- p->name);
- if (!access(interface, X_OK))
- {
- /*
- * Yes, we have a System V style interface script; use it!
- */
-
- snprintf(interface, sizeof(interface), "*/* 0 %s/interfaces/%s",
- ServerRoot, p->name);
- add_printer_filter(p, p->filetype, interface);
- }
- else
- {
- /*
- * Add a filter from application/vnd.cups-raw to printer/name to
- * handle "raw" printing by users.
- */
+ /*
+ * Add a filter from application/vnd.cups-raw to printer/name to
+ * handle "raw" printing by users.
+ */
- add_printer_filter(p, p->filetype, "application/vnd.cups-raw 0 -");
+ add_printer_filter(p, p->filetype, "application/vnd.cups-raw 0 -");
- /*
- * Add a PostScript filter, since this is still possibly PS printer.
- */
+ /*
+ * Add a PostScript filter, since this is still possibly PS printer.
+ */
- add_printer_filter(p, p->filetype,
- "application/vnd.cups-postscript 0 -");
- }
+ add_printer_filter(p, p->filetype,
+ "application/vnd.cups-postscript 0 -");
}
+ }
- if (p->pc && p->pc->prefilters)
- {
- if (!p->prefiltertype)
- p->prefiltertype = mimeAddType(MimeDatabase, "prefilter", p->name);
+ if (p->pc && p->pc->prefilters)
+ {
+ if (!p->prefiltertype)
+ p->prefiltertype = mimeAddType(MimeDatabase, "prefilter", p->name);
- for (filter = (char *)cupsArrayFirst(p->pc->prefilters);
- filter;
- filter = (char *)cupsArrayNext(p->pc->prefilters))
- add_printer_filter(p, p->prefiltertype, filter);
- }
+ for (filter = (char *)cupsArrayFirst(p->pc->prefilters);
+ filter;
+ filter = (char *)cupsArrayNext(p->pc->prefilters))
+ add_printer_filter(p, p->prefiltertype, filter);
}
}
{
for (i = 0; i < oldattr->num_values; i ++)
attr->values[i].string.text =
- _cupsStrRetain(oldattr->values[i].string.text);
+ _cupsStrAlloc(oldattr->values[i].string.text);
}
}
{
for (i = 0; i < oldattr->num_values; i ++)
attr->values[i].string.text =
- _cupsStrRetain(oldattr->values[i].string.text);
+ _cupsStrAlloc(oldattr->values[i].string.text);
}
}
{
for (i = 0; i < oldattr->num_values; i ++)
attr->values[i].string.text =
- _cupsStrRetain(oldattr->values[i].string.text);
+ _cupsStrAlloc(oldattr->values[i].string.text);
}
}
* Force sharing off for remote queues...
*/
- if (p->type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT))
+ if (p->type & CUPS_PRINTER_REMOTE)
p->shared = 0;
- else
- {
- /*
- * Copy the printer options into a browse attributes string we can re-use.
- */
-
- const char *valptr; /* Pointer into value */
- char *attrptr; /* Pointer into attribute string */
-
-
- /*
- * Free the old browse attributes as needed...
- */
-
- if (p->browse_attrs)
- free(p->browse_attrs);
-
- /*
- * Compute the length of all attributes + job-sheets, lease-duration,
- * and BrowseLocalOptions.
- */
-
- for (length = 1, i = p->num_options, option = p->options;
- i > 0;
- i --, option ++)
- {
- length += strlen(option->name) + 2;
-
- if (option->value)
- {
- for (valptr = option->value; *valptr; valptr ++)
- if (strchr(" \"\'\\", *valptr))
- length += 2;
- else
- length ++;
- }
- }
-
- length += 13 + strlen(p->job_sheets[0]) + strlen(p->job_sheets[1]);
- length += 32;
- if (BrowseLocalOptions)
- length += 12 + strlen(BrowseLocalOptions);
-
- /*
- * Allocate the new string...
- */
-
- if ((p->browse_attrs = calloc(1, length)) == NULL)
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "Unable to allocate %d bytes for browse data!",
- length);
- else
- {
- /*
- * Got the allocated string, now copy the options and attributes over...
- */
-
- sprintf(p->browse_attrs, "job-sheets=%s,%s lease-duration=%d",
- p->job_sheets[0], p->job_sheets[1], BrowseTimeout);
- attrptr = p->browse_attrs + strlen(p->browse_attrs);
-
- if (BrowseLocalOptions)
- {
- sprintf(attrptr, " ipp-options=%s", BrowseLocalOptions);
- attrptr += strlen(attrptr);
- }
-
- for (i = p->num_options, option = p->options;
- i > 0;
- i --, option ++)
- {
- *attrptr++ = ' ';
- strcpy(attrptr, option->name);
- attrptr += strlen(attrptr);
-
- if (option->value)
- {
- *attrptr++ = '=';
-
- for (valptr = option->value; *valptr; valptr ++)
- {
- if (strchr(" \"\'\\", *valptr))
- *attrptr++ = '\\';
-
- *attrptr++ = *valptr;
- }
- }
- }
- }
- }
/*
* Populate the document-format-supported attribute...
add_printer_defaults(p);
-#ifdef __sgi
- /*
- * Write the IRIX printer config and status files...
- */
-
- write_irix_config(p);
- write_irix_state(p);
-#endif /* __sgi */
-
/*
* Let the browse protocols reflect the change
*/
if (i >= p->num_reasons)
{
+ if (!strncmp(reason, "cups-ipp-missing-", 17) ||
+ !strncmp(reason, "cups-ipp-wrong-", 15))
+ log_ipp_conformance(p, reason);
+
if (i >= (int)(sizeof(p->reasons) / sizeof(p->reasons[0])))
{
cupsdLogMessage(CUPSD_LOG_ALERT,
ipp_pstate_t s, /* I - New state */
int update) /* I - Update printers.conf? */
{
+ cupsd_job_t *job; /* Current job */
ipp_pstate_t old_state; /* Old printer state */
static const char * const printer_states[] =
{ /* State strings */
};
- /*
- * Can't set status of remote printers...
- */
-
- if (p->type & CUPS_PRINTER_DISCOVERED)
- return;
-
/*
* Set the new state...
*/
* Let the browse code know this needs to be updated...
*/
- BrowseNext = p;
- p->state_time = time(NULL);
- p->browse_time = 0;
-
-#ifdef __sgi
- write_irix_state(p);
-#endif /* __sgi */
+ p->state_time = time(NULL);
}
/*
else
cupsdSetPrinterReasons(p, "-paused");
+ if (old_state != s)
+ {
+ for (job = (cupsd_job_t *)cupsArrayFirst(ActiveJobs);
+ job;
+ job = (cupsd_job_t *)cupsArrayNext(ActiveJobs))
+ if (job->reasons && job->state_value == IPP_JOB_PENDING &&
+ !_cups_strcasecmp(job->dest, p->name))
+ ippSetString(job->attrs, &job->reasons, 0,
+ s == IPP_PRINTER_STOPPED ? "printer-stopped" : "none");
+ }
+
/*
* Clear the message for the queue when going to processing...
*/
p;
p = (cupsd_printer_t *)cupsArrayNext(Printers))
{
- /*
- * Remove remote printers if we are no longer browsing...
- */
-
- if (!Browsing &&
- (p->type & (CUPS_PRINTER_IMPLICIT | CUPS_PRINTER_DISCOVERED)))
- {
- if (p->type & CUPS_PRINTER_IMPLICIT)
- cupsArrayRemove(ImplicitPrinters, p);
-
- cupsArraySave(Printers);
- cupsdDeletePrinter(p, 0);
- cupsArrayRestore(Printers);
- continue;
- }
-
/*
* Update the operation policy pointer...
*/
p->op_policy_ptr = DefaultPolicyPtr;
/*
- * Update printer attributes as needed...
+ * Update printer attributes...
*/
- if (!(p->type & CUPS_PRINTER_DISCOVERED))
- cupsdSetPrinterAttrs(p);
+ cupsdSetPrinterAttrs(p);
}
}
*printer = p;
if (dtype)
- *dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT |
- CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED);
+ *dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE);
return (p->name);
}
*printer = p;
if (dtype)
- *dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT |
- CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED);
+ *dtype = p->type & (CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE);
return (p->name);
}
cupsd_printer_t *p; /* Current printer */
-#ifdef __sgi
- /*
- * Update the IRIX printer state for the default printer; if
- * no printers remain, then the default printer file will be
- * removed...
- */
-
- write_irix_state(DefaultPrinter);
-#endif /* __sgi */
-
/*
* See if we have a printcap file; if not, don't bother writing it.
*/
cupsArrayAdd(CommonDefaults, _cupsStrAlloc("copies-default"));
cupsArrayAdd(CommonDefaults, _cupsStrAlloc("document-format-default"));
cupsArrayAdd(CommonDefaults, _cupsStrAlloc("finishings-default"));
+ cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-account-id-default"));
+ cupsArrayAdd(CommonDefaults,
+ _cupsStrAlloc("job-accounting-user-id-default"));
cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-hold-until-default"));
cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-priority-default"));
cupsArrayAdd(CommonDefaults, _cupsStrAlloc("job-sheets-default"));
"add_printer_filter: %s: adding filter %s/%s %s/%s "
"0 -", p->name, desttype->super, desttype->type,
filtertype->super, filtertype->type);
- mimeAddFilter(MimeDatabase, desttype, filtertype, cost, "-");
+ mimeAddFilter(MimeDatabase, desttype, filtertype, 0, "-");
}
}
else
attr->values[i].string.text = _cupsStrAlloc(mimetype);
}
-#ifdef HAVE_DNSSD
+#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
{
char pdl[1024]; /* Buffer to build pdl list */
mime_filter_t *filter; /* MIME filter looping var */
cupsdSetString(&p->pdl, pdl);
}
-#endif /* HAVE_DNSSD */
+#endif /* HAVE_DNSSD || HAVE_AVAHI */
}
static void
dirty_printer(cupsd_printer_t *p) /* I - Printer */
{
- if (p->type & CUPS_PRINTER_DISCOVERED)
- cupsdMarkDirty(CUPSD_DIRTY_REMOTE);
- else if (p->type & CUPS_PRINTER_CLASS)
+ if (p->type & CUPS_PRINTER_CLASS)
cupsdMarkDirty(CUPSD_DIRTY_CLASSES);
else
cupsdMarkDirty(CUPSD_DIRTY_PRINTERS);
_pwg_map_t *pwgsource, /* Current PWG source */
*pwgtype; /* Current PWG type */
ipp_attribute_t *attr; /* Attribute data */
- ipp_value_t *val; /* Attribute value */
+ _ipp_value_t *val; /* Attribute value */
int num_finishings, /* Number of finishings */
finishings[5]; /* finishings-supported values */
int num_qualities, /* Number of print-quality values */
qualities[3]; /* print-quality values */
int num_margins, /* Number of media-*-margin-supported values */
margins[16]; /* media-*-margin-supported values */
- const char *filter; /* Current filter */
+ const char *filter, /* Current filter */
+ *mandatory; /* Current mandatory attribute */
static const char * const sides[3] = /* sides-supported values */
{
"one-sided",
p->ppd_attrs = ippNew();
- if ((ppd = ppdOpenFile(ppd_name)) != NULL)
+ if ((ppd = _ppdOpenFile(ppd_name, _PPD_LOCALIZATION_NONE)) != NULL)
{
/*
* Add make/model and other various attributes...
p->pc = _ppdCacheCreateWithPPD(ppd);
+ if (!p->pc)
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unable to create cache of \"%s\": %s",
+ ppd_name, cupsLastErrorString());
+
ppdMarkDefaults(ppd);
if (ppd->color_device)
ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "color-supported",
ppd->color_device);
+
+ if (p->pc && p->pc->charge_info_uri)
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_URI,
+ "printer-charge-info-uri", NULL, p->pc->charge_info_uri);
+
+ if (p->pc && p->pc->account_id)
+ ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER, "job-account-id-supported",
+ 1);
+
+ if (p->pc && p->pc->accounting_user_id)
+ ippAddBoolean(p->ppd_attrs, IPP_TAG_PRINTER,
+ "job-accounting-user-id-supported", 1);
+
+ if (p->pc && p->pc->password)
+ {
+ ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "job-password-encryption-supported", NULL, "none");
+ ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "job-password-supported", strlen(p->pc->password));
+ }
+
if (ppd->throughput)
{
ippAddInteger(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
for (i = p->pc->num_sizes, pwgsize = p->pc->sizes;
i > 0;
i --, pwgsize ++, val ++)
- val->string.text = _cupsStrRetain(pwgsize->map.pwg);
+ val->string.text = _cupsStrAlloc(pwgsize->map.pwg);
if (p->pc->custom_min_keyword)
{
- val->string.text = _cupsStrRetain(p->pc->custom_min_keyword);
+ val->string.text = _cupsStrAlloc(p->pc->custom_min_keyword);
val ++;
- val->string.text = _cupsStrRetain(p->pc->custom_max_keyword);
+ val->string.text = _cupsStrAlloc(p->pc->custom_max_keyword);
+ }
+ }
+
+ /*
+ * media-size-supported
+ */
+
+ num_media = p->pc->num_sizes;
+ if (p->pc->custom_min_keyword)
+ num_media ++;
+
+ if ((attr = ippAddCollections(p->ppd_attrs, IPP_TAG_PRINTER,
+ "media-size-supported", num_media,
+ NULL)) != NULL)
+ {
+ val = attr->values;
+
+ for (i = p->pc->num_sizes, pwgsize = p->pc->sizes;
+ i > 0;
+ i --, pwgsize ++, val ++)
+ {
+ val->collection = ippNew();
+ ippAddInteger(val->collection, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "x-dimension", pwgsize->width);
+ ippAddInteger(val->collection, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "y-dimension", pwgsize->length);
+ }
+
+ if (p->pc->custom_min_keyword)
+ {
+ val->collection = ippNew();
+ ippAddRange(val->collection, IPP_TAG_PRINTER, "x-dimension",
+ p->pc->custom_min_width, p->pc->custom_max_width);
+ ippAddRange(val->collection, IPP_TAG_PRINTER, "y-dimension",
+ p->pc->custom_min_length, p->pc->custom_max_length);
}
}
val = attr->values;
i > 0;
i --, pwgsource ++, val ++)
- val->string.text = _cupsStrRetain(pwgsource->pwg);
+ val->string.text = _cupsStrAlloc(pwgsource->pwg);
}
/*
val = attr->values;
i > 0;
i --, pwgtype ++, val ++)
- val->string.text = _cupsStrRetain(pwgtype->pwg);
+ val->string.text = _cupsStrAlloc(pwgtype->pwg);
}
/*
}
/*
- * output-mode and print-color-mode...
+ * print-color-mode...
*/
if (ppd->color_device)
{
- static const char * const output_modes[] =
+ static const char * const color_modes[] =
{
"monochrome",
"color"
};
ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "output-mode-supported", 2, NULL, output_modes);
- ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "output-mode-default", NULL, "color");
-
- ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "print-color-mode-supported", 2, NULL, output_modes);
+ "print-color-mode-supported", 2, NULL, color_modes);
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"print-color-mode-default", NULL, "color");
}
else
{
- ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "output-mode-supported", NULL, "monochrome");
- ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
- "output-mode-default", NULL, "monochrome");
-
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"print-color-mode-supported", NULL, "monochrome");
ippAddString(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
"print-color-mode-default", NULL, "monochrome");
}
+ /*
+ * Mandatory job attributes, if any...
+ */
+
+ if (p->pc && cupsArrayCount(p->pc->mandatory) > 0)
+ {
+ int count = cupsArrayCount(p->pc->mandatory);
+ /* Number of mandatory attributes */
+
+ attr = ippAddStrings(p->ppd_attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "printer-mandatory-job-attributes", count, NULL,
+ NULL);
+
+ for (val = attr->values,
+ mandatory = (char *)cupsArrayFirst(p->pc->mandatory);
+ mandatory;
+ val ++, mandatory = (char *)cupsArrayNext(p->pc->mandatory))
+ val->string.text = _cupsStrAlloc(mandatory);
+ }
+
/*
* Printer resolutions...
*/
"printer-make-and-model", NULL,
"Local System V Printer");
}
- else if (!strncmp(p->device_uri, "ipp://", 6) &&
- (strstr(p->device_uri, "/printers/") != NULL ||
- strstr(p->device_uri, "/classes/") != NULL ||
- (strstr(p->device_uri, "._ipp.") != NULL &&
- !strcmp(p->device_uri + strlen(p->device_uri) - 5,
- "/cups"))))
+ else if (((!strncmp(p->device_uri, "ipp://", 6) ||
+ !strncmp(p->device_uri, "ipps://", 7)) &&
+ (strstr(p->device_uri, "/printers/") != NULL ||
+ strstr(p->device_uri, "/classes/") != NULL)) ||
+ ((strstr(p->device_uri, "._ipp.") != NULL ||
+ strstr(p->device_uri, "._ipps.") != NULL) &&
+ !strcmp(p->device_uri + strlen(p->device_uri) - 5, "/cups")))
{
/*
* Tell the client this is really a hard-wired remote printer.
}
+/*
+ * 'log_ipp_conformance()' - Log an IPP conformance issue with a printer.
+ */
+
+static void
+log_ipp_conformance(
+ cupsd_printer_t *p, /* I - Printer */
+ const char *reason) /* I - Printer state reason */
+{
+ const char *message; /* Message to log */
+#ifdef __APPLE__
+ aslmsg aslm; /* Apple System Log message */
+#endif /* __APPLE__ */
+
+
+ /*
+ * Strip the leading "cups-ipp-" from the reason and create a log message for
+ * it...
+ */
+
+ reason += 9;
+ if (!strcmp(reason, "missing-cancel-job"))
+ message = "Printer does not support REQUIRED Cancel-Job operation.";
+ else if (!strcmp(reason, "missing-get-job-attributes"))
+ message = "Printer does not support REQUIRED Get-Job-Attributes operation.";
+ else if (!strcmp(reason, "missing-print-job"))
+ message = "Printer does not support REQUIRED Print-Job operation.";
+ else if (!strcmp(reason, "missing-validate-job"))
+ message = "Printer does not support REQUIRED Validate-Job operation.";
+ else if (!strcmp(reason, "missing-get-printer-attributes"))
+ message = "Printer does not support REQUIRED Get-Printer-Attributes operation.";
+ else if (!strcmp(reason, "missing-send-document"))
+ message = "Printer supports Create-Job but not Send-Document operation.";
+ else if (!strcmp(reason, "missing-job-history"))
+ message = "Printer does not provide REQUIRED job history.";
+ else if (!strcmp(reason, "missing-job-id"))
+ message = "Printer does not provide REQUIRED job-id attribute.";
+ else if (!strcmp(reason, "missing-job-state"))
+ message = "Printer does not provide REQUIRED job-state attribute.";
+ else if (!strcmp(reason, "missing-operations-supported"))
+ message = "Printer does not provide REQUIRED operations-supported "
+ "attribute.";
+ else if (!strcmp(reason, "missing-printer-is-accepting-jobs"))
+ message = "Printer does not provide REQUIRED printer-is-accepting-jobs "
+ "attribute.";
+ else if (!strcmp(reason, "missing-printer-state-reasons"))
+ message = "Printer does not provide REQUIRED printer-state-reasons "
+ "attribute.";
+ else if (!strcmp(reason, "wrong-http-version"))
+ message = "Printer does not use REQUIRED HTTP/1.1 transport.";
+ else
+ message = "Unknown IPP conformance failure.";
+
+ cupsdLogMessage(CUPSD_LOG_WARN, "%s: %s", p->name, message);
+
+#ifdef __APPLE__
+ /*
+ * Report the failure information to Apple if the user opts into providing
+ * feedback to Apple...
+ */
+
+ aslm = asl_new(ASL_TYPE_MSG);
+ if (aslm)
+ {
+ asl_set(aslm, "com.apple.message.domain", "com.apple.printing.ipp.conformance");
+ asl_set(aslm, "com.apple.message.domain_scope", "com.apple.printing.ipp.conformance");
+ asl_set(aslm, "com.apple.message.signature", reason);
+ asl_set(aslm, "com.apple.message.signature2",
+ p->make_model ? p->make_model : "Unknown");
+ asl_log(NULL, aslm, ASL_LEVEL_NOTICE, "%s: %s",
+ p->make_model ? p->make_model : "Unknown", message);
+ asl_free(aslm);
+ }
+#endif /* __APPLE__ */
+}
+
+
/*
* 'new_media_col()' - Create a media-col collection value.
*/
}
-#ifdef __sgi
-/*
- * 'write_irix_config()' - Update the config files used by the IRIX
- * desktop tools.
- */
-
-static void
-write_irix_config(cupsd_printer_t *p) /* I - Printer to update */
-{
- char filename[1024]; /* Interface script filename */
- cups_file_t *fp; /* Interface script file */
- ipp_attribute_t *attr; /* Attribute data */
-
-
- /*
- * Add dummy interface and GUI scripts to fool SGI's "challenged" printing
- * tools. First the interface script that tells the tools what kind of
- * printer we have...
- */
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/interface/%s", p->name);
-
- if (p->type & CUPS_PRINTER_CLASS)
- unlink(filename);
- else if ((fp = cupsFileOpen(filename, "w")) != NULL)
- {
- cupsFilePuts(fp, "#!/bin/sh\n");
-
- if ((attr = ippFindAttribute(p->attrs, "printer-make-and-model",
- IPP_TAG_TEXT)) != NULL)
- cupsFilePrintf(fp, "NAME=\"%s\"\n", attr->values[0].string.text);
- else if (p->type & CUPS_PRINTER_CLASS)
- cupsFilePuts(fp, "NAME=\"Printer Class\"\n");
- else
- cupsFilePuts(fp, "NAME=\"Remote Destination\"\n");
-
- if (p->type & CUPS_PRINTER_COLOR)
- cupsFilePuts(fp, "TYPE=ColorPostScript\n");
- else
- cupsFilePuts(fp, "TYPE=MonoPostScript\n");
-
- cupsFilePrintf(fp, "HOSTNAME=%s\n", ServerName);
- cupsFilePrintf(fp, "HOSTPRINTER=%s\n", p->name);
-
- cupsFileClose(fp);
-
- chmod(filename, 0755);
- chown(filename, User, Group);
- }
-
- /*
- * Then the member file that tells which device file the queue is connected
- * to... Networked printers use "/dev/null" in this file, so that's what
- * we use (the actual device URI can confuse some apps...)
- */
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/member/%s", p->name);
-
- if (p->type & CUPS_PRINTER_CLASS)
- unlink(filename);
- else if ((fp = cupsFileOpen(filename, "w")) != NULL)
- {
- cupsFilePuts(fp, "/dev/null\n");
-
- cupsFileClose(fp);
-
- chmod(filename, 0644);
- chown(filename, User, Group);
- }
-
- /*
- * The gui_interface file is a script or program that launches a GUI
- * option panel for the printer, using options specified on the
- * command-line in the third argument. The option panel must send
- * any printing options to stdout on a single line when the user
- * accepts them, or nothing if the user cancels the dialog.
- *
- * The default options panel program is /usr/bin/glpoptions, from
- * the ESP Print Pro software. You can select another using the
- * PrintcapGUI option.
- */
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/gui_interface/ELF/%s.gui", p->name);
-
- if (p->type & CUPS_PRINTER_CLASS)
- unlink(filename);
- else if ((fp = cupsFileOpen(filename, "w")) != NULL)
- {
- cupsFilePuts(fp, "#!/bin/sh\n");
- cupsFilePrintf(fp, "%s -d %s -o \"$3\"\n", PrintcapGUI, p->name);
-
- cupsFileClose(fp);
-
- chmod(filename, 0755);
- chown(filename, User, Group);
- }
-
- /*
- * The POD config file is needed by the printstatus command to show
- * the printer location and device.
- */
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.config", p->name);
-
- if (p->type & CUPS_PRINTER_CLASS)
- unlink(filename);
- else if ((fp = cupsFileOpen(filename, "w")) != NULL)
- {
- cupsFilePrintf(fp, "Printer Class | %s\n",
- (p->type & CUPS_PRINTER_COLOR) ? "ColorPostScript" : "MonoPostScript");
- cupsFilePrintf(fp, "Printer Model | %s\n", p->make_model ? p->make_model : "");
- cupsFilePrintf(fp, "Location Code | %s\n", p->location ? p->location : "");
- cupsFilePrintf(fp, "Physical Location | %s\n", p->info ? p->info : "");
- cupsFilePrintf(fp, "Port Path | %s\n", p->device_uri);
- cupsFilePrintf(fp, "Config Path | /var/spool/lp/pod/%s.config\n", p->name);
- cupsFilePrintf(fp, "Active Status Path | /var/spool/lp/pod/%s.status\n", p->name);
- cupsFilePuts(fp, "Status Update Wait | 10 seconds\n");
-
- cupsFileClose(fp);
-
- chmod(filename, 0664);
- chown(filename, User, Group);
- }
-}
-
-
-/*
- * 'write_irix_state()' - Update the status files used by IRIX printing
- * desktop tools.
- */
-
-static void
-write_irix_state(cupsd_printer_t *p) /* I - Printer to update */
-{
- char filename[1024]; /* Interface script filename */
- cups_file_t *fp; /* Interface script file */
- int tag; /* Status tag value */
-
-
- if (p)
- {
- /*
- * The POD status file is needed for the printstatus window to
- * provide the current status of the printer.
- */
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/pod/%s.status", p->name);
-
- if (p->type & CUPS_PRINTER_CLASS)
- unlink(filename);
- else if ((fp = cupsFileOpen(filename, "w")) != NULL)
- {
- cupsFilePrintf(fp, "Operational Status | %s\n",
- (p->state == IPP_PRINTER_IDLE) ? "Idle" :
- (p->state == IPP_PRINTER_PROCESSING) ? "Busy" :
- "Faulted");
- cupsFilePrintf(fp, "Information | 01 00 00 | %s\n", CUPS_SVERSION);
- cupsFilePrintf(fp, "Information | 02 00 00 | Device URI: %s\n",
- p->device_uri);
- cupsFilePrintf(fp, "Information | 03 00 00 | %s jobs\n",
- p->accepting ? "Accepting" : "Not accepting");
- cupsFilePrintf(fp, "Information | 04 00 00 | %s\n", p->state_message);
-
- cupsFileClose(fp);
-
- chmod(filename, 0664);
- chown(filename, User, Group);
- }
-
- /*
- * The activeicons file is needed to provide desktop icons for printers:
- *
- * [ quoted from /usr/lib/print/tagit ]
- *
- * --- Type of printer tags (base values)
- *
- * Dumb=66048 # 0x10200
- * DumbColor=66080 # 0x10220
- * Raster=66112 # 0x10240
- * ColorRaster=66144 # 0x10260
- * Plotter=66176 # 0x10280
- * PostScript=66208 # 0x102A0
- * ColorPostScript=66240 # 0x102C0
- * MonoPostScript=66272 # 0x102E0
- *
- * --- Printer state modifiers for local printers
- *
- * Idle=0 # 0x0
- * Busy=1 # 0x1
- * Faulted=2 # 0x2
- * Unknown=3 # 0x3 (Faulted due to unknown reason)
- *
- * --- Printer state modifiers for network printers
- *
- * NetIdle=8 # 0x8
- * NetBusy=9 # 0x9
- * NetFaulted=10 # 0xA
- * NetUnknown=11 # 0xB (Faulted due to unknown reason)
- */
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/activeicons/%s", p->name);
-
- if (p->type & CUPS_PRINTER_CLASS)
- unlink(filename);
- else if ((fp = cupsFileOpen(filename, "w")) != NULL)
- {
- if (p->type & CUPS_PRINTER_COLOR)
- tag = 66240;
- else
- tag = 66272;
-
- if (p->type & CUPS_PRINTER_REMOTE)
- tag |= 8;
-
- if (p->state == IPP_PRINTER_PROCESSING)
- tag |= 1;
-
- else if (p->state == IPP_PRINTER_STOPPED)
- tag |= 2;
-
- cupsFilePuts(fp, "#!/bin/sh\n");
- cupsFilePrintf(fp, "#Tag %d\n", tag);
-
- cupsFileClose(fp);
-
- chmod(filename, 0755);
- chown(filename, User, Group);
- }
- }
-
- /*
- * The default file is needed by the printers window to show
- * the default printer.
- */
-
- snprintf(filename, sizeof(filename), "/var/spool/lp/default");
-
- if (DefaultPrinter != NULL)
- {
- if ((fp = cupsFileOpen(filename, "w")) != NULL)
- {
- cupsFilePrintf(fp, "%s\n", DefaultPrinter->name);
-
- cupsFileClose(fp);
-
- chmod(filename, 0644);
- chown(filename, User, Group);
- }
- }
- else
- unlink(filename);
-}
-#endif /* __sgi */
-
-
/*
* 'write_xml_string()' - Write a string with XML escaping.
*/
/*
- * End of "$Id: printers.c 7968 2008-09-19 23:03:01Z mike $".
+ * End of "$Id$".
*/