summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Kasik <mkasik@redhat.com>2010-03-17 10:14:24 +0100
committerMarek Kasik <mkasik@redhat.com>2010-03-17 10:14:24 +0100
commit59e5e2dd5b8945c22b332eb82fab2a1f4b5692e2 (patch)
treedbff32ef8643c4d669e288c16479d946b38c8277
parent14c9a3a596040048e0d869e830253322f4b1f11f (diff)
downloadgtk+-59e5e2dd5b8945c22b332eb82fab2a1f4b5692e2.tar.gz
Define httpGetHostname() for CUPS 1.1 and lower
Function httpGetHostname() is in CUPS since version 1.2, that is why we need its equivalent for lower versions of CUPS (#610176).
-rw-r--r--modules/printbackends/cups/gtkprintbackendcups.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index f98364aca9..8cb2e1a1f4 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -663,6 +663,40 @@ is_address_local (const gchar *address)
return FALSE;
}
+#ifndef HAVE_CUPS_API_1_2
+/* Included from CUPS library because of backward compatibility */
+const char *
+httpGetHostname(http_t *http,
+ char *s,
+ int slen)
+{
+ struct hostent *host;
+
+ if (!s || slen <= 1)
+ return (NULL);
+
+ if (http)
+ {
+ if (http->hostname[0] == '/')
+ g_strlcpy (s, "localhost", slen);
+ else
+ g_strlcpy (s, http->hostname, slen);
+ }
+ else
+ {
+ if (gethostname (s, slen) < 0)
+ g_strlcpy (s, "localhost", slen);
+
+ if (!strchr (s, '.'))
+ {
+ if ((host = gethostbyname (s)) != NULL && host->h_name)
+ g_strlcpy (s, host->h_name, slen);
+ }
+ }
+ return (s);
+}
+#endif
+
static void
gtk_print_backend_cups_set_password (GtkPrintBackend *backend,
gchar **auth_info_required,