From d09495fadd23469999a64b1812ffb880bf4372de Mon Sep 17 00:00:00 2001 From: jlovell Date: Wed, 30 Aug 2006 16:09:13 +0000 Subject: [PATCH] Load cups into easysw/current. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@211 a1ca3aef-8c08-0410-bb20-df032aa958be --- CHANGES.txt | 76 +++- Makedefs.in | 8 +- Makefile | 35 +- README.txt | 2 +- backend/backend-private.h | 12 +- backend/ieee1284.c | 8 +- backend/ipp.c | 47 ++- backend/lpd.c | 5 +- backend/runloop.c | 10 +- backend/snmp.c | 305 ++++++++++++++-- berkeley/lpc.c | 6 +- berkeley/lpq.c | 9 +- berkeley/lpr.c | 8 +- berkeley/lprm.c | 10 +- cgi-bin/admin.c | 102 ++++-- cgi-bin/ipp-var.c | 5 +- config-scripts/cups-common.m4 | 6 +- config-scripts/cups-defaults.m4 | 8 +- config-scripts/cups-directories.m4 | 32 +- config-scripts/cups-manpages.m4 | 12 +- configure.in | 18 +- cups-config.in | 5 +- cups/Makefile | 5 +- cups/adminutil.c | 45 ++- cups/attr.c | 50 ++- cups/cups.h | 8 +- cups/dir.h | 10 +- cups/file.c | 5 +- cups/file.h | 14 +- cups/http.c | 35 +- cups/http.h | 14 +- cups/i18n.h | 5 +- cups/ipp-support.c | 35 +- cups/ipp.h | 10 +- cups/langprintf.c | 50 ++- cups/language.c | 6 +- cups/libcups_s.exp | 1 + cups/localize.c | 25 +- cups/notify.c | 6 +- cups/ppd.c | 8 +- cups/testi18n.c | 9 +- cups/testppd.c | 22 +- cups/transcode.c | 8 +- cups/usersys.c | 20 +- desktop/cups.desktop | 10 +- doc/help/ref-snmp-conf.html | 17 + doc/help/translation.html | 53 ++- filter/pstops.c | 14 +- init/org.cups.cups-lpd.plist | 33 ++ man/cups-snmp.conf.man | 7 +- packaging/cups.list.in | 58 ++- packaging/installer.gif | Bin 0 -> 2686 bytes scheduler/Dependencies | 157 ++++---- scheduler/Makefile | 21 +- scheduler/auth.c | 13 +- scheduler/client.c | 189 +++++++++- scheduler/client.h | 5 +- scheduler/conf.c | 65 ++-- scheduler/cups-lpd.c | 12 +- scheduler/cups-polld.c | 97 +++-- scheduler/dirsvc.c | 37 +- scheduler/dirsvc.h | 5 +- scheduler/ipp.c | 125 ++++--- scheduler/job.c | 43 +-- scheduler/job.h | 6 +- scheduler/main.c | 10 +- scheduler/mime.h | 12 +- scheduler/policy.c | 8 +- scheduler/printers.c | 16 +- scheduler/printers.h | 5 +- scheduler/statbuf.c | 6 +- scheduler/subscriptions.c | 16 +- scheduler/sysman.c | 7 +- scheduler/testlpd.c | 550 +++++++++++++++++++++++++++++ systemv/accept.c | 6 +- systemv/cancel.c | 6 +- systemv/cupsaddsmb.c | 6 +- systemv/cupstestdsc.c | 8 +- systemv/cupstestppd.c | 88 ++++- systemv/lp.c | 6 +- systemv/lpadmin.c | 6 +- systemv/lpinfo.c | 6 +- systemv/lpmove.c | 6 +- systemv/lpoptions.c | 6 +- systemv/lppasswd.c | 6 +- systemv/lpstat.c | 39 +- templates/Makefile | 5 +- templates/es/norestart.tmpl | 2 + templates/job-cancel.tmpl | 2 +- templates/jobs.tmpl | 2 +- templates/norestart.tmpl | 2 + test/4.2-cups-printer-ops.test | 6 +- test/4.4-subscription-ops.test | 10 +- test/ipptest.c | 8 +- tools/testosx | 5 +- 95 files changed, 2306 insertions(+), 642 deletions(-) create mode 100644 init/org.cups.cups-lpd.plist create mode 100644 packaging/installer.gif create mode 100644 scheduler/testlpd.c create mode 100644 templates/es/norestart.tmpl create mode 100644 templates/norestart.tmpl diff --git a/CHANGES.txt b/CHANGES.txt index f55439e5f..5ac921349 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,80 @@ -CHANGES.txt - 2006-07-18 +CHANGES.txt - 2006-08-29 ------------------------ +CHANGES IN CUPS V1.2.3 + + - The scheduler did not send job-state or + job-config-changed events when a job was held, + released, or changed (STR #1947) + - The scheduler now aborts if the configuration file and + directory checks fail (STR #1941) + - Fixed a problem with ippPort() not using the port + number that was set via the client.conf file or + CUPS_SERVER environment variable (STR #1945) + - HTTP headers were not buffered (STR #1899) + - Some IPP printers (HP) did not like UTF-8 job names + (STR #1837) + - The CUPS desktop icon is now localized for Polish (STR + #1920) + - Printer options were not always honored when printing + from Windows clients (STR #1839) + - The openssl command would lock up the scheduler when + generating an encryption certificate on some platforms + due to a lack of entropy for the random number + generator (STR #1876) + - The web admin page did not recognize that "Listen 631" + enabled remote access (STR #1908) + - The web admin page did not check whether changes were + made to the Basic Server Settings check boxes (STR + #1908) + - The IPP backend could generate N*N copies in certain + edge cases. + - The scheduler did not restore remote printers properly + when BrowseShortNames was enabled (STR #1893) + - Polling did not handle changes to the network + environment on Mac OS X (STR #1896) + - The "make test" subscription tests used invalid + notify-recipient-uri values (STR #1910) + - Printers could be left in an undefined state on system + sleep (STR #1905) + - The Berkeley and System V commands did not always use + the expected character set (STR #1915) + - Remote printing fixes (STR #1881) + - The cupstestppd utility did not validate translation + strings for custom options properly. + - Multi-language PPD files were not properly localized in + the web interface (STR #1913) + - The admin page's simple settings options did not check + for local domain socket or IPv6 addresses and did not + use "localhost" as the listen address. + - An empty BrowseProtocols, BrowseLocalProtocols, or + BrowseRemoteProtocols line would crash the scheduler + instead of disabling the corresponding browsing options. + - The scheduler now logs IPP operation status as debug + messages instead of info or error. + - cupsFileRewind() didn't clear the end-of-file state. + - cupstestppd didn't report the actual misspelling of the + 1284DeviceID attribute (STR #1849) + - BrowseRelay didn't work on Debian (STR #1887) + - configure --without-languages didn't work (STR #1879) + - Manually added remote printers did not work (STR #1881) + - The header was not installed. + - Updated the build files for Autoconf 2.60 (STR #1853) + - The scheduler incorrectly terminated the polling + processes after receiving a partial log line. + - The cups-lpd mini-daemon reported "No printer-state + attribute found" errors when reporting the queue status + (PR #6250, STR #1821) + - SNMP backend improvements (STR #1737, STR #1742, STR + #1790, STR #1835, STR #1880) + - The scheduler erroneously reported an error with the + CGI pipe (STR #1860) + - Fixed HP-UX compile problems (STR #1858, STR #1859) + - cupstestppd crashed with some PPD files (STR #1864) + - The and header files did not + work with C++. + + CHANGES IN CUPS V1.2.2 - Documentation updates (STR #1765, STR #1780) diff --git a/Makedefs.in b/Makedefs.in index 10198cc49..97c55e09c 100644 --- a/Makedefs.in +++ b/Makedefs.in @@ -1,5 +1,5 @@ # -# "$Id: Makedefs.in 5609 2006-05-30 20:31:10Z mike $" +# "$Id: Makedefs.in 5799 2006-08-03 00:54:38Z mike $" # # Common makefile definitions for the Common UNIX Printing System (CUPS). # @@ -174,12 +174,16 @@ UNINSTALL64 = @UNINSTALL64@ # We have to define these first because autoconf uses ${prefix} # and ${exec_prefix} for most of the other directories... # +# The "datarootdir" variable may not get defined if you are using +# a version of autoconf prior to 2.60. +# # This is immediately followed by definition in ALL CAPS for the # needed directories... # bindir = @bindir@ datadir = @datadir@ +datarootdir = @datarootdir@ exec_prefix = @exec_prefix@ includedir = @includedir@ infodir = @infodir@ @@ -265,5 +269,5 @@ DBUSDIR = @DBUSDIR@ # -# End of "$Id: Makedefs.in 5609 2006-05-30 20:31:10Z mike $" +# End of "$Id: Makedefs.in 5799 2006-08-03 00:54:38Z mike $" # diff --git a/Makefile b/Makefile index d1fe2d02d..45dd92c05 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 5547 2006-05-19 12:44:29Z mike $" +# "$Id: Makefile 5902 2006-08-29 15:51:19Z mike $" # # Top-level Makefile for the Common UNIX Printing System (CUPS). # @@ -121,8 +121,9 @@ install: installhdrs $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \ $(INSTALL_DATA) init/Localizable.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \ elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \ - echo Installing LaunchDaemons configuration file...; \ + echo Installing LaunchDaemons configuration files...; \ $(INSTALL_DATA) init/org.cups.cupsd.plist $(BUILDROOT)$(DEFAULT_LAUNCHD_CONF); \ + $(INSTALL_DATA) init/org.cups.cups-lpd.plist $(BUILDROOT)/System/Library/LaunchDaemons; \ else \ echo Installing RC script...; \ $(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDDIR)/cups; \ @@ -220,24 +221,44 @@ uninstall: # Run the test suite... # -check test: all +test: all echo Running CUPS test suite... cd test; ./run-stp-tests.sh +check: all + echo Running CUPS test suite with defaults... + cd test; ./run-stp-tests.sh 1 0 n + + # # Make software distributions using EPM (http://www.easysw.com/epm/)... # -EPMFLAGS = -v +EPMFLAGS = -v --output-dir dist $(EPMARCH) -aix bsd deb depot inst osx pkg rpm setld slackware swinstall tardist: +aix bsd deb depot inst pkg rpm setld slackware swinstall tardist: epm $(EPMFLAGS) -f $@ cups packaging/cups.list epm: - epm $(EPMFLAGS) cups packaging/cups.list + epm $(EPMFLAGS) -s packaging/installer.gif cups packaging/cups.list + +osx: + epm $(EPMFLAGS) -f osx -s packaging/installer.tif cups packaging/cups.list + +.PHONEY: dist +dist: all + $(RM) -r dist + $(MAKE) $(MFLAGS) epm + case `uname` in \ + *BSD*) $(MAKE) $(MFLAGS) bsd;; \ + Darwin*) $(MAKE) $(MFLAGS) osx;; \ + IRIX*) $(MAKE) $(MFLAGS) tardist;; \ + Linux*) $(MAKE) $(MFLAGS) rpm;; \ + SunOS*) $(MAKE) $(MFLAGS) pkg;; \ + esac # -# End of "$Id: Makefile 5547 2006-05-19 12:44:29Z mike $". +# End of "$Id: Makefile 5902 2006-08-29 15:51:19Z mike $". # diff --git a/README.txt b/README.txt index 4595be8c4..34983cd94 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -README - CUPS v1.2.0 - 2006-05-08 +README - CUPS v1.2.3 - 2006-08-28 --------------------------------- Looking for compile instructions? Read the file "INSTALL.txt" diff --git a/backend/backend-private.h b/backend/backend-private.h index f9384931c..14b93cc87 100644 --- a/backend/backend-private.h +++ b/backend/backend-private.h @@ -1,5 +1,5 @@ /* - * "$Id: backend-private.h 5592 2006-05-27 03:11:52Z mike $" + * "$Id: backend-private.h 5771 2006-07-20 18:06:20Z mike $" * * Backend support definitions for the Common UNIX Printing System (CUPS). * @@ -45,9 +45,9 @@ * C++ magic... */ -# ifdef _cplusplus +# ifdef __cplusplus extern "C" { -# endif /* _cplusplus */ +# endif /* __cplusplus */ /* @@ -62,12 +62,12 @@ extern int backendGetMakeModel(const char *device_id, char *make_model, extern ssize_t backendRunLoop(int print_fd, int device_fd, int use_bc); -# ifdef _cplusplus +# ifdef __cplusplus } -# endif /* _cplusplus */ +# endif /* __cplusplus */ #endif /* !_CUPS_BACKEND_PRIVATE_H_ */ /* - * End of "$Id: backend-private.h 5592 2006-05-27 03:11:52Z mike $". + * End of "$Id: backend-private.h 5771 2006-07-20 18:06:20Z mike $". */ diff --git a/backend/ieee1284.c b/backend/ieee1284.c index f564215e0..f54149367 100644 --- a/backend/ieee1284.c +++ b/backend/ieee1284.c @@ -1,5 +1,5 @@ /* - * "$Id: ieee1284.c 5591 2006-05-26 19:51:59Z mike $" + * "$Id: ieee1284.c 5866 2006-08-23 03:03:49Z mike $" * * IEEE-1284 support functions for the Common UNIX Printing System (CUPS). * @@ -233,6 +233,8 @@ backendGetDeviceID( if (!strcasecmp(manufacturer, "Hewlett-Packard")) strcpy(manufacturer, "HP"); + else if (!strcasecmp(manufacturer, "Lexmark International")) + strcpy(manufacturer, "Lexmark"); } else { @@ -399,6 +401,8 @@ backendGetMakeModel( { if (!strncasecmp(mfg, "Hewlett-Packard", 15)) strlcpy(make_model, "HP", make_model_size); + else if (!strncasecmp(mfg, "Lexmark International", 21)) + strlcpy(make_model, "Lexmark", make_model_size); else strlcpy(make_model, mfg, make_model_size); @@ -495,5 +499,5 @@ backendGetMakeModel( /* - * End of "$Id: ieee1284.c 5591 2006-05-26 19:51:59Z mike $". + * End of "$Id: ieee1284.c 5866 2006-08-23 03:03:49Z mike $". */ diff --git a/backend/ipp.c b/backend/ipp.c index e64d6c44c..73ad5f6f4 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c 5724 2006-07-12 19:42:35Z mike $" + * "$Id: ipp.c 5889 2006-08-24 21:44:35Z mike $" * * IPP backend for the Common UNIX Printing System (CUPS). * @@ -132,13 +132,13 @@ main(int argc, /* I - Number of command-line args */ ipp_attribute_t *format_sup; /* document-format-supported */ ipp_attribute_t *printer_state; /* printer-state attribute */ ipp_attribute_t *printer_accepting; /* printer-is-accepting-jobs */ - int copies; /* Number of copies remaining */ + int copies, /* Number of copies for job */ + copies_remaining; /* Number of copies remaining */ const char *content_type; /* CONTENT_TYPE environment variable */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Actions for POSIX signals */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ int version; /* IPP version */ - int reasons; /* Number of printer-state-reasons */ static const char * const pattrs[] = { /* Printer attributes we want */ "copies-supported", @@ -214,6 +214,9 @@ main(int argc, /* I - Number of command-line args */ if ((content_type = getenv("CONTENT_TYPE")) == NULL) content_type = "application/octet-stream"; + if (!strncmp(content_type, "printer/", 8)) + content_type = "application/vnd.cups-raw"; + /* * Extract the hostname and printer name from the URI... */ @@ -736,19 +739,25 @@ main(int argc, /* I - Number of command-line args */ * See if the printer supports multiple copies... */ + copies = atoi(argv[4]); + if (copies_sup || argc < 7) - copies = 1; + { + copies_remaining = 1; + + if (argc < 7) + copies = 1; + } else - copies = atoi(argv[4]); + copies_remaining = copies; /* * Then issue the print-job request... */ - reasons = 0; job_id = 0; - while (copies > 0) + while (copies_remaining > 0) { /* * Build the IPP request... @@ -775,7 +784,13 @@ main(int argc, /* I - Number of command-line args */ fprintf(stderr, "DEBUG: requesting-user-name = \"%s\"\n", argv[2]); - if (argv[3][0]) + /* + * Only add a "job-name" attribute if the remote server supports + * copy generation - some IPP implementations like HP's don't seem + * to like UTF-8 job names (STR #1837)... + */ + + if (argv[3][0] && copies_sup) ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name", NULL, argv[3]); @@ -822,8 +837,9 @@ main(int argc, /* I - Number of command-line args */ * number of copies to 1... */ - content_type = "application/postscript"; - copies = 1; + content_type = "application/postscript"; + copies = 1; + copies_remaining = 1; } } #endif /* __APPLE__ */ @@ -851,8 +867,9 @@ main(int argc, /* I - Number of command-line args */ */ cupsEncodeOptions(request, num_options, options); + ippAddInteger(request, IPP_TAG_JOB, IPP_TAG_INTEGER, "copies", - atoi(argv[4])); + copies); } cupsFreeOptions(num_options, options); @@ -952,13 +969,13 @@ main(int argc, /* I - Number of command-line args */ if (ipp_status <= IPP_OK_CONFLICT && argc > 6) { fprintf(stderr, "PAGE: 1 %d\n", copies_sup ? atoi(argv[4]) : 1); - copies --; + copies_remaining --; } else if (ipp_status == IPP_SERVICE_UNAVAILABLE || ipp_status == IPP_PRINTER_BUSY) break; else - copies --; + copies_remaining --; /* * Wait for the job to complete... @@ -1300,6 +1317,8 @@ password_cb(const char *prompt) /* I - Prompt (not used) */ #endif /* __APPLE__ */ exit(CUPS_BACKEND_AUTH_REQUIRED); + + return (NULL); /* Eliminate compiler warning */ } } @@ -1622,5 +1641,5 @@ sigterm_handler(int sig) /* I - Signal */ /* - * End of "$Id: ipp.c 5724 2006-07-12 19:42:35Z mike $". + * End of "$Id: ipp.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/backend/lpd.c b/backend/lpd.c index ef7ef05d3..218dba737 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -1,5 +1,5 @@ /* - * "$Id: lpd.c 5495 2006-05-05 17:58:07Z mike $" + * "$Id: lpd.c 5886 2006-08-24 19:53:17Z mike $" * * Line Printer Daemon backend for the Common UNIX Printing System (CUPS). * @@ -261,6 +261,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* We want to pass utf-8 characters, not re-map them (3071945) */ sanitize_title = 0; + /* Get the default timeout from a system preference... */ { CFPropertyListRef pvalue; /* Preference value */ SInt32 toval; /* Timeout value */ @@ -1230,5 +1231,5 @@ sigterm_handler(int sig) /* I - Signal */ /* - * End of "$Id: lpd.c 5495 2006-05-05 17:58:07Z mike $". + * End of "$Id: lpd.c 5886 2006-08-24 19:53:17Z mike $". */ diff --git a/backend/runloop.c b/backend/runloop.c index 03bb09282..82673a447 100644 --- a/backend/runloop.c +++ b/backend/runloop.c @@ -1,5 +1,5 @@ /* - * "$Id: runloop.c 5726 2006-07-12 20:00:11Z mike $" + * "$Id: runloop.c 5776 2006-07-26 20:55:13Z mike $" * * Common run loop API for the Common UNIX Printing System (CUPS). * @@ -33,7 +33,11 @@ */ #include "backend-private.h" -#include +#ifdef __hpux +# include +#else +# include +#endif /* __hpux */ /* @@ -254,5 +258,5 @@ backendRunLoop(int print_fd, /* I - Print file descriptor */ /* - * End of "$Id: runloop.c 5726 2006-07-12 20:00:11Z mike $". + * End of "$Id: runloop.c 5776 2006-07-26 20:55:13Z mike $". */ diff --git a/backend/snmp.c b/backend/snmp.c index 56e7ad9e7..4a90f2ebc 100644 --- a/backend/snmp.c +++ b/backend/snmp.c @@ -1,5 +1,5 @@ /* - * "$Id: snmp.c 5736 2006-07-13 19:59:36Z mike $" + * "$Id: snmp.c 5898 2006-08-28 18:54:10Z mike $" * * SNMP discovery backend for the Common UNIX Printing System (CUPS). * @@ -52,6 +52,7 @@ * packed integer value. * compare_cache() - Compare two cache entries. * debug_printf() - Display some debugging information. + * do_request() - Do a non-blocking IPP request. * fix_make_model() - Fix common problems in the make-and-model * string. * free_array() - Free an array of strings. @@ -59,7 +60,7 @@ * get_interface_addresses() - Get the broadcast address(es) associated * with an interface. * hex_debug() - Output hex debugging data... - * list_devices() - List all of the devices we found... + * list_device() - List a device we found... * open_snmp_socket() - Open the SNMP broadcast socket. * password_cb() - Handle authentication requests. * probe_device() - Probe a device to discover whether it is a @@ -193,6 +194,13 @@ typedef struct snmp_packet_s /**** SNMP packet ****/ } snmp_packet_t; +/* + * Private CUPS API to set the last error... + */ + +extern void _cupsSetError(ipp_status_t status, const char *message); + + /* * Local functions... */ @@ -238,6 +246,8 @@ static int asn1_size_oid(const int *oid); static int asn1_size_packed(int integer); static int compare_cache(snmp_cache_t *a, snmp_cache_t *b); static void debug_printf(const char *format, ...); +static ipp_t *do_request(http_t *http, ipp_t *request, + const char *resource); static void fix_make_model(char *make_model, const char *old_make_model, int make_model_size); @@ -245,7 +255,7 @@ static void free_array(cups_array_t *a); static void free_cache(void); static http_addrlist_t *get_interface_addresses(const char *ifname); static void hex_debug(unsigned char *buffer, size_t len); -static void list_devices(void); +static void list_device(snmp_cache_t *cache); static int open_snmp_socket(void); static const char *password_cb(const char *prompt); static void probe_device(snmp_cache_t *device); @@ -278,6 +288,7 @@ static int DeviceDescOID[] = { 1, 3, 6, 1, 2, 1, 25, 3, static unsigned DeviceTypeRequest; static unsigned DeviceDescRequest; static int HostNameLookups = 0; +static int MaxRunTime = 10; static struct timeval StartTime; @@ -290,6 +301,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ char *argv[]) /* I - Command-line arguments */ { int fd; /* SNMP socket */ +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + struct sigaction action; /* Actions for POSIX signals */ +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ /* @@ -308,6 +322,23 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ cupsSetPasswordCB(password_cb); + /* + * Catch SIGALRM signals... + */ + +#ifdef HAVE_SIGSET + sigset(SIGALRM, alarm_handler); +#elif defined(HAVE_SIGACTION) + memset(&action, 0, sizeof(action)); + + sigemptyset(&action.sa_mask); + sigaddset(&action.sa_mask, SIGALRM); + action.sa_handler = alarm_handler; + sigaction(SIGALRM, &action, NULL); +#else + signal(SIGALRM, alarm_handler); +#endif /* HAVE_SIGSET */ + /* * Open the SNMP socket... */ @@ -329,12 +360,6 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ scan_devices(fd); - /* - * Display the results... - */ - - list_devices(); - /* * Close, free, and return with no errors... */ @@ -384,7 +409,7 @@ add_cache(http_addr_t *addr, /* I - Device IP address */ debug_printf("DEBUG: add_cache(addr=%p, addrname=\"%s\", uri=\"%s\", " "id=\"%s\", make_and_model=\"%s\")\n", - addr, addrname, uri ? uri : "(null)", id ? id : "(null)", + addr, addrname, uri ? uri : "(null)", id ? id : "(null)", make_and_model ? make_and_model : "(null)"); temp = calloc(1, sizeof(snmp_cache_t)); @@ -402,6 +427,9 @@ add_cache(http_addr_t *addr, /* I - Device IP address */ temp->make_and_model = strdup(make_and_model); cupsArrayAdd(Devices, temp); + + if (uri) + list_device(temp); } @@ -418,6 +446,10 @@ alarm_handler(int sig) /* I - Signal number */ (void)sig; +#if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION) + signal(SIGALRM, alarm_handler); +#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */ + if (DebugLevel) write(2, "DEBUG: ALARM!\n", 14); } @@ -1227,6 +1259,173 @@ debug_printf(const char *format, /* I - Printf-style format string */ } +/* + * 'do_request()' - Do a non-blocking IPP request. + */ + +static ipp_t * /* O - Response data or NULL */ +do_request(http_t *http, /* I - HTTP connection to server */ + ipp_t *request, /* I - IPP request */ + const char *resource) /* I - HTTP resource for POST */ +{ + ipp_t *response; /* IPP response data */ + http_status_t status; /* Status of HTTP request */ + ipp_state_t state; /* State of IPP processing */ + + + /* + * Setup the HTTP variables needed... + */ + + httpClearFields(http); + httpSetLength(http, ippLength(request)); + httpSetField(http, HTTP_FIELD_CONTENT_TYPE, "application/ipp"); + + /* + * Do the POST request... + */ + + debug_printf("DEBUG: %.3f POST %s...\n", run_time(), resource); + + if (httpPost(http, resource)) + { + if (httpReconnect(http)) + { + _cupsSetError(IPP_DEVICE_ERROR, "Unable to reconnect"); + return (NULL); + } + else if (httpPost(http, resource)) + { + _cupsSetError(IPP_GONE, "Unable to POST"); + return (NULL); + } + } + + /* + * Send the IPP data... + */ + + request->state = IPP_IDLE; + status = HTTP_CONTINUE; + + while ((state = ippWrite(http, request)) != IPP_DATA) + if (state == IPP_ERROR) + { + status = HTTP_ERROR; + break; + } + else if (httpCheck(http)) + { + if ((status = httpUpdate(http)) != HTTP_CONTINUE) + break; + } + + /* + * Get the server's return status... + */ + + debug_printf("DEBUG: %.3f Getting response...\n", run_time()); + + while (status == HTTP_CONTINUE) + if (httpWait(http, 1000)) + status = httpUpdate(http); + else + { + status = HTTP_ERROR; + http->error = ETIMEDOUT; + } + + if (status != HTTP_OK) + { + /* + * Flush any error message... + */ + + httpFlush(http); + response = NULL; + } + else + { + /* + * Read the response... + */ + + response = ippNew(); + + while ((state = ippRead(http, response)) != IPP_DATA) + if (state == IPP_ERROR) + { + /* + * Delete the response... + */ + + ippDelete(response); + response = NULL; + + _cupsSetError(IPP_SERVICE_UNAVAILABLE, strerror(errno)); + break; + } + } + + /* + * Delete the original request and return the response... + */ + + ippDelete(request); + + if (response) + { + ipp_attribute_t *attr; /* status-message attribute */ + + + attr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT); + + _cupsSetError(response->request.status.status_code, + attr ? attr->values[0].string.text : + ippErrorString(response->request.status.status_code)); + } + else if (status != HTTP_OK) + { + switch (status) + { + case HTTP_NOT_FOUND : + _cupsSetError(IPP_NOT_FOUND, httpStatus(status)); + break; + + case HTTP_UNAUTHORIZED : + _cupsSetError(IPP_NOT_AUTHORIZED, httpStatus(status)); + break; + + case HTTP_FORBIDDEN : + _cupsSetError(IPP_FORBIDDEN, httpStatus(status)); + break; + + case HTTP_BAD_REQUEST : + _cupsSetError(IPP_BAD_REQUEST, httpStatus(status)); + break; + + case HTTP_REQUEST_TOO_LARGE : + _cupsSetError(IPP_REQUEST_VALUE, httpStatus(status)); + break; + + case HTTP_NOT_IMPLEMENTED : + _cupsSetError(IPP_OPERATION_NOT_SUPPORTED, httpStatus(status)); + break; + + case HTTP_NOT_SUPPORTED : + _cupsSetError(IPP_VERSION_NOT_SUPPORTED, httpStatus(status)); + break; + + default : + _cupsSetError(IPP_SERVICE_UNAVAILABLE, httpStatus(status)); + break; + } + } + + return (response); +} + + /* * 'fix_make_model()' - Fix common problems in the make-and-model string. */ @@ -1288,6 +1487,16 @@ fix_make_model( _cups_strcpy(mmptr, mmptr + 7); } + if ((mmptr = strstr(make_model, " Network")) != NULL) + { + /* + * Drop unnecessary informational text, e.g. "Xerox DocuPrint N2025 + * Network LaserJet - 2.12" becomes "Xerox DocuPrint N2025"... + */ + + *mmptr = '\0'; + } + if ((mmptr = strchr(make_model, ',')) != NULL) { /* @@ -1422,24 +1631,18 @@ hex_debug(unsigned char *buffer, /* I - Buffer */ /* - * 'list_devices()' - List all of the devices we found... + * 'list_device()' - List a device we found... */ static void -list_devices(void) +list_device(snmp_cache_t *cache) /* I - Cached device */ { - snmp_cache_t *cache; /* Cached device */ - - - for (cache = (snmp_cache_t *)cupsArrayFirst(Devices); - cache; - cache = (snmp_cache_t *)cupsArrayNext(Devices)) - if (cache->uri) - printf("network %s \"%s\" \"%s %s\" \"%s\"\n", - cache->uri, - cache->make_and_model ? cache->make_and_model : "Unknown", - cache->make_and_model ? cache->make_and_model : "Unknown", - cache->addrname, cache->id ? cache->id : ""); + if (cache->uri) + printf("network %s \"%s\" \"%s %s\" \"%s\"\n", + cache->uri, + cache->make_and_model ? cache->make_and_model : "Unknown", + cache->make_and_model ? cache->make_and_model : "Unknown", + cache->addrname, cache->id ? cache->id : ""); } @@ -1524,7 +1727,29 @@ probe_device(snmp_cache_t *device) /* I - Device */ debug_printf("DEBUG: %.3f Probing %s...\n", run_time(), device->addrname); - if ((http = httpConnect(device->addrname, 631)) != NULL) + if (device->make_and_model && + (!strncasecmp(device->make_and_model, "Xerox", 5) || + !strncasecmp(device->make_and_model, "Kyocera", 7))) + { + /* + * Xerox and Kyocera printers often lock up on IPP probes, so exclude + * them from the IPP connection test... + */ + + http = NULL; + } + else + { + /* + * Otherwise, try connecting for up to 1 second... + */ + + alarm(1); + http = httpConnect(device->addrname, 631); + alarm(0); + } + + if (http); { /* * IPP is supported... @@ -1551,8 +1776,6 @@ probe_device(snmp_cache_t *device) /* I - Device */ }; - debug_printf("DEBUG: %s supports IPP!\n", device->addrname); - /* * Use non-blocking IO... */ @@ -1568,6 +1791,13 @@ probe_device(snmp_cache_t *device) /* I - Device */ i < (int)(sizeof(resources) / sizeof(resources[0])); i ++) { + /* + * Stop early if we are out of time... + */ + + if (MaxRunTime > 0 && run_time() >= MaxRunTime) + break; + /* * Don't look past /ipp if we have found a working URI... */ @@ -1578,16 +1808,14 @@ probe_device(snmp_cache_t *device) /* I - Device */ httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, device->addrname, 631, resources[i]); - debug_printf("DEBUG: Trying %s (num_uris=%d)\n", uri, num_uris); - request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); - response = cupsDoRequest(http, request, resources[i]); + response = do_request(http, request, resources[i]); - debug_printf("DEBUG: %s %s (%s)\n", uri, + debug_printf("DEBUG: %.3f %s %s (%s)\n", run_time(), uri, ippErrorString(cupsLastError()), cupsLastErrorString()); if (response && response->request.status.status_code == IPP_OK) @@ -1726,6 +1954,7 @@ read_snmp_conf(const char *address) /* I - Single address to probe */ int linenum; /* Line number */ const char *cups_serverroot; /* CUPS_SERVERROOT env var */ const char *debug; /* CUPS_DEBUG_LEVEL env var */ + const char *runtime; /* CUPS_MAX_RUN_TIME env var */ /* @@ -1741,6 +1970,9 @@ read_snmp_conf(const char *address) /* I - Single address to probe */ if ((debug = getenv("CUPS_DEBUG_LEVEL")) != NULL) DebugLevel = atoi(debug); + if ((runtime = getenv("CUPS_MAX_RUN_TIME")) != NULL) + MaxRunTime = atoi(runtime); + /* * Find the snmp.conf file... */ @@ -1777,6 +2009,8 @@ read_snmp_conf(const char *address) /* I - Single address to probe */ !strcasecmp(value, "yes") || !strcasecmp(value, "true") || !strcasecmp(value, "double"); + else if (!strcasecmp(line, "MaxRunTime")) + MaxRunTime = atoi(value); else fprintf(stderr, "ERROR: Unknown directive %s on line %d of %s!\n", line, linenum, filename); @@ -2075,7 +2309,9 @@ scan_devices(int fd) /* I - SNMP socket */ for (device = (snmp_cache_t *)cupsArrayFirst(Devices); device; device = (snmp_cache_t *)cupsArrayNext(Devices)) - if (!device->uri) + if (MaxRunTime > 0 && run_time() >= MaxRunTime) + break; + else if (!device->uri) probe_device(device); debug_printf("DEBUG: %.3f Scan complete!\n", run_time()); @@ -2169,7 +2405,6 @@ try_connect(http_addr_t *addr, /* I - Socket address */ addr->ipv4.sin_port = htons(port); - signal(SIGALRM, alarm_handler); alarm(1); status = connect(fd, (void *)addr, httpAddrLength(addr)); @@ -2211,9 +2446,11 @@ update_cache(snmp_cache_t *device, /* I - Device */ device->make_and_model = strdup(make_model); } + + list_device(device); } /* - * End of "$Id: snmp.c 5736 2006-07-13 19:59:36Z mike $". + * End of "$Id: snmp.c 5898 2006-08-28 18:54:10Z mike $". */ diff --git a/berkeley/lpc.c b/berkeley/lpc.c index 271d60477..c00a23a7a 100644 --- a/berkeley/lpc.c +++ b/berkeley/lpc.c @@ -1,5 +1,5 @@ /* - * "$Id: lpc.c 5023 2006-01-29 14:39:44Z mike $" + * "$Id: lpc.c 5833 2006-08-16 20:05:58Z mike $" * * "lpc" command for the Common UNIX Printing System (CUPS). * @@ -65,6 +65,8 @@ main(int argc, /* I - Number of command-line arguments */ *params; /* Pointer to parameters */ + _cupsSetLocale(); + /* * Connect to the scheduler... */ @@ -518,5 +520,5 @@ show_status(http_t *http, /* I - HTTP connection to server */ /* - * End of "$Id: lpc.c 5023 2006-01-29 14:39:44Z mike $". + * End of "$Id: lpc.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/berkeley/lpq.c b/berkeley/lpq.c index 43f01c620..78387fd5d 100644 --- a/berkeley/lpq.c +++ b/berkeley/lpq.c @@ -1,5 +1,5 @@ /* - * "$Id: lpq.c 5638 2006-06-06 20:08:13Z mike $" + * "$Id: lpq.c 5838 2006-08-17 14:41:42Z mike $" * * "lpq" command for the Common UNIX Printing System (CUPS). * @@ -76,9 +76,10 @@ main(int argc, /* I - Number of command-line arguments */ longstatus; /* Show file details */ int num_dests; /* Number of destinations */ cups_dest_t *dests; /* Destinations */ - cups_lang_t *language; /* Language */ + _cupsSetLocale(); + /* * Check for command-line options... */ @@ -90,8 +91,8 @@ main(int argc, /* I - Number of command-line arguments */ interval = 0; longstatus = 0; all = 0; - language = cupsLangDefault(); num_dests = 0; + dests = NULL; for (i = 1; i < argc; i ++) if (argv[i][0] == '+') @@ -675,5 +676,5 @@ usage(void) /* - * End of "$Id: lpq.c 5638 2006-06-06 20:08:13Z mike $". + * End of "$Id: lpq.c 5838 2006-08-17 14:41:42Z mike $". */ diff --git a/berkeley/lpr.c b/berkeley/lpr.c index f6b5fb3b7..90b73bf4d 100644 --- a/berkeley/lpr.c +++ b/berkeley/lpr.c @@ -1,5 +1,5 @@ /* - * "$Id: lpr.c 5235 2006-03-06 13:02:23Z mike $" + * "$Id: lpr.c 5838 2006-08-17 14:41:42Z mike $" * * "lpr" command for the Common UNIX Printing System (CUPS). * @@ -87,13 +87,14 @@ main(int argc, /* I - Number of command-line arguments */ ssize_t bytes; /* Bytes copied */ off_t filesize; /* Size of temp file */ int temp; /* Temporary file descriptor */ - cups_lang_t *language; /* Language information */ #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) struct sigaction action; /* Signal action */ struct sigaction oldaction; /* Old signal action */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + _cupsSetLocale(); + deletefile = 0; printer = NULL; num_dests = 0; @@ -102,7 +103,6 @@ main(int argc, /* I - Number of command-line arguments */ options = NULL; num_files = 0; title = NULL; - language = cupsLangDefault(); for (i = 1; i < argc; i ++) if (argv[i][0] == '-') @@ -529,5 +529,5 @@ sighandler(int s) /* I - Signal number */ /* - * End of "$Id: lpr.c 5235 2006-03-06 13:02:23Z mike $". + * End of "$Id: lpr.c 5838 2006-08-17 14:41:42Z mike $". */ diff --git a/berkeley/lprm.c b/berkeley/lprm.c index 41f35ca12..574f26507 100644 --- a/berkeley/lprm.c +++ b/berkeley/lprm.c @@ -1,5 +1,5 @@ /* - * "$Id: lprm.c 5719 2006-07-11 21:04:48Z mike $" + * "$Id: lprm.c 5878 2006-08-24 15:55:42Z mike $" * * "lprm" command for the Common UNIX Printing System (CUPS). * @@ -55,13 +55,14 @@ main(int argc, /* I - Number of command-line arguments */ ipp_t *request; /* IPP request */ ipp_t *response; /* IPP response */ ipp_op_t op; /* Operation */ - cups_lang_t *language; /* Language */ int num_dests; /* Number of destinations */ cups_dest_t *dests, /* Destinations */ *defdest; /* Default destination */ http_encryption_t encryption; /* Encryption? */ + _cupsSetLocale(); + /* * Setup to cancel individual print jobs... */ @@ -72,7 +73,6 @@ main(int argc, /* I - Number of command-line arguments */ response = NULL; http = NULL; encryption = cupsEncryption(); - language = cupsLangDefault(); /* * Open a connection to the server... @@ -273,7 +273,7 @@ main(int argc, /* I - Number of command-line arguments */ } /* - * If nothing has been cancelled yet, cancel the current job on the specified + * If nothing has been canceled yet, cancel the current job on the specified * (or default) printer... */ @@ -294,5 +294,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: lprm.c 5719 2006-07-11 21:04:48Z mike $". + * End of "$Id: lprm.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 85142e3a0..6536c86f7 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -1,5 +1,5 @@ /* - * "$Id: admin.c 5572 2006-05-22 18:47:09Z mike $" + * "$Id: admin.c 5878 2006-08-24 15:55:42Z mike $" * * Administration CGI for the Common UNIX Printing System (CUPS). * @@ -1597,39 +1597,97 @@ do_config_server(http_t *http) /* I - HTTP connection */ int num_settings; /* Number of server settings */ cups_option_t *settings; /* Server settings */ + const char *debug_logging, /* DEBUG_LOGGING value */ + *remote_admin, /* REMOTE_ADMIN value */ + *remote_printers, + /* REMOTE_PRINTERS value */ + *share_printers,/* SHARE_PRINTERS value */ + *user_cancel_any; + /* USER_CANCEL_ANY value */ - num_settings = 0; - num_settings = cupsAddOption(CUPS_SERVER_DEBUG_LOGGING, - cgiGetVariable("DEBUG_LOGGING") ? "1" : "0", - num_settings, &settings); - num_settings = cupsAddOption(CUPS_SERVER_REMOTE_ADMIN, - cgiGetVariable("REMOTE_ADMIN") ? "1" : "0", - num_settings, &settings); - num_settings = cupsAddOption(CUPS_SERVER_REMOTE_PRINTERS, - cgiGetVariable("REMOTE_PRINTERS") ? "1" : "0", - num_settings, &settings); - num_settings = cupsAddOption(CUPS_SERVER_SHARE_PRINTERS, - cgiGetVariable("SHARE_PRINTERS") ? "1" : "0", - num_settings, &settings); - num_settings = cupsAddOption(CUPS_SERVER_USER_CANCEL_ANY, - cgiGetVariable("USER_CANCEL_ANY") ? "1" : "0", - num_settings, &settings); - - - if (!_cupsAdminSetServerSettings(http, num_settings, settings)) + /* + * Get the checkbox values from the form... + */ + + debug_logging = cgiGetVariable("DEBUG_LOGGING") ? "1" : "0"; + remote_admin = cgiGetVariable("REMOTE_ADMIN") ? "1" : "0"; + remote_printers = cgiGetVariable("REMOTE_PRINTERS") ? "1" : "0"; + share_printers = cgiGetVariable("SHARE_PRINTERS") ? "1" : "0"; + user_cancel_any = cgiGetVariable("USER_CANCEL_ANY") ? "1" : "0"; + + /* + * Get the current server settings... + */ + + if (!_cupsAdminGetServerSettings(http, &num_settings, &settings)) { cgiStartHTML(cgiText(_("Change Settings"))); cgiSetVariable("MESSAGE", cgiText(_("Unable to change server settings:"))); cgiSetVariable("ERROR", cupsLastErrorString()); cgiCopyTemplateLang("error.tmpl"); + cgiEndHTML(); + return; + } + + /* + * See if the settings have changed... + */ + + if (strcmp(debug_logging, cupsGetOption(CUPS_SERVER_DEBUG_LOGGING, + num_settings, settings)) || + strcmp(remote_admin, cupsGetOption(CUPS_SERVER_REMOTE_ADMIN, + num_settings, settings)) || + strcmp(remote_printers, cupsGetOption(CUPS_SERVER_REMOTE_PRINTERS, + num_settings, settings)) || + strcmp(share_printers, cupsGetOption(CUPS_SERVER_SHARE_PRINTERS, + num_settings, settings)) || + strcmp(user_cancel_any, cupsGetOption(CUPS_SERVER_USER_CANCEL_ANY, + num_settings, settings))) + { + /* + * Settings *have* changed, so save the changes... + */ + + cupsFreeOptions(num_settings, settings); + + num_settings = 0; + num_settings = cupsAddOption(CUPS_SERVER_DEBUG_LOGGING, + debug_logging, num_settings, &settings); + num_settings = cupsAddOption(CUPS_SERVER_REMOTE_ADMIN, + remote_admin, num_settings, &settings); + num_settings = cupsAddOption(CUPS_SERVER_REMOTE_PRINTERS, + remote_printers, num_settings, &settings); + num_settings = cupsAddOption(CUPS_SERVER_SHARE_PRINTERS, + share_printers, num_settings, &settings); + num_settings = cupsAddOption(CUPS_SERVER_USER_CANCEL_ANY, + user_cancel_any, num_settings, &settings); + + if (!_cupsAdminSetServerSettings(http, num_settings, settings)) + { + cgiStartHTML(cgiText(_("Change Settings"))); + cgiSetVariable("MESSAGE", + cgiText(_("Unable to change server settings:"))); + cgiSetVariable("ERROR", cupsLastErrorString()); + cgiCopyTemplateLang("error.tmpl"); + } + else + { + cgiSetVariable("refresh_page", "5;URL=/admin/?OP=redirect"); + cgiStartHTML(cgiText(_("Change Settings"))); + cgiCopyTemplateLang("restart.tmpl"); + } } else { + /* + * No changes... + */ + cgiSetVariable("refresh_page", "5;URL=/admin/?OP=redirect"); cgiStartHTML(cgiText(_("Change Settings"))); - cgiCopyTemplateLang("restart.tmpl"); + cgiCopyTemplateLang("norestart.tmpl"); } cupsFreeOptions(num_settings, settings); @@ -2893,5 +2951,5 @@ match_string(const char *a, /* I - First string */ /* - * End of "$Id: admin.c 5572 2006-05-22 18:47:09Z mike $". + * End of "$Id: admin.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c index 0b515f123..c312d8bff 100644 --- a/cgi-bin/ipp-var.c +++ b/cgi-bin/ipp-var.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp-var.c 5572 2006-05-22 18:47:09Z mike $" + * "$Id: ipp-var.c 5838 2006-08-17 14:41:42Z mike $" * * CGI <-> IPP variable routines for the Common UNIX Printing System (CUPS). * @@ -110,6 +110,7 @@ cgiGetAttributes(ipp_t *request, /* I - IPP request */ */ num_attrs = 0; + attrs[0] = NULL; /* Eliminate compiler warning */ while ((ch = getc(in)) != EOF) if (ch == '\\') @@ -1279,5 +1280,5 @@ cgiText(const char *message) /* I - Message */ /* - * End of "$Id: ipp-var.c 5572 2006-05-22 18:47:09Z mike $". + * End of "$Id: ipp-var.c 5838 2006-08-17 14:41:42Z mike $". */ diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4 index 5495beaa0..d8c4d01f2 100644 --- a/config-scripts/cups-common.m4 +++ b/config-scripts/cups-common.m4 @@ -1,5 +1,5 @@ dnl -dnl "$Id: cups-common.m4 5466 2006-04-26 19:52:27Z mike $" +dnl "$Id: cups-common.m4 5843 2006-08-17 18:49:31Z mike $" dnl dnl Common configuration stuff for the Common UNIX Printing System (CUPS). dnl @@ -29,7 +29,7 @@ dnl Set the name of the config header file... AC_CONFIG_HEADER(config.h) dnl Versio number information... -CUPS_VERSION="1.2svn" +CUPS_VERSION="1.2.3" CUPS_REVISION="" if test -z "$CUPS_REVISION" -a -d .svn; then CUPS_REVISION="-r`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[[a-zA-Z]]*//g'`" @@ -265,5 +265,5 @@ AC_SUBST(DEFAULT_IPP_PORT) AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IPP_PORT,$DEFAULT_IPP_PORT) dnl -dnl End of "$Id: cups-common.m4 5466 2006-04-26 19:52:27Z mike $". +dnl End of "$Id: cups-common.m4 5843 2006-08-17 18:49:31Z mike $". dnl diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4 index 6b99cb575..a46cf3835 100644 --- a/config-scripts/cups-defaults.m4 +++ b/config-scripts/cups-defaults.m4 @@ -1,5 +1,5 @@ dnl -dnl "$Id: cups-defaults.m4 5745 2006-07-18 13:45:56Z mike $" +dnl "$Id: cups-defaults.m4 5804 2006-08-04 16:51:58Z mike $" dnl dnl Default cupsd configuration settings for the Common UNIX Printing System dnl (CUPS). @@ -25,7 +25,9 @@ dnl dnl Default langugages... AC_ARG_WITH(languages, [ --with-languages set installed languages, default="de es ja pl sv" ], - LANGUAGES="$withval", + if test "x$withval" != xno; then + LANGUAGES="$withval" + fi, LANGUAGES="de es ja pl sv") AC_SUBST(LANGUAGES) @@ -248,5 +250,5 @@ fi AC_DEFINE_UNQUOTED(CUPS_DEFAULT_PRINTCAP, "$CUPS_DEFAULT_PRINTCAP") dnl -dnl End of "$Id: cups-defaults.m4 5745 2006-07-18 13:45:56Z mike $". +dnl End of "$Id: cups-defaults.m4 5804 2006-08-04 16:51:58Z mike $". dnl diff --git a/config-scripts/cups-directories.m4 b/config-scripts/cups-directories.m4 index ece2b5820..595512b43 100644 --- a/config-scripts/cups-directories.m4 +++ b/config-scripts/cups-directories.m4 @@ -1,5 +1,5 @@ dnl -dnl "$Id: cups-directories.m4 5696 2006-06-26 18:34:20Z mike $" +dnl "$Id: cups-directories.m4 5905 2006-08-29 20:48:59Z mike $" dnl dnl Directory stuff for the Common UNIX Printing System (CUPS). dnl @@ -57,6 +57,15 @@ if test "$sharedstatedir" = "\${prefix}/com" -a "$prefix" = "/"; then sharedstatedir="/usr/com" fi +dnl Fix "datarootdir" variable if it hasn't been specified... +if test "$datarootdir" = "\${prefix}/share"; then + if test "$prefix" = "/"; then + datarootdir="/usr/share" + else + datarootdir="$prefix/share" + fi +fi + dnl Fix "datadir" variable if it hasn't been specified... if test "$datadir" = "\${prefix}/share"; then if test "$prefix" = "/"; then @@ -64,6 +73,8 @@ if test "$datadir" = "\${prefix}/share"; then else datadir="$prefix/share" fi +elif test "$datadir" = "\${datarootdir}"; then + datadir="$datarootdir" fi dnl Fix "includedir" variable if it hasn't been specified... @@ -182,12 +193,15 @@ AC_SUBST(INITDDIR) dnl Xinetd support... XINETD="" -for dir in /private/etc/xinetd.d /etc/xinetd.d /usr/local/etc/xinetd.d; do - if test -d $dir; then - XINETD="$dir" - break - fi -done + +if test ! -x /sbin/launchd; then + for dir in /private/etc/xinetd.d /etc/xinetd.d /usr/local/etc/xinetd.d; do + if test -d $dir; then + XINETD="$dir" + break + fi + done +fi AC_SUBST(XINETD) @@ -197,7 +211,7 @@ AC_ARG_WITH(cachedir, [ --with-cachedir set path for cache files],cache if test x$cachedir = x; then if test "x$uname" = xDarwin; then - CUPS_CACHEDIR="$localstatedir/tmp/cups" + CUPS_CACHEDIR="$localstatedir/spool/cups/cache" else CUPS_CACHEDIR="$localstatedir/cache/cups" fi @@ -302,5 +316,5 @@ AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$localstatedir/run/cups") AC_SUBST(CUPS_STATEDIR) dnl -dnl End of "$Id: cups-directories.m4 5696 2006-06-26 18:34:20Z mike $". +dnl End of "$Id: cups-directories.m4 5905 2006-08-29 20:48:59Z mike $". dnl diff --git a/config-scripts/cups-manpages.m4 b/config-scripts/cups-manpages.m4 index 1e6ae44de..41e8190cb 100644 --- a/config-scripts/cups-manpages.m4 +++ b/config-scripts/cups-manpages.m4 @@ -1,9 +1,9 @@ dnl -dnl "$Id: cups-manpages.m4 5466 2006-04-26 19:52:27Z mike $" +dnl "$Id: cups-manpages.m4 5799 2006-08-03 00:54:38Z mike $" dnl dnl Manpage stuff for the Common UNIX Printing System (CUPS). dnl -dnl Copyright 1997-2005 by Easy Software Products, all rights reserved. +dnl Copyright 1997-2006 by Easy Software Products, all rights reserved. dnl dnl These coded instructions, statements, and computer programs are the dnl property of Easy Software Products and are protected by Federal @@ -23,6 +23,12 @@ dnl WWW: http://www.cups.org dnl dnl Fix "mandir" variable... +if test "$mandir" = "\${datarootdir}/man" -a "$prefix" = "/"; then + # New GNU "standards" break previous ones, so make sure we use + # the right default location for the operating system... + mandir="\${prefix}/man" +fi + if test "$mandir" = "\${prefix}/man" -a "$prefix" = "/"; then case "$uname" in Darwin* | Linux | GNU | *BSD* | AIX*) @@ -103,5 +109,5 @@ AC_SUBST(MAN8EXT) AC_SUBST(MAN8DIR) dnl -dnl End of "$Id: cups-manpages.m4 5466 2006-04-26 19:52:27Z mike $". +dnl End of "$Id: cups-manpages.m4 5799 2006-08-03 00:54:38Z mike $". dnl diff --git a/configure.in b/configure.in index d9e4f6255..07909d7e1 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl -dnl "$Id: configure.in 5609 2006-05-30 20:31:10Z mike $" +dnl "$Id: configure.in 5804 2006-08-04 16:51:58Z mike $" dnl dnl Configuration script for the Common UNIX Printing System (CUPS). dnl @@ -54,9 +54,17 @@ if test "x$LANGUAGES" != x; then INSTALL_LANGUAGES="install-languages" UNINSTALL_LANGUAGES="uninstall-languages" for lang in $LANGUAGES; do - LANGFILES="$LANGFILES doc/$lang/index.html" - LANGFILES="$LANGFILES templates/$lang/edit-config.tmpl" - LANGFILES="$LANGFILES templates/$lang/header.tmpl" + if test -f doc/$lang/index.html.in; then + LANGFILES="$LANGFILES doc/$lang/index.html" + fi + + if test -f templates/$lang/edit-config.tmpl.in; then + LANGFILES="$LANGFILES templates/$lang/edit-config.tmpl" + fi + + if test -f templates/$lang/header.tmpl.in; then + LANGFILES="$LANGFILES templates/$lang/header.tmpl" + fi done fi @@ -75,5 +83,5 @@ AC_OUTPUT(Makedefs packaging/cups.list init/cups.sh init/cups-lpd cups-config chmod +x cups-config dnl -dnl End of "$Id: configure.in 5609 2006-05-30 20:31:10Z mike $". +dnl End of "$Id: configure.in 5804 2006-08-04 16:51:58Z mike $". dnl diff --git a/cups-config.in b/cups-config.in index ef5084a64..81a982b47 100755 --- a/cups-config.in +++ b/cups-config.in @@ -1,6 +1,6 @@ #! /bin/sh # -# "$Id: cups-config.in 5688 2006-06-23 20:33:08Z mike $" +# "$Id: cups-config.in 5799 2006-08-03 00:54:38Z mike $" # # CUPS configuration utility. # @@ -32,6 +32,7 @@ bindir=@bindir@ includedir=@includedir@ libdir=@libdir@ imagelibdir=@libdir@ +datarootdir=@datadir@ datadir=@datadir@ sysconfdir=@sysconfdir@ cups_datadir=@CUPS_DATADIR@ @@ -150,5 +151,5 @@ while test $# -gt 0; do done # -# End of "$Id: cups-config.in 5688 2006-06-23 20:33:08Z mike $". +# End of "$Id: cups-config.in 5799 2006-08-03 00:54:38Z mike $". # diff --git a/cups/Makefile b/cups/Makefile index 1af69254f..e0064b42e 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 5628 2006-06-05 15:25:23Z mike $" +# "$Id: Makefile 5801 2006-08-03 02:20:57Z mike $" # # API library Makefile for the Common UNIX Printing System (CUPS). # @@ -93,6 +93,7 @@ OBJS = \ HEADERS = \ adminutil.h \ array.h \ + backend.h \ cups.h \ dir.h \ file.h \ @@ -449,5 +450,5 @@ include Dependencies # -# End of "$Id: Makefile 5628 2006-06-05 15:25:23Z mike $". +# End of "$Id: Makefile 5801 2006-08-03 02:20:57Z mike $". # diff --git a/cups/adminutil.c b/cups/adminutil.c index 3825b40bf..710780029 100644 --- a/cups/adminutil.c +++ b/cups/adminutil.c @@ -1,5 +1,5 @@ /* - * "$Id: adminutil.c 5753 2006-07-18 19:53:24Z mike $" + * "$Id: adminutil.c 5878 2006-08-24 15:55:42Z mike $" * * Administration utility API definitions for the Common UNIX Printing * System (CUPS). @@ -103,7 +103,7 @@ cupsAdminCreateWindowsPPD( linenum; /* Current line number */ time_t curtime; /* Current time */ struct tm *curdate; /* Current date */ - static const char *pattrs[] = /* Printer attributes we want */ + static const char * const pattrs[] = /* Printer attributes we want */ { "job-hold-until-supported", "job-hold-until-default", @@ -772,19 +772,31 @@ _cupsAdminGetServerSettings( if (!value) continue; - if (!strcasecmp(line, "Port")) - { - remote_access = 1; - } - else if (!strcasecmp(line, "Listen")) + if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen")) { char *port; /* Pointer to port number, if any */ if ((port = strrchr(value, ':')) != NULL) *port = '\0'; + else if (isdigit(*value & 255)) + { + /* + * Listen on a port number implies remote access... + */ + + remote_access = 1; + continue; + } - if (strcasecmp(value, "localhost") && strcmp(value, "127.0.0.1")) + if (strcasecmp(value, "localhost") && strcmp(value, "127.0.0.1") +#ifdef AF_LOCAL + && *value != '/' +#endif /* AF_LOCAL */ +#ifdef AF_INET6 + && strcmp(value, "::1") +#endif /* AF_INET6 */ + ) remote_access = 1; } else if (!strcasecmp(line, "Browsing")) @@ -860,7 +872,14 @@ _cupsAdminGetServerSettings( in_location = 0; } else if (!strcasecmp(line, "Allow") && in_admin_location && - strcasecmp(value, "localhost") && strcasecmp(value, "127.0.0.1")) + strcasecmp(value, "localhost") && strcasecmp(value, "127.0.0.1") +#ifdef AF_LOCAL + && *value != '/' +#endif /* AF_LOCAL */ +#ifdef AF_INET6 + && strcmp(value, "::1") +#endif /* AF_INET6 */ + ) { remote_admin = 1; } @@ -1084,7 +1103,7 @@ _cupsAdminSetServerSettings( { cupsFilePuts(temp, "# Only listen for connections from the local " "machine.\n"); - cupsFilePrintf(temp, "Listen 127.0.0.1:%d\n", ippPort()); + cupsFilePrintf(temp, "Listen localhost:%d\n", ippPort()); } #ifdef CUPS_DEFAULT_DOMAINSOCKET @@ -1440,7 +1459,7 @@ _cupsAdminSetServerSettings( { cupsFilePuts(temp, "# Only listen for connections from the local machine.\n"); - cupsFilePrintf(temp, "Listen 127.0.0.1:%d\n", ippPort()); + cupsFilePrintf(temp, "Listen localhost:%d\n", ippPort()); } #ifdef CUPS_DEFAULT_DOMAINSOCKET @@ -1768,7 +1787,7 @@ get_cupsd_conf( * Read cupsd.conf via a HTTP GET request... */ - if ((fd = cupsTempFd(name, sizeof(name))) < 0) + if ((fd = cupsTempFd(name, namesize)) < 0) { *name = '\0'; @@ -1929,5 +1948,5 @@ write_option(cups_file_t *dstfp, /* I - PPD file */ /* - * End of "$Id: adminutil.c 5753 2006-07-18 19:53:24Z mike $". + * End of "$Id: adminutil.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/cups/attr.c b/cups/attr.c index 96b89ea05..56deac727 100644 --- a/cups/attr.c +++ b/cups/attr.c @@ -1,5 +1,5 @@ /* - * "$Id: attr.c 5119 2006-02-16 15:52:06Z mike $" + * "$Id: attr.c 5826 2006-08-15 19:04:11Z mike $" * * PPD model-specific attribute routines for the Common UNIX Printing System * (CUPS). @@ -44,13 +44,18 @@ * @since CUPS 1.1.19@ */ -ppd_attr_t * /* O - Attribute or NULL if not found */ -ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */ - const char *name, /* I - Attribute name */ - const char *spec) /* I - Specifier string or NULL */ +ppd_attr_t * /* O - Attribute or NULL if not found */ +ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */ + const char *name, /* I - Attribute name */ + const char *spec) /* I - Specifier string or NULL */ { - ppd_attr_t key; /* Search key */ + ppd_attr_t key, /* Search key */ + *attr; /* Current attribute */ + int diff; /* Current difference */ + + DEBUG_printf(("ppdFindAttr(ppd=%p, name=\"%s\", spec=\"%s\")\n", ppd, + name ? name : "(null)", spec ? spec : "(null)")); /* * Range check input... @@ -72,7 +77,36 @@ ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */ * Return the first matching attribute, if any... */ - return ((ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)); + if ((attr = (ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)) != NULL) + return (attr); + else if (spec) + return (NULL); + + /* + * No match found, loop through the sorted attributes to see if we can + * find a "wildcard" match for the attribute... + */ + + for (attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs); + attr; + attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) + { + if ((diff = strcasecmp(attr->name, name)) == 0) + break; + + if (diff > 0) + { + /* + * All remaining attributes are > than the one we are trying to find... + */ + + cupsArrayIndex(ppd->sorted_attrs, cupsArrayCount(ppd->sorted_attrs)); + + return (NULL); + } + } + + return (attr); } @@ -129,5 +163,5 @@ ppdFindNextAttr(ppd_file_t *ppd, /* I - PPD file data */ /* - * End of "$Id: attr.c 5119 2006-02-16 15:52:06Z mike $". + * End of "$Id: attr.c 5826 2006-08-15 19:04:11Z mike $". */ diff --git a/cups/cups.h b/cups/cups.h index 64b389a08..c74e52209 100644 --- a/cups/cups.h +++ b/cups/cups.h @@ -1,5 +1,5 @@ /* - * "$Id: cups.h 5233 2006-03-06 03:39:28Z mike $" + * "$Id: cups.h 5805 2006-08-04 16:52:31Z mike $" * * API definitions for the Common UNIX Printing System (CUPS). * @@ -61,10 +61,10 @@ extern "C" { * Constants... */ -# define CUPS_VERSION 1.0200 +# define CUPS_VERSION 1.0203 # define CUPS_VERSION_MAJOR 1 # define CUPS_VERSION_MINOR 2 -# define CUPS_VERSION_PATCH 0 +# define CUPS_VERSION_PATCH 3 # define CUPS_DATE_ANY -1 @@ -244,5 +244,5 @@ extern cups_file_t *cupsTempFile2(char *filename, int len); #endif /* !_CUPS_CUPS_H_ */ /* - * End of "$Id: cups.h 5233 2006-03-06 03:39:28Z mike $". + * End of "$Id: cups.h 5805 2006-08-04 16:52:31Z mike $". */ diff --git a/cups/dir.h b/cups/dir.h index 0fd52e8f1..ac5c5fc08 100644 --- a/cups/dir.h +++ b/cups/dir.h @@ -5,7 +5,7 @@ * * This set of APIs abstracts enumeration of directory entries. * - * Copyright 1997-2005 by Easy Software Products, all rights reserved. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -39,9 +39,9 @@ * C++ magic... */ -# ifdef _cplusplus +# ifdef __cplusplus extern "C" { -# endif /* _cplusplus */ +# endif /* __cplusplus */ /* @@ -67,9 +67,9 @@ extern cups_dentry_t *cupsDirRead(cups_dir_t *dp); extern void cupsDirRewind(cups_dir_t *dp); -# ifdef _cplusplus +# ifdef __cplusplus } -# endif /* _cplusplus */ +# endif /* __cplusplus */ #endif /* !_CUPS_DIR_H_ */ /* diff --git a/cups/file.c b/cups/file.c index a5c1372f5..246972d76 100644 --- a/cups/file.c +++ b/cups/file.c @@ -1,5 +1,5 @@ /* - * "$Id: file.c 5324 2006-03-23 16:47:46Z mike $" + * "$Id: file.c 5812 2006-08-09 22:42:51Z mike $" * * File functions for the Common UNIX Printing System (CUPS). * @@ -1260,6 +1260,7 @@ cupsFileRewind(cups_file_t *fp) /* I - CUPS file */ fp->pos = 0; fp->ptr = NULL; fp->end = NULL; + fp->eof = 0; return (0); } @@ -2080,5 +2081,5 @@ cups_write(cups_file_t *fp, /* I - CUPS file */ /* - * End of "$Id: file.c 5324 2006-03-23 16:47:46Z mike $". + * End of "$Id: file.c 5812 2006-08-09 22:42:51Z mike $". */ diff --git a/cups/file.h b/cups/file.h index 24649147b..b36aa0577 100644 --- a/cups/file.h +++ b/cups/file.h @@ -1,5 +1,5 @@ /* - * "$Id: file.h 5319 2006-03-21 15:28:29Z mike $" + * "$Id: file.h 5769 2006-07-20 17:17:14Z mike $" * * Public file definitions for the Common UNIX Printing System (CUPS). * @@ -8,7 +8,7 @@ * our own file functions allows us to provide transparent support of * gzip'd print files, PPD files, etc. * - * Copyright 1997-2005 by Easy Software Products, all rights reserved. + * Copyright 1997-2006 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -47,9 +47,9 @@ typedef off_t ssize_t; /* @private@ */ * C++ magic... */ -# ifdef _cplusplus +# ifdef __cplusplus extern "C" { -# endif /* _cplusplus */ +# endif /* __cplusplus */ /* @@ -103,11 +103,11 @@ extern int cupsFileUnlock(cups_file_t *fp); extern ssize_t cupsFileWrite(cups_file_t *fp, const char *buf, size_t bytes); -# ifdef _cplusplus +# ifdef __cplusplus } -# endif /* _cplusplus */ +# endif /* __cplusplus */ #endif /* !_CUPS_FILE_H_ */ /* - * End of "$Id: file.h 5319 2006-03-21 15:28:29Z mike $". + * End of "$Id: file.h 5769 2006-07-20 17:17:14Z mike $". */ diff --git a/cups/http.c b/cups/http.c index 84e204620..504be39cf 100644 --- a/cups/http.c +++ b/cups/http.c @@ -1,5 +1,5 @@ /* - * "$Id: http.c 5753 2006-07-18 19:53:24Z mike $" + * "$Id: http.c 5889 2006-08-24 21:44:35Z mike $" * * HTTP routines for the Common UNIX Printing System (CUPS). * @@ -1100,15 +1100,20 @@ httpPrintf(http_t *http, /* I - HTTP connection */ DEBUG_printf(("httpPrintf: %s", buf)); - if (http->wused) + if (http->data_encoding == HTTP_ENCODE_FIELDS) + return (httpWrite2(http, buf, bytes)); + else { - DEBUG_puts(" flushing existing data..."); + if (http->wused) + { + DEBUG_puts(" flushing existing data..."); - if (httpFlushWrite(http) < 0) - return (-1); - } + if (httpFlushWrite(http) < 0) + return (-1); + } - return (http_write(http, buf, bytes)); + return (http_write(http, buf, bytes)); + } } @@ -1888,7 +1893,7 @@ httpWrite2(http_t *http, /* I - HTTP connection */ httpFlushWrite(http); } - if ((length + http->wused) <= sizeof(http->wbuffer)) + if ((length + http->wused) < sizeof(http->wbuffer)) { /* * Write to buffer... @@ -2154,11 +2159,20 @@ http_send(http_t *http, /* I - HTTP connection */ if (httpReconnect(http)) return (-1); + /* + * Flush any written data that is pending... + */ + + if (http->wused) + httpFlushWrite(http); + /* * Send the request header... */ - http->state = request; + http->state = request; + http->data_encoding = HTTP_ENCODE_FIELDS; + if (request == HTTP_POST || request == HTTP_PUT) http->state ++; @@ -2211,6 +2225,7 @@ http_send(http_t *http, /* I - HTTP connection */ return (-1); } + httpFlushWrite(http); httpGetLength2(http); httpClearFields(http); @@ -2811,5 +2826,5 @@ http_write_ssl(http_t *http, /* I - HTTP connection */ /* - * End of "$Id: http.c 5753 2006-07-18 19:53:24Z mike $". + * End of "$Id: http.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/cups/http.h b/cups/http.h index 6303af452..2f8a28d73 100644 --- a/cups/http.h +++ b/cups/http.h @@ -1,5 +1,5 @@ /* - * "$Id: http.h 5716 2006-07-11 17:56:57Z mike $" + * "$Id: http.h 5889 2006-08-24 21:44:35Z mike $" * * Hyper-Text Transport Protocol definitions for the Common UNIX Printing * System (CUPS). @@ -39,8 +39,8 @@ # include # include # else -# ifdef __sgi /* IRIX needs this for IPv6 support!?! */ -# define INET6 +# ifdef __sgi +# define INET6 /* IRIX IPv6 support... */ # endif /* __sgi */ # include # include @@ -53,6 +53,9 @@ # if !defined(__APPLE__) || !defined(TCP_NODELAY) # include # endif /* !__APPLE__ || !TCP_NODELAY */ +# if defined(AF_UNIX) && !defined(AF_LOCAL) +# define AF_LOCAL AF_UNIX /* Older UNIX's have old names... */ +# endif /* AF_UNIX && !AF_LOCAL */ # ifdef AF_LOCAL # include # endif /* AF_LOCAL */ @@ -139,7 +142,8 @@ typedef enum http_auth_e /**** HTTP authentication types ****/ typedef enum http_encoding_e /**** HTTP transfer encoding values ****/ { HTTP_ENCODE_LENGTH, /* Data is sent with Content-Length */ - HTTP_ENCODE_CHUNKED /* Data is chunked */ + HTTP_ENCODE_CHUNKED, /* Data is chunked */ + HTTP_ENCODE_FIELDS /* Sending HTTP fields */ } http_encoding_t; typedef enum http_encryption_e /**** HTTP encryption values ****/ @@ -504,5 +508,5 @@ extern ssize_t httpWrite2(http_t *http, const char *buffer, #endif /* !_CUPS_HTTP_H_ */ /* - * End of "$Id: http.h 5716 2006-07-11 17:56:57Z mike $". + * End of "$Id: http.h 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/cups/i18n.h b/cups/i18n.h index 58de0eae5..14a5c1dd5 100644 --- a/cups/i18n.h +++ b/cups/i18n.h @@ -1,5 +1,5 @@ /* - * "$Id: i18n.h 5366 2006-04-02 16:11:04Z mike $" + * "$Id: i18n.h 5833 2006-08-16 20:05:58Z mike $" * * (Private) localization support for the Common UNIX Printing System (CUPS). * @@ -105,6 +105,7 @@ extern const char *_cupsLangString(cups_lang_t *lang, const char *message); extern void _cupsMessageFree(cups_array_t *a); extern cups_array_t *_cupsMessageLoad(const char *filename); extern const char *_cupsMessageLookup(cups_array_t *a, const char *m); +extern void _cupsSetLocale(void); # ifdef __cplusplus } @@ -113,5 +114,5 @@ extern const char *_cupsMessageLookup(cups_array_t *a, const char *m); #endif /* !_CUPS_I18N_H_ */ /* - * End of "$Id: i18n.h 5366 2006-04-02 16:11:04Z mike $". + * End of "$Id: i18n.h 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/cups/ipp-support.c b/cups/ipp-support.c index fef06af1c..d4911d60c 100644 --- a/cups/ipp-support.c +++ b/cups/ipp-support.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp-support.c 5246 2006-03-08 13:22:09Z mike $" + * "$Id: ipp-support.c 5905 2006-08-29 20:48:59Z mike $" * * Internet Printing Protocol support functions for the Common UNIX * Printing System (CUPS). @@ -304,19 +304,48 @@ ippPort(void) _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ + DEBUG_puts("ippPort()"); + + if (!cg->ipp_port) + { + /* + * See if the server definition includes the port number... + */ + + DEBUG_puts("ippPort: Not initialized..."); + + cupsServer(); + +#ifdef DEBUG + if (cg->ipp_port) + puts("ippPort: Set via cupsServer()..."); +#endif /* DEBUG */ + } + if (!cg->ipp_port) { if ((ipp_port = getenv("IPP_PORT")) != NULL) + { + DEBUG_puts("ippPort: Set via IPP_PORT..."); portnum = atoi(ipp_port); + } else if ((port = getservbyname("ipp", NULL)) == NULL) + { + DEBUG_puts("ippPort: Set via CUPS_DEFAULT_IPP_PORT..."); portnum = CUPS_DEFAULT_IPP_PORT; + } else + { + DEBUG_puts("ippPort: Set via ipp service entry..."); portnum = ntohs(port->s_port); + } if (portnum > 0) cg->ipp_port = portnum; } + DEBUG_printf(("ippPort: Returning %d...\n", cg->ipp_port)); + return (cg->ipp_port); } @@ -328,10 +357,12 @@ ippPort(void) void ippSetPort(int p) /* I - Port number to use */ { + DEBUG_printf(("ippSetPort(p=%d)\n", p)); + _cupsGlobals()->ipp_port = p; } /* - * End of "$Id: ipp-support.c 5246 2006-03-08 13:22:09Z mike $". + * End of "$Id: ipp-support.c 5905 2006-08-29 20:48:59Z mike $". */ diff --git a/cups/ipp.h b/cups/ipp.h index 6435a0eca..32b578fc7 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -1,5 +1,5 @@ /* - * "$Id: ipp.h 5138 2006-02-21 10:49:06Z mike $" + * "$Id: ipp.h 5878 2006-08-24 15:55:42Z mike $" * * Internet Printing Protocol definitions for the Common UNIX Printing * System (CUPS). @@ -172,10 +172,11 @@ typedef enum ipp_jstate_e /**** Job States.... */ IPP_JOB_HELD, /* Job is held for printing */ IPP_JOB_PROCESSING, /* Job is currently printing */ IPP_JOB_STOPPED, /* Job has been stopped */ - IPP_JOB_CANCELLED, /* Job has been cancelled */ + IPP_JOB_CANCELED, /* Job has been canceled */ IPP_JOB_ABORTED, /* Job has aborted due to error */ IPP_JOB_COMPLETED /* Job has completed successfully */ } ipp_jstate_t; +#define IPP_JOB_CANCELLED IPP_JOB_CANCELED typedef enum ipp_pstate_e /**** Printer States.... */ { @@ -304,10 +305,11 @@ typedef enum ipp_status_e /**** IPP status codes... ****/ IPP_TEMPORARY_ERROR, /* server-error-temporary-error */ IPP_NOT_ACCEPTING, /* server-error-not-accepting-jobs */ IPP_PRINTER_BUSY, /* server-error-busy */ - IPP_ERROR_JOB_CANCELLED, /* server-error-job-canceled */ + IPP_ERROR_JOB_CANCELED, /* server-error-job-canceled */ IPP_MULTIPLE_JOBS_NOT_SUPPORTED, /* server-error-multiple-document-jobs-not-supported */ IPP_PRINTER_IS_DEACTIVATED /* server-error-printer-is-deactivated */ } ipp_status_t; +#define IPP_ERROR_JOB_CANCELLED IPP_ERROR_JOB_CANCELED typedef unsigned char ipp_uchar_t; /**** Unsigned 8-bit integer/character ****/ @@ -497,5 +499,5 @@ extern ipp_state_t ippWriteIO(void *dst, ipp_iocb_t cb, int blocking, #endif /* !_CUPS_IPP_H_ */ /* - * End of "$Id: ipp.h 5138 2006-02-21 10:49:06Z mike $". + * End of "$Id: ipp.h 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/cups/langprintf.c b/cups/langprintf.c index 4430c6792..909692347 100644 --- a/cups/langprintf.c +++ b/cups/langprintf.c @@ -1,5 +1,5 @@ /* - * "$Id: langprintf.c 4924 2006-01-13 01:55:20Z mike $" + * "$Id: langprintf.c 5833 2006-08-16 20:05:58Z mike $" * * Localized printf/puts functions for the Common UNIX Printing * System (CUPS). @@ -28,6 +28,7 @@ * * _cupsLangPrintf() - Print a formatted message string to a file. * _cupsLangPuts() - Print a static message string to a file. + * _cupsSetLocale() - Set the current locale. */ /* @@ -139,5 +140,50 @@ _cupsLangPuts(FILE *fp, /* I - File to write to */ /* - * End of "$Id: langprintf.c 4924 2006-01-13 01:55:20Z mike $". + * '_cupsSetLocale()' - Set the current locale. + */ + +void +_cupsSetLocale(void) +{ +#ifdef LC_TIME + const char *lc_time; /* Current LC_TIME value */ + char new_lc_time[255], /* New LC_TIME value */ + *charset; /* Pointer to character set */ +#endif /* LC_TIME */ + + + /* + * Set the locale so that times, etc. are displayed properly. + * + * Unfortunately, while we need the localized time value, we *don't* + * want to use the localized charset for the time value, so we need + * to set LC_TIME to the locale name with .UTF-8 on the end (if + * the locale includes a character set specifier...) + */ + + setlocale(LC_ALL, ""); + +#ifdef LC_TIME + if ((lc_time = setlocale(LC_TIME, NULL)) == NULL) + lc_time = setlocale(LC_ALL, NULL); + + if (lc_time) + { + strlcpy(new_lc_time, lc_time, sizeof(new_lc_time)); + if ((charset = strchr(new_lc_time, '.')) == NULL) + charset = new_lc_time + strlen(new_lc_time); + + strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (charset - new_lc_time)); + } + else + strcpy(new_lc_time, "C"); + + setlocale(LC_TIME, new_lc_time); +#endif /* LC_TIME */ +} + + +/* + * End of "$Id: langprintf.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/cups/language.c b/cups/language.c index b74738dbf..d46c9fea9 100644 --- a/cups/language.c +++ b/cups/language.c @@ -1,5 +1,5 @@ /* - * "$Id: language.c 5753 2006-07-18 19:53:24Z mike $" + * "$Id: language.c 5769 2006-07-20 17:17:14Z mike $" * * I18N/language support for the Common UNIX Printing System (CUPS). * @@ -1288,6 +1288,8 @@ cups_unquote(char *d, /* O - Unquoted string */ *d = *d * 8 + *s - '0'; s ++; } + + d ++; } else { @@ -1312,5 +1314,5 @@ cups_unquote(char *d, /* O - Unquoted string */ /* - * End of "$Id: language.c 5753 2006-07-18 19:53:24Z mike $". + * End of "$Id: language.c 5769 2006-07-20 17:17:14Z mike $". */ diff --git a/cups/libcups_s.exp b/cups/libcups_s.exp index a7afc43d1..cad2f10af 100644 --- a/cups/libcups_s.exp +++ b/cups/libcups_s.exp @@ -16,6 +16,7 @@ _cupsMessageFree _cupsMessageLoad _cupsMessageLookup _cupsSetError +_cupsSetLocale _cupsStrAlloc _cupsStrFlush _cupsStrFormatd diff --git a/cups/localize.c b/cups/localize.c index b07609bbb..c2be099b4 100644 --- a/cups/localize.c +++ b/cups/localize.c @@ -1,5 +1,5 @@ /* - * "$Id: localize.c 5391 2006-04-14 12:26:50Z mike $" + * "$Id: localize.c 5826 2006-08-15 19:04:11Z mike $" * * PPD custom option routines for the Common UNIX Printing System (CUPS). * @@ -80,6 +80,8 @@ ppdLocalize(ppd_file_t *ppd) /* I - PPD file */ * Range check input... */ + DEBUG_printf(("ppdLocalize(ppd=%p)\n", ppd)); + if (!ppd) return (-1); @@ -93,6 +95,9 @@ ppdLocalize(ppd_file_t *ppd) /* I - PPD file */ strlcpy(ll_CC, lang->language, sizeof(ll_CC)); strlcpy(ll, lang->language, sizeof(ll)); + DEBUG_printf((" lang->language=\"%s\", ll=\"%s\", ll_CC=\"%s\"...\n", + lang->language, ll, ll_CC)); + /* * Now lookup all of the groups, options, choices, etc. */ @@ -165,17 +170,29 @@ ppd_text(ppd_file_t *ppd, /* I - PPD file */ ppd_attr_t *attr; /* Current attribute */ + DEBUG_printf(("ppd_text(ppd=%p, keyword=\"%s\", spec=\"%s\", " + "ll_CC=\"%s\", ll=\"%s\")\n", + ppd, keyword, spec, ll_CC, ll)); + /* * Look for Keyword.ll_CC, then Keyword.ll... */ - snprintf(lkeyword, sizeof(lkeyword), "%s.%s", keyword, ll_CC); + snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll_CC, keyword); if ((attr = ppdFindAttr(ppd, lkeyword, spec)) == NULL) { - snprintf(lkeyword, sizeof(lkeyword), "%s.%s", keyword, ll); + snprintf(lkeyword, sizeof(lkeyword), "%s.%s", ll, keyword); attr = ppdFindAttr(ppd, lkeyword, spec); } +#ifdef DEBUG + if (attr) + printf(" *%s %s/%s: \"%s\"\n", attr->name, attr->spec, attr->text, + attr->value ? attr->value : ""); + else + puts(" NOT FOUND"); +#endif /* DEBUG */ + /* * Return text if we find it... */ @@ -185,5 +202,5 @@ ppd_text(ppd_file_t *ppd, /* I - PPD file */ /* - * End of "$Id: localize.c 5391 2006-04-14 12:26:50Z mike $". + * End of "$Id: localize.c 5826 2006-08-15 19:04:11Z mike $". */ diff --git a/cups/notify.c b/cups/notify.c index 2a89aca3c..752056636 100644 --- a/cups/notify.c +++ b/cups/notify.c @@ -1,5 +1,5 @@ /* - * "$Id: notify.c 4961 2006-01-20 22:19:13Z mike $" + * "$Id: notify.c 5878 2006-08-24 15:55:42Z mike $" * * Notification routines for the Common UNIX Printing System (CUPS). * @@ -104,7 +104,7 @@ cupsNotifySubject(cups_lang_t *lang, /* I - Language data */ case IPP_JOB_STOPPED : state = _cupsLangString(lang, _("stopped")); break; - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : state = _cupsLangString(lang, _("canceled")); break; case IPP_JOB_ABORTED : @@ -207,5 +207,5 @@ cupsNotifyText(cups_lang_t *lang, /* I - Language data */ /* - * End of "$Id: notify.c 4961 2006-01-20 22:19:13Z mike $". + * End of "$Id: notify.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/cups/ppd.c b/cups/ppd.c index 540b14a8d..15abaa807 100644 --- a/cups/ppd.c +++ b/cups/ppd.c @@ -1,5 +1,5 @@ /* - * "$Id: ppd.c 5333 2006-03-24 00:52:21Z mike $" + * "$Id: ppd.c 5826 2006-08-15 19:04:11Z mike $" * * PPD file routines for the Common UNIX Printing System (CUPS). * @@ -2037,10 +2037,8 @@ ppd_compare_attrs(ppd_attr_t *a, /* I - First attribute */ if ((ret = strcasecmp(a->name, b->name)) != 0) return (ret); - else if (a->spec[0] && b->spec[0]) - return (strcasecmp(a->spec, b->spec)); else - return (0); + return (strcasecmp(a->spec, b->spec)); } @@ -2938,5 +2936,5 @@ ppd_read(cups_file_t *fp, /* I - File to read from */ /* - * End of "$Id: ppd.c 5333 2006-03-24 00:52:21Z mike $". + * End of "$Id: ppd.c 5826 2006-08-15 19:04:11Z mike $". */ diff --git a/cups/testi18n.c b/cups/testi18n.c index 0fc439793..32e2e50b9 100644 --- a/cups/testi18n.c +++ b/cups/testi18n.c @@ -1,5 +1,5 @@ /* - * "$Id: testi18n.c 5444 2006-04-20 18:16:54Z mike $" + * "$Id: testi18n.c 5838 2006-08-17 14:41:42Z mike $" * * Internationalization test for Common UNIX Printing System (CUPS). * @@ -82,7 +82,6 @@ main(int argc, /* I - Argument Count */ /* "A != ." - use Windows 950 (Big5) or EUC-TW */ cups_utf8_t utf8dest[1024]; /* UTF-8 destination string */ cups_utf32_t utf32dest[1024]; /* UTF-32 destination string */ - _cups_vmap_t *vmap; /* VBCS charmap pointer */ /* @@ -190,7 +189,7 @@ main(int argc, /* I - Argument Count */ fputs("_cupsCharmapGet(CUPS_EUC_JP): ", stdout); - if ((vmap = (_cups_vmap_t *)_cupsCharmapGet(CUPS_EUC_JP)) == NULL) + if (!_cupsCharmapGet(CUPS_EUC_JP)) { errors ++; puts("FAIL"); @@ -204,7 +203,7 @@ main(int argc, /* I - Argument Count */ fputs("_cupsCharmapGet(CUPS_EUC_TW): ", stdout); - if ((vmap = (_cups_vmap_t *)_cupsCharmapGet(CUPS_EUC_TW)) == NULL) + if (!_cupsCharmapGet(CUPS_EUC_TW)) { errors ++; puts("FAIL"); @@ -556,5 +555,5 @@ print_utf8(const char *msg, /* I - Message String */ /* - * End of "$Id: testi18n.c 5444 2006-04-20 18:16:54Z mike $" + * End of "$Id: testi18n.c 5838 2006-08-17 14:41:42Z mike $" */ diff --git a/cups/testppd.c b/cups/testppd.c index bdaf944a4..37032ff62 100644 --- a/cups/testppd.c +++ b/cups/testppd.c @@ -1,5 +1,5 @@ /* - * "$Id: testppd.c 5700 2006-06-26 19:20:39Z mike $" + * "$Id: testppd.c 5826 2006-08-15 19:04:11Z mike $" * * PPD test program for the Common UNIX Printing System (CUPS). * @@ -192,10 +192,18 @@ main(int argc, /* I - Number of command-line arguments */ else { int i, j, k; /* Looping vars */ + ppd_attr_t *attr; /* Current attribute */ ppd_group_t *group; /* Option group */ ppd_option_t *option; /* Option */ + char lang[255]; /* LANG environment variable */ + if (argc > 2) + { + snprintf(lang, sizeof(lang), "LANG=%s", argv[2]); + putenv(lang); + } + ppdLocalize(ppd); for (i = ppd->num_groups, group = ppd->groups; @@ -203,7 +211,7 @@ main(int argc, /* I - Number of command-line arguments */ i --, group ++) { printf("%s (%s):\n", group->name, group->text); - + for (j = group->num_options, option = group->options; j > 0; j --, option ++) @@ -215,6 +223,14 @@ main(int argc, /* I - Number of command-line arguments */ option->choices[k].text); } } + + puts("Attributes:"); + + for (attr = (ppd_attr_t *)cupsArrayFirst(ppd->sorted_attrs); + attr; + attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) + printf(" *%s %s/%s: \"%s\"\n", attr->name, attr->spec, + attr->text, attr->value ? attr->value : ""); } } @@ -223,5 +239,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: testppd.c 5700 2006-06-26 19:20:39Z mike $". + * End of "$Id: testppd.c 5826 2006-08-15 19:04:11Z mike $". */ diff --git a/cups/transcode.c b/cups/transcode.c index c7384d9cb..40bf2f054 100644 --- a/cups/transcode.c +++ b/cups/transcode.c @@ -1,5 +1,5 @@ /* - * "$Id: transcode.c 5373 2006-04-06 20:03:32Z mike $" + * "$Id: transcode.c 5838 2006-08-17 14:41:42Z mike $" * * Transcoding support for the Common UNIX Printing System (CUPS). * @@ -408,7 +408,6 @@ cupsUTF8ToUTF32( const cups_utf8_t *src, /* I - Source string */ const int maxout) /* I - Max output */ { - size_t srclen; /* Source string length */ int i; /* Looping variable */ cups_utf8_t ch; /* Character value */ cups_utf8_t next; /* Next character value */ @@ -430,7 +429,6 @@ cupsUTF8ToUTF32( */ *dest++ = 0xfeff; - srclen = strlen((char *)src); for (i = maxout - 1; *src && i > 0; i --) { @@ -1142,7 +1140,7 @@ free_vbcs_charmap(_cups_vmap_t *vmap) /* I - Character set */ */ -void * /* O - Charset map pointer */ +static void * /* O - Charset map pointer */ get_charmap( const cups_encoding_t encoding) /* I - Encoding */ { @@ -1585,5 +1583,5 @@ get_vbcs_charmap( /* - * End of "$Id: transcode.c 5373 2006-04-06 20:03:32Z mike $" + * End of "$Id: transcode.c 5838 2006-08-17 14:41:42Z mike $" */ diff --git a/cups/usersys.c b/cups/usersys.c index b75dc3790..7c9a8a848 100644 --- a/cups/usersys.c +++ b/cups/usersys.c @@ -1,5 +1,5 @@ /* - * "$Id: usersys.c 5182 2006-02-26 04:10:27Z mike $" + * "$Id: usersys.c 5902 2006-08-29 15:51:19Z mike $" * * User, system, and password routines for the Common UNIX Printing * System (CUPS). @@ -49,6 +49,7 @@ #ifdef WIN32 # include #endif /* WIN32 */ +#include "debug.h" /* @@ -224,15 +225,21 @@ cupsServer(void) linenum = 0; while (cupsFileGetConf(fp, line, sizeof(line), &value, &linenum) != NULL) + { + DEBUG_printf(("cupsServer: %d: %s %s\n", linenum, line, + value ? value : "(null)")); + if (!strcasecmp(line, "ServerName") && value) { /* * Got it! */ + DEBUG_puts("cupsServer: Got a ServerName line!"); server = value; break; } + } cupsFileClose(fp); } @@ -242,6 +249,8 @@ cupsServer(void) * Copy the server name over and set the port number, if any... */ + DEBUG_printf(("cupsServer: Using server \"%s\"...\n", server)); + strlcpy(cg->server, server, sizeof(cg->server)); if (cg->server[0] != '/' && (port = strrchr(cg->server, ':')) != NULL && @@ -249,6 +258,7 @@ cupsServer(void) { *port++ = '\0'; + DEBUG_printf(("cupsServer: Using port %d...\n", atoi(port))); ippSetPort(atoi(port)); } @@ -471,11 +481,17 @@ cups_open_client_conf(void) snprintf(filename, sizeof(filename), "%s/.cups/client.conf", home); if ((fp = cupsFileOpen(filename, "r")) != NULL) + { + DEBUG_printf(("cups_open_client_conf: Using \"%s\"...\n", filename)); return (fp); + } snprintf(filename, sizeof(filename), "%s/.cupsrc", home); if ((fp = cupsFileOpen(filename, "r")) != NULL) + { + DEBUG_printf(("cups_open_client_conf: Using \"%s\"...\n", filename)); return (fp); + } } snprintf(filename, sizeof(filename), "%s/client.conf", cg->cups_serverroot); @@ -484,5 +500,5 @@ cups_open_client_conf(void) /* - * End of "$Id: usersys.c 5182 2006-02-26 04:10:27Z mike $". + * End of "$Id: usersys.c 5902 2006-08-29 15:51:19Z mike $". */ diff --git a/desktop/cups.desktop b/desktop/cups.desktop index a273a579f..a632eb793 100644 --- a/desktop/cups.desktop +++ b/desktop/cups.desktop @@ -1,14 +1,10 @@ [Desktop Entry] Categories=Application;System;X-Red-Hat-Base; -Comment=CUPS Web Interface -Comment[en_US]=CUPS Web Interface Encoding=UTF-8 Exec=htmlview http://localhost:631/ GenericName= -GenericName[en_US]= Icon=cups MimeType= -Name=Manage Printing Path= StartupNotify=false Terminal=false @@ -17,5 +13,11 @@ Type=Application X-DCOP-ServiceType= X-KDE-SubstituteUID=false X-KDE-Username= +Name=Manage Printing +Name[en_US]=Manage Printing +Comment=CUPS Web Interface +Comment[en_US]=CUPS Web Interface Name[es]=Administrar impresión Comment[es]=Interfaz Web de CUPS +Name[pl]=Zarządzanie drukowaniem +Comment[pl]=Interfejs WWW CUPS diff --git a/doc/help/ref-snmp-conf.html b/doc/help/ref-snmp-conf.html index 92d8f375a..e3047f24b 100644 --- a/doc/help/ref-snmp-conf.html +++ b/doc/help/ref-snmp-conf.html @@ -96,5 +96,22 @@ addresses are converted to hostnames or left as numeric IP addresses.

The default setting is off.

+

MaxRunTime

+ +

Examples

+ +
+MaxRunTime 10
+MaxRunTime 300
+
+ +

Description

+ +

The MaxRunTime directive specifies the maxium +number of seconds that the SNMP backend will spend looking for +printer devices on the network.

+ +

The default setting is 10.

+ diff --git a/doc/help/translation.html b/doc/help/translation.html index 3ffb2de61..f820c0276 100644 --- a/doc/help/translation.html +++ b/doc/help/translation.html @@ -1,7 +1,7 @@ - Translating CUPS + Translating and Customizing CUPS @@ -20,6 +20,9 @@ files and directories:

    +
  • desktop/cups.desktop - the GNOME/KDE + desktop file pointing to the CUPS web interface
  • +
  • doc/images/button-*.gif - the web interface button images
  • @@ -33,14 +36,15 @@ files and directories:

  • templates/*.tmpl - the web interface template files
  • - +
-

With the exception of the message catalogs, localization files -are placed in subdirectories under the doc and -templates using the locale name. Locale names are -either ll or ll_CC, where "ll" is the -2-letter language code and "CC" is the 2-letter country code.

+

With the exception of the message catalogs and desktop file, +localization files are placed in subdirectories under the +doc and templates using the locale name. +Locale names are either ll or ll_CC, where +"ll" is the 2-letter language code and "CC" is the 2-letter +country code.

All non-image files must be encoded using the UTF-8 character set.

@@ -48,15 +52,16 @@ set.

Submitting a Translation for CUPS

-

To submit a translation for inclusion in CUPS, translate all -of the button images, template files, the +

To submit a translation for inclusion in CUPS, translate the +desktop file, all of the button images, template files, the index.html.in file, and the message catalog. Place these files in the correct subdirectory in the CUPS source code archive and run the following command to create an archive with your files:

-tar cvf ll_CC.tar.gz doc/ll_CC locale/ll_CC.po templates/ll_CC
+tar cvf ll_CC.tar.gz desktop/cups.desktop doc/ll_CC \
+    locale/cups_ll_CC.po templates/ll_CC
 

Replace "ll_CC" with the locale name for your translation. @@ -66,6 +71,19 @@ HREF="http://www.cups.org/str.php" TARGET="_blank">CUPS Bugs translation to the report.

+

The Desktop File

+ +

The desktop/cups.desktop file provides a link to +the CUPS web interface from desktop environments such as +GNOME and KDE. To translate this file, add two lines to the +bottom with the Name and Comment keys:

+ +
+Name[ll_CC]=Translation of "Manage Printing"
+Comment[ll_CC]=Translation of "CUPS Web Interface"
+
+ +

Button Images

The web interface button images are used to activate functions @@ -86,7 +104,7 @@ sub-menu. The button scripts will be available under a new Btns

When you have created all of the button images, edit the -doc/Makefile file and add the locale name to the +Makedefs file and add the locale name to the LANGUAGES variable. You can then run "make install" in the doc subdirectory to test the translated buttons.

@@ -339,10 +357,10 @@ type the following commands:

 cd locale
-cp cups.pot fr_CA.po
+cp cups.pot cups_fr_CA.po
 
-

Alternatively, you can copy the existing fr.po +

Alternatively, you can copy the existing cups_fr.po message catalog and then make any necessary changes.

Once you have make your copy of the file, edit it using your @@ -350,7 +368,7 @@ favorite text editor or translation program to translate the text to the desired language.

Finally, add your locale to the LANGUAGES -variable in the locale/Makefile file and run the "make +variable in the Makedefs file and run the "make install" command in the locale subdirectory to test the translation.

@@ -379,7 +397,7 @@ Canadian French template files should be saved in the templates/fr_CA subdirectory. After you have translated all of the templates, add the locale to the LANGUAGES variable in the -templates/Makefile and run "make install" in the +Makedefs file and run "make install" in the templates subdirectory to test the translation.

@@ -535,6 +553,11 @@ translated all of the templates, add the locale to the + + + + diff --git a/filter/pstops.c b/filter/pstops.c index 544bff6b5..6cfca815d 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -1,5 +1,5 @@ /* - * "$Id: pstops.c 5622 2006-06-01 23:43:21Z mike $" + * "$Id: pstops.c 5886 2006-08-24 19:53:17Z mike $" * * PostScript filter for the Common UNIX Printing System (CUPS). * @@ -1587,6 +1587,10 @@ copy_setup(cups_file_t *fp, /* I - File to read from */ break; } + puts("%%BeginSetup"); + + do_setup(doc, ppd); + if (!strncmp(line, "%%BeginSetup", 12)) { while (strncmp(line, "%%EndSetup", 10)) @@ -1603,7 +1607,7 @@ copy_setup(cups_file_t *fp, /* I - File to read from */ doc->num_options = include_feature(ppd, line, doc->num_options, &(doc->options)); } - else + else if (strncmp(line, "%%BeginSetup", 12)) fwrite(line, 1, linelen, stdout); if ((linelen = cupsFileGetLine(fp, line, linesize)) == 0) @@ -1615,10 +1619,6 @@ copy_setup(cups_file_t *fp, /* I - File to read from */ else fputs("ERROR: Missing %%EndSetup!\n", stderr); } - else - puts("%%BeginSetup"); - - do_setup(doc, ppd); puts("%%EndSetup"); @@ -2994,5 +2994,5 @@ write_labels(pstops_doc_t *doc, /* I - Document information */ /* - * End of "$Id: pstops.c 5622 2006-06-01 23:43:21Z mike $". + * End of "$Id: pstops.c 5886 2006-08-24 19:53:17Z mike $". */ diff --git a/init/org.cups.cups-lpd.plist b/init/org.cups.cups-lpd.plist new file mode 100644 index 000000000..f768e3338 --- /dev/null +++ b/init/org.cups.cups-lpd.plist @@ -0,0 +1,33 @@ + + + + + Disabled + + Label + org.cups.cups-lpd + ProgramArguments + + /usr/libexec/cups/daemon/cups-lpd + -o + document-format=application/octet-stream + + Sockets + + Listeners + + SockServiceName + printer + SockType + stream + + + UserName + lp + inetdCompatibility + + Wait + + + + diff --git a/man/cups-snmp.conf.man b/man/cups-snmp.conf.man index a0ad520e5..01f9c5d30 100644 --- a/man/cups-snmp.conf.man +++ b/man/cups-snmp.conf.man @@ -21,7 +21,7 @@ .\" EMail: cups-info@cups.org .\" WWW: http://www.cups.org .\" -.TH snmp.conf 5 "Common UNIX Printing System" "18 April 2006" "Easy Software Products" +.TH snmp.conf 5 "Common UNIX Printing System" "31 July 2006" "Easy Software Products" .SH NAME snmp.conf \- snmp configuration file for cups .SH DESCRIPTION @@ -68,6 +68,11 @@ HostNameLookups off Specifies whether the addresses of printers should be converted to hostnames or left as numeric IP addresses. The default is "off". +.TP 5 +MaxRunTime \fIseconds\fR +.br +Specifies the maximum number of seconds that the SNMP backend +will scan the network for printers. .SH SEE ALSO http://localhost:631/help .SH COPYRIGHT diff --git a/packaging/cups.list.in b/packaging/cups.list.in index 923b254f2..6101446d1 100644 --- a/packaging/cups.list.in +++ b/packaging/cups.list.in @@ -1,5 +1,5 @@ # -# "$Id: cups.list.in 5745 2006-07-18 13:45:56Z mike $" +# "$Id: cups.list.in 5900 2006-08-28 19:26:39Z mike $" # # ESP Package Manager (EPM) file list for the Common UNIX Printing # System (CUPS). @@ -122,6 +122,7 @@ $prefix=@prefix@ $exec_prefix=@exec_prefix@ $bindir=@bindir@ +$datarootdir=@datarootdir@ $datadir=@datadir@ $includedir=@includedir@ $infodir=@infodir@ @@ -159,7 +160,7 @@ $SBINDIR=@sbindir@ $SERVERBIN=@CUPS_SERVERBIN@ $SERVERROOT=@CUPS_SERVERROOT@ $STATEDIR=@CUPS_STATEDIR@ - +$XINETD=@XINETD@ $LIB32DIR=@LIB32DIR@ $LIB64DIR=@LIB64DIR@ @@ -290,22 +291,22 @@ l 0755 root sys /usr/bsd/lprm $BINDIR/lprm %if DSOLIBS %subpackage libs %system hpux -f 0755 root sys $LIBDIR/libcups.sl.2 cups/libcups.sl.2 +f 0755 root sys $LIBDIR/libcups.sl.2 cups/libcups.sl.2 nostrip() l 0755 root sys $LIBDIR/libcups.sl libcups.sl.2 -f 0755 root sys $LIBDIR/libcupsimage.sl.2 filter/libcupsimage.sl.2 +f 0755 root sys $LIBDIR/libcupsimage.sl.2 filter/libcupsimage.sl.2 nostrip() l 0755 root sys $LIBDIR/libcupsimage.sl libcupsimage.sl.2 %system aix -f 0755 root sys $LIBDIR/libcups_s.a cups/libcups_s.a -f 0755 root sys $LIBDIR/libcupsimage_s.a filter/libcupsimage_s.a +f 0755 root sys $LIBDIR/libcups_s.a cups/libcups_s.a nostrip() +f 0755 root sys $LIBDIR/libcupsimage_s.a filter/libcupsimage_s.a nostrip() %system darwin -f 0755 root sys $LIBDIR/libcups.2.dylib cups/libcups.2.dylib +f 0755 root sys $LIBDIR/libcups.2.dylib cups/libcups.2.dylib nostrip() l 0755 root sys $LIBDIR/libcups.dylib libcups.2.dylib -f 0755 root sys $LIBDIR/libcupsimage.2.dylib filter/libcupsimage.2.dylib +f 0755 root sys $LIBDIR/libcupsimage.2.dylib filter/libcupsimage.2.dylib nostrip() l 0755 root sys $LIBDIR/libcupsimage.dylib libcupsimage.2.dylib %system !hpux !aix !darwin -f 0755 root sys $LIBDIR/libcups.so.2 cups/libcups.so.2 +f 0755 root sys $LIBDIR/libcups.so.2 cups/libcups.so.2 nostrip() l 0755 root sys $LIBDIR/libcups.so libcups.so.2 -f 0755 root sys $LIBDIR/libcupsimage.so.2 filter/libcupsimage.so.2 +f 0755 root sys $LIBDIR/libcupsimage.so.2 filter/libcupsimage.so.2 nostrip() l 0755 root sys $LIBDIR/libcupsimage.so libcupsimage.so.2 %system all %subpackage @@ -313,9 +314,9 @@ l 0755 root sys $LIBDIR/libcupsimage.so libcupsimage.so.2 %if LIB32DIR %subpackage libs -f 0755 root sys $LIB32DIR/libcups.so.2 cups/libcups.32.so.2 +f 0755 root sys $LIB32DIR/libcups.so.2 cups/libcups.32.so.2 nostrip() l 0755 root sys $LIB32DIR/libcups.so libcups.so.2 -f 0755 root sys $LIB32DIR/libcupsimage.so.2 filter/libcupsimage.32.so.2 +f 0755 root sys $LIB32DIR/libcupsimage.so.2 filter/libcupsimage.32.so.2 nostrip() l 0755 root sys $LIB32DIR/libcupsimage.so libcupsimage.so.2 %system all %subpackage @@ -323,9 +324,9 @@ l 0755 root sys $LIB32DIR/libcupsimage.so libcupsimage.so.2 %if LIB64DIR %subpackage libs -f 0755 root sys $LIB64DIR/libcups.so.2 cups/libcups.64.so.2 +f 0755 root sys $LIB64DIR/libcups.so.2 cups/libcups.64.so.2 nostrip() l 0755 root sys $LIB64DIR/libcups.so libcups.so.2 -f 0755 root sys $LIB64DIR/libcupsimage.so.2 filter/libcupsimage.64.so.2 +f 0755 root sys $LIB64DIR/libcupsimage.so.2 filter/libcupsimage.64.so.2 nostrip() l 0755 root sys $LIB64DIR/libcupsimage.so libcupsimage.so.2 %system all %subpackage @@ -342,7 +343,7 @@ d 0511 root $CUPS_PRIMARY_SYSTEM_GROUP $STATEDIR/certs - # Data files %subpackage de -f 0644 root sys $LOCALEDIR/es/cups_de.po locale/cups_de.po +f 0644 root sys $LOCALEDIR/de/cups_de.po locale/cups_de.po %subpackage es f 0644 root sys $LOCALEDIR/es/cups_es.po locale/cups_es.po %subpackage ja @@ -562,10 +563,31 @@ d 0755 root sys $AMANDIR/man$MAN8DIR - f 0644 root sys $AMANDIR/man$MAN8DIR/cups-lpd.$MAN8EXT man/cups-lpd.$MAN8EXT %subpackage -# Startup script -%system all +# Startup scripts +%system darwin +f 0644 root sys /System/Library/LaunchDaemons/org.cups.cupsd.plist init/org.cups.cupsd.plist +%postinstall <6ciK{6%`g178e&67#J8C85tTH8XFrM z92^`S9UUGX9v>ecARr(iAt53nA|oRsBqSsyB_$>%CMPE+C@3f?DJd!{Dl021EG#T7 zEiEoCE-x=HFfcGNF)=bSGBYzXG&D3dH8nOiHa9mnI5;>tIXOByIy*Z%JUl!-Jv}}? zK0iM{KtMo2K|w-7LPJACL_|bIMMXwNMn^|SNJvOYNl8jdN=r*iOiWBoO-)WtPESuy zP*6}&QBhJ-Qd3h?R8&+|RaI72R##V7SXfwDSy@_IT3cINTwGjTU0q&YUSD5dU|?Wj zVPRroVq;@tWMpJzWo2e&W@l$-XlQ6@X=!R|YHMq2Y;0_8ZEbFDZf|dIaBy&OadC2T za&vQYbaZreb#-=jc6WDoczAeud3kzzdV70&e0+R;eSLm@et&;|fPjF3fq{a8f`fyD zgoK2Jg@uNOhKGlTh=_=ZiHVAeii?YjjEszpjg5|uj*pLzkdTm(k&%*;l9Q8@l$4Z} zm6ev3mY0{8n3$NEnVFiJnwy)OoSdAUot>VZo}ZteprD|kp`oIpqNAguq@<*!rKP5( zrl+T;sHmu^si~@}s;jH3tgNi9t*x%EuCK4Ju&}VPv9YqUva_?Zw6wIfwY9dkwzs#p zxVX5vxw*Q!y1To(yu7@dCU$jHda z$;ryf%FD~k%*@Qq&CSlv&d<-!(9qD)(b3Y<($mw^)YR0~)z#M4*4Nk9*x1lt)=I7_<=;-L_>FMg~>g((4 z?Ck9A?d|UF?(gsK@bK{Q@$vHV^7Hfa^z`)g_4W4l_V@Sq`1ttw`T6?#`uqF){QUg= z{r&#_{{R2~A^8LW3IP8AEC2ui0Brz(06+--0RIUbNU)&6g9sBMWX7-|GldW%N}Na$ zkO=@7Giuz(v7^V2ATgQ%M6o174Ixu%1X6`$Nm)#0TvVB|ib;b^Xl`ua@}^ISGjw8X zFfpi5A_g-ORQhiy044&JGW}-;BOr`Wedg4ewO|#YGav#2(m1TQumjqA&K&0-!WRWudenE{|q(3Q7UfFU(t0uWVcFvEoy0$|1r3qrWldpFHMorffT zWyGI%qZyW&WKTL7nv_&tBwlo_ z=@jOk~&f zP=_JiSQ1B-{Wj@ALZ&2j>V_1pr}=t>r9|8bb?LSW+56GJ3bmRNx=_lQ(TRH*2CS$U$y=0AWg7b9L5y|= z7XV>Jtlm)M;R+JN1c9n=kHuxhol8^U$JCM_{{!rJyn=KmK?Zm9FTvaP%+bCEu2dLD zME*r`bbeM><->CR<7JYtMkvunM5J~!R&*)N7E0P-C$`5L*1VUz1*VzO&q>)Db!c7> z1nk&x#;g?0)=j5W{?i`;3iRIrQZ(X@G`q`~OM?ri1s1{~IdjJF+QPm+exj9Cn4whtEu*Kfi>~wSN7g@TlN|59k?ff^; ze0!wr@Y4F|D)QthY+^ymhsyj<#dD-9rC^okJDwYvr1D1@n--wB3N=dL*t8<#Jopir z91`2-yB&Y}2MNtl_zA5a5+W3(T`TE)`6KIKUJZ8`zP2lGq z2C}PI6agpd)3N5mwqY+D<2Vu>2SKTLg3ipH{7ihvg&4Nzz{ z7|IY4m|z0?L5OH|;o_Fic)|#{CY*fk79q9%`gtD;dl$JS<2YsSOqBXH*vMeQAF7lu%31mHgoQS0KbdV_eEFon< zlhdk{8Qn~UJB+B>}mAF7m#sM8?$+z84L(h(|dEqIu8OHN9fyPOX5Ddkif z*;L}l(b1G{ag$_o3Yyevx`j9hgVQ%v62yWQ)HW04nMEB&7}dSyTsjrXN9~ECUy?OU zfvbo{V|SP9K!;o!h@C(i#~EqLZ*(-7NLi)?)YJ(?HkU%l_4YcKt=y(@bk&HcG#n5=&H%ijjI zS0gi>uP9Tp%S2Z7z43h__d*h20Si@uUJ=S6;~7(p_==qwv0YsnJ75kcgmn;3kif{} zzoWLPyCSw^D@SaS?8eVP6R9MbfWqSZh*p*;K4y&-lE{a`=f(qmRazy2;nlVn$ZDHN zg*T#M$Uhttp.data_encoding = HTTP_ENCODE_LENGTH; +} + + /* * 'cupsdReadClient()' - Read data from a client. */ @@ -1024,6 +1038,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Upgrade: TLS/1.0,HTTP/1.1\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); encrypt_client(con); #else @@ -1038,6 +1053,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Allow: GET, HEAD, OPTIONS, POST, PUT\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); } else if (!is_path_absolute(con->uri)) { @@ -1065,6 +1081,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Upgrade: TLS/1.0,HTTP/1.1\r\n"); httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); encrypt_client(con); #else @@ -1105,6 +1122,7 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ httpPrintf(HTTP(con), "Content-Length: 0\r\n"); httpPrintf(HTTP(con), "\r\n"); + cupsdFlushHeader(con); } } @@ -1538,6 +1556,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (cupsdCloseClient(con)); + cupsdFlushHeader(con); + cupsdLogRequest(con, HTTP_OK); } else if ((!strncmp(con->uri, "/admin/conf/", 12) && @@ -1601,6 +1621,8 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (cupsdCloseClient(con)); + cupsdFlushHeader(con); + con->http.state = HTTP_WAITING; break; @@ -2074,6 +2096,8 @@ cupsdSendError(cupsd_client_t *con, /* I - Connection */ else if (httpPrintf(HTTP(con), "\r\n") < 0) return (0); + cupsdFlushHeader(con); + con->http.state = HTTP_WAITING; return (1); @@ -2093,6 +2117,10 @@ cupsdSendHeader(cupsd_client_t *con, /* I - Client to send to */ * Send the HTTP status header... */ + httpFlushWrite(HTTP(con)); + + con->http.data_encoding = HTTP_ENCODE_FIELDS; + if (httpPrintf(HTTP(con), "HTTP/%d.%d %d %s\r\n", con->http.version / 100, con->http.version % 100, code, httpStatus(code)) < 0) return (0); @@ -2106,7 +2134,10 @@ cupsdSendHeader(cupsd_client_t *con, /* I - Client to send to */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (0); else + { + cupsdFlushHeader(con); return (1); + } } if (httpPrintf(HTTP(con), "Date: %s\r\n", httpGetDateString(time(NULL))) < 0) @@ -2191,7 +2222,7 @@ cupsdUpdateCGI(void) if (!strchr(CGIStatusBuffer->buffer, '\n')) break; - if (ptr == NULL && errno) + if (ptr == NULL && !CGIStatusBuffer->bufused) { /* * Fatal error on pipe - should never happen! @@ -2274,15 +2305,13 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ return (0); } else if (!strncasecmp(buf, "Status:", 7)) - cupsdSendError(con, atoi(buf + 7)); + cupsdSendError(con, (http_status_t)atoi(buf + 7)); else { cupsdSendHeader(con, HTTP_OK, NULL); if (con->http.version == HTTP_1_1) { - con->http.data_encoding = HTTP_ENCODE_CHUNKED; - if (httpPrintf(HTTP(con), "Transfer-Encoding: chunked\r\n") < 0) return (0); } @@ -2310,7 +2339,14 @@ cupsdWriteClient(cupsd_client_t *con) /* I - Client connection */ */ if (con->field_col == 0) + { con->got_fields = 1; + + cupsdFlushHeader(con); + + if (con->http.version == HTTP_1_1) + con->http.data_encoding = HTTP_ENCODE_CHUNKED; + } else con->field_col = 0; } @@ -3350,19 +3386,31 @@ static int /* O - 1 on success, 0 on failure */ make_certificate(void) { #if defined(HAVE_LIBSSL) && defined(HAVE_WAITPID) - int pid, /* Process ID of command */ - status; /* Status of command */ - char command[1024], /* Command */ - *argv[11], /* Command-line arguments */ - *envp[MAX_ENV]; /* Environment variables */ + int pid, /* Process ID of command */ + status; /* Status of command */ + char command[1024], /* Command */ + *argv[11], /* Command-line arguments */ + *envp[MAX_ENV + 1], /* Environment variables */ + home[1024], /* HOME environment variable */ + infofile[1024], /* Type-in information for cert */ + seedfile[1024]; /* Random number seed file */ + int envc, /* Number of environment variables */ + bytes; /* Bytes written */ + cups_file_t *fp; /* Seed/info file */ + int infofd; /* Info file descriptor */ /* - * Run the "openssl" command to generate a self-signed certificate - * that is good for 10 years: + * Run the "openssl" command to seed the random number generator and + * generate a self-signed certificate that is good for 10 years: + * + * openssl rand -rand seedfile 1 * * openssl req -new -x509 -keyout ServerKey \ * -out ServerCertificate -days 3650 -nodes + * + * The seeding step is crucial in ensuring that the openssl command + * does not block on systems without sufficient entropy... */ if (!cupsFileFind("openssl", getenv("PATH"), 1, command, sizeof(command))) @@ -3372,6 +3420,108 @@ make_certificate(void) return (0); } + if (access("/dev/urandom", 0)) + { + /* + * If the system doesn't provide /dev/urandom, then any random source + * will probably be blocking-style, so generate some random data to + * use as a seed for the certificate. Note that we have already + * seeded the random number generator in cupsdInitCerts()... + */ + + cupsdLogMessage(CUPSD_LOG_INFO, + "Seeding the random number generator..."); + + snprintf(home, sizeof(home), "HOME=%s", TempDir); + + /* + * Write the seed file... + */ + + if ((fp = cupsTempFile2(seedfile, sizeof(seedfile))) == NULL) + { + cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to create seed file %s - %s", + seedfile, strerror(errno)); + return (0); + } + + for (bytes = 0; bytes < 262144; bytes ++) + cupsFilePutChar(fp, random()); + + cupsFileClose(fp); + + /* + * Run the openssl command to seed its random number generator... + */ + + argv[0] = "openssl"; + argv[1] = "rand"; + argv[2] = "-rand"; + argv[3] = seedfile; + argv[4] = "1"; + argv[5] = NULL; + + envc = cupsdLoadEnv(envp, MAX_ENV); + envp[envc++] = home; + envp[envc] = NULL; + + if (!cupsdStartProcess(command, argv, envp, -1, -1, -1, -1, 1, &pid)) + { + unlink(seedfile); + return (0); + } + + while (waitpid(pid, &status, 0) < 0) + if (errno != EINTR) + { + status = 1; + break; + } + + cupsdFinishProcess(pid, command, sizeof(command)); + + /* + * Remove the seed file, as it is no longer needed... + */ + + unlink(seedfile); + + if (status) + { + if (WIFEXITED(status)) + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to seed random number generator - " + "the openssl command stopped with status %d!", + WEXITSTATUS(status)); + else + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to seed random number generator - " + "the openssl command crashed on signal %d!", + WTERMSIG(status)); + + return (0); + } + } + + /* + * Create a file with the certificate information fields... + * + * Note: This assumes that the default questions are asked by the openssl + * command... + */ + + if ((fp = cupsTempFile2(infofile, sizeof(infofile))) == NULL) + { + cupsdLogMessage(CUPSD_LOG_ERROR, + "Unable to create certificate information file %s - %s", + infofile, strerror(errno)); + return (0); + } + + cupsFilePrintf(fp, ".\n.\n.\n%s\n.\n%s\n%s\n", + ServerName, ServerName, ServerAdmin); + cupsFileClose(fp); + cupsdLogMessage(CUPSD_LOG_INFO, "Generating SSL server key and certificate..."); @@ -3390,8 +3540,17 @@ make_certificate(void) cupsdLoadEnv(envp, MAX_ENV); - if (!cupsdStartProcess(command, argv, envp, -1, -1, -1, -1, 1, &pid)) + infofd = open(infofile, O_RDONLY); + + if (!cupsdStartProcess(command, argv, envp, infofd, -1, -1, -1, 1, &pid)) + { + close(infofd); + unlink(infofile); return (0); + } + + close(infofd); + unlink(infofile); while (waitpid(pid, &status, 0) < 0) if (errno != EINTR) @@ -3993,6 +4152,8 @@ write_file(cupsd_client_t *con, /* I - Client connection */ if (httpPrintf(HTTP(con), "\r\n") < 0) return (0); + cupsdFlushHeader(con); + con->http.data_encoding = HTTP_ENCODE_LENGTH; con->http.data_remaining = filestats->st_size; @@ -4011,5 +4172,5 @@ write_file(cupsd_client_t *con, /* I - Client connection */ /* - * End of "$Id: client.c 5739 2006-07-16 15:21:18Z mike $". + * End of "$Id: client.c 5898 2006-08-28 18:54:10Z mike $". */ diff --git a/scheduler/client.h b/scheduler/client.h index 7a7b70cd7..ef376cda8 100644 --- a/scheduler/client.h +++ b/scheduler/client.h @@ -1,5 +1,5 @@ /* - * "$Id: client.h 5305 2006-03-18 03:05:12Z mike $" + * "$Id: client.h 5889 2006-08-24 21:44:35Z mike $" * * Client definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -104,6 +104,7 @@ extern void cupsdAcceptClient(cupsd_listener_t *lis); extern void cupsdCloseAllClients(void); extern int cupsdCloseClient(cupsd_client_t *con); extern void cupsdDeleteAllListeners(void); +extern void cupsdFlushHeader(cupsd_client_t *con); extern void cupsdPauseListening(void); extern int cupsdProcessIPPRequest(cupsd_client_t *con); extern int cupsdReadClient(cupsd_client_t *con); @@ -121,5 +122,5 @@ extern int cupsdWriteClient(cupsd_client_t *con); /* - * End of "$Id: client.h 5305 2006-03-18 03:05:12Z mike $". + * End of "$Id: client.h 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/conf.c b/scheduler/conf.c index 42acaf083..4d4f1cf85 100644 --- a/scheduler/conf.c +++ b/scheduler/conf.c @@ -1,5 +1,5 @@ /* - * "$Id: conf.c 5736 2006-07-13 19:59:36Z mike $" + * "$Id: conf.c 5905 2006-08-29 20:48:59Z mike $" * * Configuration routines for the Common UNIX Printing System (CUPS). * @@ -636,21 +636,21 @@ cupsdReadConfiguration(void) * writable by the user and group in the cupsd.conf file... */ - check_permissions(CacheDir, NULL, 0775, RunUser, Group, 1, 1); -/* check_permissions(CacheDir, "ppd", 0755, RunUser, Group, 1, 1);*/ - - check_permissions(StateDir, NULL, 0755, RunUser, Group, 1, 1); - check_permissions(StateDir, "certs", RunUser ? 0711 : 0511, User, - SystemGroupIDs[0], 1, 1); - - check_permissions(ServerRoot, NULL, 0755, RunUser, Group, 1, 0); - check_permissions(ServerRoot, "ppd", 0755, RunUser, Group, 1, 1); - check_permissions(ServerRoot, "ssl", 0700, RunUser, Group, 1, 0); - check_permissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser, Group, - 0, 0); - check_permissions(ServerRoot, "classes.conf", 0600, RunUser, Group, 0, 0); - check_permissions(ServerRoot, "printers.conf", 0600, RunUser, Group, 0, 0); - check_permissions(ServerRoot, "passwd.md5", 0600, User, Group, 0, 0); + if (check_permissions(CacheDir, NULL, 0775, RunUser, Group, 1, 1) < 0 || + check_permissions(StateDir, NULL, 0755, RunUser, Group, 1, 1) < 0 || + check_permissions(StateDir, "certs", RunUser ? 0711 : 0511, User, + SystemGroupIDs[0], 1, 1) < 0 || + check_permissions(ServerRoot, NULL, 0755, RunUser, Group, 1, 0) < 0 || + check_permissions(ServerRoot, "ppd", 0755, RunUser, Group, 1, 1) < 0 || + check_permissions(ServerRoot, "ssl", 0700, RunUser, Group, 1, 0) < 0 || + check_permissions(ServerRoot, "cupsd.conf", ConfigFilePerm, RunUser, + Group, 0, 0) < 0 || + check_permissions(ServerRoot, "classes.conf", 0600, RunUser, Group, + 0, 0) < 0 || + check_permissions(ServerRoot, "printers.conf", 0600, RunUser, Group, + 0, 0) < 0 || + check_permissions(ServerRoot, "passwd.md5", 0600, User, Group, 0, 0) < 0) + return (0); /* * Update TempDir to the default if it hasn't been set already... @@ -677,14 +677,14 @@ cupsdReadConfiguration(void) "TMPDIR (%s) has the wrong permissions!", tmpdir); else cupsdSetString(&TempDir, tmpdir); - - if (!TempDir) - cupsdLogMessage(CUPSD_LOG_INFO, "Using default TempDir of %s/tmp...", - RequestRoot); } if (!TempDir) + { + cupsdLogMessage(CUPSD_LOG_INFO, "Using default TempDir of %s/tmp...", + RequestRoot); cupsdSetStringf(&TempDir, "%s/tmp", RequestRoot); + } } /* @@ -692,7 +692,8 @@ cupsdReadConfiguration(void) * permissions... */ - check_permissions(RequestRoot, NULL, 0710, RunUser, Group, 1, 1); + if (check_permissions(RequestRoot, NULL, 0710, RunUser, Group, 1, 1) < 0) + return (0); if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot)) || access(TempDir, 0)) @@ -702,7 +703,8 @@ cupsdReadConfiguration(void) * is under the spool directory or does not exist... */ - check_permissions(TempDir, NULL, 01770, RunUser, Group, 1, 1); + if (check_permissions(TempDir, NULL, 01770, RunUser, Group, 1, 1) < 0) + return (0); } if (!strncmp(TempDir, RequestRoot, strlen(RequestRoot))) @@ -772,7 +774,7 @@ cupsdReadConfiguration(void) if (MaxActiveJobs > (MaxFDs / 3)) MaxActiveJobs = MaxFDs / 3; - if (Classification && strcasecmp(Classification, "none") == 0) + if (Classification && !strcasecmp(Classification, "none")) cupsdClearString(&Classification); if (Classification) @@ -1112,7 +1114,7 @@ cupsdReadConfiguration(void) * 'check_permissions()' - Fix the mode and ownership of a file or directory. */ -static int /* O - 0 on success, -1 on error */ +static int /* O - 0 on success, -1 on error, 1 on warning */ check_permissions(const char *filename, /* I - File/directory name */ const char *suffix, /* I - Additional file/directory name */ int mode, /* I - Permissions */ @@ -1158,7 +1160,7 @@ check_permissions(const char *filename, /* I - File/directory name */ dir_created = 1; } else - return (-1); + return (create_dir ? -1 : 1); } /* @@ -1190,7 +1192,7 @@ check_permissions(const char *filename, /* I - File/directory name */ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to change ownership of \"%s\" - %s", filename, strerror(errno)); - return (-1); + return (1); } } @@ -1203,7 +1205,7 @@ check_permissions(const char *filename, /* I - File/directory name */ cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to change permissions of \"%s\" - %s", filename, strerror(errno)); - return (-1); + return (1); } } @@ -1946,6 +1948,13 @@ parse_protocols(const char *s) /* I - Space-delimited protocols */ *valend; /* End of value */ + /* + * Empty protocol line yields NULL pointer... + */ + + if (!s) + return (0); + /* * Loop through the value string,... */ @@ -3280,5 +3289,5 @@ read_policy(cups_file_t *fp, /* I - Configuration file */ /* - * End of "$Id: conf.c 5736 2006-07-13 19:59:36Z mike $". + * End of "$Id: conf.c 5905 2006-08-29 20:48:59Z mike $". */ diff --git a/scheduler/cups-lpd.c b/scheduler/cups-lpd.c index 60b68090f..caa6bef9a 100644 --- a/scheduler/cups-lpd.c +++ b/scheduler/cups-lpd.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-lpd.c 5455 2006-04-24 13:49:59Z mike $" + * "$Id: cups-lpd.c 5878 2006-08-24 15:55:42Z mike $" * * Line Printer Daemon interface for the Common UNIX Printing System (CUPS). * @@ -471,7 +471,7 @@ get_printer(http_t *http, /* I - HTTP connection */ request = ippNewRequest(CUPS_GET_PRINTERS); - ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME, + ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(requested) / sizeof(requested[0])), NULL, requested); @@ -597,7 +597,7 @@ get_printer(http_t *http, /* I - HTTP connection */ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); - ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME, + ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", (int)(sizeof(requested) / sizeof(requested[0])), NULL, requested); @@ -648,7 +648,7 @@ get_printer(http_t *http, /* I - HTTP connection */ if (state) { if ((attr = ippFindAttribute(response, "printer-state", - IPP_TAG_INTEGER)) == NULL) + IPP_TAG_ENUM)) == NULL) syslog(LOG_ERR, "No printer-state attribute found in " "response from server!"); else @@ -1387,7 +1387,7 @@ remove_jobs(const char *dest, /* I - Destination */ return (1); } else - syslog(LOG_INFO, "Job ID %d cancelled", id); + syslog(LOG_INFO, "Job ID %d canceled", id); } httpClose(http); @@ -1716,5 +1716,5 @@ smart_gets(char *s, /* I - Pointer to line buffer */ /* - * End of "$Id: cups-lpd.c 5455 2006-04-24 13:49:59Z mike $". + * End of "$Id: cups-lpd.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/scheduler/cups-polld.c b/scheduler/cups-polld.c index 259361d5b..be6bbb5e6 100644 --- a/scheduler/cups-polld.c +++ b/scheduler/cups-polld.c @@ -1,5 +1,5 @@ /* - * "$Id: cups-polld.c 5753 2006-07-18 19:53:24Z mike $" + * "$Id: cups-polld.c 5871 2006-08-23 20:55:33Z mike $" * * Polling daemon for the Common UNIX Printing System (CUPS). * @@ -23,9 +23,11 @@ * * Contents: * - * main() - Open sockets and poll until we are killed... - * dequote() - Remote quotes from a string. - * poll_server() - Poll the server for the given set of printers or classes. + * main() - Open sockets and poll until we are killed... + * dequote() - Remote quotes from a string. + * poll_server() - Poll the server for the given set of printers or + * classes. + * sighup_handler() - Handle 'hangup' signals to restart polling. */ /* @@ -38,6 +40,14 @@ #include #include #include +#include + + +/* + * Local globals... + */ + +static int restart_polling = 1; /* @@ -47,6 +57,7 @@ static char *dequote(char *d, const char *s, int dlen); static int poll_server(http_t *http, int sock, int port, int interval, const char *prefix); +static void sighup_handler(int sig); /* @@ -65,8 +76,28 @@ main(int argc, /* I - Number of command-line args */ int seconds, /* Seconds left from poll */ remain; /* Total remaining time to sleep */ char prefix[1024]; /* Prefix for log messages */ +#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET) + struct sigaction action; /* Actions for POSIX signals */ +#endif /* HAVE_SIGACTION && !HAVE_SIGSET */ + /* + * Catch hangup signals for when the network changes... + */ + +#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */ + sigset(SIGHUP, sighup_handler); +#elif defined(HAVE_SIGACTION) + memset(&action, 0, sizeof(action)); + + sigemptyset(&action.sa_mask); + sigaddset(&action.sa_mask, SIGHUP); + action.sa_handler = sighup_handler; + sigaction(SIGHUP, &action, NULL); +#else + signal(SIGHUP, sighup_handler); +#endif /* HAVE_SIGSET */ + /* * Don't buffer log messages... */ @@ -119,38 +150,43 @@ main(int argc, /* I - Number of command-line args */ } /* - * Open a connection to the server... + * Loop forever, asking for available printers and classes... */ - while ((http = httpConnectEncrypt(argv[1], atoi(argv[2]), - cupsEncryption())) == NULL) + for (http = NULL;;) { - fprintf(stderr, "ERROR: %s Unable to connect to %s on port %s: %s\n", - prefix, argv[1], argv[2], - h_errno ? hstrerror(h_errno) : strerror(errno)); - sleep(interval); - } + /* + * Open a connection to the server... + */ - /* - * Loop forever, asking for available printers and classes... - */ + if (restart_polling || !http) + { + restart_polling = 0; + httpClose(http); + + if ((http = httpConnectEncrypt(argv[1], atoi(argv[2]), + cupsEncryption())) == NULL) + { + fprintf(stderr, "ERROR: %s Unable to connect to %s on port %s: %s\n", + prefix, argv[1], argv[2], + h_errno ? hstrerror(h_errno) : strerror(errno)); + } + } - for (;;) - { /* * Get the printers and classes... */ remain = interval; - if ((seconds = poll_server(http, sock, port, interval, prefix)) > 0) + if (http && (seconds = poll_server(http, sock, port, interval, prefix)) > 0) remain -= seconds; /* * Sleep for any remaining time... */ - if (remain > 0) + if (remain > 0 && !restart_polling) sleep(remain); } } @@ -260,6 +296,7 @@ poll_server(http_t *http, /* I - HTTP connection */ * Do the request and get back a response... */ + seconds = time(NULL); response = cupsDoRequest(http, request, "/"); if (cupsLastError() > IPP_OK_CONFLICT) @@ -285,7 +322,6 @@ poll_server(http_t *http, /* I - HTTP connection */ fprintf(stderr, "DEBUG: %s Found %d printers.\n", prefix, max_count); count = 0; - seconds = time(NULL); max_count = max_count / interval + 1; /* @@ -409,7 +445,7 @@ poll_server(http_t *http, /* I - HTTP connection */ sleep(1); } - if (!attr) + if (!attr || restart_polling) break; } @@ -425,5 +461,22 @@ poll_server(http_t *http, /* I - HTTP connection */ /* - * End of "$Id: cups-polld.c 5753 2006-07-18 19:53:24Z mike $". + * 'sighup_handler()' - Handle 'hangup' signals to restart polling. + */ + +static void +sighup_handler(int sig) /* I - Signal number */ +{ + (void)sig; + + restart_polling = 1; + +#if !defined(HAVE_SIGSET) && !defined(HAVE_SIGACTION) + signal(SIGHUP, sighup_handler); +#endif /* !HAVE_SIGSET && !HAVE_SIGACTION */ +} + + +/* + * End of "$Id: cups-polld.c 5871 2006-08-23 20:55:33Z mike $". */ diff --git a/scheduler/dirsvc.c b/scheduler/dirsvc.c index c2e19a970..cb751549b 100644 --- a/scheduler/dirsvc.c +++ b/scheduler/dirsvc.c @@ -1,5 +1,5 @@ /* - * "$Id: dirsvc.c 5724 2006-07-12 19:42:35Z mike $" + * "$Id: dirsvc.c 5889 2006-08-24 21:44:35Z mike $" * * Directory services routines for the Common UNIX Printing System (CUPS). * @@ -513,6 +513,23 @@ cupsdLoadRemoteCache(void) } +/* + * 'cupsdRestartPolling()' - Restart polling servers as needed. + */ + +void +cupsdRestartPolling(void) +{ + int i; /* Looping var */ + cupsd_dirsvc_poll_t *pollp; /* Current polling server */ + + + for (i = 0, pollp = Polled; i < NumPolled; i ++, pollp ++) + if (pollp->pid) + kill(pollp->pid, SIGHUP); +} + + /* * 'cupsdSaveRemoteCache()' - Save the remote printer cache. */ @@ -1468,7 +1485,7 @@ cupsdUpdateCUPSBrowse(void) if (cupsdCheckAuth(address, srcname, len, 1, &(Relays[i].from))) if (sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(Relays[i].to), - sizeof(http_addr_t)) <= 0) + httpAddrLength(&(Relays[i].to))) <= 0) { cupsdLogMessage(CUPSD_LOG_ERROR, "cupsdUpdateCUPSBrowse: sendto failed for relay %d - %s.", @@ -1609,7 +1626,7 @@ cupsdUpdatePolling(void) if (!strchr(PollStatusBuffer->buffer, '\n')) break; - if (ptr == NULL) + if (ptr == NULL && !PollStatusBuffer->bufused) { /* * All polling processes have died; stop polling... @@ -1923,6 +1940,9 @@ process_browse_data( else return; + if (hptr && !*hptr) + *hptr = '.'; /* Resource FQDN */ + if ((p = cupsdFindClass(name)) == NULL && BrowseShortNames) { if ((p = cupsdFindClass(resource + 9)) != NULL) @@ -2026,6 +2046,9 @@ process_browse_data( else return; + if (hptr && !*hptr) + *hptr = '.'; /* Resource FQDN */ + if ((p = cupsdFindPrinter(name)) == NULL && BrowseShortNames) { if ((p = cupsdFindPrinter(resource + 10)) != NULL) @@ -2566,7 +2589,7 @@ send_cups_browse(cupsd_printer_t *p) /* I - Printer to send */ sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(iface->broadcast), - sizeof(struct sockaddr_in)); + httpAddrLength(&(iface->broadcast))); } } else if ((iface = cupsdNetIFFind(b->iface)) != NULL) @@ -2607,7 +2630,7 @@ send_cups_browse(cupsd_printer_t *p) /* I - Printer to send */ sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(iface->broadcast), - sizeof(struct sockaddr_in)); + httpAddrLength(&(iface->broadcast))); } } } @@ -2628,7 +2651,7 @@ send_cups_browse(cupsd_printer_t *p) /* I - Printer to send */ if (sendto(BrowseSocket, packet, bytes, 0, (struct sockaddr *)&(b->to), - sizeof(struct sockaddr_in)) <= 0) + httpAddrLength(&(b->to))) <= 0) { /* * Unable to send browse packet, so remove this address from the @@ -3158,5 +3181,5 @@ slp_url_callback( /* - * End of "$Id: dirsvc.c 5724 2006-07-12 19:42:35Z mike $". + * End of "$Id: dirsvc.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/dirsvc.h b/scheduler/dirsvc.h index 171933f93..2e3a05988 100644 --- a/scheduler/dirsvc.h +++ b/scheduler/dirsvc.h @@ -1,5 +1,5 @@ /* - * "$Id: dirsvc.h 5305 2006-03-18 03:05:12Z mike $" + * "$Id: dirsvc.h 5833 2006-08-16 20:05:58Z mike $" * * Directory services definitions for the Common UNIX Printing System * (CUPS) scheduler. @@ -164,6 +164,7 @@ VAR char *BrowseLDAPBindDN VALUE(NULL), */ extern void cupsdLoadRemoteCache(void); +extern void cupsdRestartPolling(void); extern void cupsdSaveRemoteCache(void); extern void cupsdSendBrowseDelete(cupsd_printer_t *p); extern void cupsdSendBrowseList(void); @@ -180,5 +181,5 @@ extern void cupsdUpdateSLPBrowse(void); /* - * End of "$Id: dirsvc.h 5305 2006-03-18 03:05:12Z mike $". + * End of "$Id: dirsvc.h 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/scheduler/ipp.c b/scheduler/ipp.c index 28115133d..d32a71505 100644 --- a/scheduler/ipp.c +++ b/scheduler/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c 5736 2006-07-13 19:59:36Z mike $" + * "$Id: ipp.c 5907 2006-08-30 02:18:28Z mike $" * * IPP routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -630,7 +630,7 @@ cupsdProcessIPPRequest( #ifdef CUPSD_USE_CHUNKING /* * Because older versions of CUPS (1.1.17 and older) and some IPP - * clients do not implement chunking properly, we should not use + * clients do not implement chunking properly, we cannot use * chunking by default. This may become the default in future * CUPS releases, or we might add a configuration directive for * it. @@ -638,23 +638,25 @@ cupsdProcessIPPRequest( if (con->http.version == HTTP_1_1) { - con->http.data_encoding = HTTP_ENCODE_CHUNKED; - httpPrintf(HTTP(con), "Transfer-Encoding: chunked\r\n\r\n"); + cupsdFlushHeader(con); + + con->http.data_encoding = HTTP_ENCODE_CHUNKED; } else #endif /* CUPSD_USE_CHUNKING */ { - con->http.data_encoding = HTTP_ENCODE_LENGTH; - con->http.data_remaining = ippLength(con->response); + size_t length; /* Length of response */ - if (con->http.data_remaining < INT_MAX) - con->http._data_remaining = con->http.data_remaining; - else - con->http._data_remaining = INT_MAX; + + length = ippLength(con->response); httpPrintf(HTTP(con), "Content-Length: " CUPS_LLFMT "\r\n\r\n", - CUPS_LLCAST con->http.data_remaining); + CUPS_LLCAST length); + cupsdFlushHeader(con); + + con->http.data_encoding = HTTP_ENCODE_LENGTH; + con->http.data_remaining = length; } cupsdLogMessage(CUPSD_LOG_DEBUG2, @@ -784,7 +786,6 @@ add_class(cupsd_client_t *con, /* I - Client connection */ cupsd_printer_t *pclass, /* Class */ *member; /* Member printer/class */ cups_ptype_t dtype; /* Destination type */ - const char *dest; /* Printer or class name */ ipp_attribute_t *attr; /* Printer attribute */ int modify; /* Non-zero if we just modified */ char newname[IPP_MAX_NAME]; /* New class name */ @@ -1007,7 +1008,7 @@ add_class(cupsd_client_t *con, /* I - Client connection */ sizeof(method), username, sizeof(username), host, sizeof(host), &port, resource, sizeof(resource)); - if ((dest = cupsdValidateDest(host, resource, &dtype, &member)) == NULL) + if (!cupsdValidateDest(host, resource, &dtype, &member)) { /* * Bad URI... @@ -1467,7 +1468,7 @@ add_job(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", job->id); job->state = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", IPP_JOB_STOPPED); - job->state_value = job->state->values[0].integer; + job->state_value = (ipp_jstate_t)job->state->values[0].integer; job->sheets = ippAddInteger(job->attrs, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-media-sheets-completed", 0); ippAddString(job->attrs, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri", NULL, @@ -1728,7 +1729,7 @@ add_job_state_reasons( cupsdLogMessage(CUPSD_LOG_DEBUG2, "add_job_state_reasons(%p[%d], %d)", con, con->http.fd, job ? job->id : 0); - switch (job ? job->state_value : IPP_JOB_CANCELLED) + switch (job ? job->state_value : IPP_JOB_CANCELED) { case IPP_JOB_PENDING : dest = cupsdFindDest(job->dest); @@ -1763,7 +1764,7 @@ add_job_state_reasons( "job-state-reasons", NULL, "job-stopped"); break; - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : ippAddString(con->response, IPP_TAG_JOB, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-canceled-by-user"); break; @@ -1961,7 +1962,6 @@ add_job_uuid(cupsd_client_t *con, /* I - Client connection */ cupsd_job_t *job) /* I - Job */ { char uuid[1024]; /* job-uuid string */ - ipp_attribute_t *attr; /* job-uuid attribute */ _cups_md5_state_t md5state; /* MD5 state */ unsigned char md5sum[16]; /* MD5 digest/sum */ @@ -1970,7 +1970,7 @@ add_job_uuid(cupsd_client_t *con, /* I - Client connection */ * First see if the job already has a job-uuid attribute; if so, return... */ - if ((attr = ippFindAttribute(job->attrs, "job-uuid", IPP_TAG_URI)) != NULL) + if (ippFindAttribute(job->attrs, "job-uuid", IPP_TAG_URI)) return; /* @@ -2872,7 +2872,7 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ cupsdCancelJobs(NULL, username, purge); cupsdLogMessage(CUPSD_LOG_INFO, "All jobs were %s by \"%s\".", - purge ? "purged" : "cancelled", get_username(con)); + purge ? "purged" : "canceled", get_username(con)); } else { @@ -2893,7 +2893,7 @@ cancel_all_jobs(cupsd_client_t *con, /* I - Client connection */ cupsdCancelJobs(dest, username, purge); cupsdLogMessage(CUPSD_LOG_INFO, "All jobs on \"%s\" were %s by \"%s\".", - dest, purge ? "purged" : "cancelled", get_username(con)); + dest, purge ? "purged" : "canceled", get_username(con)); } con->response->request.status.status_code = IPP_OK; @@ -3043,17 +3043,17 @@ cancel_job(cupsd_client_t *con, /* I - Client connection */ } /* - * See if the job is already completed, cancelled, or aborted; if so, + * See if the job is already completed, canceled, or aborted; if so, * we can't cancel... */ - if (job->state_value >= IPP_JOB_CANCELLED) + if (job->state_value >= IPP_JOB_CANCELED) { switch (job->state_value) { - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : send_ipp_status(con, IPP_NOT_POSSIBLE, - _("Job #%d is already cancelled - can\'t cancel."), + _("Job #%d is already canceled - can\'t cancel."), jobid); break; @@ -3078,12 +3078,12 @@ cancel_job(cupsd_client_t *con, /* I - Client connection */ */ cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, - "Job cancelled by \"%s\".", username); + "Job canceled by \"%s\".", username); cupsdCancelJob(job, 0); cupsdCheckJobs(); - cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was cancelled by \"%s\".", jobid, + cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was canceled by \"%s\".", jobid, username); con->response->request.status.status_code = IPP_OK; @@ -4382,7 +4382,7 @@ copy_subscription_attrs( */ ippAddString(con->response, IPP_TAG_SUBSCRIPTION, - IPP_TAG_KEYWORD | IPP_TAG_COPY, + (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY), "notify-events", NULL, name); } else @@ -4396,7 +4396,7 @@ copy_subscription_attrs( count ++; attr = ippAddStrings(con->response, IPP_TAG_SUBSCRIPTION, - IPP_TAG_KEYWORD | IPP_TAG_COPY, + (ipp_tag_t)(IPP_TAG_KEYWORD | IPP_TAG_COPY), "notify-events", count, NULL, NULL); for (mask = 1, count = 0; mask < CUPSD_EVENT_ALL; mask <<= 1) @@ -4676,7 +4676,6 @@ create_subscription( http_status_t status; /* Policy status */ int i; /* Looping var */ ipp_attribute_t *attr; /* Current attribute */ - const char *dest; /* Destination */ cups_ptype_t dtype; /* Destination type (printer or class) */ char scheme[HTTP_MAX_URI], /* Scheme portion of URI */ @@ -4725,23 +4724,20 @@ create_subscription( if (!strcmp(resource, "/")) { - dest = NULL; dtype = (cups_ptype_t)0; printer = NULL; } else if (!strncmp(resource, "/printers", 9) && strlen(resource) <= 10) { - dest = NULL; dtype = (cups_ptype_t)0; printer = NULL; } else if (!strncmp(resource, "/classes", 8) && strlen(resource) <= 9) { - dest = NULL; dtype = CUPS_PRINTER_CLASS; printer = NULL; } - else if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) + else if (!cupsdValidateDest(host, resource, &dtype, &printer)) { /* * Bad URI... @@ -5734,7 +5730,6 @@ get_printer_attrs(cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *uri) /* I - Printer URI */ { http_status_t status; /* Policy status */ - const char *dest; /* Destination */ cups_ptype_t dtype; /* Destination type (printer or class) */ char method[HTTP_MAX_URI], /* Method portion of URI */ @@ -5760,7 +5755,7 @@ get_printer_attrs(cupsd_client_t *con, /* I - Client connection */ sizeof(method), username, sizeof(username), host, sizeof(host), &port, resource, sizeof(resource)); - if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL) + if (!cupsdValidateDest(host, resource, &dtype, &printer)) { /* * Bad URI... @@ -6269,6 +6264,9 @@ hold_job(cupsd_client_t *con, /* I - Client connection */ cupsdHoldJob(job); + cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, + "Job held by user."); + if ((newattr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_KEYWORD)) == NULL) newattr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME); @@ -6302,6 +6300,9 @@ hold_job(cupsd_client_t *con, /* I - Client connection */ */ cupsdSetJobHoldUntil(job, attr->values[0].string.text); + + cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job, + "Job job-hold-until value changed by user."); } cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was held by \"%s\".", jobid, @@ -6323,8 +6324,7 @@ move_job(cupsd_client_t *con, /* I - Client connection */ ipp_attribute_t *attr; /* Current attribute */ int jobid; /* Job ID */ cupsd_job_t *job; /* Current job */ - const char *src, /* Source printer/class */ - *dest; /* Destination */ + const char *src; /* Source printer/class */ cups_ptype_t stype, /* Source type (printer or class) */ dtype; /* Destination type (printer or class) */ char method[HTTP_MAX_URI], /* Method portion of URI */ @@ -6359,7 +6359,7 @@ move_job(cupsd_client_t *con, /* I - Client connection */ sizeof(method), username, sizeof(username), host, sizeof(host), &port, resource, sizeof(resource)); - if ((dest = cupsdValidateDest(host, resource, &dtype, &dprinter)) == NULL) + if (!cupsdValidateDest(host, resource, &dtype, &dprinter)) { /* * Bad URI... @@ -7317,6 +7317,9 @@ release_job(cupsd_client_t *con, /* I - Client connection */ attr->value_tag = IPP_TAG_KEYWORD; attr->values[0].string.text = _cupsStrAlloc("no-hold"); + + cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job, + "Job job-hold-until value changed by user."); } /* @@ -7325,6 +7328,9 @@ release_job(cupsd_client_t *con, /* I - Client connection */ cupsdReleaseJob(job); + cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, + "Job released by user."); + cupsdLogMessage(CUPSD_LOG_INFO, "Job %d was released by \"%s\".", jobid, username); @@ -8004,7 +8010,7 @@ send_document(cupsd_client_t *con, /* I - Client connection */ ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_INTEGER, "job-id", jobid); ippAddInteger(con->response, IPP_TAG_JOB, IPP_TAG_ENUM, "job-state", - job ? job->state_value : IPP_JOB_CANCELLED); + job ? job->state_value : IPP_JOB_CANCELED); add_job_state_reasons(con, job); con->response->request.status.status_code = IPP_OK; @@ -8053,14 +8059,12 @@ send_ipp_status(cupsd_client_t *con, /* I - Client connection */ _cupsLangString(con->language, message), ap); va_end(ap); - cupsdLogMessage(status >= IPP_BAD_REQUEST ? CUPSD_LOG_ERROR : CUPSD_LOG_INFO, - "%s %s: %s", + cupsdLogMessage(CUPSD_LOG_DEBUG, "%s %s: %s", ippOpString(con->request->request.op.operation_id), ippErrorString(status), formatted); } else - cupsdLogMessage(status >= IPP_BAD_REQUEST ? CUPSD_LOG_ERROR : CUPSD_LOG_INFO, - "%s %s", + cupsdLogMessage(CUPSD_LOG_DEBUG, "%s %s", ippOpString(con->request->request.op.operation_id), ippErrorString(status)); @@ -8181,6 +8185,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ resource[HTTP_MAX_URI]; /* Resource portion of URI */ int port; /* Port portion of URI */ + int event; /* Events? */ cupsdLogMessage(CUPSD_LOG_DEBUG2, "set_job_attrs(%p[%d], %s)", con, @@ -8282,6 +8287,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ cupsdLoadJob(job); + event = 0; + for (attr = con->request->attrs; attr; attr = attr->next) { if (attr->group_tag != IPP_TAG_JOB || !attr->name) @@ -8345,7 +8352,10 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ return; } else if (con->response->request.status.status_code == IPP_OK) + { cupsdSetJobPriority(job, attr->values[0].integer); + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED; + } } else if (!strcmp(attr->name, "job-state")) { @@ -8375,7 +8385,9 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ else if (con->response->request.status.status_code == IPP_OK) { job->state->values[0].integer = attr->values[0].integer; - job->state_value = attr->values[0].integer; + job->state_value = (ipp_jstate_t)attr->values[0].integer; + + event |= CUPSD_EVENT_JOB_STATE; } break; @@ -8389,7 +8401,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ } break; - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : case IPP_JOB_ABORTED : case IPP_JOB_COMPLETED : if (job->state_value > IPP_JOB_PROCESSING) @@ -8405,7 +8417,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ if (JobHistory) { job->state->values[0].integer = attr->values[0].integer; - job->state_value = attr->values[0].integer; + job->state_value = (ipp_jstate_t)attr->values[0].integer; cupsdSaveJob(job); } } @@ -8450,6 +8462,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ cupsdReleaseJob(job); else cupsdHoldJob(job); + + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE; } } else if (attr->value_tag == IPP_TAG_DELETEATTR) @@ -8470,6 +8484,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ job->attrs->last = job->attrs->prev; _ippFreeAttr(attr2); + + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED; } } else @@ -8479,6 +8495,8 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ */ copy_attribute(job->attrs, attr, 0); + + event |= CUPSD_EVENT_JOB_CONFIG_CHANGED; } } @@ -8488,6 +8506,19 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */ cupsdSaveJob(job); + /* + * Send events as needed... + */ + + if (event & CUPSD_EVENT_JOB_STATE) + cupsdAddEvent(CUPSD_EVENT_JOB_STATE, job->printer, job, + job->state_value == IPP_JOB_HELD ? + "Job held by user." : "Job restarted by user."); + + if (event & CUPSD_EVENT_JOB_CONFIG_CHANGED) + cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, job->printer, job, + "Job options changed by user."); + /* * Start jobs if possible... */ @@ -9200,5 +9231,5 @@ validate_user(cupsd_job_t *job, /* I - Job */ /* - * End of "$Id: ipp.c 5736 2006-07-13 19:59:36Z mike $". + * End of "$Id: ipp.c 5907 2006-08-30 02:18:28Z mike $". */ diff --git a/scheduler/job.c b/scheduler/job.c index 967f9ac67..79370fbba 100644 --- a/scheduler/job.c +++ b/scheduler/job.c @@ -1,5 +1,5 @@ /* - * "$Id: job.c 5719 2006-07-11 21:04:48Z mike $" + * "$Id: job.c 5889 2006-08-24 21:44:35Z mike $" * * Job management routines for the Common UNIX Printing System (CUPS). * @@ -354,7 +354,7 @@ cupsdCheckJobs(void) */ cupsdLogMessage(CUPSD_LOG_WARN, - "Printer/class %s has gone away; cancelling job %d!", + "Printer/class %s has gone away; canceling job %d!", job->dest, job->id); cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, @@ -690,7 +690,7 @@ cupsdFreeAllJobs(void) cupsdHoldSignals(); - cupsdStopAllJobs(); + cupsdStopAllJobs(1); cupsdSaveAllJobs(); for (job = (cupsd_job_t *)cupsArrayFirst(Jobs); @@ -1494,7 +1494,7 @@ cupsdSetJobPriority( */ void -cupsdStopAllJobs(void) +cupsdStopAllJobs(int force) /* I - 1 = Force all filters to stop */ { cupsd_job_t *job; /* Current job */ @@ -1506,7 +1506,7 @@ cupsdStopAllJobs(void) job = (cupsd_job_t *)cupsArrayNext(ActiveJobs)) if (job->state_value == IPP_JOB_PROCESSING) { - cupsdStopJob(job, 1); + cupsdStopJob(job, force); job->state->values[0].integer = IPP_JOB_PENDING; job->state_value = IPP_JOB_PENDING; } @@ -1728,7 +1728,7 @@ cupsdUpdateJob(cupsd_job_t *job) /* I - Job to check */ break; } - if (ptr == NULL) + if (ptr == NULL && !job->status_buffer->bufused) { /* * See if all of the filters and the backend have returned their @@ -2053,7 +2053,7 @@ load_job_cache(const char *filename) /* I - job.cache filename */ } else if (!strcasecmp(line, "State")) { - job->state_value = atoi(value); + job->state_value = (ipp_jstate_t)atoi(value); if (job->state_value < IPP_JOB_PENDING) job->state_value = IPP_JOB_PENDING; @@ -2425,7 +2425,6 @@ start_job(cupsd_job_t *job, /* I - Job ID */ /* PRINTER env variable */ rip_max_cache[255]; /* RIP_MAX_CACHE env variable */ - int remote_job; /* Remote print job? */ static char *options = NULL;/* Full list of options */ static int optlength = 0; /* Length of option buffer */ @@ -2435,7 +2434,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ if (job->num_files == 0) { - cupsdLogMessage(CUPSD_LOG_ERROR, "Job ID %d has no files! Cancelling it!", + cupsdLogMessage(CUPSD_LOG_ERROR, "Job ID %d has no files! Canceling it!", job->id); cupsdAddEvent(CUPSD_EVENT_JOB_COMPLETED, job->printer, job, @@ -2566,18 +2565,11 @@ start_job(cupsd_job_t *job, /* I - Job ID */ FilterLevel += job->cost; - /* - * Determine if we are printing to a remote printer... - */ - - remote_job = printer->raw && job->num_files > 1 && - !strncmp(printer->device_uri, "ipp://", 6); - /* * Add decompression filters, if any... */ - if (!remote_job && job->compressions[job->current_file]) + if (!printer->raw && job->compressions[job->current_file]) { /* * Add gziptoany filter to the front of the list... @@ -2911,7 +2903,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ * For remote jobs, we send all of the files in the argument list. */ - if (remote_job) + if (printer->remote && job->num_files > 1) argv = calloc(7 + job->num_files, sizeof(char *)); else argv = calloc(8, sizeof(char *)); @@ -2925,7 +2917,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ argv[4] = copies; argv[5] = options; - if (remote_job) + if (printer->remote && job->num_files > 1) { for (i = 0; i < job->num_files; i ++) { @@ -3018,11 +3010,12 @@ start_job(cupsd_job_t *job, /* I - Job ID */ envp[envc ++] = device_uri; envp[envc ++] = printer_name; - if ((filter = (mime_filter_t *)cupsArrayLast(filters)) != NULL) + if (!printer->remote && + (filter = (mime_filter_t *)cupsArrayLast(filters)) != NULL) { snprintf(final_content_type, sizeof(final_content_type), "FINAL_CONTENT_TYPE=%s/%s", - filter->src->super, filter->src->type); + filter->dst->super, filter->dst->type); envp[envc ++] = final_content_type; } @@ -3059,7 +3052,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ cupsdLogMessage(CUPSD_LOG_DEBUG, "[Job %d] envp[%d]=\"DEVICE_URI=%s\"", job->id, i, sani_uri); - if (remote_job) + if (printer->remote) job->current_file = job->num_files; else job->current_file ++; @@ -3355,7 +3348,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ slot, filterfds[slot][0], filterfds[slot][1]); cupsdClosePipe(filterfds[slot]); - if (remote_job) + if (printer->remote && job->num_files > 1) { for (i = 0; i < job->num_files; i ++) free(argv[i + 6]); @@ -3399,7 +3392,7 @@ start_job(cupsd_job_t *job, /* I - Job ID */ cupsArrayDelete(filters); - if (remote_job) + if (printer->remote && job->num_files > 1) { for (i = 0; i < job->num_files; i ++) free(argv[i + 6]); @@ -3433,5 +3426,5 @@ unload_job(cupsd_job_t *job) /* I - Job */ /* - * End of "$Id: job.c 5719 2006-07-11 21:04:48Z mike $". + * End of "$Id: job.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/job.h b/scheduler/job.h index 93bb774b2..48148c969 100644 --- a/scheduler/job.h +++ b/scheduler/job.h @@ -1,5 +1,5 @@ /* - * "$Id: job.h 5393 2006-04-14 18:17:18Z mike $" + * "$Id: job.h 5833 2006-08-16 20:05:58Z mike $" * * Print job definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -115,11 +115,11 @@ extern void cupsdSaveAllJobs(void); extern void cupsdSaveJob(cupsd_job_t *job); extern void cupsdSetJobHoldUntil(cupsd_job_t *job, const char *when); extern void cupsdSetJobPriority(cupsd_job_t *job, int priority); -extern void cupsdStopAllJobs(void); +extern void cupsdStopAllJobs(int force); extern void cupsdStopJob(cupsd_job_t *job, int force); extern void cupsdUpdateJob(cupsd_job_t *job); /* - * End of "$Id: job.h 5393 2006-04-14 18:17:18Z mike $". + * End of "$Id: job.h 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/scheduler/main.c b/scheduler/main.c index 2806c26bc..101f178de 100644 --- a/scheduler/main.c +++ b/scheduler/main.c @@ -1,5 +1,5 @@ /* - * "$Id: main.c 5634 2006-06-06 17:48:27Z mike $" + * "$Id: main.c 5878 2006-08-24 15:55:42Z mike $" * * Scheduler main loop for the Common UNIX Printing System (CUPS). * @@ -660,7 +660,7 @@ main(int argc, /* I - Number of command-line args */ * inactivity... */ - if (timeout.tv_sec == 86400 && Launchd && LaunchdTimeout && + if (timeout.tv_sec == 86400 && Launchd && LaunchdTimeout && !NumPolled && (!Browsing || !(BrowseLocalProtocols & BROWSE_DNSSD) || cupsArrayCount(Printers) == 0)) { @@ -1628,7 +1628,7 @@ launchd_sync_conf(void) kCFBooleanTrue); if ((Browsing && BrowseLocalProtocols && cupsArrayCount(Printers)) || - cupsArrayCount(ActiveJobs)) + cupsArrayCount(ActiveJobs) || NumPolled) CFDictionaryAddValue(cupsd_dict, CFSTR(LAUNCH_JOBKEY_RUNATLOAD), kCFBooleanTrue); else @@ -1893,7 +1893,7 @@ process_children(void) #endif /* HAVE_WAITPID */ { /* - * Ignore SIGTERM errors - that comes when a job is cancelled... + * Ignore SIGTERM errors - that comes when a job is canceled... */ cupsdFinishProcess(pid, name, sizeof(name)); @@ -2253,5 +2253,5 @@ usage(int status) /* O - Exit status */ /* - * End of "$Id: main.c 5634 2006-06-06 17:48:27Z mike $". + * End of "$Id: main.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/scheduler/mime.h b/scheduler/mime.h index 9c5aa6448..2b44bf121 100644 --- a/scheduler/mime.h +++ b/scheduler/mime.h @@ -1,5 +1,5 @@ /* - * "$Id: mime.h 5487 2006-05-03 19:28:29Z mike $" + * "$Id: mime.h 5771 2006-07-20 18:06:20Z mike $" * * MIME type/conversion database definitions for the Common UNIX Printing System (CUPS). * @@ -34,9 +34,9 @@ * C++ magic... */ -# ifdef _cplusplus +# ifdef __cplusplus extern "C" { -# endif /* _cplusplus */ +# endif /* __cplusplus */ /* @@ -147,11 +147,11 @@ extern mime_filter_t *mimeFirstFilter(mime_t *mime); extern mime_filter_t *mimeNextFilter(mime_t *mime); extern int mimeNumFilters(mime_t *mime); -# ifdef _cplusplus +# ifdef __cplusplus } -# endif /* _cplusplus */ +# endif /* __cplusplus */ #endif /* !_CUPS_MIME_H_ */ /* - * End of "$Id: mime.h 5487 2006-05-03 19:28:29Z mike $". + * End of "$Id: mime.h 5771 2006-07-20 18:06:20Z mike $". */ diff --git a/scheduler/policy.c b/scheduler/policy.c index e869c48ee..606978e3e 100644 --- a/scheduler/policy.c +++ b/scheduler/policy.c @@ -1,5 +1,5 @@ /* - * "$Id: policy.c 5247 2006-03-08 13:43:38Z mike $" + * "$Id: policy.c 5838 2006-08-17 14:41:42Z mike $" * * Policy routines for the Common UNIX Printing System (CUPS). * @@ -195,7 +195,7 @@ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ { cupsdLogMessage(CUPSD_LOG_CRIT, "cupsdCheckPolicy: p=%p, con=%p!", p, con); - return (0); + return ((http_status_t)0); } /* @@ -205,7 +205,7 @@ cupsdCheckPolicy(cupsd_policy_t *p, /* I - Policy */ if ((po = cupsdFindPolicyOp(p, con->request->request.op.operation_id)) == NULL) { cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdCheckPolicy: No matching operation, returning 0!"); - return (0); + return ((http_status_t)0); } con->best = po; @@ -330,5 +330,5 @@ cupsdFindPolicyOp(cupsd_policy_t *p, /* I - Policy */ /* - * End of "$Id: policy.c 5247 2006-03-08 13:43:38Z mike $". + * End of "$Id: policy.c 5838 2006-08-17 14:41:42Z mike $". */ diff --git a/scheduler/printers.c b/scheduler/printers.c index f1cb56352..02e0a219a 100644 --- a/scheduler/printers.c +++ b/scheduler/printers.c @@ -1,5 +1,5 @@ /* - * "$Id: printers.c 5724 2006-07-12 19:42:35Z mike $" + * "$Id: printers.c 5828 2006-08-15 21:21:45Z mike $" * * Printer routines for the Common UNIX Printing System (CUPS). * @@ -1492,7 +1492,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ else snprintf(resource, sizeof(resource), "/printers/%s", p->name); - if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL) + if ((auth = cupsdFindBest(resource, HTTP_POST)) == NULL || + auth->type == AUTH_NONE) auth = cupsdFindPolicyOp(p->op_policy_ptr, IPP_PRINT_JOB); if (auth) @@ -1572,7 +1573,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ printer_type = p->type; - p->raw = 0; + p->raw = 0; + p->remote = 0; if (p->type & CUPS_PRINTER_REMOTE) { @@ -1590,7 +1592,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri", NULL, p->uri); - p->raw = 1; + p->raw = 1; + p->remote = 1; } else { @@ -2030,7 +2033,8 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */ * Print all files directly... */ - p->raw = 1; + p->raw = 1; + p->remote = 1; } else { @@ -3312,5 +3316,5 @@ write_irix_state(cupsd_printer_t *p) /* I - Printer to update */ /* - * End of "$Id: printers.c 5724 2006-07-12 19:42:35Z mike $". + * End of "$Id: printers.c 5828 2006-08-15 21:21:45Z mike $". */ diff --git a/scheduler/printers.h b/scheduler/printers.h index ef8b34709..acbc73800 100644 --- a/scheduler/printers.h +++ b/scheduler/printers.h @@ -1,5 +1,5 @@ /* - * "$Id: printers.h 5330 2006-03-23 21:07:20Z mike $" + * "$Id: printers.h 5828 2006-08-15 21:21:45Z mike $" * * Printer definitions for the Common UNIX Printing System (CUPS) scheduler. * @@ -66,6 +66,7 @@ typedef struct cupsd_printer_s char *device_uri; /* Device URI */ char *port_monitor; /* Port monitor */ int raw; /* Raw queue? */ + int remote; /* Remote queue? */ mime_type_t *filetype; /* Pseudo-filetype for printer */ cups_array_t *filetypes; /* Supported file types */ void *job; /* Current job in queue */ @@ -146,5 +147,5 @@ extern char *cupsdSanitizeURI(const char *uri, char *buffer, /* - * End of "$Id: printers.h 5330 2006-03-23 21:07:20Z mike $". + * End of "$Id: printers.h 5828 2006-08-15 21:21:45Z mike $". */ diff --git a/scheduler/statbuf.c b/scheduler/statbuf.c index eb257d787..b10f63ebc 100644 --- a/scheduler/statbuf.c +++ b/scheduler/statbuf.c @@ -1,5 +1,5 @@ /* - * "$Id: statbuf.c 5447 2006-04-21 20:07:51Z mike $" + * "$Id: statbuf.c 5889 2006-08-24 21:44:35Z mike $" * * Status buffer routines for the Common UNIX Printing System (CUPS) * scheduler. @@ -193,7 +193,7 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb, /* I - Status buffer */ lineptr = NULL; } - if (lineptr == NULL) + if (!lineptr) { /* * End of file... @@ -330,5 +330,5 @@ cupsdStatBufUpdate(cupsd_statbuf_t *sb, /* I - Status buffer */ /* - * End of "$Id: statbuf.c 5447 2006-04-21 20:07:51Z mike $". + * End of "$Id: statbuf.c 5889 2006-08-24 21:44:35Z mike $". */ diff --git a/scheduler/subscriptions.c b/scheduler/subscriptions.c index f27c48ff4..f3a320594 100644 --- a/scheduler/subscriptions.c +++ b/scheduler/subscriptions.c @@ -1,5 +1,5 @@ /* - * "$Id: subscriptions.c 5716 2006-07-11 17:56:57Z mike $" + * "$Id: subscriptions.c 5878 2006-08-24 15:55:42Z mike $" * * Subscription routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -267,7 +267,7 @@ cupsdAddEvent( "job-stopped"); break; - case IPP_JOB_CANCELLED : + case IPP_JOB_CANCELED : ippAddString(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_KEYWORD, "job-state-reasons", NULL, "job-canceled-by-user"); @@ -1245,13 +1245,12 @@ cupsdStopAllNotifiers(void) void cupsdUpdateNotifierStatus(void) { - char *ptr, /* Pointer to end of line in buffer */ - message[1024]; /* Pointer to message text */ + char message[1024]; /* Pointer to message text */ int loglevel; /* Log level for message */ - while ((ptr = cupsdStatBufUpdate(NotifierStatusBuffer, &loglevel, - message, sizeof(message))) != NULL) + while (cupsdStatBufUpdate(NotifierStatusBuffer, &loglevel, + message, sizeof(message))) if (!strchr(NotifierStatusBuffer->buffer, '\n')) break; } @@ -1506,7 +1505,6 @@ cupsd_start_notifier( { int pid; /* Notifier process ID */ int fds[2]; /* Pipe file descriptors */ - int envc; /* Number of environment variables */ char *argv[4], /* Command-line arguments */ *envp[MAX_ENV], /* Environment variables */ user_data[128], /* Base-64 encoded user data */ @@ -1546,7 +1544,7 @@ cupsd_start_notifier( * Setup the environment... */ - envc = cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0]))); + cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0]))); /* * Create pipes as needed... @@ -1624,5 +1622,5 @@ cupsd_start_notifier( /* - * End of "$Id: subscriptions.c 5716 2006-07-11 17:56:57Z mike $". + * End of "$Id: subscriptions.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/scheduler/sysman.c b/scheduler/sysman.c index f83319853..853ff86c8 100644 --- a/scheduler/sysman.c +++ b/scheduler/sysman.c @@ -1,5 +1,5 @@ /* - * "$Id: sysman.c 5305 2006-03-18 03:05:12Z mike $" + * "$Id: sysman.c 5833 2006-08-16 20:05:58Z mike $" * * System management definitions for the Common UNIX Printing System (CUPS). * @@ -289,7 +289,7 @@ cupsdUpdateSystemMonitor(void) Sleeping = 1; - cupsdStopAllJobs(); + cupsdStopAllJobs(0); cupsdSaveAllJobs(); for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); @@ -350,6 +350,7 @@ cupsdUpdateSystemMonitor(void) p->browse_time = 0; cupsdSendBrowseList(); + cupsdRestartPolling(); } else cupsdLogMessage(CUPSD_LOG_DEBUG, @@ -727,5 +728,5 @@ sysEventTimerNotifier( /* - * End of "$Id: sysman.c 5305 2006-03-18 03:05:12Z mike $". + * End of "$Id: sysman.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/scheduler/testlpd.c b/scheduler/testlpd.c new file mode 100644 index 000000000..a49950391 --- /dev/null +++ b/scheduler/testlpd.c @@ -0,0 +1,550 @@ +/* + * "$Id: testlpd.c 5868 2006-08-23 19:39:39Z mike $" + * + * cups-lpd test program for the Common UNIX Printing System (CUPS). + * + * Copyright 2006 by Easy Software Products, all rights reserved. + * + * These coded instructions, statements, and computer programs are the + * property of Easy Software Products and are protected by Federal + * copyright law. Distribution and use rights are outlined in the file + * "LICENSE.txt" which should have been included with this file. If this + * file is missing or damaged please contact Easy Software Products + * at: + * + * Attn: CUPS Licensing Information + * Easy Software Products + * 44141 Airport View Drive, Suite 204 + * Hollywood, Maryland 20636 USA + * + * Voice: (301) 373-9600 + * EMail: cups-info@cups.org + * WWW: http://www.cups.org + * + * Contents: + * + * main() - Simulate an LPD client. + * do_command() - Send the LPD command and wait for a response. + * print_job() - Submit a file for printing. + * print_waiting() - Print waiting jobs. + * remove_job() - Cancel a print job. + * status_long() - Show the long printer status. + * status_short() - Show the short printer status. + * usage() - Show program usage... + */ + +/* + * Include necessary headers... + */ + +#include +#include +#include +#include +#include +#include +#include +#include + + +/* + * Local functions... + */ + +static int do_command(int outfd, int infd, const char *command); +static int print_job(int outfd, int infd, char *dest, char **args); +static int print_waiting(int outfd, int infd, char *dest); +static int remove_job(int outfd, int infd, char *dest, char **args); +static int status_long(int outfd, int infd, char *dest, char **args); +static int status_short(int outfd, int infd, char *dest, char **args); +static void usage(void); + + +/* + * 'main()' - Simulate an LPD client. + */ + +int /* O - Exit status */ +main(int argc, /* I - Number of command-line arguments */ + char *argv[]) /* I - Command-line arguments */ +{ + int i; /* Looping var */ + int status; /* Test status */ + char *op, /* Operation to test */ + **opargs, /* Remaining arguments */ + *dest; /* Destination */ + int cupslpd_argc; /* Argument count for cups-lpd */ + char *cupslpd_argv[1000]; /* Arguments for cups-lpd */ + int cupslpd_stdin[2], /* Standard input for cups-lpd */ + cupslpd_stdout[2], /* Standard output for cups-lpd */ + cupslpd_pid; /* Process ID for cups-lpd */ + + + /* + * Collect command-line arguments... + */ + + op = NULL; + opargs = NULL; + dest = NULL; + cupslpd_argc = 1; + cupslpd_argv[0] = (char *)"cups-lpd"; + + for (i = 1; i < argc; i ++) + if (!strncmp(argv[i], "-o", 2)) + { + cupslpd_argv[cupslpd_argc++] = argv[i]; + + if (argv[i][2]) + { + i ++; + + if (i >= argc) + usage(); + + cupslpd_argv[cupslpd_argc++] = argv[i]; + } + } + else if (argv[i][0] == '-') + usage(); + else if (!op) + op = argv[i]; + else if (!dest) + dest = argv[i]; + else + { + opargs = argv + i; + break; + } + + if (!op || + (!strcmp(op, "print-job") && (!dest || !opargs)) || + (!strcmp(op, "remove-job") && (!dest || !opargs)) || + (strcmp(op, "print-job") && strcmp(op, "print-waiting") && + strcmp(op, "remove-job") && strcmp(op, "status-long") && + strcmp(op, "status-short"))) + usage(); + + /* + * Run the cups-lpd program using pipes... + */ + + cupslpd_argv[cupslpd_argc] = NULL; + + pipe(cupslpd_stdin); + pipe(cupslpd_stdout); + + if ((cupslpd_pid = fork()) < 0) + { + /* + * Error! + */ + + perror("testlpd: Unable to fork"); + return (1); + } + else if (cupslpd_pid == 0) + { + /* + * Child goes here... + */ + + close(0); + dup(cupslpd_stdin[0]); + close(cupslpd_stdin[0]); + close(cupslpd_stdin[1]); + + close(1); + dup(cupslpd_stdout[1]); + close(cupslpd_stdout[0]); + close(cupslpd_stdout[1]); + + execv("./cups-lpd", cupslpd_argv); + + perror("testlpd: Unable to exec ./cups-lpd"); + exit(errno); + } + else + { + close(cupslpd_stdin[0]); + close(cupslpd_stdout[1]); + } + + /* + * Do the operation test... + */ + + if (!strcmp(op, "print-job")) + status = print_job(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + else if (!strcmp(op, "print-waiting")) + status = print_waiting(cupslpd_stdin[1], cupslpd_stdout[0], dest); + else if (!strcmp(op, "remove-job")) + status = remove_job(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + else if (!strcmp(op, "status-long")) + status = status_long(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + else if (!strcmp(op, "status-short")) + status = status_short(cupslpd_stdin[1], cupslpd_stdout[0], dest, opargs); + + /* + * Kill the test program... + */ + + close(cupslpd_stdin[1]); + close(cupslpd_stdout[0]); + kill(cupslpd_pid, SIGTERM); + + /* + * Return the test status... + */ + + return (status); +} + + +/* + * 'do_command()' - Send the LPD command and wait for a response. + */ + +static int /* O - Status from cups-lpd */ +do_command(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + const char *command) /* I - Command line to send */ +{ + int len; /* Length of command line */ + char status; /* Status byte */ + + + printf("COMMAND: %02X %s", command[0], command + 1); + + len = strlen(command); + + if (write(outfd, command, len) < len) + { + puts(" Write failed!"); + return (-1); + } + + if (read(infd, &status, 1) < 1) + puts("IN: ERROR"); + else + printf("IN: %d\n", status); + + return (status); +} + + +/* + * 'print_job()' - Submit a file for printing. + */ + +static int /* O - Status from cups-lpd */ +print_job(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + int fd; /* Print file descriptor */ + char command[1024], /* Command buffer */ + control[1024], /* Control file */ + buffer[8192]; /* Print buffer */ + int status; /* Status of command */ + struct stat fileinfo; /* File information */ + char *jobname; /* Job name */ + int sequence; /* Sequence number */ + int bytes; /* Bytes read/written */ + + + /* + * Check the print file... + */ + + if (stat(args[0], &fileinfo)) + { + perror(args[0]); + return (-1); + } + + if ((fd = open(args[0], O_RDONLY)) < 0) + { + perror(args[0]); + return (-1); + } + + /* + * Send the "receive print job" command... + */ + + snprintf(command, sizeof(command), "\002%s\n", dest); + if ((status = do_command(outfd, infd, command)) != 0) + { + close(fd); + return (status); + } + + /* + * Format a control file string that will be used to submit the job... + */ + + if ((jobname = strrchr(args[0], '/')) != NULL) + jobname ++; + else + jobname = args[0]; + + sequence = (int)getpid() % 1000; + + snprintf(control, sizeof(control), + "Hlocalhost\n" + "P%s\n" + "J%s\n" + "ldfA%03.3dlocalhost\n" + "UdfA%03.3dlocalhost\n" + "N%s\n", + cupsUser(), jobname, sequence, sequence, jobname); + + /* + * Send the control file... + */ + + bytes = strlen(control); + + snprintf(command, sizeof(command), "\002%d cfA%03.3dlocalhost\n", + bytes, sequence); + + if ((status = do_command(outfd, infd, command)) != 0) + { + close(fd); + return (status); + } + + bytes ++; + + if (write(outfd, control, bytes) < bytes) + { + printf("CONTROL: Unable to write %d bytes!\n", bytes); + close(fd); + return (-1); + } + + printf("CONTROL: Wrote %d bytes.\n", bytes); + + if (read(infd, command, 1) < 1) + { + puts("IN: ERROR"); + close(fd); + return (-1); + } + else + { + status = command[0]; + + printf("IN: %d\n", status); + } + + /* + * Send the data file... + */ + + snprintf(command, sizeof(command), "\003%d dfA%03.3dlocalhost\n", + (int)fileinfo.st_size, sequence); + + if ((status = do_command(outfd, infd, command)) != 0) + { + close(fd); + return (status); + } + + while ((bytes = read(fd, buffer, sizeof(buffer))) > 0) + { + if (write(outfd, buffer, bytes) < bytes) + { + printf("DATA: Unable to write %d bytes!\n", bytes); + close(fd); + return (-1); + } + } + + write(outfd, "", 1); + + close(fd); + + printf("DATA: Wrote %d bytes.\n", (int)fileinfo.st_size); + + if (read(infd, command, 1) < 1) + { + puts("IN: ERROR"); + close(fd); + return (-1); + } + else + { + status = command[0]; + + printf("IN: %d\n", status); + } + + return (status); +} + + +/* + * 'print_waiting()' - Print waiting jobs. + */ + +static int /* O - Status from cups-lpd */ +print_waiting(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest) /* I - Destination */ +{ + char command[1024]; /* Command buffer */ + + + /* + * Send the "print waiting jobs" command... + */ + + snprintf(command, sizeof(command), "\001%s\n", dest); + + return (do_command(outfd, infd, command)); +} + + +/* + * 'remove_job()' - Cancel a print job. + */ + +static int /* O - Status from cups-lpd */ +remove_job(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + int i; /* Looping var */ + char command[1024]; /* Command buffer */ + + /* + * Send the "remove jobs" command... + */ + + snprintf(command, sizeof(command), "\005%s", dest); + + for (i = 0; args[i]; i ++) + { + strlcat(command, " ", sizeof(command)); + strlcat(command, args[i], sizeof(command)); + } + + strlcat(command, "\n", sizeof(command)); + + return (do_command(outfd, infd, command)); +} + + +/* + * 'status_long()' - Show the long printer status. + */ + +static int /* O - Status from cups-lpd */ +status_long(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + char command[1024], /* Command buffer */ + buffer[8192]; /* Status buffer */ + int bytes; /* Bytes read/written */ + + + /* + * Send the "send short status" command... + */ + + if (args) + snprintf(command, sizeof(command), "\004%s %s\n", dest, args[0]); + else + snprintf(command, sizeof(command), "\004%s\n", dest); + + bytes = strlen(command); + + if (write(outfd, command, bytes) < bytes) + return (-1); + + /* + * Read the status back... + */ + + while ((bytes = read(infd, buffer, sizeof(buffer))) > 0) + { + fwrite(buffer, 1, bytes, stdout); + fflush(stdout); + } + + return (0); +} + + +/* + * 'status_short()' - Show the short printer status. + */ + +static int /* O - Status from cups-lpd */ +status_short(int outfd, /* I - Command file descriptor */ + int infd, /* I - Response file descriptor */ + char *dest, /* I - Destination */ + char **args) /* I - Arguments */ +{ + char command[1024], /* Command buffer */ + buffer[8192]; /* Status buffer */ + int bytes; /* Bytes read/written */ + + + /* + * Send the "send short status" command... + */ + + if (args) + snprintf(command, sizeof(command), "\003%s %s\n", dest, args[0]); + else + snprintf(command, sizeof(command), "\003%s\n", dest); + + bytes = strlen(command); + + if (write(outfd, command, bytes) < bytes) + return (-1); + + /* + * Read the status back... + */ + + while ((bytes = read(infd, buffer, sizeof(buffer))) > 0) + { + fwrite(buffer, 1, bytes, stdout); + fflush(stdout); + } + + return (0); +} + + +/* + * 'usage()' - Show program usage... + */ + +static void +usage(void) +{ + puts("Usage: testlpd [options] print-job printer user filename [... filename]"); + puts(" testlpd [options] print-waiting [printer or user]"); + puts(" testlpd [options] remove-job printer [user [job-id]]"); + puts(" testlpd [options] status-long [printer or user]"); + puts(" testlpd [options] status-short [printer or user]"); + puts(""); + puts("Options:"); + puts(" -o name=value"); + + exit(0); +} + + +/* + * End of "$Id: testlpd.c 5868 2006-08-23 19:39:39Z mike $". + */ diff --git a/systemv/accept.c b/systemv/accept.c index 14f7201d4..5757a39a8 100644 --- a/systemv/accept.c +++ b/systemv/accept.c @@ -1,5 +1,5 @@ /* - * "$Id: accept.c 5104 2006-02-15 03:21:04Z mike $" + * "$Id: accept.c 5833 2006-08-16 20:05:58Z mike $" * * "accept", "disable", "enable", and "reject" commands for the Common * UNIX Printing System (CUPS). @@ -58,6 +58,8 @@ main(int argc, /* I - Number of command-line arguments */ int cancel; /* Cancel jobs? */ + _cupsSetLocale(); + /* * See what operation we're supposed to do... */ @@ -286,5 +288,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: accept.c 5104 2006-02-15 03:21:04Z mike $". + * End of "$Id: accept.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/cancel.c b/systemv/cancel.c index f6d4aed0a..2d1a18d1c 100644 --- a/systemv/cancel.c +++ b/systemv/cancel.c @@ -1,5 +1,5 @@ /* - * "$Id: cancel.c 5696 2006-06-26 18:34:20Z mike $" + * "$Id: cancel.c 5833 2006-08-16 20:05:58Z mike $" * * "cancel" command for the Common UNIX Printing System (CUPS). * @@ -60,6 +60,8 @@ main(int argc, /* I - Number of command-line arguments */ ipp_op_t op; /* Operation */ + _cupsSetLocale(); + /* * Setup to cancel individual print jobs... */ @@ -390,5 +392,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: cancel.c 5696 2006-06-26 18:34:20Z mike $". + * End of "$Id: cancel.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/cupsaddsmb.c b/systemv/cupsaddsmb.c index 0c74fbff0..69d80ae51 100644 --- a/systemv/cupsaddsmb.c +++ b/systemv/cupsaddsmb.c @@ -1,5 +1,5 @@ /* - * "$Id: cupsaddsmb.c 5753 2006-07-18 19:53:24Z mike $" + * "$Id: cupsaddsmb.c 5833 2006-08-16 20:05:58Z mike $" * * "cupsaddsmb" command for the Common UNIX Printing System (CUPS). * @@ -78,6 +78,8 @@ main(int argc, /* I - Number of command-line arguments */ cups_dest_t *dests; /* Printers */ + _cupsSetLocale(); + /* * Parse command-line arguments... */ @@ -292,5 +294,5 @@ usage(void) /* - * End of "$Id: cupsaddsmb.c 5753 2006-07-18 19:53:24Z mike $". + * End of "$Id: cupsaddsmb.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/cupstestdsc.c b/systemv/cupstestdsc.c index b9d5ac2d3..8ed11f9b2 100644 --- a/systemv/cupstestdsc.c +++ b/systemv/cupstestdsc.c @@ -1,5 +1,5 @@ /* - * "$Id: cupstestdsc.c 5392 2006-04-14 17:50:39Z mike $" + * "$Id: cupstestdsc.c 5838 2006-08-17 14:41:42Z mike $" * * DSC test program for the Common UNIX Printing System (CUPS). * @@ -65,6 +65,8 @@ main(int argc, /* I - Number of command-line args */ int num_files; /* Number of files tested */ + _cupsSetLocale(); + /* * Collect command-line arguments... */ @@ -129,7 +131,6 @@ check_file(const char *filename) /* I - File to read from */ saw_end_setup, /* %%EndSetup seen? */ saw_page, /* %%Page seen? */ saw_trailer, /* %%Trailer seen? */ - saw_eof, /* %%EOF seen? */ saw_long_line; /* Saw long lines? */ @@ -162,7 +163,6 @@ check_file(const char *filename) /* I - File to read from */ saw_end_comments = 0; saw_end_prolog = 0; saw_end_setup = 0; - saw_eof = 0; saw_long_line = 0; saw_page = 0; saw_pages = 0; @@ -452,5 +452,5 @@ usage(void) /* - * End of "$Id: cupstestdsc.c 5392 2006-04-14 17:50:39Z mike $". + * End of "$Id: cupstestdsc.c 5838 2006-08-17 14:41:42Z mike $". */ diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 20c3c0a34..35235f337 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -1,5 +1,5 @@ /* - * "$Id: cupstestppd.c 5549 2006-05-19 19:39:28Z mike $" + * "$Id: cupstestppd.c 5833 2006-08-16 20:05:58Z mike $" * * PPD test program for the Common UNIX Printing System (CUPS). * @@ -113,6 +113,8 @@ main(int argc, /* I - Number of command-line arguments */ "JCL", "PAGE", "PROLOG" }; + _cupsSetLocale(); + /* * Display PPD files for each file listed on the command-line... */ @@ -306,9 +308,9 @@ main(int argc, /* I - Number of command-line arguments */ * Look for default keywords with no matching option... */ - for (i = 0; i < ppd->num_attrs; i ++) + for (j = 0; j < ppd->num_attrs; j ++) { - attr = ppd->attrs[i]; + attr = ppd->attrs[j]; if (!strcmp(attr->name, "DefaultColorSpace") || !strcmp(attr->name, "DefaultFont") || @@ -327,11 +329,11 @@ main(int argc, /* I - Number of command-line arguments */ * Check that the default option value matches a choice... */ - for (j = 0; j < option->num_choices; j ++) - if (!strcmp(option->choices[j].choice, attr->value)) + for (k = 0; k < option->num_choices; k ++) + if (!strcmp(option->choices[k].choice, attr->value)) break; - if (j >= option->num_choices) + if (k >= option->num_choices) { if (verbose >= 0) { @@ -1010,7 +1012,10 @@ main(int argc, /* I - Number of command-line arguments */ char *languages, /* Copy of attribute value */ *langstart, /* Start of current language */ *langptr, /* Pointer into languages */ - keyword[PPD_MAX_NAME]; /* Localization keyword */ + keyword[PPD_MAX_NAME], /* Localization keyword */ + ckeyword[PPD_MAX_NAME]; /* Custom option keyword */ + ppd_coption_t *coption; /* Custom option */ + ppd_cparam_t *cparam; /* Custom parameter */ languages = strdup(attr->value); @@ -1104,7 +1109,61 @@ main(int argc, /* I - Number of command-line arguments */ option->keyword); for (j = 0; j < option->num_choices; j ++) { - if (!ppdFindAttr(ppd, keyword, option->choices[j].choice)) + if (!strcasecmp(option->choices[j].choice, "Custom") && + (coption = ppdFindCustomOption(ppd, + option->keyword)) != NULL) + { + snprintf(ckeyword, sizeof(ckeyword), "%s.Custom%s", + langstart, option->keyword); + + if (!ppdFindAttr(ppd, ckeyword, "True")) + { + if (verbose >= 0) + { + if (!errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + _cupsLangPrintf(stdout, + _(" **FAIL** Missing \"%s\" " + "translation string for option %s, " + "choice %s!\n"), + langstart, ckeyword + 1 + strlen(langstart), + "True"); + } + + errors ++; + } + + if (strcasecmp(option->keyword, "PageSize")) + { + for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params); + cparam; + cparam = (ppd_cparam_t *)cupsArrayNext(coption->params)) + { + snprintf(ckeyword, sizeof(ckeyword), "%s.ParamCustom%s", + langstart, option->keyword); + if (!ppdFindAttr(ppd, ckeyword, cparam->name)) + { + if (verbose >= 0) + { + if (!errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + _cupsLangPrintf(stdout, + _(" **FAIL** Missing \"%s\" " + "translation string for option %s, " + "choice %s!\n"), + langstart, + ckeyword + 1 + strlen(langstart), + cparam->name); + } + + errors ++; + } + } + } + } + else if (!ppdFindAttr(ppd, keyword, option->choices[j].choice)) { if (verbose >= 0) { @@ -1184,9 +1243,10 @@ main(int argc, /* I - Number of command-line arguments */ if (!errors && !verbose) _cupsLangPuts(stdout, _(" FAIL\n")); - _cupsLangPuts(stdout, - _(" **FAIL** 1284DeviceId must be 1284DeviceID!\n" - " REF: Page 72, section 5.5\n")); + _cupsLangPrintf(stdout, + _(" **FAIL** %s must be 1284DeviceID!\n" + " REF: Page 72, section 5.5\n"), + attr->name); } errors ++; @@ -1205,9 +1265,9 @@ main(int argc, /* I - Number of command-line arguments */ * Look for default keywords with no corresponding option... */ - for (i = 0; i < ppd->num_attrs; i ++) + for (j = 0; j < ppd->num_attrs; j ++) { - attr = ppd->attrs[i]; + attr = ppd->attrs[j]; if (!strcmp(attr->name, "DefaultColorSpace") || !strcmp(attr->name, "DefaultColorSep") || @@ -1730,5 +1790,5 @@ usage(void) /* - * End of "$Id: cupstestppd.c 5549 2006-05-19 19:39:28Z mike $". + * End of "$Id: cupstestppd.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/lp.c b/systemv/lp.c index ee2ac802b..8a38c67bf 100644 --- a/systemv/lp.c +++ b/systemv/lp.c @@ -1,5 +1,5 @@ /* - * "$Id: lp.c 5235 2006-03-06 13:02:23Z mike $" + * "$Id: lp.c 5833 2006-08-16 20:05:58Z mike $" * * "lp" command for the Common UNIX Printing System (CUPS). * @@ -117,6 +117,8 @@ main(int argc, /* I - Number of command-line arguments */ return (0); #endif /* __sun */ + _cupsSetLocale(); + silent = 0; printer = NULL; num_dests = 0; @@ -838,5 +840,5 @@ sighandler(int s) /* I - Signal number */ /* - * End of "$Id: lp.c 5235 2006-03-06 13:02:23Z mike $". + * End of "$Id: lp.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/lpadmin.c b/systemv/lpadmin.c index c0467fa76..b8e1c69ca 100644 --- a/systemv/lpadmin.c +++ b/systemv/lpadmin.c @@ -1,5 +1,5 @@ /* - * "$Id: lpadmin.c 5545 2006-05-18 21:00:56Z mike $" + * "$Id: lpadmin.c 5833 2006-08-16 20:05:58Z mike $" * * "lpadmin" command for the Common UNIX Printing System (CUPS). * @@ -92,6 +92,8 @@ main(int argc, /* I - Number of command-line arguments */ cups_option_t *options; /* Options */ + _cupsSetLocale(); + http = NULL; printer = NULL; num_options = 0; @@ -1984,5 +1986,5 @@ validate_name(const char *name) /* I - Name to check */ /* - * End of "$Id: lpadmin.c 5545 2006-05-18 21:00:56Z mike $". + * End of "$Id: lpadmin.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/lpinfo.c b/systemv/lpinfo.c index df8bef1aa..aad4b252d 100644 --- a/systemv/lpinfo.c +++ b/systemv/lpinfo.c @@ -1,5 +1,5 @@ /* - * "$Id: lpinfo.c 4925 2006-01-13 02:52:47Z mike $" + * "$Id: lpinfo.c 5833 2006-08-16 20:05:58Z mike $" * * "lpinfo" command for the Common UNIX Printing System (CUPS). * @@ -62,6 +62,8 @@ main(int argc, /* I - Number of command-line arguments */ int long_status; /* Long listing? */ + _cupsSetLocale(); + http = NULL; long_status = 0; @@ -434,5 +436,5 @@ show_models(http_t *http, /* I - HTTP connection to server */ /* - * End of "$Id: lpinfo.c 4925 2006-01-13 02:52:47Z mike $". + * End of "$Id: lpinfo.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/lpmove.c b/systemv/lpmove.c index 8f9fdefbf..135343869 100644 --- a/systemv/lpmove.c +++ b/systemv/lpmove.c @@ -1,5 +1,5 @@ /* - * "$Id: lpmove.c 5023 2006-01-29 14:39:44Z mike $" + * "$Id: lpmove.c 5833 2006-08-16 20:05:58Z mike $" * * "lpmove" command for the Common UNIX Printing System (CUPS). * @@ -66,6 +66,8 @@ main(int argc, /* I - Number of command-line arguments */ *dest; /* New destination */ + _cupsSetLocale(); + dest = NULL; dests = NULL; http = NULL; @@ -233,5 +235,5 @@ move_job(http_t *http, /* I - HTTP connection to server */ /* - * End of "$Id: lpmove.c 5023 2006-01-29 14:39:44Z mike $". + * End of "$Id: lpmove.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/lpoptions.c b/systemv/lpoptions.c index 30d57aa48..155fcb242 100644 --- a/systemv/lpoptions.c +++ b/systemv/lpoptions.c @@ -1,5 +1,5 @@ /* - * "$Id: lpoptions.c 5753 2006-07-18 19:53:24Z mike $" + * "$Id: lpoptions.c 5833 2006-08-16 20:05:58Z mike $" * * Printer option program for the Common UNIX Printing System (CUPS). * @@ -69,6 +69,8 @@ main(int argc, /* I - Number of command-line arguments */ *option; /* Current option */ + _cupsSetLocale(); + /* * Loop through the command-line arguments... */ @@ -482,5 +484,5 @@ usage(void) /* - * End of "$Id: lpoptions.c 5753 2006-07-18 19:53:24Z mike $". + * End of "$Id: lpoptions.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/lppasswd.c b/systemv/lppasswd.c index d9822a07e..f825d1e7f 100644 --- a/systemv/lppasswd.c +++ b/systemv/lppasswd.c @@ -1,5 +1,5 @@ /* - * "$Id: lppasswd.c 4924 2006-01-13 01:55:20Z mike $" + * "$Id: lppasswd.c 5833 2006-08-16 20:05:58Z mike $" * * MD5 password program for the Common UNIX Printing System (CUPS). * @@ -102,6 +102,8 @@ main(int argc, /* I - Number of command-line arguments */ #endif /* HAVE_SIGACTION && !HAVE_SIGSET*/ + _cupsSetLocale(); + /* * Check to see if stdin, stdout, and stderr are still open... */ @@ -509,5 +511,5 @@ usage(FILE *fp) /* I - File to send usage to */ /* - * End of "$Id: lppasswd.c 4924 2006-01-13 01:55:20Z mike $". + * End of "$Id: lppasswd.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/systemv/lpstat.c b/systemv/lpstat.c index eeb1cb260..4eafb58c4 100644 --- a/systemv/lpstat.c +++ b/systemv/lpstat.c @@ -1,5 +1,5 @@ /* - * "$Id: lpstat.c 5638 2006-06-06 20:08:13Z mike $" + * "$Id: lpstat.c 5833 2006-08-16 20:05:58Z mike $" * * "lpstat" command for the Common UNIX Printing System (CUPS). * @@ -84,41 +84,8 @@ main(int argc, /* I - Number of command-line arguments */ char op; /* Last operation on command-line */ - /* - * Set the locale so that times, etc. are displayed properly. - * - * Unfortunately, while we need the localized time value, we *don't* - * want to use the localized charset for the time value, so we need - * to set LC_TIME to the locale name with .UTF-8 on the end (if - * the locale includes a character set specifier...) - */ - - setlocale(LC_ALL, ""); - -#ifdef LC_TIME - { - const char *lc_time; /* Current LC_TIME value */ - char new_lc_time[255], /* New LC_TIME value */ - *charset; /* Pointer to character set */ - - if ((lc_time = setlocale(LC_TIME, NULL)) == NULL) - lc_time = setlocale(LC_ALL, NULL); + _cupsSetLocale(); - if (lc_time) - { - strlcpy(new_lc_time, lc_time, sizeof(new_lc_time)); - if ((charset = strchr(new_lc_time, '.')) == NULL) - charset = new_lc_time + strlen(new_lc_time); - - strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (charset - new_lc_time)); - } - else - strcpy(new_lc_time, "C"); - - setlocale(LC_TIME, new_lc_time); - } -#endif /* LC_TIME */ - /* * Parse command-line options... */ @@ -2281,5 +2248,5 @@ show_scheduler(http_t *http) /* I - HTTP connection to server */ /* - * End of "$Id: lpstat.c 5638 2006-06-06 20:08:13Z mike $". + * End of "$Id: lpstat.c 5833 2006-08-16 20:05:58Z mike $". */ diff --git a/templates/Makefile b/templates/Makefile index d2e4952ce..e1b5babc7 100644 --- a/templates/Makefile +++ b/templates/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 5609 2006-05-30 20:31:10Z mike $" +# "$Id: Makefile 5878 2006-08-24 15:55:42Z mike $" # # Template makefile for the Common UNIX Printing System (CUPS). # @@ -61,6 +61,7 @@ FILES = \ maintenance.tmpl \ modify-class.tmpl \ modify-printer.tmpl \ + norestart.tmpl \ option-boolean.tmpl \ option-conflict.tmpl \ option-header.tmpl \ @@ -155,5 +156,5 @@ uninstall-languages: # -# End of "$Id: Makefile 5609 2006-05-30 20:31:10Z mike $". +# End of "$Id: Makefile 5878 2006-08-24 15:55:42Z mike $". # diff --git a/templates/es/norestart.tmpl b/templates/es/norestart.tmpl new file mode 100644 index 000000000..b4cb36c4f --- /dev/null +++ b/templates/es/norestart.tmpl @@ -0,0 +1,2 @@ +

No se ha reiniciado el servidor debido a que no se han hecho +cambios en la configuración...

diff --git a/templates/job-cancel.tmpl b/templates/job-cancel.tmpl index fbdda31dd..2bc5a13d5 100644 --- a/templates/job-cancel.tmpl +++ b/templates/job-cancel.tmpl @@ -1 +1 @@ -

Job {job_id} has been cancelled. +

Job {job_id} has been canceled. diff --git a/templates/jobs.tmpl b/templates/jobs.tmpl index 08d207849..1827d77a9 100644 --- a/templates/jobs.tmpl +++ b/templates/jobs.tmpl @@ -19,7 +19,7 @@

+{job_state=7?canceled at
{time_at_completed}:{job_state=8?aborted:completed at
{time_at_completed}}}}}}} 
This template is used as the first form when modifying a printer.
norestart.tmplThis template shows "server not restarted because no + changes were made to the configuration".
option-boolean.tmpl This template is used to select a boolean PPD option.{job_media_sheets_completed=0?Unknown:{?job_media_sheets_completed}} {job_state=3?pending since
{time_at_creation}:{job_state=4?held since
{time_at_creation}: {job_state=5?processing since
{time_at_processing}:{job_state=6?stopped: -{job_state=7?cancelled at
{time_at_completed}:{job_state=8?aborted:completed at
{time_at_completed}}}}}}} 
{job_preserved>0? diff --git a/templates/norestart.tmpl b/templates/norestart.tmpl new file mode 100644 index 000000000..402e0f997 --- /dev/null +++ b/templates/norestart.tmpl @@ -0,0 +1,2 @@ +

The server was not restarted because no changes were made to +the configuration...

diff --git a/test/4.2-cups-printer-ops.test b/test/4.2-cups-printer-ops.test index 54189002f..1be448e3b 100644 --- a/test/4.2-cups-printer-ops.test +++ b/test/4.2-cups-printer-ops.test @@ -1,5 +1,5 @@ # -# "$Id: 4.2-cups-printer-ops.test 5493 2006-05-05 16:33:57Z mike $" +# "$Id: 4.2-cups-printer-ops.test 5833 2006-08-16 20:05:58Z mike $" # # Verify that the CUPS printer operations work. # @@ -105,7 +105,7 @@ ATTR name requesting-user-name $user GROUP subscription - ATTR uri notify-recipient testnotify + ATTR uri notify-recipient testnotify:// ATTR keyword notify-events printer-added,printer-modified,printer-deleted # What statuses are OK? @@ -258,5 +258,5 @@ } # -# End of "$Id: 4.2-cups-printer-ops.test 5493 2006-05-05 16:33:57Z mike $" +# End of "$Id: 4.2-cups-printer-ops.test 5833 2006-08-16 20:05:58Z mike $" # diff --git a/test/4.4-subscription-ops.test b/test/4.4-subscription-ops.test index c3098ef07..4126c11d7 100644 --- a/test/4.4-subscription-ops.test +++ b/test/4.4-subscription-ops.test @@ -1,5 +1,5 @@ # -# "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $" +# "$Id: 4.4-subscription-ops.test 5833 2006-08-16 20:05:58Z mike $" # # Verify that the CUPS subscription operations work. # @@ -18,7 +18,7 @@ ATTR uri printer-uri $method://$hostname:$port/printers/Test1 GROUP subscription - ATTR uri notify-recipient testnotify + ATTR uri notify-recipient testnotify:// ATTR keyword notify-events printer-state-changed ATTR integer notify-lease-duration 5 @@ -71,12 +71,12 @@ ATTR uri printer-uri $method://$hostname:$port/printers/Test1 GROUP subscription - ATTR uri notify-recipient testnotify + ATTR uri notify-recipient testnotify:// ATTR keyword notify-events printer-state-changed ATTR integer notify-lease-duration 5 GROUP subscription - ATTR uri notify-recipient testnotify + ATTR uri notify-recipient testnotify:// ATTR keyword notify-events printer-config-changed ATTR integer notify-lease-duration 5 @@ -118,5 +118,5 @@ } # -# End of "$Id: 4.4-subscription-ops.test 4840 2005-11-14 21:53:30Z mike $" +# End of "$Id: 4.4-subscription-ops.test 5833 2006-08-16 20:05:58Z mike $" # diff --git a/test/ipptest.c b/test/ipptest.c index 8a294e9a0..252e1dffd 100644 --- a/test/ipptest.c +++ b/test/ipptest.c @@ -1,5 +1,5 @@ /* - * "$Id: ipptest.c 5741 2006-07-17 18:36:20Z mike $" + * "$Id: ipptest.c 5878 2006-08-24 15:55:42Z mike $" * * IPP test command for the Common UNIX Printing System (CUPS). * @@ -838,7 +838,9 @@ print_attr(ipp_attribute_t *attr) /* I - Attribute to print */ return; } - printf(" %s (%s) = ", attr->name, get_tag_string(attr->value_tag)); + printf(" %s (%s%s) = ", attr->name, + attr->num_values > 1 ? "1setOf " : "", + get_tag_string(attr->value_tag)); switch (attr->value_tag) { @@ -922,5 +924,5 @@ usage(const char *option) /* I - Option string or NULL */ /* - * End of "$Id: ipptest.c 5741 2006-07-17 18:36:20Z mike $". + * End of "$Id: ipptest.c 5878 2006-08-24 15:55:42Z mike $". */ diff --git a/tools/testosx b/tools/testosx index 655853a3b..2c0715e1f 100755 --- a/tools/testosx +++ b/tools/testosx @@ -45,12 +45,15 @@ if test -x /bin/launchctl; then cat >$pkgdir/Resources/postflight <$pkgdir/Resources/postflight <