#
-# "$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).
#
PAMLIBS = @PAMLIBS@
SSLFLAGS = @SSLFLAGS@
SSLLIBS = @SSLLIBS@
+LAUNCHDLIBS = @LAUNCHDLIBS@
#
# Directories...
PAMDIR = $(BUILDROOT)@PAMDIR@
PAMFILE = @PAMFILE@
+DEFAULT_LAUNCHD_CONF = @DEFAULT_LAUNCHD_CONF@
+
#
# Rules...
#
-# 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 $"
#
#
-# "$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).
#
#
DIRS = cups backend berkeley cgi-bin filter locale man pdftops \
- notifier scheduler systemv
+ notifier scheduler systemv test
#
# Make all targets...
$(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 \
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 $".
#
/*
- * "$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).
*
* 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);
}
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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])
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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));
/*
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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));
/*
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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));
/*
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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)
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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...
*/
/*
- * 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 $".
*/
/*
- * "$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).
*
"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);
/*
- * 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 $".
*/
/*
- * "$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).
*
}
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);
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);
/*
- * 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 $".
*/
/*
- * "$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).
*
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",
/*
- * 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 $".
*/
/*
- * "$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).
*
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...
*/
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);
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);
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);
* 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",
* 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...
http_status_t get_status; /* Status of GET */
+ /* TODO: Use cupsGetFile() API... */
snprintf(uri, sizeof(uri), "/printers/%s.ppd", name);
if (httpGet(http, uri))
}
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);
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);
*/
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!")));
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);
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);
}
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!")));
}
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!")));
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);
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);
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);
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);
/*
- * 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 $".
*/
/*
- * "$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).
*
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);
/*
- * 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 $".
*/
/*
- * "$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).
*
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);
}
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
* 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") ||
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);
}
/*
- * 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 $".
*/
/*
- * "$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).
*
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);
/*
- * 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 $".
*/
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])
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
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
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)
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
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
--- /dev/null
+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
/*
- * "$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).
*
#undef HAVE_PTHREAD_H
+/*
+ * Do we have launchd support?
+ */
+
+#undef HAVE_LAUNCH_H
+#undef HAVE_LAUNCHD
+#define CUPS_DEFAULT_LAUNCHD_CONF ""
+
+
/*
* Various scripting languages...
*/
#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 $".
*/
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
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)
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
#
-# "$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).
#
attr.o \
auth.o \
backchannel.o \
+ backend.o \
custom.o \
dest.o \
dir.o \
#
-# End of "$Id: Makefile 5000 2006-01-26 23:38:43Z mike $".
+# End of "$Id: Makefile 5023 2006-01-29 14:39:44Z mike $".
#
--- /dev/null
+/*
+ * "$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 <stdlib.h>
+#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 $".
+ */
/*
- * "$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).
*
} 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 $".
*/
/*
- * "$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).
*
* 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
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);
}
/*
- * 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 $".
*/
/*
- * "$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.
*
*/
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);
/*
*/
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 */
/*
*/
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;
* 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;
* 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;
* 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;
* 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)
}
+/*
+ * '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.
*/
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);
}
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);
}
*/
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 */
* 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)
{
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)
{
* 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)
{
*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);
}
}
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 */
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))
{
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...
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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)...
* 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.
* 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
/*
* '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 */
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 */
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)
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));
}
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;
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)
#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(" ");
/*
* '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 */
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,
/*
- * 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 $".
*/
/*
- * "$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).
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 */
# 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,
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;
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,
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);
/*
#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 $".
*/
/*
- * "$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).
*/
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);
/*
if (http == NULL)
return (IPP_ERROR);
- return (ippWriteIO(http, (ipp_iocb_t)httpWrite,
+ return (ippWriteIO(http, (ipp_iocb_t)httpWrite2,
http->blocking, NULL, ipp));
}
* '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 */
}
}
- if ((bytes = httpRead(http, (char *)buffer, length - tbytes)) <= 0)
+ if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) <= 0)
break;
}
}
* '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));
}
* '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 $".
*/
/*
- * "$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).
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 ****/
{
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,
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);
/*
#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 $".
*/
/*
- * "$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).
*
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));
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,
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));
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);
/*
- * 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 $".
*/
/*
- * "$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).
*
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);
/*
* '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 */
* '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 */
/*
- * 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 $".
*/
/*
- * "$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).
*
* 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);
break;
}
- if (httpWrite(http, buffer, bytes) < bytes)
+ if (httpWrite2(http, buffer, bytes) < bytes)
break;
}
}
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);
* 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);
* 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);
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))
{
/*
{
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))
{
/*
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);
/*
- * 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 $".
*/
#
-# "$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).
#
WEBPAGES = cups.css cupsdoc.css index.html robots.txt
WEBIMAGES = \
+ favicon.ico \
images/accept-jobs.gif \
images/add-class.gif \
images/add-printer.gif \
DD {
margin-left: 5em;
}
+
+P.summary {
+ margin-left: 5em;
+ font-family: monospace;
+}
<head>
<title>CUPS PPD Extensions</title>
<meta name='keywords' content='Programming, PostScript Printer Description'>
+ <link rel='stylesheet' type='text/css' href='../cups.css'>
</head>
<body>
<!--
- "$Id: spec-ppd.html 4941 2006-01-18 13:16:40Z mike $"
+ "$Id: spec-ppd.html 5023 2006-01-29 14:39:44Z mike $"
CUPS PPD extensions specification for the Common UNIX Printing System (CUPS).
<h2 class='title'><a name='ATTRIBUTES'>General Attributes</a></h2>
-<h3>cupsFilter</h3>
+<h3>APDuplexRequiresFlippedMargin</h3>
+
+<p class='summary'>*APDuplexRequiresFlippedMargin: boolean</p>
+
+<p>This boolean attribute notifies the RIP filters that the
+destination printer does not require the top and bottom margins
+of the <tt>ImageableArea</tt> swapped for the back page. The
+default value is <code>true</code>.</p>
-<p>This string attribute provides a conversion rule of the
-form:</p>
+<p>Example:</p>
<pre class='command'>
-source/type cost program
+<em>*% Don't swap the top and bottom margins for the back side</em>
+*APDuplexRequiresFlippedMargin: false
</pre>
-<p>The destination type is assumed to the printer's type. If a
-printer supports the source type directly, the special filter
-program "-" may be specified.</p>
+<p>Also see the related <tt>cupsFlipDuplex</tt> attribute.</p>
+
+<h3>cupsFilter</h3>
+
+<p class='summary'>*cupsFilter: "source/type cost program"</p>
+
+<p>This string attribute provides a conversion rule from the
+given source type to the printer's native format using the
+filter "program". If a printer supports the source type directly,
+the special filter program "-" may be specified.</p>
<p>Examples:</p>
<h3>cupsFlipDuplex</h3>
+<p class='summary'>*cupsFlipDuplex: boolean</p>
+
<p>This boolean attribute notifies the RIP filters that the
destination printer requires an upside-down image for the back
-page. The default value is false.</p>
+page. The default value is <code>false</code>.</p>
<p>Example:</p>
*cupsFlipDuplex: true
</pre>
+<p>Also see the related <tt>APDuplexRequiresFlippedMargins</tt> attribute.</p>
+
+<h3>cupsLanguages</h3>
+
+<p class='summary'>*cupsLanguages: "locale list"</p>
+
+<p>This attribute describes which language localizations are
+included in the PPD. The "locale list" string is a space-delimited
+list of locale names ("en", "en_US", "fr_FR", etc.)</p>
+
+<p>Example:</p>
+
+<pre class='command'>
+<em>*% Specify Canadian, UK, and US English, and Candian and French French</em>
+*cupsLanguages: "en_CA en_UK en_US fr_CA fr_FR"
+</pre>
+
<h3>cupsManualCopies</h3>
+<p class='summary'>*cupsManualCopies: boolean</p>
+
<p>This boolean attribute notifies the RIP filters that the
destination printer does not support copy generation in
-hardware. The default value is false.</p>
+hardware. The default value is <code>false</code>.</p>
<p>Example:</p>
<h3>cupsModelNumber</h3>
+<p class='summary'>*cupsModelNumber: number</p>
+
<p>This integer attribute specifies a printer-specific model
number. This number can be used by a filter program to adjust
the output for a specific model of printer.</p>
<h3>cupsPortMonitor</h3>
+<p class='summary'>*cupsPortMonitor urischeme/Descriptive Text: "port monitor"</p>
+
<p>This string attribute specifies printer-specific "port
monitor" filters that may be used with the printer. The CUPS
scheduler also looks for the <tt>Protocols</tt> attribute to see
respectively) is listed in the printer's
<tt>port-monitor-supported</tt> attribute.</p>
+<p>The "urischeme" portion of the attribute specifies the URI scheme
+that this port monitor should be used for. Typically this is used to
+pre-select a particular port monitor for each type of connection that
+is supported by the printer. The "port monitor" string can be "none"
+to disable the port monitor for the given URI scheme.</p>
+
<p>Examples:</p>
<pre class='command'>
<em>*% Specify a PostScript printer that supports the TBCP protocol</em>
*Protocols: TBCP PJL
+<em>*% Specify that TBCP should be used for socket connections but not USB</em>
+*cupsPortMonitor socket/AppSocket Printing: "tbcp"
+*cupsPortMonitor usb/USB Printing: "none"
+
<em>*% Specify a printer-specific port monitor for an Epson USB printer</em>
-*cupsPortMonitor epson-usb/USB Status Monitor: "epson-usb"
+*cupsPortMonitor usb/USB Status Monitor: "epson-usb"
</pre>
<h3>cupsVersion</h3>
+<p class='summary'>*cupsVersion: major.minor</p>
+
<p>This required attribute describes which version of the CUPS
PPD file extensions was used. Currently it must be the string
"1.0", "1.1", or "1.2".</p>
<p>When the base option is part of the <tt>JCLSetup</tt> section,
the "command" string contains JCL commands with "\order"
placeholders for each numbered parameter. The CUPS API handles
-any necessary value quoting for HP-PJL commands.</p>
+any necessary value quoting for HP-PJL commands. For example, if
+the JCL command string is "@PJL SET PASSCODE=\1" and the first
+option value is "1234" then CUPS will output the string
+"@PJL SET PASSCODE=1234".</p>
<p>For non-<tt>JCLSetup</tt> options, the "order" value is a
number from 1 to N and specifies the order of values as they are
-placed on the stack before the command.</p>
+placed on the stack before the command. For example, if the
+PostScript command string is
+"<</cupsReal1 2 1 roll>>setpagedevice" and the
+option value is "2.0" then CUPS will output the string
+"2.0 <</cupsReal1 2 1 roll>>setpagedevice".</p>
<blockquote><b>Note:</b> Currently only CustomPageSize supports
more than 1 parameter. This restriction is due to value encoding
<li><tt>passcode</tt> - a string of numbers value with a
minimum of "minimum" numbers and a maximum of "maximum"
- numbers (passcode strings are not displayed in the user
- interface)</li>
+ numbers ("minimum" and "maximum" are numbers and passcode
+ strings are not displayed in the user interface)</li>
<li><tt>password</tt> - a string value with a minimum of
"minimum" characters and a maximum of "maximum"
- characters (password strings are not displayed in the
- user interface)</li>
+ characters ("minimum" and "maximum" are numbers and password
+ strings are not displayed in the user interface)</li>
<li><tt>points</tt> - a measurement value in points from
"minimum" to "maximum"</li>
<li><tt>string</tt> - a string value with a minimum of
"minimum" characters and a maximum of "maximum"
- characters</li>
+ characters ("minimum" and "maximum" are numbers)</li>
</ul>
*ParamCustomJCLPasscode Code/Key Code: 1 passcode 4 4
+<em>*% Base PostScript watermark option</em>
+*OpenUI WatermarkText/Watermark Text: PickOne
+*OrderDependency: 10 AnySetup *WatermarkText
+*DefaultWatermarkText: None
+*WatermarkText None: ""
+*WatermarkText Draft: "<</cupsString1(Draft)>>setpagedevice"
+*CloseUI: *WatermarkText
+
+<em>*% Custom PostScript watermark option</em>
+*CustomWatermarkText True: "<</cupsString1 2 1 roll>>setpagedevice"
+*ParamCustomWatermarkText Text: 1 string 0 32
+
+
<em>*% Base PostScript gamma/density option</em>
*OpenUI GammaDensity/Gamma and Density: PickOne
*OrderDependency: 10 AnySetup *GammaDensity
*GammaDensity Normal/Normal: "<</cupsReal1 1.0/cupsReal2 1.0>>setpagedevice"
*GammaDensity Light/Lighter: "<</cupsReal1 0.9/cupsReal2 0.67>>setpagedevice"
*GammaDensity Dark/Darker: "<</cupsReal1 1.1/cupsReal2 1.5>>setpagedevice"
-*JCLCloseUI: *GammaDensity
+*CloseUI: *GammaDensity
<em>*% Custom PostScript gamma/density option</em>
*CustomGammaDensity True: "<</cupsReal1 3 1 roll/cupsReal2 3 1>>setpagedevice"
<h2 class='title'><a name='PROFILES'>Color Profiles</a></h2>
+<p>CUPS supports two types of color profiles. The first type is
+based on sRGB and is used by the standard CUPS raster filters and
+ESP Ghostscript. The second type is based on ICC profiles and is
+used by the Core Graphics-based filters on MacOS X.</p>
+
+<blockquote><b>Note:</b> At this time, none of the CUPS raster
+filters support ICC profiles. This will be addressed as time
+and resources permit.</blockquote>
+
<h3>cupsColorProfile</h3>
-<p>This string attribute specifies a color profile of the
-form:</p>
+<p class='summary'>*cupsColorProfile Resolution/MediaType: "density
+gamma m00 m01 m02 m10 m11 m12 m20 m21 m22"</p>
-<pre class='command'>
-*cupsColorProfile Resolution/MediaType: "density gamma m00 m01 m02 m10 m11 m12 m20 m21 m22"
-</pre>
+<p>This string attribute specifies an sRGB-based color profile
+consisting of gamma and density controls and a 3x3 CMY color
+transform matrix.</p>
<p>The <i>Resolution</i> and <i>MediaType</i> values may be "-"
to act as a wildcard. Otherwise they must match one of the
<h3>cupsICCProfile</h3>
-<p>This attribute specifies an ICC color profile of the
-form:</p>
-
-<pre class='command'>
-*cupsICCProfile ColorModel.MediaType.Resolution/Description: "filename"
-</pre>
+<p class='summary'>*cupsICCProfile
+ColorModel.MediaType.Resolution/Description: "filename"</p>
-<p>The <tt>ColorModel</tt>, <tt>MediaType</tt>, and
+<p>This attribute specifies an ICC color profile that is
+used to convert the document colors to the device
+colorspace. The <tt>ColorModel</tt>, <tt>MediaType</tt>, and
<tt>Resolution</tt> keywords specify a selector for color
profiles. If omitted, the color profile will match any option
keyword for the corresponding main keyword.</p>
</pre>
-<h2 class='title'><a name='I18N'>I18N Support</a></h2>
+<h2 class='title'><a name='I18N'>Global PPD Support</a></h2>
<p>CUPS 1.2 and higher adds support for PPD files containing multiple
-languages by following the following rules:</p>
+languages by following the following additional rules:</p>
<ol>
- <li>The <tt>LanguageVersion</tt> is <tt>English</tt></li>
+ <li>The <tt>LanguageVersion</tt> MUST be <tt>English</tt></li>
+
+ <li>The <tt>LanguageEncoding</tt> MUST be <tt>ISOLatin1</tt></li>
+
+ <li>The <tt>cupsLanguages</tt> attribute MUST be provided and
+ list each of the supported locales in the PPD file</li>
+
+ <li>Main and option keywords MUST NOT exceed 34 (instead of 40)
+ characters to allow room for the locale prefixes in translation
+ attributes</li>
- <li>The <tt>LanguageEncoding</tt> is <tt>ISOLatin1</tt></li>
+ <li>The main keyword "Translation" MUST NOT be used</li>
- <li>Main and option keywords may not exceed 34
- characters, which is a subset of what the Adobe PPD spec
- allows.</li>
+ <li>Translation strings included with the main and option
+ keywords MUST NOT contain characters outside the ASCII
+ subset of ISOLatin1 and UTF-8; developers wishing to use
+ characters outside ASCII MUST provide a separate set of
+ English localization attributes for the affected keywords.</li>
- <li>Translations are specified using a locale prefix of
+ <li>Localizations are specified using a locale prefix of
the form "ll" or "ll_CC." where "ll" is the 2-letter ISO
language code and "CC" is the 2-letter ISO country
code</li>
- <li>Translation strings are encoded using UTF-8.</li>
+ <li>Locale-specific translation strings MUST be encoded
+ using UTF-8.</li>
- <li>Main keywords are translated using any of the
+ <li>Main keywords MUST be localized using one of the
following forms:
<p><tt>*ll.Translation MainKeyword/translation
text: ""</tt><br />
<tt>*ll_CC.Translation MainKeyword/translation
text: ""</tt></p></li>
- <li>Option keywords are translated using any of the
+ <li>Option keywords MUST be localized using one of the
following forms:
<p><tt>*ll.MainKeyword OptionKeyword/translation
text: ""</tt><br />
<tt>*ll_CC.MainKeyword OptionKeyword/translation
text: ""</tt></p></li>
+ <li>Localization attributes MAY appear anywhere after the
+ first line of the PPD file</li>
+
</ol>
-<p>Examples:</p>
+<blockquote><b>Note:</b>
+We use a <tt>LanguageEncoding</tt> value of <tt>ISOLatin1</tt>
+and limit the allowed base translation strings to ASCII to avoid
+character coding issues that would otherwise occur. In addition,
+requiring the base translation strings to be in English allows
+for easier fallback translation when no localization is provided
+in the PPD file for a given locale.</blockquote>
+<p>Examples:</p>
<pre class='command'>
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
+*cupsLanguages: "de_DE fr_FR"
*ModelName: "Foobar Laser 9999"
-<em>*% Localize for French and German</em>
+<em>*% Localize ModelName for French and German</em>
*fr_FR.Translation ModelName/La Foobar Laser 9999: ""
*de_DE.Translation ModelName/Foobar LaserDrucken 9999: ""
*OpenUI *InputSlot/Paper Source: PickOne
*OrderDependency: 10 AnySetup *InputSlot
*DefaultInputSlot: Auto
-<em>*% Localize for French and German</em>
+<em>*% Localize InputSlot for French and German</em>
*fr_FR.Translation InputSlot/Papier source: ""
*de_DE.Translation InputSlot/Papiereinzug: ""
*InputSlot Auto/Default: "<</ManualFeed false>>setpagedevice"
-<em>*% Localize for French and German</em>
+<em>*% Localize InputSlot=Auto for French and German</em>
*fr_FR.InputSlot Auto/Par Defaut: ""
*de_DE.InputSlot Auto/Standard: ""
*InputSlot Manual/Manual Feed: "<</ManualFeed true>>setpagedevice"
-<em>*% Localize for French and German</em>
+<em>*% Localize InputSlot=Manual for French and German</em>
*fr_FR.InputSlot Manual/Manuel mecanisme de alimentation: ""
*de_DE.InputSlot Manual/Manueller Einzug: ""
*CloseUI: *InputSlot
<li>Added custom option values support</li>
+ <li>Added <tt>APDuplexRequiresFlippedMargin</tt> attribute</li>
+
<li>Added <tt>cupsICCProfile</tt> attribute</li>
+ <li>Added <tt>cupsLanguages</tt> attribute</li>
+
<li>Added <tt>cupsPortMonitor</tt> attribute</li>
<li>Removed <tt>cupsProtocol</tt> attribute</li>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Enabled</key>
+ <true/>
+ <key>Label</key>
+ <string>org.cups.cupsd</string>
+ <key>OnDemand</key>
+ <true/>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/usr/sbin/cupsd</string>
+ <string>-l</string>
+ </array>
+ <key>RunAtLoad</key>
+ <true/>
+ <key>ServiceIPC</key>
+ <true/>
+ <key>Sockets</key>
+ <dict>
+ <key>Listeners</key>
+ <array>
+ <dict>
+ <key>SockNodeName</key>
+ <string>localhost</string>
+ <key>SockServiceName</key>
+ <string>ipp</string>
+ </dict>
+ <dict>
+ <key>SockPathMode</key>
+ <integer>49663</integer>
+ <key>SockPathName</key>
+ <string>/private/var/run/cupsd</string>
+ </dict>
+ </array>
+ </dict>
+</dict>
+</plist>
--- /dev/null
+#!/bin/sh
+# This is a dummy script to ensure that the CUPS domain socket is world-
+# writable. This works around a problem in launchd...
+
+if test -e /private/var/run/cupsd; then
+ chmod g+w,o+w /private/var/run/cupsd
+fi
/*
- * "$Id: translate.c 4896 2006-01-08 03:57:45Z mike $"
+ * "$Id: translate.c 5023 2006-01-29 14:39:44Z mike $"
*
* HTTP-based translation program for the Common UNIX Printing System (CUPS).
*
httpPost(http, "/translate_t");
}
- httpWrite(http, buffer, bufptr - buffer);
+ httpWrite2(http, buffer, bufptr - buffer);
while ((status = httpUpdate(http)) == HTTP_CONTINUE);
bufptr = buffer;
bufend = buffer + sizeof(buffer) - 1;
- while ((bytes = httpRead(http, bufptr, bufend - bufptr)) > 0)
+ while ((bytes = httpRead2(http, bufptr, bufend - bufptr)) > 0)
bufptr += bytes;
if (bytes < 0)
/*
- * End of "$Id: translate.c 4896 2006-01-08 03:57:45Z mike $".
+ * End of "$Id: translate.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: client.c 4950 2006-01-19 16:07:57Z mike $"
+ * "$Id: client.c 5023 2006-01-29 14:39:44Z mike $"
*
* Client routines for the Common UNIX Printing System (CUPS) scheduler.
*
* Separate the URI into its components...
*/
- httpSeparateURI(con->uri, method, sizeof(method),
+ httpSeparateURI(HTTP_URI_CODING_MOST, con->uri,
+ method, sizeof(method),
userpass, sizeof(userpass),
hostname, sizeof(hostname), &port,
resource, sizeof(resource));
"CHUNKED" : "LENGTH",
CUPS_LLCAST con->http.data_remaining, con->file);
- if ((bytes = httpRead(HTTP(con), line, sizeof(line))) < 0)
+ if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) < 0)
return (cupsdCloseClient(con));
else if (bytes > 0)
{
if (con->http.state != HTTP_POST_SEND)
{
- if ((bytes = httpRead(HTTP(con), line, sizeof(line))) < 0)
+ if ((bytes = httpRead2(HTTP(con), line, sizeof(line))) < 0)
return (cupsdCloseClient(con));
else if (bytes > 0)
{
}
}
- if (httpWrite(HTTP(con), buf, bytes) < 0)
+ if (httpWrite2(HTTP(con), buf, bytes) < 0)
{
cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsdWriteClient: %d Write of %d bytes failed!",
/*
- * End of "$Id: client.c 4950 2006-01-19 16:07:57Z mike $".
+ * End of "$Id: client.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: conf.c 5008 2006-01-27 19:30:34Z mike $"
+ * "$Id: conf.c 5020 2006-01-28 13:36:15Z mike $"
*
* Configuration routines for the Common UNIX Printing System (CUPS).
*
{ "ServerKey", &ServerKey, CUPSD_VARTYPE_STRING },
# endif /* HAVE_LIBSSL || HAVE_GNUTLS */
#endif /* HAVE_SSL */
+#ifdef HAVE_LAUNCHD
+ { "LaunchdTimeout", &LaunchdTimeout, CUPSD_VARTYPE_INTEGER },
+ { "LaunchdConf", &LaunchdConf, CUPSD_VARTYPE_STRING },
+#endif /* HAVE_LAUNCHD */
{ "ServerName", &ServerName, CUPSD_VARTYPE_STRING },
{ "ServerRoot", &ServerRoot, CUPSD_VARTYPE_STRING },
{ "StateDir", &StateDir, CUPSD_VARTYPE_STRING },
char *old_serverroot, /* Old ServerRoot */
*old_requestroot; /* Old RequestRoot */
- /*
- * Shutdown the server...
- */
-
- cupsdStopServer();
-
/*
* Save the old root paths...
*/
DefaultLeaseDuration = 86400;
MaxLeaseDuration = 0;
+#ifdef HAVE_LAUNCHD
+ LaunchdTimeout = DEFAULT_TIMEOUT + 10;
+ cupsdSetString(&LaunchdConf, CUPS_DEFAULT_LAUNCHD_CONF);
+#endif /* HAVE_LAUNCHD */
+
/*
* Read the configuration file...
*/
cupsdClearString(&old_serverroot);
cupsdClearString(&old_requestroot);
- /*
- * Startup the server and return...
- */
-
- cupsdStartServer();
-
return (1);
}
memset(lis, 0, sizeof(cupsd_listener_t));
memcpy(&(lis->address), &(addr->addr), sizeof(lis->address));
+ lis->fd = -1;
#ifdef HAVE_SSL
if (!strcasecmp(line, "SSLPort") || !strcasecmp(line, "SSLListen"))
lis->encryption = HTTP_ENCRYPT_ALWAYS;
#endif /* HAVE_SSL */
+
+ httpAddrString(&lis->address, temp, sizeof(temp));
+
#ifdef AF_INET6
if (lis->address.addr.sa_family == AF_INET6)
cupsdLogMessage(CUPSD_LOG_INFO, "Listening to %s:%d (IPv6)", temp,
/*
- * End of "$Id: conf.c 5008 2006-01-27 19:30:34Z mike $".
+ * End of "$Id: conf.c 5020 2006-01-28 13:36:15Z mike $".
*/
/*
- * "$Id: conf.h 4988 2006-01-26 00:53:00Z mike $"
+ * "$Id: conf.h 5020 2006-01-28 13:36:15Z mike $"
*
* Configuration file definitions for the Common UNIX Printing System (CUPS)
* scheduler.
# endif /* HAVE_LIBSSL || HAVE_GNUTLS */
#endif /* HAVE_SSL */
+#ifdef HAVE_LAUNCHD
+VAR int LaunchdTimeout VALUE(DEFAULT_TIMEOUT);
+ /* Time after which an idle cupsd will exit */
+VAR char *LaunchdConf VALUE(NULL);
+ /* launchd(8) configuration file */
+#endif /* HAVE_LAUNCHD */
/*
* Prototypes...
/*
- * End of "$Id: conf.h 4988 2006-01-26 00:53:00Z mike $".
+ * End of "$Id: conf.h 5020 2006-01-28 13:36:15Z mike $".
*/
/*
- * "$Id: cups-lpd.c 4807 2005-10-21 19:17:52Z mike $"
+ * "$Id: cups-lpd.c 5023 2006-01-29 14:39:44Z mike $"
*
* Line Printer Daemon interface for the Common UNIX Printing System (CUPS).
*
request->request.op.operation_id = IPP_GET_PRINTER_ATTRIBUTES;
request->request.op.request_id = 1;
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", name);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", name);
language = cupsLangDefault();
request->request.op.operation_id = IPP_PRINT_JOB;
request->request.op.request_id = 1;
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", name);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", name);
language = cupsLangDefault();
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language", NULL, language->language);
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", queue);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", queue);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
"attributes-natural-language", NULL, language->language);
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", queue);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", queue);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
NULL, uri);
/*
- * End of "$Id: cups-lpd.c 4807 2005-10-21 19:17:52Z mike $".
+ * End of "$Id: cups-lpd.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: dirsvc.c 5008 2006-01-27 19:30:34Z mike $"
+ * "$Id: dirsvc.c 5023 2006-01-29 14:39:44Z mike $"
*
* Directory services routines for the Common UNIX Printing System (CUPS).
*
* Pull the URI apart to see if this is a local or remote printer...
*/
- httpSeparateURI(uri, method, sizeof(method), username, sizeof(username),
- host, sizeof(host), &port, resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), username,
+ sizeof(username), host, sizeof(host), &port, resource,
+ sizeof(resource));
/*
* Determine if the URI contains any illegal characters in it...
iface->address.addr.sa_family != AF_INET)
continue;
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, iface->hostname,
- iface->port,
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ iface->hostname, iface->port,
(p->type & CUPS_PRINTER_CLASS) ? "/classes/%s%s" :
"/printers/%s",
p->name);
if (iface)
{
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, iface->hostname,
- iface->port,
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ iface->hostname, iface->port,
(p->type & CUPS_PRINTER_CLASS) ? "/classes/%s%s" :
"/printers/%s",
p->name);
* Pull the URI apart to see if this is a local or remote printer...
*/
- httpSeparateURI(uri, method, sizeof(method), username, sizeof(username),
- host, sizeof(host), &port, resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), username,
+ sizeof(username), host, sizeof(host), &port, resource,
+ sizeof(resource));
DEBUG_printf(("host=\"%s\", ServerName=\"%s\"\n", host, ServerName));
* Pull the URI apart to see if this is a local or remote printer...
*/
- httpSeparateURI(uri, method, sizeof(method), username, sizeof(username),
- host, sizeof(host), &port, resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method),
+ username, sizeof(username), host, sizeof(host), &port,
+ resource, sizeof(resource));
if (strcasecmp(host, ServerName) == 0)
continue;
/*
- * End of "$Id: dirsvc.c 5008 2006-01-27 19:30:34Z mike $".
+ * End of "$Id: dirsvc.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: dirsvc.h 4822 2005-11-04 21:13:20Z mike $"
+ * "$Id: dirsvc.h 5020 2006-01-28 13:36:15Z mike $"
*
* Directory services definitions for the Common UNIX Printing System
* (CUPS) scheduler.
#define BROWSE_CUPS 1 /* CUPS */
#define BROWSE_SLP 2 /* SLPv2 */
#define BROWSE_LDAP 4 /* LDAP (not supported yet) */
-#define BROWSE_ALL 7 /* All protocols */
+#define BROWSE_DNSSD 8 /* DNS Service Discovery aka Bonjour */
+#define BROWSE_ALL 15 /* All protocols */
/*
/*
- * End of "$Id: dirsvc.h 4822 2005-11-04 21:13:20Z mike $".
+ * End of "$Id: dirsvc.h 5020 2006-01-28 13:36:15Z mike $".
*/
/*
- * "$Id: ipp.c 4995 2006-01-26 20:14:42Z mike $"
+ * "$Id: ipp.c 5023 2006-01-29 14:39:44Z mike $"
*
* IPP routines for the Common UNIX Printing System (CUPS) scheduler.
*
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Do we have a valid URI?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/classes/", 9) || strlen(resource) == 9)
* Search for the printer or class URI...
*/
- httpSeparateURI(attr->values[i].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[i].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &member)) == NULL)
{
* Do we have a valid URI?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/printers/", 10) || strlen(resource) == 10)
{
* Do we have a valid device URI?
*/
- httpSeparateURI(attr->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(method, "file"))
{
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
* And if the destination is valid...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- userpass, sizeof(userpass), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), userpass, sizeof(userpass), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Find the current job on the specified printer...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
* Send the requested attributes for each job...
*/
- httpAssembleURIf(job_uri, sizeof(job_uri), "ipp", NULL,
+ httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
con->servername, con->serverport, "/jobs/%d",
job->id);
!ippFindAttribute(printer->attrs, "printer-uri-supported",
IPP_TAG_URI))
{
- httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL,
- con->servername, con->serverport, "/printers/%s",
- printer->name);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+ "ipp", NULL, con->servername, con->serverport,
+ "/printers/%s", printer->name);
ippAddString(con->response, IPP_TAG_PRINTER, IPP_TAG_URI,
"printer-uri-supported", NULL, printer_uri);
cupsdLogMessage(CUPSD_LOG_DEBUG2, "printer-uri-supported=\"%s\"",
if (sub->dest && (!ra || cupsArrayFind(ra, "notify-printer-uri")))
{
- httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL,
- con->servername, con->serverport, "/printers/%s",
- sub->dest->name);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+ "ipp", NULL, con->servername, con->serverport,
+ "/printers/%s", sub->dest->name);
ippAddString(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
"notify-printer-uri", NULL, printer_uri);
}
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
"cupsdCreateSubscription(con=%p(%d), uri=\"%s\")",
con, con->http.fd, uri->values[0].string.text);
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- userpass, sizeof(userpass), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), userpass, sizeof(userpass), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(resource, "/"))
{
* Do we have a valid URI?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(resource, "/") ||
(!strncmp(resource, "/jobs", 5) && strlen(resource) <= 6))
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(resource, "/") ||
(!strncmp(resource, "/jobs", 5) && strlen(resource) <= 6) ||
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
return;
}
- httpSeparateURI(attr->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &dprinter)) == NULL)
{
* See if we have a job URI or a printer URI...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (!strcmp(uri->name, "printer-uri"))
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Got a job URI; parse it to get the job ID...
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (strncmp(resource, "/jobs/", 6))
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((name = cupsdValidateDest(host, resource, &dtype, &printer)) == NULL)
{
* Is the destination valid?
*/
- httpSeparateURI(uri->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if (cupsdValidateDest(host, resource, &dtype, &printer) == NULL)
{
/*
- * 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 $".
*/
/*
- * "$Id: job.c 5007 2006-01-27 18:25:42Z mike $"
+ * "$Id: job.c 5023 2006-01-29 14:39:44Z mike $"
*
* Job management routines for the Common UNIX Printing System (CUPS).
*
continue;
}
- httpSeparateURI(attr->values[0].string.text, method, sizeof(method),
- username, sizeof(username), host, sizeof(host), &port,
- resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, attr->values[0].string.text, method,
+ sizeof(method), username, sizeof(username), host,
+ sizeof(host), &port, resource, sizeof(resource));
if ((dest = cupsdValidateDest(host, resource, &(job->dtype),
NULL)) == NULL)
/*
- * End of "$Id: job.c 5007 2006-01-27 18:25:42Z mike $".
+ * End of "$Id: job.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: listen.c 4780 2005-10-13 00:38:28Z mike $"
+ * "$Id: listen.c 5020 2006-01-28 13:36:15Z mike $"
*
* Server listening routines for the Common UNIX Printing System (CUPS)
* scheduler.
p = ntohs(lis->address.ipv4.sin_port);
/*
- * Create a socket for listening...
+ * If needed, create a socket for listening...
*/
- lis->fd = socket(lis->address.addr.sa_family, SOCK_STREAM, 0);
-
if (lis->fd == -1)
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdStartListening: Unable to open listen socket for address %s:%d - %s.",
- s, p, strerror(errno));
- continue;
- }
-
- fcntl(lis->fd, F_SETFD, fcntl(lis->fd, F_GETFD) | FD_CLOEXEC);
-
- /*
- * Set things up to reuse the local address for this port.
- */
-
- val = 1;
-#ifdef __sun
- setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
-#else
- setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
-#endif /* __sun */
-
- /*
- * Bind to the port we found...
- */
-
-#ifdef AF_INET6
- if (lis->address.addr.sa_family == AF_INET6)
- {
-# ifdef IPV6_V6ONLY
- /*
- * Accept only IPv6 connections on this socket, to avoid
- * potential security issues and to make all platforms behave
- * the same.
- */
-
- val = 1;
-# ifdef __sun
- setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&val, sizeof(val));
-# else
- setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));
-# endif /* __sun */
-# endif /* IPV6_V6ONLY */
-
- status = bind(lis->fd, (struct sockaddr *)&(lis->address),
- httpAddrLength(&(lis->address)));
- }
- else
-#endif /* AF_INET6 */
-#ifdef AF_LOCAL
- if (lis->address.addr.sa_family == AF_LOCAL)
- {
- mode_t mask; /* Umask setting */
-
-
/*
- * Remove any existing domain socket file...
+ * Create a socket for listening...
*/
-
- unlink(lis->address.un.sun_path);
-
+
+ lis->fd = socket(lis->address.addr.sa_family, SOCK_STREAM, 0);
+
+ if (lis->fd == -1)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartListening: Unable to open listen socket for address %s:%d - %s.",
+ s, p, strerror(errno));
+ continue;
+ }
+
/*
- * Save the curent umask and set it to 0...
+ * Set things up to reuse the local address for this port.
*/
-
- mask = umask(0);
-
+
+ val = 1;
+ #ifdef __sun
+ setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
+ #else
+ setsockopt(lis->fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+ #endif /* __sun */
+
/*
- * Bind the domain socket...
+ * Bind to the port we found...
*/
-
+
+ #ifdef AF_INET6
+ if (lis->address.addr.sa_family == AF_INET6)
+ {
+ # ifdef IPV6_V6ONLY
+ /*
+ * Accept only IPv6 connections on this socket, to avoid
+ * potential security issues and to make all platforms behave
+ * the same.
+ */
+
+ val = 1;
+ # ifdef __sun
+ setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&val, sizeof(val));
+ # else
+ setsockopt(lis->fd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));
+ # endif /* __sun */
+ # endif /* IPV6_V6ONLY */
+
+ status = bind(lis->fd, (struct sockaddr *)&(lis->address),
+ httpAddrLength(&(lis->address)));
+ }
+ else
+ #endif /* AF_INET6 */
+ #ifdef AF_LOCAL
+ if (lis->address.addr.sa_family == AF_LOCAL)
+ {
+ mode_t mask; /* Umask setting */
+
+
+ /*
+ * Remove any existing domain socket file...
+ */
+
+ unlink(lis->address.un.sun_path);
+
+ /*
+ * Save the curent umask and set it to 0...
+ */
+
+ mask = umask(0);
+
+ /*
+ * Bind the domain socket...
+ */
+
+ status = bind(lis->fd, (struct sockaddr *)&(lis->address),
+ httpAddrLength(&(lis->address)));
+
+ /*
+ * Restore the umask...
+ */
+
+ umask(mask);
+ }
+ else
+ #endif /* AF_LOCAL */
status = bind(lis->fd, (struct sockaddr *)&(lis->address),
- httpAddrLength(&(lis->address)));
-
+ sizeof(lis->address.ipv4));
+
+ if (status < 0)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartListening: Unable to bind socket for address %s:%d - %s.",
+ s, p, strerror(errno));
+ close(lis->fd);
+ lis->fd = -1;
+ continue;
+ }
+
/*
- * Restore the umask...
+ * Listen for new clients.
*/
-
- umask(mask);
+
+ if (listen(lis->fd, ListenBackLog) < 0)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "cupsdStartListening: Unable to listen for clients on address %s:%d - %s.",
+ s, p, strerror(errno));
+ exit(errno);
+ }
}
- else
-#endif /* AF_LOCAL */
- status = bind(lis->fd, (struct sockaddr *)&(lis->address),
- sizeof(lis->address.ipv4));
- if (status < 0)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdStartListening: Unable to bind socket for address %s:%d - %s.",
- s, p, strerror(errno));
- close(lis->fd);
- lis->fd = -1;
- continue;
- }
-
- /*
- * Listen for new clients.
- */
-
- if (listen(lis->fd, ListenBackLog) < 0)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "cupsdStartListening: Unable to listen for clients on address %s:%d - %s.",
- s, p, strerror(errno));
- exit(errno);
- }
+ fcntl(lis->fd, F_SETFD, fcntl(lis->fd, F_GETFD) | FD_CLOEXEC);
+
if (p)
cupsdLogMessage(CUPSD_LOG_INFO,
for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
{
+ if (lis->fd != -1)
+ {
#ifdef WIN32
- closesocket(lis->fd);
+ closesocket(lis->fd);
#else
- close(lis->fd);
+ close(lis->fd);
#endif /* WIN32 */
#ifdef AF_LOCAL
* Remove domain sockets...
*/
- if (lis->address.addr.sa_family == AF_LOCAL)
- unlink(lis->address.un.sun_path);
+ if (lis->address.addr.sa_family == AF_LOCAL)
+ unlink(lis->address.un.sun_path);
#endif /* AF_LOCAL */
+ }
}
}
/*
- * End of "$Id: listen.c 4780 2005-10-13 00:38:28Z mike $".
+ * End of "$Id: listen.c 5020 2006-01-28 13:36:15Z mike $".
*/
/*
- * "$Id: main.c 5007 2006-01-27 18:25:42Z mike $"
+ * "$Id: main.c 5023 2006-01-29 14:39:44Z mike $"
*
* Scheduler main loop for the Common UNIX Printing System (CUPS).
*
* cupsdReleaseSignals() - Release signals for delivery.
* cupsdSetString() - Set a string value.
* cupsdSetStringf() - Set a formatted string value.
+ * launchd_checkin() - Check-in with launchd and collect the
+ * listening fds.
+ * launchd_reload() - Tell launchd to reload the configuration
+ * file to pick up the new listening directives.
+ * launchd_sync_conf() - Re-write the launchd(8) config file
+ * com.easysw.cupsd.plist based on cupsd.conf.
* parent_handler() - Catch USR1/CHLD signals...
* process_children() - Process all dead children...
* sigchld_handler() - Handle 'child' signals from old processes.
#include <syslog.h>
#include <grp.h>
+#ifdef HAVE_LAUNCH_H
+# include <launch.h>
+# include <libgen.h>
+#endif /* HAVE_LAUNCH_H */
+
#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
# include <malloc.h>
#endif /* HAVE_MALLOC_H && HAVE_MALLINFO */
* Local functions...
*/
+#ifdef HAVE_LAUNCHD
+static void launchd_checkin(void);
+static void launchd_reload(void);
+static int launchd_sync_conf(void);
+#endif /* HAVE_LAUNCHD */
+
static void parent_handler(int sig);
static void process_children(void);
static void sigchld_handler(int sig);
static void sighup_handler(int sig);
static void sigterm_handler(int sig);
static long select_timeout(int fds);
-static void usage(void);
+static void usage(int status);
/*
cupsd_job_t *job; /* Current job */
cupsd_listener_t *lis; /* Current listener */
time_t current_time, /* Current time */
- activity, /* Activity timer */
+ activity, /* Client activity timer */
browse_time, /* Next browse send time */
senddoc_time, /* Send-Document time */
expire_time; /* Subscription expire time */
cups_file_t *fp; /* Fake lpsched lock file */
struct stat statbuf; /* Needed for checking lpsched FIFO */
#endif /* __sgi */
+#if HAVE_LAUNCHD
+ int launchd, /* Started with the -l option? */
+ launchd_idle_exit;
+ /* Idle exit on select timeout? */
+#endif /* HAVE_LAUNCHD */
/*
* Check for command-line arguments...
*/
- fg = 0;
+ fg = 0;
+#if HAVE_LAUNCHD
+ launchd = 0;
+#endif /* HAVE_LAUNCHD */
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
case 'c' : /* Configuration file */
i ++;
if (i >= argc)
- usage();
+ {
+ _cupsLangPuts(stderr, _("cupsd: Expected config filename "
+ "after \"-c\" option!\n"));
+ usage(1);
+ }
if (argv[i][0] == '/')
{
fg = -1;
break;
+ case 'h' : /* Show usage/help */
+ usage(0);
+ break;
+
+ case 'l' : /* Started by launchd... */
+#ifdef HAVE_LAUNCHD
+ launchd = 1;
+ fg = 1;
+#else
+ _cupsLangPuts(stderr, _("cupsd: launchd(8) support not compiled "
+ "in, running in normal mode.\n"));
+ fg = 0;
+#endif /* HAVE_LAUNCHD */
+ break;
+
default : /* Unknown option */
- fprintf(stderr, "cupsd: Unknown option \'%c\' - aborting!\n",
- *opt);
- usage();
+ _cupsLangPrintf(stderr, _("cupsd: Unknown option \"%c\" - "
+ "aborting!\n"), *opt);
+ usage(1);
break;
}
else
{
- fprintf(stderr, "cupsd: Unknown argument \'%s\' - aborting!\n", argv[i]);
- usage();
+ _cupsLangPrintf(stderr, _("cupsd: Unknown argument \"%s\" - aborting!\n"),
+ argv[i]);
+ usage(1);
}
if (!ConfigurationFile)
return (1);
}
+#if HAVE_LAUNCHD
+ if (launchd)
+ {
+ /*
+ * If we were started by launchd make sure the cupsd plist file contains the
+ * same listeners as cupsd.conf; If it didn't then reload it before getting
+ * the list of listening file descriptors...
+ */
+
+ if (launchd_sync_conf())
+ {
+ launchd_reload();
+
+ /*
+ * Until rdar://3854821 is fixed we have to exit after the reload...
+ */
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "Exiting on launchd_reload");
+ exit(0);
+ }
+
+ launchd_checkin();
+ }
+#endif /* HAVE_LAUNCHD */
+
+ /*
+ * Startup the server...
+ */
+
+ cupsdStartServer();
+
/*
* Catch hangup and child signals and ignore broken pipes...
*/
if ((NumClients == 0 && (!job || NeedReload != RELOAD_ALL)) ||
(time(NULL) - ReloadTime) >= ReloadTimeout)
{
+ /*
+ * Shutdown the server...
+ */
+
+ cupsdStopServer();
+
+ /*
+ * Read configuration...
+ */
+
if (!cupsdReadConfiguration())
{
syslog(LOG_LPR, "Unable to read configuration file \'%s\' - exiting!",
ConfigurationFile);
break;
}
+
+#if HAVE_LAUNCHD
+ if (launchd)
+ {
+ if (launchd_sync_conf())
+ {
+ launchd_reload();
+
+ /*
+ * Until rdar://3854821 is fixed we have to exit after the reload...
+ */
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "Exiting on launchd_reload");
+ stop_scheduler = 1;
+ break;
+ }
+
+ launchd_checkin();
+ }
+#endif /* HAVE_LAUNCHD */
+
+ /*
+ * Startup the server...
+ */
+
+ cupsdStartServer();
}
}
timeout.tv_sec = select_timeout(fds);
timeout.tv_usec = 0;
+#if HAVE_LAUNCHD
+ /*
+ * If no other work is scheduled and we're being controlled by
+ * launchd(8) then timeout after 'LaunchdTimeout' seconds of
+ * inactivity...
+ */
+
+ if (timeout.tv_sec == 86400 && launchd && LaunchdTimeout &&
+ (!Browsing || !(BrowseLocalProtocols & BROWSE_DNSSD) ||
+ cupsArrayCount(Printers) == 0))
+ {
+ timeout.tv_sec = LaunchdTimeout;
+ launchd_idle_exit = 1;
+ }
+ else
+ launchd_idle_exit = 0;
+#endif /* HAVE_LAUNCHD */
+
if (timeout.tv_sec < 86400) /* Only use timeout for < 1 day */
fds = select(MaxFDs, input, output, NULL, &timeout);
else
current_time = time(NULL);
+#if HAVE_LAUNCHD
+ /*
+ * If no other work was scheduled and we're being controlled by launchd(8)
+ * then timeout after 'LaunchdTimeout' seconds of inactivity...
+ */
+
+ if (!fds && launchd_idle_exit)
+ {
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Printer sharing is off and there are no jobs pending, "
+ "will restart on demand.");
+ stop_scheduler = 1;
+ break;
+ }
+#endif /* HAVE_LAUNCHD */
+
/*
* Check for status info from job filters...
*/
cupsdStopSystemMonitor();
+#ifdef HAVE_LAUNCHD
+ /*
+ * Update the launchd config file as needed...
+ */
+
+ launchd_sync_conf();
+#endif /* HAVE_LAUNCHD */
+
#ifdef __sgi
/*
* Remove the fake IRIX lpsched lock file, but only if the existing
}
+#ifdef HAVE_LAUNCHD
+/*
+ * 'launchd_checkin()' - Check-in with launchd and collect the listening fds.
+ */
+
+static void
+launchd_checkin(void)
+{
+ int i, /* Looping var */
+ portnum; /* Port number */
+ launch_data_t ld_msg, /* Launch data message */
+ ld_resp, /* Launch data response */
+ ld_array, /* Launch data array */
+ ld_sockets, /* Launch data sockets dictionary */
+ ld_runatload, /* Run-at-load setting */
+ tmp; /* Launch data */
+ cupsd_listener_t *lis; /* Listeners array */
+ http_addr_t addr; /* Address variable */
+ socklen_t addrlen; /* Length of address */
+ bool runatload; /* Run-at-load setting value */
+
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: pid=%d", (int)getpid());
+
+ /*
+ * Check-in with launchd...
+ */
+
+ ld_msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
+ if ((ld_resp = launch_msg(ld_msg)) == NULL)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_checkin: launch_msg(\"" LAUNCH_KEY_CHECKIN
+ "\") IPC failure");
+ exit(EXIT_FAILURE);
+ }
+
+ if (launch_data_get_type(ld_resp) == LAUNCH_DATA_ERRNO)
+ {
+ errno = launch_data_get_errno(ld_resp);
+ cupsdLogMessage(CUPSD_LOG_ERROR, "launchd_checkin: Check-in failed: %s",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Get the "run-at-load" setting...
+ */
+
+ if ((ld_runatload = launch_data_dict_lookup(ld_resp,
+ LAUNCH_JOBKEY_RUNATLOAD)) != NULL &&
+ launch_data_get_type(ld_runatload) == LAUNCH_DATA_BOOL)
+ runatload = launch_data_get_bool(ld_runatload);
+ else
+ {
+ errno = launch_data_get_errno(ld_resp);
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_checkin: Unable to find Run-at-load setting: %s",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: Run-at-load=%s",
+ runatload ? "true" : "false");
+
+ /*
+ * Get the sockets dictionary...
+ */
+
+ if (!(ld_sockets = launch_data_dict_lookup(ld_resp, LAUNCH_JOBKEY_SOCKETS)))
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_checkin: No sockets found to answer requests on!");
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Get the array of listener sockets...
+ */
+
+ if (!(ld_array = launch_data_dict_lookup(ld_sockets, "Listeners")))
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_checkin: No sockets found to answer requests on!");
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Add listening fd(s) to the Listener array...
+ */
+
+ if (launch_data_get_type(ld_array) == LAUNCH_DATA_ARRAY)
+ {
+ /*
+ * Free the listeners array built from cupsd.conf...
+ */
+
+ if (NumListeners > 0)
+ free(Listeners);
+
+ NumListeners = launch_data_array_get_count(ld_array);
+ Listeners = calloc(NumListeners, sizeof(cupsd_listener_t));
+
+ if (!Listeners)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_checkin: Unable to allocate new Listeners - %s.",
+ strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ /*
+ * Note: launchd wants us to access the array in ascending order,
+ * thus "i" counts up and not down as we normally do elsewhere...
+ */
+
+ for (i = 0, lis = Listeners; i < NumListeners; i ++, lis ++)
+ {
+ /*
+ * Copy the current address and log it...
+ */
+
+ tmp = launch_data_array_get_index(ld_array, i);
+ lis->fd = launch_data_get_fd(tmp);
+ addrlen = sizeof(lis->address);
+
+ if (getsockname(lis->fd, (struct sockaddr *)&(lis->address), &addrlen))
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_checkin: Unable to get local address - %s",
+ strerror(errno));
+ }
+
+# ifdef HAVE_SSL
+ portnum = 0;
+
+# ifdef AF_INET6
+ if (addr.addr.sa_family == AF_INET6)
+ portnum = ntohs(addr.ipv6.sin6_port);
+ else
+# endif /* AF_INET6 */
+# ifdef AF_LOCAL
+ if (addr.addr.sa_family == AF_LOCAL)
+ {
+ /*
+ * Make sure the domain socket is accessible to all...
+ */
+
+ fchmod(lis->fd, 0140777);
+ }
+ else
+# endif /* AF_LOCAL */
+ if (addr.addr.sa_family == AF_INET)
+ portnum = ntohs(addr.ipv4.sin_port);
+
+ if (portnum == 443)
+ lis->encryption = HTTP_ENCRYPT_ALWAYS;
+# endif /* HAVE_SSL */
+ }
+ }
+
+ /*
+ * Collect the browse socket (if there is one)...
+ */
+
+ if ((ld_array = launch_data_dict_lookup(ld_sockets, "BrowseSockets")))
+ {
+ if (launch_data_get_type(ld_array) == LAUNCH_DATA_ARRAY)
+ {
+ tmp = launch_data_array_get_index(ld_array, 0);
+
+ if (launch_data_get_type(tmp) == LAUNCH_DATA_FD)
+ {
+ if (BrowseSocket != -1)
+ close(BrowseSocket);
+
+ BrowseSocket = launch_data_get_fd(tmp);
+ }
+ else
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "launchd_checkin: BrowseSocket not a fd!");
+ }
+ else
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "launchd_checkin: BrowseSockets is not an array!");
+ }
+ else
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "launchd_checkin: No BrowseSockets");
+
+ launch_data_free(ld_msg);
+ launch_data_free(ld_resp);
+}
+
+
+/*
+ * 'launchd_reload()' - Tell launchd to reload the configuration file to pick
+ * up the new listening directives.
+ */
+
+static void
+launchd_reload(void)
+{
+ int child_status; /* Exit status of child process */
+ pid_t child_pid, /* Child PID */
+ waitpid_status; /* Child process exit status */
+ char *argv[4]; /* Argument strings */
+
+
+ /*
+ * The current launchd doesn't support a reload option (rdar://3854821).
+ * Until this is fixed we need to reload the config file by execing launchctl
+ * twice (to unload then load). NOTE: This will cause us to exit on SIGTERM
+ * which will cancel all client & job activity.
+ *
+ * After this is fixed we'll be able to tell launchd to reload the file
+ * and pick up the new listening descriptors without disrupting current
+ * activity.
+ */
+
+ /*
+ * Unloading the current configuration will cause launchd to send us a SIGTERM;
+ * block it for now so we can get our work done...
+ */
+
+ cupsdHoldSignals();
+
+ /*
+ * Set up the unload arguments to launchctl...
+ */
+
+ argv[0] = "/bin/launchctl";
+ argv[1] = "unload";
+ argv[2] = LaunchdConf;
+ argv[3] = NULL;
+
+ if (cupsdStartProcess(argv[0], argv, NULL, -1, -1, -1, -1, 1, &child_pid) < 0)
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_reload: Unable to execute %s - %s", argv[0],
+ strerror(errno));
+ else
+ {
+ do
+ {
+ waitpid_status = waitpid(child_pid, &child_status, 0);
+ }
+ while (waitpid_status == (pid_t)-1 && errno == EINTR);
+
+ if (WIFSIGNALED(child_status))
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "launchd_reload: %s pid %d crashed on signal %d!",
+ basename(argv[0]), child_pid, WTERMSIG(child_status));
+ else
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "launchd_reload: %s pid %d stopped with status %d!",
+ basename(argv[0]), child_pid, WEXITSTATUS(child_status));
+
+ /*
+ * Do it again with the load command...
+ */
+
+ argv[1] = "load";
+
+ if (cupsdStartProcess(argv[0], argv, NULL, -1, -1, -1, -1, 1,
+ &child_pid) < 0)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR,
+ "launchd_reload: Unable to fork for %s - %s", argv[0],
+ strerror(errno));
+ }
+ else
+ {
+ do
+ {
+ waitpid_status = waitpid(child_pid, &child_status, 0);
+ } while (waitpid_status == (pid_t)-1 && errno == EINTR);
+
+ if (WIFSIGNALED(child_status))
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "launchd_reload: %s pid %d crashed on signal %d!",
+ basename(argv[0]), child_pid, WTERMSIG(child_status));
+ else
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "launchd_reload: %s pid %d stopped with status %d",
+ basename(argv[0]), child_pid,
+ WEXITSTATUS(child_status));
+ }
+ }
+
+ /*
+ * Leave signals blocked since exit() will be called momentarily anyways...
+ */
+}
+
+
+/*
+ * 'launchd_sync_conf()' - Re-write the launchd(8) config file
+ * org.cups.cupsd.plist based on cupsd.conf.
+ */
+
+static int /* O - 1 if the file was updated */
+launchd_sync_conf(void)
+{
+ int i, /* Looping var */
+ portnum; /* Port number */
+ CFMutableDictionaryRef cupsd_dict, /* com.easysw.cupsd.plist dictionary */
+ sockets, /* Sockets dictionary */
+ listener; /* Listener dictionary */
+ CFDataRef resourceData; /* XML representation of the property list */
+ CFMutableArrayRef array; /* Array */
+ CFNumberRef socket_mode; /* Domain socket mode bits */
+ CFStringRef socket_path; /* Domain socket path */
+ CFTypeRef value; /* CF value */
+ CFURLRef fileURL; /* File URL */
+ SInt32 errorCode; /* Error code */
+ cupsd_listener_t *lis; /* Current listening socket */
+ struct servent *service; /* Services data base entry */
+ char temp[1024]; /* Temporary buffer for value */
+ struct stat cupsd_sb, /* File info for cupsd.conf */
+ launchd_sb; /* File info for com.easysw.cupsd.plist */
+
+
+ /*
+ * If the launchd conf file modification time is newer than the cupsd.conf
+ * time then there's nothing to do...
+ */
+
+ if (!stat(ConfigurationFile, &cupsd_sb) &&
+ !stat(LaunchdConf, &launchd_sb) &&
+ launchd_sb.st_mtimespec.tv_sec >= cupsd_sb.st_mtimespec.tv_sec)
+ {
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "launchd_sync_conf: Nothing to do, pid=%d.",
+ (int)getpid());
+ return (0);
+ }
+
+ /*
+ * Time to write a new 'com.easysw.cupsd.plist' file.
+ * Create the new dictionary and populate it with values...
+ */
+
+ if ((cupsd_dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks)) != NULL)
+ {
+ CFDictionaryAddValue(cupsd_dict, CFSTR("Label"), CFSTR("org.cups.cupsd"));
+ CFDictionaryAddValue(cupsd_dict, CFSTR("Enabled"), kCFBooleanTrue);
+ CFDictionaryAddValue(cupsd_dict, CFSTR("OnDemand"), kCFBooleanTrue);
+
+ if ((Browsing && BrowseLocalProtocols && cupsArrayCount(Printers)) ||
+ cupsArrayCount(ActiveJobs))
+ CFDictionaryAddValue(cupsd_dict, CFSTR("RunAtLoad"), kCFBooleanTrue);
+ else
+ CFDictionaryAddValue(cupsd_dict, CFSTR("RunAtLoad"), kCFBooleanFalse);
+
+ CFDictionaryAddValue(cupsd_dict, CFSTR("ServiceIPC"), kCFBooleanTrue);
+
+ if ((array = CFArrayCreateMutable(kCFAllocatorDefault, 2,
+ &kCFTypeArrayCallBacks)) != NULL)
+ {
+ CFDictionaryAddValue(cupsd_dict, CFSTR("ProgramArguments"), array);
+ CFArrayAppendValue(array, CFSTR("/usr/sbin/cupsd"));
+ CFArrayAppendValue(array, CFSTR("-l"));
+ CFRelease(array);
+ }
+
+ /*
+ * Add a sockets dictionary...
+ */
+
+ if ((sockets = (CFMutableDictionaryRef)CFDictionaryCreateMutable(
+ kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks)) != NULL)
+ {
+ CFDictionaryAddValue(cupsd_dict, CFSTR("Sockets"), sockets);
+
+ /*
+ * Add a Listeners array to the sockets dictionary...
+ */
+
+ if ((array = CFArrayCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeArrayCallBacks)) != NULL)
+ {
+ CFDictionaryAddValue(sockets, CFSTR("Listeners"), array);
+
+ /*
+ * For each listener add a dictionary to the listeners array...
+ */
+
+ for (i = NumListeners, lis = Listeners; i > 0; i --, lis ++)
+ {
+ if ((listener = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks)) != NULL)
+ {
+ CFArrayAppendValue(array, listener);
+
+# ifdef AF_LOCAL
+ if (lis->address.addr.sa_family == AF_LOCAL)
+ {
+ if ((socket_path = CFStringCreateWithCString(kCFAllocatorDefault,
+ lis->address.un.sun_path,
+ kCFStringEncodingUTF8)))
+ {
+ CFDictionaryAddValue(listener, CFSTR("SockPathName"),
+ socket_path);
+ CFRelease(socket_path);
+ }
+ portnum = 0140777; /* (S_IFSOCK|S_IRWXU|S_IRWXG|S_IRWXO) or *
+ * 49663d decimal */
+ if ((socket_mode = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberIntType, &portnum)))
+ {
+ CFDictionaryAddValue(listener, CFSTR("SockPathMode"),
+ socket_mode);
+ CFRelease(socket_mode);
+ }
+ }
+ else
+# endif /* AF_LOCAL */
+ {
+# ifdef AF_INET6
+ if (lis->address.addr.sa_family == AF_INET6)
+ {
+ CFDictionaryAddValue(listener, CFSTR("SockFamily"),
+ CFSTR("IPv6"));
+ portnum = lis->address.ipv6.sin6_port;
+ }
+ else
+# endif /* AF_INET6 */
+ {
+ CFDictionaryAddValue(listener, CFSTR("SockFamily"),
+ CFSTR("IPv4"));
+ portnum = lis->address.ipv4.sin_port;
+ }
+
+ if ((service = getservbyport(portnum, NULL)))
+ value = CFStringCreateWithCString(kCFAllocatorDefault,
+ service->s_name,
+ kCFStringEncodingUTF8);
+ else
+ value = CFNumberCreate(kCFAllocatorDefault,
+ kCFNumberIntType, &portnum);
+
+ if (value)
+ {
+ CFDictionaryAddValue(listener, CFSTR("SockServiceName"), value);
+ CFRelease(value);
+ }
+
+ httpAddrString(&lis->address, temp, sizeof(temp));
+ if ((value = CFStringCreateWithCString(kCFAllocatorDefault, temp,
+ kCFStringEncodingUTF8)))
+ {
+ CFDictionaryAddValue(listener, CFSTR("SockNodeName"), value);
+ CFRelease(value);
+ }
+ }
+
+ CFRelease(listener);
+ }
+ }
+
+ CFRelease(array);
+ }
+
+ /*
+ * Add the BrowseSocket to the sockets dictionary...
+ */
+
+ if (Browsing && (BrowseRemoteProtocols & BROWSE_CUPS))
+ {
+ if ((array = CFArrayCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeArrayCallBacks)) != NULL)
+ {
+ CFDictionaryAddValue(sockets, CFSTR("BrowseSockets"), array);
+
+ if ((listener = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks)) != NULL)
+ {
+ CFArrayAppendValue(array, listener);
+
+ CFDictionaryAddValue(listener, CFSTR("SockFamily"), CFSTR("IPv4"));
+ CFDictionaryAddValue(listener, CFSTR("SockType"), CFSTR("dgram"));
+
+ if ((service = getservbyport(BrowsePort, NULL)))
+ value = CFStringCreateWithCString(kCFAllocatorDefault,
+ service->s_name,
+ kCFStringEncodingUTF8);
+ else
+ value = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType,
+ &BrowsePort);
+
+ CFDictionaryAddValue(listener, CFSTR("SockServiceName"), value);
+ CFRelease(value);
+
+ CFRelease(listener);
+ }
+
+ CFRelease(array);
+ }
+ }
+
+ CFRelease(sockets);
+ }
+
+ cupsdLogMessage(CUPSD_LOG_DEBUG,
+ "launchd_sync_conf: Updating \"%s\", pid=%d\n",
+ LaunchdConf, (int)getpid());
+
+ if ((fileURL = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
+ (const unsigned char *)LaunchdConf,
+ strlen(LaunchdConf), false)))
+ {
+ if ((resourceData = CFPropertyListCreateXMLData(kCFAllocatorDefault,
+ cupsd_dict)))
+ {
+ if (!CFURLWriteDataAndPropertiesToResource(fileURL, resourceData,
+ NULL, &errorCode))
+ {
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "launchd_sync_conf: "
+ "CFURLWriteDataAndPropertiesToResource(\"%s\") "
+ "failed: %d\n",
+ LaunchdConf, (int)errorCode);
+ }
+
+ CFRelease(resourceData);
+ }
+
+ CFRelease(fileURL);
+ }
+
+ CFRelease(cupsd_dict);
+ }
+
+ /*
+ * Let the caller know we updated the file...
+ */
+
+ return (1);
+}
+#endif /* HAVE_LAUNCHD */
+
+
/*
* 'parent_handler()' - Catch USR1/CHLD signals...
*/
*/
static void
-usage(void)
+usage(int status) /* O - Exit status */
{
- fputs("Usage: cupsd [-c config-file] [-f] [-F]\n", stderr);
- exit(1);
+ _cupsLangPuts(status ? stderr : stdout,
+ _("Usage: cupsd [-c config-file] [-f] [-F] [-h] [-l]\n"
+ "\n"
+ "-c config-file Load alternate configuration file\n"
+ "-f Run in the foreground\n"
+ "-F Run in the foreground but detach\n"
+ "-h Show this usage message\n"
+ "-l Run cupsd from launchd(8)\n"));
+ exit(status);
}
/*
- * End of "$Id: main.c 5007 2006-01-27 18:25:42Z mike $".
+ * End of "$Id: main.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: sysman.c 5007 2006-01-27 18:25:42Z mike $"
+ * "$Id: sysman.c 5018 2006-01-28 06:06:55Z mike $"
*
* System management definitions for the Common UNIX Printing System (CUPS).
*
* Constants...
*/
-#define SYSEVENT_CANSLEEP 0x1 /* Decide whether to allow sleep or not */
-#define SYSEVENT_WILLSLEEP 0x2 /* Computer will go to sleep */
-#define SYSEVENT_WOKE 0x4 /* Computer woke from sleep */
-#define SYSEVENT_NETCHANGED 0x8 /* Network changed */
-#define SYSEVENT_NAMECHANGED 0x10 /* Computer name changed */
+# define SYSEVENT_CANSLEEP 0x1 /* Decide whether to allow sleep or not */
+# define SYSEVENT_WILLSLEEP 0x2 /* Computer will go to sleep */
+# define SYSEVENT_WOKE 0x4 /* Computer woke from sleep */
+# define SYSEVENT_NETCHANGED 0x8 /* Network changed */
+# define SYSEVENT_NAMECHANGED 0x10 /* Computer name changed */
/*
CFArrayRef changedKeys,
void *context);
static void sysEventTimerNotifier(CFRunLoopTimerRef timer, void *context);
-#endif /* __APPLE__ */
/*
threadData->sysevent.event = 0;
}
}
+#endif /* __APPLE__ */
/*
- * End of "$Id: sysman.c 5007 2006-01-27 18:25:42Z mike $".
+ * End of "$Id: sysman.c 5018 2006-01-28 06:06:55Z mike $".
*/
/*
- * "$Id: accept.c 4990 2006-01-26 02:21:45Z mike $"
+ * "$Id: accept.c 5023 2006-01-29 14:39:44Z mike $"
*
* "accept", "disable", "enable", and "reject" commands for the Common
* UNIX Printing System (CUPS).
request = ippNewRequest(op);
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", argv[i]);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", argv[i]);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
/*
- * End of "$Id: accept.c 4990 2006-01-26 02:21:45Z mike $".
+ * End of "$Id: accept.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: cancel.c 4948 2006-01-19 03:23:41Z mike $"
+ * "$Id: cancel.c 5023 2006-01-29 14:39:44Z mike $"
*
* "cancel" command for the Common UNIX Printing System (CUPS).
*
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",
/*
- * End of "$Id: cancel.c 4948 2006-01-19 03:23:41Z mike $".
+ * End of "$Id: cancel.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: cupsaddsmb.c 4933 2006-01-16 00:26:57Z mike $"
+ * "$Id: cupsaddsmb.c 5023 2006-01-29 14:39:44Z mike $"
*
* "cupsaddsmb" command for the Common UNIX Printing System (CUPS).
*
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);
/*
- * End of "$Id: cupsaddsmb.c 4933 2006-01-16 00:26:57Z mike $".
+ * End of "$Id: cupsaddsmb.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: lpadmin.c 4925 2006-01-13 02:52:47Z mike $"
+ * "$Id: lpadmin.c 5023 2006-01-29 14:39:44Z mike $"
*
* "lpadmin" command for the Common UNIX Printing System (CUPS).
*
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);
* OK, the printer isn't part of the class, so add it...
*/
- 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);
if (response != NULL &&
(members = ippFindAttribute(response, "member-uris", IPP_TAG_URI)) != NULL)
* printer-uri
*/
- 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);
request = ippNewRequest(CUPS_SET_DEFAULT);
request = ippNewRequest(CUPS_DELETE_PRINTER);
- 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);
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);
request = ippNewRequest(CUPS_ADD_PRINTER);
- 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);
request = ippNewRequest(CUPS_ADD_PRINTER);
- 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);
request = ippNewRequest(CUPS_ADD_PRINTER);
- 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);
request = ippNewRequest(CUPS_ADD_PRINTER);
- 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);
request = ippNewRequest(CUPS_ADD_PRINTER);
- 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);
request = ippNewRequest(CUPS_ADD_PRINTER);
- 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);
DEBUG_printf(("set_printer_options(%p, \"%s\", %d, %p)\n", http, printer,
num_options, options));
- 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);
/*
* Build a GET_PRINTER_ATTRIBUTES request, which requires the following
if (attr->values[0].integer & (CUPS_PRINTER_CLASS | CUPS_PRINTER_IMPLICIT))
{
op = CUPS_ADD_CLASS;
- httpAssembleURIf(uri, sizeof(uri), "ipp", NULL, "localhost", 0,
- "/classes/%s", printer);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/classes/%s", printer);
}
}
/*
- * End of "$Id: lpadmin.c 4925 2006-01-13 02:52:47Z mike $".
+ * End of "$Id: lpadmin.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: lpmove.c 4945 2006-01-18 21:41:17Z mike $"
+ * "$Id: lpmove.c 5023 2006-01-29 14:39:44Z mike $"
*
* "lpmove" command for the Common UNIX Printing System (CUPS).
*
}
else
{
- httpAssembleURIf(job_uri, sizeof(job_uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", src);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, job_uri, sizeof(job_uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", src);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
job_uri);
}
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
NULL, cupsUser());
- httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL, "localhost", 0,
- "/printers/%s", dest);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+ "ipp", NULL, "localhost", 0, "/printers/%s", dest);
ippAddString(request, IPP_TAG_JOB, IPP_TAG_URI, "job-printer-uri",
NULL, printer_uri);
/*
- * End of "$Id: lpmove.c 4945 2006-01-18 21:41:17Z mike $".
+ * End of "$Id: lpmove.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: lpstat.c 4948 2006-01-19 03:23:41Z mike $"
+ * "$Id: lpstat.c 5023 2006-01-29 14:39:44Z mike $"
*
* "lpstat" command for the Common UNIX Printing System (CUPS).
*
response2 = NULL;
if (members == NULL && printer_uri != NULL)
{
- httpSeparateURI(printer_uri, method, sizeof(method),
+ httpSeparateURI(HTTP_URI_CODING_ALL, printer_uri, method, sizeof(method),
username, sizeof(username), server, sizeof(server),
&port, resource, sizeof(resource));
if (device == NULL)
{
- httpSeparate(uri, method, username, hostname, &port, resource);
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method),
+ username, sizeof(username), hostname,
+ sizeof(hostname), &port, resource, sizeof(resource));
_cupsLangPrintf(stdout,
_("Output for printer %s is sent to remote "
"printer %s on %s\n"),
"requested-attributes",
sizeof(jattrs) / sizeof(jattrs[0]), NULL, jattrs);
- httpAssembleURIf(printer_uri, sizeof(printer_uri), "ipp", NULL,
- "localhost", 0, "/printers/%s", printer);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri),
+ "ipp", NULL, "localhost", 0, "/printers/%s", printer);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, printer_uri);
/*
- * End of "$Id: lpstat.c 4948 2006-01-19 03:23:41Z mike $".
+ * End of "$Id: lpstat.c 5023 2006-01-29 14:39:44Z mike $".
*/
/*
- * "$Id: ipptest.c 4973 2006-01-25 02:36:02Z mike $"
+ * "$Id: ipptest.c 5023 2006-01-29 14:39:44Z mike $"
*
* IPP test command for the Common UNIX Printing System (CUPS).
*
* Connect to the server...
*/
- httpSeparateURI(uri, method, sizeof(method), userpass, sizeof(userpass),
- server, sizeof(server), &port, resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass,
+ sizeof(userpass), server, sizeof(server), &port, resource,
+ sizeof(resource));
if ((http = httpConnect(server, port)) == NULL)
{
printf("Unable to connect to %s on port %d - %s\n", server, port,
* Initialize things...
*/
- httpSeparateURI(uri, method, sizeof(method), userpass, sizeof(userpass),
- server, sizeof(server), &port, resource, sizeof(resource));
+ httpSeparateURI(HTTP_URI_CODING_ALL, uri, method, sizeof(method), userpass,
+ sizeof(userpass), server, sizeof(server), &port, resource,
+ sizeof(resource));
request = ippNew();
op = (ipp_op_t)0;
/*
- * End of "$Id: ipptest.c 4973 2006-01-25 02:36:02Z mike $".
+ * End of "$Id: ipptest.c 5023 2006-01-29 14:39:44Z mike $".
*/
exit 1
fi
-# Update the current working copy...
-svn up
-rev=`svnversion . | sed -e '1,$s/[a-zA-Z]//g'`
-
-# Make everything...
-make all
+# Get the current working copy version...
+rev=`svnversion . | awk -F: '{print $NF}' | sed -e '1,$s/[a-zA-Z]*//g'`
# Setup an install directory...
user=`whoami`
cat >$pkgdir/Resources/preflight <<EOF
#!/bin/sh
+# Stop any running cupsd processes...
killall cupsd || exit 0
EOF
chmod 755 $pkgdir/Resources/preflight
cat >$pkgdir/Resources/postflight <<EOF
#!/bin/sh
-/usr/sbin/cupsd
+launchctl unload /System/Library/LaunchDaemons/org.cups.cupsd.plist || exit 0
+launchctl load /System/Library/LaunchDaemons/org.cups.cupsd.plist
+sleep 1
+if test -e /private/var/run/cupsd; then
+ chmod g+w,o+w /private/var/run/cupsd
+fi
EOF
chmod 755 $pkgdir/Resources/postflight