]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
MacOS X fixes and files.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 30 Oct 2001 20:37:16 +0000 (20:37 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Tue, 30 Oct 2001 20:37:16 +0000 (20:37 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@1930 7a7537e8-13f0-0310-91df-b6672ffda945

16 files changed:
CHANGES.txt
Makefile
backend/lpd.c
backend/socket.c
config-scripts/cups-directories.m4
cups.plist [new file with mode: 0644]
cups.sh.in
cups.strings [new file with mode: 0644]
cups/Makefile
cups/http.c
cups/http.h
cups/util.c
scheduler/client.c
scheduler/conf.c
scheduler/listen.c
scheduler/main.c

index 3055858da856b8cb7582863a8bd35cba1a1429c4..14ee186bc7e17951633f56c1ed575061e551f905 100644 (file)
@@ -9,6 +9,7 @@ CHANGES IN CUPS V1.1.11
          files.
        - Added new "cupsaddsmb" utility for exporting
          CUPS printer drivers to SAMBA/Windows clients.
+       - Added preliminary support for Darwin/MacOS X.
        - The CUPS-Add-Printer operation no longer allows
          arbitrary scheme names in device URIs to be used - it
          now restricts the available schemes to those found in
@@ -68,8 +69,6 @@ CHANGES IN CUPS V1.1.11
          using the subdirectory approach, e.g. the "es"
          subdirectory under /usr/share/cups/banners is used for
          the Spanish banner files.
-       - Added support for Darwin/MacOS X builds (compiles
-         but does not work 100%).
        - Updated the scheduler so it knows the correct
          language abbreviation to use for all supported
          PPD LanguageVersion values.  The new code also
@@ -93,6 +92,18 @@ CHANGES IN CUPS V1.1.11
        - *BSD static library creation fixes.
        - Use mkstemps() instead of tmpnam() in pdftops whenever
          possible.
+       - Added httpGetHostByName() function as a wrapper around
+         gethostbyname() - some implementations of this
+         function do not support IP addresses (e.g. MacOS X.)
+       - Added casts to all printf's of file lengths, since
+         there is currently no standard way of formatting long
+         long values.
+       - The client filename field was not cleared in all
+         instances, resulting in old form data being submitted
+         to CGIs.
+       - The httpConnect*() functions now try all available
+         addresses for a host when connecting for the first
+         time.
 
 
 CHANGES IN CUPS V1.1.10-1
index 443af9da5e27535061a93040d81faaa104488ea9..dc7a3f7596df0ca1fd2187df43c0f8785f4e29ba 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-# "$Id: Makefile,v 1.37 2001/10/26 03:16:46 mike Exp $"
+# "$Id: Makefile,v 1.38 2001/10/30 20:37:13 mike Exp $"
 #
 #   Top-level Makefile for the Common UNIX Printing System (CUPS).
 #
@@ -92,9 +92,13 @@ install:
        fi
        if test "x$(INITDIR)" = "x" -a "x$(INITDDIR)" != "x"; then \
                $(INSTALL_DIR) $(BUILDROOT)$(INITDDIR); \
-               $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
-               if test "$(INITDDIR)" = "/System/Library/StartupItems/cups"; then \
-                       $(INSTALL_DATA) cups.plist $(BUILDROOT)$(INITDDIR)/cups.plist; \
+               if test "$(INITDDIR)" = "/System/Library/StartupItems/CUPS"; then \
+                       $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR)/CUPS; \
+                       $(INSTALL_DATA) cups.plist $(BUILDROOT)$(INITDDIR)/StartupParameters.plist; \
+                       $(INSTALL_DIR) $(BUILDROOT)$(INITDDIR)/Resources/English.lproj; \
+                       $(INSTALL_DATA) cups.strings $(BUILDROOT)$(INITDDIR)/Resources/English.lproj/Localizable.strings; \
+               else \
+                       $(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR)/cups; \
                fi \
        fi
 
@@ -139,5 +143,5 @@ tardist:
        epm $(EPMFLAGS) -f tardist cups
 
 #
-# End of "$Id: Makefile,v 1.37 2001/10/26 03:16:46 mike Exp $".
+# End of "$Id: Makefile,v 1.38 2001/10/30 20:37:13 mike Exp $".
 #
index 7aa6e66b5ef546abdf4a1bb2174cef828e3462a4..abcc74d514bb0f0d7a2128ab13a9fb84031e366f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: lpd.c,v 1.29 2001/06/06 16:47:52 mike Exp $"
+ * "$Id: lpd.c,v 1.30 2001/10/30 20:37:13 mike Exp $"
  *
  *   Line Printer Daemon backend for the Common UNIX Printing System (CUPS).
  *
@@ -399,7 +399,7 @@ lpd_queue(char *hostname,   /* I - Host to connect to */
   * First try to reserve a port for this connection...
   */
 
-  if ((hostaddr = gethostbyname(hostname)) == NULL)
+  if ((hostaddr = httpGetHostByName(hostname)) == NULL)
   {
     fprintf(stderr, "ERROR: Unable to locate printer \'%s\' - %s",
             hostname, strerror(errno));
@@ -674,5 +674,5 @@ lpd_write(int  lpd_fd,              /* I - LPD socket */
 
 
 /*
- * End of "$Id: lpd.c,v 1.29 2001/06/06 16:47:52 mike Exp $".
+ * End of "$Id: lpd.c,v 1.30 2001/10/30 20:37:13 mike Exp $".
  */
index 264329d667156582eec09df1bc873437663c20b6..690b7e935b7f0a4eb73fcc245569e984d3e74f77 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: socket.c,v 1.23 2001/07/30 19:38:25 mike Exp $"
+ * "$Id: socket.c,v 1.24 2001/10/30 20:37:13 mike Exp $"
  *
  *   AppSocket backend for the Common UNIX Printing System (CUPS).
  *
@@ -146,7 +146,7 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
   * Then try to connect to the remote host...
   */
 
-  if ((hostaddr = gethostbyname(hostname)) == NULL)
+  if ((hostaddr = httpGetHostByName(hostname)) == NULL)
   {
     fprintf(stderr, "ERROR: Unable to locate printer \'%s\' - %s\n",
             hostname, strerror(errno));
@@ -343,5 +343,5 @@ main(int  argc,             /* I - Number of command-line arguments (6 or 7) */
 
 
 /*
- * End of "$Id: socket.c,v 1.23 2001/07/30 19:38:25 mike Exp $".
+ * End of "$Id: socket.c,v 1.24 2001/10/30 20:37:13 mike Exp $".
  */
index 00218b6d1efc8535435e7e77272d4a6b512c1832..a560a94d6bd90a6823d541f44691af0b8e1cb1a7 100644 (file)
@@ -1,5 +1,5 @@
 dnl
-dnl "$Id: cups-directories.m4,v 1.3 2001/10/07 12:16:08 mike Exp $"
+dnl "$Id: cups-directories.m4,v 1.4 2001/10/30 20:37:14 mike Exp $"
 dnl
 dnl   Directory stuff for the Common UNIX Printing System (CUPS).
 dnl
@@ -108,7 +108,7 @@ if test x$rcdir = x; then
                Darwin*)
                        # Darwin and MacOS X - this is just strange...
                        INITDIR=""
-                       INITDDIR="/System/Library/StartupItems/cups"
+                       INITDDIR="/System/Library/StartupItems/CUPS"
                        ;;
 
                Linux*)
@@ -171,7 +171,7 @@ fi
 
 dnl See what directory to put server executables...
 case "$uname" in
-       FreeBSD* | NetBSD* | OpenBSD*)
+       FreeBSD* | NetBSD* | OpenBSD* | Darwin*)
                # *BSD
                INSTALL_SYSV=""
                CUPS_SERVERBIN='${exec_prefix}/libexec/cups'
@@ -193,7 +193,7 @@ AC_SUBST(CUPS_REQUESTS)
 
 dnl Set the CUPS_LOCALE directory...
 case "$uname" in
-       Linux* | FreeBSD* | NetBSD* | OpenBSD*)
+       Linux* | FreeBSD* | NetBSD* | OpenBSD* | Darwin*)
                CUPS_LOCALEDIR='${datadir}/locale'
                AC_DEFINE_UNQUOTED(CUPS_LOCALEDIR, "$datadir/locale")
                ;;
@@ -232,5 +232,5 @@ dnl Set the CUPS_FONTPATH directory...
 AC_DEFINE_UNQUOTED(CUPS_FONTPATH, "$fontpath")
 
 dnl
-dnl End of "$Id: cups-directories.m4,v 1.3 2001/10/07 12:16:08 mike Exp $".
+dnl End of "$Id: cups-directories.m4,v 1.4 2001/10/30 20:37:14 mike Exp $".
 dnl
diff --git a/cups.plist b/cups.plist
new file mode 100644 (file)
index 0000000..f7c80c6
--- /dev/null
@@ -0,0 +1,11 @@
+{
+  Description     = "CUPS Printing";
+  Provides        = ("CUPS");
+  Requires        = ("Resolver");
+  OrderPreference = "None";
+  Messages =
+  {
+    start = "Starting CUPS";
+    stop  = "Stopping CUPS";
+  };
+}
index ee5e500bd760e17f353a6d716907f4b68b1fb768..59a1542e1b3f1e359e9d9ead3fbb9a0eb4661c2a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# "$Id: cups.sh.in,v 1.12 2001/05/21 21:32:50 mike Exp $"
+# "$Id: cups.sh.in,v 1.13 2001/10/30 20:37:13 mike Exp $"
 #
 #   Startup/shutdown script for the Common UNIX Printing System (CUPS).
 #
@@ -43,6 +43,7 @@
 
 
 #### OS-Dependent Configuration
+
 case "`uname`" in
        IRIX*)
                IS_ON=/sbin/chkconfig
@@ -52,6 +53,16 @@ case "`uname`" in
                IS_ON=:
                ;;
 
+       Darwin*)
+               . /etc/rc.common
+
+               if test "${CUPS:=-YES-}" = "-NO-"; then
+                       exit 0
+               fi
+
+               IS_ON=:
+               ;;
+
        *)
                IS_ON=/bin/true
                ;;
@@ -65,10 +76,14 @@ esac
 # all but IRIX, which can configure verbose bootup messages.
 #
 
-if $IS_ON verbose; then
-       ECHO=echo
+if "`uname`" = "Darwin"; then
+       ECHO=ConsoleMessage
 else
-       ECHO=:
+       if $IS_ON verbose; then
+               ECHO=echo
+       else
+               ECHO=:
+       fi
 fi
 
 #
@@ -86,7 +101,7 @@ case "`uname`" in
        OSF1*)
                pid=`ps -e | awk '{print $1,$5}' | grep cupsd | awk '{print $1}'`
                ;;
-       Linux* | NetBSD*)
+       Linux* | NetBSD* | Darwin*)
                pid=`ps ax | awk '{print $1,$5}' | grep cupsd | awk '{print $1}'`
                ;;
        *)
@@ -143,5 +158,5 @@ exit 0
 
 
 #
-# End of "$Id: cups.sh.in,v 1.12 2001/05/21 21:32:50 mike Exp $".
+# End of "$Id: cups.sh.in,v 1.13 2001/10/30 20:37:13 mike Exp $".
 #
diff --git a/cups.strings b/cups.strings
new file mode 100644 (file)
index 0000000..0d75354
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+       <key>Starting CUPS</key>
+       <string>Starting CUPS</string>
+</dict>
+</plist>
+
index bbb90fc60503ca7c8447d791f103e9c3882184fc..94390d41bc0bc90814000fe8f81ef639b978a21f 100644 (file)
@@ -1,5 +1,5 @@
 #
-# "$Id: Makefile,v 1.62 2001/10/07 12:16:09 mike Exp $"
+# "$Id: Makefile,v 1.63 2001/10/30 20:37:14 mike Exp $"
 #
 #   Support library Makefile for the Common UNIX Printing System (CUPS).
 #
@@ -131,7 +131,7 @@ libcups_s.a:        $(LIBOBJS) ../Makedefs
 libcups.la:    $(LIBOBJS) ../Makedefs
        echo Linking $@...
        $(DSO) $(DSOFLAGS) -o $@ $(LIBOBJS:.o=.lo) -rpath $(LIBDIR) \
-               -version-info 2:3 $(SSLLIBS)
+               -version-info 2:4 $(SSLLIBS)
 
 
 #
@@ -200,5 +200,5 @@ $(OBJS):    ../Makedefs ../config.h
 
 
 #
-# End of "$Id: Makefile,v 1.62 2001/10/07 12:16:09 mike Exp $".
+# End of "$Id: Makefile,v 1.63 2001/10/30 20:37:14 mike Exp $".
 #
index abd162836bb72eccb1ffca672787dda1e583607f..f1a49a45678be9bad0b4832cfc86eac3ab9ccd6e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.c,v 1.87 2001/09/14 16:52:06 mike Exp $"
+ * "$Id: http.c,v 1.88 2001/10/30 20:37:14 mike Exp $"
  *
  *   HTTP routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -32,6 +32,8 @@
  *   httpConnectEncrypt() - Connect to a HTTP server using encryption.
  *   httpEncryption()     - Set the required encryption on the link.
  *   httpReconnect()      - Reconnect to a HTTP server...
+ *   httpGetHostByName()  - Lookup a hostname or IP address, and return
+ *                          address records for the specified name.
  *   httpSeparate()       - Separate a Universal Resource Identifier into its
  *                          components.
  *   httpGetSubField()    - Get a sub-field value.
@@ -339,6 +341,7 @@ httpConnectEncrypt(const char *host,        /* I - Host to connect to */
                   http_encryption_t encrypt)
                                        /* I - Type of encryption to use */
 {
+  int                  i;              /* Looping var */
   http_t               *http;          /* New HTTP connection */
   struct hostent       *hostaddr;      /* Host address data */
 
@@ -352,7 +355,7 @@ httpConnectEncrypt(const char *host,        /* I - Host to connect to */
   * Lookup the host...
   */
 
-  if ((hostaddr = gethostbyname(host)) == NULL)
+  if ((hostaddr = httpGetHostByName(host)) == NULL)
   {
    /*
     * This hack to make users that don't have a localhost entry in
@@ -361,7 +364,7 @@ httpConnectEncrypt(const char *host,        /* I - Host to connect to */
 
     if (strcasecmp(host, "localhost") != 0)
       return (NULL);
-    else if ((hostaddr = gethostbyname("127.0.0.1")) == NULL)
+    else if ((hostaddr = httpGetHostByName("127.0.0.1")) == NULL)
       return (NULL);
   }
 
@@ -405,16 +408,31 @@ httpConnectEncrypt(const char *host,      /* I - Host to connect to */
   http->encryption = encrypt;
 
  /*
-  * Connect to the remote system...
+  * Loop through the addresses we have until one of them connects...
   */
 
-  if (httpReconnect(http))
+  for (i = 0; hostaddr->h_addr_list[i]; i ++)
   {
-    free(http);
-    return (NULL);
+   /*
+    * Load the address...
+    */
+
+    httpAddrLoad(hostaddr, port, i, &(http->hostaddr));
+
+   /*
+    * Connect to the remote system...
+    */
+
+    if (!httpReconnect(http))
+      return (http);
   }
-  else
-    return (http);
+
+ /*
+  * Could not connect to any known address - bail out!
+  */
+
+  free(http);
+  return (NULL);
 }
 
 
@@ -583,6 +601,69 @@ httpReconnect(http_t *http)        /* I - HTTP data */
 }
 
 
+/*
+ * 'httpGetHostByName()' - Lookup a hostname or IP address, and return
+ *                         address records for the specified name.
+ */
+
+struct hostent *                       /* O - Host entry */
+httpGetHostByName(const char *name)    /* I - Hostname or IP address */
+{
+  unsigned             ip[4];          /* IP address components */
+  static unsigned      packed_ip;      /* Packed IPv4 address */
+  static char          *packed_ptr[2]; /* Pointer to packed address */
+  static struct hostent        host_ip;        /* Host entry for IP address */
+
+
+ /*
+  * This function is needed because some operating systems have a
+  * buggy implementation of httpGetHostByName() that does not support
+  * IP addresses.  If the first character of the name string is a
+  * number, then sscanf() is used to extract the IP components.
+  * We then pack the components into an IPv4 address manually,
+  * since the inet_aton() function is deprecated.  We use the
+  * htonl() macro to get the right byte order for the address.
+  */
+
+  if (isdigit(name[0]))
+  {
+   /*
+    * We have an IP address; break it up and provide the host entry
+    * to the caller.  Currently only supports IPv4 addresses, although
+    * it should be trivial to support IPv6 in CUPS 1.2.
+    */
+
+    if (sscanf(name, "%u.%u.%u.%u", ip, ip + 1, ip + 2, ip + 3) != 4)
+      return (NULL); /* Must have 4 numbers */
+
+    packed_ip = htonl(((((((ip[0] << 8) | ip[1]) << 8) | ip[2]) << 8) | ip[3]));
+
+   /*
+    * Fill in the host entry and return it...
+    */
+
+    host_ip.h_name      = (char *)name;
+    host_ip.h_aliases   = NULL;
+    host_ip.h_addrtype  = AF_INET;
+    host_ip.h_length    = 4;
+    host_ip.h_addr_list = packed_ptr;
+    packed_ptr[0]       = (char *)(&packed_ip);
+    packed_ptr[1]       = NULL;
+
+    return (&host_ip);
+  }
+  else
+  {
+   /*
+    * Use the gethostbyname() function to get the IP address for
+    * the name...
+    */
+
+    return (gethostbyname(name));
+  }
+}
+
+
 /*
  * 'httpSeparate()' - Separate a Universal Resource Identifier into its
  *                    components.
@@ -2115,5 +2196,5 @@ http_upgrade(http_t *http)        /* I - HTTP data */
 
 
 /*
- * End of "$Id: http.c,v 1.87 2001/09/14 16:52:06 mike Exp $".
+ * End of "$Id: http.c,v 1.88 2001/10/30 20:37:14 mike Exp $".
  */
index 4675e940285b1a0e4ad19be3d110336e4307e0df..267327c1a9a0ffff2c53f53c67cf1acea284bde1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: http.h,v 1.34 2001/05/06 00:11:24 mike Exp $"
+ * "$Id: http.h,v 1.35 2001/10/30 20:37:15 mike Exp $"
  *
  *   Hyper-Text Transport Protocol definitions for the Common UNIX Printing
  *   System (CUPS).
@@ -301,6 +301,7 @@ extern char         *httpGets(char *line, int length, http_t *http);
 extern const char      *httpGetDateString(time_t t);
 extern time_t          httpGetDateTime(const char *s);
 #  define              httpGetField(http,field)        (http)->fields[field]
+extern struct hostent  *httpGetHostByName(const char *name);
 extern char            *httpGetSubField(http_t *http, http_field_t field,
                                         const char *name, char *value);
 extern int             httpHead(http_t *http, const char *uri);
@@ -340,5 +341,5 @@ extern char         *httpMD5String(const md5_byte_t *, char [33]);
 #endif /* !_CUPS_HTTP_H_ */
 
 /*
- * End of "$Id: http.h,v 1.34 2001/05/06 00:11:24 mike Exp $".
+ * End of "$Id: http.h,v 1.35 2001/10/30 20:37:15 mike Exp $".
  */
index 031e95572053b6e48d0f1e758c3ed22b2444ed3b..4214aa93d8e5ad05a21ec8bcb359a8dca5028d82 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: util.c,v 1.87 2001/10/29 13:30:08 mike Exp $"
+ * "$Id: util.c,v 1.88 2001/10/30 20:37:15 mike Exp $"
  *
  *   Printing utilities for the Common UNIX Printing System (CUPS).
  *
@@ -244,9 +244,10 @@ cupsDoFileRequest(http_t     *http,        /* I - HTTP connection to server */
     */
 
     if (filename != NULL)
-      sprintf(length, "%u", ippLength(request) + (size_t)fileinfo.st_size);
+      sprintf(length, "%lu", (unsigned long)(ippLength(request) +
+                                             (size_t)fileinfo.st_size));
     else
-      sprintf(length, "%u", ippLength(request));
+      sprintf(length, "%lu", (unsigned long)ippLength(request));
 
     httpClearFields(http);
     httpSetField(http, HTTP_FIELD_CONTENT_LENGTH, length);
@@ -1736,5 +1737,5 @@ cups_local_auth(http_t *http)     /* I - Connection */
 
 
 /*
- * End of "$Id: util.c,v 1.87 2001/10/29 13:30:08 mike Exp $".
+ * End of "$Id: util.c,v 1.88 2001/10/30 20:37:15 mike Exp $".
  */
index 337e5d254f034aecb809e979728202ae658a9315..a4933d6a31a52e1d5b0796bf71c64fae1ba8a255 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: client.c,v 1.104 2001/10/29 13:30:08 mike Exp $"
+ * "$Id: client.c,v 1.105 2001/10/30 20:37:15 mike Exp $"
  *
  *   Client routines for the Common UNIX Printing System (CUPS) scheduler.
  *
@@ -173,7 +173,7 @@ AcceptClient(listener_t *lis)       /* I - Listener socket */
     * Do double lookups as needed...
     */
 
-    if ((host = gethostbyname(con->http.hostname)) != NULL)
+    if ((host = httpGetHostByName(con->http.hostname)) != NULL)
     {
      /*
       * See if the hostname maps to the IP address...
@@ -1149,8 +1149,8 @@ ReadClient(client_t *con) /* I - Client to read from */
                return (0);
              }
 
-             if (httpPrintf(HTTP(con), "Content-Length: %d\r\n",
-                            filestats.st_size) < 0)
+             if (httpPrintf(HTTP(con), "Content-Length: %lu\r\n",
+                            (unsigned long)filestats.st_size) < 0)
              {
                CloseClient(con);
                return (0);
@@ -1206,6 +1206,7 @@ ReadClient(client_t *con) /* I - Client to read from */
            close(con->file);
            con->file = 0;
            unlink(con->filename);
+           con->filename[0] = '\0';
 
             if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
            {
@@ -1239,6 +1240,7 @@ ReadClient(client_t *con) /* I - Client to read from */
             LogMessage(L_DEBUG2, "ReadClient() %d Removing temp file %s",
                       con->http.fd, con->filename);
            unlink(con->filename);
+           con->filename[0] = '\0';
 
             if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
            {
@@ -1337,6 +1339,7 @@ ReadClient(client_t *con) /* I - Client to read from */
              close(con->file);
              con->file = 0;
              unlink(con->filename);
+             con->filename[0] = '\0';
 
               if (!SendError(con, HTTP_REQUEST_TOO_LARGE))
              {
@@ -1374,6 +1377,7 @@ ReadClient(client_t *con) /* I - Client to read from */
               LogMessage(L_DEBUG2, "ReadClient() %d Removing temp file %s",
                         con->http.fd, con->filename);
              unlink(con->filename);
+             con->filename[0] = '\0';
 
              if (con->request)
              {
@@ -1590,7 +1594,8 @@ SendFile(client_t    *con,
 
   if (httpPrintf(HTTP(con), "Last-Modified: %s\r\n", httpGetDateString(filestats->st_mtime)) < 0)
     return (0);
-  if (httpPrintf(HTTP(con), "Content-Length: %d\r\n", filestats->st_size) < 0)
+  if (httpPrintf(HTTP(con), "Content-Length: %lu\r\n",
+                 (unsigned long)filestats->st_size) < 0)
     return (0);
   if (httpPrintf(HTTP(con), "\r\n") < 0)
     return (0);
@@ -1763,29 +1768,6 @@ WriteClient(client_t *con)               /* I - Client connection */
     }
 
     con->bytes += bytes;
-
-#ifdef __APPLE__ /* Currently just test code... */
-    printf("Wrote %d initial bytes...\n", bytes);
-
-    if (!con->pipe_pid)
-    {
-     /*
-      * Copy rest of file...
-      */
-
-      while ((bytes = read(con->file, buf, HTTP_MAX_BUFFER)) > 0)
-      {
-        con->bytes += bytes;
-        printf("Writing %d more bytes...\n", bytes);
-        if (httpWrite(HTTP(con), buf, bytes) < 0)
-        {
-          CloseClient(con);
-          return (0);
-        }
-      }
-    }
-#endif /* __APPLE__ */
   }
 
   if (bytes <= 0)
@@ -1830,6 +1812,7 @@ WriteClient(client_t *con)                /* I - Client connection */
       LogMessage(L_DEBUG2, "WriteClient: %d Removing temp file %s",
                  con->http.fd, con->filename);
       unlink(con->filename);
+      con->filename[0] = '\0';
     }
 
     if (con->request != NULL)
@@ -2416,7 +2399,7 @@ pipe_command(client_t *con,       /* I - Client connection */
     if (getuid() == 0)
     {
      /*
-      * Running as root, so change to non-priviledged user...
+      * Running as root, so change to non-priviledged user...
       */
 
       if (setgid(Group))
@@ -2439,11 +2422,13 @@ pipe_command(client_t *con,     /* I - Client connection */
     if (infile)
     {
       close(0);
-      dup(infile);
+      if (dup(infile) < 0)
+       exit(errno);
     }
 
     close(1);
-    dup(fds[1]);
+    if (dup(fds[1]) < 0)
+      exit(errno);
 
    /*
     * Close extra file descriptors...
@@ -2463,7 +2448,6 @@ pipe_command(client_t *con,       /* I - Client connection */
     */
 
     execve(command, argv, envp);
-    perror("execve failed");
     exit(errno);
     return (0);
   }
@@ -2499,5 +2483,5 @@ pipe_command(client_t *con,       /* I - Client connection */
 
 
 /*
- * End of "$Id: client.c,v 1.104 2001/10/29 13:30:08 mike Exp $".
+ * End of "$Id: client.c,v 1.105 2001/10/30 20:37:15 mike Exp $".
  */
index e18d84977f453b6d707a02cc197efd03369f4433..32b66cfe32c953d9d3580607fb5127ba49266edf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: conf.c,v 1.91 2001/09/14 16:52:08 mike Exp $"
+ * "$Id: conf.c,v 1.92 2001/10/30 20:37:16 mike Exp $"
  *
  *   Configuration routines for the Common UNIX Printing System (CUPS).
  *
@@ -1761,9 +1761,9 @@ get_address(char               *value,            /* I - Value string */
 
   if (hostname[0] && strcmp(hostname, "*") != 0)
   {
-    if ((host = gethostbyname(hostname)) == NULL)
+    if ((host = httpGetHostByName(hostname)) == NULL)
     {
-      LogMessage(L_ERROR, "gethostbyname(\"%s\") failed - %s!", hostname,
+      LogMessage(L_ERROR, "httpGetHostByName(\"%s\") failed - %s!", hostname,
                  strerror(errno));
       return (0);
     }
@@ -1794,5 +1794,5 @@ get_address(char               *value,            /* I - Value string */
 
 
 /*
- * End of "$Id: conf.c,v 1.91 2001/09/14 16:52:08 mike Exp $".
+ * End of "$Id: conf.c,v 1.92 2001/10/30 20:37:16 mike Exp $".
  */
index 5370ccf491f791f72575a58a2a52fc72dcfda7c5..38e3dd49d35bad10b2e85ba59328b90a5c0ccf06 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: listen.c,v 1.10 2001/06/05 18:28:43 mike Exp $"
+ * "$Id: listen.c,v 1.11 2001/10/30 20:37:16 mike Exp $"
  *
  *   Server listening routines for the Common UNIX Printing System (CUPS)
  *   scheduler.
@@ -116,7 +116,7 @@ StartListening(void)
 
   memset(&ServerAddr, 0, sizeof(ServerAddr));
 
-  if ((host = gethostbyname(ServerName)) != NULL)
+  if ((host = httpGetHostByName(ServerName)) != NULL)
   {
    /*
     * Found the server's address!
@@ -218,5 +218,5 @@ StopListening(void)
 
 
 /*
- * End of "$Id: listen.c,v 1.10 2001/06/05 18:28:43 mike Exp $".
+ * End of "$Id: listen.c,v 1.11 2001/10/30 20:37:16 mike Exp $".
  */
index cb071c48f49ed160cff51c22274b7e033c9a44c8..7ab4735c608468833938fd579c1b860da017259c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: main.c,v 1.61 2001/10/25 16:26:02 mike Exp $"
+ * "$Id: main.c,v 1.62 2001/10/30 20:37:16 mike Exp $"
  *
  *   Scheduler main loop for the Common UNIX Printing System (CUPS).
  *
@@ -382,12 +382,6 @@ main(int  argc,                    /* I - Number of command-line arguments */
       * Process the input buffer...
       */
 
-#ifdef __APPLE__
-      printf("Client %d, fd = %d, input = %d, output = %d\n", con - Clients,
-             con->http.fd, FD_ISSET(con->http.fd, &input),
-             FD_ISSET(con->http.fd, &output));
-#endif /* __APPLE__ */
-
       if (FD_ISSET(con->http.fd, &input) || con->http.used)
         if (!ReadClient(con))
        {
@@ -751,5 +745,5 @@ usage(void)
 
 
 /*
- * End of "$Id: main.c,v 1.61 2001/10/25 16:26:02 mike Exp $".
+ * End of "$Id: main.c,v 1.62 2001/10/30 20:37:16 mike Exp $".
  */