From 757d2cad8f3f75c420ad2e462b787cd9cf8a7a62 Mon Sep 17 00:00:00 2001
From: jlovell
Date: Wed, 8 Mar 2006 00:32:35 +0000
Subject: [PATCH] Load cups into easysw/current.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@80 a1ca3aef-8c08-0410-bb20-df032aa958be
---
Makedefs.in | 5 +-
Makefile | 80 +-
backend/Makefile | 17 +-
backend/ieee1394.c | 8 +-
backend/ipp.c | 11 +-
backend/lpd.c | 16 +-
backend/parallel.c | 8 +-
backend/scsi-irix.c | 8 +-
backend/scsi-linux.c | 8 +-
backend/serial.c | 8 +-
backend/socket.c | 8 +-
backend/usb-darwin.c | 9 +-
backend/usb-unix.c | 8 +-
berkeley/Makefile | 17 +-
berkeley/lpr.c | 6 +-
cgi-bin/Makefile | 15 +-
cgi-bin/admin.c | 1020 +++---------------
cgi-bin/ipp-var.c | 6 +-
conf/Makefile | 28 +-
conf/client.conf | 67 --
config-scripts/cups-common.m4 | 5 +-
cups/Dependencies | 51 +-
cups/Makefile | 41 +-
cups/adminutil.c | 1900 +++++++++++++++++++++++++++++++++
cups/adminutil.h | 89 ++
cups/cups.h | 8 +-
cups/emit.c | 857 ++++++++-------
cups/encode.c | 6 +-
cups/getputfile.c | 10 +-
cups/globals.c | 8 +-
cups/globals.h | 14 +-
cups/http-addr.c | 44 +-
cups/http.c | 6 +-
cups/http.h | 6 +-
cups/i18n.h | 8 +-
cups/ipp-private.h | 8 +-
cups/ipp.c | 116 +-
cups/language.c | 180 ++--
cups/libcups_s.exp | 30 +-
cups/mark.c | 76 +-
cups/md5-apple.h | 10 +-
cups/md5.c | 12 +-
cups/md5.h | 8 +-
cups/md5passwd.c | 22 +-
cups/page.c | 42 +-
cups/ppd.c | 80 +-
cups/ppd.h | 6 +-
cups/string.c | 203 +++-
cups/string.h | 21 +-
cups/testadmin.c | 129 +++
cups/testhttp.c | 6 +-
cups/util.c | 6 +-
data/Makefile | 36 +-
doc/Makefile | 41 +-
doc/cups-printable.css | 4 +
doc/cups.css | 4 +
doc/help/cgi.html | 91 ++
doc/help/ref-cupsd-conf.html | 1 +
doc/help/whatsnew.html | 632 ++++++++---
doc/index.html.in | 14 +-
doc/ja/index.html.in | 14 +-
filter/Makefile | 29 +-
fonts/Makefile | 22 +-
locale/Makefile | 16 +-
locale/cups.pot | 125 ++-
locale/cups_ja.po | 139 ++-
man/Makefile | 29 +-
monitor/Makefile | 16 +-
notifier/Makefile | 16 +-
notifier/mailto.c | 9 +-
packaging/LICENSE.rtf | 4 +-
packaging/installer.tif | Bin 6580 -> 6076 bytes
packaging/installer.xcf.gz | Bin 7461 -> 7026 bytes
pdftops/Makefile | 14 +-
ppd/Makefile | 23 +-
scheduler/Makefile | 29 +-
scheduler/auth.c | 42 +-
scheduler/conf.c | 12 +-
scheduler/ipp.c | 60 +-
scheduler/main.c | 6 +-
scheduler/printers.c | 42 +-
scheduler/sysman.c | 20 +-
scripting/php/Dependencies | 8 +-
scripting/php/Makefile | 19 +-
standards/Makefile | 11 +-
systemv/Dependencies | 8 +-
systemv/Makefile | 27 +-
systemv/cupsaddsmb.c | 896 ++--------------
systemv/lp.c | 6 +-
templates/Makefile | 28 +-
templates/admin.tmpl | 2 +-
templates/edit-config.tmpl.in | 4 +-
test/Makefile | 13 +-
tools/testosx | 14 +-
94 files changed, 4850 insertions(+), 3037 deletions(-)
delete mode 100644 conf/client.conf
create mode 100644 cups/adminutil.c
create mode 100644 cups/adminutil.h
create mode 100644 cups/testadmin.c
create mode 100644 doc/help/cgi.html
diff --git a/Makedefs.in b/Makedefs.in
index 4520f8b2f..fc84a5354 100644
--- a/Makedefs.in
+++ b/Makedefs.in
@@ -1,5 +1,5 @@
#
-# "$Id: Makedefs.in 5194 2006-02-27 20:57:07Z mike $"
+# "$Id: Makedefs.in 5229 2006-03-05 16:48:12Z mike $"
#
# Common makefile definitions for the Common UNIX Printing System (CUPS).
#
@@ -40,6 +40,7 @@ MV = @MV@
PHPCONFIG = @PHPCONFIG@
RANLIB = @RANLIB@
RM = @RM@ -f
+RMDIR = @RMDIR@
SED = @SED@
SHELL = /bin/sh
STRIP = @STRIP@
@@ -215,5 +216,5 @@ DBUSDIR = @DBUSDIR@
#
-# End of "$Id: Makedefs.in 5194 2006-02-27 20:57:07Z mike $"
+# End of "$Id: Makedefs.in 5229 2006-03-05 16:48:12Z mike $"
#
diff --git a/Makefile b/Makefile
index 3535a9fde..2913b9831 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5217 2006-03-02 21:24:01Z mike $"
+# "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $"
#
# Top-level Makefile for the Common UNIX Printing System (CUPS).
#
@@ -30,7 +30,8 @@ include Makedefs
DIRS = cups backend berkeley cgi-bin filter locale man monitor \
notifier pdftops scheduler systemv test \
- $(PHPDIR)
+ $(PHPDIR) \
+ conf data doc fonts ppd templates
#
@@ -76,32 +77,20 @@ install: installhdrs
echo Installing in $$dir... ;\
(cd $$dir; $(MAKE) $(MFLAGS) install) || exit 1;\
done
- echo Installing in conf...
- (cd conf; $(MAKE) $(MFLAGS) install)
- echo Installing in data...
- (cd data; $(MAKE) $(MFLAGS) install)
- echo Installing in doc...
- (cd doc; $(MAKE) $(MFLAGS) install)
- echo Installing in fonts...
- (cd fonts; $(MAKE) $(MFLAGS) install)
- echo Installing in ppd...
- (cd ppd; $(MAKE) $(MFLAGS) install)
- echo Installing in templates...
- (cd templates; $(MAKE) $(MFLAGS) install)
echo Installing cups-config script...
- $(INSTALL_DIR) $(BINDIR)
+ $(INSTALL_DIR) -m 755 $(BINDIR)
$(INSTALL_SCRIPT) cups-config $(BINDIR)/cups-config
echo Installing startup script...
if test "x$(INITDIR)" != "x"; then \
- $(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/init.d; \
+ $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/init.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/init.d/cups; \
- $(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc0.d; \
+ $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc0.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc0.d/K00cups; \
- $(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc2.d; \
+ $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc2.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc2.d/S99cups; \
- $(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc3.d; \
+ $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc3.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc3.d/S99cups; \
- $(INSTALL_DIR) $(BUILDROOT)$(INITDIR)/rc5.d; \
+ $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc5.d; \
$(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDIR)/rc5.d/S99cups; \
fi
if test "x$(INITDIR)" = "x" -a "x$(INITDDIR)" != "x"; then \
@@ -109,7 +98,7 @@ install: installhdrs
if test "$(INITDDIR)" = "/System/Library/StartupItems/PrintingServices"; then \
$(INSTALL_SCRIPT) init/PrintingServices $(BUILDROOT)$(INITDDIR)/PrintingServices; \
$(INSTALL_DATA) init/StartupParameters.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
- $(INSTALL_DIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
+ $(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
$(INSTALL_DATA) init/Localizable.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \
$(INSTALL_DATA) init/org.cups.cupsd.plist $(BUILDROOT)$(DEFAULT_LAUNCHD_CONF); \
@@ -119,7 +108,7 @@ install: installhdrs
fi
if test "x$(DBUSDIR)" != "x"; then \
echo Installing cups.conf in $(DBUSDIR)...;\
- $(INSTALL_DIR) $(BUILDROOT)$(DBUSDIR); \
+ $(INSTALL_DIR) -m 755 $(BUILDROOT)$(DBUSDIR); \
$(INSTALL_DATA) packaging/cups-dbus.conf $(BUILDROOT)$(DBUSDIR)/cups.conf; \
fi
@@ -136,6 +125,51 @@ installhdrs:
(cd filter ; $(MAKE) $(MFLAGS) installhdrs) || exit 1;
+#
+# Uninstall object and target files...
+#
+
+uninstall:
+ for dir in $(DIRS); do\
+ echo Uninstalling in $$dir... ;\
+ (cd $$dir; $(MAKE) $(MFLAGS) uninstall) || exit 1;\
+ done
+ echo Uninstalling cups-config script...
+ $(RM) $(BINDIR)/cups-config
+ -$(RMDIR) $(BINDIR)
+ echo Uninstalling startup script...
+ if test "x$(INITDIR)" != "x"; then \
+ $(RM) $(BUILDROOT)$(INITDIR)/init.d/cups; \
+ $(RMDIR) $(BUILDROOT)$(INITDIR)/init.d; \
+ $(RM) $(BUILDROOT)$(INITDIR)/rc0.d/K00cups; \
+ $(RMDIR) $(BUILDROOT)$(INITDIR)/rc0.d; \
+ $(RM) $(BUILDROOT)$(INITDIR)/rc2.d/S99cups; \
+ $(RMDIR) $(BUILDROOT)$(INITDIR)/rc2.d; \
+ $(RM) $(BUILDROOT)$(INITDIR)/rc3.d/S99cups; \
+ $(RMDIR) $(BUILDROOT)$(INITDIR)/rc3.d; \
+ $(RM) $(BUILDROOT)$(INITDIR)/rc5.d/S99cups; \
+ $(RMDIR) $(BUILDROOT)$(INITDIR)/rc5.d; \
+ fi
+ if test "x$(INITDIR)" = "x" -a "x$(INITDDIR)" != "x"; then \
+ if test "$(INITDDIR)" = "/System/Library/StartupItems/PrintingServices"; then \
+ $(RM) $(BUILDROOT)$(INITDDIR)/PrintingServices; \
+ $(RM) $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
+ $(RM) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
+ $(RMDIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
+ elif test "$(INITDDIR)" = "/System/Library/LaunchDaemons"; then \
+ $(RM) $(BUILDROOT)$(DEFAULT_LAUNCHD_CONF); \
+ else \
+ $(INSTALL_SCRIPT) init/cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
+ fi \
+ $(RMDIR) $(BUILDROOT)$(INITDDIR); \
+ fi
+ if test "x$(DBUSDIR)" != "x"; then \
+ echo Uninstalling cups.conf in $(DBUSDIR)...;\
+ $(RM) $(BUILDROOT)$(DBUSDIR)/cups.conf; \
+ $(RMDIR) $(BUILDROOT)$(DBUSDIR); \
+ fi
+
+
#
# Run the test suite...
#
@@ -159,5 +193,5 @@ epm:
#
-# End of "$Id: Makefile 5217 2006-03-02 21:24:01Z mike $".
+# End of "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $".
#
diff --git a/backend/Makefile b/backend/Makefile
index bebaa471d..4267f21e5 100644
--- a/backend/Makefile
+++ b/backend/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5131 2006-02-18 05:31:36Z mike $"
+# "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $"
#
# Backend makefile for the Common UNIX Printing System (CUPS).
#
@@ -72,6 +72,19 @@ install: all
$(LN) ipp $(SERVERBIN)/backend/http
+#
+# Uninstall all targets...
+#
+
+uninstall:
+ for file in $(RBACKENDS) $(UBACKENDS); do \
+ $(RM) $(SERVERBIN)/backend/$$file; \
+ done
+ $(RM) $(SERVERBIN)/backend/http
+ -$(RMDIR) $(SERVERBIN)/backend
+ -$(RMDIR) $(SERVERBIN)
+
+
#
# betest
#
@@ -179,5 +192,5 @@ include Dependencies
#
-# End of "$Id: Makefile 5131 2006-02-18 05:31:36Z mike $".
+# End of "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $".
#
diff --git a/backend/ieee1394.c b/backend/ieee1394.c
index 0be210581..3d88c7a08 100644
--- a/backend/ieee1394.c
+++ b/backend/ieee1394.c
@@ -1,5 +1,5 @@
/*
- * "$Id: ieee1394.c 4494 2005-02-18 02:18:11Z mike $"
+ * "$Id: ieee1394.c 5241 2006-03-07 22:07:44Z mike $"
*
* IEEE-1394 backend for the Common UNIX Printing System (CUPS).
*
@@ -140,6 +140,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Try to open the printer device...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
if ((dev = ieee1394_open(argv[0])) == NULL)
@@ -150,6 +152,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
}
while (dev == NULL);
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Now that we are "connected" to the port, ignore SIGTERM so that we
* can finish out any page data the driver sends (e.g. to eject the
@@ -259,5 +263,5 @@ list_devices(void)
/*
- * End of "$Id: ieee1394.c 4494 2005-02-18 02:18:11Z mike $".
+ * End of "$Id: ieee1394.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/ipp.c b/backend/ipp.c
index 07699d655..878f634e1 100644
--- a/backend/ipp.c
+++ b/backend/ipp.c
@@ -1,5 +1,5 @@
/*
- * "$Id: ipp.c 5180 2006-02-26 01:31:45Z mike $"
+ * "$Id: ipp.c 5241 2006-03-07 22:07:44Z mike $"
*
* IPP backend for the Common UNIX Printing System (CUPS).
*
@@ -507,6 +507,8 @@ main(int argc, /* I - Number of command-line args */
* Try connecting to the remote server...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
fprintf(stderr, "INFO: Connecting to %s on port %d...\n", hostname, port);
@@ -563,6 +565,7 @@ main(int argc, /* I - Number of command-line args */
}
while (http == NULL);
+ fputs("STATE: -connecting-to-device\n", stderr);
fprintf(stderr, "INFO: Connected to %s...\n", hostname);
/*
@@ -1242,8 +1245,8 @@ compress_files(int num_files, /* I - Number of files */
while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0)
if (cupsFileWrite(out, buffer, bytes) < bytes)
{
- fprintf(stderr, "ERROR: Unable to write %d bytes to \"%s\": %s\n",
- bytes, filename, strerror(errno));
+ fprintf(stderr, "ERROR: Unable to write " CUPS_LLFMT " bytes to \"%s\": %s\n",
+ CUPS_LLCAST bytes, filename, strerror(errno));
cupsFileClose(in);
cupsFileClose(out);
exit(CUPS_BACKEND_FAILED);
@@ -1615,5 +1618,5 @@ sigterm_handler(int sig) /* I - Signal */
/*
- * End of "$Id: ipp.c 5180 2006-02-26 01:31:45Z mike $".
+ * End of "$Id: ipp.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/lpd.c b/backend/lpd.c
index 30dea2372..5a2f1c313 100644
--- a/backend/lpd.c
+++ b/backend/lpd.c
@@ -1,5 +1,5 @@
/*
- * "$Id: lpd.c 5023 2006-01-29 14:39:44Z mike $"
+ * "$Id: lpd.c 5241 2006-03-07 22:07:44Z mike $"
*
* Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
*
@@ -644,6 +644,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
* First try to reserve a port for this connection...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
fprintf(stderr, "INFO: Attempting to connect to host %s for printer %s\n",
hostname, printer);
@@ -769,12 +770,15 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
#ifdef __APPLE__
recoverable = 1;
fprintf(stderr, "WARNING: recoverable: "
+ "Network host \'%s\' is busy, down, or "
+ "unreachable; will retry in 30 seconds...\n",
+ hostname);
#else
fprintf(stderr, "WARNING: "
-#endif /* __APPLE__ */
"Network host \'%s\' is busy, down, or "
"unreachable; will retry in 30 seconds...\n",
hostname);
+#endif /* __APPLE__ */
sleep(30);
}
else if (error == EADDRINUSE)
@@ -790,10 +794,11 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
#ifdef __APPLE__
recoverable = 1;
perror("ERROR: recoverable: "
+ "Unable to connect to printer; will retry in 30 seconds...");
#else
perror("ERROR: "
-#endif /* __APPLE__ */
"Unable to connect to printer; will retry in 30 seconds...");
+#endif /* __APPLE__ */
sleep(30);
}
}
@@ -812,6 +817,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
}
#endif /* __APPLE__ */
+ fputs("STATE: -connecting-to-device\n", stderr);
fprintf(stderr, "INFO: Connected to %s...\n", hostname);
fprintf(stderr, "DEBUG: Connected on ports %d (local %d)...\n", port,
lport);
@@ -853,7 +859,7 @@ lpd_queue(const char *hostname, /* I - Host to connect to */
return (CUPS_BACKEND_FAILED);
}
- httpGetHostname(localhost, sizeof(localhost));
+ httpGetHostname(NULL, localhost, sizeof(localhost));
snprintf(control, sizeof(control),
"H%.31s\n" /* RFC 1179, Section 7.2 - host name <= 31 chars */
@@ -1224,5 +1230,5 @@ sigterm_handler(int sig) /* I - Signal */
/*
- * End of "$Id: lpd.c 5023 2006-01-29 14:39:44Z mike $".
+ * End of "$Id: lpd.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/parallel.c b/backend/parallel.c
index 3731b378c..6acb8134f 100644
--- a/backend/parallel.c
+++ b/backend/parallel.c
@@ -1,5 +1,5 @@
/*
- * "$Id: parallel.c 5194 2006-02-27 20:57:07Z mike $"
+ * "$Id: parallel.c 5241 2006-03-07 22:07:44Z mike $"
*
* Parallel port backend for the Common UNIX Printing System (CUPS).
*
@@ -202,6 +202,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Open the parallel port device...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
if ((fd = open(resource, O_WRONLY | O_EXCL)) == -1)
@@ -247,6 +249,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
}
while (fd < 0);
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Set any options provided...
*/
@@ -733,5 +737,5 @@ list_devices(void)
/*
- * End of "$Id: parallel.c 5194 2006-02-27 20:57:07Z mike $".
+ * End of "$Id: parallel.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/scsi-irix.c b/backend/scsi-irix.c
index 097071c23..cec216e87 100644
--- a/backend/scsi-irix.c
+++ b/backend/scsi-irix.c
@@ -1,5 +1,5 @@
/*
- * "$Id: scsi-irix.c 4703 2005-09-26 19:33:58Z mike $"
+ * "$Id: scsi-irix.c 5241 2006-03-07 22:07:44Z mike $"
*
* IRIX SCSI printer support for the Common UNIX Printing System (CUPS).
*
@@ -103,6 +103,8 @@ print_device(const char *resource, /* I - SCSI device */
* Open the SCSI device file...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
if ((scsi_fd = open(resource, O_RDWR | O_EXCL)) == -1)
@@ -144,6 +146,8 @@ print_device(const char *resource, /* I - SCSI device */
}
while (scsi_fd == -1);
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Now that we are "connected" to the port, ignore SIGTERM so that we
* can finish out any page data the driver sends (e.g. to eject the
@@ -227,5 +231,5 @@ print_device(const char *resource, /* I - SCSI device */
/*
- * End of "$Id: scsi-irix.c 4703 2005-09-26 19:33:58Z mike $".
+ * End of "$Id: scsi-irix.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/scsi-linux.c b/backend/scsi-linux.c
index b5c1d1bef..75c9629dc 100644
--- a/backend/scsi-linux.c
+++ b/backend/scsi-linux.c
@@ -1,5 +1,5 @@
/*
- * "$Id: scsi-linux.c 4703 2005-09-26 19:33:58Z mike $"
+ * "$Id: scsi-linux.c 5241 2006-03-07 22:07:44Z mike $"
*
* Linux SCSI printer support for the Common UNIX Printing System (CUPS).
*
@@ -116,6 +116,8 @@ print_device(const char *resource, /* I - SCSI device */
* Open the SCSI device file...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
if ((scsi_fd = open(resource, O_RDWR | O_EXCL)) == -1)
@@ -157,6 +159,8 @@ print_device(const char *resource, /* I - SCSI device */
}
while (scsi_fd == -1);
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Now that we are "connected" to the port, ignore SIGTERM so that we
* can finish out any page data the driver sends (e.g. to eject the
@@ -245,5 +249,5 @@ print_device(const char *resource, /* I - SCSI device */
/*
- * End of "$Id: scsi-linux.c 4703 2005-09-26 19:33:58Z mike $".
+ * End of "$Id: scsi-linux.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/serial.c b/backend/serial.c
index 7d8abe786..17de8d8d3 100644
--- a/backend/serial.c
+++ b/backend/serial.c
@@ -1,5 +1,5 @@
/*
- * "$Id: serial.c 5194 2006-02-27 20:57:07Z mike $"
+ * "$Id: serial.c 5241 2006-03-07 22:07:44Z mike $"
*
* Serial port backend for the Common UNIX Printing System (CUPS).
*
@@ -223,6 +223,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
* Open the serial port device...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
if ((fd = open(resource, O_WRONLY | O_NOCTTY | O_EXCL | O_NDELAY)) == -1)
@@ -263,6 +265,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
}
while (fd < 0);
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Set any options provided...
*/
@@ -1130,5 +1134,5 @@ list_devices(void)
/*
- * End of "$Id: serial.c 5194 2006-02-27 20:57:07Z mike $".
+ * End of "$Id: serial.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/socket.c b/backend/socket.c
index ab541be60..1833be6fc 100644
--- a/backend/socket.c
+++ b/backend/socket.c
@@ -1,5 +1,5 @@
/*
- * "$Id: socket.c 5099 2006-02-13 02:46:10Z mike $"
+ * "$Id: socket.c 5241 2006-03-07 22:07:44Z mike $"
*
* AppSocket backend for the Common UNIX Printing System (CUPS).
*
@@ -256,6 +256,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
while (copies > 0)
{
+ fputs("STATE: +connecting-to-device\n", stderr);
+
for (delay = 5;;)
{
if (!httpAddrConnect(addrlist, &fd))
@@ -304,6 +306,8 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
break;
}
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Now that we are "connected" to the port, ignore SIGTERM so that we
* can finish out any page data the driver sends (e.g. to eject the
@@ -488,5 +492,5 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */
/*
- * End of "$Id: socket.c 5099 2006-02-13 02:46:10Z mike $".
+ * End of "$Id: socket.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/usb-darwin.c b/backend/usb-darwin.c
index 5c2ee4f4f..11009b27a 100644
--- a/backend/usb-darwin.c
+++ b/backend/usb-darwin.c
@@ -1,5 +1,5 @@
/*
- * "$Id: usb-darwin.c 4548 2005-06-27 02:33:50Z mike $"
+ * "$Id: usb-darwin.c 5241 2006-03-07 22:07:44Z mike $"
*
* USB port on Darwin backend for the Common UNIX Printing System (CUPS).
*
@@ -674,6 +674,9 @@ int print_device(const char *uri, const char *hostname, const char *resource, co
USBPrinterInfo *activePrinter = NULL;
USBPrinterClassContext **classdriver;
int countdown = INITIAL_LOG_INTERVAL;
+
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
/* */
@@ -746,6 +749,8 @@ int print_device(const char *uri, const char *hostname, const char *resource, co
return (status);
}
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Now that we are "connected" to the port, ignore SIGTERM so that we
* can finish out any page data the driver sends (e.g. to eject the
@@ -1895,5 +1900,5 @@ static CFStringRef CreateEncodedCFString(CFStringRef string)
}
/*
- * End of "$Id: usb-darwin.c 4548 2005-06-27 02:33:50Z mike $".
+ * End of "$Id: usb-darwin.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/backend/usb-unix.c b/backend/usb-unix.c
index b28222202..e034a0a2c 100644
--- a/backend/usb-unix.c
+++ b/backend/usb-unix.c
@@ -1,5 +1,5 @@
/*
- * "$Id: usb-unix.c 5162 2006-02-24 03:15:13Z mike $"
+ * "$Id: usb-unix.c 5241 2006-03-07 22:07:44Z mike $"
*
* USB port backend for the Common UNIX Printing System (CUPS).
*
@@ -82,6 +82,8 @@ print_device(const char *uri, /* I - Device URI */
* Open the USB port device...
*/
+ fputs("STATE: +connecting-to-device\n", stderr);
+
do
{
if ((fd = open_device(uri)) == -1)
@@ -127,6 +129,8 @@ print_device(const char *uri, /* I - Device URI */
}
while (fd < 0);
+ fputs("STATE: -connecting-to-device\n", stderr);
+
/*
* Set any options provided...
*/
@@ -616,5 +620,5 @@ open_device(const char *uri) /* I - Device URI */
/*
- * End of "$Id: usb-unix.c 5162 2006-02-24 03:15:13Z mike $".
+ * End of "$Id: usb-unix.c 5241 2006-03-07 22:07:44Z mike $".
*/
diff --git a/berkeley/Makefile b/berkeley/Makefile
index 6f438cda3..eb16d025c 100644
--- a/berkeley/Makefile
+++ b/berkeley/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5065 2006-02-03 16:55:30Z mike $"
+# "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $"
#
# Berkeley commands makefile for the Common UNIX Printing System (CUPS).
#
@@ -64,6 +64,19 @@ install: all
$(INSTALL_BIN) lpc $(SBINDIR)
+#
+# Uninstall all targets...
+#
+
+uninstall:
+ $(RM) $(BINDIR)/lpq
+ $(RM) $(BINDIR)/lpr
+ $(RM) $(BINDIR)/lprm
+ $(RM) $(SBINDIR)/lpc
+ -$(RMDIR) $(SBINDIR)
+ -$(RMDIR) $(BINDIR)
+
+
#
# lpc
#
@@ -108,5 +121,5 @@ include Dependencies
#
-# End of "$Id: Makefile 5065 2006-02-03 16:55:30Z mike $".
+# End of "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $".
#
diff --git a/berkeley/lpr.c b/berkeley/lpr.c
index c909892e3..f6b5fb3b7 100644
--- a/berkeley/lpr.c
+++ b/berkeley/lpr.c
@@ -1,5 +1,5 @@
/*
- * "$Id: lpr.c 4974 2006-01-25 07:04:33Z mike $"
+ * "$Id: lpr.c 5235 2006-03-06 13:02:23Z mike $"
*
* "lpr" command for the Common UNIX Printing System (CUPS).
*
@@ -231,7 +231,7 @@ main(int argc, /* I - Number of command-line arguments */
snprintf(email, sizeof(email), "mailto:%s@%s", cupsUser(),
- httpGetHostname(buffer, sizeof(buffer)));
+ httpGetHostname(NULL, buffer, sizeof(buffer)));
num_options = cupsAddOption("notify-recipient", email,
num_options, &options);
}
@@ -529,5 +529,5 @@ sighandler(int s) /* I - Signal number */
/*
- * End of "$Id: lpr.c 4974 2006-01-25 07:04:33Z mike $".
+ * End of "$Id: lpr.c 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/cgi-bin/Makefile b/cgi-bin/Makefile
index 7cce230f8..9497bb59f 100644
--- a/cgi-bin/Makefile
+++ b/cgi-bin/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5145 2006-02-22 00:25:14Z mike $"
+# "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $"
#
# CGI makefile for the Common UNIX Printing System (CUPS).
#
@@ -65,6 +65,17 @@ install: all
done
+#
+# Uninstall all targets...
+#
+
+uninstall:
+ for file in $(CGIS); do \
+ $(RM) $(SERVERBIN)/cgi-bin/$$file; \
+ done
+ -$(RMDIR) $(SERVERBIN)/cgi-bin
+
+
#
# libcgi.a
#
@@ -159,5 +170,5 @@ include Dependencies
#
-# End of "$Id: Makefile 5145 2006-02-22 00:25:14Z mike $".
+# End of "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $".
#
diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c
index 3547ee5fd..0b8597b67 100644
--- a/cgi-bin/admin.c
+++ b/cgi-bin/admin.c
@@ -1,5 +1,5 @@
/*
- * "$Id: admin.c 5107 2006-02-15 19:14:17Z mike $"
+ * "$Id: admin.c 5240 2006-03-07 21:55:29Z mike $"
*
* Administration CGI for the Common UNIX Printing System (CUPS).
*
@@ -43,6 +43,7 @@
*/
#include "cgi-private.h"
+#include
#include
#include
#include
@@ -1574,586 +1575,45 @@ do_config_server(http_t *http) /* I - HTTP connection */
* Save basic setting changes...
*/
- http_status_t status; /* PUT status */
- cups_file_t *cupsd; /* cupsd.conf file */
- char tempfile[1024]; /* Temporary new cupsd.conf */
- int tempfd; /* Temporary file descriptor */
- cups_file_t *temp; /* Temporary file */
- char line[1024], /* Line from cupsd.conf file */
- *value; /* Value on line */
- const char *server_root; /* Location of config files */
- int linenum, /* Line number in file */
- in_policy, /* In a policy section? */
- in_cancel_job, /* In a cancel-job section? */
- in_admin_location, /* In the /admin location? */
- in_conf_location, /* In the /admin/conf location? */
- in_root_location; /* In the / location? */
- int remote_printers, /* Show remote printers */
- share_printers, /* Share local printers */
- remote_admin, /* Remote administration allowed? */
- user_cancel_any, /* Cancel-job policy set? */
- debug_logging; /* LogLevel debug set? */
- int wrote_port_listen, /* Wrote the port/listen lines? */
- wrote_browsing, /* Wrote the browsing lines? */
- wrote_policy, /* Wrote the policy? */
- wrote_loglevel, /* Wrote the LogLevel line? */
- wrote_admin_location, /* Wrote the /admin location? */
- wrote_conf_location, /* Wrote the /admin/conf location? */
- wrote_root_location; /* Wrote the / location? */
- int indent; /* Indentation */
-
-
- /*
- * Get form variables...
- */
-
- remote_printers = cgiGetVariable("REMOTE_PRINTERS") != NULL;
- share_printers = cgiGetVariable("SHARE_PRINTERS") != NULL;
- remote_admin = cgiGetVariable("REMOTE_ADMIN") != NULL;
- user_cancel_any = cgiGetVariable("USER_CANCEL_ANY") != NULL;
- debug_logging = cgiGetVariable("DEBUG_LOGGING") != NULL;
-
- /*
- * Locate the cupsd.conf file...
- */
-
- if ((server_root = getenv("CUPS_SERVERROOT")) == NULL)
- server_root = CUPS_SERVERROOT;
-
- snprintf(line, sizeof(line), "%s/cupsd.conf", server_root);
-
- /*
- * Open the cupsd.conf file...
- */
-
- if ((cupsd = cupsFileOpen(line, "r")) == NULL)
- {
- /*
- * Unable to open - log an error...
- */
-
- cgiStartHTML(cgiText(_("Change Settings")));
- cgiSetVariable("MESSAGE", cgiText(_("Unable to change server settings:")));
- cgiSetVariable("ERROR", strerror(errno));
- cgiCopyTemplateLang("error.tmpl");
- cgiEndHTML();
-
- perror(line);
- return;
- }
-
- /*
- * Create a temporary file for the new cupsd.conf file...
- */
-
- if ((tempfd = cupsTempFd(tempfile, sizeof(tempfile))) < 0)
- {
- cgiStartHTML(cgiText(_("Change Settings")));
- cgiSetVariable("MESSAGE", cgiText(_("Unable to change server settings:")));
- cgiSetVariable("ERROR", strerror(errno));
- cgiCopyTemplateLang("error.tmpl");
- cgiEndHTML();
-
- perror(tempfile);
- cupsFileClose(cupsd);
- return;
- }
-
- if ((temp = cupsFileOpenFd(tempfd, "w")) == NULL)
+ int num_settings; /* Number of server settings */
+ cups_option_t *settings; /* Server settings */
+
+
+ num_settings = 0;
+ num_settings = cupsAddOption(CUPS_SERVER_DEBUG_LOGGING,
+ cgiGetVariable("DEBUG_LOGGING") ? "1" : "0",
+ num_settings, &settings);
+ num_settings = cupsAddOption(CUPS_SERVER_REMOTE_ADMIN,
+ cgiGetVariable("REMOTE_ADMIN") ? "1" : "0",
+ num_settings, &settings);
+ num_settings = cupsAddOption(CUPS_SERVER_REMOTE_PRINTERS,
+ cgiGetVariable("REMOTE_PRINTERS") ? "1" : "0",
+ num_settings, &settings);
+ num_settings = cupsAddOption(CUPS_SERVER_SHARE_PRINTERS,
+ cgiGetVariable("SHARE_PRINTERS") ? "1" : "0",
+ num_settings, &settings);
+ num_settings = cupsAddOption(CUPS_SERVER_USER_CANCEL_ANY,
+ cgiGetVariable("USER_CANCEL_ANY") ? "1" : "0",
+ num_settings, &settings);
+
+
+ if (!_cupsAdminSetServerSettings(http, num_settings, settings))
{
cgiStartHTML(cgiText(_("Change Settings")));
cgiSetVariable("MESSAGE", cgiText(_("Unable to change server settings:")));
- cgiSetVariable("ERROR", strerror(errno));
- cgiCopyTemplateLang("error.tmpl");
- cgiEndHTML();
-
- perror(tempfile);
- close(tempfd);
- unlink(tempfile);
- cupsFileClose(cupsd);
- return;
- }
-
- /*
- * Copy the old file to the new, making changes along the way...
- */
-
- in_admin_location = 0;
- in_cancel_job = 0;
- in_conf_location = 0;
- in_policy = 0;
- in_root_location = 0;
- linenum = 0;
- wrote_admin_location = 0;
- wrote_browsing = 0;
- wrote_conf_location = 0;
- wrote_loglevel = 0;
- wrote_policy = 0;
- wrote_port_listen = 0;
- wrote_root_location = 0;
- indent = 0;
-
- while (cupsFileGetConf(cupsd, line, sizeof(line), &value, &linenum))
- {
- if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen"))
- {
- if (!wrote_port_listen)
- {
- wrote_port_listen = 1;
-
- if (share_printers || remote_admin)
- {
- cupsFilePuts(temp, "# Allow remote access\n");
- cupsFilePrintf(temp, "Listen *:%d\n", ippPort());
- }
- else
- {
- cupsFilePuts(temp, "# Only listen for connections from the local machine.\n");
- cupsFilePrintf(temp, "Listen localhost:%d\n", ippPort());
- }
-
-#ifdef CUPS_DEFAULT_DOMAINSOCKET
- cupsFilePuts(temp, "Listen " CUPS_DEFAULT_DOMAINSOCKET "\n");
-#endif /* CUPS_DEFAULT_DOMAINSOCKET */
- }
- }
- else if (!strcasecmp(line, "Browsing") ||
- !strcasecmp(line, "BrowseAddress") ||
- !strcasecmp(line, "BrowseAllow") ||
- !strcasecmp(line, "BrowseDeny") ||
- !strcasecmp(line, "BrowseOrder"))
- {
- if (!wrote_browsing)
- {
- wrote_browsing = 1;
-
- if (remote_printers || share_printers)
- {
- if (remote_printers && share_printers)
- cupsFilePuts(temp, "# Enable printer sharing and shared printers.\n");
- else if (remote_printers)
- cupsFilePuts(temp, "# Show shared printers on the local network.\n");
- else
- cupsFilePuts(temp, "# Share local printers on the local network.\n");
-
- cupsFilePuts(temp, "Browsing On\n");
- cupsFilePuts(temp, "BrowseOrder allow,deny\n");
-
- if (remote_printers)
- cupsFilePuts(temp, "BrowseAllow @LOCAL\n");
-
- if (share_printers)
- cupsFilePuts(temp, "BrowseAddress @LOCAL\n");
- }
- else
- {
- cupsFilePuts(temp, "# Disable printer sharing and shared printers.\n");
- cupsFilePuts(temp, "Browsing Off\n");
- }
- }
- }
- else if (!strcasecmp(line, "LogLevel"))
- {
- wrote_loglevel = 1;
-
- if (debug_logging)
- {
- cupsFilePuts(temp, "# Show troubleshooting information in error_log.\n");
- cupsFilePuts(temp, "LogLevel debug\n");
- }
- else
- {
- cupsFilePuts(temp, "# Show general information in error_log.\n");
- cupsFilePuts(temp, "LogLevel info\n");
- }
- }
- else if (!strcasecmp(line, "\n", line, value);
- indent += 2;
- }
- else if (!strcasecmp(line, ""))
- {
- indent -= 2;
- if (!wrote_policy)
- {
- wrote_policy = 1;
-
- if (!user_cancel_any)
- cupsFilePuts(temp, " # Only the owner or an administrator can cancel a job...\n"
- " \n"
- " Order deny,allow\n"
- " Allow @SYSTEM\n"
- " Allow @OWNER\n"
- " \n");
- }
-
- in_policy = 0;
-
- cupsFilePuts(temp, "\n");
- }
- else if (!strcasecmp(line, "\n", line, value);
- }
- else if (!strcasecmp(line, ""))
- {
- indent -= 2;
- if (in_admin_location)
- {
- wrote_admin_location = 1;
-
- if (remote_admin)
- cupsFilePuts(temp, " # Allow remote administration...\n");
- else
- cupsFilePuts(temp, " # Restrict access to the admin pages...\n");
-
- cupsFilePuts(temp, " Order allow,deny\n");
-
- if (remote_admin)
- cupsFilePuts(temp, " Allow @LOCAL\n");
- else
- cupsFilePuts(temp, " Allow localhost\n");
- }
- else if (in_conf_location)
- {
- wrote_conf_location = 1;
-
- if (remote_admin)
- cupsFilePuts(temp, " # Allow remote access to the configuration files...\n");
- else
- cupsFilePuts(temp, " # Restrict access to the configuration files...\n");
-
- cupsFilePuts(temp, " Order allow,deny\n");
-
- if (remote_admin)
- cupsFilePuts(temp, " Allow @LOCAL\n");
- else
- cupsFilePuts(temp, " Allow localhost\n");
- }
- else if (in_root_location)
- {
- wrote_root_location = 1;
-
- if (remote_admin && share_printers)
- cupsFilePuts(temp, " # Allow shared printing and remote administration...\n");
- else if (remote_admin)
- cupsFilePuts(temp, " # Allow remote administration...\n");
- else if (share_printers)
- cupsFilePuts(temp, " # Allow shared printing...\n");
- else
- cupsFilePuts(temp, " # Restrict access to the server...\n");
-
- cupsFilePuts(temp, " Order allow,deny\n");
-
- if (remote_admin || share_printers)
- cupsFilePuts(temp, " Allow @LOCAL\n");
- else
- cupsFilePuts(temp, " Allow localhost\n");
- }
-
- in_admin_location = 0;
- in_conf_location = 0;
- in_root_location = 0;
-
- cupsFilePuts(temp, "\n");
- }
- else if (!strcasecmp(line, "\n");
- }
- }
- else if (!strcasecmp(line, "") && in_cancel_job)
- {
- indent -= 2;
-
- if (in_cancel_job == 1)
- cupsFilePuts(temp, " \n");
-
- wrote_policy = 1;
-
- if (!user_cancel_any)
- cupsFilePuts(temp, " # Only the owner or an administrator can cancel a job...\n"
- " \n"
- " Order deny,allow\n"
- " Require user @OWNER @SYSTEM\n"
- " \n");
-
- in_cancel_job = 0;
- }
- else if ((in_admin_location || in_conf_location || in_root_location) &&
- (!strcasecmp(line, "Allow") || !strcasecmp(line, "Deny") ||
- !strcasecmp(line, "Order")))
- continue;
- else if (in_cancel_job == 2)
- continue;
- else if (!strcasecmp(line, "\n", line, value);
- else if (line[0] == '<')
- {
- if (value)
- {
- cupsFilePrintf(temp, "%*s%s %s>\n", indent, "", line, value);
- indent += 2;
- }
- else
- {
- if (line[1] == '/')
- indent -= 2;
-
- cupsFilePrintf(temp, "%*s%s\n", indent, "", line);
- }
- }
- else if (value)
- cupsFilePrintf(temp, "%*s%s %s\n", indent, "", line, value);
- else
- cupsFilePrintf(temp, "%*s%s\n", indent, "", line);
- }
-
- /*
- * Write any missing info...
- */
-
- if (!wrote_browsing)
- {
- if (remote_printers || share_printers)
- {
- if (remote_printers && share_printers)
- cupsFilePuts(temp, "# Enable printer sharing and shared printers.\n");
- else if (remote_printers)
- cupsFilePuts(temp, "# Show shared printers on the local network.\n");
- else
- cupsFilePuts(temp, "# Share local printers on the local network.\n");
-
- cupsFilePuts(temp, "Browsing On\n");
- cupsFilePuts(temp, "BrowseOrder allow,deny\n");
-
- if (remote_printers)
- cupsFilePuts(temp, "BrowseAllow @LOCAL\n");
-
- if (share_printers)
- cupsFilePuts(temp, "BrowseAddress @LOCAL\n");
- }
- else
- {
- cupsFilePuts(temp, "# Disable printer sharing and shared printers.\n");
- cupsFilePuts(temp, "Browsing Off\n");
- }
- }
-
- if (!wrote_loglevel)
- {
- if (debug_logging)
- {
- cupsFilePuts(temp, "# Show troubleshooting information in error_log.\n");
- cupsFilePuts(temp, "LogLevel debug\n");
- }
- else
- {
- cupsFilePuts(temp, "# Show general information in error_log.\n");
- cupsFilePuts(temp, "LogLevel info\n");
- }
- }
-
- if (!wrote_port_listen)
- {
- if (share_printers || remote_admin)
- {
- cupsFilePuts(temp, "# Allow remote access\n");
- cupsFilePrintf(temp, "Listen *:%d\n", ippPort());
- }
- else
- {
- cupsFilePuts(temp, "# Only listen for connections from the local machine.\n");
- cupsFilePrintf(temp, "Listen localhost:%d\n", ippPort());
- }
-
-#ifdef CUPS_DEFAULT_DOMAINSOCKET
- cupsFilePuts(temp, "Listen " CUPS_DEFAULT_DOMAINSOCKET "\n");
-#endif /* CUPS_DEFAULT_DOMAINSOCKET */
- }
-
- if (!wrote_root_location)
- {
- if (remote_admin && share_printers)
- cupsFilePuts(temp, "# Allow shared printing and remote administration...\n");
- else if (remote_admin)
- cupsFilePuts(temp, "# Allow remote administration...\n");
- else if (share_printers)
- cupsFilePuts(temp, "# Allow shared printing...\n");
- else
- cupsFilePuts(temp, "# Restrict access to the server...\n");
-
- cupsFilePuts(temp, "\n"
- " Order allow,deny\n");
-
- if (remote_admin || share_printers)
- cupsFilePuts(temp, " Allow @LOCAL\n");
- else
- cupsFilePuts(temp, " Allow localhost\n");
-
- cupsFilePuts(temp, "\n");
- }
-
- if (!wrote_admin_location)
- {
- if (remote_admin)
- cupsFilePuts(temp, "# Allow remote administration...\n");
- else
- cupsFilePuts(temp, "# Restrict access to the admin pages...\n");
-
- cupsFilePuts(temp, "\n"
- " Order allow,deny\n");
-
- if (remote_admin)
- cupsFilePuts(temp, " Allow @LOCAL\n");
- else
- cupsFilePuts(temp, " Allow localhost\n");
-
- cupsFilePuts(temp, "\n");
- }
-
- if (!wrote_conf_location)
- {
- if (remote_admin)
- cupsFilePuts(temp, "# Allow remote access to the configuration files...\n");
- else
- cupsFilePuts(temp, "# Restrict access to the configuration files...\n");
-
- cupsFilePuts(temp, "\n"
- " AuthType Basic\n"
- " Require user @SYSTEM\n"
- " Order allow,deny\n");
-
- if (remote_admin)
- cupsFilePuts(temp, " Allow @LOCAL\n");
- else
- cupsFilePuts(temp, " Allow localhost\n");
-
- cupsFilePuts(temp, "\n");
- }
-
- if (!wrote_policy)
- {
- cupsFilePuts(temp, "\n"
- " # Job-related operations must be done by the owner or an adminstrator...\n"
- " \n"
- " Require user @OWNER @SYSTEM\n"
- " Order deny,allow\n"
- " \n"
- " # All administration operations require an adminstrator to authenticate...\n"
- " \n"
- " AuthType Basic\n"
- " Require user @SYSTEM\n"
- " Order deny,allow\n"
- "\n");
-
- if (!user_cancel_any)
- cupsFilePuts(temp, " # Only the owner or an administrator can cancel a job...\n"
- " \n"
- " Require user @OWNER @SYSTEM\n"
- " Order deny,allow\n"
- " \n");
-
- cupsFilePuts(temp, " \n"
- " Order deny,allow\n"
- " \n"
- "\n");
- }
-
- cupsFileClose(cupsd);
- cupsFileClose(temp);
-
- /*
- * Upload the configuration file to the server...
- */
-
- status = cupsPutFile(http, "/admin/conf/cupsd.conf", tempfile);
-
- if (status != HTTP_CREATED)
- {
- cgiSetVariable("MESSAGE", cgiText(_("Unable to upload cupsd.conf file:")));
- cgiSetVariable("ERROR", httpStatus(status));
- cgiStartHTML(cgiText(_("Change Settings")));
+ cgiSetVariable("ERROR", cupsLastErrorString());
cgiCopyTemplateLang("error.tmpl");
}
else
{
cgiSetVariable("refresh_page", "5;/admin/?OP=redirect");
-
cgiStartHTML(cgiText(_("Change Settings")));
cgiCopyTemplateLang("restart.tmpl");
}
- cgiEndHTML();
+ cupsFreeOptions(num_settings, settings);
- unlink(tempfile);
+ cgiEndHTML();
}
else if (cgiIsPOST())
{
@@ -2482,14 +1942,11 @@ do_export(http_t *http) /* I - HTTP connection */
*export_all; /* Export all printers? */
int export_count, /* Number of printers to export */
printer_count; /* Number of available printers */
+ const char *name, /* What name to pull */
+ *dest; /* Current destination */
+ char ppd[1024]; /* PPD file */
- /*
- * Show header...
- */
-
- cgiStartHTML(cgiText(_("Export Printers to Samba")));
-
/*
* Get form data...
*/
@@ -2499,163 +1956,6 @@ do_export(http_t *http) /* I - HTTP connection */
export_all = cgiGetVariable("EXPORT_ALL");
export_count = cgiGetSize("EXPORT_NAME");
- if (username && *username && password && *password && export_count <= 1000)
- {
- /*
- * Do export...
- */
-
- char userpass[1024], /* Username%password */
- *argv[1005]; /* Arguments */
- int argc; /* Number of arguments */
- int pid; /* Process ID of child */
- int status; /* Status of command */
-
-
- fputs("DEBUG: Export printers...\n", stderr);
-
- /*
- * Create the command-line for cupsaddsmb...
- */
-
- snprintf(userpass, sizeof(userpass), "%s%%%s", username, password);
-
- argv[0] = "cupsaddsmb";
- argv[1] = "-v";
- argv[2] = "-U";
- argv[3] = userpass;
- argc = 4;
-
- if (export_all)
- argv[argc ++] = "-a";
- else
- {
- for (i = 0; i < export_count; i ++)
- argv[argc ++] = (char *)cgiGetArray("EXPORT_NAME", i);
- }
-
- argv[argc] = NULL;
-
- /*
- * Run the command...
- */
-
- if ((pid = fork()) == 0)
- {
- /*
- * Child goes here...
- */
-
- close(0);
- open("/dev/null", O_RDONLY);
- close(1);
- dup(2);
-
- execvp("cupsaddsmb", argv);
- perror("ERROR: Unable to execute cupsaddsmb");
- exit(20);
- }
- else if (pid < 0)
- cgiSetVariable("ERROR", cgiText(_("Unable to fork process!")));
- else
- {
- /*
- * Parent goes here, wait for child to finish...
- */
-
- while (wait(&status) < 0);
-
- if (status)
- {
- char message[1024]; /* Error message */
-
-
- if (WIFEXITED(status))
- {
- switch (WEXITSTATUS(status))
- {
- case 1 :
- cgiSetVariable("ERROR", cgiText(_("Unable to connect to server!")));
- break;
-
- case 2 :
- cgiSetVariable("ERROR", cgiText(_("Unable to get printer "
- "attributes!")));
- break;
-
- case 3 :
- cgiSetVariable("ERROR", cgiText(_("Unable to convert PPD file!")));
- break;
-
- case 4 :
- cgiSetVariable("ERROR", cgiText(_("Unable to copy Windows 2000 "
- "printer driver files!")));
- break;
-
- case 5 :
- cgiSetVariable("ERROR", cgiText(_("Unable to install Windows "
- "2000 printer driver files!")));
- break;
-
- case 6 :
- cgiSetVariable("ERROR", cgiText(_("Unable to copy Windows 9x "
- "printer driver files!")));
- break;
-
- case 7 :
- cgiSetVariable("ERROR", cgiText(_("Unable to install Windows "
- "9x printer driver files!")));
- break;
-
- case 8 :
- cgiSetVariable("ERROR", cgiText(_("Unable to set Windows "
- "printer driver!")));
- break;
-
- case 9 :
- cgiSetVariable("ERROR", cgiText(_("No printer drivers found!")));
- break;
-
- case 20 :
- cgiSetVariable("ERROR", cgiText(_("Unable to execute "
- "cupsaddsmb command!")));
- break;
-
- default :
- snprintf(message, sizeof(message),
- cgiText(_("cupsaddsmb failed with status %d")),
- WEXITSTATUS(status));
-
- cgiSetVariable("ERROR", message);
- break;
- }
- }
- else
- {
- snprintf(message, sizeof(message),
- cgiText(_("cupsaddsmb crashed on signal %d")),
- WTERMSIG(status));
-
- cgiSetVariable("ERROR", message);
- }
- }
- else
- {
- cgiCopyTemplateLang("samba-exported.tmpl");
- cgiEndHTML();
- return;
- }
- }
- }
- else if (username && !*username)
- cgiSetVariable("ERROR",
- cgiText(_("A Samba username is required to export "
- "printer drivers!")));
- else if (username && (!password || !*password))
- cgiSetVariable("ERROR",
- cgiText(_("A Samba password is required to export "
- "printer drivers!")));
-
/*
* Get list of available printers...
*/
@@ -2686,9 +1986,10 @@ do_export(http_t *http) /* I - HTTP connection */
for (i = 0; i < printer_count; i ++)
{
+ dest = cgiGetArray("PRINTER_NAME", i);
+
for (j = 0; j < export_count; j ++)
- if (!strcasecmp(cgiGetArray("PRINTER_NAME", i),
- cgiGetArray("EXPORT_NAME", j)))
+ if (!strcasecmp(dest, cgiGetArray("EXPORT_NAME", j)))
break;
cgiSetArray("PRINTER_EXPORT", i, j < export_count ? "Y" : "");
@@ -2696,10 +1997,67 @@ do_export(http_t *http) /* I - HTTP connection */
}
}
+ /*
+ * Export or get the printers to export...
+ */
+
+ if (username && *username && password && *password &&
+ (export_all || export_count > 0))
+ {
+ /*
+ * Do export...
+ */
+
+ fputs("DEBUG: Export printers...\n", stderr);
+
+ if (export_all)
+ {
+ name = "PRINTER_NAME";
+ export_count = cgiGetSize("PRINTER_NAME");
+ }
+ else
+ name = "EXPORT_NAME";
+
+ for (i = 0; i < export_count; i ++)
+ {
+ dest = cgiGetArray(name, i);
+
+ if (!cupsAdminCreateWindowsPPD(http, dest, ppd, sizeof(ppd)))
+ break;
+
+ j = cupsAdminExportSamba(dest, ppd, "localhost", username, password,
+ stderr);
+
+ unlink(ppd);
+
+ if (!j)
+ break;
+ }
+
+ if (i < export_count)
+ cgiSetVariable("ERROR", cupsLastErrorString());
+ else
+ {
+ cgiStartHTML(cgiText(_("Export Printers to Samba")));
+ cgiCopyTemplateLang("samba-exported.tmpl");
+ cgiEndHTML();
+ return;
+ }
+ }
+ else if (username && !*username)
+ cgiSetVariable("ERROR",
+ cgiText(_("A Samba username is required to export "
+ "printer drivers!")));
+ else if (username && (!password || !*password))
+ cgiSetVariable("ERROR",
+ cgiText(_("A Samba password is required to export "
+ "printer drivers!")));
+
/*
* Show form...
*/
+ cgiStartHTML(cgiText(_("Export Printers to Samba")));
cgiCopyTemplateLang("samba-export.tmpl");
cgiEndHTML();
}
@@ -2712,10 +2070,10 @@ do_export(http_t *http) /* I - HTTP connection */
static void
do_menu(http_t *http) /* I - HTTP connection */
{
- cups_file_t *cupsd; /* cupsd.conf file */
- char line[1024], /* Line from cupsd.conf file */
- *value; /* Value on line */
- const char *server_root; /* Location of config files */
+ int num_settings; /* Number of server settings */
+ cups_option_t *settings; /* Server settings */
+ const char *val; /* Setting value */
+ char filename[1024]; /* Temporary filename */
const char *datadir; /* Location of data files */
ipp_t *request, /* IPP request */
*response; /* IPP response */
@@ -2723,165 +2081,37 @@ do_menu(http_t *http) /* I - HTTP connection */
/*
- * Locate the cupsd.conf file...
+ * Get the current server settings...
*/
- if ((server_root = getenv("CUPS_SERVERROOT")) == NULL)
- server_root = CUPS_SERVERROOT;
-
- snprintf(line, sizeof(line), "%s/cupsd.conf", server_root);
-
- cgiStartHTML(cgiText(_("Administration")));
-
- printf("\n", line);
-
- /*
- * Open the cupsd.conf file...
- */
-
- if ((cupsd = cupsFileOpen(line, "r")) == NULL)
+ if (!_cupsAdminGetServerSettings(http, &num_settings, &settings))
{
- /*
- * Unable to open - log an error...
- */
-
+ cgiStartHTML(cgiText(_("Administration")));
cgiSetVariable("MESSAGE", cgiText(_("Unable to open cupsd.conf file:")));
- cgiSetVariable("ERROR", strerror(errno));
+ cgiSetVariable("ERROR", cupsLastErrorString());
cgiCopyTemplateLang("error.tmpl");
cgiEndHTML();
-
- perror(line);
}
- else
- {
- /*
- * Read the file, keeping track of what settings are enabled...
- */
- int remote_access = 0, /* Remote access allowed? */
- remote_admin = 0, /* Remote administration allowed? */
- browsing = 1, /* Browsing enabled? */
- browse_allow = 1, /* Browse address set? */
- browse_address = 0, /* Browse address set? */
- cancel_policy = 1, /* Cancel-job policy set? */
- debug_logging = 0; /* LogLevel debug set? */
- int linenum = 0, /* Line number in file */
- in_policy = 0, /* In a policy section? */
- in_cancel_job = 0, /* In a cancel-job section? */
- in_admin_location = 0; /* In the /admin location? */
+ if ((val = cupsGetOption(CUPS_SERVER_DEBUG_LOGGING, num_settings,
+ settings)) != NULL && atoi(val))
+ cgiSetVariable("DEBUG_LOGGING", "CHECKED");
+ if ((val = cupsGetOption(CUPS_SERVER_REMOTE_ADMIN, num_settings,
+ settings)) != NULL && atoi(val))
+ cgiSetVariable("REMOTE_ADMIN", "CHECKED");
- while (cupsFileGetConf(cupsd, line, sizeof(line), &value, &linenum))
- {
- if (!strcasecmp(line, "Port"))
- {
- remote_access = 1;
- }
- else if (!strcasecmp(line, "Listen"))
- {
- char *port; /* Pointer to port number, if any */
+ if ((val = cupsGetOption(CUPS_SERVER_REMOTE_PRINTERS, num_settings,
+ settings)) != NULL && atoi(val))
+ cgiSetVariable("REMOTE_PRINTERS", "CHECKED");
+ if ((val = cupsGetOption(CUPS_SERVER_SHARE_PRINTERS, num_settings,
+ settings)) != NULL && atoi(val))
+ cgiSetVariable("SHARE_PRINTERS", "CHECKED");
- if ((port = strrchr(value, ':')) != NULL)
- *port = '\0';
-
- if (strcasecmp(value, "localhost") && strcmp(value, "127.0.0.1"))
- remote_access = 1;
- }
- else if (!strcasecmp(line, "Browsing"))
- {
- browsing = !strcasecmp(value, "yes") || !strcasecmp(value, "on") ||
- !strcasecmp(value, "true");
- }
- else if (!strcasecmp(line, "BrowseAddress"))
- {
- browse_address = 1;
- }
- else if (!strcasecmp(line, "BrowseAllow"))
- {
- browse_allow = 1;
- }
- else if (!strcasecmp(line, "BrowseOrder"))
- {
- browse_allow = !strncasecmp(value, "deny,", 5);
- }
- else if (!strcasecmp(line, "LogLevel"))
- {
- debug_logging = !strncasecmp(value, "debug", 5);
- }
- else if (!strcasecmp(line, ""))
- {
- in_policy = 0;
- }
- else if (!strcasecmp(line, ""))
- {
- in_cancel_job = 0;
- }
- else if (!strcasecmp(line, "Require") && in_cancel_job)
- {
- cancel_policy = 0;
- }
- else if (!strcasecmp(line, ""))
- {
- in_admin_location = 0;
- }
- else if (!strcasecmp(line, "Allow") && in_admin_location &&
- strcasecmp(value, "localhost") && strcasecmp(value, "127.0.0.1"))
- {
- remote_admin = 1;
- }
- }
-
- cupsFileClose(cupsd);
-
- if (browsing && browse_allow)
- cgiSetVariable("REMOTE_PRINTERS", "CHECKED");
-
- if (remote_access && browsing && browse_address)
- cgiSetVariable("SHARE_PRINTERS", "CHECKED");
-
- if (remote_access && remote_admin)
- cgiSetVariable("REMOTE_ADMIN", "CHECKED");
-
- if (cancel_policy)
- cgiSetVariable("USER_CANCEL_ANY", "CHECKED");
-
- if (debug_logging)
- cgiSetVariable("DEBUG_LOGGING", "CHECKED");
- }
+ if ((val = cupsGetOption(CUPS_SERVER_USER_CANCEL_ANY, num_settings,
+ settings)) != NULL && atoi(val))
+ cgiSetVariable("USER_CANCEL_ANY", "CHECKED");
/*
* Get the list of printers and their devices...
@@ -3100,33 +2330,39 @@ do_menu(http_t *http) /* I - HTTP connection */
if ((datadir = getenv("CUPS_DATADIR")) == NULL)
datadir = CUPS_DATADIR;
- snprintf(line, sizeof(line), "%s/drivers/pscript5.dll", datadir);
- if (!access(line, 0))
+ snprintf(filename, sizeof(filename), "%s/drivers/pscript5.dll", datadir);
+ if (!access(filename, R_OK))
{
/*
* Found Windows 2000 driver file, see if we have smbclient and
* rpcclient...
*/
- if (cupsFileFind("smbclient", getenv("PATH"), 1, line, sizeof(line)) &&
- cupsFileFind("rpcclient", getenv("PATH"), 1, line, sizeof(line)))
+ if (cupsFileFind("smbclient", getenv("PATH"), 1, filename,
+ sizeof(filename)) &&
+ cupsFileFind("rpcclient", getenv("PATH"), 1, filename,
+ sizeof(filename)))
cgiSetVariable("HAVE_SAMBA", "Y");
else
{
- if (!cupsFileFind("smbclient", getenv("PATH"), 1, line, sizeof(line)))
+ if (!cupsFileFind("smbclient", getenv("PATH"), 1, filename,
+ sizeof(filename)))
fputs("ERROR: smbclient not found!\n", stderr);
- if (!cupsFileFind("rpcclient", getenv("PATH"), 1, line, sizeof(line)))
+ if (!cupsFileFind("rpcclient", getenv("PATH"), 1, filename,
+ sizeof(filename)))
fputs("ERROR: rpcclient not found!\n", stderr);
}
}
else
- perror(line);
+ perror(filename);
/*
* Finally, show the main menu template...
*/
+ cgiStartHTML(cgiText(_("Administration")));
+
cgiCopyTemplateLang("admin.tmpl");
cgiEndHTML();
@@ -3610,5 +2846,5 @@ match_string(const char *a, /* I - First string */
/*
- * End of "$Id: admin.c 5107 2006-02-15 19:14:17Z mike $".
+ * End of "$Id: admin.c 5240 2006-03-07 21:55:29Z mike $".
*/
diff --git a/cgi-bin/ipp-var.c b/cgi-bin/ipp-var.c
index fb598f84f..274c8e9b8 100644
--- a/cgi-bin/ipp-var.c
+++ b/cgi-bin/ipp-var.c
@@ -1,5 +1,5 @@
/*
- * "$Id: ipp-var.c 5184 2006-02-26 15:13:44Z mike $"
+ * "$Id: ipp-var.c 5235 2006-03-06 13:02:23Z mike $"
*
* CGI <-> IPP variable routines for the Common UNIX Printing System (CUPS).
*
@@ -661,7 +661,7 @@ cgiRewriteURL(const char *uri, /* I - Current URI */
if ((server = getenv("SERVER_NAME")) == NULL)
server = "";
- httpGetHostname(servername, sizeof(servername));
+ httpGetHostname(NULL, servername, sizeof(servername));
/*
* Then flag whether we are using SSL on this connection...
@@ -1277,5 +1277,5 @@ cgiText(const char *message) /* I - Message */
/*
- * End of "$Id: ipp-var.c 5184 2006-02-26 15:13:44Z mike $".
+ * End of "$Id: ipp-var.c 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/conf/Makefile b/conf/Makefile
index 82a796509..e806900af 100644
--- a/conf/Makefile
+++ b/conf/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5185 2006-02-26 15:27:14Z mike $"
+# "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $"
#
# Configuration file makefile for the Common UNIX Printing System (CUPS).
#
@@ -28,7 +28,7 @@ include ../Makedefs
# Config files...
#
-KEEP = client.conf cupsd.conf
+KEEP = cupsd.conf
REPLACE = mime.convs mime.types
@@ -46,6 +46,13 @@ all:
clean:
+#
+# Dummy depend...
+#
+
+depend:
+
+
#
# Install files...
#
@@ -81,5 +88,20 @@ install: all
#
-# End of "$Id: Makefile 5185 2006-02-26 15:27:14Z mike $".
+# Uninstall files...
+#
+
+uninstall:
+ for file in $(KEEP) $(REPLACE) cupsd.conf.default; do \
+ $(RM) $(SERVERROOT)/$$file; \
+ done
+ -$(RMDIR) $(SERVERROOT)
+ -if test x$(PAMDIR) != x; then \
+ $(RM) $(BUILDROOT)$(PAMDIR)/cups; \
+ $(RMDIR) $(BUILDROOT)$(PAMDIR); \
+ fi
+
+
+#
+# End of "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $".
#
diff --git a/conf/client.conf b/conf/client.conf
deleted file mode 100644
index dfe332165..000000000
--- a/conf/client.conf
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# "$Id: client.conf 4494 2005-02-18 02:18:11Z mike $"
-#
-# Sample client configuration file for the Common UNIX Printing System
-# (CUPS).
-#
-# Copyright 1997-2005 by Easy Software Products, all rights reserved.
-#
-# These coded instructions, statements, and computer programs are the
-# property of Easy Software Products and are protected by Federal
-# copyright law. Distribution and use rights are outlined in the file
-# "LICENSE.txt" which should have been included with this file. If this
-# file is missing or damaged please contact Easy Software Products
-# at:
-#
-# Attn: CUPS Licensing Information
-# Easy Software Products
-# 44141 Airport View Drive, Suite 204
-# Hollywood, Maryland 20636 USA
-#
-# Voice: (301) 373-9600
-# EMail: cups-info@cups.org
-# WWW: http://www.cups.org
-#
-
-########################################################################
-# #
-# This is the CUPS client configuration file. This file is used to #
-# define client-specific parameters, such as the default server or #
-# default encryption settings. #
-# #
-########################################################################
-
-#
-# ServerName: the hostname of your server. By default CUPS will use the
-# hostname of the system or the value of the CUPS_SERVER environment
-# variable. ONLY ONE SERVER NAME MAY BE SPECIFIED AT A TIME. To use
-# more than one server you must use a local scheduler with browsing
-# and possibly polling.
-#
-
-#ServerName myhost.domain.com
-
-#
-# Encryption: whether or not to use encryption; this depends on having
-# the OpenSSL library linked into the CUPS library.
-#
-# Possible values:
-#
-# Always - Always use encryption (SSL)
-# Never - Never use encryption
-# Required - Use TLS encryption upgrade
-# IfRequested - Use encryption if the server requests it
-#
-# The default value is "IfRequested". This parameter can also be set
-# using the CUPS_ENCRYPTION environment variable.
-#
-
-#Encryption Always
-#Encryption Never
-#Encryption Required
-#Encryption IfRequested
-
-
-#
-# End of "$Id: client.conf 4494 2005-02-18 02:18:11Z mike $".
-#
diff --git a/config-scripts/cups-common.m4 b/config-scripts/cups-common.m4
index abad61d56..ccc3b460b 100644
--- a/config-scripts/cups-common.m4
+++ b/config-scripts/cups-common.m4
@@ -1,5 +1,5 @@
dnl
-dnl "$Id: cups-common.m4 5144 2006-02-21 20:44:01Z mike $"
+dnl "$Id: cups-common.m4 5229 2006-03-05 16:48:12Z mike $"
dnl
dnl Common configuration stuff for the Common UNIX Printing System (CUPS).
dnl
@@ -63,6 +63,7 @@ AC_PATH_PROG(LD,ld)
AC_PATH_PROG(LN,ln)
AC_PATH_PROG(MV,mv)
AC_PATH_PROG(RM,rm)
+AC_PATH_PROG(RM,rmdir)
AC_PATH_PROG(SED,sed)
AC_PATH_PROG(STRIP,strip)
@@ -263,5 +264,5 @@ AC_SUBST(DEFAULT_IPP_PORT)
AC_DEFINE_UNQUOTED(CUPS_DEFAULT_IPP_PORT,$DEFAULT_IPP_PORT)
dnl
-dnl End of "$Id: cups-common.m4 5144 2006-02-21 20:44:01Z mike $".
+dnl End of "$Id: cups-common.m4 5229 2006-03-05 16:48:12Z mike $".
dnl
diff --git a/cups/Dependencies b/cups/Dependencies
index 9b68b1299..e979f0371 100644
--- a/cups/Dependencies
+++ b/cups/Dependencies
@@ -1,11 +1,13 @@
# DO NOT DELETE
+adminutil.o: adminutil.h cups.h ipp.h http.h md5.h ppd.h array.h file.h
+adminutil.o: language.h globals.h string.h ../config.h i18n.h normalize.h
+adminutil.o: transcode.h debug.h
array.o: array.h string.h ../config.h debug.h
attr.o: ppd.h array.h file.h debug.h string.h ../config.h
auth.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
auth.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
-backchannel.o: cups.h ipp.h http.h string.h ../config.h md5.h ppd.h array.h
-backchannel.o: file.h language.h
+backchannel.o: cups.h ipp.h http.h md5.h ppd.h array.h file.h language.h
backend.o: backend.h string.h ../config.h
custom.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
custom.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
@@ -13,28 +15,28 @@ dest.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
dest.o: array.h file.h language.h i18n.h normalize.h transcode.h
dir.o: dir.h string.h ../config.h debug.h
emit.o: ppd.h array.h file.h string.h ../config.h
-encode.o: cups.h ipp.h http.h string.h ../config.h md5.h ppd.h array.h file.h
-encode.o: language.h ipp-private.h debug.h
-file.o: http-private.h ../config.h http.h string.h md5.h ipp-private.h ipp.h
+encode.o: cups.h ipp.h http.h md5.h ppd.h array.h file.h language.h
+encode.o: ipp-private.h string.h ../config.h debug.h
+file.o: http-private.h ../config.h http.h md5.h ipp-private.h ipp.h string.h
file.o: ../cups/debug.h file.h
-getputfile.o: cups.h ipp.h http.h string.h ../config.h md5.h ppd.h array.h
-getputfile.o: file.h language.h debug.h
-globals.o: http-private.h ../config.h http.h string.h md5.h ipp-private.h
-globals.o: ipp.h globals.h cups.h ppd.h array.h file.h language.h i18n.h
+getputfile.o: cups.h ipp.h http.h md5.h ppd.h array.h file.h language.h
+getputfile.o: string.h ../config.h debug.h
+globals.o: http-private.h ../config.h http.h md5.h ipp-private.h ipp.h
+globals.o: globals.h string.h cups.h ppd.h array.h file.h language.h i18n.h
globals.o: normalize.h transcode.h
-http.o: http-private.h ../config.h http.h string.h md5.h ipp-private.h ipp.h
-http.o: globals.h cups.h ppd.h array.h file.h language.h i18n.h normalize.h
+http.o: http-private.h ../config.h http.h md5.h ipp-private.h ipp.h globals.h
+http.o: string.h cups.h ppd.h array.h file.h language.h i18n.h normalize.h
http.o: transcode.h debug.h
http-addr.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
http-addr.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
-http-addrlist.o: http-private.h ../config.h http.h string.h md5.h
-http-addrlist.o: ipp-private.h ipp.h globals.h cups.h ppd.h array.h file.h
-http-addrlist.o: language.h i18n.h normalize.h transcode.h debug.h
+http-addrlist.o: http-private.h ../config.h http.h md5.h ipp-private.h ipp.h
+http-addrlist.o: globals.h string.h cups.h ppd.h array.h file.h language.h
+http-addrlist.o: i18n.h normalize.h transcode.h debug.h
http-support.o: debug.h globals.h string.h ../config.h cups.h ipp.h http.h
http-support.o: md5.h ppd.h array.h file.h language.h i18n.h normalize.h
http-support.o: transcode.h
-ipp.o: http-private.h ../config.h http.h string.h md5.h ipp-private.h ipp.h
-ipp.o: globals.h cups.h ppd.h array.h file.h language.h i18n.h normalize.h
+ipp.o: http-private.h ../config.h http.h md5.h ipp-private.h ipp.h globals.h
+ipp.o: string.h cups.h ppd.h array.h file.h language.h i18n.h normalize.h
ipp.o: transcode.h debug.h
ipp-support.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
ipp-support.o: array.h file.h language.h i18n.h normalize.h transcode.h
@@ -45,15 +47,16 @@ language.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
language.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
localize.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
localize.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
-mark.o: ppd.h array.h file.h string.h ../config.h debug.h
+mark.o: cups.h ipp.h http.h md5.h ppd.h array.h file.h language.h string.h
+mark.o: ../config.h debug.h
md5.o: md5.h string.h ../config.h
-md5passwd.o: http.h string.h ../config.h md5.h
+md5passwd.o: http.h md5.h string.h ../config.h
normalize.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
normalize.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
notify.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
notify.o: array.h file.h language.h i18n.h normalize.h transcode.h
-options.o: cups.h ipp.h http.h string.h ../config.h md5.h ppd.h array.h
-options.o: file.h language.h debug.h
+options.o: cups.h ipp.h http.h md5.h ppd.h array.h file.h language.h string.h
+options.o: ../config.h debug.h
page.o: ppd.h array.h file.h string.h ../config.h
ppd.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h array.h
ppd.o: file.h language.h i18n.h normalize.h transcode.h debug.h
@@ -66,14 +69,16 @@ tempfile.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
tempfile.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
transcode.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
transcode.o: array.h file.h language.h i18n.h normalize.h transcode.h
-usersys.o: http-private.h ../config.h http.h string.h md5.h ipp-private.h
-usersys.o: ipp.h globals.h cups.h ppd.h array.h file.h language.h i18n.h
+usersys.o: http-private.h ../config.h http.h md5.h ipp-private.h ipp.h
+usersys.o: globals.h string.h cups.h ppd.h array.h file.h language.h i18n.h
usersys.o: normalize.h transcode.h
util.o: globals.h string.h ../config.h cups.h ipp.h http.h md5.h ppd.h
util.o: array.h file.h language.h i18n.h normalize.h transcode.h debug.h
+testadmin.o: adminutil.h cups.h ipp.h http.h md5.h ppd.h array.h file.h
+testadmin.o: language.h string.h ../config.h
testarray.o: ../cups/string.h ../config.h string.h array.h dir.h debug.h
testfile.o: string.h ../config.h file.h debug.h
-testhttp.o: http.h string.h ../config.h md5.h
+testhttp.o: http.h md5.h string.h ../config.h
testi18n.o: language.h array.h string.h ../config.h transcode.h normalize.h
testipp.o: ../cups/string.h ../config.h string.h ipp.h http.h md5.h
testlang.o: i18n.h language.h array.h
diff --git a/cups/Makefile b/cups/Makefile
index cbd6e36f4..750b80bc9 100644
--- a/cups/Makefile
+++ b/cups/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5138 2006-02-21 10:49:06Z mike $"
+# "$Id: Makefile 5240 2006-03-07 21:55:29Z mike $"
#
# API library Makefile for the Common UNIX Printing System (CUPS).
#
@@ -31,6 +31,7 @@ include ../Makedefs
#
LIBOBJS = \
+ adminutil.o \
array.o \
attr.o \
auth.o \
@@ -70,6 +71,7 @@ LIBOBJS = \
util.o
OBJS = \
$(LIBOBJS) \
+ testadmin.o \
testarray.o \
testfile.o \
testhttp.o \
@@ -85,6 +87,7 @@ OBJS = \
#
HEADERS = \
+ adminutil.h \
array.h \
cups.h \
dir.h \
@@ -106,6 +109,7 @@ HEADERS = \
TARGETS = \
$(LIBCUPS) \
libcups.a \
+ testadmin \
testarray \
testfile \
testhttp \
@@ -169,6 +173,26 @@ installhdrs:
done
+#
+# Uninstall object and target files...
+#
+
+uninstall:
+ $(RM) $(LIBDIR)/libcups.2.dylib
+ $(RM) $(LIBDIR)/libcups.a
+ $(RM) $(LIBDIR)/libcups.dylib
+ $(RM) $(LIBDIR)/libcups_s.a
+ $(RM) $(LIBDIR)/libcups.sl
+ $(RM) $(LIBDIR)/libcups.sl.2
+ $(RM) $(LIBDIR)/libcups.so
+ $(RM) $(LIBDIR)/libcups.so.2
+ -$(RMDIR) $(LIBDIR)
+ for file in $(HEADERS); do \
+ $(RM) $(INCLUDEDIR)/cups/$$file; \
+ done
+ -$(RMDIR) $(INCLUDEDIR)/cups
+
+
#
# libcups.so.2, libcups.sl.2
#
@@ -230,6 +254,9 @@ libcups.a: $(LIBOBJS)
#
# CUPS language bindings for various scripting languages...
#
+# NOTE: Not currently used or functional - see the scripting/php directory
+# for the hand-written bindings...
+#
phpcups.so: $(LIBCUPS) php_cups_wrap.o
echo Linking $@...
@@ -248,6 +275,16 @@ php_cups_wrap.c: cups.h
swig -php -o $@ -module cups cups.h
+#
+# testadmin (dependency on static CUPS library is intentional)
+#
+
+testadmin: testadmin.o libcups.a
+ echo Linking $@...
+ $(CC) $(LDFLAGS) -o $@ testadmin.o libcups.a \
+ $(SSLLIBS) $(COMMONLIBS) $(LIBZ)
+
+
#
# testarray (dependency on static CUPS library is intentional)
#
@@ -357,5 +394,5 @@ include Dependencies
#
-# End of "$Id: Makefile 5138 2006-02-21 10:49:06Z mike $".
+# End of "$Id: Makefile 5240 2006-03-07 21:55:29Z mike $".
#
diff --git a/cups/adminutil.c b/cups/adminutil.c
new file mode 100644
index 000000000..44ffe6ed9
--- /dev/null
+++ b/cups/adminutil.c
@@ -0,0 +1,1900 @@
+/*
+ * "$Id: adminutil.c 5240 2006-03-07 21:55:29Z mike $"
+ *
+ * Administration utility API definitions for the Common UNIX Printing
+ * System (CUPS).
+ *
+ * MANY OF THE FUNCTIONS IN THIS HEADER ARE PRIVATE AND SUBJECT TO
+ * CHANGE AT ANY TIME. USE AT YOUR OWN RISK.
+ *
+ * Copyright 2001-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:
+ *
+ * cupsAdminCreateWindowsPPD() - Create the Windows PPD file for a printer.
+ * cupsAdminExportSamba() - Export a printer to Samba.
+ * _cupsAdminGetServerSettings() - Get settings from the server.
+ * _cupsAdminSetServerSettings() - Set settings on the server.
+ * do_samba_command() - Do a SAMBA command.
+ * get_cupsd_conf() - Get the current cupsd.conf file.
+ * invalidate_cupsd_cache() - Invalidate the cached cupsd.conf settings.
+ * write_option() - Write a CUPS option to a PPD file.
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "adminutil.h"
+#include "globals.h"
+#include "debug.h"
+#include
+#include
+#include
+#include
+#include
+
+
+/*
+ * Local functions...
+ */
+
+static int do_samba_command(const char *command,
+ const char *address,
+ const char *subcommand,
+ const char *authfile,
+ FILE *logfile);
+static http_status_t get_cupsd_conf(http_t *http, _cups_globals_t *cg,
+ time_t last_update, char *name,
+ int namelen, int *remote);
+static void invalidate_cupsd_cache(_cups_globals_t *cg);
+static void write_option(cups_file_t *dstfp, int order,
+ const char *name, const char *text,
+ const char *attrname,
+ ipp_attribute_t *suppattr,
+ ipp_attribute_t *defattr, int defval,
+ int valcount);
+
+
+/*
+ * 'cupsAdminCreateWindowsPPD()' - Create the Windows PPD file for a printer.
+ */
+
+char * /* O - PPD file or NULL */
+cupsAdminCreateWindowsPPD(
+ http_t *http, /* I - Connection to server */
+ const char *dest, /* I - Printer or class */
+ char *buffer, /* I - Filename buffer */
+ int bufsize) /* I - Size of filename buffer */
+{
+ const char *src; /* Source PPD filename */
+ cups_file_t *srcfp, /* Source PPD file */
+ *dstfp; /* Destination PPD file */
+ ipp_t *request, /* IPP request */
+ *response; /* IPP response */
+ ipp_attribute_t *suppattr, /* IPP -supported attribute */
+ *defattr; /* IPP -default attribute */
+ cups_lang_t *language; /* Current language */
+ char line[256], /* Line from PPD file */
+ junk[256], /* Extra junk to throw away */
+ *ptr, /* Pointer into line */
+ uri[1024], /* Printer URI */
+ option[41], /* Option */
+ choice[41]; /* Choice */
+ int jcloption, /* In a JCL option? */
+ linenum; /* Current line number */
+ time_t curtime; /* Current time */
+ struct tm *curdate; /* Current date */
+ static const char *pattrs[] = /* Printer attributes we want */
+ {
+ "job-hold-until-supported",
+ "job-hold-until-default",
+ "job-sheets-supported",
+ "job-sheets-default",
+ "job-priority-supported",
+ "job-priority-default"
+ };
+
+
+ /*
+ * Range check the input...
+ */
+
+ if (buffer)
+ *buffer = '\0';
+
+ if (!http || !dest || !buffer || bufsize < 2)
+ return (NULL);
+
+ /*
+ * Get the PPD file...
+ */
+
+ if ((src = cupsGetPPD2(http, dest)) == NULL)
+ return (NULL);
+
+ /*
+ * Get the supported banner pages, etc. for the printer...
+ */
+
+ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+
+ 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);
+
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
+ NULL, pattrs);
+
+ /*
+ * Do the request and get back a response...
+ */
+
+ response = cupsDoRequest(http, request, "/");
+ if (!response || cupsLastError() > IPP_OK_CONFLICT)
+ {
+ unlink(src);
+ return (NULL);
+ }
+
+ /*
+ * Open the original PPD file...
+ */
+
+ if ((srcfp = cupsFileOpen(src, "rb")) == NULL)
+ return (NULL);
+
+ /*
+ * Create a temporary output file using the destination buffer...
+ */
+
+ if ((dstfp = cupsTempFile2(buffer, bufsize)) < 0)
+ {
+ cupsFileClose(srcfp);
+
+ unlink(src);
+
+ return (NULL);
+ }
+
+ /*
+ * Write a new header explaining that this isn't the original PPD...
+ */
+
+ cupsFilePuts(dstfp, "*PPD-Adobe: \"4.3\"\n");
+
+ curtime = time(NULL);
+ curdate = gmtime(&curtime);
+
+ cupsFilePrintf(dstfp, "*%% Modified on %04d%02d%02d%02d%02d%02d+0000 "
+ "for CUPS Windows Driver\n",
+ curdate->tm_year + 1900, curdate->tm_mon + 1, curdate->tm_mday,
+ curdate->tm_hour, curdate->tm_min, curdate->tm_sec);
+
+ /*
+ * Read the existing PPD file, converting all PJL commands to CUPS
+ * job ticket comments...
+ */
+
+ jcloption = 0;
+ linenum = 0;
+ language = cupsLangDefault();
+
+ while (cupsFileGets(srcfp, line, sizeof(line)))
+ {
+ linenum ++;
+
+ if (!strncmp(line, "*PPD-Adobe:", 11))
+ {
+ /*
+ * Already wrote the PPD header...
+ */
+
+ continue;
+ }
+ else if (!strncmp(line, "*JCLBegin:", 10) ||
+ !strncmp(line, "*JCLToPSInterpreter:", 20) ||
+ !strncmp(line, "*JCLEnd:", 8) ||
+ !strncmp(line, "*Protocols:", 11))
+ {
+ /*
+ * Don't use existing JCL keywords; we'll create our own, below...
+ */
+
+ cupsFilePrintf(dstfp, "*%% Commented out for CUPS Windows Driver...\n"
+ "*%%%s", line + 1);
+ continue;
+ }
+ else if (!strncmp(line, "*JCLOpenUI", 10))
+ {
+ jcloption = 1;
+ cupsFilePuts(dstfp, line);
+ }
+ else if (!strncmp(line, "*JCLCloseUI", 11))
+ {
+ jcloption = 0;
+ cupsFilePuts(dstfp, line);
+ }
+ else if (jcloption &&
+ strncmp(line, "*End", 4) &&
+ strncmp(line, "*Default", 8) &&
+ strncmp(line, "*OrderDependency", 16))
+ {
+ if ((ptr = strchr(line, ':')) == NULL)
+ {
+ snprintf(line, sizeof(line),
+ _cupsLangString(language, _("Missing value on line %d!\n")),
+ linenum);
+ _cupsSetError(IPP_DOCUMENT_FORMAT_ERROR, line);
+
+ cupsFileClose(srcfp);
+ cupsFileClose(dstfp);
+
+ unlink(src);
+ unlink(buffer);
+
+ *buffer = '\0';
+
+ return (NULL);
+ }
+
+ if ((ptr = strchr(ptr, '\"')) == NULL)
+ {
+ snprintf(line, sizeof(line),
+ _cupsLangString(language,
+ _("Missing double quote on line %d!\n")),
+ linenum);
+ _cupsSetError(IPP_DOCUMENT_FORMAT_ERROR, line);
+
+ cupsFileClose(srcfp);
+ cupsFileClose(dstfp);
+
+ unlink(src);
+ unlink(buffer);
+
+ *buffer = '\0';
+
+ return (NULL);
+ }
+
+ if (sscanf(line, "*%40s%*[ \t]%40[^/]", option, choice) != 2)
+ {
+ snprintf(line, sizeof(line),
+ _cupsLangString(language,
+ _("Bad option + choice on line %d!\n")),
+ linenum);
+ _cupsSetError(IPP_DOCUMENT_FORMAT_ERROR, line);
+
+ cupsFileClose(srcfp);
+ cupsFileClose(dstfp);
+
+ unlink(src);
+ unlink(buffer);
+
+ *buffer = '\0';
+
+ return (NULL);
+ }
+
+ if (strchr(ptr + 1, '\"') == NULL)
+ {
+ /*
+ * Skip remaining...
+ */
+
+ while (cupsFileGets(srcfp, junk, sizeof(junk)) != NULL)
+ {
+ linenum ++;
+
+ if (!strncmp(junk, "*End", 4))
+ break;
+ }
+ }
+
+ snprintf(ptr + 1, sizeof(line) - (ptr - line + 1),
+ "%%cupsJobTicket: %s=%s\n\"\n*End\n", option, choice);
+
+ cupsFilePrintf(dstfp, "*%% Changed for CUPS Windows Driver...\n%s", line);
+ }
+ else
+ cupsFilePuts(dstfp, line);
+ }
+
+ cupsFileClose(srcfp);
+ unlink(src);
+
+ /*
+ * Now add the CUPS-specific attributes and options...
+ */
+
+ cupsFilePuts(dstfp, "\n*% CUPS Job Ticket support and options...\n");
+ cupsFilePuts(dstfp, "*Protocols: PJL\n");
+ cupsFilePuts(dstfp, "*JCLBegin: \"%!PS-Adobe-3.0<0A>\"\n");
+ cupsFilePuts(dstfp, "*JCLToPSInterpreter: \"\"\n");
+ cupsFilePuts(dstfp, "*JCLEnd: \"\"\n");
+
+ cupsFilePuts(dstfp, "\n*OpenGroup: CUPS/CUPS Options\n\n");
+
+ if ((defattr = ippFindAttribute(response, "job-hold-until-default",
+ IPP_TAG_ZERO)) != NULL &&
+ (suppattr = ippFindAttribute(response, "job-hold-until-supported",
+ IPP_TAG_ZERO)) != NULL)
+ write_option(dstfp, 10, "cupsJobHoldUntil", "Hold Until", "job-hold-until",
+ suppattr, defattr, 0, 1);
+
+ if ((defattr = ippFindAttribute(response, "job-priority-default",
+ IPP_TAG_INTEGER)) != NULL &&
+ (suppattr = ippFindAttribute(response, "job-priority-supported",
+ IPP_TAG_RANGE)) != NULL)
+ write_option(dstfp, 11, "cupsJobPriority", "Priority", "job-priority",
+ suppattr, defattr, 0, 1);
+
+ if ((defattr = ippFindAttribute(response, "job-sheets-default",
+ IPP_TAG_ZERO)) != NULL &&
+ (suppattr = ippFindAttribute(response, "job-sheets-supported",
+ IPP_TAG_ZERO)) != NULL)
+ {
+ write_option(dstfp, 20, "cupsJobSheetsStart", "Start Banner",
+ "job-sheets", suppattr, defattr, 0, 2);
+ write_option(dstfp, 21, "cupsJobSheetsEnd", "End Banner",
+ "job-sheets", suppattr, defattr, 1, 2);
+ }
+
+ cupsFilePuts(dstfp, "*CloseGroup: CUPS\n");
+ cupsFileClose(dstfp);
+
+ ippDelete(response);
+
+ return (buffer);
+}
+
+
+/*
+ * 'cupsAdminExportSamba()' - Export a printer to Samba.
+ */
+
+int /* O - 1 on success, 0 on failure */
+cupsAdminExportSamba(
+ const char *dest, /* I - Destination to export */
+ const char *ppd, /* I - PPD file */
+ const char *samba_server, /* I - Samba server */
+ const char *samba_user, /* I - Samba username */
+ const char *samba_password, /* I - Samba password */
+ FILE *logfile) /* I - Log file, if any */
+{
+ int status; /* Status of smbclient/rpcclient commands */
+ int have_drivers; /* Have drivers? */
+ char file[1024], /* File to test for */
+ authfile[1024], /* Temporary authentication file */
+ address[1024], /* Address for command */
+ subcmd[1024], /* Sub-command */
+ message[1024]; /* Error message */
+ cups_file_t *fp; /* Authentication file */
+ cups_lang_t *language; /* Current language */
+ _cups_globals_t *cg = _cupsGlobals();
+ /* Global data */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!dest || !ppd || !samba_server || !samba_user || !samba_password)
+ {
+ _cupsSetError(IPP_INTERNAL_ERROR, NULL);
+ return (0);
+ }
+
+ /*
+ * Create a temporary authentication file for Samba...
+ */
+
+ if ((fp = cupsTempFile2(authfile, sizeof(authfile))) == NULL)
+ {
+ _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno));
+ return (0);
+ }
+
+ cupsFilePrintf(fp, "username = %s\n", samba_user);
+ cupsFilePrintf(fp, "password = %s\n", samba_password);
+ cupsFileClose(fp);
+
+ /*
+ * See which drivers are available; the new CUPS v6 and Adobe drivers
+ * depend on the Windows 2k PS driver, so copy that driver first:
+ *
+ * Files:
+ *
+ * ps5ui.dll
+ * pscript.hlp
+ * pscript.ntf
+ * pscript5.dll
+ */
+
+ have_drivers = 0;
+ language = cupsLangDefault();
+
+ snprintf(file, sizeof(file), "%s/drivers/pscript5.dll", cg->cups_datadir);
+ if (!access(file, 0))
+ {
+ have_drivers |= 1;
+
+ /*
+ * Windows 2k driver is installed; do the smbclient commands needed
+ * to copy the Win2k drivers over...
+ */
+
+ snprintf(address, sizeof(address), "//%s/print$", samba_server);
+
+ snprintf(subcmd, sizeof(subcmd),
+ "mkdir W32X86;"
+ "put %s W32X86/%s.ppd;"
+ "put %s/drivers/ps5ui.dll W32X86/ps5ui.dll;"
+ "put %s/drivers/pscript.hlp W32X86/pscript.hlp;"
+ "put %s/drivers/pscript.ntf W32X86/pscript.ntf;"
+ "put %s/drivers/pscript5.dll W32X86/pscript5.dll",
+ ppd, dest, cg->cups_datadir, cg->cups_datadir,
+ cg->cups_datadir, cg->cups_datadir);
+
+ if ((status = do_samba_command("smbclient", address, subcmd,
+ authfile, logfile)) != 0)
+ {
+ snprintf(message, sizeof(message),
+ _cupsLangString(language,
+ _("Unable to copy Windows 2000 printer "
+ "driver files (%d)!")), status);
+
+ _cupsSetError(IPP_INTERNAL_ERROR, message);
+
+ if (logfile)
+ _cupsLangPrintf(logfile, "%s\n", message);
+
+ unlink(authfile);
+
+ return (0);
+ }
+
+ /*
+ * See if we also have the CUPS driver files; if so, use them!
+ */
+
+ snprintf(file, sizeof(file), "%s/drivers/cupsps6.dll", cg->cups_datadir);
+ if (!access(file, 0))
+ {
+ /*
+ * Copy the CUPS driver files over...
+ */
+
+ snprintf(subcmd, sizeof(subcmd),
+ "put %s/drivers/cups6.ini W32X86/cups6.ini;"
+ "put %s/drivers/cupsps6.dll W32X86/cupsps6.dll;"
+ "put %s/drivers/cupsui6.dll W32X86/cupsui6.dll",
+ cg->cups_datadir, cg->cups_datadir, cg->cups_datadir);
+
+ if ((status = do_samba_command("smbclient", address, subcmd,
+ authfile, logfile)) != 0)
+ {
+ snprintf(message, sizeof(message),
+ _cupsLangString(language,
+ _("Unable to copy CUPS printer driver "
+ "files (%d)!")), status);
+
+ _cupsSetError(IPP_INTERNAL_ERROR, message);
+
+ if (logfile)
+ _cupsLangPrintf(logfile, "%s\n", message);
+
+ unlink(authfile);
+
+ return (0);
+ }
+
+ /*
+ * Do the rpcclient command needed for the CUPS drivers...
+ */
+
+ snprintf(subcmd, sizeof(subcmd),
+ "adddriver \"Windows NT x86\" \"%s:"
+ "pscript5.dll:%s.ppd:ps5ui.dll:pscript.hlp:NULL:RAW:"
+ "pscript5.dll,%s.ppd,ps5ui.dll,pscript.hlp,pscript.ntf,"
+ "cups6.ini,cupsps6.dll,cupsui6.dll\"",
+ dest, dest, dest);
+ }
+ else
+ {
+ /*
+ * Don't have the CUPS drivers, so just use the standard Windows
+ * drivers...
+ */
+
+ snprintf(subcmd, sizeof(subcmd),
+ "adddriver \"Windows NT x86\" \"%s:"
+ "pscript5.dll:%s.ppd:ps5ui.dll:pscript.hlp:NULL:RAW:"
+ "pscript5.dll,%s.ppd,ps5ui.dll,pscript.hlp,pscript.ntf\"",
+ dest, dest, dest);
+ }
+
+ if ((status = do_samba_command("rpcclient", samba_server, subcmd,
+ authfile, logfile)) != 0)
+ {
+ snprintf(message, sizeof(message),
+ _cupsLangString(language,
+ _("Unable to install Windows 2000 printer "
+ "driver files (%d)!")), status);
+
+ _cupsSetError(IPP_INTERNAL_ERROR, message);
+
+ if (logfile)
+ _cupsLangPrintf(logfile, "%s\n", message);
+
+ unlink(authfile);
+
+ return (0);
+ }
+ }
+
+ snprintf(file, sizeof(file), "%s/drivers/ADOBEPS4.DRV", cg->cups_datadir);
+ if (!access(file, 0))
+ {
+ have_drivers |= 2;
+
+ /*
+ * Do the smbclient commands needed for the Adobe Win9x drivers...
+ */
+
+ snprintf(address, sizeof(address), "//%s/print$", samba_server);
+
+ snprintf(subcmd, sizeof(subcmd),
+ "mkdir WIN40;"
+ "put %s WIN40/%s.PPD;"
+ "put %s/drivers/ADFONTS.MFM WIN40/ADFONTS.MFM;"
+ "put %s/drivers/ADOBEPS4.DRV WIN40/ADOBEPS4.DRV;"
+ "put %s/drivers/ADOBEPS4.HLP WIN40/ADOBEPS4.HLP;"
+ "put %s/drivers/ICONLIB.DLL WIN40/ICONLIB.DLL;"
+ "put %s/drivers/PSMON.DLL WIN40/PSMON.DLL;",
+ ppd, dest, cg->cups_datadir, cg->cups_datadir,
+ cg->cups_datadir, cg->cups_datadir, cg->cups_datadir);
+
+ if ((status = do_samba_command("smbclient", address, subcmd,
+ authfile, logfile)) != 0)
+ {
+ snprintf(message, sizeof(message),
+ _cupsLangString(language,
+ _("Unable to copy Windows 9x printer "
+ "driver files (%d)!")), status);
+
+ _cupsSetError(IPP_INTERNAL_ERROR, message);
+
+ if (logfile)
+ _cupsLangPrintf(logfile, "%s\n", message);
+
+ unlink(authfile);
+
+ return (0);
+ }
+
+ /*
+ * Do the rpcclient commands needed for the Adobe Win9x drivers...
+ */
+
+ snprintf(subcmd, sizeof(subcmd),
+ "adddriver \"Windows 4.0\" \"%s:ADOBEPS4.DRV:%s.PPD:NULL:"
+ "ADOBEPS4.HLP:PSMON.DLL:RAW:"
+ "ADOBEPS4.DRV,%s.PPD,ADOBEPS4.HLP,PSMON.DLL,ADFONTS.MFM,"
+ "ICONLIB.DLL\"",
+ dest, dest, dest);
+
+ if ((status = do_samba_command("rpcclient", samba_server, subcmd,
+ authfile, logfile)) != 0)
+ {
+ snprintf(message, sizeof(message),
+ _cupsLangString(language,
+ _("Unable to install Windows 9x printer "
+ "driver files (%d)!")), status);
+
+ _cupsSetError(IPP_INTERNAL_ERROR, message);
+
+ if (logfile)
+ _cupsLangPrintf(logfile, "%s\n", message);
+
+ unlink(authfile);
+
+ return (0);
+ }
+ }
+
+ if (logfile && !(have_drivers & 1))
+ {
+ if (!have_drivers)
+ strlcpy(message,
+ _cupsLangString(language,
+ _("No Windows printer drivers are installed!")),
+ sizeof(message));
+ else
+ strlcpy(message,
+ _cupsLangString(language,
+ _("Warning, no Windows 2000 printer drivers "
+ "are installed!")),
+ sizeof(message));
+
+ _cupsSetError(IPP_INTERNAL_ERROR, message);
+ _cupsLangPrintf(logfile, "%s\n", message);
+ }
+
+ if (have_drivers == 0)
+ return (0);
+
+ /*
+ * Finally, associate the drivers we just added with the queue...
+ */
+
+ snprintf(subcmd, sizeof(subcmd), "setdriver %s %s", dest, dest);
+
+ if ((status = do_samba_command("rpcclient", samba_server, subcmd,
+ authfile, logfile)) != 0)
+ {
+ snprintf(message, sizeof(message),
+ _cupsLangString(language,
+ _("Unable to set Windows printer driver (%d)!\n")),
+ status);
+
+ _cupsSetError(IPP_INTERNAL_ERROR, message);
+
+ if (logfile)
+ _cupsLangPrintf(logfile, "%s\n", message);
+
+ unlink(authfile);
+
+ return (0);
+ }
+
+ unlink(authfile);
+
+ return (1);
+}
+
+
+/*
+ * '_cupsAdminGetServerSettings()' - Get settings from the server.
+ *
+ * The returned settings should be freed with cupsFreeOptions() when
+ * you are done with them.
+ *
+ * @since CUPS 1.2@
+ */
+
+int /* O - 1 on success, 0 on failure */
+_cupsAdminGetServerSettings(
+ http_t *http, /* I - Connection to server */
+ int *num_settings, /* O - Number of settings */
+ cups_option_t **settings) /* O - Settings */
+{
+ int i; /* Looping var */
+ cups_file_t *cupsd; /* cupsd.conf file */
+ char cupsdconf[1024]; /* cupsd.conf filename */
+ int remote; /* Remote cupsd.conf file? */
+ http_status_t status; /* Status of getting cupsd.conf */
+ char line[1024], /* Line from cupsd.conf file */
+ *value; /* Value on line */
+ cups_option_t *setting; /* Current setting */
+ _cups_globals_t *cg = _cupsGlobals(); /* Global data */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!http || !num_settings || !settings)
+ {
+ _cupsSetError(IPP_INTERNAL_ERROR, NULL);
+
+ if (num_settings)
+ *num_settings = 0;
+
+ if (settings)
+ *settings = NULL;
+
+ return (0);
+ }
+
+ *num_settings = 0;
+ *settings = NULL;
+
+ /*
+ * Get the cupsd.conf file...
+ */
+
+ if ((status = get_cupsd_conf(http, cg, cg->cupsd_update, cupsdconf,
+ sizeof(cupsdconf), &remote)) == HTTP_OK)
+ {
+ if ((cupsd = cupsFileOpen(cupsdconf, "r")) == NULL)
+ _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno));
+ }
+ else
+ cupsd = NULL;
+
+ if (cupsd)
+ {
+ /*
+ * Read the file, keeping track of what settings are enabled...
+ */
+
+ int remote_access = 0, /* Remote access allowed? */
+ remote_admin = 0, /* Remote administration allowed? */
+ browsing = 1, /* Browsing enabled? */
+ browse_allow = 1, /* Browse address set? */
+ browse_address = 0, /* Browse address set? */
+ cancel_policy = 1, /* Cancel-job policy set? */
+ debug_logging = 0; /* LogLevel debug set? */
+ int linenum = 0, /* Line number in file */
+ in_location = 0, /* In a location section? */
+ in_policy = 0, /* In a policy section? */
+ in_cancel_job = 0, /* In a cancel-job section? */
+ in_admin_location = 0; /* In the /admin location? */
+
+
+ invalidate_cupsd_cache(cg);
+
+ cg->cupsd_update = time(NULL);
+ httpGetHostname(http, cg->cupsd_hostname, sizeof(cg->cupsd_hostname));
+
+ while (cupsFileGetConf(cupsd, line, sizeof(line), &value, &linenum))
+ {
+ if (!value)
+ continue;
+
+ if (!strcasecmp(line, "Port"))
+ {
+ remote_access = 1;
+ }
+ else if (!strcasecmp(line, "Listen"))
+ {
+ char *port; /* Pointer to port number, if any */
+
+
+ if ((port = strrchr(value, ':')) != NULL)
+ *port = '\0';
+
+ if (strcasecmp(value, "localhost") && strcmp(value, "127.0.0.1"))
+ remote_access = 1;
+ }
+ else if (!strcasecmp(line, "Browsing"))
+ {
+ browsing = !strcasecmp(value, "yes") || !strcasecmp(value, "on") ||
+ !strcasecmp(value, "true");
+ }
+ else if (!strcasecmp(line, "BrowseAddress"))
+ {
+ browse_address = 1;
+ }
+ else if (!strcasecmp(line, "BrowseAllow"))
+ {
+ browse_allow = 1;
+ }
+ else if (!strcasecmp(line, "BrowseOrder"))
+ {
+ browse_allow = !strncasecmp(value, "deny,", 5);
+ }
+ else if (!strcasecmp(line, "LogLevel"))
+ {
+ debug_logging = !strncasecmp(value, "debug", 5);
+ }
+ else if (!strcasecmp(line, ""))
+ {
+ in_policy = 0;
+ }
+ else if (!strcasecmp(line, ""))
+ {
+ in_cancel_job = 0;
+ }
+ else if (!strcasecmp(line, "Require") && in_cancel_job)
+ {
+ cancel_policy = 0;
+ }
+ else if (!strcasecmp(line, ""))
+ {
+ in_admin_location = 0;
+ in_location = 0;
+ }
+ else if (!strcasecmp(line, "Allow") && in_admin_location &&
+ strcasecmp(value, "localhost") && strcasecmp(value, "127.0.0.1"))
+ {
+ remote_admin = 1;
+ }
+ else if (line[0] != '<' && !in_location && !in_policy)
+ cg->cupsd_num_settings = cupsAddOption(line, value,
+ cg->cupsd_num_settings,
+ &(cg->cupsd_settings));
+ }
+
+ cupsFileClose(cupsd);
+
+ cg->cupsd_num_settings = cupsAddOption(CUPS_SERVER_DEBUG_LOGGING,
+ debug_logging ? "1" : "0",
+ cg->cupsd_num_settings,
+ &(cg->cupsd_settings));
+
+ cg->cupsd_num_settings = cupsAddOption(CUPS_SERVER_REMOTE_ADMIN,
+ (remote_access && remote_admin) ?
+ "1" : "0",
+ cg->cupsd_num_settings,
+ &(cg->cupsd_settings));
+
+ cg->cupsd_num_settings = cupsAddOption(CUPS_SERVER_REMOTE_PRINTERS,
+ (browsing && browse_allow) ?
+ "1" : "0",
+ cg->cupsd_num_settings,
+ &(cg->cupsd_settings));
+
+ cg->cupsd_num_settings = cupsAddOption(CUPS_SERVER_SHARE_PRINTERS,
+ (remote_access && browsing &&
+ browse_address) ? "1" : "0",
+ cg->cupsd_num_settings,
+ &(cg->cupsd_settings));
+
+ cg->cupsd_num_settings = cupsAddOption(CUPS_SERVER_USER_CANCEL_ANY,
+ cancel_policy ? "1" : "0",
+ cg->cupsd_num_settings,
+ &(cg->cupsd_settings));
+ }
+ else if (status != HTTP_NOT_MODIFIED)
+ invalidate_cupsd_cache(cg);
+
+ /*
+ * Remove any temporary files and copy the settings array...
+ */
+
+ if (remote)
+ unlink(cupsdconf);
+
+ for (i = cg->cupsd_num_settings, setting = cg->cupsd_settings;
+ i > 0;
+ i --, setting ++)
+ *num_settings = cupsAddOption(setting->name, setting->value,
+ *num_settings, settings);
+
+ return (cg->cupsd_num_settings > 0);
+}
+
+
+/*
+ * '_cupsAdminSetServerSettings()' - Set settings on the server.
+ *
+ * @since CUPS 1.2@
+ */
+
+int /* O - 1 on success, 0 on failure */
+_cupsAdminSetServerSettings(
+ http_t *http, /* I - Connection to server */
+ int num_settings, /* I - Number of settings */
+ cups_option_t *settings) /* I - Settings */
+{
+ int i; /* Looping var */
+ http_status_t status; /* GET/PUT status */
+ cups_file_t *cupsd; /* cupsd.conf file */
+ char cupsdconf[1024]; /* cupsd.conf filename */
+ int remote; /* Remote cupsd.conf file? */
+ char tempfile[1024]; /* Temporary new cupsd.conf */
+ cups_file_t *temp; /* Temporary file */
+ char line[1024], /* Line from cupsd.conf file */
+ *value; /* Value on line */
+ int linenum, /* Line number in file */
+ in_location, /* In a location section? */
+ in_policy, /* In a policy section? */
+ in_default_policy, /* In the default policy section? */
+ in_cancel_job, /* In a cancel-job section? */
+ in_admin_location, /* In the /admin location? */
+ in_conf_location, /* In the /admin/conf location? */
+ in_root_location; /* In the / location? */
+ const char *val; /* Setting value */
+ int remote_printers, /* Show remote printers */
+ share_printers, /* Share local printers */
+ remote_admin, /* Remote administration allowed? */
+ user_cancel_any, /* Cancel-job policy set? */
+ debug_logging; /* LogLevel debug set? */
+ int wrote_port_listen, /* Wrote the port/listen lines? */
+ wrote_browsing, /* Wrote the browsing lines? */
+ wrote_policy, /* Wrote the policy? */
+ wrote_loglevel, /* Wrote the LogLevel line? */
+ wrote_admin_location, /* Wrote the /admin location? */
+ wrote_conf_location, /* Wrote the /admin/conf location? */
+ wrote_root_location; /* Wrote the / location? */
+ int indent; /* Indentation */
+ int cupsd_num_settings; /* New number of settings */
+ cups_option_t *cupsd_settings, /* New settings */
+ *setting; /* Current setting */
+ _cups_globals_t *cg = _cupsGlobals(); /* Global data */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!http || !num_settings || !settings)
+ {
+ _cupsSetError(IPP_INTERNAL_ERROR, NULL);
+
+ return (0);
+ }
+
+ /*
+ * Get the cupsd.conf file...
+ */
+
+ if ((status = get_cupsd_conf(http, cg, 0, cupsdconf, sizeof(cupsdconf),
+ &remote)) == HTTP_OK)
+ {
+ if ((cupsd = cupsFileOpen(cupsdconf, "r")) == NULL)
+ {
+ _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno));
+ return (0);
+ }
+ }
+ else
+ return (0);
+
+ /*
+ * Get basic settings...
+ */
+
+ if ((val = cupsGetOption(CUPS_SERVER_DEBUG_LOGGING, num_settings,
+ settings)) != NULL)
+ debug_logging = atoi(val);
+ else
+ debug_logging = 0;
+
+ if ((val = cupsGetOption(CUPS_SERVER_REMOTE_ADMIN, num_settings,
+ settings)) != NULL)
+ remote_admin = atoi(val);
+ else
+ remote_admin = 0;
+
+ if ((val = cupsGetOption(CUPS_SERVER_REMOTE_PRINTERS, num_settings,
+ settings)) != NULL)
+ remote_printers = atoi(val);
+ else
+ remote_printers = 1;
+
+ if ((val = cupsGetOption(CUPS_SERVER_SHARE_PRINTERS, num_settings,
+ settings)) != NULL)
+ share_printers = atoi(val);
+ else
+ share_printers = 0;
+
+ if ((val = cupsGetOption(CUPS_SERVER_USER_CANCEL_ANY, num_settings,
+ settings)) != NULL)
+ user_cancel_any = atoi(val);
+ else
+ user_cancel_any = 0;
+
+ /*
+ * Create a temporary file for the new cupsd.conf file...
+ */
+
+ if ((temp = cupsTempFile2(tempfile, sizeof(tempfile))) == NULL)
+ {
+ cupsFileClose(cupsd);
+
+ if (remote)
+ unlink(cupsdconf);
+
+ _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno));
+ return (0);
+ }
+
+ /*
+ * Copy the old file to the new, making changes along the way...
+ */
+
+ cupsd_num_settings = 0;
+ in_admin_location = 0;
+ in_cancel_job = 0;
+ in_conf_location = 0;
+ in_default_policy = 0;
+ in_location = 0;
+ in_policy = 0;
+ in_root_location = 0;
+ linenum = 0;
+ wrote_admin_location = 0;
+ wrote_browsing = 0;
+ wrote_conf_location = 0;
+ wrote_loglevel = 0;
+ wrote_policy = 0;
+ wrote_port_listen = 0;
+ wrote_root_location = 0;
+ indent = 0;
+
+ while (cupsFileGetConf(cupsd, line, sizeof(line), &value, &linenum))
+ {
+ if (!strcasecmp(line, "Port") || !strcasecmp(line, "Listen"))
+ {
+ if (!wrote_port_listen)
+ {
+ wrote_port_listen = 1;
+
+ if (share_printers || remote_admin)
+ {
+ cupsFilePuts(temp, "# Allow remote access\n");
+ cupsFilePrintf(temp, "Port %d\n", ippPort());
+ }
+ else
+ {
+ cupsFilePuts(temp, "# Only listen for connections from the local machine.\n");
+ cupsFilePrintf(temp, "Listen 127.0.0.1:%d\n", ippPort());
+ }
+
+#ifdef CUPS_DEFAULT_DOMAINSOCKET
+ if (!access(CUPS_DEFAULT_DOMAINSOCKET, 0))
+ cupsFilePuts(temp, "Listen " CUPS_DEFAULT_DOMAINSOCKET "\n");
+#endif /* CUPS_DEFAULT_DOMAINSOCKET */
+ }
+ }
+ else if (!strcasecmp(line, "Browsing") ||
+ !strcasecmp(line, "BrowseAddress") ||
+ !strcasecmp(line, "BrowseAllow") ||
+ !strcasecmp(line, "BrowseDeny") ||
+ !strcasecmp(line, "BrowseOrder"))
+ {
+ if (!wrote_browsing)
+ {
+ wrote_browsing = 1;
+
+ if (remote_printers || share_printers)
+ {
+ if (remote_printers && share_printers)
+ cupsFilePuts(temp, "# Enable printer sharing and shared printers.\n");
+ else if (remote_printers)
+ cupsFilePuts(temp, "# Show shared printers on the local network.\n");
+ else
+ cupsFilePuts(temp, "# Share local printers on the local network.\n");
+
+ cupsFilePuts(temp, "Browsing On\n");
+ cupsFilePuts(temp, "BrowseOrder allow,deny\n");
+
+ if (remote_printers)
+ cupsFilePuts(temp, "BrowseAllow @LOCAL\n");
+
+ if (share_printers)
+ cupsFilePuts(temp, "BrowseAddress @LOCAL\n");
+ }
+ else
+ {
+ cupsFilePuts(temp, "# Disable printer sharing and shared printers.\n");
+ cupsFilePuts(temp, "Browsing Off\n");
+ }
+ }
+ }
+ else if (!strcasecmp(line, "LogLevel"))
+ {
+ wrote_loglevel = 1;
+
+ if (debug_logging)
+ {
+ cupsFilePuts(temp, "# Show troubleshooting information in error_log.\n");
+ cupsFilePuts(temp, "LogLevel debug\n");
+ }
+ else
+ {
+ cupsFilePuts(temp, "# Show general information in error_log.\n");
+ cupsFilePuts(temp, "LogLevel info\n");
+ }
+ }
+ else if (!strcasecmp(line, "\n", line, value);
+ indent += 2;
+ }
+ else if (!strcasecmp(line, ""))
+ {
+ indent -= 2;
+ if (!wrote_policy && in_default_policy)
+ {
+ wrote_policy = 1;
+
+ if (!user_cancel_any)
+ cupsFilePuts(temp, " # Only the owner or an administrator can cancel a job...\n"
+ " \n"
+ " Order deny,allow\n"
+ " Allow @SYSTEM\n"
+ " Allow @OWNER\n"
+ " \n");
+ }
+
+ in_policy = 0;
+ in_default_policy = 0;
+
+ cupsFilePuts(temp, "\n");
+ }
+ else if (!strcasecmp(line, "\n", line, value);
+ }
+ else if (!strcasecmp(line, ""))
+ {
+ in_location = 0;
+ indent -= 2;
+ if (in_admin_location)
+ {
+ wrote_admin_location = 1;
+
+ if (remote_admin)
+ cupsFilePuts(temp, " # Allow remote administration...\n");
+ else
+ cupsFilePuts(temp, " # Restrict access to the admin pages...\n");
+
+ cupsFilePuts(temp, " Order allow,deny\n");
+
+ if (remote_admin)
+ cupsFilePuts(temp, " Allow @LOCAL\n");
+ else
+ cupsFilePuts(temp, " Allow localhost\n");
+ }
+ else if (in_conf_location)
+ {
+ wrote_conf_location = 1;
+
+ if (remote_admin)
+ cupsFilePuts(temp, " # Allow remote access to the configuration files...\n");
+ else
+ cupsFilePuts(temp, " # Restrict access to the configuration files...\n");
+
+ cupsFilePuts(temp, " Order allow,deny\n");
+
+ if (remote_admin)
+ cupsFilePuts(temp, " Allow @LOCAL\n");
+ else
+ cupsFilePuts(temp, " Allow localhost\n");
+ }
+ else if (in_root_location)
+ {
+ wrote_root_location = 1;
+
+ if (remote_admin && share_printers)
+ cupsFilePuts(temp, " # Allow shared printing and remote administration...\n");
+ else if (remote_admin)
+ cupsFilePuts(temp, " # Allow remote administration...\n");
+ else if (share_printers)
+ cupsFilePuts(temp, " # Allow shared printing...\n");
+ else
+ cupsFilePuts(temp, " # Restrict access to the server...\n");
+
+ cupsFilePuts(temp, " Order allow,deny\n");
+
+ if (remote_admin || share_printers)
+ cupsFilePuts(temp, " Allow @LOCAL\n");
+ else
+ cupsFilePuts(temp, " Allow localhost\n");
+ }
+
+ in_admin_location = 0;
+ in_conf_location = 0;
+ in_root_location = 0;
+
+ cupsFilePuts(temp, "\n");
+ }
+ else if (!strcasecmp(line, "\n");
+ }
+ }
+ else if (!strcasecmp(line, "") && in_cancel_job)
+ {
+ indent -= 2;
+
+ if (in_cancel_job == 1)
+ cupsFilePuts(temp, " \n");
+
+ wrote_policy = 1;
+
+ if (!user_cancel_any)
+ cupsFilePuts(temp, " # Only the owner or an administrator can cancel a job...\n"
+ " \n"
+ " Order deny,allow\n"
+ " Require user @OWNER @SYSTEM\n"
+ " \n");
+
+ in_cancel_job = 0;
+ }
+ else if ((in_admin_location || in_conf_location || in_root_location) &&
+ (!strcasecmp(line, "Allow") || !strcasecmp(line, "Deny") ||
+ !strcasecmp(line, "Order")))
+ continue;
+ else if (in_cancel_job == 2)
+ continue;
+ else if (!strcasecmp(line, "\n", line, value);
+ else if (line[0] == '<')
+ {
+ if (value)
+ {
+ cupsFilePrintf(temp, "%*s%s %s>\n", indent, "", line, value);
+ indent += 2;
+ }
+ else
+ {
+ if (line[1] == '/')
+ indent -= 2;
+
+ cupsFilePrintf(temp, "%*s%s\n", indent, "", line);
+ }
+ }
+ else if (!in_policy && !in_location &&
+ (val = cupsGetOption(line, num_settings, settings)) != NULL &&
+ !cupsGetOption(line, cupsd_num_settings, cupsd_settings))
+ {
+ /*
+ * Add this directive to the list of directives we have written...
+ */
+
+ cupsd_num_settings = cupsAddOption(line, value, cupsd_num_settings,
+ &cupsd_settings);
+
+ /*
+ * Write the new value in its place, without indentation since we
+ * only support setting root directives, not in sections...
+ */
+
+ cupsFilePrintf(temp, "%s %s\n", line, value);
+ }
+ else if (value)
+ {
+ if (!in_policy && !in_location)
+ {
+ /*
+ * Record the non-policy, non-location directives that we find
+ * in the server settings, since we cache this info and record it
+ * in _cupsAdminGetServerSettings()...
+ */
+
+ cupsd_num_settings = cupsAddOption(line, value, cupsd_num_settings,
+ &cupsd_settings);
+ }
+
+ cupsFilePrintf(temp, "%*s%s %s\n", indent, "", line, value);
+ }
+ else
+ cupsFilePrintf(temp, "%*s%s\n", indent, "", line);
+ }
+
+ /*
+ * Write any missing info...
+ */
+
+ if (!wrote_browsing)
+ {
+ if (remote_printers || share_printers)
+ {
+ if (remote_printers && share_printers)
+ cupsFilePuts(temp, "# Enable printer sharing and shared printers.\n");
+ else if (remote_printers)
+ cupsFilePuts(temp, "# Show shared printers on the local network.\n");
+ else
+ cupsFilePuts(temp, "# Share local printers on the local network.\n");
+
+ cupsFilePuts(temp, "Browsing On\n");
+ cupsFilePuts(temp, "BrowseOrder allow,deny\n");
+
+ if (remote_printers)
+ cupsFilePuts(temp, "BrowseAllow @LOCAL\n");
+
+ if (share_printers)
+ cupsFilePuts(temp, "BrowseAddress @LOCAL\n");
+ }
+ else
+ {
+ cupsFilePuts(temp, "# Disable printer sharing and shared printers.\n");
+ cupsFilePuts(temp, "Browsing Off\n");
+ }
+ }
+
+ if (!wrote_loglevel)
+ {
+ if (debug_logging)
+ {
+ cupsFilePuts(temp, "# Show troubleshooting information in error_log.\n");
+ cupsFilePuts(temp, "LogLevel debug\n");
+ }
+ else
+ {
+ cupsFilePuts(temp, "# Show general information in error_log.\n");
+ cupsFilePuts(temp, "LogLevel info\n");
+ }
+ }
+
+ if (!wrote_port_listen)
+ {
+ if (share_printers || remote_admin)
+ {
+ cupsFilePuts(temp, "# Allow remote access\n");
+ cupsFilePrintf(temp, "Port %d\n", ippPort());
+ }
+ else
+ {
+ cupsFilePuts(temp, "# Only listen for connections from the local machine.\n");
+ cupsFilePrintf(temp, "Listen 127.0.0.1:%d\n", ippPort());
+ }
+
+#ifdef CUPS_DEFAULT_DOMAINSOCKET
+ if (!access(CUPS_DEFAULT_DOMAINSOCKET, 0))
+ cupsFilePuts(temp, "Listen " CUPS_DEFAULT_DOMAINSOCKET "\n");
+#endif /* CUPS_DEFAULT_DOMAINSOCKET */
+ }
+
+ if (!wrote_root_location)
+ {
+ if (remote_admin && share_printers)
+ cupsFilePuts(temp, "# Allow shared printing and remote administration...\n");
+ else if (remote_admin)
+ cupsFilePuts(temp, "# Allow remote administration...\n");
+ else if (share_printers)
+ cupsFilePuts(temp, "# Allow shared printing...\n");
+ else
+ cupsFilePuts(temp, "# Restrict access to the server...\n");
+
+ cupsFilePuts(temp, "\n"
+ " Order allow,deny\n");
+
+ if (remote_admin || share_printers)
+ cupsFilePuts(temp, " Allow @LOCAL\n");
+ else
+ cupsFilePuts(temp, " Allow localhost\n");
+
+ cupsFilePuts(temp, "\n");
+ }
+
+ if (!wrote_admin_location)
+ {
+ if (remote_admin)
+ cupsFilePuts(temp, "# Allow remote administration...\n");
+ else
+ cupsFilePuts(temp, "# Restrict access to the admin pages...\n");
+
+ cupsFilePuts(temp, "\n"
+ " Order allow,deny\n");
+
+ if (remote_admin)
+ cupsFilePuts(temp, " Allow @LOCAL\n");
+ else
+ cupsFilePuts(temp, " Allow localhost\n");
+
+ cupsFilePuts(temp, "\n");
+ }
+
+ if (!wrote_conf_location)
+ {
+ if (remote_admin)
+ cupsFilePuts(temp, "# Allow remote access to the configuration files...\n");
+ else
+ cupsFilePuts(temp, "# Restrict access to the configuration files...\n");
+
+ cupsFilePuts(temp, "\n"
+ " AuthType Basic\n"
+ " Require user @SYSTEM\n"
+ " Order allow,deny\n");
+
+ if (remote_admin)
+ cupsFilePuts(temp, " Allow @LOCAL\n");
+ else
+ cupsFilePuts(temp, " Allow localhost\n");
+
+ cupsFilePuts(temp, "\n");
+ }
+
+ if (!wrote_policy)
+ {
+ cupsFilePuts(temp, "\n"
+ " # Job-related operations must be done by the owner or an adminstrator...\n"
+ " \n"
+ " Require user @OWNER @SYSTEM\n"
+ " Order deny,allow\n"
+ " \n"
+ " # All administration operations require an adminstrator to authenticate...\n"
+ " \n"
+ " AuthType Basic\n"
+ " Require user @SYSTEM\n"
+ " Order deny,allow\n"
+ "\n");
+
+ if (!user_cancel_any)
+ cupsFilePuts(temp, " # Only the owner or an administrator can cancel a job...\n"
+ " \n"
+ " Require user @OWNER @SYSTEM\n"
+ " Order deny,allow\n"
+ " \n");
+
+ cupsFilePuts(temp, " \n"
+ " Order deny,allow\n"
+ " \n"
+ "\n");
+ }
+
+ for (i = num_settings, setting = settings; i > 0; i --, setting ++)
+ if (setting->name[0] != '_' &&
+ !cupsGetOption(setting->name, cupsd_num_settings, cupsd_settings))
+ {
+ /*
+ * Add this directive to the list of directives we have written...
+ */
+
+ cupsd_num_settings = cupsAddOption(setting->name, setting->value,
+ cupsd_num_settings, &cupsd_settings);
+
+ /*
+ * Write the new value in its place, without indentation since we
+ * only support setting root directives, not in sections...
+ */
+
+ cupsFilePrintf(temp, "%s %s\n", setting->name, setting->value);
+ }
+
+ cupsFileClose(cupsd);
+ cupsFileClose(temp);
+
+ /*
+ * Upload the configuration file to the server...
+ */
+
+ status = cupsPutFile(http, "/admin/conf/cupsd.conf", tempfile);
+
+ if (status == HTTP_CREATED)
+ {
+ /*
+ * Updated OK, add the basic settings...
+ */
+
+ cupsd_num_settings = cupsAddOption(CUPS_SERVER_DEBUG_LOGGING,
+ debug_logging ? "1" : "0",
+ cupsd_num_settings, &cupsd_settings);
+ cupsd_num_settings = cupsAddOption(CUPS_SERVER_REMOTE_ADMIN,
+ remote_admin ? "1" : "0",
+ cupsd_num_settings, &cupsd_settings);
+ cupsd_num_settings = cupsAddOption(CUPS_SERVER_REMOTE_PRINTERS,
+ remote_printers ? "1" : "0",
+ cupsd_num_settings, &cupsd_settings);
+ cupsd_num_settings = cupsAddOption(CUPS_SERVER_SHARE_PRINTERS,
+ share_printers ? "1" : "0",
+ cupsd_num_settings, &cupsd_settings);
+ cupsd_num_settings = cupsAddOption(CUPS_SERVER_USER_CANCEL_ANY,
+ user_cancel_any ? "1" : "0",
+ cupsd_num_settings, &cupsd_settings);
+
+ /*
+ * Save the new values...
+ */
+
+ invalidate_cupsd_cache(cg);
+
+ cg->cupsd_num_settings = cupsd_num_settings;
+ cg->cupsd_settings = cupsd_settings;
+ cg->cupsd_update = time(NULL);
+
+ httpGetHostname(http, cg->cupsd_hostname, sizeof(cg->cupsd_hostname));
+ }
+ else
+ cupsFreeOptions(cupsd_num_settings, cupsd_settings);
+
+ /*
+ * Remote our temp files and return...
+ */
+
+ if (remote)
+ unlink(cupsdconf);
+
+ unlink(tempfile);
+
+ return (status == HTTP_CREATED);
+}
+
+
+/*
+ * 'do_samba_command()' - Do a SAMBA command.
+ */
+
+static int /* O - Status of command */
+do_samba_command(const char *command, /* I - Command to run */
+ const char *address, /* I - Address for command */
+ const char *subcmd, /* I - Sub-command */
+ const char *authfile, /* I - Samba authentication file */
+ FILE *logfile) /* I - Optional log file */
+{
+ int status; /* Status of command */
+ int pid; /* Process ID of child */
+
+
+ if (logfile)
+ _cupsLangPrintf(logfile,
+ _("Running command: %s %s -N -A %s -c \'%s\'\n"),
+ command, address, authfile, subcmd);
+
+ if ((pid = fork()) == 0)
+ {
+ /*
+ * Child goes here, redirect stdin/out/err and execute the command...
+ */
+
+ close(0);
+ open("/dev/null", O_RDONLY);
+
+ close(1);
+
+ if (logfile)
+ dup(fileno(logfile));
+ else
+ open("/dev/null", O_WRONLY);
+
+ close(2);
+ dup(1);
+
+ execlp(command, command, address, "-N", "-A", authfile, "-c", subcmd,
+ (char *)0);
+ exit(errno);
+ }
+ else if (pid < 0)
+ {
+ status = -1;
+
+ _cupsLangPrintf(stderr, _("cupsaddsmb: Unable to run \"%s\": %s\n"),
+ command, strerror(errno));
+ }
+ else
+ {
+ /*
+ * Wait for the process to complete...
+ */
+
+ while (wait(&status) != pid);
+ }
+
+ if (logfile)
+ _cupsLangPuts(logfile, "\n");
+
+ DEBUG_printf(("status=%d\n", status));
+
+ if (WIFEXITED(status))
+ return (WEXITSTATUS(status));
+ else
+ return (-WTERMSIG(status));
+}
+
+
+/*
+ * 'get_cupsd_conf()' - Get the current cupsd.conf file.
+ */
+
+static http_status_t /* O - Status of request */
+get_cupsd_conf(
+ http_t *http, /* I - Connection to server */
+ _cups_globals_t *cg, /* I - Global data */
+ time_t last_update, /* I - Last update time for file */
+ char *name, /* I - Filename buffer */
+ int namesize, /* I - Size of filename buffer */
+ int *remote) /* O - Remote file? */
+{
+ int fd; /* Temporary file descriptor */
+ struct stat info; /* cupsd.conf file information */
+ http_status_t status; /* Status of getting cupsd.conf */
+ char host[HTTP_MAX_HOST]; /* Hostname for connection */
+
+
+ /*
+ * See if we already have the data we need...
+ */
+
+ httpGetHostname(http, host, sizeof(host));
+
+ if (strcasecmp(cg->cupsd_hostname, host))
+ invalidate_cupsd_cache(cg);
+
+ snprintf(name, namesize, "%s/cupsd.conf", cg->cups_serverroot);
+ *remote = 0;
+
+ if (!strcasecmp(host, "localhost") && !access(name, R_OK))
+ {
+ /*
+ * Read the local file rather than using HTTP...
+ */
+
+ if (stat(name, &info))
+ {
+ *name = '\0';
+
+ _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno));
+
+ return (HTTP_SERVER_ERROR);
+ }
+ else if (last_update && info.st_mtime <= last_update)
+ status = HTTP_NOT_MODIFIED;
+ else
+ status = HTTP_OK;
+ }
+ else
+ {
+ /*
+ * Read cupsd.conf via a HTTP GET request...
+ */
+
+ if ((fd = cupsTempFd(name, sizeof(name))) < 0)
+ {
+ *name = '\0';
+
+ _cupsSetError(IPP_INTERNAL_ERROR, strerror(errno));
+
+ invalidate_cupsd_cache(cg);
+
+ return (HTTP_SERVER_ERROR);
+ }
+
+ *remote = 1;
+
+ httpClearFields(http);
+
+ if (last_update)
+ httpSetField(http, HTTP_FIELD_IF_MODIFIED_SINCE,
+ httpGetDateString(last_update));
+
+ status = cupsGetFd(http, "/admin/conf/cupsd.conf", fd);
+
+ close(fd);
+
+ if (status != HTTP_OK)
+ {
+ unlink(name);
+ *name = '\0';
+ }
+ }
+
+ return (status);
+}
+
+
+/*
+ * 'invalidate_cupsd_cache()' - Invalidate the cached cupsd.conf settings.
+ */
+
+static void
+invalidate_cupsd_cache(
+ _cups_globals_t *cg) /* I - Global data */
+{
+ cupsFreeOptions(cg->cupsd_num_settings, cg->cupsd_settings);
+
+ cg->cupsd_hostname[0] = '\0';
+ cg->cupsd_update = 0;
+ cg->cupsd_num_settings = 0;
+ cg->cupsd_settings = NULL;
+}
+
+
+/*
+ * 'write_option()' - Write a CUPS option to a PPD file.
+ */
+
+static void
+write_option(cups_file_t *dstfp, /* I - PPD file */
+ int order, /* I - Order dependency */
+ const char *name, /* I - Option name */
+ const char *text, /* I - Option text */
+ const char *attrname, /* I - Attribute name */
+ ipp_attribute_t *suppattr, /* I - IPP -supported attribute */
+ ipp_attribute_t *defattr, /* I - IPP -default attribute */
+ int defval, /* I - Default value number */
+ int valcount) /* I - Number of values */
+{
+ int i; /* Looping var */
+
+
+ cupsFilePrintf(dstfp, "*JCLOpenUI *%s/%s: PickOne\n"
+ "*OrderDependency: %d JCLSetup *%s\n",
+ name, text, order, name);
+
+ if (defattr->value_tag == IPP_TAG_INTEGER)
+ {
+ /*
+ * Do numeric options with a range or list...
+ */
+
+ cupsFilePrintf(dstfp, "*Default%s: %d\n", name,
+ defattr->values[defval].integer);
+
+ if (suppattr->value_tag == IPP_TAG_RANGE)
+ {
+ /*
+ * List each number in the range...
+ */
+
+ for (i = suppattr->values[0].range.lower;
+ i <= suppattr->values[0].range.upper;
+ i ++)
+ {
+ cupsFilePrintf(dstfp, "*%s %d: \"", name, i);
+
+ if (valcount == 1)
+ cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\n\"\n*End\n",
+ attrname, i);
+ else if (defval == 0)
+ cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\"\n", attrname, i);
+ else if (defval < (valcount - 1))
+ cupsFilePrintf(dstfp, ",%d\"\n", i);
+ else
+ cupsFilePrintf(dstfp, ",%d\n\"\n*End\n", i);
+ }
+ }
+ else
+ {
+ /*
+ * List explicit numbers...
+ */
+
+ for (i = 0; i < suppattr->num_values; i ++)
+ {
+ cupsFilePrintf(dstfp, "*%s %d: \"", name, suppattr->values[i].integer);
+
+ if (valcount == 1)
+ cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\n\"\n*End\n", attrname,
+ suppattr->values[i].integer);
+ else if (defval == 0)
+ cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\"\n", attrname,
+ suppattr->values[i].integer);
+ else if (defval < (valcount - 1))
+ cupsFilePrintf(dstfp, ",%d\"\n", suppattr->values[i].integer);
+ else
+ cupsFilePrintf(dstfp, ",%d\n\"\n*End\n", suppattr->values[i].integer);
+ }
+ }
+ }
+ else
+ {
+ /*
+ * Do text options with a list...
+ */
+
+ cupsFilePrintf(dstfp, "*Default%s: %s\n", name,
+ defattr->values[defval].string.text);
+
+ for (i = 0; i < suppattr->num_values; i ++)
+ {
+ cupsFilePrintf(dstfp, "*%s %s: \"", name,
+ suppattr->values[i].string.text);
+
+ if (valcount == 1)
+ cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%s\n\"\n*End\n", attrname,
+ suppattr->values[i].string.text);
+ else if (defval == 0)
+ cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%s\"\n", attrname,
+ suppattr->values[i].string.text);
+ else if (defval < (valcount - 1))
+ cupsFilePrintf(dstfp, ",%s\"\n", suppattr->values[i].string.text);
+ else
+ cupsFilePrintf(dstfp, ",%s\n\"\n*End\n",
+ suppattr->values[i].string.text);
+ }
+ }
+
+ cupsFilePrintf(dstfp, "*JCLCloseUI: *%s\n\n", name);
+}
+
+
+/*
+ * End of "$Id: adminutil.c 5240 2006-03-07 21:55:29Z mike $".
+ */
diff --git a/cups/adminutil.h b/cups/adminutil.h
new file mode 100644
index 000000000..8b66d1b8d
--- /dev/null
+++ b/cups/adminutil.h
@@ -0,0 +1,89 @@
+/*
+ * "$Id: adminutil.h 5235 2006-03-06 13:02:23Z mike $"
+ *
+ * Administration utility API definitions for the Common UNIX Printing
+ * System (CUPS).
+ *
+ * MANY OF THE FUNCTIONS IN THIS HEADER ARE PRIVATE AND SUBJECT TO
+ * CHANGE AT ANY TIME. USE AT YOUR OWN RISK.
+ *
+ * Copyright 2001-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.
+ */
+
+#ifndef _CUPS_ADMINUTIL_H_
+# define _CUPS_ADMINUTIL_H_
+
+/*
+ * Include necessary headers...
+ */
+
+# include "cups.h"
+
+
+/*
+ * C++ magic...
+ */
+
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+
+
+/*
+ * Constants...
+ */
+
+# define CUPS_SERVER_DEBUG_LOGGING "_debug_logging"
+# define CUPS_SERVER_REMOTE_ADMIN "_remote_admin"
+# define CUPS_SERVER_REMOTE_PRINTERS "_remote_printers"
+# define CUPS_SERVER_SHARE_PRINTERS "_share_printers"
+# define CUPS_SERVER_USER_CANCEL_ANY "_user_cancel_any"
+
+
+/*
+ * Functions...
+ */
+
+extern int cupsAdminExportSamba(const char *dest, const char *ppd,
+ const char *samba_server,
+ const char *samba_user,
+ const char *samba_password,
+ FILE *logfile);
+extern char *cupsAdminCreateWindowsPPD(http_t *http, const char *dest,
+ char *buffer, int bufsize);
+
+extern int _cupsAdminGetServerSettings(http_t *http,
+ int *num_settings,
+ cups_option_t **settings);
+extern int _cupsAdminSetServerSettings(http_t *http,
+ int num_settings,
+ cups_option_t *settings);
+
+
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
+
+#endif /* !_CUPS_ADMINUTIL_H_ */
+
+/*
+ * End of "$Id: adminutil.h 5235 2006-03-06 13:02:23Z mike $".
+ */
diff --git a/cups/cups.h b/cups/cups.h
index 17db3d1d0..64b389a08 100644
--- a/cups/cups.h
+++ b/cups/cups.h
@@ -1,5 +1,5 @@
/*
- * "$Id: cups.h 5156 2006-02-23 04:24:32Z mike $"
+ * "$Id: cups.h 5233 2006-03-06 03:39:28Z mike $"
*
* API definitions for the Common UNIX Printing System (CUPS).
*
@@ -61,10 +61,10 @@ extern "C" {
* Constants...
*/
-# define CUPS_VERSION 1.0190
+# define CUPS_VERSION 1.0200
# define CUPS_VERSION_MAJOR 1
# define CUPS_VERSION_MINOR 2
-# define CUPS_VERSION_PATCH -10
+# define CUPS_VERSION_PATCH 0
# define CUPS_DATE_ANY -1
@@ -244,5 +244,5 @@ extern cups_file_t *cupsTempFile2(char *filename, int len);
#endif /* !_CUPS_CUPS_H_ */
/*
- * End of "$Id: cups.h 5156 2006-02-23 04:24:32Z mike $".
+ * End of "$Id: cups.h 5233 2006-03-06 03:39:28Z mike $".
*/
diff --git a/cups/emit.c b/cups/emit.c
index f914f14d0..2aeda0114 100644
--- a/cups/emit.c
+++ b/cups/emit.c
@@ -1,5 +1,5 @@
/*
- * "$Id: emit.c 5086 2006-02-07 02:45:26Z mike $"
+ * "$Id: emit.c 5238 2006-03-07 04:41:42Z mike $"
*
* PPD code emission routines for the Common UNIX Printing System (CUPS).
*
@@ -32,10 +32,12 @@
* ppdCollect2() - Collect all marked options that reside in the
* specified section and minimum order.
* ppdEmit() - Emit code for marked options to a file.
- * ppdEmitAfterOrder() - Emit a subset of the code for marked options to a file.
+ * ppdEmitAfterOrder() - Emit a subset of the code for marked options to a
+ * file.
* ppdEmitFd() - Emit code for marked options to a file.
* ppdEmitJCL() - Emit code for JCL options to a file.
* ppdEmitJCLEnd() - Emit JCLEnd code to a file.
+ * ppdEmitString() - Get a string containing the code for marked options.
* ppd_handle_media() - Handle media selection...
* ppd_sort() - Sort options by ordering numbers...
*/
@@ -47,6 +49,7 @@
#include "ppd.h"
#include
#include "string.h"
+#include
#if defined(WIN32) || defined(__EMX__)
# include
@@ -200,268 +203,40 @@ ppdEmitAfterOrder(
ppd_file_t *ppd, /* I - PPD file record */
FILE *fp, /* I - File to write to */
ppd_section_t section, /* I - Section to write */
- int limit, /* I - Non-zero to use min_order, 0 to include all */
- float min_order) /* I - Lowest order dependency to include */
+ int limit, /* I - Non-zero to use min_order */
+ float min_order) /* I - Lowest OrderDependency */
{
- int i, /* Looping var */
- count; /* Number of choices */
- ppd_choice_t **choices; /* Choices */
- ppd_size_t *size; /* Custom page size */
+ char *buffer; /* Option code */
+ int status; /* Return status */
/*
- * Use PageSize or PageRegion as required...
+ * Range check input...
*/
- ppd_handle_media(ppd);
+ if (!ppd || !fp)
+ return (-1);
/*
- * Collect the options we need to emit and emit them!
+ * Get the string...
*/
- if ((count = ppdCollect2(ppd, section, min_order, &choices)) == 0)
- return (0);
-
- for (i = 0; i < count; i ++)
- if (section != PPD_ORDER_EXIT && section != PPD_ORDER_JCL)
- {
- /*
- * Send wrapper commands to prevent printer errors for unsupported
- * options...
- */
-
- if (fputs("[{\n", fp) < 0)
- {
- free(choices);
- return (-1);
- }
-
- /*
- * Send DSC comments with option...
- */
-
- if ((!strcasecmp(choices[i]->option->keyword, "PageSize") ||
- !strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
- !strcasecmp(choices[i]->choice, "Custom"))
- {
- /*
- * Variable size; write out standard size options, using the
- * parameter positions defined in the PPD file...
- */
-
- ppd_attr_t *attr; /* PPD attribute */
- int pos, /* Position of custom value */
- orientation; /* Orientation to use */
- float values[5]; /* Values for custom command */
- int isfloat[5]; /* Whether each value is float or int */
-
- fputs("%%BeginFeature: *CustomPageSize True\n", fp);
-
- size = ppdPageSize(ppd, "Custom");
-
- memset(values, 0, sizeof(values));
- memset(isfloat, 0, sizeof(isfloat));
-
- if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", "Width")) != NULL)
- {
- pos = atoi(attr->value) - 1;
-
- if (pos < 0 || pos > 4)
- pos = 0;
- }
- else
- pos = 0;
-
- values[pos] = size->width;
- isfloat[pos] = 1;
-
- if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", "Height")) != NULL)
- {
- pos = atoi(attr->value) - 1;
-
- if (pos < 0 || pos > 4)
- pos = 1;
- }
- else
- pos = 1;
-
- values[pos] = size->length;
- isfloat[pos] = 1;
-
- /*
- * According to the Adobe PPD specification, an orientation of 1
- * will produce a print that comes out upside-down with the X
- * axis perpendicular to the direction of feed, which is exactly
- * what we want to be consistent with non-PS printers.
- *
- * We could also use an orientation of 3 to produce output that
- * comes out rightside-up (this is the default for many large format
- * printer PPDs), however for consistency we will stick with the
- * value 1.
- *
- * If we wanted to get fancy, we could use orientations of 0 or
- * 2 and swap the width and length, however we don't want to get
- * fancy, we just want it to work consistently.
- *
- * The orientation value is range limited by the Orientation
- * parameter definition, so certain non-PS printer drivers that
- * only support an Orientation of 0 will get the value 0 as
- * expected.
- */
-
- orientation = 1;
-
- if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize",
- "Orientation")) != NULL)
- {
- int min_orient, max_orient; /* Minimum and maximum orientations */
-
-
- if (sscanf(attr->value, "%d%*s%d%d", &pos, &min_orient,
- &max_orient) != 3)
- pos = 4;
- else
- {
- pos --;
-
- if (pos < 0 || pos > 4)
- pos = 4;
-
- if (orientation > max_orient)
- orientation = max_orient;
- else if (orientation < min_orient)
- orientation = min_orient;
- }
- }
- else
- pos = 4;
-
- values[pos] = orientation;
-
- for (pos = 0; pos < 5; pos ++)
- if (isfloat[pos])
- fprintf(fp, "%.2f\n", values[pos]);
- else
- fprintf(fp, "%.0f\n", values[pos]);
-
- if (choices[i]->code == NULL)
- {
- /*
- * This can happen with certain buggy PPD files that don't include
- * a CustomPageSize command sequence... We just use a generic
- * Level 2 command sequence...
- */
-
- fputs(ppd_custom_code, fp);
- }
- }
- else if (!strcasecmp(choices[i]->choice, "Custom"))
- {
- /*
- * Custom option...
- */
-
- ppd_coption_t *coption; /* Custom option */
- ppd_cparam_t *cparam; /* Custom parameter */
- const char *s; /* Pointer into string value */
-
-
- /*
- * TODO: Support custom options with more than 1 parameter...
- */
-
- if ((coption = ppdFindCustomOption(ppd, choices[i]->option->keyword))
- != NULL &&
- (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params)) != NULL)
- {
- if (fprintf(fp, "%%%%BeginFeature: *Custom%s True\n",
- coption->keyword) < 0)
- {
- free(choices);
- return (-1);
- }
-
- switch (cparam->type)
- {
- case PPD_CUSTOM_CURVE :
- case PPD_CUSTOM_INVCURVE :
- case PPD_CUSTOM_POINTS :
- case PPD_CUSTOM_REAL :
- if (fprintf(fp, "%f\n", cparam->current.custom_real) < 0)
- {
- free(choices);
- return (-1);
- }
- break;
-
- case PPD_CUSTOM_INT :
- if (fprintf(fp, "%d\n", cparam->current.custom_int) < 0)
- {
- free(choices);
- return (-1);
- }
- break;
-
- case PPD_CUSTOM_PASSCODE :
- case PPD_CUSTOM_PASSWORD :
- case PPD_CUSTOM_STRING :
- putc('(', fp);
-
- for (s = cparam->current.custom_string; *s; s ++)
- if (*s < ' ' || *s == '(' || *s == ')' || *s >= 127)
- fprintf(fp, "\\%03o", *s & 255);
- else
- putc(*s, fp);
-
- if (fputs(")\n", fp) < 0)
- {
- free(choices);
- return (-1);
- }
- break;
- }
- }
- }
- else if (fprintf(fp, "%%%%BeginFeature: *%s %s\n",
- choices[i]->option->keyword,
- choices[i]->choice) < 0)
- {
- free(choices);
- return (-1);
- }
+ buffer = ppdEmitString(ppd, section, min_order);
- if (choices[i]->code != NULL && choices[i]->code[0] != '\0')
- {
- if (fputs(choices[i]->code, fp) < 0)
- {
- free(choices);
- return (-1);
- }
-
- if (choices[i]->code[strlen(choices[i]->code) - 1] != '\n')
- putc('\n', fp);
- }
+ /*
+ * Write it as needed and return...
+ */
- if (fputs("%%EndFeature\n", fp) < 0)
- {
- free(choices);
- return (-1);
- }
+ if (buffer)
+ {
+ status = fputs(buffer, fp) < 0 ? -1 : 0;
- if (fputs("} stopped cleartomark\n", fp) < 0)
- {
- free(choices);
- return (-1);
- }
- }
- else if (fputs(choices[i]->code, fp) < 0)
- {
- free(choices);
- return (-1);
- }
+ free(buffer);
+ }
+ else
+ status = 0;
- free(choices);
- return (0);
+ return (status);
}
@@ -474,194 +249,58 @@ ppdEmitFd(ppd_file_t *ppd, /* I - PPD file record */
int fd, /* I - File to write to */
ppd_section_t section) /* I - Section to write */
{
- int i, /* Looping var */
- count, /* Number of choices */
- custom_size; /* Non-zero if this option is a custom size */
- ppd_choice_t **choices; /* Choices */
- ppd_size_t *size; /* Custom page size */
- char buf[1024]; /* Output buffer for feature */
+ char *buffer, /* Option code */
+ *bufptr; /* Pointer into code */
+ size_t buflength; /* Length of option code */
+ ssize_t bytes; /* Bytes written */
+ int status; /* Return status */
/*
- * Use PageSize or PageRegion as required...
+ * Range check input...
*/
- ppd_handle_media(ppd);
+ if (!ppd || fd < 0)
+ return (-1);
/*
- * Collect the options we need to emit and emit them!
+ * Get the string...
*/
- if ((count = ppdCollect(ppd, section, &choices)) == 0)
- return (0);
-
- for (i = 0; i < count; i ++)
- if (section != PPD_ORDER_EXIT && section != PPD_ORDER_JCL)
- {
- /*
- * Send wrapper commands to prevent printer errors for unsupported
- * options...
- */
-
- if (write(fd, "[{\n", 3) < 1)
- {
- free(choices);
- return (-1);
- }
-
- /*
- * Send DSC comments with option...
- */
-
- if ((!strcasecmp(choices[i]->option->keyword, "PageSize") ||
- !strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
- !strcasecmp(choices[i]->choice, "Custom"))
- {
- custom_size = 1;
-
- strcpy(buf, "%%BeginFeature: *CustomPageSize True\n");
- }
- else
- {
- custom_size = 0;
-
- snprintf(buf, sizeof(buf), "%%%%BeginFeature: *%s %s\n",
- choices[i]->option->keyword, choices[i]->choice);
- }
-
- if (write(fd, buf, strlen(buf)) < 1)
- {
- free(choices);
- return (-1);
- }
-
- if (custom_size)
- {
- /*
- * Variable size; write out standard size options, using the
- * parameter positions defined in the PPD file...
- */
-
- ppd_attr_t *attr; /* PPD attribute */
- int pos, /* Position of custom value */
- values[5], /* Values for custom command */
- orientation; /* Orientation to use */
-
-
- size = ppdPageSize(ppd, "Custom");
-
- memset(values, 0, sizeof(values));
-
- if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", "Width")) != NULL)
- {
- pos = atoi(attr->value) - 1;
-
- if (pos < 0 || pos > 4)
- pos = 0;
- }
- else
- pos = 0;
-
- values[pos] = (int)size->width;
-
- if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", "Height")) != NULL)
- {
- pos = atoi(attr->value) - 1;
-
- if (pos < 0 || pos > 4)
- pos = 1;
- }
- else
- pos = 1;
-
- values[pos] = (int)size->length;
-
- if (size->width < size->length)
- orientation = 1;
- else
- orientation = 0;
-
- if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize",
- "Orientation")) != NULL)
- {
- int min_orient, max_orient; /* Minimum and maximum orientations */
-
-
- if (sscanf(attr->value, "%d%*s%d%d", &pos, &min_orient,
- &max_orient) != 3)
- pos = 4;
- else
- {
- pos --;
-
- if (pos < 0 || pos > 4)
- pos = 4;
+ buffer = ppdEmitString(ppd, section, 0.0);
- if (orientation > max_orient)
- orientation = max_orient;
- else if (orientation < min_orient)
- orientation = min_orient;
- }
- }
- else
- pos = 4;
-
- values[pos] = orientation;
-
- snprintf(buf, sizeof(buf), "%d %d %d %d %d\n", values[0], values[1],
- values[2], values[3], values[4]);
-
- if (write(fd, buf, strlen(buf)) < 1)
- {
- free(choices);
- return (-1);
- }
-
- if (choices[i]->code == NULL)
- {
- /*
- * This can happen with certain buggy PPD files that don't include
- * a CustomPageSize command sequence... We just use a generic
- * Level 2 command sequence...
- */
-
- if (write(fd, ppd_custom_code, strlen(ppd_custom_code)) < 1)
- {
- free(choices);
- return (-1);
- }
- }
- }
+ /*
+ * Write it as needed and return...
+ */
- if (choices[i]->code != NULL && choices[i]->code[0] != '\0')
- {
- if (write(fd, choices[i]->code, strlen(choices[i]->code)) < 1)
- {
- free(choices);
- return (-1);
- }
- }
+ if (buffer)
+ {
+ buflength = strlen(buffer);
+ bufptr = buffer;
+ bytes = 0;
- if (write(fd, "%%EndFeature\n", 13) < 1)
+ while (buflength > 0)
+ {
+ if ((bytes = write(fd, bufptr, buflength)) < 0)
{
- free(choices);
- return (-1);
- }
+ if (errno == EAGAIN || errno == EINTR)
+ continue;
- if (write(fd, "} stopped cleartomark\n", 22) < 1)
- {
- free(choices);
- return (-1);
+ break;
}
- }
- else if (write(fd, choices[i]->code, strlen(choices[i]->code)) < 1)
- {
- free(choices);
- return (-1);
+
+ buflength -= bytes;
+ bufptr += bytes;
}
- free(choices);
- return (0);
+ status = bytes < 0 ? -1 : 0;
+
+ free(buffer);
+ }
+ else
+ status = 0;
+
+ return (status);
}
@@ -684,7 +323,7 @@ ppdEmitJCL(ppd_file_t *ppd, /* I - PPD file record */
* Range check the input...
*/
- if (ppd == NULL || ppd->jcl_begin == NULL || ppd->jcl_ps == NULL)
+ if (!ppd || !ppd->jcl_begin || !ppd->jcl_ps)
return (0);
/*
@@ -780,24 +419,17 @@ int /* O - 0 on success, -1 on failure */
ppdEmitJCLEnd(ppd_file_t *ppd, /* I - PPD file record */
FILE *fp) /* I - File to write to */
{
- ppd_attr_t *attr; /* PPD attributes */
-
-
/*
* Range check the input...
*/
- if (ppd == NULL)
+ if (!ppd)
return (0);
- if (ppd->jcl_end == NULL)
+ if (!ppd->jcl_end)
{
if (ppd->num_filters == 0)
- fputc(0x04, fp);
-
- if ((attr = ppdFindAttr(ppd, "cupsProtocol", NULL)) != NULL &&
- attr->value != NULL && !strcasecmp(attr->value, "TBCP"))
- fputs("\033%-12345X", stdout);
+ putc(0x04, fp);
return (0);
}
@@ -828,6 +460,365 @@ ppdEmitJCLEnd(ppd_file_t *ppd, /* I - PPD file record */
}
+/*
+ * 'ppdEmitString()' - Get a string containing the code for marked options.
+ *
+ * When "min_order" is greater than zero, this function only includes options
+ * whose OrderDependency value is greater than or equal to "min_order".
+ * Otherwise, all options in the specified section are included in the
+ * returned string.
+ *
+ * The return string is allocated on the heap and should be freed using
+ * free() when you are done with it.
+ *
+ * @since CUPS 1.2@
+ */
+
+char * /* O - String containing option code */
+ppdEmitString(ppd_file_t *ppd, /* I - PPD file record */
+ ppd_section_t section, /* I - Section to write */
+ float min_order) /* I - Lowest OrderDependency */
+{
+ int i, j, /* Looping vars */
+ count; /* Number of choices */
+ ppd_choice_t **choices; /* Choices */
+ ppd_size_t *size; /* Custom page size */
+ ppd_coption_t *coption; /* Custom option */
+ ppd_cparam_t *cparam; /* Custom parameter */
+ size_t bufsize; /* Size of string buffer needed */
+ char *buffer, /* String buffer */
+ *bufptr, /* Pointer into buffer */
+ *bufend; /* End of buffer */
+ struct lconv *loc; /* Locale data */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!ppd)
+ return (NULL);
+
+ /*
+ * Use PageSize or PageRegion as required...
+ */
+
+ ppd_handle_media(ppd);
+
+ /*
+ * Collect the options we need to emit...
+ */
+
+ if ((count = ppdCollect2(ppd, section, min_order, &choices)) == 0)
+ return (NULL);
+
+ /*
+ * Count the number of bytes that are required to hold all of the
+ * option code...
+ */
+
+ for (i = 0, bufsize = 1; i < count; i ++)
+ {
+ if (section != PPD_ORDER_EXIT && section != PPD_ORDER_JCL)
+ {
+ bufsize += 3; /* [{\n */
+
+ if ((!strcasecmp(choices[i]->option->keyword, "PageSize") ||
+ !strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
+ !strcasecmp(choices[i]->choice, "Custom"))
+ {
+ bufsize += 37; /* %%BeginFeature: *CustomPageSize True */
+ bufsize += 50; /* Five 9-digit numbers + newline */
+ }
+ else if (!strcasecmp(choices[i]->choice, "Custom") &&
+ (coption = ppdFindCustomOption(ppd,
+ choices[i]->option->keyword))
+ != NULL)
+ {
+ bufsize += 23 + strlen(choices[i]->option->keyword);
+ /* %%BeginFeature: *keyword True */
+
+
+ for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params);
+ cparam;
+ cparam = (ppd_cparam_t *)cupsArrayNext(coption->params))
+ {
+ switch (cparam->type)
+ {
+ case PPD_CUSTOM_CURVE :
+ case PPD_CUSTOM_INVCURVE :
+ case PPD_CUSTOM_POINTS :
+ case PPD_CUSTOM_REAL :
+ case PPD_CUSTOM_INT :
+ bufsize += 10;
+ break;
+
+ case PPD_CUSTOM_PASSCODE :
+ case PPD_CUSTOM_PASSWORD :
+ case PPD_CUSTOM_STRING :
+ bufsize += 3 + 4 * strlen(cparam->current.custom_string);
+ break;
+ }
+ }
+ }
+ else
+ bufsize += 19 + strlen(choices[i]->option->keyword) +
+ strlen(choices[i]->choice);
+ /* %%BeginFeature: *keyword choice */
+
+ bufsize += 13; /* %%EndFeature\n */
+ bufsize += 22; /* } stopped cleartomark\n */
+ }
+
+ if (choices[i]->code)
+ bufsize += strlen(choices[i]->code);
+ else
+ bufsize += strlen(ppd_custom_code);
+ }
+
+ /*
+ * Allocate memory...
+ */
+
+ if ((buffer = calloc(1, bufsize)) == NULL)
+ {
+ free(choices);
+ return (NULL);
+ }
+
+ bufend = buffer + bufsize - 1;
+ loc = localeconv();
+
+ /*
+ * Copy the option code to the buffer...
+ */
+
+ for (i = 0, bufptr = buffer; i < count; i ++, bufptr += strlen(bufptr))
+ if (section != PPD_ORDER_EXIT && section != PPD_ORDER_JCL)
+ {
+ /*
+ * Add wrapper commands to prevent printer errors for unsupported
+ * options...
+ */
+
+ strlcpy(bufptr, "[{\n", bufend - bufptr + 1);
+ bufptr += 3;
+
+ /*
+ * Send DSC comments with option...
+ */
+
+ if ((!strcasecmp(choices[i]->option->keyword, "PageSize") ||
+ !strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
+ !strcasecmp(choices[i]->choice, "Custom"))
+ {
+ /*
+ * Variable size; write out standard size options, using the
+ * parameter positions defined in the PPD file...
+ */
+
+ ppd_attr_t *attr; /* PPD attribute */
+ int pos, /* Position of custom value */
+ orientation; /* Orientation to use */
+ float values[5]; /* Values for custom command */
+
+
+ strlcpy(bufptr, "%%BeginFeature: *CustomPageSize True\n",
+ bufend - bufptr + 1);
+ bufptr += 37;
+
+ size = ppdPageSize(ppd, "Custom");
+
+ memset(values, 0, sizeof(values));
+
+ if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", "Width")) != NULL)
+ {
+ pos = atoi(attr->value) - 1;
+
+ if (pos < 0 || pos > 4)
+ pos = 0;
+ }
+ else
+ pos = 0;
+
+ values[pos] = size->width;
+
+ if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize", "Height")) != NULL)
+ {
+ pos = atoi(attr->value) - 1;
+
+ if (pos < 0 || pos > 4)
+ pos = 1;
+ }
+ else
+ pos = 1;
+
+ values[pos] = size->length;
+
+ /*
+ * According to the Adobe PPD specification, an orientation of 1
+ * will produce a print that comes out upside-down with the X
+ * axis perpendicular to the direction of feed, which is exactly
+ * what we want to be consistent with non-PS printers.
+ *
+ * We could also use an orientation of 3 to produce output that
+ * comes out rightside-up (this is the default for many large format
+ * printer PPDs), however for consistency we will stick with the
+ * value 1.
+ *
+ * If we wanted to get fancy, we could use orientations of 0 or
+ * 2 and swap the width and length, however we don't want to get
+ * fancy, we just want it to work consistently.
+ *
+ * The orientation value is range limited by the Orientation
+ * parameter definition, so certain non-PS printer drivers that
+ * only support an Orientation of 0 will get the value 0 as
+ * expected.
+ */
+
+ orientation = 1;
+
+ if ((attr = ppdFindAttr(ppd, "ParamCustomPageSize",
+ "Orientation")) != NULL)
+ {
+ int min_orient, max_orient; /* Minimum and maximum orientations */
+
+
+ if (sscanf(attr->value, "%d%*s%d%d", &pos, &min_orient,
+ &max_orient) != 3)
+ pos = 4;
+ else
+ {
+ pos --;
+
+ if (pos < 0 || pos > 4)
+ pos = 4;
+
+ if (orientation > max_orient)
+ orientation = max_orient;
+ else if (orientation < min_orient)
+ orientation = min_orient;
+ }
+ }
+ else
+ pos = 4;
+
+ values[pos] = orientation;
+
+ for (pos = 0; pos < 5; pos ++)
+ {
+ bufptr = _cupsStrFormatd(bufptr, bufend, values[pos], loc);
+ *bufptr++ = '\n';
+ }
+
+ if (!choices[i]->code)
+ {
+ /*
+ * This can happen with certain buggy PPD files that don't include
+ * a CustomPageSize command sequence... We just use a generic
+ * Level 2 command sequence...
+ */
+
+ strlcpy(bufptr, ppd_custom_code, bufend - bufptr + 1);
+ bufptr += strlen(bufptr);
+ }
+ }
+ else if (!strcasecmp(choices[i]->choice, "Custom") &&
+ (coption = ppdFindCustomOption(ppd,
+ choices[i]->option->keyword))
+ != NULL)
+ {
+ /*
+ * Custom option...
+ */
+
+ const char *s; /* Pointer into string value */
+
+
+ snprintf(bufptr, bufend - bufptr + 1,
+ "%%%%BeginFeature: *Custom%s True\n", coption->keyword);
+ bufptr += strlen(bufptr);
+
+ for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params);
+ cparam;
+ cparam = (ppd_cparam_t *)cupsArrayNext(coption->params))
+ {
+ switch (cparam->type)
+ {
+ case PPD_CUSTOM_CURVE :
+ case PPD_CUSTOM_INVCURVE :
+ case PPD_CUSTOM_POINTS :
+ case PPD_CUSTOM_REAL :
+ bufptr = _cupsStrFormatd(bufptr, bufend,
+ cparam->current.custom_real, loc);
+ *bufptr++ = '\n';
+ break;
+
+ case PPD_CUSTOM_INT :
+ snprintf(bufptr, bufend - bufptr + 1, "%d\n",
+ cparam->current.custom_int);
+ bufptr += strlen(bufptr);
+ break;
+
+ case PPD_CUSTOM_PASSCODE :
+ case PPD_CUSTOM_PASSWORD :
+ case PPD_CUSTOM_STRING :
+ *bufptr++ = '(';
+
+ for (s = cparam->current.custom_string; *s; s ++)
+ if (*s < ' ' || *s == '(' || *s == ')' || *s >= 127)
+ {
+ snprintf(bufptr, bufend - bufptr + 1, "\\%03o", *s & 255);
+ bufptr += strlen(bufptr);
+ }
+ else
+ *bufptr++ = *s;
+
+ *bufptr++ = ')';
+ *bufptr++ = '\n';
+ break;
+ }
+ }
+ }
+ else
+ {
+ snprintf(bufptr, bufend - bufptr + 1, "%%%%BeginFeature: *%s %s\n",
+ choices[i]->option->keyword, choices[i]->choice);
+ bufptr += strlen(bufptr);
+ }
+
+ if (choices[i]->code && choices[i]->code[0])
+ {
+ j = strlen(choices[i]->code);
+ memcpy(bufptr, choices[i]->code, j);
+ bufptr += j;
+
+ if (choices[i]->code[j - 1] != '\n')
+ *bufptr++ = '\n';
+ }
+
+ strlcpy(bufptr, "%%EndFeature\n"
+ "} stopped cleartomark\n", bufend - bufptr + 1);
+ bufptr += strlen(bufptr);
+ }
+ else
+ {
+ strlcpy(bufptr, choices[i]->code, bufend - bufptr + 1);
+ bufptr += strlen(bufptr);
+ }
+
+ /*
+ * Nul-terminate, free, and return...
+ */
+
+ *bufptr = '\0';
+
+ free(choices);
+
+ return (buffer);
+}
+
+
/*
* 'ppd_handle_media()' - Handle media selection...
*/
@@ -926,5 +917,5 @@ ppd_sort(ppd_choice_t **c1, /* I - First choice */
/*
- * End of "$Id: emit.c 5086 2006-02-07 02:45:26Z mike $".
+ * End of "$Id: emit.c 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/encode.c b/cups/encode.c
index b0bbdda5a..a57b0a850 100644
--- a/cups/encode.c
+++ b/cups/encode.c
@@ -1,5 +1,5 @@
/*
- * "$Id: encode.c 5151 2006-02-22 22:43:17Z mike $"
+ * "$Id: encode.c 5230 2006-03-05 17:01:51Z mike $"
*
* Option encoding routines for the Common UNIX Printing System (CUPS).
*
@@ -341,7 +341,7 @@ cupsEncodeOptions2(
* Allocate memory for the attribute values...
*/
- if ((attr = _ipp_add_attr(ipp, count)) == NULL)
+ if ((attr = _ippAddAttr(ipp, count)) == NULL)
{
/*
* Ran out of memory!
@@ -552,5 +552,5 @@ compare_ipp_options(_ipp_option_t *a, /* I - First option */
/*
- * End of "$Id: encode.c 5151 2006-02-22 22:43:17Z mike $".
+ * End of "$Id: encode.c 5230 2006-03-05 17:01:51Z mike $".
*/
diff --git a/cups/getputfile.c b/cups/getputfile.c
index 6c534a70f..9dc7f7a9c 100644
--- a/cups/getputfile.c
+++ b/cups/getputfile.c
@@ -1,5 +1,5 @@
/*
- * "$Id: getputfile.c 5147 2006-02-22 16:37:44Z mike $"
+ * "$Id: getputfile.c 5235 2006-03-06 13:02:23Z mike $"
*
* Get/put file functions for the Common UNIX Printing System (CUPS).
*
@@ -68,6 +68,8 @@ cupsGetFd(http_t *http, /* I - HTTP connection to server */
int bytes; /* Number of bytes read */
char buffer[8192]; /* Buffer for file */
http_status_t status; /* HTTP status from server */
+ char if_modified_since[HTTP_MAX_VALUE];
+ /* If-Modified-Since header */
/*
@@ -89,10 +91,14 @@ cupsGetFd(http_t *http, /* I - HTTP connection to server */
* Then send GET requests to the HTTP server...
*/
+ strlcpy(if_modified_since, httpGetField(http, HTTP_FIELD_IF_MODIFIED_SINCE),
+ sizeof(if_modified_since));
+
do
{
httpClearFields(http);
httpSetField(http, HTTP_FIELD_AUTHORIZATION, http->authstring);
+ httpSetField(http, HTTP_FIELD_IF_MODIFIED_SINCE, if_modified_since);
if (httpGet(http, resource))
{
@@ -482,5 +488,5 @@ cupsPutFile(http_t *http, /* I - HTTP connection to server */
/*
- * End of "$Id: getputfile.c 5147 2006-02-22 16:37:44Z mike $".
+ * End of "$Id: getputfile.c 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/cups/globals.c b/cups/globals.c
index 3cbcadd17..98d5cf1ca 100644
--- a/cups/globals.c
+++ b/cups/globals.c
@@ -1,5 +1,5 @@
/*
- * "$Id: globals.c 5047 2006-02-02 05:14:15Z mike $"
+ * "$Id: globals.c 5235 2006-03-06 13:02:23Z mike $"
*
* Global variable access routines for the Common UNIX Printing System (CUPS).
*
@@ -160,11 +160,13 @@ globals_destructor(void *value) /* I - Data to free */
if (cg->http)
httpClose(cg->http);
- _cups_sp_flush(cg);
+ _cupsStrFlush(cg);
_cupsLangFlush(cg);
_cupsCharmapFlush(cg);
_cupsNormalizeMapsFlush(cg);
+ cupsFreeOptions(cg->cupsd_num_settings, cg->cupsd_settings);
+
free(value);
}
@@ -211,5 +213,5 @@ _cupsGlobals(void)
/*
- * End of "$Id: globals.c 5047 2006-02-02 05:14:15Z mike $".
+ * End of "$Id: globals.c 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/cups/globals.h b/cups/globals.h
index 1fae0efb2..15661d587 100644
--- a/cups/globals.h
+++ b/cups/globals.h
@@ -1,5 +1,5 @@
/*
- * "$Id: globals.h 5138 2006-02-21 10:49:06Z mike $"
+ * "$Id: globals.h 5235 2006-03-06 13:02:23Z mike $"
*
* Global variable definitions for the Common UNIX Printing System (CUPS).
*
@@ -66,6 +66,14 @@ typedef struct _cups_globals_s /**** CUPS global state data ****/
*cups_statedir, /* CUPS_STATEDIR environment var */
*localedir; /* LOCALDIR environment var */
+ /* adminutil.c */
+ time_t cupsd_update; /* Last time we got or set cupsd.conf */
+ char cupsd_hostname[HTTP_MAX_HOST];
+ /* Hostname for connection */
+ int cupsd_num_settings;
+ /* Number of server settings */
+ cups_option_t *cupsd_settings;/* Server settings */
+
/* http.c */
char http_date[256]; /* Date+time buffer */
@@ -148,7 +156,7 @@ extern void _cupsLangFlush(_cups_globals_t *cg);
extern void _cupsCharmapFlush(_cups_globals_t *cg);
extern void _cupsNormalizeMapsFlush(_cups_globals_t *cg);
extern void _cupsSetError(ipp_status_t status, const char *message);
-extern void _cups_sp_flush(_cups_globals_t *cg);
+extern void _cupsStrFlush(_cups_globals_t *cg);
/*
@@ -161,5 +169,5 @@ extern void _cups_sp_flush(_cups_globals_t *cg);
#endif /* !_CUPS_GLOBALS_H_ */
/*
- * End of "$Id: globals.h 5138 2006-02-21 10:49:06Z mike $".
+ * End of "$Id: globals.h 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/cups/http-addr.c b/cups/http-addr.c
index ec0f7b269..665829867 100644
--- a/cups/http-addr.c
+++ b/cups/http-addr.c
@@ -1,5 +1,5 @@
/*
- * "$Id: http-addr.c 5161 2006-02-24 03:11:46Z mike $"
+ * "$Id: http-addr.c 5235 2006-03-06 13:02:23Z mike $"
*
* HTTP address routines for the Common UNIX Printing System (CUPS).
*
@@ -490,35 +490,43 @@ httpGetHostByName(const char *name) /* I - Hostname or IP address */
/*
- * 'httpGetHostname()' - Get the FQDN for the local system.
+ * 'httpGetHostname()' - Get the FQDN for the connection or local system.
*
- * This function uses both gethostname() and gethostbyname() to
- * get the local hostname with domain.
+ * When "http" points to a connected socket, return the hostname or
+ * address that was used in the call to httpConnect() or httpConnectEncrypt().
+ * Otherwise, return the FQDN for the local system using both gethostname()
+ * and gethostbyname() to get the local hostname with domain.
*
* @since CUPS 1.2@
*/
-const char * /* O - FQDN for this system */
-httpGetHostname(char *s, /* I - String buffer for name */
- int slen) /* I - Size of buffer */
+const char * /* O - FQDN for connection or system */
+httpGetHostname(http_t *http, /* I - HTTP connection or NULL */
+ char *s, /* I - String buffer for name */
+ int slen) /* I - Size of buffer */
{
struct hostent *host; /* Host entry to get FQDN */
- /*
- * Get the hostname...
- */
-
- gethostname(s, slen);
-
- if (!strchr(s, '.'))
+ if (http)
+ strlcpy(s, http->hostname, slen);
+ else
{
/*
- * The hostname is not a FQDN, so look it up...
+ * Get the hostname...
*/
- if ((host = gethostbyname(s)) != NULL)
- strlcpy(s, host->h_name, slen);
+ gethostname(s, slen);
+
+ if (!strchr(s, '.'))
+ {
+ /*
+ * The hostname is not a FQDN, so look it up...
+ */
+
+ if ((host = gethostbyname(s)) != NULL)
+ strlcpy(s, host->h_name, slen);
+ }
}
/*
@@ -530,5 +538,5 @@ httpGetHostname(char *s, /* I - String buffer for name */
/*
- * End of "$Id: http-addr.c 5161 2006-02-24 03:11:46Z mike $".
+ * End of "$Id: http-addr.c 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/cups/http.c b/cups/http.c
index dc0da3892..2e380988e 100644
--- a/cups/http.c
+++ b/cups/http.c
@@ -1,5 +1,5 @@
/*
- * "$Id: http.c 5222 2006-03-03 18:57:56Z mike $"
+ * "$Id: http.c 5226 2006-03-04 22:03:18Z mike $"
*
* HTTP routines for the Common UNIX Printing System (CUPS).
*
@@ -539,6 +539,8 @@ httpGetBlocking(http_t *http) /* I - HTTP connection */
/*
* 'httpGetCookie()' - Get any cookie data from the response.
+ *
+ * @since CUPS 1.1.19@
*/
const char * /* O - Cookie data or NULL */
@@ -2754,5 +2756,5 @@ http_write_ssl(http_t *http, /* I - HTTP connection */
/*
- * End of "$Id: http.c 5222 2006-03-03 18:57:56Z mike $".
+ * End of "$Id: http.c 5226 2006-03-04 22:03:18Z mike $".
*/
diff --git a/cups/http.h b/cups/http.h
index 6ff09a20f..1c520b932 100644
--- a/cups/http.h
+++ b/cups/http.h
@@ -1,5 +1,5 @@
/*
- * "$Id: http.h 5147 2006-02-22 16:37:44Z mike $"
+ * "$Id: http.h 5235 2006-03-06 13:02:23Z mike $"
*
* Hyper-Text Transport Protocol definitions for the Common UNIX Printing
* System (CUPS).
@@ -462,7 +462,7 @@ extern int httpFlushWrite(http_t *http);
extern int httpGetBlocking(http_t *http);
extern const char *httpGetDateString2(time_t t, char *s, int slen);
extern int httpGetFd(http_t *http);
-extern const char *httpGetHostname(char *s, int slen);
+extern const char *httpGetHostname(http_t *http, char *s, int slen);
extern off_t httpGetLength2(http_t *http);
extern http_status_t httpGetStatus(http_t *http);
extern char *httpGetSubField2(http_t *http, http_field_t field,
@@ -491,5 +491,5 @@ extern ssize_t httpWrite2(http_t *http, const char *buffer,
#endif /* !_CUPS_HTTP_H_ */
/*
- * End of "$Id: http.h 5147 2006-02-22 16:37:44Z mike $".
+ * End of "$Id: http.h 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/cups/i18n.h b/cups/i18n.h
index c2f3f474e..e5658f239 100644
--- a/cups/i18n.h
+++ b/cups/i18n.h
@@ -1,5 +1,5 @@
/*
- * "$Id: i18n.h 4924 2006-01-13 01:55:20Z mike $"
+ * "$Id: i18n.h 5238 2006-03-07 04:41:42Z mike $"
*
* (Private) localization support for the Common UNIX Printing System (CUPS).
*
@@ -60,10 +60,6 @@ typedef struct _cups_message_s /**** Message catalog entry ****/
* Prototypes...
*/
-/**** New in CUPS 1.1.20 ****/
-extern void _cupsRestoreLocale(int category, char *oldlocale);
-extern char *_cupsSaveLocale(int category, const char *locale);
-
/**** New in CUPS 1.2 ****/
extern const char *_cupsEncodingName(cups_encoding_t encoding);
extern int _cupsLangPrintf(FILE *fp, const char *message, ...)
@@ -84,5 +80,5 @@ extern const char *_cupsMessageLookup(cups_array_t *a, const char *m);
#endif /* !_CUPS_I18N_H_ */
/*
- * End of "$Id: i18n.h 4924 2006-01-13 01:55:20Z mike $".
+ * End of "$Id: i18n.h 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/ipp-private.h b/cups/ipp-private.h
index 37473987f..af303f1da 100644
--- a/cups/ipp-private.h
+++ b/cups/ipp-private.h
@@ -1,5 +1,5 @@
/*
- * "$Id: ipp-private.h 4973 2006-01-25 02:36:02Z mike $"
+ * "$Id: ipp-private.h 5230 2006-03-05 17:01:51Z mike $"
*
* Private IPP definitions for the Common UNIX Printing System (CUPS).
*
@@ -47,8 +47,8 @@ extern "C" {
* Prototypes for private functions...
*/
-extern ipp_attribute_t *_ipp_add_attr(ipp_t *, int);
-extern void _ipp_free_attr(ipp_attribute_t *);
+extern ipp_attribute_t *_ippAddAttr(ipp_t *, int);
+extern void _ippFreeAttr(ipp_attribute_t *);
/*
@@ -61,5 +61,5 @@ extern void _ipp_free_attr(ipp_attribute_t *);
#endif /* !_CUPS_IPP_H_ */
/*
- * End of "$Id: ipp-private.h 4973 2006-01-25 02:36:02Z mike $".
+ * End of "$Id: ipp-private.h 5230 2006-03-05 17:01:51Z mike $".
*/
diff --git a/cups/ipp.c b/cups/ipp.c
index e9be31fe6..d34c35ccb 100644
--- a/cups/ipp.c
+++ b/cups/ipp.c
@@ -1,5 +1,5 @@
/*
- * "$Id: ipp.c 5047 2006-02-02 05:14:15Z mike $"
+ * "$Id: ipp.c 5231 2006-03-05 17:22:27Z mike $"
*
* Internet Printing Protocol support functions for the Common UNIX
* Printing System (CUPS).
@@ -57,8 +57,8 @@
* connection.
* ippWriteFile() - Write data for an IPP message to a file.
* ippWriteIO() - Write data for an IPP message.
- * _ipp_add_attr() - Add a new attribute to the request.
- * _ipp_free_attr() - Free an attribute.
+ * _ippAddAttr() - Add a new attribute to the request.
+ * _ippFreeAttr() - Free an attribute.
* ipp_length() - Compute the length of an IPP message or
* collection value.
* ipp_read_http() - Semi-blocking read on a HTTP connection...
@@ -111,10 +111,10 @@ ippAddBoolean(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_BOOLEAN;
attr->values[0].boolean = value;
@@ -145,10 +145,10 @@ ippAddBooleans(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL || num_values < 1)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+ if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_BOOLEAN;
@@ -183,10 +183,10 @@ ippAddCollection(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_BEGIN_COLLECTION;
attr->values[0].collection = value;
@@ -220,10 +220,10 @@ ippAddCollections(
if (ipp == NULL || name == NULL || num_values < 1)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+ if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_BEGIN_COLLECTION;
@@ -256,10 +256,10 @@ ippAddDate(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL || value == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_DATE;
memcpy(attr->values[0].date, value, 11);
@@ -288,10 +288,10 @@ ippAddInteger(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = type;
attr->values[0].integer = value;
@@ -320,10 +320,10 @@ ippAddIntegers(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL || num_values < 1)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+ if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = type;
@@ -356,14 +356,14 @@ ippAddOctetString(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
/*
* Initialize the attribute data...
*/
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_STRING;
attr->values[0].unknown.length = datalen;
@@ -402,7 +402,7 @@ ippAddString(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
/*
@@ -432,13 +432,13 @@ ippAddString(ipp_t *ipp, /* I - IPP message */
* Initialize the attribute data...
*/
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = type;
attr->values[0].string.charset = ((int)type & IPP_TAG_COPY) ? (char *)charset :
- charset ? _cups_sp_alloc(charset) : NULL;
+ charset ? _cupsStrAlloc(charset) : NULL;
attr->values[0].string.text = ((int)type & IPP_TAG_COPY) ? (char *)value :
- value ? _cups_sp_alloc(value) : NULL;
+ value ? _cupsStrAlloc(value) : NULL;
return (attr);
}
@@ -466,14 +466,14 @@ ippAddStrings(
if (ipp == NULL || name == NULL || num_values < 1)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+ if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
return (NULL);
/*
* Initialize the attribute data...
*/
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = type;
@@ -483,7 +483,7 @@ ippAddStrings(
{
if (i == 0)
value->string.charset = ((int)type & IPP_TAG_COPY) ? (char *)charset :
- charset ? _cups_sp_alloc(charset) : NULL;
+ charset ? _cupsStrAlloc(charset) : NULL;
else
value->string.charset = attr->values[0].string.charset;
@@ -495,10 +495,10 @@ ippAddStrings(
if (type == IPP_TAG_LANGUAGE && !strcasecmp(values[i], "C"))
value->string.text = ((int)type & IPP_TAG_COPY) ? "en" :
- _cups_sp_alloc("en");
+ _cupsStrAlloc("en");
else
value->string.text = ((int)type & IPP_TAG_COPY) ? (char *)values[i] :
- _cups_sp_alloc(values[i]);
+ _cupsStrAlloc(values[i]);
}
}
@@ -523,10 +523,10 @@ ippAddRange(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_RANGE;
attr->values[0].range.lower = lower;
@@ -556,10 +556,10 @@ ippAddRanges(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL || num_values < 1)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+ if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_RANGE;
@@ -594,10 +594,10 @@ ippAddResolution(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 1)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 1)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_RESOLUTION;
attr->values[0].resolution.xres = xres;
@@ -629,10 +629,10 @@ ippAddResolutions(ipp_t *ipp, /* I - IPP message */
if (ipp == NULL || name == NULL || num_values < 1)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, num_values)) == NULL)
+ if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
return (NULL);
- attr->name = _cups_sp_alloc(name);
+ attr->name = _cupsStrAlloc(name);
attr->group_tag = group;
attr->value_tag = IPP_TAG_RESOLUTION;
@@ -665,7 +665,7 @@ ippAddSeparator(ipp_t *ipp) /* I - IPP message */
if (ipp == NULL)
return (NULL);
- if ((attr = _ipp_add_attr(ipp, 0)) == NULL)
+ if ((attr = _ippAddAttr(ipp, 0)) == NULL)
return (NULL);
attr->group_tag = IPP_TAG_ZERO;
@@ -743,7 +743,7 @@ ippDelete(ipp_t *ipp) /* I - IPP message */
for (attr = ipp->attrs; attr != NULL; attr = next)
{
next = attr->next;
- _ipp_free_attr(attr);
+ _ippFreeAttr(attr);
}
free(ipp);
@@ -791,7 +791,7 @@ ippDeleteAttribute(
* Free memory used by the attribute...
*/
- _ipp_free_attr(current);
+ _ippFreeAttr(current);
}
}
@@ -1254,7 +1254,7 @@ ippReadIO(void *src, /* I - Data source */
if (ipp->current)
ipp->prev = ipp->current;
- attr = ipp->current = _ipp_add_attr(ipp, 1);
+ attr = ipp->current = _ippAddAttr(ipp, 1);
DEBUG_printf(("ippReadIO: membername, ipp->current=%p, ipp->prev=%p\n",
ipp->current, ipp->prev));
@@ -1280,14 +1280,14 @@ ippReadIO(void *src, /* I - Data source */
if (ipp->current)
ipp->prev = ipp->current;
- attr = ipp->current = _ipp_add_attr(ipp, 1);
+ attr = ipp->current = _ippAddAttr(ipp, 1);
DEBUG_printf(("ippReadIO: name=\'%s\', ipp->current=%p, ipp->prev=%p\n",
buffer, ipp->current, ipp->prev));
attr->group_tag = ipp->curtag;
attr->value_tag = tag;
- attr->name = _cups_sp_alloc((char *)buffer);
+ attr->name = _cupsStrAlloc((char *)buffer);
attr->num_values = 0;
}
else
@@ -1347,7 +1347,7 @@ ippReadIO(void *src, /* I - Data source */
}
buffer[n] = '\0';
- value->string.text = _cups_sp_alloc((char *)buffer);
+ value->string.text = _cupsStrAlloc((char *)buffer);
DEBUG_printf(("ippReadIO: value = \'%s\'\n",
value->string.text));
break;
@@ -1427,13 +1427,13 @@ ippReadIO(void *src, /* I - Data source */
string[n] = '\0';
}
- value->string.charset = _cups_sp_alloc((char *)string);
+ value->string.charset = _cupsStrAlloc((char *)string);
bufptr += 2 + n;
n = (bufptr[0] << 8) | bufptr[1];
bufptr[2 + n] = '\0';
- value->string.text = _cups_sp_alloc((char *)bufptr + 2);
+ value->string.text = _cupsStrAlloc((char *)bufptr + 2);
break;
case IPP_TAG_BEGIN_COLLECTION :
@@ -1480,7 +1480,7 @@ ippReadIO(void *src, /* I - Data source */
}
buffer[n] = '\0';
- attr->name = _cups_sp_alloc((char *)buffer);
+ attr->name = _cupsStrAlloc((char *)buffer);
/*
* Since collection members are encoded differently than
@@ -2400,17 +2400,17 @@ ippWriteIO(void *dst, /* I - Destination */
/*
- * '_ipp_add_attr()' - Add a new attribute to the request.
+ * '_ippAddAttr()' - Add a new attribute to the request.
*/
ipp_attribute_t * /* O - New attribute */
-_ipp_add_attr(ipp_t *ipp, /* I - IPP message */
+_ippAddAttr(ipp_t *ipp, /* I - IPP message */
int num_values) /* I - Number of values */
{
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("_ipp_add_attr(%p, %d)\n", ipp, num_values));
+ DEBUG_printf(("_ippAddAttr(%p, %d)\n", ipp, num_values));
if (ipp == NULL || num_values < 0)
return (NULL);
@@ -2430,24 +2430,24 @@ _ipp_add_attr(ipp_t *ipp, /* I - IPP message */
ipp->last = attr;
}
- DEBUG_printf(("_ipp_add_attr(): %p\n", attr));
+ DEBUG_printf(("_ippAddAttr(): %p\n", attr));
return (attr);
}
/*
- * '_ipp_free_attr()' - Free an attribute.
+ * '_ippFreeAttr()' - Free an attribute.
*/
void
-_ipp_free_attr(ipp_attribute_t *attr) /* I - Attribute to free */
+_ippFreeAttr(ipp_attribute_t *attr) /* I - Attribute to free */
{
int i; /* Looping var */
ipp_value_t *value; /* Current value */
- DEBUG_printf(("_ipp_free_attr(): %p\n", attr));
+ DEBUG_printf(("_ippFreeAttr(): %p\n", attr));
switch (attr->value_tag)
{
@@ -2463,7 +2463,7 @@ _ipp_free_attr(ipp_attribute_t *attr) /* I - Attribute to free */
for (i = 0, value = attr->values;
i < attr->num_values;
i ++, value ++)
- _cups_sp_free(value->string.text);
+ _cupsStrFree(value->string.text);
break;
case IPP_TAG_TEXTLANG :
@@ -2473,8 +2473,8 @@ _ipp_free_attr(ipp_attribute_t *attr) /* I - Attribute to free */
i ++, value ++)
{
if (value->string.charset && i == 0)
- _cups_sp_free(value->string.charset);
- _cups_sp_free(value->string.text);
+ _cupsStrFree(value->string.charset);
+ _cupsStrFree(value->string.text);
}
break;
@@ -2506,7 +2506,7 @@ _ipp_free_attr(ipp_attribute_t *attr) /* I - Attribute to free */
}
if (attr->name)
- _cups_sp_free(attr->name);
+ _cupsStrFree(attr->name);
free(attr);
}
@@ -2798,5 +2798,5 @@ ipp_write_file(int *fd, /* I - File descriptor */
/*
- * End of "$Id: ipp.c 5047 2006-02-02 05:14:15Z mike $".
+ * End of "$Id: ipp.c 5231 2006-03-05 17:22:27Z mike $".
*/
diff --git a/cups/language.c b/cups/language.c
index 169c38af9..1d1533fd3 100644
--- a/cups/language.c
+++ b/cups/language.c
@@ -1,5 +1,5 @@
/*
- * "$Id: language.c 5109 2006-02-15 20:11:10Z mike $"
+ * "$Id: language.c 5238 2006-03-07 04:41:42Z mike $"
*
* I18N/language support for the Common UNIX Printing System (CUPS).
*
@@ -38,8 +38,6 @@
* _cupsMessageFree() - Free a messages array.
* _cupsMessageLoad() - Load a .po file into a messages array.
* _cupsMessageLookup() - Lookup a message string.
- * _cupsRestoreLocale() - Restore the original locale...
- * _cupsSaveLocale() - Set the locale and save a copy of the old locale...
* appleLangDefault() - Get the default locale string.
* cups_cache_lookup() - Lookup a language in the cache...
* cups_message_compare() - Compare two messages.
@@ -271,15 +269,12 @@ cupsLangGet(const char *language) /* I - Language or locale */
langname[16], /* Requested language name */
country[16], /* Country code */
charset[16], /* Character set */
-#ifdef CODESET
*csptr, /* Pointer to CODESET string */
-#endif /* CODESET */
*ptr, /* Pointer into language/charset */
real[48], /* Real language name */
filename[1024]; /* Filename for language locale file */
cups_encoding_t encoding; /* Encoding to use */
cups_lang_t *lang; /* Current language... */
- char *oldlocale; /* Old locale name */
_cups_globals_t *cg = _cupsGlobals();
/* Pointer to library globals */
static const char * const locale_encodings[] =
@@ -327,19 +322,38 @@ cupsLangGet(const char *language) /* I - Language or locale */
DEBUG_printf(("cupsLangGet(language=\"%s\")\n", language ? language : "(null)"));
#ifdef __APPLE__
+ /*
+ * Set the character set to UTF-8...
+ */
+
+ strcpy(charset, "UTF8");
+
/*
* Apple's setlocale doesn't give us the user's localization
* preference so we have to look it up this way...
*/
- if (language == NULL)
+ if (!language)
language = appleLangDefault();
+
#else
- if (language == NULL)
+ /*
+ * Set the charset to "unknown"...
+ */
+
+ charset[0] = '\0';
+
+ /*
+ * Use setlocale() to determine the currently set locale, and then
+ * fallback to environment variables to avoid setting the locale,
+ * since setlocale() is not thread-safe!
+ */
+
+ if (!language)
{
/*
* First see if the locale has been set; if it is still "C" or
- * "POSIX", set the locale to the default...
+ * "POSIX", use the environment to get the default...
*/
# ifdef LC_MESSAGES
@@ -352,14 +366,46 @@ cupsLangGet(const char *language) /* I - Language or locale */
ptr ? ptr : "(null)"));
if (!ptr || !strcmp(ptr, "C") || !strcmp(ptr, "POSIX"))
-# ifdef LC_MESSAGES
{
- ptr = setlocale(LC_MESSAGES, "");
- setlocale(LC_CTYPE, "");
+ /*
+ * Get the character set from the LC_CTYPE locale setting...
+ */
+
+ if ((ptr = getenv("LC_CTYPE")) == NULL)
+ if ((ptr = getenv("LC_ALL")) == NULL)
+ if ((ptr = getenv("LANG")) == NULL)
+ ptr = "en_US";
+
+ if ((csptr = strchr(ptr, '.')) != NULL)
+ {
+ /*
+ * Extract the character set from the environment...
+ */
+
+ for (ptr = charset, csptr ++; *csptr; csptr ++)
+ if (ptr < (charset + sizeof(charset) - 1) && isalnum(*csptr & 255))
+ *ptr++ = *csptr;
+
+ *ptr = '\0';
+ }
+ else
+ {
+ /*
+ * Default to UTF-8...
+ */
+
+ strcpy(charset, "UTF8");
+ }
+
+ /*
+ * Get the locale for messages from the LC_MESSAGES locale setting...
+ */
+
+ if ((ptr = getenv("LC_MESSAGES")) == NULL)
+ if ((ptr = getenv("LC_ALL")) == NULL)
+ if ((ptr = getenv("LANG")) == NULL)
+ ptr = "en_US";
}
-# else
- ptr = setlocale(LC_ALL, "");
-# endif /* LC_MESSAGES */
if (ptr)
{
@@ -380,27 +426,19 @@ cupsLangGet(const char *language) /* I - Language or locale */
if (!language)
{
/*
- * Switch to the value of the "LANG" environment variable, and if
- * that is NULL as well, use "C".
+ * Switch to the POSIX ("C") locale...
*/
- if ((language = getenv("LANG")) == NULL)
- language = "C";
+ language = "C";
}
- /*
- * Set the charset to "unknown"...
- */
-
- charset[0] = '\0';
-
#ifdef CODESET
/*
* On systems that support the nl_langinfo(CODESET) call, use
* this value as the character set...
*/
- if ((csptr = nl_langinfo(CODESET)) != NULL)
+ if (!charset[0] && (csptr = nl_langinfo(CODESET)) != NULL)
{
/*
* Copy all of the letters and numbers in the CODESET string...
@@ -417,22 +455,6 @@ cupsLangGet(const char *language) /* I - Language or locale */
}
#endif /* CODESET */
- /*
- * Set the locale back to POSIX while we do string ops, since
- * apparently some buggy C libraries break ctype() for non-I18N
- * chars...
- */
-
-#if defined(__APPLE__)
- /* The ctype bug isn't in Apple's libc */
- (void)locale; /* anti-compiler-warning-code */
- (void)oldlocale; /* anti-compiler-warning-code */
-#elif !defined(LC_CTYPE)
- oldlocale = _cupsSaveLocale(LC_ALL, "C");
-#else
- oldlocale = _cupsSaveLocale(LC_CTYPE, "C");
-#endif /* __APPLE__ */
-
/*
* Parse the language string passed in to a locale string. "C" is the
* standard POSIX locale and is copied unchanged. Otherwise the
@@ -501,18 +523,6 @@ cupsLangGet(const char *language) /* I - Language or locale */
}
}
- /*
- * Restore the locale...
- */
-
-#if defined(__APPLE__)
- /* The ctype bug isn't in Apple's libc */
-#elif !defined(LC_CTYPE)
- _cupsRestoreLocale(LC_ALL, oldlocale);
-#else
- _cupsRestoreLocale(LC_CTYPE, oldlocale);
-#endif /* __APPLE__ */
-
DEBUG_printf(("cupsLangGet: langname=\"%s\", country=\"%s\", charset=\"%s\"\n",
langname, country, charset));
@@ -900,66 +910,6 @@ _cupsMessageLookup(cups_array_t *a, /* I - Message array */
}
-/*
- * '_cupsRestoreLocale()' - Restore the original locale...
- */
-
-void
-_cupsRestoreLocale(int category, /* I - Category */
- char *oldlocale) /* I - Old locale or NULL */
-{
- DEBUG_printf(("_cupsRestoreLocale(category=%d, oldlocale=\"%s\")\n",
- category, oldlocale));
-
- if (oldlocale)
- {
- /*
- * Reset the locale and free the locale string...
- */
-
- setlocale(category, oldlocale);
- free(oldlocale);
- }
-}
-
-
-/*
- * '_cupsSaveLocale()' - Set the locale and save a copy of the old locale...
- */
-
-char * /* O - Old locale or NULL */
-_cupsSaveLocale(int category, /* I - Category */
- const char *locale) /* I - New locale or NULL */
-{
- char *oldlocale; /* Old locale */
-
-
- DEBUG_printf(("_cupsSaveLocale(category=%d, locale=\"%s\")\n",
- category, locale));
-
- /*
- * Get the old locale and copy it...
- */
-
- if ((oldlocale = setlocale(category, NULL)) != NULL)
- oldlocale = strdup(oldlocale);
-
- DEBUG_printf((" oldlocale=\"%s\"\n", oldlocale ? oldlocale : "(null)"));
-
- /*
- * Set the new locale...
- */
-
- setlocale(category, locale);
-
- /*
- * Return a copy of the old locale...
- */
-
- return (oldlocale);
-}
-
-
#ifdef __APPLE__
/*
* Code & data to translate OSX's language names to their ISO 639-1 locale.
@@ -1296,5 +1246,5 @@ cups_unquote(char *d, /* O - Unquoted string */
/*
- * End of "$Id: language.c 5109 2006-02-15 20:11:10Z mike $".
+ * End of "$Id: language.c 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/libcups_s.exp b/cups/libcups_s.exp
index 000766cdf..bcf6d564b 100644
--- a/cups/libcups_s.exp
+++ b/cups/libcups_s.exp
@@ -1,21 +1,27 @@
-_cups_hstrerror
-_cups_md5_append
-_cups_md5_finish
-_cups_md5_init
-_cups_strlcat
-_cups_strlcpy
+_cupsAdminGetServerSettings
+_cupsAdminSetServerSettings
+_cupsCharmapFlush
_cupsEncodingName
_cupsGetPassword
_cupsGlobals
+_cupsLangFlush
_cupsLangPrintf
_cupsLangPuts
_cupsLangString
+_cupsMD5Append
+_cupsMD5Finish
+_cupsMD5Init
_cupsMessageFree
_cupsMessageLoad
_cupsMessageLookup
-_cupsRestoreLocale
-_cupsSaveLocale
-_httpReadCDSA
-_httpWriteCDSA
-_ipp_add_attr
-_ipp_free_attr
+_cupsNormalizeMapsFlush
+_cupsSetError
+_cupsStrAlloc
+_cups_strcpy
+_cupsStrFlush
+_cupsStrFree
+_cups_strlcat
+_cups_strlcpy
+_cupsStrStatistics
+_ippAddAttr
+_ippFreeAttr
diff --git a/cups/mark.c b/cups/mark.c
index bb29bcbcf..5cbac1b76 100644
--- a/cups/mark.c
+++ b/cups/mark.c
@@ -1,5 +1,5 @@
/*
- * "$Id: mark.c 5190 2006-02-27 02:42:07Z mike $"
+ * "$Id: mark.c 5238 2006-03-07 04:41:42Z mike $"
*
* Option marking routines for the Common UNIX Printing System (CUPS).
*
@@ -323,6 +323,7 @@ ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
int i, j; /* Looping vars */
ppd_option_t *o; /* Option pointer */
ppd_choice_t *c; /* Choice pointer */
+ struct lconv *loc; /* Locale data */
DEBUG_printf(("ppdMarkOption(ppd=%p, option=\"%s\", choice=\"%s\")\n",
@@ -354,6 +355,7 @@ ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
if ((o = ppdFindOption(ppd, option)) == NULL)
return (0);
+ loc = localeconv();
if (!strncasecmp(choice, "Custom.", 7))
{
@@ -380,7 +382,7 @@ ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
ppd_coption_t *coption; /* Custom option */
ppd_cparam_t *cparam; /* Custom parameter */
- char units[33]; /* Custom points units */
+ char *units; /* Custom points units */
if ((coption = ppdFindCustomOption(ppd, option)) != NULL)
{
@@ -392,24 +394,27 @@ ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
case PPD_CUSTOM_CURVE :
case PPD_CUSTOM_INVCURVE :
case PPD_CUSTOM_REAL :
- cparam->current.custom_real = atof(choice + 7);
+ cparam->current.custom_real = _cupsStrScand(choice + 7, NULL,
+ loc);
break;
case PPD_CUSTOM_POINTS :
- if (sscanf(choice + 7, "%f%s", &(cparam->current.custom_points),
- units) < 2)
- strcpy(units, "pt");
-
- if (!strcasecmp(units, "cm"))
- cparam->current.custom_points *= 72.0 / 2.54;
- else if (!strcasecmp(units, "mm"))
- cparam->current.custom_points *= 72.0 / 25.4;
- else if (!strcasecmp(units, "m"))
- cparam->current.custom_points *= 72.0 / 0.0254;
- else if (!strcasecmp(units, "in"))
- cparam->current.custom_points *= 72.0;
- else if (!strcasecmp(units, "ft"))
- cparam->current.custom_points *= 12 * 72.0;
+ cparam->current.custom_points = _cupsStrScand(choice + 7,
+ &units, loc);
+
+ if (units)
+ {
+ if (!strcasecmp(units, "cm"))
+ cparam->current.custom_points *= 72.0 / 2.54;
+ else if (!strcasecmp(units, "mm"))
+ cparam->current.custom_points *= 72.0 / 25.4;
+ else if (!strcasecmp(units, "m"))
+ cparam->current.custom_points *= 72.0 / 0.0254;
+ else if (!strcasecmp(units, "in"))
+ cparam->current.custom_points *= 72.0;
+ else if (!strcasecmp(units, "ft"))
+ cparam->current.custom_points *= 12 * 72.0;
+ }
break;
case PPD_CUSTOM_INT :
@@ -436,7 +441,7 @@ ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
ppd_coption_t *coption; /* Custom option */
ppd_cparam_t *cparam; /* Custom parameter */
- char units[33]; /* Custom points units */
+ char *units; /* Custom points units */
int num_vals; /* Number of values */
cups_option_t *vals, /* Values */
*val; /* Value */
@@ -459,24 +464,27 @@ ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
case PPD_CUSTOM_CURVE :
case PPD_CUSTOM_INVCURVE :
case PPD_CUSTOM_REAL :
- cparam->current.custom_real = atof(val->value);
+ cparam->current.custom_real = _cupsStrScand(val->value, NULL,
+ loc);
break;
case PPD_CUSTOM_POINTS :
- if (sscanf(val->value, "%f%s", &(cparam->current.custom_points),
- units) < 2)
- strcpy(units, "pt");
-
- if (!strcasecmp(units, "cm"))
- cparam->current.custom_points *= 72.0 / 2.54;
- else if (!strcasecmp(units, "mm"))
- cparam->current.custom_points *= 72.0 / 25.4;
- else if (!strcasecmp(units, "m"))
- cparam->current.custom_points *= 72.0 / 0.0254;
- else if (!strcasecmp(units, "in"))
- cparam->current.custom_points *= 72.0;
- else if (!strcasecmp(units, "ft"))
- cparam->current.custom_points *= 12 * 72.0;
+ cparam->current.custom_points = _cupsStrScand(val->value, &units,
+ loc);
+
+ if (units)
+ {
+ if (!strcasecmp(units, "cm"))
+ cparam->current.custom_points *= 72.0 / 2.54;
+ else if (!strcasecmp(units, "mm"))
+ cparam->current.custom_points *= 72.0 / 25.4;
+ else if (!strcasecmp(units, "m"))
+ cparam->current.custom_points *= 72.0 / 0.0254;
+ else if (!strcasecmp(units, "in"))
+ cparam->current.custom_points *= 72.0;
+ else if (!strcasecmp(units, "ft"))
+ cparam->current.custom_points *= 12 * 72.0;
+ }
break;
case PPD_CUSTOM_INT :
@@ -648,5 +656,5 @@ ppd_defaults(ppd_file_t *ppd, /* I - PPD file */
/*
- * End of "$Id: mark.c 5190 2006-02-27 02:42:07Z mike $".
+ * End of "$Id: mark.c 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/md5-apple.h b/cups/md5-apple.h
index d4770ccd1..4284ad4ab 100644
--- a/cups/md5-apple.h
+++ b/cups/md5-apple.h
@@ -1,5 +1,5 @@
/*
- * "$Id: md5-apple.h 4695 2005-09-23 17:07:14Z mike $"
+ * "$Id: md5-apple.h 5232 2006-03-05 17:59:19Z mike $"
*
* MD5 MacOS X compatibility header for the Common UNIX Printing
* System (CUPS).
@@ -28,12 +28,12 @@
*/
void md5_init(_cups_md5_state_t *pms)
- { _cups_md5_init(pms); }
+ { _cupsMD5Init(pms); }
void md5_append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes)
- { _cups_md5_append(pms, data, nbytes); }
+ { _cupsMD5Append(pms, data, nbytes); }
void md5_finish(_cups_md5_state_t *pms, unsigned char digest[16])
- { _cups_md5_finish(pms, digest); }
+ { _cupsMD5Finish(pms, digest); }
/*
- * End of "$Id: md5-apple.h 4695 2005-09-23 17:07:14Z mike $".
+ * End of "$Id: md5-apple.h 5232 2006-03-05 17:59:19Z mike $".
*/
diff --git a/cups/md5.c b/cups/md5.c
index a0469408c..9a3fab987 100644
--- a/cups/md5.c
+++ b/cups/md5.c
@@ -26,7 +26,7 @@
ghost@aladdin.com
*/
-/*$Id: md5.c 4695 2005-09-23 17:07:14Z mike $ */
+/*$Id: md5.c 5232 2006-03-05 17:59:19Z mike $ */
/*
Independent implementation of MD5 (RFC 1321).
@@ -273,7 +273,7 @@ _cups_md5_process(_cups_md5_state_t *pms, const unsigned char *data /*[64]*/)
}
void
-_cups_md5_init(_cups_md5_state_t *pms)
+_cupsMD5Init(_cups_md5_state_t *pms)
{
pms->count[0] = pms->count[1] = 0;
pms->abcd[0] = 0x67452301;
@@ -283,7 +283,7 @@ _cups_md5_init(_cups_md5_state_t *pms)
}
void
-_cups_md5_append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes)
+_cupsMD5Append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes)
{
const unsigned char *p = data;
int left = nbytes;
@@ -321,7 +321,7 @@ _cups_md5_append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes)
}
void
-_cups_md5_finish(_cups_md5_state_t *pms, unsigned char digest[16])
+_cupsMD5Finish(_cups_md5_state_t *pms, unsigned char digest[16])
{
static const unsigned char pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -336,9 +336,9 @@ _cups_md5_finish(_cups_md5_state_t *pms, unsigned char digest[16])
for (i = 0; i < 8; ++i)
data[i] = (unsigned char)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
- _cups_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
+ _cupsMD5Append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
- _cups_md5_append(pms, data, 8);
+ _cupsMD5Append(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (unsigned char)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}
diff --git a/cups/md5.h b/cups/md5.h
index 72b338b50..3b0281c0f 100644
--- a/cups/md5.h
+++ b/cups/md5.h
@@ -26,7 +26,7 @@
ghost@aladdin.com
*/
-/*$Id: md5.h 4512 2005-05-12 19:47:56Z mike $ */
+/*$Id: md5.h 5232 2006-03-05 17:59:19Z mike $ */
/*
Independent implementation of MD5 (RFC 1321).
@@ -60,13 +60,13 @@ extern "C" {
# endif /* __cplusplus */
/* Initialize the algorithm. */
-void _cups_md5_init(_cups_md5_state_t *pms);
+void _cupsMD5Init(_cups_md5_state_t *pms);
/* Append a string to the message. */
-void _cups_md5_append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes);
+void _cupsMD5Append(_cups_md5_state_t *pms, const unsigned char *data, int nbytes);
/* Finish the message and return the digest. */
-void _cups_md5_finish(_cups_md5_state_t *pms, unsigned char digest[16]);
+void _cupsMD5Finish(_cups_md5_state_t *pms, unsigned char digest[16]);
# ifdef __cplusplus
} /* end extern "C" */
diff --git a/cups/md5passwd.c b/cups/md5passwd.c
index 1b9029a29..df8a75881 100644
--- a/cups/md5passwd.c
+++ b/cups/md5passwd.c
@@ -1,5 +1,5 @@
/*
- * "$Id: md5passwd.c 4828 2005-11-11 12:53:38Z mike $"
+ * "$Id: md5passwd.c 5232 2006-03-05 17:59:19Z mike $"
*
* MD5 password support for the Common UNIX Printing System (CUPS).
*
@@ -59,9 +59,9 @@ httpMD5(const char *username, /* I - User name */
*/
snprintf(line, sizeof(line), "%s:%s:%s", username, realm, passwd);
- _cups_md5_init(&state);
- _cups_md5_append(&state, (unsigned char *)line, (int)strlen(line));
- _cups_md5_finish(&state, sum);
+ _cupsMD5Init(&state);
+ _cupsMD5Append(&state, (unsigned char *)line, (int)strlen(line));
+ _cupsMD5Finish(&state, sum);
/*
* Return the sum...
@@ -94,9 +94,9 @@ httpMD5Final(const char *nonce, /* I - Server nonce value */
*/
snprintf(line, sizeof(line), "%s:%s", method, resource);
- _cups_md5_init(&state);
- _cups_md5_append(&state, (unsigned char *)line, (int)strlen(line));
- _cups_md5_finish(&state, sum);
+ _cupsMD5Init(&state);
+ _cupsMD5Append(&state, (unsigned char *)line, (int)strlen(line));
+ _cupsMD5Finish(&state, sum);
httpMD5String(sum, a2);
/*
@@ -107,9 +107,9 @@ httpMD5Final(const char *nonce, /* I - Server nonce value */
snprintf(line, sizeof(line), "%s:%s:%s", md5, nonce, a2);
- _cups_md5_init(&state);
- _cups_md5_append(&state, (unsigned char *)line, (int)strlen(line));
- _cups_md5_finish(&state, sum);
+ _cupsMD5Init(&state);
+ _cupsMD5Append(&state, (unsigned char *)line, (int)strlen(line));
+ _cupsMD5Finish(&state, sum);
return (httpMD5String(sum, md5));
}
@@ -147,5 +147,5 @@ httpMD5String(const unsigned char *sum, /* I - MD5 sum data */
/*
- * End of "$Id: md5passwd.c 4828 2005-11-11 12:53:38Z mike $".
+ * End of "$Id: md5passwd.c 5232 2006-03-05 17:59:19Z mike $".
*/
diff --git a/cups/page.c b/cups/page.c
index 0c340297a..f9ac4ef85 100644
--- a/cups/page.c
+++ b/cups/page.c
@@ -1,5 +1,5 @@
/*
- * "$Id: page.c 4494 2005-02-18 02:18:11Z mike $"
+ * "$Id: page.c 5238 2006-03-07 04:41:42Z mike $"
*
* Page size functions for the Common UNIX Printing System (CUPS).
*
@@ -45,28 +45,29 @@
* 'ppdPageSize()' - Get the page size record for the given size.
*/
-ppd_size_t * /* O - Size record for page or NULL */
-ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */
- const char *name) /* I - Size name */
+ppd_size_t * /* O - Size record for page or NULL */
+ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */
+ const char *name) /* I - Size name */
{
- int i; /* Looping var */
- float w, l; /* Width and length of page */
- char units[255]; /* Page size units... */
+ int i; /* Looping var */
+ float w, l; /* Width and length of page */
+ char *nameptr; /* Pointer into name */
+ struct lconv *loc; /* Locale data */
- if (ppd == NULL)
+ if (!ppd)
return (NULL);
- if (name != NULL)
+ if (name)
{
- if (strncmp(name, "Custom.", 7) == 0 && ppd->variable_sizes)
+ if (!strncmp(name, "Custom.", 7) && ppd->variable_sizes)
{
/*
* Find the custom page size...
*/
for (i = 0; i < ppd->num_sizes; i ++)
- if (strcmp("Custom", ppd->sizes[i].name) == 0)
+ if (!strcmp("Custom", ppd->sizes[i].name))
break;
if (i == ppd->num_sizes)
@@ -81,11 +82,16 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */
* Custom.WIDTHxLENGTH[pt] - Size in points
*/
- units[0] = '\0';
- if (sscanf(name + 7, "%fx%f%254s", &w, &l, units) < 2)
+ loc = localeconv();
+ w = _cupsStrScand(name + 7, &nameptr, loc);
+ if (!nameptr || *nameptr != 'x')
return (NULL);
- if (strcasecmp(units, "in") == 0)
+ l = _cupsStrScand(nameptr, &nameptr, loc);
+ if (!nameptr)
+ return (NULL);
+
+ if (!strcasecmp(nameptr, "in"))
{
ppd->sizes[i].width = w * 72.0f;
ppd->sizes[i].length = l * 72.0f;
@@ -94,7 +100,7 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */
ppd->sizes[i].right = w * 72.0f - ppd->custom_margins[2];
ppd->sizes[i].top = l * 72.0f - ppd->custom_margins[3];
}
- else if (strcasecmp(units, "cm") == 0)
+ else if (!strcasecmp(nameptr, "cm"))
{
ppd->sizes[i].width = w / 2.54f * 72.0f;
ppd->sizes[i].length = l / 2.54f * 72.0f;
@@ -103,7 +109,7 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */
ppd->sizes[i].right = w / 2.54f * 72.0f - ppd->custom_margins[2];
ppd->sizes[i].top = l / 2.54f * 72.0f - ppd->custom_margins[3];
}
- else if (strcasecmp(units, "mm") == 0)
+ else if (!strcasecmp(nameptr, "mm"))
{
ppd->sizes[i].width = w / 25.4f * 72.0f;
ppd->sizes[i].length = l / 25.4f * 72.0f;
@@ -131,7 +137,7 @@ ppdPageSize(ppd_file_t *ppd, /* I - PPD file record */
*/
for (i = 0; i < ppd->num_sizes; i ++)
- if (strcmp(name, ppd->sizes[i].name) == 0)
+ if (!strcasecmp(name, ppd->sizes[i].name))
return (ppd->sizes + i);
}
}
@@ -187,5 +193,5 @@ ppdPageLength(ppd_file_t *ppd, /* I - PPD file */
/*
- * End of "$Id: page.c 4494 2005-02-18 02:18:11Z mike $".
+ * End of "$Id: page.c 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/ppd.c b/cups/ppd.c
index c13149320..f55f8865d 100644
--- a/cups/ppd.c
+++ b/cups/ppd.c
@@ -1,5 +1,5 @@
/*
- * "$Id: ppd.c 5200 2006-02-28 00:10:32Z mike $"
+ * "$Id: ppd.c 5238 2006-03-07 04:41:42Z mike $"
*
* PPD file routines for the Common UNIX Printing System (CUPS).
*
@@ -393,7 +393,6 @@ ppdOpen(FILE *fp) /* I - File to read from */
ppd_file_t * /* O - PPD file record */
ppdOpen2(cups_file_t *fp) /* I - File to read from */
{
- char *oldlocale; /* Old locale settings */
int i, j, k; /* Looping vars */
int count; /* Temporary count */
ppd_file_t *ppd; /* PPD file record */
@@ -420,6 +419,7 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
ppd_profile_t *profile; /* Pointer to color profile */
char **filter; /* Pointer to filter */
cups_lang_t *language; /* Default language */
+ struct lconv *loc; /* Locale data */
int ui_keyword; /* Is this line a UI keyword? */
_cups_globals_t *cg = _cupsGlobals();
/* Global data */
@@ -554,12 +554,7 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
*/
language = cupsLangDefault();
-
-#ifdef LC_NUMERIC
- oldlocale = _cupsSaveLocale(LC_NUMERIC, "C");
-#else
- oldlocale = _cupsSaveLocale(LC_ALL, "C");
-#endif /* LC_NUMERIC */
+ loc = localeconv();
/*
* Read lines from the PPD file and add them to the file record...
@@ -772,13 +767,18 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
memset(profile, 0, sizeof(ppd_profile_t));
strlcpy(profile->resolution, name, sizeof(profile->resolution));
strlcpy(profile->media_type, text, sizeof(profile->media_type));
- sscanf(string, "%f%f%f%f%f%f%f%f%f%f%f", &(profile->density),
- &(profile->gamma),
- profile->matrix[0] + 0, profile->matrix[0] + 1,
- profile->matrix[0] + 2, profile->matrix[1] + 0,
- profile->matrix[1] + 1, profile->matrix[1] + 2,
- profile->matrix[2] + 0, profile->matrix[2] + 1,
- profile->matrix[2] + 2);
+
+ profile->density = _cupsStrScand(string, &sptr, loc);
+ profile->gamma = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[0][0] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[0][1] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[0][2] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[1][0] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[1][1] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[1][2] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[2][0] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[2][1] = _cupsStrScand(sptr, &sptr, loc);
+ profile->matrix[2][2] = _cupsStrScand(sptr, &sptr, loc);
}
else if (!strcmp(keyword, "cupsFilter"))
{
@@ -877,8 +877,8 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
if (!strcmp(ctype, "curve"))
{
cparam->type = PPD_CUSTOM_CURVE;
- cparam->minimum.custom_curve = atof(cminimum);
- cparam->maximum.custom_curve = atof(cmaximum);
+ cparam->minimum.custom_curve = _cupsStrScand(cminimum, NULL, loc);
+ cparam->maximum.custom_curve = _cupsStrScand(cmaximum, NULL, loc);
}
else if (!strcmp(ctype, "int"))
{
@@ -889,8 +889,8 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
else if (!strcmp(ctype, "invcurve"))
{
cparam->type = PPD_CUSTOM_INVCURVE;
- cparam->minimum.custom_invcurve = atof(cminimum);
- cparam->maximum.custom_invcurve = atof(cmaximum);
+ cparam->minimum.custom_invcurve = _cupsStrScand(cminimum, NULL, loc);
+ cparam->maximum.custom_invcurve = _cupsStrScand(cmaximum, NULL, loc);
}
else if (!strcmp(ctype, "passcode"))
{
@@ -907,14 +907,14 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
else if (!strcmp(ctype, "points"))
{
cparam->type = PPD_CUSTOM_POINTS;
- cparam->minimum.custom_points = atof(cminimum);
- cparam->maximum.custom_points = atof(cmaximum);
+ cparam->minimum.custom_points = _cupsStrScand(cminimum, NULL, loc);
+ cparam->maximum.custom_points = _cupsStrScand(cmaximum, NULL, loc);
}
else if (!strcmp(ctype, "real"))
{
cparam->type = PPD_CUSTOM_REAL;
- cparam->minimum.custom_real = atof(cminimum);
- cparam->maximum.custom_real = atof(cmaximum);
+ cparam->minimum.custom_real = _cupsStrScand(cminimum, NULL, loc);
+ cparam->maximum.custom_real = _cupsStrScand(cmaximum, NULL, loc);
}
else if (!strcmp(ctype, "string"))
{
@@ -948,9 +948,10 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
}
}
else if (!strcmp(keyword, "HWMargins"))
- sscanf(string, "%f%f%f%f", ppd->custom_margins + 0,
- ppd->custom_margins + 1, ppd->custom_margins + 2,
- ppd->custom_margins + 3);
+ {
+ for (i = 0, sptr = string; i < 4; i ++)
+ ppd->custom_margins[i] = _cupsStrScand(sptr, &sptr, loc);
+ }
else if (!strncmp(keyword, "Custom", 6) && !strcmp(name, "True"))
{
ppd_coption_t *coption; /* Custom option */
@@ -1344,7 +1345,9 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
else if (!strcmp(keyword, "OrderDependency") ||
!strcmp(keyword, "NonUIOrderDependency"))
{
- if (sscanf(string, "%f%40s%40s", &order, name, keyword) != 3)
+ order = _cupsStrScand(string, &sptr, loc);
+
+ if (!sptr || sscanf(sptr, "%40s%40s", name, keyword) != 2)
{
cg->ppd_status = PPD_BAD_ORDER_DEPENDENCY;
@@ -1560,7 +1563,8 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
goto error;
}
- sscanf(string, "%f%f", &(size->width), &(size->length));
+ size->width = _cupsStrScand(string, &sptr, loc);
+ size->length = _cupsStrScand(sptr, NULL, loc);
ppd_free(string);
string = NULL;
@@ -1581,8 +1585,10 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
goto error;
}
- sscanf(string, "%f%f%f%f", &(size->left), &(size->bottom),
- &(size->right), &(size->top));
+ size->left = _cupsStrScand(string, &sptr, loc);
+ size->bottom = _cupsStrScand(sptr, &sptr, loc);
+ size->right = _cupsStrScand(sptr, &sptr, loc);
+ size->top = _cupsStrScand(sptr, NULL, loc);
ppd_free(string);
string = NULL;
@@ -1643,12 +1649,6 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
cupsLangFree(language);
-#ifdef LC_NUMERIC
- _cupsRestoreLocale(LC_NUMERIC, oldlocale);
-#else
- _cupsRestoreLocale(LC_ALL, oldlocale);
-#endif /* LC_NUMERIC */
-
#ifdef DEBUG
if (!feof(fp))
printf("Premature EOF at %lu...\n", (unsigned long)ftell(fp));
@@ -1711,12 +1711,6 @@ ppdOpen2(cups_file_t *fp) /* I - File to read from */
cupsLangFree(language);
-#ifdef LC_NUMERIC
- _cupsRestoreLocale(LC_NUMERIC, oldlocale);
-#else
- _cupsRestoreLocale(LC_ALL, oldlocale);
-#endif /* LC_NUMERIC */
-
return (NULL);
}
@@ -2885,5 +2879,5 @@ ppd_read(cups_file_t *fp, /* I - File to read from */
/*
- * End of "$Id: ppd.c 5200 2006-02-28 00:10:32Z mike $".
+ * End of "$Id: ppd.c 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/ppd.h b/cups/ppd.h
index 2ec40c21f..d7688c3d5 100644
--- a/cups/ppd.h
+++ b/cups/ppd.h
@@ -1,5 +1,5 @@
/*
- * "$Id: ppd.h 5190 2006-02-27 02:42:07Z mike $"
+ * "$Id: ppd.h 5238 2006-03-07 04:41:42Z mike $"
*
* PostScript Printer Description definitions for the Common UNIX Printing
* System (CUPS).
@@ -381,6 +381,8 @@ extern int ppdEmitAfterOrder(ppd_file_t *ppd, FILE *fp,
ppd_section_t section, int limit,
float min_order);
extern int ppdEmitJCLEnd(ppd_file_t *ppd, FILE *fp);
+extern char *ppdEmitString(ppd_file_t *ppd, ppd_section_t section,
+ float min_order);
extern ppd_coption_t *ppdFindCustomOption(ppd_file_t *ppd,
const char *keyword);
extern ppd_cparam_t *ppdFindCustomParam(ppd_coption_t *opt,
@@ -403,5 +405,5 @@ extern ppd_file_t *ppdOpen2(cups_file_t *fp);
#endif /* !_CUPS_PPD_H_ */
/*
- * End of "$Id: ppd.h 5190 2006-02-27 02:42:07Z mike $".
+ * End of "$Id: ppd.h 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/string.c b/cups/string.c
index b30c77075..b92773da3 100644
--- a/cups/string.c
+++ b/cups/string.c
@@ -1,5 +1,5 @@
/*
- * "$Id: string.c 5047 2006-02-02 05:14:15Z mike $"
+ * "$Id: string.c 5238 2006-03-07 04:41:42Z mike $"
*
* String functions for the Common UNIX Printing System (CUPS).
*
@@ -25,10 +25,12 @@
*
* Contents:
*
- * _cups_sp_alloc() - Allocate/reference a string.
- * _cups_sp_flush() - Flush the string pool...
- * _cups_sp_free() - Free/dereference a string.
- * _cups_sp_statistics() - Return allocation statistics for string pool.
+ * _cupsStrAlloc() - Allocate/reference a string.
+ * _cupsStrFlush() - Flush the string pool...
+ * _cupsStrFormatd() - Format a floating-point number.
+ * _cupsStrFree() - Free/dereference a string.
+ * _cupsStrScand() - Scan a string for a floating-point number.
+ * _cupsStrStatistics() - Return allocation statistics for string pool.
* _cups_strcpy() - Copy a string allowing for overlapping strings.
* _cups_strdup() - Duplicate a string.
* _cups_strcasecmp() - Do a case-insensitive comparison.
@@ -57,11 +59,11 @@ static int compare_sp_items(_cups_sp_item_t *a, _cups_sp_item_t *b);
/*
- * '_cups_sp_alloc()' - Allocate/reference a string.
+ * '_cupsStrAlloc()' - Allocate/reference a string.
*/
char * /* O - String pointer */
-_cups_sp_alloc(const char *s) /* I - String */
+_cupsStrAlloc(const char *s) /* I - String */
{
_cups_globals_t *cg; /* Global data */
_cups_sp_item_t *item, /* String pool item */
@@ -132,11 +134,11 @@ _cups_sp_alloc(const char *s) /* I - String */
/*
- * '_cups_sp_flush()' - Flush the string pool...
+ * '_cupsStrFlush()' - Flush the string pool...
*/
void
-_cups_sp_flush(_cups_globals_t *cg) /* I - Global data */
+_cupsStrFlush(_cups_globals_t *cg) /* I - Global data */
{
_cups_sp_item_t *item; /* Current item */
@@ -154,11 +156,91 @@ _cups_sp_flush(_cups_globals_t *cg) /* I - Global data */
/*
- * '_cups_sp_free()' - Free/dereference a string.
+ * '_cupsStrFormatd()' - Format a floating-point number.
+ */
+
+char * /* O - Pointer to end of string */
+_cupsStrFormatd(char *buf, /* I - String */
+ char *bufend, /* I - End of string buffer */
+ double number, /* I - Number to format */
+ struct lconv *loc) /* I - Locale data */
+{
+ char *bufptr, /* Pointer into buffer */
+ temp[1024], /* Temporary string */
+ *tempdec, /* Pointer to decimal point */
+ *tempptr; /* Pointer into temporary string */
+ const char *dec; /* Decimal point */
+ int declen; /* Length of decimal point */
+
+
+ /*
+ * Format the number using the "%.12f" format and then eliminate
+ * unnecessary trailing 0's.
+ */
+
+ snprintf(temp, sizeof(temp), "%.12f", number);
+ for (tempptr = temp + strlen(temp) - 1;
+ tempptr > temp && *tempptr == '0';
+ *tempptr-- = '\0');
+
+ /*
+ * Next, find the decimal point...
+ */
+
+ if (loc && loc->decimal_point)
+ {
+ dec = loc->decimal_point;
+ declen = strlen(dec);
+ }
+ else
+ {
+ dec = ".";
+ declen = 1;
+ }
+
+ if (declen == 1)
+ tempdec = strchr(temp, *dec);
+ else
+ tempdec = strstr(temp, dec);
+
+ /*
+ * Copy everything up to the decimal point...
+ */
+
+ if (tempdec)
+ {
+ for (tempptr = temp, bufptr = buf;
+ tempptr < tempdec && bufptr < bufend;
+ *bufptr++ = *tempptr++);
+
+ tempdec += declen;
+
+ if (*tempdec && bufptr < bufend)
+ {
+ *bufptr++ = '.';
+
+ while (*tempptr && bufptr < bufend)
+ *bufptr++ = *tempptr++;
+ }
+
+ *bufptr = '\0';
+ }
+ else
+ {
+ strlcpy(buf, temp, bufend - buf + 1);
+ bufptr = buf + strlen(buf);
+ }
+
+ return (bufptr);
+}
+
+
+/*
+ * '_cupsStrFree()' - Free/dereference a string.
*/
void
-_cups_sp_free(const char *s)
+_cupsStrFree(const char *s) /* I - String to free */
{
_cups_globals_t *cg; /* Global data */
_cups_sp_item_t *item, /* String pool item */
@@ -211,12 +293,103 @@ _cups_sp_free(const char *s)
/*
- * '_cups_sp_statistics()' - Return allocation statistics for string pool.
+ * '_cupsStrScand()' - Scan a string for a floating-point number.
+ *
+ * This function handles the locale-specific BS so that a decimal
+ * point is always the period (".")...
+ */
+
+double /* O - Number */
+_cupsStrScand(const char *buf, /* I - Pointer to number */
+ char **bufptr, /* O - New pointer or NULL on error */
+ struct lconv *loc) /* I - Locale data */
+{
+ char temp[1024], /* Temporary buffer */
+ *tempptr; /* Pointer into temporary buffer */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!buf)
+ return (0.0);
+
+ /*
+ * Skip leading whitespace...
+ */
+
+ while (isspace(*buf & 255))
+ buf ++;
+
+ /*
+ * Copy leading sign, numbers, period, and then numbers...
+ */
+
+ tempptr = temp;
+ if (*buf == '-' || *buf == '+')
+ *tempptr++ = *buf++;
+
+ while (isdigit(*buf & 255))
+ if (tempptr < (temp + sizeof(temp) - 1))
+ *tempptr++ = *buf++;
+ else
+ {
+ if (bufptr)
+ *bufptr = NULL;
+
+ return (0.0);
+ }
+
+ if (*buf == '.')
+ {
+ if (loc && loc->decimal_point)
+ {
+ strlcpy(tempptr, loc->decimal_point, sizeof(temp) - (tempptr - temp));
+ tempptr += strlen(tempptr);
+ }
+ else if (tempptr < (temp + sizeof(temp) - 1))
+ *tempptr++ = '.';
+ else
+ {
+ if (bufptr)
+ *bufptr = NULL;
+
+ return (0.0);
+ }
+
+ while (isdigit(*buf & 255))
+ if (tempptr < (temp + sizeof(temp) - 1))
+ *tempptr++ = *buf++;
+ else
+ {
+ if (bufptr)
+ *bufptr = NULL;
+
+ return (0.0);
+ }
+ }
+
+ /*
+ * Nul-terminate the temporary string and return the value...
+ */
+
+ if (bufptr)
+ *bufptr = (char *)buf;
+
+ *tempptr = '\0';
+
+ return (strtod(temp, NULL));
+}
+
+
+/*
+ * '_cupsStrStatistics()' - Return allocation statistics for string pool.
*/
size_t /* O - Number of strings */
-_cups_sp_statistics(size_t *alloc_bytes,/* O - Allocated bytes */
- size_t *total_bytes)/* O - Total string bytes */
+_cupsStrStatistics(size_t *alloc_bytes, /* O - Allocated bytes */
+ size_t *total_bytes) /* O - Total string bytes */
{
size_t count, /* Number of strings */
abytes, /* Allocated string bytes */
@@ -455,5 +628,5 @@ compare_sp_items(_cups_sp_item_t *a, /* I - First item */
/*
- * End of "$Id: string.c 5047 2006-02-02 05:14:15Z mike $".
+ * End of "$Id: string.c 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/string.h b/cups/string.h
index 124cc7ede..1cec6aeec 100644
--- a/cups/string.h
+++ b/cups/string.h
@@ -1,5 +1,5 @@
/*
- * "$Id: string.h 5047 2006-02-02 05:14:15Z mike $"
+ * "$Id: string.h 5238 2006-03-07 04:41:42Z mike $"
*
* String definitions for the Common UNIX Printing System (CUPS).
*
@@ -36,6 +36,7 @@
# include
# include
# include
+# include
# ifdef HAVE_STRING_H
# include
@@ -129,9 +130,19 @@ extern int _cups_vsnprintf(char *, size_t, const char *, va_list);
* String pool functions...
*/
-extern char *_cups_sp_alloc(const char *s);
-extern void _cups_sp_free(const char *s);
-extern size_t _cups_sp_statistics(size_t *alloc_bytes, size_t *total_bytes);
+extern char *_cupsStrAlloc(const char *s);
+extern void _cupsStrFree(const char *s);
+extern size_t _cupsStrStatistics(size_t *alloc_bytes, size_t *total_bytes);
+
+
+/*
+ * Floating point number functions...
+ */
+
+extern char *_cupsStrFormatd(char *buf, char *bufend, double number,
+ struct lconv *loc);
+extern double _cupsStrScand(const char *buf, char **bufptr,
+ struct lconv *loc);
/*
@@ -145,5 +156,5 @@ extern size_t _cups_sp_statistics(size_t *alloc_bytes, size_t *total_bytes);
#endif /* !_CUPS_STRING_H_ */
/*
- * End of "$Id: string.h 5047 2006-02-02 05:14:15Z mike $".
+ * End of "$Id: string.h 5238 2006-03-07 04:41:42Z mike $".
*/
diff --git a/cups/testadmin.c b/cups/testadmin.c
new file mode 100644
index 000000000..0f2e1d0c2
--- /dev/null
+++ b/cups/testadmin.c
@@ -0,0 +1,129 @@
+/*
+ * "$Id: testadmin.c 5240 2006-03-07 21:55:29Z mike $"
+ *
+ * Admin function test program 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:
+ *
+ * main() - Main entry.
+ * show_settings() - Show settings in the array...
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include "adminutil.h"
+#include "string.h"
+
+
+/*
+ * Local functions...
+ */
+
+static void show_settings(int num_settings, cups_option_t *settings);
+
+
+/*
+ * 'main()' - Main entry.
+ */
+
+int /* O - Exit status */
+main(int argc, /* I - Number of command-line args */
+ char *argv[]) /* I - Command-line arguments */
+{
+ int i, /* Looping var */
+ num_settings; /* Number of settings */
+ cups_option_t *settings; /* Settings */
+ http_t *http; /* Connection to server */
+
+
+ /*
+ * Connect to the server using the defaults...
+ */
+
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+
+ /*
+ * Set the current configuration if we have anything on the command-line...
+ */
+
+ if (argc > 1)
+ {
+ for (i = 1, num_settings = 0; i < argc; i ++)
+ num_settings = cupsParseOptions(argv[i], num_settings, &settings);
+
+ if (_cupsAdminSetServerSettings(http, num_settings, settings))
+ {
+ puts("New server settings:");
+ cupsFreeOptions(num_settings, settings);
+ }
+ else
+ {
+ printf("Server settings not changed: %s\n", cupsLastErrorString());
+ return (1);
+ }
+ }
+ else
+ puts("Current server settings:");
+
+ /*
+ * Get the current configuration...
+ */
+
+ if (_cupsAdminGetServerSettings(http, &num_settings, &settings))
+ {
+ show_settings(num_settings, settings);
+ cupsFreeOptions(num_settings, settings);
+ return (0);
+ }
+ else
+ {
+ printf(" %s\n", cupsLastErrorString());
+ return (1);
+ }
+}
+
+
+/*
+ * 'show_settings()' - Show settings in the array...
+ */
+
+static void
+show_settings(
+ int num_settings, /* I - Number of settings */
+ cups_option_t *settings) /* I - Settings */
+{
+ while (num_settings > 0)
+ {
+ printf(" %s=%s\n", settings->name, settings->value);
+
+ settings ++;
+ num_settings --;
+ }
+}
+
+
+/*
+ * End of "$Id: testadmin.c 5240 2006-03-07 21:55:29Z mike $".
+ */
diff --git a/cups/testhttp.c b/cups/testhttp.c
index 71b8709f9..3fcffc659 100644
--- a/cups/testhttp.c
+++ b/cups/testhttp.c
@@ -1,5 +1,5 @@
/*
- * "$Id: testhttp.c 5023 2006-01-29 14:39:44Z mike $"
+ * "$Id: testhttp.c 5235 2006-03-06 13:02:23Z mike $"
*
* HTTP test program for the Common UNIX Printing System (CUPS).
*
@@ -290,7 +290,7 @@ main(int argc, /* I - Number of command-line arguments */
fputs("httpGetHostname(): ", stdout);
- if (httpGetHostname(hostname, sizeof(hostname)))
+ if (httpGetHostname(NULL, hostname, sizeof(hostname)))
printf("PASS (%s)\n", hostname);
else
{
@@ -515,5 +515,5 @@ main(int argc, /* I - Number of command-line arguments */
/*
- * End of "$Id: testhttp.c 5023 2006-01-29 14:39:44Z mike $".
+ * End of "$Id: testhttp.c 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/cups/util.c b/cups/util.c
index 5a018b66f..aea6055a2 100644
--- a/cups/util.c
+++ b/cups/util.c
@@ -1,5 +1,5 @@
/*
- * "$Id: util.c 5165 2006-02-24 21:20:30Z mike $"
+ * "$Id: util.c 5235 2006-03-06 13:02:23Z mike $"
*
* Printing utilities for the Common UNIX Printing System (CUPS).
*
@@ -839,7 +839,7 @@ cupsGetPPD2(http_t *http, /* I - HTTP connection */
* Remap local hostname to localhost...
*/
- httpGetHostname(localhost, sizeof(localhost));
+ httpGetHostname(NULL, localhost, sizeof(localhost));
if (!strcasecmp(localhost, hostname))
strcpy(hostname, "localhost");
@@ -1641,5 +1641,5 @@ cups_get_printer_uri(
/*
- * End of "$Id: util.c 5165 2006-02-24 21:20:30Z mike $".
+ * End of "$Id: util.c 5235 2006-03-06 13:02:23Z mike $".
*/
diff --git a/data/Makefile b/data/Makefile
index 88c344f25..6910a1143 100644
--- a/data/Makefile
+++ b/data/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5085 2006-02-06 13:27:53Z mike $"
+# "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $"
#
# Datafile makefile for the Common UNIX Printing System (CUPS).
#
@@ -133,6 +133,13 @@ all:
clean:
+#
+# Dummy depend...
+#
+
+depend:
+
+
#
# Install files...
#
@@ -158,5 +165,30 @@ install: all
#
-# End of "$Id: Makefile 5085 2006-02-06 13:27:53Z mike $".
+# Uninstall files...
+#
+
+uninstall:
+ for file in $(BANNERS); do \
+ $(RM) $(DATADIR)/banners/$$file; \
+ done
+ for file in $(CHARMAPS); do \
+ $(RM) $(DATADIR)/charmaps/$$file; \
+ done
+ for file in $(CHARSETS); do \
+ $(RM) $(DATADIR)/charsets/$$file; \
+ done
+ for file in $(DATAFILES); do \
+ $(RM) $(DATADIR)/data/$$file; \
+ done
+ -$(RMDIR) $(DATADIR)/profiles
+ -$(RMDIR) $(DATADIR)/data
+ -$(RMDIR) $(DATADIR)/charsets
+ -$(RMDIR) $(DATADIR)/charmaps
+ -$(RMDIR) $(DATADIR)/banners
+ -$(RMDIR) $(DATADIR)
+
+
+#
+# End of "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $".
#
diff --git a/doc/Makefile b/doc/Makefile
index ddfe235a3..de9b54782 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -1,5 +1,5 @@
#
-# "$Id: Makefile 5224 2006-03-04 02:00:43Z mike $"
+# "$Id: Makefile 5229 2006-03-05 16:48:12Z mike $"
#
# Documentation makefile for the Common UNIX Printing System (CUPS).
#
@@ -40,7 +40,6 @@ WEBBUTTONS = \
images/button-add-class.gif \
images/button-add-printer.gif \
images/button-add-this-printer.gif \
- images/button-cancel.gif \
images/button-cancel-all-jobs.gif \
images/button-cancel-job.gif \
images/button-change-settings.gif \
@@ -188,6 +187,13 @@ all:
clean:
+#
+# Dummy depend target...
+#
+
+depend:
+
+
#
# Install all documentation files...
#
@@ -209,13 +215,40 @@ install: all
$(INSTALL_DIR) -m 755 $(DOCDIR)/$$lang/images; \
if test -f $$lang/index.html; then \
$(INSTALL_MAN) $$lang/index.html $(DOCDIR)/$$lang; \
- fi \
+ fi; \
for file in $(WEBBUTTONS); do \
if test -f $$lang/$$file; then \
$(INSTALL_MAN) $$lang/$$file $(DOCDIR)/$$lang/images; \
- fi \
+ fi; \
+ done \
+ done
+
+
+#
+# Unnstall all documentation files...
+#
+
+uninstall:
+ for file in $(WEBPAGES); do \
+ $(RM) $(DOCDIR)/$$file; \
+ done
+ for file in $(HELPFILES); do \
+ $(INSTALL_MAN) $(DOCDIR)/help/$$file; \
+ done
+ for file in $(WEBIMAGES) $(WEBBUTTONS); do \
+ $(INSTALL_MAN) $(DOCDIR)/images/$$file; \
+ done
+ -for lang in $(LANGUAGES); do \
+ $(RM) $(DOCDIR)/$$lang/index.html; \
+ for file in $(WEBBUTTONS); do \
+ $(RM) $(DOCDIR)/$$lang/images/$$file; \
done \
+ $(RMDIR) $(DOCDIR)/$$lang/images; \
+ $(RMDIR) $(DOCDIR)/$$lang; \
done
+ -$(RMDIR) $(DOCDIR)/images
+ -$(RMDIR) $(DOCDIR)/help
+ -$(RMDIR) $(DOCDIR)
#
diff --git a/doc/cups-printable.css b/doc/cups-printable.css
index 5019a4aaf..a6544b8d1 100644
--- a/doc/cups-printable.css
+++ b/doc/cups-printable.css
@@ -115,6 +115,10 @@ DD {
margin-left: 54pt;
}
+DL.category DT {
+ font-weight: bold;
+}
+
P.summary {
margin-left: 54pt;
font-family: monospace;
diff --git a/doc/cups.css b/doc/cups.css
index 298e66f39..53f5b8daa 100644
--- a/doc/cups.css
+++ b/doc/cups.css
@@ -227,6 +227,10 @@ DD {
margin-left: 54pt;
}
+DL.category DT {
+ font-weight: bold;
+}
+
P.summary {
margin-left: 54pt;
font-family: monospace;
diff --git a/doc/help/cgi.html b/doc/help/cgi.html
new file mode 100644
index 000000000..efb8efa0e
--- /dev/null
+++ b/doc/help/cgi.html
@@ -0,0 +1,91 @@
+
+
+
+ Using CGI Programs
+
+
+
+CUPS has traditionally provided a dynamic web interface
+through dedicated CGI programs that are executed when users open
+special directories on the CUPS server. Each CGI performs
+administration, class, help, job, and printer functions as
+directed by the user, but the actual programs that are run and
+functions that are available are limited to those that were
+originally designed into the scheduler.
+
+Support is now available for CGI programs and specific
+scripting languages, currently Java, Perl, PHP, and Python. The
+interpreters for these languages are currently configured at
+compile time. Future versions may expand the interface to allow
+for generic support of scripting languages similar to the Apache
+"AddHandler" directive, but with external programs instead of
+modules.
+
+Table 1 shows the MIME media types that are reserved for the
+CGI support in CUPS. The names have been chosen to mirror those
+used by Apache:
+
+
+Table 1: CGI MIME Media Types
+
+ MIME Media Type |
+ Description |
+
+
+ application/x-httpd-cgi |
+ CGI script/program |
+
+
+ application/x-httpd-java |
+ Java program |
+
+
+ application/x-httpd-perl |
+ Perl script |
+
+
+ application/x-httpd-php |
+ PHP script |
+
+
+ application/x-httpd-python |
+ Python script |
+
+
+
+
+
+In order to enable the corresponding type, you must create a
+new /etc/cups/cgi.types file which maps the filename
+extensions to the appropriate MIME type, for example:
+
+
+application/x-httpd-cgi cgi
+application/x-httpd-java class
+application/x-httpd-perl pl
+application/x-httpd-php php
+application/x-httpd-python py
+
+
+CGI scripts/programs (application/x-httpd-cgi) also must have
+execution permissions to be treated as a CGI script or
+program.
+
+
+
+CUPS implements most of the CGI/1.1 specification, with the
+following exceptions:
+
+
+
+ - No PATH_INFO or PATH_TRANSLATED support
+
+ - Limited HTTP field support; only the Content-Length
+ (CONTENT_LENGTH), Cookie (HTTP_COOKIE), and User-Agent
+ (HTTP_USER_AGENT) fields are placed in environment
+ variables at this time
+
+
+
+
+
diff --git a/doc/help/ref-cupsd-conf.html b/doc/help/ref-cupsd-conf.html
index ee69c1c05..2788879f7 100644
--- a/doc/help/ref-cupsd-conf.html
+++ b/doc/help/ref-cupsd-conf.html
@@ -14,6 +14,7 @@ BrowseLDAPServer
BrowseLocalProtocols
BrowseRemoteProtocols
DefaultAuthType
+DefaultEncryption
DefaultPolicy
FilterNice
JobRetryInterval
diff --git a/doc/help/whatsnew.html b/doc/help/whatsnew.html
index 864ec23ff..7b5f0e59f 100644
--- a/doc/help/whatsnew.html
+++ b/doc/help/whatsnew.html
@@ -5,184 +5,520 @@
-This document describes the new features in CUPS 1.2. If you
+
CUPS 1.2 adds over 90 changes and new features to CUPS 1.1.x.
+This page provides a high-level outline of these changes. If you
have never used CUPS before, read the "Overview of CUPS" document instead.
-CUPS 1.2 adds many new features to CUPS 1.1.x:
+HREF="overview.html">"Overview of CUPS" document instead.
-
+
- - Networking
+
-
- Printer Browsing
+ - Networking
+
- - Web Interface
+ - IPv6; CUPS now supports IPv6
+ connectivity when the host operating system
+ provides it
- - IPP Support
+ - Domain Sockets; CUPS now supports
+ the much faster UNIX domain sockets for local
+ printing
- - Scheduler
+ - Auto-SSL; CUPS now automatically
+ detects when a client is connecting with SSL
+ encryption, so it can support both unencrypted,
+ SSL-encrypted, and TLS-encrypted connections over
+ a single port
+
+
- - Localization and Internationalization
- - Printer Drivers
+ - Browsing
+
+
+ - LDAP Support; CUPS now supports
+ printer sharing via the Lightweight Directory
+ Access Protocol, version 3
+
+ - Printer Lease Times; The server's
+ BrowseTimeout value is now included
+
+ - Network Default Options; The server
+ now advertises a printer's default options such
+ as job-sheets, media, and so forth
+
+ - Network Default Printer; CUPS now
+ advertises server-default printers so that
+ clients can choose the correct default network
+ printer
+
+ - "Delete Printer" Message; CUPS now
+ sends a final "delete printer" message to all
+ clients when a printer is deleted, allowing for
+ extremely long BrowseTimeout values without
+ side-effects
- - CUPS API
+ - BrowseLocalOptions and
+ BrowseRemoteOptions Support; You can
+ configure CUPS to use specific IPP options for
+ local and remote printers, for example to
+ compress print jobs that are sent over a slow WAN
+ link
- - CUPS Imaging API
+ - BrowseLocalProtocols and
+ BrowseRemoteProtocols Support; You can
+ configure CUPS to use different protocols for
+ advertising local shared printers and discovering
+ remote shared printers
-
+
-
+ Web Interface
+
-<--
-1. Networking
- a. IPv6
- i. Next-generation Internet support
- ii. ????
- b. Domain sockets
- i. Enhanced performance under load for local clients.
- ii. Authentication without passwords on platforms that support it.
--->
+ - Improved Look and Feel; The web
+ interface has improved readability and a more
+ consistent design
-CUPS 1.2 adds support for IPv6 and domain sockets. The IPv6
-support allows CUPS to work with the next-generation Internet as
-well as taking advantage of automatic local network
-configuration. Domain sockets provide 5 to 10 times faster
-printing from the desktop.
+ - New Searchable On-Line Help; The
+ on-line help has been reorganized into
+ categorized articles and references and can be
+ searched
+ - Add This Printer; The administration
+ page offers a new Add This Printer
+ button for automatically-discovered printers,
+ making printer configuration even easier than
+ before
-
+ - Export Printers to Samba; The
+ administration page now offers an Export
+ Printers to Samba button and function which
+ allows administrators to export printer drivers
+ to Windows clients via Samba
-<--
-2. Printer Browsing
- a. CUPS browsing updates
- i. "Delete" bit for printers
- ii. "lease-time" for printers so that clients and servers don't need
- the same browse timeout/interval settings
- iii. Additional attributes/default options for network-wide defaults
- iv. Network default printer
- v. Ability to control send and receive protocols independently
- b. Rendevous support
- c. LDAP support
- d. Per-printer sharing
--->
+ - Change Settings; The administration
+ page offers a new simple server settings form for
+ controlling common configuration settings such as
+ printer sharing and remote administration
+
+ - Edit Configuration File; The
+ administration page now provides a form for
+ editing the cupsd.conf file from your
+ web browser
+
+ - View Log Files; The administration
+ page now provides access to the
+ access_log, error_log, and
+ page_log log files
+
+ - Searchable Classes, Jobs, and
+ Printers; the class, job, and printer pages
+ can now be searched and shown in ascending or
+ descending order, with the results displayed in
+ groups of 10
+
+ - Links for Class Members; When
+ viewing a printer class, we now provide
+ hyperlinks to each of the class members -
+ previously only the names were shown
+
+ - Print Self-Test Page; When the
+ printer driver supports the CUPS command file
+ format, you can now print the printer's self-test
+ page
+
+ - Clean Print Heads; When the printer
+ driver supports the CUPS command file format, you
+ can now clean the printer's heads
+
+ - Set Default Options; You can now set
+ the default options for a printer, including the
+ new operation and error policies (the previous
+ incarnation of this was confusingly called
+ "Configure Printer")
+
+ - Set Default Printer; You can now
+ make a printer the default printer on the
+ network
+
+ - Set Allowed Users; You can now set
+ the list of users and/or groups that are allowed
+ or not allowed to access a printer or class
+
+ - Cancel All Jobs; You can now cancel
+ all jobs on a printer or class
+
+ - Move Job; You can now move an active
+ job to a different printer or class
+
+ - Move All Jobs; You can now move all
+ active jobs to a different printer or class
+
+ - Per-Printer Sharing; You can now
+ share (Publish) or hide (Unpublish) printers
+ individually
+
+ - Show All Jobs; You can now view all
+ jobs in addition to just the active or completed
+ jobs
+
+
+
+
+ IPP Support
+
+
+ - IPP Notifications; CUPS now supports
+ the complete IPP notification specification to
+ provide asynchronous event notification to
+ clients and users
+
+ - ippget Notification Scheme; CUPS now
+ supports the required
ippget
pull
+ method for event notification, allowing
+ applications to receive events asychronously
+
+ - mailto Notification Scheme; CUPS now
+ supports
mailto
recipients as
+ proposed by the Printer Working Group, allowing
+ users to receive event notifications via
+ email
+
+ - CUPS Extensions to IPP
+ Notifications; CUPS adds several server
+ events (start, stop, restart, and audit) that can
+ be monitored via the IPP notification
+ operations
+
+ - CUPS-Get-Printers Improvements; The
+ CUPS-Get-Printers operation now returns all
+ queues by default and filters the results based
+ on the
requesting-user-name
+ attribute
+
+ - Proxy Authentication; CUPS provides
+ the new CUPS-Authenticate-Job operation to
+ support proxy authentication of print jobs
+
+ - Unique Job IDs; CUPS maintains a new
+
job-uuid
attribute which provides a
+ unique identifier that can be used to track a job
+ on your network or anywhere in the world
+
+ - port-monitor; CUPS now supports the
+ per-printer
port-monitor
and
+ port-monitor-supported
attributes
+ for device-specific data/transport encoding
+
+ - printer-op-policy; CUPS supports new
+
printer-op-policy
and
+ printer-op-policy-supported
+ attributes which provide per-printer fine-grained
+ access control policies
+
+ - printer-error-policy; CUPS supports
+ new
printer-error-policy
and
+ printer-error-policy-supported
+ attributes which provide per-printer control over
+ job error handling
+
+ - printer-is-shared; CUPS supports a
+ new
printer-is-shared
attribute
+ which provides per-printer sharing
+
+ - printer-state-change-time; CUPS now
+ tracks the last time and date of a change to the
+ printer configuration, enabled/disabled state, or
+ accepting/rejecting state
+
+ - printer-uri-supported; CUPS now
+ reports the IP address or hostname used by the
+ client in the
printer-uri-supported
+ attribute - this prevents hostname resolution
+ issues on complex networks
+
+ - requested-attributes; CUPS now fully
+ supports limiting of attributes by name or group
+ - previously CUPS would only limit common
+ attributes and did not support attribute group
+ names
+
+ - Default Job Template Attributes;
+ CUPS now supports arbitrary default job template
+ attributes and applies them to print jobs as
+ needed
+
+ - which-jobs; The Get-Jobs operation
+ now supports a
which-jobs
value of
+ "all" to return all jobs regardless of state
+
+ - document-format-supported; The
+
document-format-supported
attribute
+ now reflects the formats that are actually
+ supported by the printer
+
+ - printer-type; The
+
printer-type
attribute now provides
+ bits for "not shared", "authenticated", and
+ "supports commands"
+
+
+
+
+ Scheduler
+
+
+ - Remote Printer Caching; The scheduler
+ now maintains a remote printer cache so that
+ remote printers are not lost when the scheduler
+ or system is restarted
+
+ - Job Caching; The scheduler now
+ maintains a job cache so that completed jobs do
+ not need to be loaded into memory all of the time
+ - jobs are loaded and unloaded automatically for
+ optimum performance and memory usage
+
+ - Other Performance Improvements;
+ Thanks to new CUPS API interfaces, the schedule
+ now uses less memory, less CPU, and scales to
+ even larger installations
+
+ - Improved Logging; CUPS now logs the
+ IPP operation and status in in the
+ access_log file
+
+ - Policies; CUPS now provides
+ per-printer and server access control policies
+ based on IPP operations in addition to the
+ traditional location-based access control
+ available in previous releases
+
+ - DefaultAuthType; In conjunction with
+ the new policy support, CUPS now supports a
+ default authentication type that is used for IPP
+ operations requiring a username
+
+ - DefaultEncryption; When
+ authenticating a request, CUPS now uses the
+
DefaultEncryption
setting in
+ addition to any location or policy encryption
+ setting in effect
+
+ - Per-Printer
+ document-format-supported; CUPS now
+ maintains per-printer
+
document-format-supported
attributes
+ that reflect the formats that can be printed by a
+ particular printer
+
+ - Server-side Default Options; CUPS
+ now supports server-side default options for each
+ printer or class that are applied to new
+ jobs
+
+ - POSIX ACL Support; CUPS now uses
+ POSIX ACLs, when available, to allows multiple
+ system groups to be used for local certificate
+ authentication
-CUPS 1.2 adds support for Bonjour/mDNS and LDAP-based printer
-sharing. Printers can be shared or "published" individually,
-allowing a server to only share specific printers, and you can
-set which protocols to use for local and remote printers.
-Previously CUPS would share all or none of its printers and use
-the same protocols for local and remote printers.
+ - RunAsUser Removed; The insecure
+ RunAsUser mode has been removed in favor of OS
+ mechanisms such as SELinux
-CUPS Browse Protocol
+ - Launchd Support; The schedule now
+ supports running via the MacOS X launchd program,
+ delaying cupsd startup until needed
+
+ - Dynamic Device Lookup; The scheduler
+ now queries the backends for devices as
+ needed - no more restarting to get new devices!
+
+ - Dynamic PPD/Printer Driver Lookup;
+ The scheduler now scans for PPD files and/or
+ printer drivers as needed - no more restarting
+ after installing drivers, and PPD files can be
+ generated dynamically!
-The CUPS browse protocol has also been upgraded. New type
-bits, authenticated, default, and deleted, provide key
-information to clients. The "authenticated" type bit tells
-clients that the print queue requires authentication when
-printing. The "default" type bit tells clients that the print
-queue should be used as the default unless the user sets a
-different one. The "deleted" type bit is set when a printer is
-deleted from the server - this allows the client to remove its
-copy of a printer immediately rather than waiting for it to
-timeout.
+ - Port Monitor Support; CUPS now
+ supports "port monitor" filters between the
+ printer driver filters and backend to do printer-
+ and device-specific encoding and transport
+ functions.
-Previously, a change to the BrowseTimeout setting on the
-server had to be mirrored to each client. Browse packets now
-include printer lease time information which allows the server to
-use a different timeout setting than its clients, making
-configuration simpler and more reliable.
+ - Multi-File Job Improvements; CUPS
+ now sends multi-file jobs in a single connection
+ to the printer or remote server, preserving the
+ order of jobs
-Browse packets can also now contain connection options to be
-used when printing to the server. This allows the administrator
-to require encryption or compress print jobs for certain
-printers. This is most often used when printing over
-limited-bandwidth WAN connections.
+ - Environment Variable Support; The
+ scheduler now supports setting environment
+ variables for filters and CGI programs via the
+ Apache
PassEnv
and
+ SetEnv
directives
+ - Improved CGI Support; The scheduler
+ now supports more of the CGI/1.1
+ specification
-
+ - Log Files; Log files are now
+ accessible via HTTP requests using the
+ /conf/log/filename resource
-
+ - Power Management; The scheduler now
+ responds to power management events from the
+ operating system (currently MacOS X only)
-The web interface features an all-new administration interface
-which provides ...
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ LPD Client Support
+
+
+ - Performance Improvements; CUPS no
+ longer loads every available printer before
+ accepting a print job
+
+ - Banner Support; Banner pages can now
+ be requested by an LPD client, with server-side
+ overrides as desired
+
+ - Multi-File Support; CUPS now creates
+ a single IPP job for multi-file LPD jobs
+
+
+
+
+ Localization and Internationalization
+
+
+ - Command-Line Programs; All
+ command-line programs are now fully
+ localized
+
+ - Character Set Support; CUPS now
+ supports a wider range of character sets
+ including Big5 and Shift-JIS
+
+ - Globalized PPD Support; PPD files
+ can now contain multiple language
+ localizations
+
+
+
+
+ Printer Drivers
+
+
+ - New Drivers; CUPS 1.2 adds Zebra
+ CPCL and EPL label printer drivers
+
+ - Driver Interfaces; CUPS now supports
+ driver interfaces which allow a driver to
+ advertise the printers it supports and
+ automatically generate the PPD file as
+ needed
+
+ - High-Definition Range Color; CUPS
+ 1.2 adds 16-bit per channel color support
+
+ - Raster Compression; The CUPS raster
+ format has been updated to use data
+ compression for faster printing
+
+ - Extended Printer Attributes; The
+ CUPS raster format has been extended to support
+ additional per-page printer-specific
+ attributes
+
+ - Back-Channel Data Support; Printer
+ drivers can now read data back from the printer
+ device
+
+ - Custom PPD Options; PPD files can
+ now contain options that accept custom
+ values
+
+
+
+
+ CUPS API
+
+
+ - Thread Safety; All of the CUPS API
+ is now thread-safe on systems that support POSIX
+ threads
+
+ - Performance Improvements; Many of
+ the existing APIs have been optimized for
+ speed
+
+ - Array API; The new array API
+ provides a generic array container and is used to
+ implement many of the new CUPS 1.2 features and
+ performance improvements
+
+ - Directory API; The new directory API
+ allows applications to portably list the contents
+ of a directory
+
+ - File API; The new file API supports
+ optionally-compressed file IO and simple socket
+ communications without the limitations of
+ stdio
+
+ - HTTP API; The HTTP API now provides
+ many new URI and address handling functions,
+ accessor functions to key
http_t
+ information, write-buffering functions, and large
+ file APIs
+
+ - IPP API; The IPP API now provides
+ functions to encode arbitrary options, add
+
octetString
attributes, create
+ common IPP requests, convert IPP status and
+ operation code values to/from strings, and read
+ and write IPP messages via callbacks.
+
+ - PPD API; The PPD API has been
+ updated with new functions to support reading
+ from CUPS files, localization of globalized PPD
+ files, emission of arbitrary ranges of options,
+ custom option support, enhanced JCL support, and
+ access to all options in the PPD file
+
+ - Error Handling; The CUPS API now
+ provides a convenience function to get the full
+ error message of the last request
+
+ - Back-Channel API; The new
+ back-channel API provides backends and filters
+ with access to information sent back from a
+ printer
+
+
+
+
+ CUPS Imaging API
+
+
+ - Image API; The new image API
+ provides access to image files of arbitrary size
+ and is based on the CUPS 1.1.x private image
+ filter APIs
+
+ - Raster API; The raster API provides
+ new functions to read and write the version 2
+ raster page headers, and a new function to
+ generate a page header from marked PPD
+ options
+
+
+
+