From d2354e63977f1d0386a8d5724db2ec90fb666824 Mon Sep 17 00:00:00 2001 From: msweet Date: Wed, 14 Jan 2009 19:55:19 +0000 Subject: [PATCH] Merge changes from CUPS 1.4svn-r8252. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1123 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES-1.3.txt | 6 +- CHANGES.txt | 14 +- backend/usb-libusb.c | 8 +- cgi-bin/admin.c | 18 +- cgi-bin/cgi.h | 3 +- cgi-bin/html.c | 54 +- cgi-bin/ipp-var.c | 90 ++-- cgi-bin/libcupscgi.exp | 1 + config-scripts/cups-manpages.m4 | 12 +- cups/conflicts.c | 70 +++ cups/cups.h | 6 +- cups/encode.c | 44 +- cups/http-addr.c | 12 +- cups/http-addrlist.c | 7 +- cups/ipp.c | 12 - cups/libcups.exp | 1 + cups/mark.c | 147 ++++-- cups/testipp.c | 15 +- cups/testppd.c | 23 +- doc/Makefile | 1 + doc/help/api-array.html | 4 +- doc/help/api-ppd.html | 34 ++ doc/help/ref-cupsd-conf.html.in | 14 +- doc/help/sharing.html | 181 +++++++ doc/help/spec-ipp.html | 6 +- locale/cups_es.po | 668 ++++++++----------------- packaging/cups.list.in | 3 +- packaging/cups.spec.in | 3 +- ppdc/ppdc-driver.cxx | 8 +- ppdc/ppdc-source.cxx | 10 +- ppdc/ppdpo.cxx | 4 +- scheduler/ipp.c | 11 + scheduler/job.c | 23 +- scheduler/printers.c | 66 ++- scheduler/type.c | 3 +- templates/es/add-rss-subscription.tmpl | 2 +- templates/es/admin.tmpl | 2 +- templates/es/error-op.tmpl | 4 +- templates/es/error.tmpl | 2 +- templates/es/printer-configured.tmpl | 4 +- templates/es/printer.tmpl | 2 +- templates/es/test-page.tmpl | 2 +- test/4.1-requests.test | 19 + test/4.2-cups-printer-ops.test | 23 + test/get-printer-attributes-2.0.test | 47 ++ test/ipptest.c | 120 ++++- test/run-stp-tests.sh | 6 +- 47 files changed, 1148 insertions(+), 667 deletions(-) create mode 100644 doc/help/sharing.html create mode 100644 test/get-printer-attributes-2.0.test diff --git a/CHANGES-1.3.txt b/CHANGES-1.3.txt index 42e447283..b57dbf20c 100644 --- a/CHANGES-1.3.txt +++ b/CHANGES-1.3.txt @@ -3,7 +3,11 @@ CHANGES-1.3.txt CHANGES IN CUPS V1.3.10 - - Documentation fixes (STR #2994, STR #2995, STR #3008, STR #3056) + - Documentation fixes (STR #2994, STR #2995, STR #3008, STR #3056, + STR #3057) + - The scheduler did not always load MIME type rules correctly + (STR #3059) + - The test page did not format correctly on A4 paper (STR #3060) - The web interface sometimes incorrectly redirected users to 127.0.0.1 (STR #3022) - cupsPrintFile*() did not send the document filename for single diff --git a/CHANGES.txt b/CHANGES.txt index 4c35ec79d..262c7e471 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,21 @@ -CHANGES.txt - 2009-01-09 +CHANGES.txt - 2009-01-14 ------------------------ CHANGES IN CUPS V1.4b3 + - Documentation fixes (STR #3044, STR #3057) + - The libusb-based USB backend did not work. + - The scheduler did not set the printer-commands attribute correctly + for some PPDs. + - The ppdi utility did not work. + - The web interface no longer uses multi-part output with old or broken + web browsers (STR #3049) - CUPS now conforms to the draft IPP/2.0 and IPP/2.1 specification. + - Added a new cupsGetConflicts() API to get a list of conflicting + options. + - The PPD compiler didn't localize options or choices that did not + have associated translation text (STR #3045) + - Updated the Spanish localization (STR #3043) - Fixed build problems (STR #3040, STR #3047) - cupsResolveConflicts() did not resolve using the default option choice in some cases due to the mirror UIConstraints that are diff --git a/backend/usb-libusb.c b/backend/usb-libusb.c index 6e6494c49..3cb61e395 100644 --- a/backend/usb-libusb.c +++ b/backend/usb-libusb.c @@ -3,7 +3,7 @@ * * Libusb interface code for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -156,13 +156,13 @@ print_device(const char *uri, /* I - Device URI */ * TODO: Add back-channel support, along with better write error handling. */ - if (poll(pfds, 2, -1) > 0) + while (poll(pfds, 2, -1) > 0) { if (pfds[0].revents & POLLIN) { if ((bytes = read(print_fd, buffer, sizeof(buffer))) > 0) { - while (usb_bulk_write(printer->handle, printer->write_endp, buffer, + if (usb_bulk_write(printer->handle, printer->write_endp, buffer, bytes, 45000) < 0) { _cupsLangPrintf(stderr, @@ -174,7 +174,7 @@ print_device(const char *uri, /* I - Device URI */ tbytes += bytes; } - else if (bytes < 0 && errno != EAGAIN && errno != EINTR) + else if (bytes == 0 || (bytes < 0 && errno != EAGAIN && errno != EINTR)) break; } diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 1601ef7c8..b0b3ae23e 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -3,7 +3,7 @@ * * Administration CGI for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -261,7 +261,7 @@ choose_device_cb( current_device ++; - if (time(NULL) > last_device_time) + if (time(NULL) > last_device_time && cgiSupportsMultipart()) { /* * Update the page... @@ -921,7 +921,21 @@ do_am_printer(http_t *http, /* I - HTTP connection */ if (cupsGetDevices(http, 30, CUPS_INCLUDE_ALL, CUPS_EXCLUDE_NONE, (cups_device_cb_t)choose_device_cb, (void *)title) == IPP_OK) + { fputs("DEBUG: Got device list!\n", stderr); + + if (!cgiSupportsMultipart()) + { + /* + * Non-modern browsers that don't support multi-part documents get + * everything at the end... + */ + + cgiStartHTML(title); + cgiCopyTemplateLang("choose-device.tmpl"); + cgiEndHTML(); + } + } else { fprintf(stderr, diff --git a/cgi-bin/cgi.h b/cgi-bin/cgi.h index 66de5110a..5546d7ac5 100644 --- a/cgi-bin/cgi.h +++ b/cgi-bin/cgi.h @@ -3,7 +3,7 @@ * * CGI support library definitions. * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -95,6 +95,7 @@ extern void cgiShowIPPError(const char *message); extern void cgiShowJobs(http_t *http, const char *dest); extern void cgiStartHTML(const char *title); extern void cgiStartMultipart(void); +extern int cgiSupportsMultipart(void); extern const char *cgiText(const char *message); #endif /* !_CUPS_CGI_H_ */ diff --git a/cgi-bin/html.c b/cgi-bin/html.c index e99245868..2db9bdd25 100644 --- a/cgi-bin/html.c +++ b/cgi-bin/html.c @@ -3,7 +3,7 @@ * * HTML support functions for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -14,12 +14,13 @@ * * Contents: * - * cgiEndHTML() - End a HTML page. - * cgiEndMultipart() - End the delivery of a multipart web page. - * cgiFormEncode() - Encode a string as a form variable... - * cgiStartHTML() - Start a HTML page. - * cgiStartMultipart() - Start a multipart delivery of a web page... - * cgi_null_passwd() - Return a NULL password for authentication. + * cgiEndHTML() - End a HTML page. + * cgiEndMultipart() - End the delivery of a multipart web page. + * cgiFormEncode() - Encode a string as a form variable. + * cgiStartHTML() - Start a HTML page. + * cgiStartMultipart() - Start a multipart delivery of a web page. + * cgiSupportsMultipart() - Does the browser support multi-part documents? + * cgi_null_passwd() - Return a NULL password for authentication. */ /* @@ -72,7 +73,7 @@ cgiEndMultipart(void) /* - * 'cgiFormEncode()' - Encode a string as a form variable... + * 'cgiFormEncode()' - Encode a string as a form variable. */ char * /* O - Destination string */ @@ -183,7 +184,7 @@ cgiStartHTML(const char *title) /* I - Title of page */ /* - * 'cgiStartMultipart()' - Start a multipart delivery of a web page... + * 'cgiStartMultipart()' - Start a multipart delivery of a web page. */ void @@ -195,6 +196,41 @@ cgiStartMultipart(void) } +/* + * 'cgiSupportsMultipart()' - Does the browser support multi-part documents? + */ + +int /* O - 1 if multi-part supported, 0 otherwise */ +cgiSupportsMultipart(void) +{ + const char *user_agent; /* User-Agent string */ + static int supports_multipart = -1;/* Cached value */ + + + if (supports_multipart < 0) + { + /* + * CUPS STR #3049: Apparently some browsers don't support multi-part + * documents, which makes them useless for many web sites. Rather than + * abandoning those users, we'll offer a degraded single-part mode... + * + * Currently we know that anything based on Gecko, MSIE, and Safari all + * work. We'll add more as they are reported/tested. + */ + + if ((user_agent = getenv("HTTP_USER_AGENT")) != NULL && + (strstr(user_agent, " Gecko/") != NULL || + strstr(user_agent, " MSIE ") != NULL || + strstr(user_agent, " Safari/") != NULL)) + supports_multipart = 1; + else + supports_multipart = 0; + } + + return (supports_multipart); +} + + /* * 'cgi_null_passwd()' - Return a NULL password for authentication. */ diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c index 90c90cf74..842268b67 100644 --- a/cgi-bin/ipp-var.c +++ b/cgi-bin/ipp-var.c @@ -3,7 +3,7 @@ * * CGI <-> IPP variable routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -548,11 +548,14 @@ cgiPrintCommand(http_t *http, /* I - Connection to server */ * Show status... */ - cgiStartMultipart(); - cgiStartHTML(title); - cgiCopyTemplateLang("command.tmpl"); - cgiEndHTML(); - fflush(stdout); + if (cgiSupportsMultipart()) + { + cgiStartMultipart(); + cgiStartHTML(title); + cgiCopyTemplateLang("command.tmpl"); + cgiEndHTML(); + fflush(stdout); + } /* * Send the command file job... @@ -574,7 +577,9 @@ cgiPrintCommand(http_t *http, /* I - Connection to server */ cgiStartHTML(title); cgiCopyTemplateLang("error.tmpl"); cgiEndHTML(); - cgiEndMultipart(); + + if (cgiSupportsMultipart()) + cgiEndMultipart(); return; } @@ -592,7 +597,9 @@ cgiPrintCommand(http_t *http, /* I - Connection to server */ cgiStartHTML(title); cgiCopyTemplateLang("error.tmpl"); cgiEndHTML(); - cgiEndMultipart(); + + if (cgiSupportsMultipart()) + cgiEndMultipart(); cupsCancelJob(dest, job_id); return; @@ -602,44 +609,47 @@ cgiPrintCommand(http_t *http, /* I - Connection to server */ * Wait for the job to complete... */ - for (;;) + if (cgiSupportsMultipart()) { - /* - * Get the current job state... - */ + for (;;) + { + /* + * Get the current job state... + */ - snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id); - request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES); - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", - NULL, uri); - if (user) - ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, - "requesting-user-name", NULL, user); - ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, - "requested-attributes", 2, NULL, job_attrs); + snprintf(uri, sizeof(uri), "ipp://localhost/jobs/%d", job_id); + request = ippNewRequest(IPP_GET_JOB_ATTRIBUTES); + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", + NULL, uri); + if (user) + ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, + "requesting-user-name", NULL, user); + ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, + "requested-attributes", 2, NULL, job_attrs); - if ((response = cupsDoRequest(http, request, "/")) != NULL) - cgiSetIPPVars(response, NULL, NULL, NULL, 0); + if ((response = cupsDoRequest(http, request, "/")) != NULL) + cgiSetIPPVars(response, NULL, NULL, NULL, 0); - attr = ippFindAttribute(response, "job-state", IPP_TAG_ENUM); - if (!attr || attr->values[0].integer >= IPP_JOB_STOPPED) - { - ippDelete(response); - break; - } + attr = ippFindAttribute(response, "job-state", IPP_TAG_ENUM); + if (!attr || attr->values[0].integer >= IPP_JOB_STOPPED) + { + ippDelete(response); + break; + } - /* - * Job not complete, so update the status... - */ + /* + * Job not complete, so update the status... + */ - ippDelete(response); + ippDelete(response); - cgiStartHTML(title); - cgiCopyTemplateLang("command.tmpl"); - cgiEndHTML(); - fflush(stdout); + cgiStartHTML(title); + cgiCopyTemplateLang("command.tmpl"); + cgiEndHTML(); + fflush(stdout); - sleep(5); + sleep(5); + } } /* @@ -655,7 +665,9 @@ cgiPrintCommand(http_t *http, /* I - Connection to server */ cgiStartHTML(title); cgiCopyTemplateLang("command.tmpl"); cgiEndHTML(); - cgiEndMultipart(); + + if (cgiSupportsMultipart()) + cgiEndMultipart(); } diff --git a/cgi-bin/libcupscgi.exp b/cgi-bin/libcupscgi.exp index efe0ac7e3..73e309e96 100644 --- a/cgi-bin/libcupscgi.exp +++ b/cgi-bin/libcupscgi.exp @@ -30,6 +30,7 @@ _cgiShowIPPError _cgiShowJobs _cgiStartHTML _cgiStartMultipart +_cgiSupportsMultipart _cgiText _helpDeleteIndex _helpFindNode diff --git a/config-scripts/cups-manpages.m4 b/config-scripts/cups-manpages.m4 index 13881c5bf..44d31369b 100644 --- a/config-scripts/cups-manpages.m4 +++ b/config-scripts/cups-manpages.m4 @@ -51,14 +51,6 @@ AC_SUBST(PMANDIR) dnl Setup manpage extensions... case "$uname" in - *BSD* | Darwin*) - # *BSD - MAN1EXT=1 - MAN5EXT=5 - MAN7EXT=7 - MAN8EXT=8 - MAN8DIR=8 - ;; IRIX*) # SGI IRIX MAN1EXT=1 @@ -75,8 +67,8 @@ case "$uname" in MAN8EXT=1m MAN8DIR=1m ;; - Linux* | GNU*) - # Linux and GNU Hurd + Linux* | GNU* | Darwin*) + # Linux, GNU Hurd, and Mac OS X MAN1EXT=1.gz MAN5EXT=5.gz MAN7EXT=7.gz diff --git a/cups/conflicts.c b/cups/conflicts.c index a99810cd9..6376f69ef 100644 --- a/cups/conflicts.c +++ b/cups/conflicts.c @@ -18,6 +18,8 @@ * * Contents: * + * cupsGetConflicts() - Get a list of conflicting options in a marked + * PPD. * cupsResolveConflicts() - Resolve conflicts in a marked PPD. * ppdConflicts() - Check to see if there are any conflicts among * the marked option choices. @@ -65,6 +67,74 @@ static cups_array_t *ppd_test_constraints(ppd_file_t *ppd, int which); +/* + * 'cupsGetConflicts()' - Get a list of conflicting options in a marked PPD. + * + * This function gets a list of options that would conflict if "option" and + * "choice" were marked in the PPD. You would typically call this function + * after marking the currently selected options in the PPD in order to + * determine whether a new option selection would cause a conflict. + * + * The number of conflicting options are returned with "options" pointing to + * the conflicting options. The returned option array must be freed using + * @link cupsFreeOptions@. + * + * @since CUPS 1.4@ + */ + +int /* O - Number of conflicting options */ +cupsGetConflicts( + ppd_file_t *ppd, /* I - PPD file */ + const char *option, /* I - Option to test */ + const char *choice, /* I - Choice to test */ + cups_option_t **options) /* O - Conflicting options */ +{ + int i, /* Looping var */ + num_options; /* Number of conflicting options */ + cups_array_t *active; /* Active conflicts */ + _ppd_cups_uiconsts_t *c; /* Current constraints */ + _ppd_cups_uiconst_t *cptr; /* Current constraint */ + + + /* + * Range check input... + */ + + if (options) + *options = NULL; + + if (!ppd || !option || !choice || !options) + return (0); + + /* + * Test for conflicts... + */ + + active = ppd_test_constraints(ppd, option, choice, 0, NULL, + _PPD_ALL_CONSTRAINTS); + + /* + * Loop through all of the UI constraints and add any options that conflict... + */ + + for (num_options = 0, c = (_ppd_cups_uiconsts_t *)cupsArrayFirst(active); + c; + c = (_ppd_cups_uiconsts_t *)cupsArrayNext(active)) + { + for (i = c->num_constraints, cptr = c->constraints; + i > 0; + i --, cptr ++) + if (strcasecmp(cptr->option->keyword, option)) + num_options = cupsAddOption(cptr->option->keyword, cptr->choice->choice, + num_options, options); + } + + cupsArrayDelete(active); + + return (num_options); +} + + /* * 'cupsResolveConflicts()' - Resolve conflicts in a marked PPD. * diff --git a/cups/cups.h b/cups/cups.h index 6d3ca29a4..153ceb499 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -3,7 +3,7 @@ * * API definitions for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -281,6 +281,10 @@ extern int cupsCreateJob(http_t *http, const char *name, cups_option_t *options) _CUPS_API_1_4; extern ipp_status_t cupsFinishDocument(http_t *http, const char *name) _CUPS_API_1_4; +extern int cupsGetConflicts(ppd_file_t *ppd, const char *option, + const char *choice, + cups_option_t **options) + _CUPS_API_1_4; extern ipp_status_t cupsGetDevices(http_t *http, int timeout, const char *exclude_schemes, const char *include_schemes, diff --git a/cups/encode.c b/cups/encode.c index 7d9198ea7..16762aa0c 100644 --- a/cups/encode.c +++ b/cups/encode.c @@ -3,7 +3,7 @@ * * Option encoding routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -86,6 +86,13 @@ static const _ipp_option_t ipp_options[] = { 1, "marker-names", IPP_TAG_NAME, IPP_TAG_PRINTER }, { 1, "marker-types", IPP_TAG_KEYWORD, IPP_TAG_PRINTER }, { 1, "media", IPP_TAG_KEYWORD, IPP_TAG_JOB }, + { 0, "media-col", IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB }, + { 0, "media-col-default", IPP_TAG_BEGIN_COLLECTION, IPP_TAG_PRINTER }, + { 0, "media-color", IPP_TAG_KEYWORD, IPP_TAG_JOB }, + { 1, "media-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER }, + { 0, "media-key", IPP_TAG_KEYWORD, IPP_TAG_JOB }, + { 0, "media-size", IPP_TAG_BEGIN_COLLECTION, IPP_TAG_JOB }, + { 0, "media-type", IPP_TAG_KEYWORD, IPP_TAG_JOB }, { 0, "mirror", IPP_TAG_BOOLEAN, IPP_TAG_JOB }, { 0, "mirror-default", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER }, { 0, "natural-scaling", IPP_TAG_INTEGER, IPP_TAG_JOB }, @@ -152,7 +159,9 @@ static const _ipp_option_t ipp_options[] = { 0, "sides", IPP_TAG_KEYWORD, IPP_TAG_JOB }, { 0, "sides-default", IPP_TAG_KEYWORD, IPP_TAG_PRINTER }, { 0, "wrap", IPP_TAG_BOOLEAN, IPP_TAG_JOB }, - { 0, "wrap-default", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER } + { 0, "wrap-default", IPP_TAG_BOOLEAN, IPP_TAG_PRINTER }, + { 0, "x-dimension", IPP_TAG_INTEGER, IPP_TAG_JOB }, + { 0, "y-dimension", IPP_TAG_INTEGER, IPP_TAG_JOB } }; @@ -215,6 +224,9 @@ cupsEncodeOptions2( ipp_attribute_t *attr; /* IPP attribute */ ipp_tag_t value_tag; /* IPP value tag */ cups_option_t *option; /* Current option */ + ipp_t *collection; /* Collection value */ + int num_cols; /* Number of collection values */ + cups_option_t *cols; /* Collection values */ DEBUG_printf(("cupsEncodeOptions2(ipp=%p, num_options=%d, options=%p, " @@ -369,6 +381,7 @@ cupsEncodeOptions2( */ DEBUG_puts("cupsEncodeOptions2: Ran out of memory for value copy!"); + ippDeleteAttribute(ipp, attr); return; } @@ -534,6 +547,28 @@ cupsEncodeOptions2( "\"%s\"...\n", (char *)attr->values[j].unknown.data)); break; + case IPP_TAG_BEGIN_COLLECTION : + /* + * Collection value + */ + + num_cols = cupsParseOptions(val, 0, &cols); + if ((collection = ippNew()) == NULL) + { + cupsFreeOptions(num_cols, cols); + + if (copy) + free(copy); + + ippDeleteAttribute(ipp, attr); + return; + } + + attr->values[j].collection = collection; + cupsEncodeOptions2(collection, num_cols, cols, IPP_TAG_JOB); + cupsFreeOptions(num_cols, cols); + break; + default : if ((attr->values[j].string.text = _cupsStrAlloc(val)) == NULL) { @@ -542,6 +577,11 @@ cupsEncodeOptions2( */ DEBUG_puts("cupsEncodeOptions2: Ran out of memory for string!"); + + if (copy) + free(copy); + + ippDeleteAttribute(ipp, attr); return; } diff --git a/cups/http-addr.c b/cups/http-addr.c index 9a39292eb..52e828525 100644 --- a/cups/http-addr.c +++ b/cups/http-addr.c @@ -3,7 +3,7 @@ * * HTTP address routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -207,6 +207,16 @@ httpAddrLookup( } #endif /* AF_LOCAL */ + /* + * Optimize lookups for localhost/loopback addresses... + */ + + if (httpAddrLocalhost(addr)) + { + strlcpy(name, "localhost", namelen); + return (name); + } + #ifdef HAVE_RES_INIT /* * STR #2920: Initialize resolver after failure in cups-polld diff --git a/cups/http-addrlist.c b/cups/http-addrlist.c index b44acc636..a5b2e1f58 100644 --- a/cups/http-addrlist.c +++ b/cups/http-addrlist.c @@ -3,7 +3,7 @@ * * HTTP address list routines for the Common UNIX Printing System (CUPS). * - * Copyright 2007-2008 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the @@ -265,6 +265,7 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p } else #endif /* AF_LOCAL */ + if (!hostname || strcasecmp(hostname, "localhost")) { #ifdef HAVE_GETADDRINFO struct addrinfo hints, /* Address lookup hints */ @@ -501,7 +502,7 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p * Detect some common errors and handle them sanely... */ - if (!addr && (!hostname || !strcmp(hostname, "localhost"))) + if (!addr && (!hostname || !strcasecmp(hostname, "localhost"))) { struct servent *port; /* Port number for service */ int portnum; /* Port number */ @@ -530,7 +531,7 @@ httpAddrGetList(const char *hostname, /* I - Hostname, IP address, or NULL for p else return (NULL); - if (hostname && !strcmp(hostname, "localhost")) + if (hostname && !strcasecmp(hostname, "localhost")) { /* * Unfortunately, some users ignore all of the warnings in the diff --git a/cups/ipp.c b/cups/ipp.c index de0f12c40..f8e7dafa6 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -1108,18 +1108,6 @@ ippReadIO(void *src, /* I - Data source */ return (IPP_ERROR); } - /* - * Verify the major version number... - */ - - if (buffer[0] != 1 && buffer[0] != 2) - { - DEBUG_printf(("ippReadIO: version number (%d.%d) is bad.\n", - buffer[0], buffer[1])); - ipp_buffer_release(buffer); - return (IPP_ERROR); - } - /* * Then copy the request header over... */ diff --git a/cups/libcups.exp b/cups/libcups.exp index 32803d6b6..74914ae44 100644 --- a/cups/libcups.exp +++ b/cups/libcups.exp @@ -140,6 +140,7 @@ _cupsFreeDests _cupsFreeJobs _cupsFreeOptions _cupsGetClasses +_cupsGetConflicts _cupsGetDefault _cupsGetDefault2 _cupsGetDest diff --git a/cups/mark.c b/cups/mark.c index 4466ec1ce..b2cef1f2d 100644 --- a/cups/mark.c +++ b/cups/mark.c @@ -79,10 +79,12 @@ cupsMarkOptions( cups_option_t *options) /* I - Options */ { int i, j, k; /* Looping vars */ - char *val, /* Pointer into value */ - *ptr, /* Pointer into string */ + char *ptr, /* Pointer into string */ s[255]; /* Temporary string */ - const char *page_size; /* PageSize option */ + const char *val, /* Pointer into value */ + *media, /* media option */ + *media_col, /* media-col option */ + *page_size; /* PageSize option */ cups_option_t *optptr; /* Current option */ ppd_option_t *option; /* PPD option */ ppd_attr_t *attr; /* PPD attribute */ @@ -123,61 +125,124 @@ cupsMarkOptions( debug_marked(ppd, "Before..."); /* - * Mark options... + * Do special handling for media, media-col, and PageSize... */ - for (i = num_options, optptr = options; i > 0; i --, optptr ++) - if (!strcasecmp(optptr->name, "media")) + media = cupsGetOption("media", num_options, options); + media_col = cupsGetOption("media-col", num_options, options); + page_size = cupsGetOption("PageSize", num_options, options); + + if (media_col && (!page_size || !page_size[0])) + { + /* + * Pull out the corresponding media size from the media-col value... + */ + + int num_media_cols, /* Number of media-col values */ + num_media_sizes;/* Number of media-size values */ + cups_option_t *media_cols, /* media-col values */ + *media_sizes; /* media-size values */ + + + num_media_cols = cupsParseOptions(media_col, 0, &media_cols); + + if ((val = cupsGetOption("media-key", num_media_cols, media_cols)) != NULL) + media = val; + else if ((val = cupsGetOption("media-size", num_media_cols, + media_cols)) != NULL) { /* - * Loop through the option string, separating it at commas and - * marking each individual option as long as the corresponding - * PPD option (PageSize, InputSlot, etc.) is not also set. - * - * For PageSize, we also check for an empty option value since - * some versions of MacOS X use it to specify auto-selection - * of the media based solely on the size. + * Lookup by dimensions... */ - page_size = cupsGetOption("PageSize", num_options, options); + double width, /* Width in points */ + length; /* Length in points */ + struct lconv *loc; /* Locale data */ + _cups_pwg_media_t *pwgmedia; /* PWG media name */ - for (val = optptr->value; *val;) - { - /* - * Extract the sub-option from the string... - */ - for (ptr = s; *val && *val != ',' && (ptr - s) < (sizeof(s) - 1);) - *ptr++ = *val++; - *ptr++ = '\0'; + num_media_sizes = cupsParseOptions(val, 0, &media_sizes); + loc = localeconv(); - if (*val == ',') - val ++; + if ((val = cupsGetOption("x-dimension", num_media_sizes, + media_sizes)) != NULL) + width = _cupsStrScand(val, NULL, loc) * 2540.0 / 72.0; + else + width = 0.0; - /* - * Mark it... - */ + if ((val = cupsGetOption("y-dimension", num_media_sizes, + media_sizes)) != NULL) + length = _cupsStrScand(val, NULL, loc) * 2540.0 / 72.0; + else + length = 0.0; - if (!page_size || !page_size[0]) - ppd_mark_size(ppd, s); + if ((pwgmedia = _cupsPWGMediaBySize(width, length)) != NULL) + media = pwgmedia->pwg; - if (cupsGetOption("InputSlot", num_options, options) == NULL) - ppd_mark_option(ppd, "InputSlot", s); + cupsFreeOptions(num_media_sizes, media_sizes); + } - if (cupsGetOption("MediaType", num_options, options) == NULL) - ppd_mark_option(ppd, "MediaType", s); + cupsFreeOptions(num_media_cols, media_cols); + } - if (cupsGetOption("EFMediaType", num_options, options) == NULL) - ppd_mark_option(ppd, "EFMediaType", s); /* EFI */ + if (media) + { + /* + * Loop through the option string, separating it at commas and + * marking each individual option as long as the corresponding + * PPD option (PageSize, InputSlot, etc.) is not also set. + * + * For PageSize, we also check for an empty option value since + * some versions of MacOS X use it to specify auto-selection + * of the media based solely on the size. + */ - if (cupsGetOption("EFMediaQualityMode", num_options, options) == NULL) - ppd_mark_option(ppd, "EFMediaQualityMode", s); /* EFI */ + for (val = media; *val;) + { + /* + * Extract the sub-option from the string... + */ - if (!strcasecmp(s, "manual") && - !cupsGetOption("ManualFeed", num_options, options)) - ppd_mark_option(ppd, "ManualFeed", "True"); - } + for (ptr = s; *val && *val != ',' && (ptr - s) < (sizeof(s) - 1);) + *ptr++ = *val++; + *ptr++ = '\0'; + + if (*val == ',') + val ++; + + /* + * Mark it... + */ + + if (!page_size || !page_size[0]) + ppd_mark_size(ppd, s); + + if (cupsGetOption("InputSlot", num_options, options) == NULL) + ppd_mark_option(ppd, "InputSlot", s); + + if (cupsGetOption("MediaType", num_options, options) == NULL) + ppd_mark_option(ppd, "MediaType", s); + + if (cupsGetOption("EFMediaType", num_options, options) == NULL) + ppd_mark_option(ppd, "EFMediaType", s); /* EFI */ + + if (cupsGetOption("EFMediaQualityMode", num_options, options) == NULL) + ppd_mark_option(ppd, "EFMediaQualityMode", s); /* EFI */ + + if (!strcasecmp(s, "manual") && + !cupsGetOption("ManualFeed", num_options, options)) + ppd_mark_option(ppd, "ManualFeed", "True"); } + } + + /* + * Mark other options... + */ + + for (i = num_options, optptr = options; i > 0; i --, optptr ++) + if (!strcasecmp(optptr->name, "media") || + !strcasecmp(optptr->name, "media-col")) + continue; else if (!strcasecmp(optptr->name, "sides")) { for (j = 0; diff --git a/cups/testipp.c b/cups/testipp.c index aa119ace9..972c6474d 100644 --- a/cups/testipp.c +++ b/cups/testipp.c @@ -3,7 +3,7 @@ * * IPP test program for the Common UNIX Printing System (CUPS). * - * Copyright 2007 by Apple Inc. + * Copyright 2007-2009 by Apple Inc. * Copyright 1997-2005 by Easy Software Products. * * These coded instructions, statements, and computer programs are the @@ -488,7 +488,7 @@ print_attributes(ipp_t *ipp, /* I - IPP request */ for (group = IPP_TAG_ZERO, attr = ipp->attrs; attr; attr = attr->next) { - if ((attr->group_tag == IPP_TAG_ZERO && indent <= 8) || !attr->name) + if (!attr->name && indent == 4) { group = IPP_TAG_ZERO; putchar('\n'); @@ -499,17 +499,10 @@ print_attributes(ipp_t *ipp, /* I - IPP request */ { group = attr->group_tag; - putchar('\n'); - for (i = 4; i < indent; i ++) - putchar(' '); - - printf("%s:\n\n", tags[group]); + printf("\n%*s%s:\n\n", indent - 4, "", tags[group]); } - for (i = 0; i < indent; i ++) - putchar(' '); - - printf("%s (", attr->name); + printf("%*s%s (", indent, "", attr->name ? attr->name : "(null)"); if (attr->num_values > 1) printf("1setOf "); printf("%s):", tags[attr->value_tag]); diff --git a/cups/testppd.c b/cups/testppd.c index 97337ccac..44c43b55b 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -113,7 +113,8 @@ main(int argc, /* I - Number of command-line arguments */ int conflicts; /* Number of conflicts */ char *s; /* String */ char buffer[8192]; /* String buffer */ - const char *text; /* Localized text */ + const char *text, /* Localized text */ + *val; /* Option value */ int num_options; /* Number of options */ cups_option_t *options; /* Options */ ppd_size_t minsize, /* Minimum size */ @@ -265,8 +266,26 @@ main(int argc, /* I - Number of command-line arguments */ * Test constraints... */ - fputs("ppdConflicts(): ", stdout); + fputs("cupsGetConflicts(InputSlot=Envelope): ", stdout); ppdMarkOption(ppd, "PageSize", "Letter"); + + num_options = cupsGetConflicts(ppd, "InputSlot", "Envelope", &options); + if (num_options != 2 || + (val = cupsGetOption("PageRegion", num_options, options)) == NULL || + strcasecmp(val, "Letter") || + (val = cupsGetOption("PageSize", num_options, options)) == NULL || + strcasecmp(val, "Letter")) + { + printf("FAIL (%d options:", num_options); + for (i = 0; i < num_options; i ++) + printf(" %s=%s", options[i].name, options[i].value); + puts(")"); + status ++; + } + else + puts("PASS"); + + fputs("ppdConflicts(): ", stdout); ppdMarkOption(ppd, "InputSlot", "Envelope"); if ((conflicts = ppdConflicts(ppd)) == 2) diff --git a/doc/Makefile b/doc/Makefile index bf8bca0d1..0c894afaa 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -104,6 +104,7 @@ HELPFILES = \ help/ref-snmp-conf.html \ help/ref-subscriptions-conf.html \ help/security.html \ + help/sharing.html \ help/spec-banner.html \ help/spec-browsing.html \ help/spec-cmp.html \ diff --git a/doc/help/api-array.html b/doc/help/api-array.html index f7373e3b6..1916f3d59 100644 --- a/doc/help/api-array.html +++ b/doc/help/api-array.html @@ -388,8 +388,8 @@ div.contents ul.subcontents li {
  • cupsArrayNext
  • cupsArrayPrev
  • cupsArrayRemove
  • -
  • cupsArraySave.">cupsArrayRestore
  • -
  • cupsArrayRestore.">cupsArraySave
  • +
  • cupsArrayRestore
  • +
  • cupsArraySave
  • cupsArrayUserData
  • Data Types
  • Functions