CHANGES IN CUPS V1.3.8
- Documentation updates (STR #2785, STR #2861, STR #2862)
+ - The IPP backend did not relay marker-* attributes.
+ - The CUPS GNOME/KDE menu item was not localized for
+ Japanese (STR #2876)
+ - The cupstestppd utility reported mixed line endings for
+ Mac OS and Windows PPD files (STR #2874)
+ - The pdftops filter did not print landscape orientation PDF
+ pages correctly on all printers (STR #2850)
+ - The scheduler did not handle expiring of implicit classes
+ or their members properly, leading to a configuration where
+ one of the members would have a short name (STR #2766)
+ - The scheduler and cupstestppd utilities did not support
+ cupsFilter and cupsPreFilter programs with spaces in their
+ names (STR #2866)
+ - Removed unused variables and assignments found by the
+ LLVM "clang" tool.
+ - Added NULL checks recommended by the LLVM "clang" tool.
- The scheduler would crash if you started a printer that
pointed to a backend that did not exist (STR #2865)
- The ppdLocalize functions incorrectly mapped all generic
-CHANGES.txt - 2008-07-02
+CHANGES.txt - 2008-07-14
------------------------
CHANGES IN CUPS V1.4b1
+ - Added an AccessLogLevel directive to cupsd.conf to control
+ what is logged to the access_log file.
+ - The default LogLevel is now "warn" instead of "info" to reduce
+ the amount of logging that is done to disk by default.
- The PPD compiler did not include OID query keywords in PPD
files (STR #2871)
- The cups-driverd helper program now directly supports driver
done
+#
+# Run the clang.llvm.org static code analysis tool on the C sources.
+#
+
+.PHONY: clang
+clang:
+ if test ! -d clang; then \
+ mkdir clang; \
+ else \
+ rm -rf clang/*; \
+ fi
+ $(MAKE) $(MFLAGS) CC="scan-build -o ../clang $(CC)" clean all
+
+
#
# Generate a ctags file...
#
* compress_files() - Compress print files...
* password_cb() - Disable the password prompt for
* cupsDoFileRequest().
+ * report_attr() - Report an IPP attribute value.
* report_printer_state() - Report the printer state.
* run_pictwps_filter() - Convert PICT files to PostScript when printing
* remotely.
static void compress_files(int num_files, char **files);
#endif /* HAVE_LIBZ */
static const char *password_cb(const char *);
+static void report_attr(ipp_attribute_t *attr);
static int report_printer_state(ipp_t *ipp, int job_id);
#ifdef __APPLE__
int send_options; /* Send job options? */
int num_options; /* Number of printer options */
cups_option_t *options; /* Printer options */
+ const char *device_uri; /* Device URI */
char method[255], /* Method in URI */
hostname[1024], /* Hostname */
username[255], /* Username info */
{ /* Printer attributes we want */
"copies-supported",
"document-format-supported",
+ "marker-colors",
+ "marker-levels",
+ "marker-message",
+ "marker-names",
+ "marker-types",
"printer-is-accepting-jobs",
"printer-state",
"printer-state-message",
* Extract the hostname and printer name from the URI...
*/
- if (httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+ if ((device_uri = cupsBackendDeviceURI(argv)) == NULL)
+ return (CUPS_BACKEND_FAILED);
+
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, device_uri,
method, sizeof(method), username, sizeof(username),
hostname, sizeof(hostname), &port,
resource, sizeof(resource)) < HTTP_URI_OK)
cups_file_t *fp; /* Temporary file */
char buffer[8192]; /* Buffer for copying */
int bytes; /* Number of bytes read */
+ off_t tbytes; /* Total bytes copied */
if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0)
return (CUPS_BACKEND_FAILED);
}
+ tbytes = 0;
+
while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
if (cupsFileWrite(fp, buffer, bytes) < bytes)
{
unlink(tmpfilename);
return (CUPS_BACKEND_FAILED);
}
+ else
+ tbytes += bytes;
cupsFileClose(fp);
+ /*
+ * Don't try printing files less than 2 bytes...
+ */
+
+ if (tbytes <= 1)
+ {
+ _cupsLangPuts(stderr, _("ERROR: Empty print file!\n"));
+ unlink(tmpfilename);
+ return (CUPS_BACKEND_FAILED);
+ }
+
/*
* Point to the single file from stdin...
*/
*/
if ((snmp_fd = _cupsSNMPOpen(http->hostaddr->addr.sa_family)) >= 0)
+ {
if (backendSNMPSupplies(snmp_fd, http->hostaddr, &start_count, NULL))
{
/*
_cupsSNMPClose(snmp_fd);
snmp_fd = -1;
}
+ }
+ else
+ start_count = 0;
/*
* Build a URI for the printer and fill the standard IPP attributes for
*response; /* IPP response */
static const char * const attrs[] = /* Attributes we want */
{
+ "marker-colors",
+ "marker-levels",
+ "marker-message",
+ "marker-names",
+ "marker-types",
"printer-state-message",
"printer-state-reasons"
};
}
+/*
+ * 'report_attr()' - Report an IPP attribute value.
+ */
+
+static void
+report_attr(ipp_attribute_t *attr) /* I - Attribute */
+{
+ int i; /* Looping var */
+ char value[1024], /* Value string */
+ *valptr, /* Pointer into value string */
+ *attrptr; /* Pointer into attribute value */
+
+
+ /*
+ * Convert the attribute values into quoted strings...
+ */
+
+ for (i = 0, valptr = value;
+ i < attr->num_values && valptr < (value + sizeof(value) - 10);
+ i ++)
+ {
+ if (i > 0)
+ *valptr++ = ',';
+
+ switch (attr->value_tag)
+ {
+ case IPP_TAG_INTEGER :
+ case IPP_TAG_ENUM :
+ snprintf(valptr, sizeof(value) - (valptr - value), "%d",
+ attr->values[i].integer);
+ valptr += strlen(valptr);
+ break;
+
+ case IPP_TAG_TEXT :
+ case IPP_TAG_NAME :
+ case IPP_TAG_KEYWORD :
+ *valptr++ = '\"';
+ for (attrptr = attr->values[i].string.text;
+ *attrptr && valptr < (value + sizeof(value) - 10);
+ attrptr ++)
+ {
+ if (*attrptr == '\\' || *attrptr == '\"')
+ *valptr++ = '\\';
+
+ *valptr++ = *attrptr;
+ }
+ *valptr++ = '\"';
+ break;
+
+ default :
+ /*
+ * Unsupported value type...
+ */
+
+ return;
+ }
+ }
+
+ *valptr = '\0';
+
+ /*
+ * Tell the scheduler about the new values...
+ */
+
+ fprintf(stderr, "ATTR: %s=%s\n", attr->name, value);
+}
+
+
/*
* 'report_printer_state()' - Report the printer state.
*/
{
int i; /* Looping var */
int count; /* Count of reasons shown... */
- ipp_attribute_t *psm, /* pritner-state-message */
- *reasons; /* printer-state-reasons */
+ ipp_attribute_t *psm, /* printer-state-message */
+ *reasons, /* printer-state-reasons */
+ *marker; /* marker-* attributes */
const char *reason; /* Current reason */
const char *message; /* Message to show */
char unknown[1024]; /* Unknown message string */
fprintf(stderr, "%s\n", state);
+ /*
+ * Relay the current marker-* attribute values...
+ */
+
+ if ((marker = ippFindAttribute(ipp, "marker-colors", IPP_TAG_NAME)) != NULL)
+ report_attr(marker);
+ if ((marker = ippFindAttribute(ipp, "marker-levels",
+ IPP_TAG_INTEGER)) != NULL)
+ report_attr(marker);
+ if ((marker = ippFindAttribute(ipp, "marker-message", IPP_TAG_TEXT)) != NULL)
+ report_attr(marker);
+ if ((marker = ippFindAttribute(ipp, "marker-names", IPP_TAG_NAME)) != NULL)
+ report_attr(marker);
+ if ((marker = ippFindAttribute(ipp, "marker-types", IPP_TAG_KEYWORD)) != NULL)
+ report_attr(marker);
+
return (count);
}
main(int argc, /* I - Number of command-line arguments (6 or 7) */
char *argv[]) /* I - Command-line arguments */
{
+ const char *device_uri; /* Device URI */
char method[255], /* Method in URI */
hostname[1024], /* Hostname */
username[255], /* Username info */
* Extract the hostname and printer name from the URI...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+ if ((device_uri = cupsBackendDeviceURI(argv)) == NULL)
+ return (CUPS_BACKEND_FAILED);
+
+ httpSeparateURI(HTTP_URI_CODING_ALL, device_uri,
method, sizeof(method), username, sizeof(username),
hostname, sizeof(hostname), &port,
resource, sizeof(resource));
unlink(tmpfilename);
return (CUPS_BACKEND_FAILED);
}
-
- filename = tmpfilename;
}
else if (argc == 6)
{
*/
if ((snmp_fd = _cupsSNMPOpen(addr->addr.addr.sa_family)) >= 0)
+ {
if (backendSNMPSupplies(snmp_fd, &(addr->addr), &start_count, NULL))
{
/*
_cupsSNMPClose(snmp_fd);
snmp_fd = -1;
}
+ }
+ else
+ start_count = 0;
/*
* Check for side-channel requests...
*fullName, /* Full name */
*make_and_model; /* Make and model from TXT record */
cups_devtype_t type; /* Device registration type */
- int cups_shared, /* CUPS shared printer? */
+ int priority, /* Priority associated with type */
+ cups_shared, /* CUPS shared printer? */
sent; /* Did we list the device? */
} cups_device_t;
* Announce any devices we've found...
*/
+ cups_device_t *best; /* Best matching device */
char device_uri[1024]; /* Device URI */
int count; /* Number of queries */
static const char * const schemes[] =
/* URI schemes for devices */
- for (device = (cups_device_t *)cupsArrayFirst(devices), count = 0;
+ for (device = (cups_device_t *)cupsArrayFirst(devices),
+ best = NULL, count = 0;
device;
device = (cups_device_t *)cupsArrayNext(devices))
if (!device->ref && !device->sent)
DNSServiceRefDeallocate(device->ref);
device->ref = 0;
- httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
- schemes[device->type], NULL, device->fullName, 0,
- device->cups_shared ? "/cups" : "/");
+ if (!best)
+ best = device;
+ else if (strcasecmp(best->name, device->name) ||
+ strcasecmp(best->domain, device->domain))
+ {
+ httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
+ schemes[best->type], NULL, best->fullName, 0,
+ best->cups_shared ? "/cups" : "/");
+
+ printf("network %s \"%s\" \"%s\"\n", device_uri,
+ best->make_and_model ? best->make_and_model : "Unknown",
+ best->name);
+ fflush(stdout);
+
+ best->sent = 1;
+ best = device;
+ }
+ else if (best->priority > device->priority ||
+ (best->priority == device->priority &&
+ best->type < device->type))
+ {
+ best->sent = 1;
+ best = device;
+ }
+ else
+ device->sent = 1;
+ }
- printf("network %s \"%s\" \"%s\"\n", device_uri,
- device->make_and_model ? device->make_and_model : "Unknown",
- device->name);
- fflush(stdout);
+ if (best)
+ {
+ httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
+ schemes[best->type], NULL, best->fullName, 0,
+ best->cups_shared ? "/cups" : "/");
- device->sent = 1;
- }
+ printf("network %s \"%s\" \"%s\"\n", device_uri,
+ best->make_and_model ? best->make_and_model : "Unknown",
+ best->name);
+ fflush(stdout);
+
+ best->sent = 1;
+ }
}
}
}
* Resolve the device URI...
*/
- resolved_uri = cupsBackendDeviceURI(argv);
+ if ((resolved_uri = cupsBackendDeviceURI(argv)) == NULL)
+ exit(CUPS_BACKEND_FAILED);
/*
* Extract the scheme from the URI...
else
key.type = CUPS_DEVICE_RIOUSBPRINT;
- if ((device = cupsArrayFind(devices, &key)) != NULL)
- {
- /*
- * No, see if this registration is a higher priority protocol...
- */
+ for (device = cupsArrayFind(devices, &key);
+ device;
+ device = cupsArrayNext(devices))
+ if (strcasecmp(device->name, key.name) ||
+ strcasecmp(device->domain, key.domain))
+ break;
+ else if (device->type == key.type)
+ return (device);
- if (key.type > device->type)
- {
- fprintf(stderr, "DEBUG: Updating \"%s\" to \"%s.%s%s\"...\n",
- device->fullName, serviceName, regtype, replyDomain);
-
- device->type = key.type;
- }
- }
- else
- {
- /*
- * Yes, add the device...
- */
+ /*
+ * Yes, add the device...
+ */
- fprintf(stderr, "DEBUG: Found \"%s.%s%s\"...\n", serviceName, regtype,
- replyDomain);
+ fprintf(stderr, "DEBUG: Found \"%s.%s%s\"...\n", serviceName, regtype,
+ replyDomain);
- device = calloc(sizeof(cups_device_t), 1);
- device->name = strdup(serviceName);
- device->domain = strdup(replyDomain);
- device->type = key.type;
+ device = calloc(sizeof(cups_device_t), 1);
+ device->name = strdup(serviceName);
+ device->domain = strdup(replyDomain);
+ device->type = key.type;
+ device->priority = 50;
- cupsArrayAdd(devices, device);
- }
+ cupsArrayAdd(devices, device);
/*
- * Update the "full name" of this service, which is used for queries...
+ * Set the "full name" of this service, which is used for queries...
*/
snprintf(fullName, sizeof(fullName), "%s.%s%s", serviceName, regtype,
replyDomain);
-
- if (device->fullName)
- free(device->fullName);
-
device->fullName = strdup(fullName);
return (device);
if ((ptr = strstr(name, "._")) != NULL)
*ptr = '\0';
- if ((device = cupsArrayFind(devices, &key)) != NULL)
+ if (strstr(fullName, "_ipp._tcp.") ||
+ strstr(fullName, "_ipp-tls._tcp."))
+ key.type = CUPS_DEVICE_IPP;
+ else if (strstr(fullName, "_fax-ipp._tcp."))
+ key.type = CUPS_DEVICE_FAX_IPP;
+ else if (strstr(fullName, "_printer._tcp."))
+ key.type = CUPS_DEVICE_PRINTER;
+ else if (strstr(fullName, "_pdl-datastream._tcp."))
+ key.type = CUPS_DEVICE_PDL_DATASTREAM;
+ else
+ key.type = CUPS_DEVICE_RIOUSBPRINT;
+
+ for (device = cupsArrayFind(devices, &key);
+ device;
+ device = cupsArrayNext(devices))
{
- /*
- * Found it, pull out the make and model from the TXT record and save it...
- */
+ if (strcasecmp(device->name, key.name) ||
+ strcasecmp(device->domain, key.domain))
+ {
+ device = NULL;
+ break;
+ }
+ else if (device->type == key.type)
+ {
+ /*
+ * Found it, pull out the priority and make and model from the TXT
+ * record and save it...
+ */
- const void *value; /* Pointer to value */
- uint8_t valueLen; /* Length of value (max 255) */
- char make_and_model[512], /* Manufacturer and model */
- model[256]; /* Model */
+ const void *value; /* Pointer to value */
+ uint8_t valueLen; /* Length of value (max 255) */
+ char make_and_model[512], /* Manufacturer and model */
+ model[256], /* Model */
+ priority[256]; /* Priority */
- if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MFG",
- &valueLen)) == NULL)
- value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MANUFACTURER", &valueLen);
+ value = TXTRecordGetValuePtr(rdlen, rdata, "priority", &valueLen);
- if (value && valueLen)
- {
- memcpy(make_and_model, value, valueLen);
- make_and_model[valueLen] = '\0';
- }
- else
- make_and_model[0] = '\0';
+ if (value && valueLen)
+ {
+ memcpy(priority, value, valueLen);
+ priority[valueLen] = '\0';
+ device->priority = atoi(priority);
+ }
- if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MDL",
- &valueLen)) == NULL)
- value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MODEL", &valueLen);
+ if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MFG",
+ &valueLen)) == NULL)
+ value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MANUFACTURER",
+ &valueLen);
- if (value && valueLen)
- {
- memcpy(model, value, valueLen);
- model[valueLen] = '\0';
- }
- else if ((value = TXTRecordGetValuePtr(rdlen, rdata, "product",
- &valueLen)) != NULL && valueLen > 2)
- {
- if (((char *)value)[0] == '(')
+ if (value && valueLen)
{
- /*
- * Strip parenthesis...
- */
-
- memcpy(model, value + 1, valueLen - 2);
- model[valueLen - 2] = '\0';
+ memcpy(make_and_model, value, valueLen);
+ make_and_model[valueLen] = '\0';
}
else
+ make_and_model[0] = '\0';
+
+ if ((value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MDL",
+ &valueLen)) == NULL)
+ value = TXTRecordGetValuePtr(rdlen, rdata, "usb_MODEL", &valueLen);
+
+ if (value && valueLen)
{
memcpy(model, value, valueLen);
model[valueLen] = '\0';
}
-
- if (!strcasecmp(model, "GPL Ghostscript") ||
- !strcasecmp(model, "GNU Ghostscript") ||
- !strcasecmp(model, "ESP Ghostscript"))
+ else if ((value = TXTRecordGetValuePtr(rdlen, rdata, "product",
+ &valueLen)) != NULL && valueLen > 2)
{
- if ((value = TXTRecordGetValuePtr(rdlen, rdata, "ty",
- &valueLen)) != NULL)
- {
+ if (((char *)value)[0] == '(')
+ {
+ /*
+ * Strip parenthesis...
+ */
+
+ memcpy(model, value + 1, valueLen - 2);
+ model[valueLen - 2] = '\0';
+ }
+ else
+ {
memcpy(model, value, valueLen);
model[valueLen] = '\0';
+ }
- if ((ptr = strchr(model, ',')) != NULL)
- *ptr = '\0';
+ if (!strcasecmp(model, "GPL Ghostscript") ||
+ !strcasecmp(model, "GNU Ghostscript") ||
+ !strcasecmp(model, "ESP Ghostscript"))
+ {
+ if ((value = TXTRecordGetValuePtr(rdlen, rdata, "ty",
+ &valueLen)) != NULL)
+ {
+ memcpy(model, value, valueLen);
+ model[valueLen] = '\0';
+
+ if ((ptr = strchr(model, ',')) != NULL)
+ *ptr = '\0';
+ }
+ else
+ strcpy(model, "Unknown");
}
- else
- strcpy(model, "Unknown");
}
- }
- else
- strcpy(model, "Unknown");
+ else
+ strcpy(model, "Unknown");
- if (device->make_and_model)
- free(device->make_and_model);
+ if (device->make_and_model)
+ free(device->make_and_model);
- if (make_and_model[0])
- {
- strlcat(make_and_model, " ", sizeof(make_and_model));
- strlcat(make_and_model, model, sizeof(make_and_model));
- device->make_and_model = strdup(make_and_model);
- }
- else
- device->make_and_model = strdup(model);
+ if (make_and_model[0])
+ {
+ strlcat(make_and_model, " ", sizeof(make_and_model));
+ strlcat(make_and_model, model, sizeof(make_and_model));
+ device->make_and_model = strdup(make_and_model);
+ }
+ else
+ device->make_and_model = strdup(model);
- if ((device->type == CUPS_DEVICE_IPP ||
- device->type == CUPS_DEVICE_PRINTER) &&
- (value = TXTRecordGetValuePtr(rdlen, rdata, "printer-type",
- &valueLen)) != NULL)
- {
- /*
- * This is a CUPS printer!
- */
+ if ((device->type == CUPS_DEVICE_IPP ||
+ device->type == CUPS_DEVICE_PRINTER) &&
+ TXTRecordGetValuePtr(rdlen, rdata, "printer-type", &valueLen))
+ {
+ /*
+ * This is a CUPS printer!
+ */
- device->cups_shared = 1;
+ device->cups_shared = 1;
- if (device->type == CUPS_DEVICE_PRINTER)
- device->sent = 1;
+ if (device->type == CUPS_DEVICE_PRINTER)
+ device->sent = 1;
+ }
+
+ break;
}
}
- else
+
+ if (!device)
fprintf(stderr, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName);
}
*/
static int listDevices(void)
{
- int err = noErr;
int i;
int numberFound;
return -1; /* Network is down */
}
- if ((err = zip_getmyzone(ZIP_DEF_INTERFACE, &at_zone)) != 0)
+ if (zip_getmyzone(ZIP_DEF_INTERFACE, &at_zone))
{
_cupsLangPrintError(_("ERROR: Unable to get default AppleTalk zone"));
return -2;
at_inet_t sendDataAddr;
at_inet_t src;
at_resp_t resp;
- int userdata, xo, reqlen;
+ int userdata, xo = 0, reqlen;
u_short tid;
u_char bitmap;
int maxfdp1,
nbp_failures = 0;
struct timeval timeout, *timeoutPtr;
u_char flowQuantum = 1;
- u_short recvSequence = 0;
time_t now,
start_time,
elasped_time,
case AT_PAP_TYPE_SEND_DATA: /* Send-Data packet */
sendDataAddr.socket = src.socket;
gSendDataID = tid;
- recvSequence = OSReadBigInt16(&SEQUENCE_NUM(userdata), 0);
+ OSReadBigInt16(&SEQUENCE_NUM(userdata), 0);
if ((fileBufferNbytes > 0 || fileEOFRead) && fileEOFSent == false)
{
{
int result,
open_result,
- userdata,
- atp_err;
+ userdata;
time_t tm,
waitTime;
char data[10],
fprintf(stderr, "DEBUG: -> %s\n", packet_name(AT_PAP_TYPE_OPEN_CONN));
- if ((atp_err = atp_sendreq(*fd, &tuple->enu_addr, data, 4, userdata, 1, 0,
- 0, &resp, &retry, 0)) < 0)
+ if (atp_sendreq(*fd, &tuple->enu_addr, data, 4, userdata, 1, 0,
+ 0, &resp, &retry, 0) < 0)
{
statusUpdate("Destination unreachable", 23);
result = EHOSTUNREACH;
{
int fd;
u_short tmpID;
- int result;
unsigned char rdata[ATP_DATA_SIZE];
int userdata;
u_char *puserdata = (u_char *)&userdata;
resp.resp[0].iov_base = rdata;
resp.resp[0].iov_len = sizeof(rdata);
- result = atp_sendreq(fd, &gSessionAddr, 0, 0, userdata, 1, 0, 0, &resp, &retry, 0);
+ atp_sendreq(fd, &gSessionAddr, 0, 0, userdata, 1, 0, 0, &resp, &retry, 0);
- result = close(fd);
+ close(fd);
}
return noErr;
}
main(int argc, /* I - Number of command-line arguments (6 or 7) */
char *argv[]) /* I - Command-line arguments */
{
+ const char *device_uri; /* Device URI */
char method[255], /* Method in URI */
hostname[1024], /* Hostname */
username[255], /* Username info (not used) */
* Extract the hostname and port number from the URI...
*/
- httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv),
+ if ((device_uri = cupsBackendDeviceURI(argv)) == NULL)
+ return (CUPS_BACKEND_FAILED);
+
+ httpSeparateURI(HTTP_URI_CODING_ALL, device_uri,
method, sizeof(method), username, sizeof(username),
hostname, sizeof(hostname), &port,
resource, sizeof(resource));
*/
if ((snmp_fd = _cupsSNMPOpen(addr->addr.addr.sa_family)) >= 0)
+ {
if (backendSNMPSupplies(snmp_fd, &(addr->addr), &start_count, NULL))
{
/*
_cupsSNMPClose(snmp_fd);
snmp_fd = -1;
}
+ }
+ else
+ start_count = 0;
/*
* Print everything...
*
* "lpr" command for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
testtemplate.o: ../cups/versioning.h ../cups/ppd.h ../cups/array.h
testtemplate.o: ../cups/file.h ../cups/language.h ../cups/array.h
testtemplate.o: help-index.h
+websearch.o: cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
+websearch.o: ../cups/versioning.h ../cups/ppd.h ../cups/array.h
+websearch.o: ../cups/file.h ../cups/language.h ../cups/array.h help-index.h
# DO NOT DELETE
help-index.32.o: help-index.c cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
testtemplate.32.o: testtemplate.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h
testtemplate.32.o: testtemplate.c ../cups/file.h ../cups/language.h ../cups/array.h
testtemplate.32.o: testtemplate.c help-index.h
+websearch.32.o: websearch.c cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
+websearch.32.o: websearch.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h
+websearch.32.o: websearch.c ../cups/file.h ../cups/language.h ../cups/array.h help-index.h
# DO NOT DELETE
help-index.64.o: help-index.c cgi-private.h cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
testtemplate.64.o: testtemplate.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h
testtemplate.64.o: testtemplate.c ../cups/file.h ../cups/language.h ../cups/array.h
testtemplate.64.o: testtemplate.c help-index.h
+websearch.64.o: websearch.c cgi.h ../cups/cups.h ../cups/ipp.h ../cups/http.h
+websearch.64.o: websearch.c ../cups/versioning.h ../cups/ppd.h ../cups/array.h
+websearch.64.o: websearch.c ../cups/file.h ../cups/language.h ../cups/array.h help-index.h
printers.o \
testcgi.o \
testhi.o \
- testtemplate.o
+ testtemplate.o \
+ websearch.o
CGIS = \
admin.cgi \
classes.cgi \
$(LIB32CUPSCGI) \
$(LIB32CUPSCGI) \
testcgi \
- testhi
+ testhi \
+ websearch
TARGETS = \
$(LIBTARGETS) \
$(COMMONLIBS) $(SSLLIBS) $(LIBZ) $(LIBGSSAPI)
+#
+# websearch
+#
+
+websearch: websearch.o ../Makedefs libcupscgi.a ../cups/libcups.a
+ echo Linking $@...
+ $(CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ websearch.o libcupscgi.a \
+ ../cups/libcups.a $(COMMONLIBS) $(SSLLIBS) $(LIBZ) $(LIBGSSAPI)
+
+
#
# Dependencies...
#
return;
}
- else if (!file && (var = cgiGetVariable("PPD_NAME")) == NULL)
+ else if (!file && !cgiGetVariable("PPD_NAME"))
{
if (modify)
{
cgiSetVariable("KEYWORD", "job_sheets_start");
cgiSetVariable("KEYTEXT", cgiText(_("Starting Banner")));
- cgiSetVariable("DEFCHOICE", attr == NULL ?
- "" : attr->values[0].string.text);
+ cgiSetVariable("DEFCHOICE", attr != NULL ?
+ attr->values[0].string.text : "");
cgiCopyTemplateLang("option-pickone.tmpl");
cgiSetVariable("KEYWORD", "job_sheets_end");
cgiSetVariable("KEYTEXT", cgiText(_("Ending Banner")));
- cgiSetVariable("DEFCHOICE", attr == NULL && attr->num_values > 1 ?
- "" : attr->values[1].string.text);
+ cgiSetVariable("DEFCHOICE", attr != NULL && attr->num_values > 1 ?
+ attr->values[1].string.text : "");
cgiCopyTemplateLang("option-pickone.tmpl");
}
if ((var = cgiGetVariable("protocol")) != NULL)
- cupsFilePrintf(out, "*cupsProtocol: %s\n", cgiGetVariable("protocol"));
+ cupsFilePrintf(out, "*cupsProtocol: %s\n", var);
cupsFileClose(in);
cupsFileClose(out);
attr->values[1].string.text = _cupsStrAlloc(cgiGetVariable("job_sheets_end"));
if ((var = cgiGetVariable("printer_error_policy")) != NULL)
- attr = ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME,
- "printer-error-policy", NULL, var);
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME,
+ "printer-error-policy", NULL, var);
if ((var = cgiGetVariable("printer_op_policy")) != NULL)
- attr = ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME,
- "printer-op-policy", NULL, var);
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME,
+ "printer-op-policy", NULL, var);
/*
* Do the request and get back a response...
n2, n2->score, n2->section ? n2->section : "", n2->text));
if (n1->score != n2->score)
- return (n1->score - n2->score);
+ return (n2->score - n1->score);
if (n1->section && !n2->section)
return (1);
char *lword; /* Last word in query */
- DEBUG_printf(("help_compile_search(query=\"%s\")\n", query ? query : "(nil)"));
+ DEBUG_printf(("cgiCompileSearch(query=\"%s\")\n", query));
+
+ /*
+ * Range check input...
+ */
+
+ if (!query)
+ return (NULL);
/*
* Allocate a regular expression storage structure...
--- /dev/null
+/*
+ * "$Id$"
+ *
+ * Web search program for www.cups.org.
+ *
+ * Copyright 2007-2008 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
+ *
+ * These coded instructions, statements, and computer programs are the
+ * 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/".
+ *
+ * Usage:
+ *
+ * websearch directory "search string"
+ *
+ * Contents:
+ *
+ * main() - Search a directory of help files.
+ * list_nodes() - List matching nodes.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "cgi.h"
+
+
+/*
+ * Local functions...
+ */
+
+static void list_nodes(const char *title, cups_array_t *nodes);
+
+
+/*
+ * 'main()' - Test the help index code.
+ */
+
+int /* O - Exit status */
+main(int argc, /* I - Number of command-line args */
+ char *argv[]) /* I - Command-line arguments */
+{
+ help_index_t *hi, /* Help index */
+ *search; /* Search index */
+ char indexname[1024]; /* Name of index file */
+
+
+ if (argc != 3)
+ {
+ puts("Usage: websearch directory \"search terms\"");
+ return (1);
+ }
+
+ /*
+ * Load the help index...
+ */
+
+ snprintf(indexname, sizeof(indexname), "%s/.index", argv[1]);
+ hi = helpLoadIndex(indexname, argv[1]);
+
+ /*
+ * Do any searches...
+ */
+
+ search = helpSearchIndex(hi, argv[2], NULL, NULL);
+
+ if (search)
+ list_nodes(argv[1], search->sorted);
+
+ /*
+ * Return with no errors...
+ */
+
+ return (0);
+}
+
+
+/*
+ * 'list_nodes()' - List nodes in an array...
+ */
+
+static void
+list_nodes(const char *title, /* I - Title string */
+ cups_array_t *nodes) /* I - Nodes */
+{
+ help_node_t *node; /* Current node */
+
+
+ printf("%d\n", cupsArrayCount(nodes));
+ for (node = (help_node_t *)cupsArrayFirst(nodes);
+ node;
+ node = (help_node_t *)cupsArrayNext(nodes))
+ {
+ if (node->anchor)
+ printf("%d|%s#%s|%s\n", node->score, node->filename, node->anchor,
+ node->text);
+ else
+ printf("%d|%s|%s\n", node->score, node->filename, node->text);
+ }
+}
+
+
+/*
+ * End of "$Id$".
+ */
# file.
#
-# Log general information in error_log - change "info" to "debug" for
-# troubleshooting...
-LogLevel info
+# Log general information in error_log - change "@CUPS_LOG_LEVEL@" to "debug"
+# for troubleshooting...
+LogLevel @CUPS_LOG_LEVEL@
# Administrator user group...
SystemGroup @CUPS_SYSTEM_GROUPS@
AC_CHECK_FUNCS(notify_post)
dnl Check for Authorization Services support
+ AC_ARG_WITH(adminkey, [ --with-adminkey set the default SystemAuthKey value],
+ default_adminkey="$withval",
+ default_adminkey="default")
+ AC_ARG_WITH(operkey, [ --with-operkey set the default operator @AUTHKEY value],
+ default_operkey="$withval",
+ default_operkey="default")
+
AC_CHECK_HEADER(Security/Authorization.h, [
AC_DEFINE(HAVE_AUTHORIZATION_H)
- if grep -q system.print.operator /etc/authorization; then
- CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
- CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
+
+ if test "x$default_adminkey" != xdefault; then
+ CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey $default_adminkey"
+ elif grep -q system.print.operator /etc/authorization; then
+ CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
else
+ CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.preferences"
+ fi
+
+ if test "x$default_operkey" != xdefault; then
+ CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY($default_operkey) @admin @lpadmin"
+ elif grep -q system.print.operator /etc/authorization; then
CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.operator) @admin @lpadmin"
- CUPS_SYSTEM_AUTHKEY="SystemGroupAuthKey system.print.admin"
+ else
+ CUPS_DEFAULT_PRINTADMIN_AUTH="@AUTHKEY(system.print.admin) @admin @lpadmin"
fi])
AC_CHECK_HEADER(Security/SecBasePriv.h,AC_DEFINE(HAVE_SECBASEPRIV_H))
AC_SUBST(CUPS_LOG_FILE_PERM)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, 0$CUPS_LOG_FILE_PERM)
+dnl Default LogLevel
+AC_ARG_WITH(log_level, [ --with-log-level set default LogLevel value, default=warn],
+ CUPS_LOG_LEVEL="$withval",
+ CUPS_LOG_LEVEL="warn")
+AC_SUBST(CUPS_LOG_LEVEL)
+AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_LEVEL, "$CUPS_LOG_LEVEL")
+
+dnl Default AccessLogLevel
+AC_ARG_WITH(log_level, [ --with-access-log-level set default AccessLogLevel value, default=actions],
+ CUPS_LOG_LEVEL="$withval",
+ CUPS_LOG_LEVEL="actions")
+AC_SUBST(CUPS_ACCESS_LOG_LEVEL)
+AC_DEFINE_UNQUOTED(CUPS_DEFAULT_ACCESS_LOG_LEVEL, "$CUPS_ACCESS_LOG_LEVEL")
+
dnl Default Browsing
AC_ARG_ENABLE(browsing, [ --enable-browsing enable Browsing by default, default=yes])
if test "x$enable_browsing" = xno; then
#define CUPS_DEFAULT_LOG_FILE_PERM 0644
+/*
+ * Default logging settings...
+ */
+
+#define CUPS_DEFAULT_LOG_LEVEL "warn"
+#define CUPS_DEFAULT_ACCESS_LOG_LEVEL "actions"
+
+
/*
* Default browsing settings...
*/
{
write_option(dstfp, jclorder ++, "cupsJobSheetsStart", "Start Banner",
"job-sheets", suppattr, defattr, 0, 2);
- write_option(dstfp, jclorder ++, "cupsJobSheetsEnd", "End Banner",
+ write_option(dstfp, jclorder, "cupsJobSheetsEnd", "End Banner",
"job-sheets", suppattr, defattr, 1, 2);
}
if (!value && strncmp(line, "</", 2))
value = line + strlen(line);
- if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen"))
+ if ((!strcasecmp(line, "Port") || !strcasecmp(line, "Listen")) && value)
{
char *port; /* Pointer to port number, if any */
{
in_policy = 0;
}
- else if (!strcasecmp(line, "<Limit") && in_policy)
+ else if (!strcasecmp(line, "<Limit") && in_policy && value)
{
/*
* See if the policy limit is for the Cancel-Job operation...
{
cancel_policy = 0;
}
- else if (!strcasecmp(line, "<Location"))
+ else if (!strcasecmp(line, "<Location") && value)
{
in_admin_location = !strcasecmp(value, "/admin");
in_location = 1;
in_admin_location = 0;
in_location = 0;
}
- else if (!strcasecmp(line, "Allow") &&
+ else if (!strcasecmp(line, "Allow") && value &&
strcasecmp(value, "localhost") && strcasecmp(value, "127.0.0.1")
#ifdef AF_LOCAL
&& *value != '/'
* Get the cupsd.conf file...
*/
- if ((status = get_cupsd_conf(http, cg, 0, cupsdconf, sizeof(cupsdconf),
- &remote)) == HTTP_OK)
+ if (get_cupsd_conf(http, cg, 0, cupsdconf, sizeof(cupsdconf),
+ &remote) == HTTP_OK)
{
if ((cupsd = cupsFileOpen(cupsdconf, "r")) == NULL)
{
else
{
cupsFilePuts(temp, "# Show general information in error_log.\n");
- cupsFilePuts(temp, "LogLevel info\n");
+ cupsFilePuts(temp, "LogLevel " CUPS_DEFAULT_LOG_LEVEL "\n");
}
}
else if (!strcasecmp(line, "<Policy"))
else
{
cupsFilePuts(temp, "# Show general information in error_log.\n");
- cupsFilePuts(temp, "LogLevel info\n");
+ cupsFilePuts(temp, "LogLevel " CUPS_DEFAULT_LOG_LEVEL "\n");
}
}
if (http->gssctx != GSS_C_NO_CONTEXT)
{
- major_status = gss_delete_sec_context(&minor_status, &http->gssctx,
- GSS_C_NO_BUFFER);
+ gss_delete_sec_context(&minor_status, &http->gssctx, GSS_C_NO_BUFFER);
http->gssctx = GSS_C_NO_CONTEXT;
}
httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value,
output_token.length);
- major_status = gss_release_buffer(&minor_status, &output_token);
+ gss_release_buffer(&minor_status, &output_token);
}
else
{
DEBUG_printf(("cupsDoAuthentication: Kerberos credentials too large - "
"%d bytes!\n", (int)output_token.length));
- major_status = gss_release_buffer(&minor_status, &output_token);
+ gss_release_buffer(&minor_status, &output_token);
return (-1);
}
&major_status_string);
if (!GSS_ERROR(err_major_status))
- err_major_status = gss_display_status(&err_minor_status,
- minor_status,
- GSS_C_MECH_CODE,
- GSS_C_NULL_OID,
- &msg_ctx,
- &minor_status_string);
+ gss_display_status(&err_minor_status, minor_status, GSS_C_MECH_CODE,
+ GSS_C_NULL_OID, &msg_ctx, &minor_status_string);
printf("%s: %s, %s\n", message, (char *)major_status_string.value,
(char *)minor_status_string.value);
}
return (_httpResolveURI(device_uri, cg->resolved_uri,
- sizeof(cg->resolved_uri)));
+ sizeof(cg->resolved_uri), 1));
}
{
char *bufptr, /* Pointer to position in buffer */
*bufend, /* Pointer to end of buffer */
- sign, /* Sign of format width */
size, /* Size character (h, l, L) */
type; /* Format type character */
int width, /* Width of field */
int bytes; /* Total number of bytes needed */
+ if (!buffer || bufsize < 2 || !format)
+ return (-1);
+
/*
* Loop through the format string, formatting as needed...
*/
if (*format == '%')
{
- if (bufptr && bufptr < bufend) *bufptr++ = *format;
+ if (bufptr < bufend)
+ *bufptr++ = *format;
bytes ++;
format ++;
continue;
}
else if (strchr(" -+#\'", *format))
- {
- *tptr++ = *format;
- sign = *format++;
- }
- else
- sign = 0;
+ *tptr++ = *format++;
if (*format == '*')
{
}
}
}
- else
- prec = -1;
if (*format == 'l' && format[1] == 'l')
{
size = *format++;
}
+ else
+ size = 0;
if (!*format)
break;
{
bytes ++;
- if (bufptr && bufptr < bufend)
+ if (bufptr < bufend)
*bufptr++ = *format;
format ++;
if (!name || !dests)
return (0);
- if ((dest = cupsGetDest(name, instance, num_dests, *dests)) != NULL)
+ if (cupsGetDest(name, instance, num_dests, *dests))
return (num_dests);
/*
DEBUG_puts("appleGetDefault: Missing or bad location history array...");
- CFRelease(network);
return (NULL);
}
else
name[0] = '\0';
- CFRelease(locations);
- CFRelease(network);
-
DEBUG_printf(("appleGetDefault: Returning \"%s\"...\n", name));
return (*name ? name : NULL);
CFRelease(newlocation);
}
- if (locations)
- CFRelease(locations);
- CFRelease(network);
CFRelease(newprinter);
}
if (addr)
addr->next = temp;
- else
- addr = temp;
}
}
else if (!hostname)
if (addr)
addr->next = temp;
- else
- addr = temp;
}
}
}
extern char *_httpEncodeURI(char *dst, const char *src,
size_t dstsize);
extern const char *_httpResolveURI(const char *uri, char *resolved_uri,
- size_t resolved_size);
+ size_t resolved_size, int log);
#endif /* !_CUPS_HTTP_PRIVATE_H_ */
/*
_httpResolveURI(
const char *uri, /* I - DNS-SD URI */
char *resolved_uri, /* I - Buffer for resolved URI */
- size_t resolved_size) /* I - Size of URI buffer */
+ size_t resolved_size, /* I - Size of URI buffer */
+ int log) /* I - Log progress to stderr? */
{
char scheme[32], /* URI components... */
userpass[256],
hostname[1024],
resource[1024];
int port;
+ http_uri_status_t status; /* URI decode status */
+ DEBUG_printf(("_httpResolveURI(uri=\"%s\", resolved_uri=%p, "
+ "resolved_size=" CUPS_LLFMT ")\n", uri, resolved_uri,
+ CUPS_LLCAST resolved_size));
+
/*
* Get the device URI...
*/
- if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, sizeof(scheme),
- userpass, sizeof(userpass), hostname, sizeof(hostname),
- &port, resource, sizeof(resource)) < HTTP_URI_OK)
+ if ((status = httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme,
+ sizeof(scheme), userpass, sizeof(userpass),
+ hostname, sizeof(hostname), &port, resource,
+ sizeof(resource))) < HTTP_URI_OK)
+ {
+ if (log)
+ _cupsLangPrintf(stderr, _("Bad device URI \"%s\"!\n"), uri);
+
+ DEBUG_printf(("_httpResolveURI: httpSeparateURI returned %d!\n", status));
+ DEBUG_puts("_httpResolveURI: Returning NULL");
return (NULL);
+ }
/*
* Resolve it as needed...
* Separate the hostname into service name, registration type, and domain...
*/
- regtype = strchr(hostname, '.');
- *regtype++ = '\0';
+ for (regtype = strstr(hostname, "._tcp") - 2;
+ regtype > hostname;
+ regtype --)
+ if (regtype[0] == '.' && regtype[1] == '_')
+ {
+ /*
+ * Found ._servicetype in front of ._tcp...
+ */
+
+ *regtype++ = '\0';
+ break;
+ }
+
+ if (regtype <= hostname)
+ {
+ DEBUG_puts("_httpResolveURI: Bad hostname, returning NULL");
+ return (NULL);
+ }
domain = regtype + strlen(regtype) - 1;
if (domain > regtype && *domain == '.')
resolved_uri[0] = '\0';
+ DEBUG_printf(("_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
+ "domain=\"%s\"\n", hostname, regtype, domain));
+ if (log)
+ {
+ fputs("STATE: +connecting-to-device\n", stderr);
+ _cupsLangPrintf(stderr, _("INFO: Looking for \"%s\"...\n"), hostname);
+ }
+
if (DNSServiceResolve(&ref, 0, 0, hostname, regtype, domain,
resolve_callback,
&uribuf) == kDNSServiceErr_NoError)
DNSServiceRefDeallocate(ref);
}
else
-#endif /* HAVE_DNSSD */
+ uri = NULL;
+
+ if (log)
+ fputs("STATE: -connecting-to-device\n", stderr);
+
+#else
+ /*
+ * No DNS-SD support...
+ */
uri = NULL;
+#endif /* HAVE_DNSSD */
+
+ if (log && !uri)
+ _cupsLangPuts(stderr, _("Unable to find printer!\n"));
}
+ DEBUG_printf(("_httpResolveURI: Returning \"%s\"\n", uri));
+
return (uri);
}
httpClose(http_t *http) /* I - Connection to server */
{
#ifdef HAVE_GSSAPI
- OM_uint32 minor_status, /* Minor status code */
- major_status; /* Major status code */
+ OM_uint32 minor_status; /* Minor status code */
#endif /* HAVE_GSSAPI */
#ifdef HAVE_GSSAPI
if (http->gssctx != GSS_C_NO_CONTEXT)
- major_status = gss_delete_sec_context(&minor_status, &http->gssctx,
- GSS_C_NO_BUFFER);
+ gss_delete_sec_context(&minor_status, &http->gssctx, GSS_C_NO_BUFFER);
if (http->gssname != GSS_C_NO_NAME)
- major_status = gss_release_name(&minor_status, &http->gssname);
+ gss_release_name(&minor_status, &http->gssname);
#endif /* HAVE_GSSAPI */
#ifdef HAVE_AUTHORIZATION_H
* Get the request header...
*/
- if ((n = (*cb)(src, buffer, 8)) < 8)
+ if ((*cb)(src, buffer, 8) < 8)
{
- DEBUG_printf(("ippReadIO: Unable to read header (%d bytes read)!\n", n));
+ DEBUG_puts("ippReadIO: Unable to read header!");
return (IPP_ERROR);
}
return (IPP_ERROR);
}
+ if (!value)
+ {
+ DEBUG_puts("ippReadIO: NULL value!");
+ return (IPP_ERROR);
+ }
+
value->unknown.length = n;
if (n > 0)
{
* Format the message...
*/
- bytes = snprintf(buffer, sizeof(buffer), "%s: %s",
- _cupsLangString(cg->lang_default, message),
- strerror(last_errno));
+ snprintf(buffer, sizeof(buffer), "%s: %s",
+ _cupsLangString(cg->lang_default, message), strerror(last_errno));
/*
* Convert and write to stderr...
*/
va_start(ap, message);
- bytes = vsnprintf(buffer, sizeof(buffer),
- _cupsLangString(cg->lang_default, message), ap);
+ vsnprintf(buffer, sizeof(buffer),
+ _cupsLangString(cg->lang_default, message), ap);
va_end(ap);
/*
else if (!strcmp(string, "Plus90"))
ppd->landscape = 90;
}
- else if (!strcmp(keyword, "Emulators"))
+ else if (!strcmp(keyword, "Emulators") && string)
{
for (count = 1, sptr = string; sptr != NULL;)
if ((sptr = strchr(sptr, ' ')) != NULL)
if (ch == 0x0a)
cupsFileGetChar(fp);
}
-
- ch = '\n';
}
else if (ch < ' ' && ch != '\t' && cg->ppd_conform == PPD_CONFORM_STRICT)
{
* Loop until we can send the request without authorization problems.
*/
- status = HTTP_ERROR;
expect = HTTP_CONTINUE;
for (;;)
*status = CUPS_SC_STATUS_TOO_BIG;
}
- else if (templen > *datalen || templen > (bytes - 4))
+ else if (!datalen || templen > *datalen || templen > (bytes - 4))
{
/*
* Either the response is bigger than the provided buffer or the
if (argc > 1)
{
- for (i = 1, num_settings = 0; i < argc; i ++)
+ for (i = 1, num_settings = 0, settings = NULL; i < argc; i ++)
num_settings = cupsParseOptions(argv[i], num_settings, &settings);
if (cupsAdminSetServerSettings(http, num_settings, settings))
*
* CUPS API test program for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
if ((dest = cupsGetDest(dests[num_dests / 2].name, NULL, num_dests,
dests)) == NULL)
{
- status = 1;
puts("FAIL");
return (1);
}
if (cupsPrintFile(dest->name, "../data/testprint.ps", "Test Page",
dest->num_options, dest->options) <= 0)
{
- status = 1;
puts("FAIL");
+ return (1);
}
else
puts("PASS");
if ((ppdfile = cupsGetPPD(dest->name)) == NULL)
{
- status = 1;
puts("FAIL");
}
else
if (a == b)
return (1);
- if ((!a && b) || (a && !b))
+ if (!a || !b)
return (0);
if (strcasecmp(a->name, b->name) ||
/*
- * End of "$Id: testfile.c 6192 2007-01-10 19:26:48Z mike $".
+ * End of "$Id$".
*/
* Do uncompressed random I/O tests...
*/
- status = random_tests();
+ status += random_tests();
/*
* Test fdopen and close without reading...
*
* HTTP test program for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
#include <stdio.h>
#include <stdlib.h>
-#include "http.h"
+#include "http-private.h"
#include "string.h"
return (failures);
}
+ else if (strstr(argv[1], "._tcp"))
+ {
+ /*
+ * Test resolving an mDNS name.
+ */
+
+ char resolved[1024]; /* Resolved URI */
+
+
+ printf("_httpResolveURI(%s): ", argv[1]);
+ fflush(stdout);
+
+ if (!_httpResolveURI(argv[1], resolved, sizeof(resolved)))
+ {
+ puts("FAIL");
+ return (1);
+ }
+ else
+ {
+ printf("PASS (%s)\n", resolved);
+ return (0);
+ }
+ }
/*
* Test HTTP GET requests...
Comment[pl]=Interfejs WWW CUPS
Name[it]=Gestione stampa
Comment[it]=Interfaccia web di CUPS
+Name[ja]=印刷の管理
+Comment[ja]=CUPS Web インタフェース
Name[he]=נהל הדפסות
Comment[he]=ממשק דפדפן של CUPS
Name[zh_TW]=印表管理
<VAR>@CUPS_LOGDIR@/access_log</VAR>.</P>
+<H2 CLASS="title"><A NAME="AccessLogLevel">AccessLogLevel</A></H2>
+
+<H3>Examples</H3>
+
+<PRE CLASS="command">
+AccessLogLevel config
+AccessLogLevel actions
+AccessLogLevel all
+</PRE>
+
+<H3>Description</H3>
+
+<P>The <CODE>AccessLogLevel</CODE> directive controls which requests are logged
+to the access log file. The following levels are defined:</P>
+
+<UL>
+
+ <LI><CODE>config</CODE>; Log when printers and classes are added,
+ deleted, or modified and when configuration files are accessed or
+ updated.</LI>
+
+ <LI><CODE>actions</CODE>; Log when print jobs are submitted,
+ held, released, modified, or canceled, and any of the conditions
+ for <CODE>config</CODE>.</LI>
+
+ <LI><CODE>all</CODE>; Log all requests.</LI>
+
+</UL>
+
+<P>The default access log level is <CODE>@CUPS_ACCESS_LOG_LEVEL@</CODE>.</P>
+
+
<H2 CLASS="title"><A NAME="Allow">Allow</A></H2>
<H3>Examples</H3>
<LI><CODE>notice</CODE> - Log temporary error conditions</LI>
<LI><CODE>info</CODE> - Log all requests and state
- changes (default)</LI>
+ changes</LI>
<LI><CODE>debug</CODE> - Log basic debugging
information</LI>
</UL>
+<p>The default <code>LogLevel</code> is <code>@CUPS_LOG_LEVEL@</code>.</p>
+
<H2 CLASS="title"><A NAME="MaxClients">MaxClients</A></H2>
*
* CMYK color separation code for CUPS.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1993-2005 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
{
int k; /* Current black value */
const short **channels; /* Copy of channel LUTs */
- const unsigned char *black_lut, /* Black LUT */
- *color_lut; /* Color LUT */
int ink, /* Amount of ink */
ink_limit; /* Ink limit from separation */
*/
channels = (const short **)cmyk->channels;
- black_lut = cmyk->black_lut;
- color_lut = cmyk->color_lut;
ink_limit = cmyk->ink_limit;
switch (cmyk->num_channels)
y, /* Current yellow value */
k; /* Current black value */
const short **channels; /* Copy of channel LUTs */
- const unsigned char *black_lut, /* Black LUT */
- *color_lut; /* Color LUT */
int ink, /* Amount of ink */
ink_limit; /* Ink limit from separation */
*/
channels = (const short **)cmyk->channels;
- black_lut = cmyk->black_lut;
- color_lut = cmyk->color_lut;
ink_limit = cmyk->ink_limit;
switch (cmyk->num_channels)
int k, /* Current black value */
kc; /* Current black color value */
const short **channels; /* Copy of channel LUTs */
- const unsigned char *black_lut, /* Black LUT */
- *color_lut; /* Color LUT */
int ink, /* Amount of ink */
ink_limit; /* Ink limit from separation */
*/
channels = (const short **)cmyk->channels;
- black_lut = cmyk->black_lut;
- color_lut = cmyk->color_lut;
ink_limit = cmyk->ink_limit;
switch (cmyk->num_channels)
kc, /* Current black color value */
km; /* Maximum black value */
const short **channels; /* Copy of channel LUTs */
- const unsigned char *black_lut, /* Black LUT */
- *color_lut; /* Color LUT */
int ink, /* Amount of ink */
ink_limit; /* Ink limit from separation */
*/
channels = (const short **)cmyk->channels;
- black_lut = cmyk->black_lut;
- color_lut = cmyk->color_lut;
ink_limit = cmyk->ink_limit;
switch (cmyk->num_channels)
band->buffer = calloc(DotRowCount, DotBufferSize);
}
+ if (!DotAvailList)
+ {
+ fputs("ERROR: Unable to allocate band list!\n", stderr);
+ exit(1);
+ }
+
fputs("DEBUG: Pointer list at start of page...\n", stderr);
for (band = DotAvailList; band != NULL; band = band->next)
* Perform the color separation...
*/
- offset = 0;
width = header->cupsWidth;
subwidth = header->cupsWidth / DotColStep;
xstep = 3600 / header->HWResolution[0];
*
* Colorspace conversions for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1993-2006 by Easy Software Products.
*
* The color saturation/hue matrix stuff is provided thanks to Mr. Paul
static cups_clut_t *lut = NULL; /* Lookup table for matrix */
- if (saturation != last_sat ||
- hue != last_hue)
+ if (saturation != last_sat || hue != last_hue || !lut)
{
/*
* Build the color adjustment matrix...
lastbit = last_byte * 8;
}
- ret = 0;
for (ret = 0, i = curbit + code_size - 1, j = code_size;
j > 0;
i --, j --)
return (firstcode);
}
+ else if (!table)
+ return (0);
if (sp > stack)
return (*--sp);
*/
if (!JobCanceled)
- linelen = copy_trailer(fp, doc, ppd, number, line, linelen, linesize);
+ copy_trailer(fp, doc, ppd, number, line, linelen, linesize);
}
char name[255], /* Option name */
value[255]; /* Option value */
ppd_option_t *option; /* Option in file */
- ppd_choice_t *choice; /* Choice */
/*
return (num_options);
}
- if ((choice = ppdFindChoice(option, value)) == NULL)
+ if (!ppdFindChoice(option, value))
{
fprintf(stderr, _("WARNING: Unknown choice \"%s\" for option \"%s\"!\n"),
value, name + 1);
w / bboxw, l / bboxl);
}
else
- {
w = PageWidth;
- l = PageLength;
- }
break;
case 2 :
*plast; /* Pointer to last pixel */
unsigned char *wptr; /* Pointer into write buffer */
int bpp, /* Bytes per pixel */
- count, /* Count */
- maxrun; /* Maximum run of 128 * bpp */
+ count; /* Count */
DEBUG_printf(("cups_raster_write(r=%p, pixels=%p)\n", r, pixels));
plast = pend - bpp;
wptr = r->buffer;
*wptr++ = r->count - 1;
- maxrun = 128 * bpp;
/*
* Write using a modified TIFF "packbits" compression...
comp_ptr += count;
}
- line_ptr = CompBuffer;
- line_end = comp_ptr;
-
/*
* Set the length of the data and write it...
*/
/*
- * "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $"
+ * "$Id$"
*
* Image library test program for the Common UNIX Printing System (CUPS).
*
/*
- * End of "$Id: testimage.c 4485 2005-01-03 19:30:00Z mike $".
+ * End of "$Id$".
*/
*
* Text to PostScript filter for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1993-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
lchar_t *start; /* First character in sequence */
- for (col = 0, start = line; col < SizeColumns;)
+ for (col = 0; col < SizeColumns;)
{
while (col < SizeColumns && (line->ch == ' ' || line->ch == 0))
{
if (*bufptr != '\"')
continue;
- *bufptr++ = '\0';
+ *bufptr = '\0';
return (1);
}
.br
Defines the access log filename.
.TP 5
+AccessLogLevel config
+.TP 5
+AccessLogLevel actions
+.TP 5
+AccessLogLevel all
+.br
+Specifies the logging level for the AccessLog file.
+.TP 5
Allow all
.TP 5
Allow none
*
* Man page to HTML conversion program.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 2004-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
if (blist)
{
fputs("</li>\n</ul>\n", outfile);
- blist = 0;
}
if (list)
fputs("</dd>\n", outfile);
fputs("</dl>\n", outfile);
- list = 0;
}
fputs("</body>\n"
f 0755 root sys $SERVERBIN/daemon/cups-driverd scheduler/cups-driverd
f 0755 root sys $SERVERBIN/daemon/cups-polld scheduler/cups-polld
d 0755 root sys $SERVERBIN/driver -
-f 0755 root sys $SERVERBIN/driver/drv ppdc/drv
d 0755 root sys $SERVERBIN/filter -
f 0755 root sys $SERVERBIN/filter/commandtoespcx driver/commandtoescpx
f 0755 root sys $SERVERBIN/filter/commandtopclx driver/commandtopclx
/usr/lib/cups/daemon/cups-driverd
/usr/lib/cups/daemon/cups-polld
%dir /usr/lib/cups/driver
-/usr/lib/cups/driver/drv
%dir /usr/lib/cups/filter
/usr/lib/cups/filter/*
%dir /usr/lib/cups/monitor
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);
}
}
valueptr ++);
if (*valueptr)
- *valueptr++ = '\0';
+ *valueptr = '\0';
cupsdSetString(&p->job_sheets[1], value);
}
cupsdLogMessage(CUPSD_LOG_WARN,
"Possible DoS attack - more than %d clients connecting "
"from %s!",
- MaxClientsPerHost, tempcon->http.hostname);
+ MaxClientsPerHost, con->http.hostname);
}
#ifdef WIN32
ssl_options; /* SSL Option for hostname */
- if ((err = SecPolicySearchCreate(CSSM_CERT_X_509v3, &CSSMOID_APPLE_TP_SSL,
- NULL, &policy_search)))
+ if (SecPolicySearchCreate(CSSM_CERT_X_509v3, &CSSMOID_APPLE_TP_SSL,
+ NULL, &policy_search))
{
cupsdLogMessage(CUPSD_LOG_ERROR, "Cannot create a policy search reference");
CFRelease(keychain);
return (NULL);
}
- if ((err = SecPolicySearchCopyNext(policy_search, &policy)))
+ if (SecPolicySearchCopyNext(policy_search, &policy))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Cannot find a policy to use for searching");
options.Data = (uint8 *)&ssl_options;
options.Length = sizeof(ssl_options);
- if ((err = SecPolicySetValue(policy, &options)))
+ if (SecPolicySetValue(policy, &options))
{
cupsdLogMessage(CUPSD_LOG_ERROR,
"Cannot set policy value to use for searching");
cupsdSetString(&con->command, filename);
- filename = strrchr(filename, '/') + 1; /* Filename always absolute */
-
if (options)
cupsdSetStringf(&con->options, " %s", options);
* Numeric options...
*/
+ AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS;
ConfigFilePerm = CUPS_DEFAULT_CONFIG_FILE_PERM;
DefaultAuthType = CUPSD_AUTH_BASIC;
#ifdef HAVE_SSL
KeepAliveTimeout = DEFAULT_KEEPALIVE;
ListenBackLog = SOMAXCONN;
LogFilePerm = CUPS_DEFAULT_LOG_FILE_PERM;
- LogLevel = CUPSD_LOG_ERROR;
+ LogLevel = CUPSD_LOG_WARN;
MaxClients = 100;
MaxClientsPerHost = 0;
MaxLogSize = 1024 * 1024;
cupsdLogMessage(CUPSD_LOG_WARN, "Unknown HostNameLookups %s on line %d.",
value, linenum);
}
+ else if (!strcasecmp(line, "AccessLogLevel") && value)
+ {
+ /*
+ * Amount of logging to do to access log...
+ */
+
+ if (!strcasecmp(value, "all"))
+ AccessLogLevel = CUPSD_ACCESSLOG_ALL;
+ else if (!strcasecmp(value, "actions"))
+ AccessLogLevel = CUPSD_ACCESSLOG_ACTIONS;
+ else if (!strcasecmp(value, "config"))
+ AccessLogLevel = CUPSD_ACCESSLOG_CONFIG;
+ else
+ cupsdLogMessage(CUPSD_LOG_WARN, "Unknown AccessLogLevel %s on line %d.",
+ value, linenum);
+ }
else if (!strcasecmp(line, "LogLevel") && value)
{
/*
- * Amount of logging to do...
+ * Amount of logging to do to error log...
*/
if (!strcasecmp(value, "debug2"))
* Configuration file definitions for the Common UNIX Printing System (CUPS)
* scheduler.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
CUPSD_LOG_DEBUG2 /* Detailed debugging */
} cupsd_loglevel_t;
+typedef enum
+{
+ CUPSD_ACCESSLOG_CONFIG, /* Log config requests */
+ CUPSD_ACCESSLOG_ACTIONS, /* Log config, print, and job management requests */
+ CUPSD_ACCESSLOG_ALL /* Log everything */
+} cupsd_accesslog_t;
+
/*
* Printcap formats...
/* User ID for server */
VAR gid_t Group VALUE(0);
/* Group ID for server */
-VAR int ClassifyOverride VALUE(0),
+VAR int AccessLogLevel VALUE(CUPSD_ACCESSLOG_ACTIONS),
+ /* Access log level */
+ ClassifyOverride VALUE(0),
/* Allow overrides? */
ConfigFilePerm VALUE(0640),
/* Permissions for config files */
LogFilePerm VALUE(0644),
/* Permissions for log files */
- LogLevel VALUE(CUPSD_LOG_ERROR),
- /* Log level */
+ LogLevel VALUE(CUPSD_LOG_WARN),
+ /* Error log level */
MaxClients VALUE(0),
/* Maximum number of clients */
MaxClientsPerHost VALUE(0),
const char *device_uri, /* I - Device URI */
const char *device_id) /* I - 1284 device ID */
{
- cupsd_device_t *device, /* New device */
- *temp; /* Found device */
+ cupsd_device_t *device; /* New device */
/*
* Add the device to the array and return...
*/
- if ((temp = cupsArrayFind(devices, device)) != NULL)
+ if (cupsArrayFind(devices, device))
{
/*
* Avoid duplicates!
break;
case 0x05 : /* Remove jobs */
- /*
- * Grab the agent and skip to the list of users and/or jobs.
- */
+ if (list)
+ {
+ /*
+ * Grab the agent and skip to the list of users and/or jobs.
+ */
- agent = list;
+ agent = list;
- for (; *list && !isspace(*list & 255); list ++);
- while (isspace(*list & 255))
- *list++ = '\0';
+ for (; *list && !isspace(*list & 255); list ++);
+ while (isspace(*list & 255))
+ *list++ = '\0';
- syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent);
+ syslog(LOG_INFO, "Remove jobs %s on %s by %s", list, dest, agent);
- status = remove_jobs(dest, agent, list);
+ status = remove_jobs(dest, agent, list);
+ }
+ else
+ status = 1;
putchar(status);
break;
for (value = valueptr; *valueptr && !isspace(*valueptr & 255); valueptr ++);
if (*valueptr)
- *valueptr++ = '\0';
+ *valueptr = '\0';
cupsdSetString(&p->job_sheets[1], value);
}
to; /* Timeout time */
- if (!Browsing || !BrowseLocalProtocols || !Printers)
+ if (!Browsing || !Printers)
return;
/*
* Figure out how many printers need an update...
*/
- if (BrowseInterval > 0)
+ if (BrowseInterval > 0 && BrowseLocalProtocols)
{
int max_count; /* Maximum number to update */
}
/*
- * Loop through all of the printers and send local updates as needed...
+ * Loop through all of the printers and timeout old printers as needed...
*/
for (p = (cupsd_printer_t *)cupsArrayFirst(Printers);
* If this is a remote queue, see if it needs to be timed out...
*/
- if (p->type & CUPS_PRINTER_DISCOVERED)
+ if ((p->type & CUPS_PRINTER_DISCOVERED) &&
+ !(p->type & CUPS_PRINTER_IMPLICIT) &&
+ p->browse_expire < to)
{
- if (p->browse_expire < to)
- {
- cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
- "%s \'%s\' deleted by directory services (timeout).",
- (p->type & CUPS_PRINTER_CLASS) ? "Class" : "Printer",
- p->name);
+ cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
+ "%s \'%s\' deleted by directory services (timeout).",
+ (p->type & CUPS_PRINTER_CLASS) ? "Class" : "Printer",
+ p->name);
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "Remote destination \"%s\" has timed out; "
- "deleting it...",
- p->name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "Remote destination \"%s\" has timed out; "
+ "deleting it...",
+ p->name);
- cupsArraySave(Printers);
- cupsdDeletePrinter(p, 1);
- cupsArrayRestore(Printers);
- cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE);
- }
+ cupsArraySave(Printers);
+ cupsdDeletePrinter(p, 1);
+ cupsArrayRestore(Printers);
+ cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE);
}
}
}
newname[IPP_MAX_NAME], /* New name of printer */
*hptr, /* Pointer into hostname */
*sptr; /* Pointer into ServerName */
+ const char *shortname; /* Short queue name (queue) */
char local_make_model[IPP_MAX_NAME];
/* Local make and model */
cupsd_printer_t *p; /* Printer information */
const char *ipp_options, /* ipp-options value */
*lease_duration; /* lease-duration value */
+ int is_class; /* Is this queue a class? */
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "process_browse_data(uri=\"%s\", host=\"%s\", "
+ "resource=\"%s\", type=%x, state=%d, location=\"%s\", "
+ "info=\"%s\", make_model=\"%s\", num_attrs=%d, attrs=%p)",
+ uri, host, resource, type, state,
+ location ? location : "(nil)", info ? info : "(nil)",
+ make_model ? make_model : "(nil)", num_attrs, attrs);
+
/*
* Determine if the URI contains any illegal characters in it...
*/
(strncmp(resource, "/printers/", 10) &&
strncmp(resource, "/classes/", 9)))
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "process_browse_data: Bad printer URI in browse data: %s",
- uri);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad printer URI in browse data: %s", uri);
return;
}
(!strncmp(resource, "/printers/", 10) && strchr(resource + 10, '/')) ||
(!strncmp(resource, "/classes/", 9) && strchr(resource + 9, '/')))
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "process_browse_data: Bad resource in browse data: %s",
+ cupsdLogMessage(CUPSD_LOG_ERROR, "Bad resource in browse data: %s",
resource);
return;
}
* See if we already have it listed in the Printers list, and add it if not...
*/
- type |= CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED;
- type &= ~CUPS_PRINTER_IMPLICIT;
- update = 0;
- hptr = strchr(host, '.');
- sptr = strchr(ServerName, '.');
+ type |= CUPS_PRINTER_REMOTE | CUPS_PRINTER_DISCOVERED;
+ type &= ~CUPS_PRINTER_IMPLICIT;
+ update = 0;
+ hptr = strchr(host, '.');
+ sptr = strchr(ServerName, '.');
+ is_class = type & CUPS_PRINTER_CLASS;
if (!ServerNameIsIP && sptr != NULL && hptr != NULL)
{
}
}
- if (type & CUPS_PRINTER_CLASS)
+ if (is_class)
{
/*
* Remote destination is a class...
else
return;
- if (hptr && !*hptr)
- *hptr = '.'; /* Resource FQDN */
+ shortname = resource + 9;
+ }
+ else
+ {
+ /*
+ * Remote destination is a printer...
+ */
- if ((p = cupsdFindDest(name)) == NULL && BrowseShortNames)
- {
- if ((p = cupsdFindDest(resource + 9)) != NULL)
- {
- if (p->hostname && strcasecmp(p->hostname, host))
- {
- /*
- * Nope, this isn't the same host; if the hostname isn't the local host,
- * add it to the other class and then find a class using the full host
- * name...
- */
+ if (!strncmp(resource, "/printers/", 10))
+ snprintf(name, sizeof(name), "%s@%s", resource + 10, host);
+ else
+ return;
- if (p->type & CUPS_PRINTER_REMOTE)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "Renamed remote class \"%s\" to \"%s@%s\"...",
- p->name, p->name, p->hostname);
- cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
- "Class \'%s\' deleted by directory services.",
- p->name);
-
- snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname);
- cupsdRenamePrinter(p, newname);
-
- cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
- "Class \'%s\' added by directory services.",
- p->name);
- }
+ shortname = resource + 10;
+ }
- p = NULL;
- }
- else if (!p->hostname)
- {
- /*
- * Hostname not set, so this must be a cached remote printer
- * that was created for a pending print job...
- */
+ if (hptr && !*hptr)
+ *hptr = '.'; /* Resource FQDN */
- cupsdSetString(&p->hostname, host);
- cupsdSetString(&p->uri, uri);
- cupsdSetString(&p->device_uri, uri);
- update = 1;
- }
- }
- else
- {
- /*
- * Use the short name for this shared class.
- */
+ if ((p = cupsdFindDest(name)) == NULL && BrowseShortNames)
+ {
+ /*
+ * Long name doesn't exist, try short name...
+ */
- strlcpy(name, resource + 9, sizeof(name));
- }
- }
- else if (p && !p->hostname)
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "process_browse_data: %s not found...",
+ name);
+
+ if ((p = cupsdFindDest(shortname)) == NULL)
{
/*
- * Hostname not set, so this must be a cached remote printer
- * that was created for a pending print job...
+ * Short name doesn't exist, use it for this shared queue.
*/
- cupsdSetString(&p->hostname, host);
- cupsdSetString(&p->uri, uri);
- cupsdSetString(&p->device_uri, uri);
- update = 1;
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "process_browse_data: %s not found...",
+ shortname);
+ strlcpy(name, shortname, sizeof(name));
}
-
- if (!p)
+ else
{
/*
- * Class doesn't exist; add it...
+ * Short name exists...
*/
- p = cupsdAddClass(name);
-
- cupsdLogMessage(CUPSD_LOG_DEBUG, "Added remote class \"%s\"...", name);
-
- cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
- "Class \'%s\' added by directory services.", name);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "process_browse_data: %s found, type=%x, hostname=%s...",
+ shortname, p->type, p->hostname ? p->hostname : "(nil)");
- /*
- * Force the URI to point to the real server...
- */
+ if (p->type & CUPS_PRINTER_IMPLICIT)
+ p = NULL; /* Don't replace implicit classes */
+ else if (p->hostname && strcasecmp(p->hostname, host))
+ {
+ /*
+ * Short name exists but is for a different host. If this is a remote
+ * queue, rename it and use the long name...
+ */
- p->type = type & ~CUPS_PRINTER_REJECTING;
- p->accepting = 1;
- cupsdSetString(&p->uri, uri);
- cupsdSetString(&p->device_uri, uri);
- cupsdSetString(&p->hostname, host);
+ if (p->type & CUPS_PRINTER_REMOTE)
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "Renamed remote %s \"%s\" to \"%s@%s\"...",
+ is_class ? "class" : "printer", p->name, p->name,
+ p->hostname);
+ cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
+ "%s \'%s\' deleted by directory services.",
+ is_class ? "Class" : "Printer", p->name);
+
+ snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname);
+ cupsdRenamePrinter(p, newname);
+
+ cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
+ "%s \'%s\' added by directory services.",
+ is_class ? "Class" : "Printer", p->name);
+ }
- update = 1;
+ /*
+ * Force creation with long name...
+ */
- cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE);
+ p = NULL;
+ }
}
}
else
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "process_browse_data: %s found, type=%x, hostname=%s...",
+ name, p->type, p->hostname ? p->hostname : "(nil)");
+
+ if (!p)
{
/*
- * Remote destination is a printer...
+ * Queue doesn't exist; add it...
*/
- if (!strncmp(resource, "/printers/", 10))
- snprintf(name, sizeof(name), "%s@%s", resource + 10, host);
+ if (is_class)
+ p = cupsdAddClass(name);
else
- return;
-
- if (hptr && !*hptr)
- *hptr = '.'; /* Resource FQDN */
-
- if ((p = cupsdFindDest(name)) == NULL && BrowseShortNames)
- {
- if ((p = cupsdFindDest(resource + 10)) != NULL)
- {
- if (p->hostname && strcasecmp(p->hostname, host))
- {
- /*
- * Nope, this isn't the same host; if the hostname isn't the local host,
- * add it to the other printer and then find a printer using the full host
- * name...
- */
-
- if (p->type & CUPS_PRINTER_REMOTE)
- {
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "Renamed remote printer \"%s\" to \"%s@%s\"...",
- p->name, p->name, p->hostname);
- cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
- "Printer \'%s\' deleted by directory services.",
- p->name);
-
- snprintf(newname, sizeof(newname), "%s@%s", p->name, p->hostname);
- cupsdRenamePrinter(p, newname);
-
- cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
- "Printer \'%s\' added by directory services.",
- p->name);
- }
-
- p = NULL;
- }
- else if (!p->hostname)
- {
- /*
- * Hostname not set, so this must be a cached remote printer
- * that was created for a pending print job...
- */
-
- cupsdSetString(&p->hostname, host);
- cupsdSetString(&p->uri, uri);
- cupsdSetString(&p->device_uri, uri);
- update = 1;
- }
- }
- else
- {
- /*
- * Use the short name for this shared printer.
- */
+ p = cupsdAddPrinter(name);
- strlcpy(name, resource + 10, sizeof(name));
- }
- }
- else if (p && !p->hostname)
- {
- /*
- * Hostname not set, so this must be a cached remote printer
- * that was created for a pending print job...
- */
+ cupsdClearString(&(p->hostname));
- cupsdSetString(&p->hostname, host);
- cupsdSetString(&p->uri, uri);
- cupsdSetString(&p->device_uri, uri);
- update = 1;
- }
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "Added remote %s \"%s\"...",
+ is_class ? "class" : "printer", name);
- if (!p)
- {
- /*
- * Printer doesn't exist; add it...
- */
+ cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
+ "%s \'%s\' added by directory services.",
+ is_class ? "Class" : "Printer", name);
- p = cupsdAddPrinter(name);
+ /*
+ * Force the URI to point to the real server...
+ */
- cupsdAddEvent(CUPSD_EVENT_PRINTER_ADDED, p, NULL,
- "Printer \'%s\' added by directory services.", name);
+ p->type = type & ~CUPS_PRINTER_REJECTING;
+ p->accepting = 1;
- cupsdLogMessage(CUPSD_LOG_DEBUG, "Added remote printer \"%s\"...", name);
+ cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP);
+ }
- /*
- * Force the URI to point to the real server...
- */
+ if (!p)
+ return;
- p->type = type & ~CUPS_PRINTER_REJECTING;
- p->accepting = 1;
- cupsdSetString(&p->hostname, host);
- cupsdSetString(&p->uri, uri);
- cupsdSetString(&p->device_uri, uri);
+ if (!p->hostname)
+ {
+ /*
+ * Hostname not set, so this must be a cached remote printer
+ * that was created for a pending print job...
+ */
- update = 1;
+ cupsdSetString(&p->hostname, host);
+ cupsdSetString(&p->uri, uri);
+ cupsdSetString(&p->device_uri, uri);
+ update = 1;
- cupsdMarkDirty(CUPSD_DIRTY_PRINTCAP | CUPSD_DIRTY_REMOTE);
- }
+ cupsdMarkDirty(CUPSD_DIRTY_REMOTE);
}
/*
if (!make_model || !make_model[0])
{
- if (type & CUPS_PRINTER_CLASS)
+ if (is_class)
snprintf(local_make_model, sizeof(local_make_model),
"Remote Class on %s", host);
else
{
cupsdAddEvent(CUPSD_EVENT_PRINTER_DELETED, p, NULL,
"%s \'%s\' deleted by directory services.",
- (type & CUPS_PRINTER_CLASS) ? "Class" : "Printer", p->name);
+ is_class ? "Class" : "Printer", p->name);
cupsdExpireSubscriptions(p, NULL);
IPP_TAG_INTEGER)) != NULL)
attr->values[0].integer = 0;
else
- attr = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER,
- "job-k-octets", 0);
+ ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-k-octets", 0);
if ((attr = ippFindAttribute(job->attrs, "job-hold-until",
IPP_TAG_KEYWORD)) == NULL)
* none...
*/
- for (attr = job->attrs->attrs, prev = NULL;
- attr;
- prev = attr, attr = attr->next)
+ for (attr = job->attrs->attrs; attr; attr = attr->next)
if (attr->group_tag == IPP_TAG_SUBSCRIPTION)
break;
/*
* Remove all of the subscription attributes from the job request...
+ *
+ * TODO: Optimize this since subscription groups have to come at the
+ * end of the request...
*/
for (attr = job->attrs->attrs, prev = NULL; attr; attr = next)
* job object...
*/
- for (i = printer->num_options, num_options = 0, option = printer->options;
+ for (i = printer->num_options, num_options = 0, options = NULL,
+ option = printer->options;
i > 0;
i --, option ++)
if (!ippFindAttribute(job->attrs, option->name, IPP_TAG_ZERO))
* See if we have data ready...
*/
- bytes = 0;
-
FD_ZERO(&input);
FD_SET(temppipe[0], &input);
FD_SET(CGIPipes[0], &input);
static void
send_ipp_status(cupsd_client_t *con, /* I - Client connection */
- ipp_status_t status, /* I - IPP status code */
- const char *message, /* I - Status message */
- ...) /* I - Additional args as needed */
+ ipp_status_t status, /* I - IPP status code */
+ const char *message,/* I - Status message */
+ ...) /* I - Additional args as needed */
{
va_list ap; /* Pointer to additional args */
char formatted[1024]; /* Formatted errror message */
*/
if (attr == NULL)
- attr = ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD,
- "job-hold-until", NULL, holdstr);
+ ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-hold-until",
+ NULL, holdstr);
else
cupsdSetString(&attr->values[0].string.text, holdstr);
i = ipp_length(job->attrs);
- if (i > optlength)
+ if (i > optlength || !options)
{
if (optlength == 0)
optptr = malloc(i);
{
cupsdLogJob(job, loglevel, "%s", message);
- strlcpy(job->printer->state_message, message,
- sizeof(job->printer->state_message));
- cupsdAddPrinterHistory(job->printer);
+ if (loglevel < CUPSD_LOG_DEBUG)
+ {
+ strlcpy(job->printer->state_message, message,
+ sizeof(job->printer->state_message));
+ cupsdAddPrinterHistory(job->printer);
- if (loglevel <= CUPSD_LOG_INFO)
event |= CUPSD_EVENT_PRINTER_STATE;
- if (loglevel <= job->status_level)
- {
- /*
- * Some messages show in the printer-state-message attribute...
- */
+ if (loglevel <= job->status_level)
+ {
+ /*
+ * Some messages show in the printer-state-message attribute...
+ */
- if (loglevel != CUPSD_LOG_NOTICE)
- job->status_level = loglevel;
+ if (loglevel != CUPSD_LOG_NOTICE)
+ job->status_level = loglevel;
- update_job_attrs(job, 1);
+ update_job_attrs(job, 1);
+ }
}
}
&major_status_string);
if (!GSS_ERROR(err_major_status))
- err_major_status = gss_display_status(&err_minor_status,
- minor_status,
- GSS_C_MECH_CODE,
- GSS_C_NULL_OID,
- &msg_ctx,
- &minor_status_string);
+ gss_display_status(&err_minor_status, minor_status, GSS_C_MECH_CODE,
+ GSS_C_NULL_OID, &msg_ctx, &minor_status_string);
ret = cupsdLogMessage(level, "%s: %s, %s", message,
(char *)major_status_string.value,
};
+ /*
+ * Filter requests as needed...
+ */
+
+ if (AccessLogLevel < CUPSD_ACCESSLOG_ALL)
+ {
+ /*
+ * Eliminate simple GET requests...
+ */
+
+ if ((con->operation == HTTP_GET &&
+ strncmp(con->uri, "/admin/conf", 11) &&
+ strncmp(con->uri, "/admin/log", 10)) ||
+ (con->operation == HTTP_POST && !con->request &&
+ strncmp(con->uri, "/admin", 6)) ||
+ (con->operation != HTTP_POST && con->operation != HTTP_PUT))
+ return (1);
+
+ if (con->request && con->response &&
+ con->response->request.status.status_code < IPP_REDIRECTION_OTHER_SITE)
+ {
+ /*
+ * Check successful requests...
+ */
+
+ ipp_op_t op = con->request->request.op.operation_id;
+ static cupsd_accesslog_t standard_ops[] =
+ {
+ CUPSD_ACCESSLOG_ALL, /* reserved */
+ CUPSD_ACCESSLOG_ALL, /* reserved */
+ CUPSD_ACCESSLOG_ACTIONS,/* Print-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Print-URI */
+ CUPSD_ACCESSLOG_ACTIONS,/* Validate-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Create-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Send-Document */
+ CUPSD_ACCESSLOG_ACTIONS,/* Send-URI */
+ CUPSD_ACCESSLOG_ACTIONS,/* Cancel-Job */
+ CUPSD_ACCESSLOG_ALL, /* Get-Job-Attributes */
+ CUPSD_ACCESSLOG_ALL, /* Get-Jobs */
+ CUPSD_ACCESSLOG_ALL, /* Get-Printer-Attributes */
+ CUPSD_ACCESSLOG_ACTIONS,/* Hold-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Release-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Restart-Job */
+ CUPSD_ACCESSLOG_ALL, /* reserved */
+ CUPSD_ACCESSLOG_CONFIG, /* Pause-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Resume-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Purge-Jobs */
+ CUPSD_ACCESSLOG_CONFIG, /* Set-Printer-Attributes */
+ CUPSD_ACCESSLOG_ACTIONS,/* Set-Job-Attributes */
+ CUPSD_ACCESSLOG_CONFIG, /* Get-Printer-Supported-Values */
+ CUPSD_ACCESSLOG_ACTIONS,/* Create-Printer-Subscription */
+ CUPSD_ACCESSLOG_ACTIONS,/* Create-Job-Subscription */
+ CUPSD_ACCESSLOG_ALL, /* Get-Subscription-Attributes */
+ CUPSD_ACCESSLOG_ALL, /* Get-Subscriptions */
+ CUPSD_ACCESSLOG_ACTIONS,/* Renew-Subscription */
+ CUPSD_ACCESSLOG_ACTIONS,/* Cancel-Subscription */
+ CUPSD_ACCESSLOG_ALL, /* Get-Notifications */
+ CUPSD_ACCESSLOG_ACTIONS,/* Send-Notifications */
+ CUPSD_ACCESSLOG_ALL, /* reserved */
+ CUPSD_ACCESSLOG_ALL, /* reserved */
+ CUPSD_ACCESSLOG_ALL, /* reserved */
+ CUPSD_ACCESSLOG_ALL, /* Get-Print-Support-Files */
+ CUPSD_ACCESSLOG_CONFIG, /* Enable-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Disable-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Pause-Printer-After-Current-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Hold-New-Jobs */
+ CUPSD_ACCESSLOG_ACTIONS,/* Release-Held-New-Jobs */
+ CUPSD_ACCESSLOG_CONFIG, /* Deactivate-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Activate-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Restart-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Shutdown-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* Startup-Printer */
+ CUPSD_ACCESSLOG_ACTIONS,/* Reprocess-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Cancel-Current-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Suspend-Current-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Resume-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* Promote-Job */
+ CUPSD_ACCESSLOG_ACTIONS /* Schedule-Job-After */
+ };
+ static cupsd_accesslog_t cups_ops[] =
+ {
+ CUPSD_ACCESSLOG_ALL, /* CUPS-Get-Default */
+ CUPSD_ACCESSLOG_ALL, /* CUPS-Get-Printers */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Add-Modify-Printer */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Delete-Printer */
+ CUPSD_ACCESSLOG_ALL, /* CUPS-Get-Classes */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Add-Modify-Class */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Delete-Class */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Accept-Jobs */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Reject-Jobs */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Set-Default */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Get-Devices */
+ CUPSD_ACCESSLOG_CONFIG, /* CUPS-Get-PPDs */
+ CUPSD_ACCESSLOG_ACTIONS,/* CUPS-Move-Job */
+ CUPSD_ACCESSLOG_ACTIONS,/* CUPS-Authenticate-Job */
+ CUPSD_ACCESSLOG_ALL /* CUPS-Get-PPD */
+ };
+
+
+ if ((op <= IPP_SCHEDULE_JOB_AFTER && standard_ops[op] > AccessLogLevel) ||
+ (op >= CUPS_GET_DEFAULT && op <= CUPS_GET_PPD &&
+ cups_ops[op - CUPS_GET_DEFAULT] > AccessLogLevel))
+ return (1);
+ }
+ }
+
#ifdef HAVE_VSYSLOG
/*
* See if we are logging accesses via syslog...
log_linesize = len;
}
- len = vsnprintf(log_line, log_linesize, message, ap);
+ vsnprintf(log_line, log_linesize, message, ap);
}
return (log_line);
#endif /* HAVE_LDAP */
}
- if (Browsing && BrowseLocalProtocols && current_time > browse_time)
+ if (Browsing && current_time > browse_time)
{
cupsdSendBrowseList();
browse_time = current_time;
if (!Printers)
Printers = cupsArrayNew(compare_printers, NULL);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAddPrinter: Adding %s to Printers", p->name);
cupsArrayAdd(Printers, p);
if (!ImplicitPrinters)
* Remove the printer from the list...
*/
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "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...
for (value = valueptr; *valueptr && !isspace(*valueptr & 255); valueptr ++);
if (*valueptr)
- *valueptr++ = '\0';
+ *valueptr = '\0';
cupsdSetString(&p->job_sheets[1], value);
}
* Remove the printer from the array(s) first...
*/
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "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...
* Add the printer back to the printer array(s)...
*/
+ 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);
+ }
}
{
cupsFilePrintf(fp, "Attribute %s ", marker->name);
- if (!ptr && (ptr = strchr(marker->values[0].string.text, '#')) != NULL)
+ if ((ptr = strchr(marker->values[0].string.text, '#')) != NULL)
{
cupsFileWrite(fp, marker->values[0].string.text,
ptr - marker->values[0].string.text);
* Add all of the default options from the .conf files...
*/
- for (num_options = 0, i = p->num_options, option = p->options;
+ for (num_options = 0, options = NULL, i = p->num_options, option = p->options;
i > 0;
i --, option ++)
{
* super/type cost program
*/
- if (sscanf(filter, "%15[^/]/%31s%d%1023s", super, type, &cost, program) != 4)
+ if (sscanf(filter, "%15[^/]/%31s%d%*[ \t]%1023[^\n]", super, type, &cost,
+ program) != 4)
{
cupsdLogMessage(CUPSD_LOG_ERROR, "%s: invalid filter string \"%s\"!",
p->name, filter);
#ifdef TEST
+# define testmain main
int
-main(void)
+testmain(void)
{
FILE *fp;
*
* Select abstraction functions for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 2006-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
void *data) /* I - Data to pass to callback */
{
_cupsd_fd_t *fdptr; /* File descriptor record */
+#ifdef HAVE_EPOLL
int added; /* 1 if added, 0 if modified */
+#endif /* HAVE_EPOLL */
/*
return (0);
}
+#ifdef HAVE_EPOLL
added = 1;
}
else
added = 0;
+#else
+ }
+#endif /* HAVE_EPOLL */
#ifdef HAVE_KQUEUE
{
case IPP_PRINT_JOB :
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, "ipp://localhost/printers/test");
- ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-hold-until",
- NULL, "indefinite");
ippDelete(cupsDoFileRequest(http, request, "/printers/test",
"../data/testprint.ps"));
break;
while (isalnum(*rule & 255) && (ptr - name) < (sizeof(name) - 1))
*ptr++ = *rule++;
- *ptr = '\0';
- num_values = 0;
+ *ptr = '\0';
if (*rule == '(')
{
snprintf(value[0], sizeof(value[0]), "*.%s", name);
length[0] = strlen(value[0]);
- num_values = 1;
op = MIME_MAGIC_MATCH;
}
*
* "cancel" command for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
op = IPP_CANCEL_JOB;
purge = 0;
- job_id = 0;
dest = NULL;
user = NULL;
http = NULL;
/*
- * "$Id: cupsctl.c 6379 2007-03-21 14:57:22Z mike $"
+ * "$Id$"
*
* CUPS control program for the Common UNIX Printing System (CUPS).
*
/*
- * End of "$Id: cupsctl.c 6379 2007-03-21 14:57:22Z mike $".
+ * End of "$Id$".
*/
*
* DSC test program for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
if (!status)
_cupsLangPuts(stdout, _("FAIL\n"));
- status ++;
_cupsLangPuts(stdout,
_(" Missing %!PS-Adobe-3.0 on first line!\n"
" REF: Page 17, 3.1 Conforming Documents\n"));
if (eol == EOL_NONE)
eol = EOL_CRLF;
- else
+ else if (eol != EOL_CRLF)
mixed = 1;
}
else if (eol == EOL_NONE)
eol = EOL_CR;
- else
+ else if (eol != EOL_CR)
mixed = 1;
}
int verbose, /* I - Verbosity level */
int warn) /* I - Warnings only? */
{
+ int i; /* Looping var */
ppd_attr_t *attr; /* PPD attribute */
const char *ptr; /* Pointer into string */
char super[16], /* Super-type for filter */
type[256], /* Type for filter */
- program[256], /* Program/filter name */
+ program[1024], /* Program/filter name */
pathprog[1024]; /* Complete path to program/filter */
int cost; /* Cost of filter */
const char *prefix; /* WARN/FAIL prefix */
prefix = warn ? " WARN " : "**FAIL**";
- for (attr = ppdFindAttr(ppd, "cupsFilter", NULL);
- attr;
- attr = ppdFindNextAttr(ppd, "cupsFilter", NULL))
+ for (i = 0; i < ppd->num_filters; i ++)
{
- if (!attr->value ||
- sscanf(attr->value, "%15[^/]/%255s%d%255s", super, type, &cost,
- program) != 4)
+ if (sscanf(ppd->filters[i], "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type,
+ &cost, program) != 4)
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
if (verbose >= 0)
_cupsLangPrintf(stdout,
_(" %s Bad cupsFilter value \"%s\"!\n"),
- prefix, attr->value ? attr->value : "");
+ prefix, ppd->filters[i]);
if (!warn)
errors ++;
attr = ppdFindNextAttr(ppd, "cupsPreFilter", NULL))
{
if (!attr->value ||
- sscanf(attr->value, "%15[^/]/%255s%d%255s", super, type, &cost,
- program) != 4)
+ sscanf(attr->value, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super, type,
+ &cost, program) != 4)
{
if (!warn && !errors && !verbose)
_cupsLangPuts(stdout, _(" FAIL\n"));
*
* "lpadmin" command for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
attr = ippAddStrings(request, IPP_TAG_PRINTER, IPP_TAG_URI,
"member-uris", members->num_values + 1, NULL, NULL);
for (i = 0; i < members->num_values; i ++)
- attr->values[i].string.text = strdup(members->values[i].string.text);
+ attr->values[i].string.text = _cupsStrAlloc(members->values[i].string.text);
- attr->values[i].string.text = strdup(uri);
+ attr->values[i].string.text = _cupsStrAlloc(uri);
}
else
- attr = ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "member-uris", NULL, uri);
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "member-uris", NULL,
+ uri);
/*
* Then send the request...
for (j = 0, k = 0; j < members->num_values; j ++)
if (j != i)
- attr->values[k ++].string.text = strdup(members->values[j].string.text);
+ attr->values[k ++].string.text =
+ _cupsStrAlloc(members->values[j].string.text);
}
/*
*
* Printer option program for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
if (num_dests == 0)
num_dests = cupsGetDests(&dests);
- if ((dest = cupsGetDest(printer, instance, num_dests, dests)) == NULL)
+ if (num_dests == 0 || !dests ||
+ (dest = cupsGetDest(printer, instance, num_dests,
+ dests)) == NULL)
{
_cupsLangPuts(stderr,
_("lpoptions: Unknown printer or class!\n"));
while (cparam)
{
- _cupsLangPrintf(stdout, "%s%s=%s", choice->marked ? "*" : "",
- cparam->name, types[cparam->type]);
+ _cupsLangPrintf(stdout, "%s%s=%s", prefix, cparam->name,
+ types[cparam->type]);
cparam = (ppd_cparam_t *)cupsArrayNext(coption->params);
prefix = " ";
}
request = ippNew();
op = (ipp_op_t)0;
group = IPP_TAG_ZERO;
- value = IPP_TAG_ZERO;
num_statuses = 0;
num_expects = 0;
num_displayed = 0;