]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/http-addr.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / http-addr.c
index ec0f7b269035a022405488fa62551bd26eeabc7a..665829867c8b02aea15285d6910414ff71f485ba 100644 (file)
@@ -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 $".
  */