From a4d045870e17abe8840b77615c0d59f4b332ee31 Mon Sep 17 00:00:00 2001 From: jlovell Date: Sun, 29 Jan 2006 16:52:03 +0000 Subject: [PATCH] Load cups into easysw/current. git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@39 a1ca3aef-8c08-0410-bb20-df032aa958be --- Makedefs.in | 7 +- Makefile | 12 +- backend/ipp.c | 23 +- backend/lpd.c | 9 +- backend/parallel.c | 9 +- backend/scsi.c | 9 +- backend/serial.c | 9 +- backend/socket.c | 9 +- backend/usb.c | 18 +- berkeley/lpc.c | 9 +- berkeley/lpq.c | 12 +- berkeley/lprm.c | 8 +- cgi-bin/admin.c | 86 ++-- cgi-bin/classes.c | 8 +- cgi-bin/ipp-var.c | 22 +- cgi-bin/printers.c | 8 +- config-scripts/cups-defaults.m4 | 28 +- config-scripts/cups-directories.m4 | 14 +- config-scripts/cups-launchd.m4 | 53 +++ config.h.in | 13 +- configure.in | 5 +- cups/Makefile | 5 +- cups/backend.c | 67 +++ cups/backend.h | 11 +- cups/getputfile.c | 10 +- cups/http-support.c | 224 +++++---- cups/http.c | 68 ++- cups/http.h | 31 +- cups/ipp.c | 29 +- cups/ipp.h | 18 +- cups/testhttp.c | 15 +- cups/testipp.c | 16 +- cups/util.c | 40 +- doc/Makefile | 3 +- doc/cups.css | 5 + doc/help/spec-ppd.html | 200 ++++++-- init/cups.osx | 0 init/cupsd-launchd.plist | 39 ++ init/cupsd-launchd.sh | 7 + locale/translate.c | 8 +- scheduler/client.c | 13 +- scheduler/conf.c | 29 +- scheduler/conf.h | 10 +- scheduler/cups-lpd.c | 20 +- scheduler/dirsvc.c | 27 +- scheduler/dirsvc.h | 7 +- scheduler/ipp.c | 192 ++++---- scheduler/job.c | 10 +- scheduler/listen.c | 213 +++++---- scheduler/main.c | 736 ++++++++++++++++++++++++++++- scheduler/sysman.c | 16 +- systemv/accept.c | 8 +- systemv/cancel.c | 8 +- systemv/cupsaddsmb.c | 8 +- systemv/lpadmin.c | 56 +-- systemv/lpmove.c | 12 +- systemv/lpstat.c | 14 +- test/ipptest.c | 14 +- tools/testosx | 16 +- 59 files changed, 1878 insertions(+), 698 deletions(-) create mode 100644 config-scripts/cups-launchd.m4 create mode 100644 cups/backend.c mode change 100644 => 100755 init/cups.osx create mode 100644 init/cupsd-launchd.plist create mode 100755 init/cupsd-launchd.sh diff --git a/Makedefs.in b/Makedefs.in index 4c6ccb676..4bc2e371d 100644 --- a/Makedefs.in +++ b/Makedefs.in @@ -1,5 +1,5 @@ # -# "$Id: Makedefs.in 5008 2006-01-27 19:30:34Z mike $" +# "$Id: Makedefs.in 5020 2006-01-28 13:36:15Z mike $" # # Common makefile definitions for the Common UNIX Printing System (CUPS). # @@ -118,6 +118,7 @@ OPTIONS = PAMLIBS = @PAMLIBS@ SSLFLAGS = @SSLFLAGS@ SSLLIBS = @SSLLIBS@ +LAUNCHDLIBS = @LAUNCHDLIBS@ # # Directories... @@ -177,6 +178,8 @@ MAN8DIR = @MAN8DIR@ PAMDIR = $(BUILDROOT)@PAMDIR@ PAMFILE = @PAMFILE@ +DEFAULT_LAUNCHD_CONF = @DEFAULT_LAUNCHD_CONF@ + # # Rules... @@ -205,5 +208,5 @@ PAMFILE = @PAMFILE@ # -# End of "$Id: Makedefs.in 5008 2006-01-27 19:30:34Z mike $" +# End of "$Id: Makedefs.in 5020 2006-01-28 13:36:15Z mike $" # diff --git a/Makefile b/Makefile index 9cfaec9bb..99a042d5b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 5003 2006-01-27 02:33:36Z mike $" +# "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $" # # Top-level Makefile for the Common UNIX Printing System (CUPS). # @@ -29,7 +29,7 @@ include Makedefs # DIRS = cups backend berkeley cgi-bin filter locale man pdftops \ - notifier scheduler systemv + notifier scheduler systemv test # # Make all targets... @@ -107,6 +107,12 @@ install: installhdrs $(INSTALL_DATA) init/cups.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \ $(INSTALL_DIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \ $(INSTALL_DATA) init/cups.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \ + elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \ + $(INSTALL_DATA) init/cupsd-launchd.plist $(BUILDROOT)$(DEFAULT_LAUNCHD_CONF); \ + $(INSTALL_SCRIPT) init/cupsd-launchd.sh $(BUILDROOT)/System/Library/StartupItems/PrintingServices/PrintingServices; \ + $(INSTALL_DATA) init/cups.plist $(BUILDROOT)/System/Library/StartupItems/PrintingServices/StartupParameters.plist; \ + $(INSTALL_DIR) $(BUILDROOT)/System/Library/StartupItems/PrintingServices/Resources/English.lproj; \ + $(INSTALL_DATA) init/cups.strings $(BUILDROOT)/System/Library/StartupItems/PrintingServices/Resources/English.lproj/Localizable.strings; \ else \ $(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDDIR)/cups; \ fi \ @@ -165,5 +171,5 @@ tardist: epm $(EPMFLAGS) -f tardist cups packaging/cups.list # -# End of "$Id: Makefile 5003 2006-01-27 02:33:36Z mike $". +# End of "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $". # diff --git a/backend/ipp.c b/backend/ipp.c index 468f69dd2..9db806cb6 100644 --- a/backend/ipp.c +++ b/backend/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c 4926 2006-01-13 03:12:13Z mike $" + * "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $" * * IPP backend for the Common UNIX Printing System (CUPS). * @@ -209,20 +209,13 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the hostname and printer name from the URI... */ - if (getenv("DEVICE_URI") != NULL) - /* authentication information is only available in the env var */ - httpSeparateURI(getenv("DEVICE_URI"), method, sizeof(method), - username, sizeof(username), - hostname, sizeof(hostname), &port, - resource, sizeof(resource)); - else if (strchr(argv[0], ':') != NULL) - httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username), - hostname, sizeof(hostname), &port, - resource, sizeof(resource)); - else + if (httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + method, sizeof(method), username, sizeof(username), + hostname, sizeof(hostname), &port, + resource, sizeof(resource)) < HTTP_URI_OK) { - fputs("ERROR: Missing device URI on command-line and no DEVICE_URI environment variable!\n", - stderr); + fputs("ERROR: Missing device URI on command-line and no DEVICE_URI " + "environment variable!\n", stderr); return (CUPS_BACKEND_STOP); } @@ -1375,5 +1368,5 @@ sigterm_handler(int sig) /* I - Signal */ /* - * End of "$Id: ipp.c 4926 2006-01-13 03:12:13Z mike $". + * End of "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/backend/lpd.c b/backend/lpd.c index 9407fe6cf..30dea2372 100644 --- a/backend/lpd.c +++ b/backend/lpd.c @@ -1,5 +1,5 @@ /* - * "$Id: lpd.c 4991 2006-01-26 15:01:46Z mike $" + * "$Id: lpd.c 5023 2006-01-29 14:39:44Z mike $" * * Line Printer Daemon backend for the Common UNIX Printing System (CUPS). * @@ -231,8 +231,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the hostname and printer name from the URI... */ - httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username), - hostname, sizeof(hostname), &port, + httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + method, sizeof(method), username, sizeof(username), + hostname, sizeof(hostname), &port, resource, sizeof(resource)); if (!username[0]) @@ -1223,5 +1224,5 @@ sigterm_handler(int sig) /* I - Signal */ /* - * End of "$Id: lpd.c 4991 2006-01-26 15:01:46Z mike $". + * End of "$Id: lpd.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/backend/parallel.c b/backend/parallel.c index d80f8e214..d1a85a0bb 100644 --- a/backend/parallel.c +++ b/backend/parallel.c @@ -1,5 +1,5 @@ /* - * "$Id: parallel.c 4906 2006-01-10 20:53:28Z mike $" + * "$Id: parallel.c 5023 2006-01-29 14:39:44Z mike $" * * Parallel port backend for the Common UNIX Printing System (CUPS). * @@ -174,8 +174,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the device name and options from the URI... */ - httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username), - hostname, sizeof(hostname), &port, + httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + method, sizeof(method), username, sizeof(username), + hostname, sizeof(hostname), &port, resource, sizeof(resource)); /* @@ -727,5 +728,5 @@ list_devices(void) /* - * End of "$Id: parallel.c 4906 2006-01-10 20:53:28Z mike $". + * End of "$Id: parallel.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/backend/scsi.c b/backend/scsi.c index fdbc7f2f3..06a088899 100644 --- a/backend/scsi.c +++ b/backend/scsi.c @@ -1,5 +1,5 @@ /* - * "$Id: scsi.c 4906 2006-01-10 20:53:28Z mike $" + * "$Id: scsi.c 5023 2006-01-29 14:39:44Z mike $" * * SCSI printer backend for the Common UNIX Printing System (CUPS). * @@ -183,8 +183,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the device name and options from the URI... */ - httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username), - hostname, sizeof(hostname), &port, + httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + method, sizeof(method), username, sizeof(username), + hostname, sizeof(hostname), &port, resource, sizeof(resource)); /* @@ -219,5 +220,5 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* - * End of "$Id: scsi.c 4906 2006-01-10 20:53:28Z mike $". + * End of "$Id: scsi.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/backend/serial.c b/backend/serial.c index 3079eef5e..32aa2f4b8 100644 --- a/backend/serial.c +++ b/backend/serial.c @@ -1,5 +1,5 @@ /* - * "$Id: serial.c 4906 2006-01-10 20:53:28Z mike $" + * "$Id: serial.c 5023 2006-01-29 14:39:44Z mike $" * * Serial port backend for the Common UNIX Printing System (CUPS). * @@ -196,8 +196,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the device name and options from the URI... */ - httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username), - hostname, sizeof(hostname), &port, + httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + method, sizeof(method), username, sizeof(username), + hostname, sizeof(hostname), &port, resource, sizeof(resource)); /* @@ -1110,5 +1111,5 @@ list_devices(void) /* - * End of "$Id: serial.c 4906 2006-01-10 20:53:28Z mike $". + * End of "$Id: serial.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/backend/socket.c b/backend/socket.c index 240adca1f..713b21337 100644 --- a/backend/socket.c +++ b/backend/socket.c @@ -1,5 +1,5 @@ /* - * "$Id: socket.c 4974 2006-01-25 07:04:33Z mike $" + * "$Id: socket.c 5023 2006-01-29 14:39:44Z mike $" * * AppSocket backend for the Common UNIX Printing System (CUPS). * @@ -164,8 +164,9 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the hostname and port number from the URI... */ - httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username), - hostname, sizeof(hostname), &port, + httpSeparateURI(HTTP_URI_CODING_ALL, cupsBackendDeviceURI(argv), + method, sizeof(method), username, sizeof(username), + hostname, sizeof(hostname), &port, resource, sizeof(resource)); if (port == 0) @@ -487,5 +488,5 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* - * End of "$Id: socket.c 4974 2006-01-25 07:04:33Z mike $". + * End of "$Id: socket.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/backend/usb.c b/backend/usb.c index 3ffe2d0d1..92fae2edd 100644 --- a/backend/usb.c +++ b/backend/usb.c @@ -1,5 +1,5 @@ /* - * "$Id: usb.c 4906 2006-01-10 20:53:28Z mike $" + * "$Id: usb.c 5023 2006-01-29 14:39:44Z mike $" * * USB port backend for the Common UNIX Printing System (CUPS). * @@ -196,21 +196,17 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * Extract the device name and options from the URI... */ - if (strncmp(argv[0], "usb:", 4)) - uri = getenv("DEVICE_URI"); - else - uri = argv[0]; + uri = cupsBackendDeviceURI(argv); - if (!uri) + if (httpSeparateURI(HTTP_URI_CODING_ALL, uri, + method, sizeof(method), username, sizeof(username), + hostname, sizeof(hostname), &port, + resource, sizeof(resource)) < HTTP_URI_OK) { fputs("ERROR: No device URI found in argv[0] or in DEVICE_URI environment variable!\n", stderr); return (1); } - httpSeparateURI(argv[0], method, sizeof(method), username, sizeof(username), - hostname, sizeof(hostname), &port, - resource, sizeof(resource)); - /* * See if there are any options... */ @@ -269,5 +265,5 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ /* - * End of "$Id: usb.c 4906 2006-01-10 20:53:28Z mike $". + * End of "$Id: usb.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/berkeley/lpc.c b/berkeley/lpc.c index 5edbeafb7..271d60477 100644 --- a/berkeley/lpc.c +++ b/berkeley/lpc.c @@ -1,5 +1,5 @@ /* - * "$Id: lpc.c 4948 2006-01-19 03:23:41Z mike $" + * "$Id: lpc.c 5023 2006-01-29 14:39:44Z mike $" * * "lpc" command for the Common UNIX Printing System (CUPS). * @@ -444,8 +444,9 @@ show_status(http_t *http, /* I - HTTP connection to server */ "attributes-natural-language", NULL, language->language); - httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL, - "localhost", 631, "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri), + "ipp", NULL, "localhost", 631, "/printers/%s", + printer); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri); @@ -517,5 +518,5 @@ show_status(http_t *http, /* I - HTTP connection to server */ /* - * End of "$Id: lpc.c 4948 2006-01-19 03:23:41Z mike $". + * End of "$Id: lpc.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/berkeley/lpq.c b/berkeley/lpq.c index 6fd1dfc91..d1d06db1d 100644 --- a/berkeley/lpq.c +++ b/berkeley/lpq.c @@ -1,5 +1,5 @@ /* - * "$Id: lpq.c 4948 2006-01-19 03:23:41Z mike $" + * "$Id: lpq.c 5023 2006-01-29 14:39:44Z mike $" * * "lpq" command for the Common UNIX Printing System (CUPS). * @@ -368,8 +368,8 @@ show_jobs(const char *command, /* I - Command name */ } else { - httpAssembleURIf(resource, sizeof(resource), "ipp", NULL, "localhost", 0, - "/printers/%s", dest); + httpAssembleURIf(HTTP_URI_CODING_ALL, resource, sizeof(resource), "ipp", + NULL, "localhost", 0, "/printers/%s", dest); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, resource); @@ -592,8 +592,8 @@ show_printer(const char *command, /* I - Command name */ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", dest); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", dest); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -651,5 +651,5 @@ usage(void) /* - * End of "$Id: lpq.c 4948 2006-01-19 03:23:41Z mike $". + * End of "$Id: lpq.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/berkeley/lprm.c b/berkeley/lprm.c index 8497ff532..67479b5a3 100644 --- a/berkeley/lprm.c +++ b/berkeley/lprm.c @@ -1,5 +1,5 @@ /* - * "$Id: lprm.c 4948 2006-01-19 03:23:41Z mike $" + * "$Id: lprm.c 5023 2006-01-29 14:39:44Z mike $" * * "lprm" command for the Common UNIX Printing System (CUPS). * @@ -223,8 +223,8 @@ main(int argc, /* I - Number of command-line arguments */ if (dest) { - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", dest); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", dest); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", @@ -283,5 +283,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: lprm.c 4948 2006-01-19 03:23:41Z mike $". + * End of "$Id: lprm.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 01252ba5c..55ab8fd4d 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -1,5 +1,5 @@ /* - * "$Id: admin.c 4943 2006-01-18 20:30:42Z mike $" + * "$Id: admin.c 5023 2006-01-29 14:39:44Z mike $" * * Administration CGI for the Common UNIX Printing System (CUPS). * @@ -87,6 +87,15 @@ main(int argc, /* I - Number of command-line arguments */ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption()); + if (!http) + { + perror("ERROR: Unable to connect to cupsd"); + fprintf(stderr, "DEBUG: cupsServer()=\"%s\"\n", cupsServer()); + fprintf(stderr, "DEBUG: ippPort()=%d\n", ippPort()); + fprintf(stderr, "DEBUG: cupsEncryption()=%d\n", cupsEncryption()); + exit(1); + } + /* * Set the web interface section... */ @@ -303,8 +312,8 @@ do_am_class(http_t *http, /* I - HTTP connection */ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/classes/%s", name); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/classes/%s", name); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -408,8 +417,9 @@ do_am_class(http_t *http, /* I - HTTP connection */ request = ippNewRequest(CUPS_ADD_CLASS); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/classes/%s", cgiGetVariable("PRINTER_NAME")); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/classes/%s", + cgiGetVariable("PRINTER_NAME")); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -526,8 +536,9 @@ do_am_printer(http_t *http, /* I - HTTP connection */ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", cgiGetVariable("PRINTER_NAME")); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", + cgiGetVariable("PRINTER_NAME")); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -611,6 +622,8 @@ do_am_printer(http_t *http, /* I - HTTP connection */ * printer-uri */ + fputs("DEBUG: Getting list of devices...\n", stderr); + request = ippNewRequest(CUPS_GET_DEVICES); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", @@ -620,11 +633,19 @@ do_am_printer(http_t *http, /* I - HTTP connection */ * Do the request and get back a response... */ + fprintf(stderr, "DEBUG: http=%p (%s)\n", http, http->hostname); + if ((response = cupsDoRequest(http, request, "/")) != NULL) { + fputs("DEBUG: Got device list!\n", stderr); + cgiSetIPPVars(response, NULL, NULL, NULL, 0); ippDelete(response); } + else + fprintf(stderr, + "ERROR: CUPS-Get-Devices request failed with status %x: %s\n", + cupsLastError(), cupsLastErrorString()); /* * Let the user choose... @@ -705,6 +726,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */ http_status_t get_status; /* Status of GET */ + /* TODO: Use cupsGetFile() API... */ snprintf(uri, sizeof(uri), "/printers/%s.ppd", name); if (httpGet(http, uri)) @@ -719,7 +741,7 @@ do_am_printer(http_t *http, /* I - HTTP connection */ } else if ((fd = cupsTempFd(filename, sizeof(filename))) >= 0) { - while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0) + while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0) write(fd, buffer, bytes); close(fd); @@ -921,8 +943,9 @@ do_am_printer(http_t *http, /* I - HTTP connection */ request = ippNewRequest(CUPS_ADD_PRINTER); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", cgiGetVariable("PRINTER_NAME")); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", + cgiGetVariable("PRINTER_NAME")); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -1055,8 +1078,8 @@ do_config_printer(http_t *http) /* I - HTTP connection */ */ if ((printer = cgiGetVariable("PRINTER_NAME")) != NULL) - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", printer); else { cgiSetVariable("ERROR", cgiText(_("Missing form variable!"))); @@ -1220,8 +1243,8 @@ do_config_printer(http_t *http) /* I - HTTP connection */ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", printer); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -1460,8 +1483,9 @@ do_config_printer(http_t *http) /* I - HTTP connection */ request = ippNewRequest(CUPS_ADD_PRINTER); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", cgiGetVariable("PRINTER_NAME")); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", + cgiGetVariable("PRINTER_NAME")); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -2323,8 +2347,8 @@ do_delete_class(http_t *http) /* I - HTTP connection */ } if ((pclass = cgiGetVariable("PRINTER_NAME")) != NULL) - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/classes/%s", pclass); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/classes/%s", pclass); else { cgiSetVariable("ERROR", cgiText(_("Missing form variable!"))); @@ -2384,8 +2408,8 @@ do_delete_printer(http_t *http) /* I - HTTP connection */ } if ((printer = cgiGetVariable("PRINTER_NAME")) != NULL) - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", printer); else { cgiSetVariable("ERROR", cgiText(_("Missing form variable!"))); @@ -3127,8 +3151,9 @@ do_printer_op(http_t *http, /* I - HTTP connection */ request = ippNewRequest(op); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - is_class ? "/classes/%s" : "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, is_class ? "/classes/%s" : "/printers/%s", + printer); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -3236,8 +3261,9 @@ do_set_allowed_users(http_t *http) /* I - HTTP connection */ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - is_class ? "/classes/%s" : "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, is_class ? "/classes/%s" : "/printers/%s", + printer); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -3322,8 +3348,9 @@ do_set_allowed_users(http_t *http) /* I - HTTP connection */ request = ippNewRequest(is_class ? CUPS_ADD_CLASS : CUPS_ADD_PRINTER); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - is_class ? "/classes/%s" : "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, is_class ? "/classes/%s" : "/printers/%s", + printer); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -3465,8 +3492,9 @@ do_set_sharing(http_t *http) /* I - HTTP connection */ request = ippNewRequest(is_class ? CUPS_ADD_CLASS : CUPS_ADD_PRINTER); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - is_class ? "/classes/%s" : "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, is_class ? "/classes/%s" : "/printers/%s", + printer); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -3562,5 +3590,5 @@ match_string(const char *a, /* I - First string */ /* - * End of "$Id: admin.c 4943 2006-01-18 20:30:42Z mike $". + * End of "$Id: admin.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cgi-bin/classes.c b/cgi-bin/classes.c index 355928af6..fbea24199 100644 --- a/cgi-bin/classes.c +++ b/cgi-bin/classes.c @@ -1,5 +1,5 @@ /* - * "$Id: classes.c 4931 2006-01-14 20:37:40Z mike $" + * "$Id: classes.c 5023 2006-01-29 14:39:44Z mike $" * * Class status CGI for the Common UNIX Printing System (CUPS). * @@ -385,8 +385,8 @@ show_class(http_t *http, /* I - Connection to server */ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/classes/%s", pclass); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/classes/%s", pclass); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -459,5 +459,5 @@ show_class(http_t *http, /* I - Connection to server */ /* - * End of "$Id: classes.c 4931 2006-01-14 20:37:40Z mike $". + * End of "$Id: classes.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c index bc20e75d2..6a59d5c8b 100644 --- a/cgi-bin/ipp-var.c +++ b/cgi-bin/ipp-var.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp-var.c 4931 2006-01-14 20:37:40Z mike $" + * "$Id: ipp-var.c 5023 2006-01-29 14:39:44Z mike $" * * CGI <-> IPP variable routines for the Common UNIX Printing System (CUPS). * @@ -457,8 +457,9 @@ cgiMoveJobs(http_t *http, /* I - Connection to server */ snprintf(resource, sizeof(resource), "/%s/%s", cgiGetVariable("SECTION"), dest); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", ippPort(), - "/%s/%s", cgiGetVariable("SECTION"), dest); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", ippPort(), "/%s/%s", + cgiGetVariable("SECTION"), dest); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); } @@ -549,8 +550,9 @@ cgiPrintTestPage(http_t *http, /* I - Connection to server */ snprintf(resource, sizeof(resource), "/%s/%s", cgiGetVariable("SECTION"), dest); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", ippPort(), - "/%s/%s", cgiGetVariable("SECTION"), dest); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", ippPort(), "/%s/%s", cgiGetVariable("SECTION"), + dest); /* * Build an IPP_PRINT_JOB request, which requires the following @@ -672,8 +674,8 @@ cgiRewriteURL(const char *uri, /* I - Current URI */ * Convert the URI to a URL... */ - httpSeparateURI(uri, method, sizeof(method), userpass, sizeof(userpass), - hostname, sizeof(hostname), &port, + httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass, + sizeof(userpass), hostname, sizeof(hostname), &port, rawresource, sizeof(rawresource)); if (!strcmp(method, "ipp") || @@ -1090,8 +1092,8 @@ cgiShowJobs(http_t *http, /* I - Connection to server */ if (dest) { - httpAssembleURIf(url, sizeof(url), "ipp", NULL, "localhost", ippPort(), - "/printers/%s", dest); + httpAssembleURIf(HTTP_URI_CODING_ALL, url, sizeof(url), "ipp", NULL, + "localhost", ippPort(), "/printers/%s", dest); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, url); } @@ -1270,5 +1272,5 @@ cgiText(const char *message) /* I - Message */ /* - * End of "$Id: ipp-var.c 4931 2006-01-14 20:37:40Z mike $". + * End of "$Id: ipp-var.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cgi-bin/printers.c b/cgi-bin/printers.c index ddc027f51..fc0b65a9e 100644 --- a/cgi-bin/printers.c +++ b/cgi-bin/printers.c @@ -1,5 +1,5 @@ /* - * "$Id: printers.c 4931 2006-01-14 20:37:40Z mike $" + * "$Id: printers.c 5023 2006-01-29 14:39:44Z mike $" * * Printer status CGI for the Common UNIX Printing System (CUPS). * @@ -392,8 +392,8 @@ show_printer(http_t *http, /* I - Connection to server */ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); - httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", printer); + httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", printer); ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri); @@ -466,5 +466,5 @@ show_printer(http_t *http, /* I - Connection to server */ /* - * End of "$Id: printers.c 4931 2006-01-14 20:37:40Z mike $". + * End of "$Id: printers.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/config-scripts/cups-defaults.m4 b/config-scripts/cups-defaults.m4 index 26bfae8c7..6edee7473 100644 --- a/config-scripts/cups-defaults.m4 +++ b/config-scripts/cups-defaults.m4 @@ -25,17 +25,21 @@ dnl dnl Default ConfigFilePerm AC_ARG_WITH(config_perm, [ --with-config-file-perm set default ConfigFilePerm value, default=0640], - CUPS_CONFIG_FILE_PERM="$withval", - CUPS_CONFIG_FILE_PERM="0640") + CUPS_CONFIG_FILE_PERM="$withval", + if test "x$uname" = xDarwin; then + CUPS_CONFIG_FILE_PERM="644" + else + CUPS_CONFIG_FILE_PERM="640" + fi) AC_SUBST(CUPS_CONFIG_FILE_PERM) -AC_DEFINE_UNQUOTED(CUPS_DEFAULT_CONFIG_FILE_PERM, $CUPS_CONFIG_FILE_PERM) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_CONFIG_FILE_PERM, 0$CUPS_CONFIG_FILE_PERM) dnl Default LogFilePerm AC_ARG_WITH(log_perm, [ --with-log-file-perm set default LogFilePerm value, default=0644], - CUPS_LOG_FILE_PERM="$withval", - CUPS_LOG_FILE_PERM="0644") + CUPS_LOG_FILE_PERM="$withval", + CUPS_LOG_FILE_PERM="644") AC_SUBST(CUPS_LOG_FILE_PERM) -AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, $CUPS_LOG_FILE_PERM) +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LOG_FILE_PERM, 0$CUPS_LOG_FILE_PERM) dnl Default Browsing AC_ARG_ENABLE(browsing, [ --enable-browsing enable Browsing by default, default=yes]) @@ -50,19 +54,19 @@ AC_SUBST(CUPS_BROWSING) dnl Default BrowseLocalProtocols AC_ARG_WITH(browse_local, [ --with-local-protocols set default BrowseLocalProtocols, default="CUPS"], - CUPS_BROWSE_LOCAL_PROTOCOLS="$withval", - CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS") + CUPS_BROWSE_LOCAL_PROTOCOLS="$withval", + CUPS_BROWSE_LOCAL_PROTOCOLS="CUPS") AC_SUBST(CUPS_BROWSE_LOCAL_PROTOCOLS) AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_LOCAL_PROTOCOLS, - "$CUPS_BROWSE_LOCAL_PROTOCOLS") + "$CUPS_BROWSE_LOCAL_PROTOCOLS") dnl Default BrowseRemoteProtocols AC_ARG_WITH(browse_remote, [ --with-remote-protocols set default BrowseRemoteProtocols, default="CUPS"], - CUPS_BROWSE_REMOTE_PROTOCOLS="$withval", - CUPS_BROWSE_REMOTE_PROTOCOLS="CUPS") + CUPS_BROWSE_REMOTE_PROTOCOLS="$withval", + CUPS_BROWSE_REMOTE_PROTOCOLS="CUPS") AC_SUBST(CUPS_BROWSE_REMOTE_PROTOCOLS) AC_DEFINE_UNQUOTED(CUPS_DEFAULT_BROWSE_REMOTE_PROTOCOLS, - "$CUPS_BROWSE_REMOTE_PROTOCOLS") + "$CUPS_BROWSE_REMOTE_PROTOCOLS") dnl Default BrowseShortNames AC_ARG_ENABLE(browse_short, [ --enable-browse-short-names diff --git a/config-scripts/cups-directories.m4 b/config-scripts/cups-directories.m4 index 836ec6742..741874025 100644 --- a/config-scripts/cups-directories.m4 +++ b/config-scripts/cups-directories.m4 @@ -1,5 +1,5 @@ dnl -dnl "$Id: cups-directories.m4 4933 2006-01-16 00:26:57Z mike $" +dnl "$Id: cups-directories.m4 5023 2006-01-29 14:39:44Z mike $" dnl dnl Directory stuff for the Common UNIX Printing System (CUPS). dnl @@ -126,7 +126,9 @@ if test x$rcdir = x; then Darwin*) # Darwin and MacOS X... INITDIR="" - INITDDIR="/System/Library/StartupItems/PrintingServices" + AC_CHECK_PROG(INITDDIR, launchd, + "/System/Library/LaunchDaemons", + "/System/Library/StartupItems/PrintingServices") ;; Linux | GNU) @@ -177,7 +179,11 @@ dnl Setup default locations... AC_ARG_WITH(cachedir, [ --with-cachedir set path for cache files],cachedir="$withval",cachedir="") if test x$cachedir = x; then - CUPS_CACHEDIR="$localstatedir/cache/cups" + if test "x$uname" = xDarwin; then + CUPS_CACHEDIR="$localstatedir/tmp/cups" + else + CUPS_CACHEDIR="$localstatedir/cache/cups" + fi else CUPS_CACHEDIR="$cachedir" fi @@ -279,5 +285,5 @@ AC_DEFINE_UNQUOTED(CUPS_STATEDIR, "$localstatedir/run/cups") AC_SUBST(CUPS_STATEDIR) dnl -dnl End of "$Id: cups-directories.m4 4933 2006-01-16 00:26:57Z mike $". +dnl End of "$Id: cups-directories.m4 5023 2006-01-29 14:39:44Z mike $". dnl diff --git a/config-scripts/cups-launchd.m4 b/config-scripts/cups-launchd.m4 new file mode 100644 index 000000000..8e075e9bf --- /dev/null +++ b/config-scripts/cups-launchd.m4 @@ -0,0 +1,53 @@ +dnl +dnl "$Id$" +dnl +dnl launchd stuff for the Common UNIX Printing System (CUPS). +dnl +dnl Copyright 1997-2005 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 +dnl copyright law. Distribution and use rights are outlined in the file +dnl "LICENSE.txt" which should have been included with this file. If this +dnl file is missing or damaged please contact Easy Software Products +dnl at: +dnl +dnl Attn: CUPS Licensing Information +dnl Easy Software Products +dnl 44141 Airport View Drive, Suite 204 +dnl Hollywood, Maryland 20636 USA +dnl +dnl Voice: (301) 373-9600 +dnl EMail: cups-info@cups.org +dnl WWW: http://www.cups.org +dnl + + +AC_ARG_ENABLE(launchd, [ --enable-launchd turn on launchd support, default=yes]) + +DEFAULT_LAUNCHD_CONF="" +LAUNCHDLIBS="" + +if test x$enable_launchd != xno; then + AC_CHECK_FUNC(launch_msg, AC_DEFINE(HAVE_LAUNCHD)) + AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H)) + + case "$uname" in + Darwin*) + # Darwin, MacOS X + DEFAULT_LAUNCHD_CONF="/System/Library/LaunchDaemons/org.cups.cupsd.plist" + # liblaunch is already part of libSystem + ;; + *) + # All others; this test will need to be updated + ;; + esac +fi + +AC_DEFINE_UNQUOTED(CUPS_DEFAULT_LAUNCHD_CONF, "$DEFAULT_LAUNCHD_CONF") +AC_SUBST(DEFAULT_LAUNCHD_CONF) +AC_SUBST(LAUNCHDLIBS) + +dnl +dnl End of "$Id$". +dnl diff --git a/config.h.in b/config.h.in index a6f0f4904..ee1e4bc34 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,5 @@ /* - * "$Id: config.h.in 5008 2006-01-27 19:30:34Z mike $" + * "$Id: config.h.in 5020 2006-01-28 13:36:15Z mike $" * * Configuration file for the Common UNIX Printing System (CUPS). * @@ -352,6 +352,15 @@ #undef HAVE_PTHREAD_H +/* + * Do we have launchd support? + */ + +#undef HAVE_LAUNCH_H +#undef HAVE_LAUNCHD +#define CUPS_DEFAULT_LAUNCHD_CONF "" + + /* * Various scripting languages... */ @@ -403,5 +412,5 @@ #endif /* !_CUPS_CONFIG_H_ */ /* - * End of "$Id: config.h.in 5008 2006-01-27 19:30:34Z mike $". + * End of "$Id: config.h.in 5020 2006-01-28 13:36:15Z mike $". */ diff --git a/configure.in b/configure.in index 58dff5694..811d48b5f 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl -dnl "$Id: configure.in 5008 2006-01-27 19:30:34Z mike $" +dnl "$Id: configure.in 5020 2006-01-28 13:36:15Z mike $" dnl dnl Configuration script for the Common UNIX Printing System (CUPS). dnl @@ -41,6 +41,7 @@ sinclude(config-scripts/cups-ssl.m4) sinclude(config-scripts/cups-pam.m4) sinclude(config-scripts/cups-threads.m4) sinclude(config-scripts/cups-largefile.m4) +sinclude(config-scripts/cups-launchd.m4) MAKEDEFS="../Makedefs" AC_SUBST(MAKEDEFS) @@ -55,5 +56,5 @@ AC_OUTPUT(Makedefs packaging/cups.list init/cups.sh cups-config chmod +x cups-config dnl -dnl End of "$Id: configure.in 5008 2006-01-27 19:30:34Z mike $". +dnl End of "$Id: configure.in 5020 2006-01-28 13:36:15Z mike $". dnl diff --git a/cups/Makefile b/cups/Makefile index 94ff53a29..e23017bf3 100644 --- a/cups/Makefile +++ b/cups/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 5000 2006-01-26 23:38:43Z mike $" +# "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $" # # API library Makefile for the Common UNIX Printing System (CUPS). # @@ -35,6 +35,7 @@ LIBOBJS = \ attr.o \ auth.o \ backchannel.o \ + backend.o \ custom.o \ dest.o \ dir.o \ @@ -356,5 +357,5 @@ include Dependencies # -# End of "$Id: Makefile 5000 2006-01-26 23:38:43Z mike $". +# End of "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $". # diff --git a/cups/backend.c b/cups/backend.c new file mode 100644 index 000000000..68d234d12 --- /dev/null +++ b/cups/backend.c @@ -0,0 +1,67 @@ +/* + * "$Id: backend.c 5024 2006-01-29 14:58:15Z mike $" + * + * Backend functions for the Common UNIX Printing System (CUPS). + * + * Copyright 2006 by Easy Software Products. + * + * 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 + * + * This file is subject to the Apple OS-Developed Software exception. + * + * Contents: + * + * cupsBackendDeviceURI() - Get the device URI for a backend. + */ + +/* + * Include necessary headers... + */ + +#include +#include "backend.h" +#include "string.h" + + +/* + * 'cupsBackendDeviceURI()' - Get the device URI for a backend. + * + * The "argv" argument is the argv argument passed to main(). This + * function returns the device URI passed in the DEVICE_URI environment + * variable or the device URI passed in argv[0], whichever is found + * first. + */ + +const char * /* O - Device URI or NULL */ +cupsBackendDeviceURI(char **argv) /* I - Command-line arguments */ +{ + const char *device_uri; /* Device URI */ + + + if ((device_uri = getenv("DEVICE_URI")) != NULL) + return (device_uri); + + if (!argv || !argv[0] || !strchr(argv[0], ':')) + return (NULL); + else + return (argv[0]); +} + + +/* + * End of "$Id: backend.c 5024 2006-01-29 14:58:15Z mike $". + */ diff --git a/cups/backend.h b/cups/backend.h index a816b2f07..ca107c93f 100644 --- a/cups/backend.h +++ b/cups/backend.h @@ -1,5 +1,5 @@ /* - * "$Id: backend.h 4973 2006-01-25 02:36:02Z mike $" + * "$Id: backend.h 5023 2006-01-29 14:39:44Z mike $" * * Backend definitions for the Common UNIX Printing System (CUPS). * @@ -43,8 +43,15 @@ typedef enum cups_backend_e /**** Backend exit codes ****/ } cups_backend_t; +/* + * Prototypes... + */ + +extern const char *cupsBackendDeviceURI(char **argv); + + #endif /* !_CUPS_BACKEND_H_ */ /* - * End of "$Id: backend.h 4973 2006-01-25 02:36:02Z mike $". + * End of "$Id: backend.h 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/getputfile.c b/cups/getputfile.c index 82c9bdf28..da1579fa8 100644 --- a/cups/getputfile.c +++ b/cups/getputfile.c @@ -1,5 +1,5 @@ /* - * "$Id: getputfile.c 4984 2006-01-25 21:55:36Z mike $" + * "$Id: getputfile.c 5023 2006-01-29 14:39:44Z mike $" * * Get/put file functions for the Common UNIX Printing System (CUPS). * @@ -166,7 +166,7 @@ cupsGetFd(http_t *http, /* I - HTTP connection to server */ * Yes, copy the file... */ - while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0) + while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0) write(fd, buffer, bytes); } else @@ -322,11 +322,11 @@ cupsPutFd(http_t *http, /* I - HTTP connection to server */ break; } else - httpWrite(http, buffer, bytes); + httpWrite2(http, buffer, bytes); if (status == HTTP_CONTINUE) { - httpWrite(http, buffer, 0); + httpWrite2(http, buffer, 0); while ((status = httpUpdate(http)) == HTTP_CONTINUE); } @@ -447,5 +447,5 @@ cupsPutFile(http_t *http, /* I - HTTP connection to server */ /* - * End of "$Id: getputfile.c 4984 2006-01-25 21:55:36Z mike $". + * End of "$Id: getputfile.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/http-support.c b/cups/http-support.c index 0770f138a..3103007aa 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -1,5 +1,5 @@ /* - * "$Id: http-support.c 4961 2006-01-20 22:19:13Z mike $" + * "$Id: http-support.c 5023 2006-01-29 14:39:44Z mike $" * * HTTP support routines for the Common UNIX Printing System (CUPS) scheduler. * @@ -93,9 +93,11 @@ static const char * const http_months[12] = */ static const char *http_copy_decode(char *dst, const char *src, - int dstsize, const char *term); + int dstsize, const char *term, + int decode); static char *http_copy_encode(char *dst, const char *src, - char *dstend, const char *reserved); + char *dstend, const char *reserved, + const char *term, int encode); /* @@ -110,46 +112,18 @@ static char *http_copy_encode(char *dst, const char *src, */ http_uri_status_t /* O - URI status */ -httpAssembleURI(char *uri, /* I - URI buffer */ - int urilen, /* I - Size of URI buffer */ - const char *scheme, /* I - Scheme name */ - const char *username, /* I - Username */ - const char *host, /* I - Hostname or address */ - int port, /* I - Port number */ - const char *resource) /* I - Resource */ -{ - return (httpAssembleURIf(uri, urilen, scheme, username, host, port, "%s", - resource)); -} - - -/* - * 'httpAssembleURIf()' - Assemble a uniform resource identifier from its - * components with a formatted resource. - * - * This function creates a formatted version of the resource string - * argument "resourcef" and properly escapes all reserved characters - * in a URI. You should use this function in place of traditional - * string functions whenever you need to create a URI string. - * - * @since CUPS 1.2@ - */ - -http_uri_status_t /* O - URI status */ -httpAssembleURIf(char *uri, /* I - URI buffer */ - int urilen, /* I - Size of URI buffer */ - const char *scheme, /* I - Scheme name */ - const char *username, /* I - Username */ - const char *host, /* I - Hostname or address */ - int port, /* I - Port number */ - const char *resourcef, /* I - Printf-style resource */ - ...) /* I - Additional arguments as needed */ +httpAssembleURI( + http_uri_coding_t encoding, /* I - Encoding flags */ + char *uri, /* I - URI buffer */ + int urilen, /* I - Size of URI buffer */ + const char *scheme, /* I - Scheme name */ + const char *username, /* I - Username */ + const char *host, /* I - Hostname or address */ + int port, /* I - Port number */ + const char *resource) /* I - Resource */ { char *ptr, /* Pointer into URI buffer */ *end; /* End of URI buffer */ - va_list ap; /* Pointer to additional arguments */ - char resource[1024]; /* Formatted resource string */ - int bytes; /* Bytes in formatted string */ /* @@ -169,7 +143,7 @@ httpAssembleURIf(char *uri, /* I - URI buffer */ */ end = uri + urilen - 1; - ptr = http_copy_encode(uri, scheme, end, NULL); + ptr = http_copy_encode(uri, scheme, end, NULL, NULL, 0); if (!ptr) goto assemble_overflow; @@ -213,7 +187,8 @@ httpAssembleURIf(char *uri, /* I - URI buffer */ * Add username@ first... */ - ptr = http_copy_encode(ptr, username, end, "/?@"); + ptr = http_copy_encode(ptr, username, end, "/?@", NULL, + encoding & HTTP_URI_CODING_USERNAME); if (!ptr) goto assemble_overflow; @@ -294,7 +269,8 @@ httpAssembleURIf(char *uri, /* I - URI buffer */ * Otherwise, just copy the host string... */ - ptr = http_copy_encode(ptr, host, end, NULL); + ptr = http_copy_encode(ptr, host, end, NULL, NULL, + encoding & HTTP_URI_CODING_HOSTNAME); if (!ptr) goto assemble_overflow; @@ -318,26 +294,18 @@ httpAssembleURIf(char *uri, /* I - URI buffer */ * Last but not least, add the resource string... */ - if (resourcef) + if (resource) { char *query; /* Pointer to query string */ - va_start(ap, resourcef); - bytes = vsnprintf(resource, sizeof(resource), resourcef, ap); - va_end(ap); - - if (bytes >= sizeof(resource)) - goto assemble_overflow; - /* - * Temporarily remove query string if present... + * Copy the resource string up to the query string if present... */ - if ((query = strchr(resource, '?')) != NULL) - *query = '\0'; - - ptr = http_copy_encode(ptr, resource, end, NULL); + query = strchr(resource, '?'); + ptr = http_copy_encode(ptr, resource, end, NULL, "?", + encoding & HTTP_URI_CODING_RESOURCE); if (!ptr) goto assemble_overflow; @@ -347,9 +315,10 @@ httpAssembleURIf(char *uri, /* I - URI buffer */ * Copy query string without encoding... */ - *query = '?'; - strlcpy(ptr, query, end - ptr); - ptr += strlen(ptr); + ptr = http_copy_encode(ptr, query, end, NULL, NULL, + encoding & HTTP_URI_CODING_QUERY); + if (!ptr) + goto assemble_overflow; } } else if (ptr < end) @@ -377,6 +346,66 @@ httpAssembleURIf(char *uri, /* I - URI buffer */ } +/* + * 'httpAssembleURIf()' - Assemble a uniform resource identifier from its + * components with a formatted resource. + * + * This function creates a formatted version of the resource string + * argument "resourcef" and properly escapes all reserved characters + * in a URI. You should use this function in place of traditional + * string functions whenever you need to create a URI string. + * + * @since CUPS 1.2@ + */ + +http_uri_status_t /* O - URI status */ +httpAssembleURIf( + http_uri_coding_t encoding, /* I - Encoding flags */ + char *uri, /* I - URI buffer */ + int urilen, /* I - Size of URI buffer */ + const char *scheme, /* I - Scheme name */ + const char *username, /* I - Username */ + const char *host, /* I - Hostname or address */ + int port, /* I - Port number */ + const char *resourcef, /* I - Printf-style resource */ + ...) /* I - Additional arguments as needed */ +{ + va_list ap; /* Pointer to additional arguments */ + char resource[1024]; /* Formatted resource string */ + int bytes; /* Bytes in formatted string */ + + + /* + * Range check input... + */ + + if (!uri || urilen < 1 || !scheme || port < 0 || !resourcef) + { + if (uri) + *uri = '\0'; + + return (HTTP_URI_BAD_ARGUMENTS); + } + + /* + * Format the resource string and assemble the URI... + */ + + va_start(ap, resourcef); + bytes = vsnprintf(resource, sizeof(resource), resourcef, ap); + va_end(ap); + + if (bytes >= sizeof(resource)) + { + *uri = '\0'; + return (HTTP_URI_OVERFLOW); + } + else + return (httpAssembleURI(encoding, uri, urilen, scheme, username, host, + port, resource)); +} + + /* * 'httpDecode64()' - Base64-decode a string. */ @@ -714,8 +743,9 @@ httpSeparate(const char *uri, /* I - Universal Resource Identifier */ int *port, /* O - Port number to use */ char *resource) /* O - Resource/filename [1024] */ { - httpSeparateURI(uri, scheme, 32, username, HTTP_MAX_URI, host, HTTP_MAX_URI, - port, resource, HTTP_MAX_URI); + httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, 32, username, + HTTP_MAX_URI, host, HTTP_MAX_URI, port, resource, + HTTP_MAX_URI); } @@ -738,8 +768,8 @@ httpSeparate2(const char *uri, /* I - Universal Resource Identifier */ char *resource, /* O - Resource/filename */ int resourcelen) /* I - Size of resource buffer */ { - httpSeparateURI(uri, scheme, schemelen, username, usernamelen, host, hostlen, - port, resource, resourcelen); + httpSeparateURI(HTTP_URI_CODING_ALL, uri, scheme, schemelen, username, + usernamelen, host, hostlen, port, resource, resourcelen); } @@ -751,16 +781,18 @@ httpSeparate2(const char *uri, /* I - Universal Resource Identifier */ */ http_uri_status_t /* O - Result of separation */ -httpSeparateURI(const char *uri, /* I - Universal Resource Identifier */ - char *scheme, /* O - Scheme (http, https, etc.) */ - int schemelen, /* I - Size of scheme buffer */ - char *username, /* O - Username */ - int usernamelen, /* I - Size of username buffer */ - char *host, /* O - Hostname */ - int hostlen, /* I - Size of hostname buffer */ - int *port, /* O - Port number to use */ - char *resource, /* O - Resource/filename */ - int resourcelen) /* I - Size of resource buffer */ +httpSeparateURI( + http_uri_coding_t decoding, /* I - Decoding flags */ + const char *uri, /* I - Universal Resource Identifier */ + char *scheme, /* O - Scheme (http, https, etc.) */ + int schemelen, /* I - Size of scheme buffer */ + char *username, /* O - Username */ + int usernamelen, /* I - Size of username buffer */ + char *host, /* O - Hostname */ + int hostlen, /* I - Size of hostname buffer */ + int *port, /* O - Port number to use */ + char *resource, /* O - Resource/filename */ + int resourcelen) /* I - Size of resource buffer */ { char *ptr, /* Pointer into string... */ *end; /* End of string */ @@ -886,7 +918,8 @@ httpSeparateURI(const char *uri, /* I - Universal Resource Identifier */ * Get a username:password combo... */ - uri = http_copy_decode(username, uri, usernamelen, "@"); + uri = http_copy_decode(username, uri, usernamelen, "@", + decoding & HTTP_URI_CODING_USERNAME); if (!uri) { @@ -911,7 +944,8 @@ httpSeparateURI(const char *uri, /* I - Universal Resource Identifier */ if (!strncmp(uri, "v1.", 3)) uri += 3; /* Skip IPvN leader... */ - uri = http_copy_decode(host, uri, hostlen, "]"); + uri = http_copy_decode(host, uri, hostlen, "]", + decoding & HTTP_URI_CODING_HOSTNAME); if (!uri) { @@ -953,7 +987,8 @@ httpSeparateURI(const char *uri, /* I - Universal Resource Identifier */ * Grab hostname or IPv4 address... */ - uri = http_copy_decode(host, uri, hostlen, ":?/"); + uri = http_copy_decode(host, uri, hostlen, ":?/", + decoding & HTTP_URI_CODING_HOSTNAME); if (!uri) { @@ -1022,29 +1057,30 @@ httpSeparateURI(const char *uri, /* I - Universal Resource Identifier */ *resource = '/'; /* - * Copy any query string without decoding it... + * Copy any query string... */ if (*uri == '?') - { - strlcpy(resource + 1, uri, resourcelen - 1); - uri += strlen(uri); - } + uri = http_copy_decode(resource + 1, uri, resourcelen - 1, NULL, + decoding & HTTP_URI_CODING_QUERY); else resource[1] = '\0'; } else { - uri = http_copy_decode(resource, uri, resourcelen, "?"); + uri = http_copy_decode(resource, uri, resourcelen, "?", + decoding & HTTP_URI_CODING_RESOURCE); if (uri && *uri == '?') { /* - * Concatenate any query string without decoding it... + * Concatenate any query string... */ - strlcat(resource, uri, resourcelen); - uri += strlen(uri); + char *resptr = resource + strlen(resource); + + uri = http_copy_decode(resptr, uri, resourcelen - (resptr - resource), + NULL, decoding & HTTP_URI_CODING_QUERY); } } @@ -1143,7 +1179,8 @@ static const char * /* O - New source pointer or NULL on error */ http_copy_decode(char *dst, /* O - Destination buffer */ const char *src, /* I - Source pointer */ int dstsize, /* I - Destination size */ - const char *term) /* I - Terminating characters */ + const char *term, /* I - Terminating characters */ + int decode) /* I - Decode %-encoded values */ { char *ptr, /* Pointer into buffer */ *end; /* End of buffer */ @@ -1158,7 +1195,7 @@ http_copy_decode(char *dst, /* O - Destination buffer */ for (ptr = dst, end = dst + dstsize - 1; *src && !strchr(term, *src); src ++) if (ptr < end) { - if (*src == '%') + if (*src == '%' && decode) { if (isxdigit(src[1] & 255) && isxdigit(src[2] & 255)) { @@ -1208,15 +1245,20 @@ static char * /* O - End of current URI */ http_copy_encode(char *dst, /* O - Destination buffer */ const char *src, /* I - Source pointer */ char *dstend, /* I - End of destination buffer */ - const char *reserved) /* I - Extra reserved characters */ + const char *reserved, /* I - Extra reserved characters */ + const char *term, /* I - Terminating characters */ + int encode) /* I - %-encode reserved chars? */ { static const char *hex = "0123456789ABCDEF"; while (*src && dst < dstend) { - if (*src == '%' || *src <= ' ' || *src & 128 || - (reserved && strchr(reserved, *src))) + if (term && *src == *term) + return (dst); + + if (encode && (*src == '%' || *src <= ' ' || *src & 128 || + (reserved && strchr(reserved, *src)))) { /* * Hex encode reserved characters... @@ -1243,5 +1285,5 @@ http_copy_encode(char *dst, /* O - Destination buffer */ /* - * End of "$Id: http-support.c 4961 2006-01-20 22:19:13Z mike $". + * End of "$Id: http-support.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/http.c b/cups/http.c index b094a5d49..fc6a20d07 100644 --- a/cups/http.c +++ b/cups/http.c @@ -1,5 +1,5 @@ /* - * "$Id: http.c 4995 2006-01-26 20:14:42Z mike $" + * "$Id: http.c 5023 2006-01-29 14:39:44Z mike $" * * HTTP routines for the Common UNIX Printing System (CUPS). * @@ -50,6 +50,7 @@ * httpPrintf() - Print a formatted string to a HTTP connection. * httpPut() - Send a PUT request to the server. * httpRead() - Read data from a HTTP connection. + * httpRead2() - Read data from a HTTP connection. * _httpReadCDSA() - Read function for CDSA decryption code. * httpReconnect() - Reconnect to a HTTP server... * httpSetCookie() - Set the cookie value(s)... @@ -59,6 +60,7 @@ * httpUpdate() - Update the current HTTP state for incoming data. * httpWait() - Wait for data available on a connection. * httpWrite() - Write data to a HTTP connection. + * httpWrite2() - Write data to a HTTP connection. * _httpWriteCDSA() - Write function for CDSA encryption code. * http_field() - Return the field index for a field name. * http_read_ssl() - Read from a SSL/TLS connection. @@ -395,7 +397,7 @@ httpFlush(http_t *http) /* I - HTTP data */ * Read any data we can... */ - while (httpRead(http, buffer, sizeof(buffer)) > 0); + while (httpRead2(http, buffer, sizeof(buffer)) > 0); /* * Restore blocking and reset the connection if we didn't get all of @@ -988,6 +990,11 @@ httpPut(http_t *http, /* I - HTTP data */ /* * 'httpRead()' - Read data from a HTTP connection. + * + * This function is deprecated. Use the httpRead2() function which can + * read more than 2GB of data. + * + * @deprecated@ */ int /* O - Number of bytes read */ @@ -995,7 +1002,20 @@ httpRead(http_t *http, /* I - HTTP data */ char *buffer, /* I - Buffer for data */ int length) /* I - Maximum number of bytes */ { - int bytes; /* Bytes read */ + return ((int)httpRead2(http, buffer, length)); +} + + +/* + * 'httpRead2()' - Read data from a HTTP connection. + */ + +ssize_t /* O - Number of bytes read */ +httpRead2(http_t *http, /* I - HTTP data */ + char *buffer, /* I - Buffer for data */ + size_t length) /* I - Maximum number of bytes */ +{ + ssize_t bytes; /* Bytes read */ char len[32]; /* Length string */ @@ -1013,23 +1033,23 @@ httpRead(http_t *http, /* I - HTTP data */ if (http->data_encoding == HTTP_ENCODE_CHUNKED && http->data_remaining <= 0) { - DEBUG_puts("httpRead: Getting chunk length..."); + DEBUG_puts("httpRead2: Getting chunk length..."); if (httpGets(len, sizeof(len), http) == NULL) { - DEBUG_puts("httpRead: Could not get length!"); + DEBUG_puts("httpRead2: Could not get length!"); return (0); } http->data_remaining = strtoll(len, NULL, 16); if (http->data_remaining < 0) { - DEBUG_puts("httpRead: Negative chunk length!"); + DEBUG_puts("httpRead2: Negative chunk length!"); return (0); } } - DEBUG_printf(("httpRead: data_remaining=" CUPS_LLFMT "\n", + DEBUG_printf(("httpRead2: data_remaining=" CUPS_LLFMT "\n", CUPS_LLCAST http->data_remaining)); if (http->data_remaining <= 0) @@ -1078,12 +1098,12 @@ httpRead(http_t *http, /* I - HTTP data */ else #endif /* HAVE_SSL */ { - DEBUG_printf(("httpRead: reading %d bytes from socket into buffer...\n", + DEBUG_printf(("httpRead2: reading %d bytes from socket into buffer...\n", bytes)); bytes = recv(http->fd, http->buffer, bytes, 0); - DEBUG_printf(("httpRead: read %d bytes from socket into buffer...\n", + DEBUG_printf(("httpRead2: read %d bytes from socket into buffer...\n", bytes)); } @@ -1116,7 +1136,7 @@ httpRead(http_t *http, /* I - HTTP data */ bytes = length; - DEBUG_printf(("httpRead: grabbing %d bytes from input buffer...\n", bytes)); + DEBUG_printf(("httpRead2: grabbing %d bytes from input buffer...\n", bytes)); memcpy(buffer, http->buffer, length); http->used -= length; @@ -1138,13 +1158,13 @@ httpRead(http_t *http, /* I - HTTP data */ if (!http->blocking && !httpWait(http, 1000)) return (0); - DEBUG_printf(("httpRead: reading %d bytes from socket...\n", length)); + DEBUG_printf(("httpRead2: reading %d bytes from socket...\n", length)); while ((bytes = recv(http->fd, buffer, length, 0)) < 0) if (errno != EINTR) break; - DEBUG_printf(("httpRead: read %d bytes from socket...\n", bytes)); + DEBUG_printf(("httpRead2: read %d bytes from socket...\n", bytes)); } if (bytes > 0) @@ -1190,7 +1210,7 @@ httpRead(http_t *http, /* I - HTTP data */ #ifdef DEBUG { int i, j, ch; - printf("httpRead: Read %d bytes:\n", bytes); + printf("httpRead2: Read %d bytes:\n", bytes); for (i = 0; i < bytes; i += 16) { printf(" "); @@ -1635,6 +1655,11 @@ httpWait(http_t *http, /* I - HTTP data */ /* * 'httpWrite()' - Write data to a HTTP connection. + * + * This function is deprecated. Use the httpWrite2() function which can + * write more than 2GB of data. + * + * @deprecated@ */ int /* O - Number of bytes written */ @@ -1642,7 +1667,20 @@ httpWrite(http_t *http, /* I - HTTP data */ const char *buffer, /* I - Buffer for data */ int length) /* I - Number of bytes to write */ { - int bytes; /* Bytes written */ + return ((int)httpWrite2(http, buffer, length)); +} + + +/* + * 'httpWrite2()' - Write data to a HTTP connection. + */ + +ssize_t /* O - Number of bytes written */ +httpWrite2(http_t *http, /* I - HTTP data */ + const char *buffer, /* I - Buffer for data */ + size_t length) /* I - Number of bytes to write */ +{ + ssize_t bytes; /* Bytes written */ DEBUG_printf(("httpWrite(http=%p, buffer=%p, length=%d)\n", http, @@ -2535,5 +2573,5 @@ http_write_ssl(http_t *http, /* I - HTTP data */ /* - * End of "$Id: http.c 4995 2006-01-26 20:14:42Z mike $". + * End of "$Id: http.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/http.h b/cups/http.h index 1384e6d7d..9c346eebf 100644 --- a/cups/http.h +++ b/cups/http.h @@ -1,5 +1,5 @@ /* - * "$Id: http.h 4973 2006-01-25 02:36:02Z mike $" + * "$Id: http.h 5023 2006-01-29 14:39:44Z mike $" * * Hyper-Text Transport Protocol definitions for the Common UNIX Printing * System (CUPS). @@ -268,6 +268,17 @@ typedef enum http_uri_status_e /**** URI separation status @since CUPS1.2@ **** HTTP_URI_MISSING_RESOURCE /* Missing resource in URI (warning) */ } http_uri_status_t; +typedef enum http_uri_coding_e /**** URI en/decode flags ****/ +{ + HTTP_URI_CODING_NONE = 0, /* Don't en/decode anything */ + HTTP_URI_CODING_USERNAME = 1, /* En/decode the username portion */ + HTTP_URI_CODING_HOSTNAME = 2, /* En/decode the hostname portion */ + HTTP_URI_CODING_RESOURCE = 4, /* En/decode the resource portion */ + HTTP_URI_CODING_MOST = 7, /* En/decode all but the query */ + HTTP_URI_CODING_QUERY = 8, /* En/decode the query portion */ + HTTP_URI_CODING_ALL = 15 /* En/decode everything */ +} http_uri_coding_t; + typedef enum http_version_e /**** HTTP version numbers ****/ { HTTP_0_9 = 9, /* HTTP/0.9 */ @@ -384,7 +395,7 @@ __attribute__ ((__format__ (__printf__, 2, 3))) # endif /* __GNUC__ */ ; extern int httpPut(http_t *http, const char *uri); -extern int httpRead(http_t *http, char *buffer, int length); +extern int httpRead(http_t *http, char *buffer, int length) _HTTP_DEPRECATED; extern int httpReconnect(http_t *http); extern void httpSeparate(const char *uri, char *method, char *username, char *host, int *port, @@ -394,7 +405,7 @@ extern void httpSetField(http_t *http, http_field_t field, extern const char *httpStatus(http_status_t status); extern int httpTrace(http_t *http, const char *uri); extern http_status_t httpUpdate(http_t *http); -extern int httpWrite(http_t *http, const char *buffer, int length); +extern int httpWrite(http_t *http, const char *buffer, int length) _HTTP_DEPRECATED; extern char *httpEncode64(char *out, const char *in) _HTTP_DEPRECATED; extern char *httpDecode64(char *out, const char *in) _HTTP_DEPRECATED; extern int httpGetLength(http_t *http) _HTTP_DEPRECATED; @@ -434,12 +445,14 @@ extern char *httpAddrLookup(const http_addr_t *addr, char *name, int namelen); extern char *httpAddrString(const http_addr_t *addr, char *s, int slen); -extern http_uri_status_t httpAssembleURI(char *uri, int urilen, +extern http_uri_status_t httpAssembleURI(http_uri_coding_t encoding, + char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, const char *resource); -extern http_uri_status_t httpAssembleURIf(char *uri, int urilen, +extern http_uri_status_t httpAssembleURIf(http_uri_coding_t encoding, + char *uri, int urilen, const char *scheme, const char *username, const char *host, int port, @@ -451,12 +464,16 @@ extern off_t httpGetLength2(http_t *http); extern char *httpGetSubField2(http_t *http, http_field_t field, const char *name, char *value, int valuelen); -extern http_uri_status_t httpSeparateURI(const char *uri, +extern ssize_t httpRead2(http_t *http, char *buffer, size_t length); +extern http_uri_status_t httpSeparateURI(http_uri_coding_t decoding, + const char *uri, char *scheme, int schemelen, char *username, int usernamelen, char *host, int hostlen, int *port, char *resource, int resourcelen); extern void httpSetLength(http_t *http, size_t length); +extern ssize_t httpWrite2(http_t *http, const char *buffer, + size_t length); /* @@ -469,5 +486,5 @@ extern void httpSetLength(http_t *http, size_t length); #endif /* !_CUPS_HTTP_H_ */ /* - * End of "$Id: http.h 4973 2006-01-25 02:36:02Z mike $". + * End of "$Id: http.h 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/ipp.c b/cups/ipp.c index fbe7e39de..be6f0bbc9 100644 --- a/cups/ipp.c +++ b/cups/ipp.c @@ -1,5 +1,5 @@ /* - * "$Id: ipp.c 4995 2006-01-26 20:14:42Z mike $" + * "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $" * * Internet Printing Protocol support functions for the Common UNIX * Printing System (CUPS). @@ -85,9 +85,12 @@ */ static size_t ipp_length(ipp_t *ipp, int collection); -static int ipp_read_http(http_t *http, ipp_uchar_t *buffer, int length); -static int ipp_read_file(int *fd, ipp_uchar_t *buffer, int length); -static int ipp_write_file(int *fd, ipp_uchar_t *buffer, int length); +static ssize_t ipp_read_http(http_t *http, ipp_uchar_t *buffer, + size_t length); +static ssize_t ipp_read_file(int *fd, ipp_uchar_t *buffer, + size_t length); +static ssize_t ipp_write_file(int *fd, ipp_uchar_t *buffer, + size_t length); /* @@ -1580,7 +1583,7 @@ ippWrite(http_t *http, /* I - HTTP connection */ if (http == NULL) return (IPP_ERROR); - return (ippWriteIO(http, (ipp_iocb_t)httpWrite, + return (ippWriteIO(http, (ipp_iocb_t)httpWrite2, http->blocking, NULL, ipp)); } @@ -2623,10 +2626,10 @@ ipp_length(ipp_t *ipp, /* I - IPP message or collection */ * 'ipp_read_http()' - Semi-blocking read on a HTTP connection... */ -static int /* O - Number of bytes read */ +static ssize_t /* O - Number of bytes read */ ipp_read_http(http_t *http, /* I - Client connection */ ipp_uchar_t *buffer, /* O - Buffer for data */ - int length) /* I - Total length */ + size_t length) /* I - Total length */ { int tbytes, /* Total bytes read */ bytes; /* Bytes read this pass */ @@ -2718,7 +2721,7 @@ ipp_read_http(http_t *http, /* I - Client connection */ } } - if ((bytes = httpRead(http, (char *)buffer, length - tbytes)) <= 0) + if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) <= 0) break; } } @@ -2740,10 +2743,10 @@ ipp_read_http(http_t *http, /* I - Client connection */ * 'ipp_read_file()' - Read IPP data from a file. */ -static int /* O - Number of bytes read */ +static ssize_t /* O - Number of bytes read */ ipp_read_file(int *fd, /* I - File descriptor */ ipp_uchar_t *buffer, /* O - Read buffer */ - int length) /* I - Number of bytes to read */ + size_t length) /* I - Number of bytes to read */ { return (read(*fd, buffer, length)); } @@ -2753,15 +2756,15 @@ ipp_read_file(int *fd, /* I - File descriptor */ * 'ipp_write_file()' - Write IPP data to a file. */ -static int /* O - Number of bytes written */ +static ssize_t /* O - Number of bytes written */ ipp_write_file(int *fd, /* I - File descriptor */ ipp_uchar_t *buffer, /* I - Data to write */ - int length) /* I - Number of bytes to write */ + size_t length) /* I - Number of bytes to write */ { return (write(*fd, buffer, length)); } /* - * End of "$Id: ipp.c 4995 2006-01-26 20:14:42Z mike $". + * End of "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/ipp.h b/cups/ipp.h index f011a35e4..4a337a84e 100644 --- a/cups/ipp.h +++ b/cups/ipp.h @@ -1,5 +1,5 @@ /* - * "$Id: ipp.h 4995 2006-01-26 20:14:42Z mike $" + * "$Id: ipp.h 5023 2006-01-29 14:39:44Z mike $" * * Internet Printing Protocol definitions for the Common UNIX Printing * System (CUPS). @@ -310,9 +310,9 @@ typedef enum /**** IPP status codes... ****/ typedef unsigned char ipp_uchar_t; /**** Unsigned 8-bit integer/character ****/ -/**** New in CUPS 1.1.19 ****/ -typedef int (*ipp_iocb_t)(void *, ipp_uchar_t *, int); - /**** IPP IO Callback Function ****/ +/**** New in CUPS 1.2 ****/ +typedef ssize_t (*ipp_iocb_t)(void *, ipp_uchar_t *, size_t); + /**** IPP IO Callback Function @since CUPS 1.2@ ****/ typedef union /**** Request Header ****/ { @@ -470,11 +470,7 @@ extern ipp_attribute_t *ippAddCollections(ipp_t *ipp, ipp_tag_t group, const ipp_t **values); extern void ippDeleteAttribute(ipp_t *ipp, ipp_attribute_t *attr); extern ipp_state_t ippReadFile(int fd, ipp_t *ipp); -extern ipp_state_t ippReadIO(void *src, ipp_iocb_t cb, int blocking, - ipp_t *parent, ipp_t *ipp); extern ipp_state_t ippWriteFile(int fd, ipp_t *ipp); -extern ipp_state_t ippWriteIO(void *dst, ipp_iocb_t cb, int blocking, - ipp_t *parent, ipp_t *ipp); /**** New in CUPS 1.2 ****/ extern ipp_attribute_t *ippAddOctetString(ipp_t *ipp, ipp_tag_t group, @@ -484,6 +480,10 @@ extern ipp_status_t ippErrorValue(const char *name); extern ipp_t *ippNewRequest(ipp_op_t op); extern const char *ippOpString(ipp_op_t op); extern ipp_op_t ippOpValue(const char *name); +extern ipp_state_t ippReadIO(void *src, ipp_iocb_t cb, int blocking, + ipp_t *parent, ipp_t *ipp); +extern ipp_state_t ippWriteIO(void *dst, ipp_iocb_t cb, int blocking, + ipp_t *parent, ipp_t *ipp); /* @@ -496,5 +496,5 @@ extern ipp_op_t ippOpValue(const char *name); #endif /* !_CUPS_IPP_H_ */ /* - * End of "$Id: ipp.h 4995 2006-01-26 20:14:42Z mike $". + * End of "$Id: ipp.h 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/testhttp.c b/cups/testhttp.c index 69f959541..71b8709f9 100644 --- a/cups/testhttp.c +++ b/cups/testhttp.c @@ -1,5 +1,5 @@ /* - * "$Id: testhttp.c 4943 2006-01-18 20:30:42Z mike $" + * "$Id: testhttp.c 5023 2006-01-29 14:39:44Z mike $" * * HTTP test program for the Common UNIX Printing System (CUPS). * @@ -325,7 +325,8 @@ main(int argc, /* I - Number of command-line arguments */ fputs("httpSeparateURI(): ", stdout); for (i = 0, j = 0; i < (int)(sizeof(uri_tests) / sizeof(uri_tests[0])); i ++) { - uri_status = httpSeparateURI(uri_tests[i].uri, scheme, sizeof(scheme), + uri_status = httpSeparateURI(HTTP_URI_CODING_MOST, + uri_tests[i].uri, scheme, sizeof(scheme), username, sizeof(username), hostname, sizeof(hostname), &port, resource, sizeof(resource)); @@ -390,7 +391,8 @@ main(int argc, /* I - Number of command-line arguments */ strstr(uri_tests[i].uri, "//")) { k ++; - uri_status = httpAssembleURI(buffer, sizeof(buffer), + uri_status = httpAssembleURI(HTTP_URI_CODING_MOST, + buffer, sizeof(buffer), uri_tests[i].scheme, uri_tests[i].username, uri_tests[i].hostname, @@ -459,7 +461,8 @@ main(int argc, /* I - Number of command-line arguments */ continue; } - httpSeparateURI(argv[i], scheme, sizeof(scheme), username, sizeof(username), + httpSeparateURI(HTTP_URI_CODING_MOST, argv[i], scheme, sizeof(scheme), + username, sizeof(username), hostname, sizeof(hostname), &port, resource, sizeof(resource)); @@ -485,7 +488,7 @@ main(int argc, /* I - Number of command-line arguments */ length = httpGetLength2(http); total = 0; - while ((bytes = httpRead(http, buffer, sizeof(buffer))) > 0) + while ((bytes = httpRead2(http, buffer, sizeof(buffer))) > 0) { total += bytes; fwrite(buffer, bytes, 1, out); @@ -512,5 +515,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: testhttp.c 4943 2006-01-18 20:30:42Z mike $". + * End of "$Id: testhttp.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/testipp.c b/cups/testipp.c index dbe50b54d..07bcdffc0 100644 --- a/cups/testipp.c +++ b/cups/testipp.c @@ -1,5 +1,5 @@ /* - * "$Id: testipp.c 4731 2005-09-30 23:11:10Z mike $" + * "$Id: testipp.c 5023 2006-01-29 14:39:44Z mike $" * * IPP test program for the Common UNIX Printing System (CUPS). * @@ -144,8 +144,8 @@ ipp_uchar_t collection[] = /* Collection buffer */ void hex_dump(const char *title, ipp_uchar_t *buffer, int bytes); void print_attributes(ipp_t *ipp, int indent); -int read_cb(void *data, ipp_uchar_t *buffer, int bytes); -int write_cb(void *data, ipp_uchar_t *buffer, int bytes); +ssize_t read_cb(void *data, ipp_uchar_t *buffer, size_t bytes); +ssize_t write_cb(void *data, ipp_uchar_t *buffer, size_t bytes); /* @@ -594,10 +594,10 @@ print_attributes(ipp_t *ipp, /* I - IPP request */ * 'read_cb()' - Read data from a buffer. */ -int /* O - Number of bytes read */ +ssize_t /* O - Number of bytes read */ read_cb(void *data, /* I - Data */ ipp_uchar_t *buffer, /* O - Buffer to read */ - int bytes) /* I - Number of bytes to read */ + size_t bytes) /* I - Number of bytes to read */ { int count; /* Number of bytes */ @@ -621,10 +621,10 @@ read_cb(void *data, /* I - Data */ * 'write_cb()' - Write data into a buffer. */ -int /* O - Number of bytes written */ +ssize_t /* O - Number of bytes written */ write_cb(void *data, /* I - Data */ ipp_uchar_t *buffer, /* I - Buffer to write */ - int bytes) /* I - Number of bytes to write */ + size_t bytes) /* I - Number of bytes to write */ { int count; /* Number of bytes */ @@ -645,5 +645,5 @@ write_cb(void *data, /* I - Data */ /* - * End of "$Id: testipp.c 4731 2005-09-30 23:11:10Z mike $". + * End of "$Id: testipp.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/cups/util.c b/cups/util.c index e26db23f2..b1108effb 100644 --- a/cups/util.c +++ b/cups/util.c @@ -1,5 +1,5 @@ /* - * "$Id: util.c 4987 2006-01-26 00:25:21Z mike $" + * "$Id: util.c 5023 2006-01-29 14:39:44Z mike $" * * Printing utilities for the Common UNIX Printing System (CUPS). * @@ -121,8 +121,8 @@ cupsCancelJob(const char *name, /* I - Name of printer or class */ * Create a printer URI... */ - if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", printer) != HTTP_URI_OK) + if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", printer) != HTTP_URI_OK) { cups_set_error(IPP_INTERNAL_ERROR, NULL); @@ -336,7 +336,7 @@ cupsDoFileRequest(http_t *http, /* I - HTTP connection to server */ break; } - if (httpWrite(http, buffer, bytes) < bytes) + if (httpWrite2(http, buffer, bytes) < bytes) break; } } @@ -891,8 +891,8 @@ cupsGetJobs2(http_t *http, /* I - HTTP connection */ if (mydest) { - if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", mydest) != HTTP_URI_OK) + if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", mydest) != HTTP_URI_OK) { cups_set_error(IPP_INTERNAL_ERROR, NULL); @@ -1552,8 +1552,8 @@ cupsPrintFiles2(http_t *http, /* I - HTTP connection */ * Setup the printer URI... */ - if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", name) != HTTP_URI_OK) + if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", name) != HTTP_URI_OK) { cups_set_error(IPP_INTERNAL_ERROR, NULL); @@ -1816,8 +1816,8 @@ cups_get_printer_uri( * Setup the printer URI... */ - if (httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0, - "/printers/%s", name) != HTTP_URI_OK) + if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, + "localhost", 0, "/printers/%s", name) != HTTP_URI_OK) { cups_set_error(IPP_INTERNAL_ERROR, NULL); @@ -1877,9 +1877,9 @@ cups_get_printer_uri( for (i = 0; i < attr->num_values; i ++) { - httpSeparateURI(attr->values[i].string.text, scheme, sizeof(scheme), - username, sizeof(username), host, hostsize, - port, resource, resourcesize); + httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, + scheme, sizeof(scheme), username, sizeof(username), + host, hostsize, port, resource, resourcesize); if (!strncmp(resource, "/printers/", 10)) { /* @@ -1901,9 +1901,9 @@ cups_get_printer_uri( { for (i = 0; i < attr->num_values; i ++) { - httpSeparateURI(attr->values[i].string.text, scheme, sizeof(scheme), - username, sizeof(username), host, hostsize, - port, resource, resourcesize); + httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, + scheme, sizeof(scheme), username, sizeof(username), + host, hostsize, port, resource, resourcesize); if (!strncmp(resource, "/classes/", 9)) { /* @@ -1945,9 +1945,9 @@ cups_get_printer_uri( else if ((attr = ippFindAttribute(response, "printer-uri-supported", IPP_TAG_URI)) != NULL) { - httpSeparateURI(attr->values[0].string.text, scheme, sizeof(scheme), - username, sizeof(username), host, hostsize, - port, resource, resourcesize); + httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, + scheme, sizeof(scheme), username, sizeof(username), + host, hostsize, port, resource, resourcesize); ippDelete(response); return (1); @@ -1990,5 +1990,5 @@ cups_set_error(ipp_status_t status, /* I - IPP status code */ /* - * End of "$Id: util.c 4987 2006-01-26 00:25:21Z mike $". + * End of "$Id: util.c 5023 2006-01-29 14:39:44Z mike $". */ diff --git a/doc/Makefile b/doc/Makefile index a6aa8a3cd..c8f86cdba 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile 4950 2006-01-19 16:07:57Z mike $" +# "$Id: Makefile 5020 2006-01-28 13:36:15Z mike $" # # Documentation makefile for the Common UNIX Printing System (CUPS). # @@ -30,6 +30,7 @@ include ../Makedefs WEBPAGES = cups.css cupsdoc.css index.html robots.txt WEBIMAGES = \ + favicon.ico \ images/accept-jobs.gif \ images/add-class.gif \ images/add-printer.gif \ diff --git a/doc/cups.css b/doc/cups.css index 24c7f5ea4..a1981b58a 100644 --- a/doc/cups.css +++ b/doc/cups.css @@ -221,3 +221,8 @@ DT { DD { margin-left: 5em; } + +P.summary { + margin-left: 5em; + font-family: monospace; +} diff --git a/doc/help/spec-ppd.html b/doc/help/spec-ppd.html index a6d70ba73..eb9ac267b 100644 --- a/doc/help/spec-ppd.html +++ b/doc/help/spec-ppd.html @@ -4,10 +4,11 @@ CUPS PPD Extensions +