CUPS_API_MINOR=`echo $ECHO_N $CUPS_API_VERSION | awk -F. '{print $2}'`
if test $CUPS_API_MAJOR -gt 1 -o \
- $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 2; then
- AC_DEFINE(HAVE_CUPS_API_1_2, 1,
- [Define to 1 if CUPS 1.2 API is available])
+ $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -lt 2; then
+ AC_MSG_ERROR([CUPS >= 1.2 not found])
fi
AC_SUBST(CUPS_API_MAJOR)
}
-#if HAVE_CUPS_API_1_2
if (httpWrite2 (request->http, buffer, bytes) < bytes)
-#else
- if (httpWrite (request->http, buffer, (int) bytes) < bytes)
-#endif /* HAVE_CUPS_API_1_2 */
{
int http_errno;
request->poll_state = GTK_CUPS_HTTP_READ;
-#if HAVE_CUPS_API_1_2
bytes = httpRead2 (request->http, buffer, sizeof (buffer));
-#else
- bytes = httpRead (request->http, buffer, sizeof (buffer));
-#endif /* HAVE_CUPS_API_1_2 */
request->bytes_received += bytes;
GTK_NOTE (PRINTING,
}
/* Stop if we do not expect any more data or EOF was received. */
-#if HAVE_CUPS_API_1_2
if (httpGetLength2 (request->http) <= request->bytes_received || bytes == 0)
-#else
- if (httpGetLength (request->http) <= request->bytes_received || bytes == 0)
-#endif /* HAVE_CUPS_API_1_2 */
{
request->state = GTK_CUPS_GET_DONE;
request->poll_state = GTK_CUPS_HTTP_IDLE;
gtk_cups_connection_test_new (const char *server)
{
GtkCupsConnectionTest *result = NULL;
-#ifdef HAVE_CUPS_API_1_2
gchar *port_str = NULL;
result = g_new (GtkCupsConnectionTest, 1);
result->at_init = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
result->at_init = gtk_cups_connection_test_get_state (result);
-#else
- result = g_new (GtkCupsConnectionTest, 1);
-#endif
return result;
}
GtkCupsConnectionState
gtk_cups_connection_test_get_state (GtkCupsConnectionTest *test)
{
-#ifdef HAVE_CUPS_API_1_2
GtkCupsConnectionState result = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
http_addrlist_t *iter;
gint error_code;
return result;
}
-#else
- return GTK_CUPS_CONNECTION_AVAILABLE;
-#endif
}
/* This function frees memory used by the GtkCupsConnectionTest structure.
if (test == NULL)
return;
-#ifdef HAVE_CUPS_API_1_2
test->current_addr = NULL;
test->last_wrong_addr = NULL;
httpAddrFreeList (test->addrlist);
close (test->socket);
test->socket = -1;
}
-#endif
g_free (test);
}
struct _GtkCupsConnectionTest
{
-#ifdef HAVE_CUPS_API_1_2
GtkCupsConnectionState at_init;
http_addrlist_t *addrlist;
http_addrlist_t *current_addr;
http_addrlist_t *last_wrong_addr;
gint socket;
-#endif
};
#define GTK_CUPS_REQUEST_START 0
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,
else
dispatch->data_poll->events = 0;
-#ifdef HAVE_CUPS_API_1_2
dispatch->data_poll->fd = httpGetFd (dispatch->request->http);
-#else
- dispatch->data_poll->fd = dispatch->request->http->fd;
-#endif
g_source_add_poll (source, dispatch->data_poll);
}
}
char *label;
int n_choices;
int i;
-#ifdef HAVE_CUPS_API_1_2
ppd_coption_t *coption;
-#endif
g_assert (ppd_option->ui == PPD_UI_PICKONE);
label = get_option_text (ppd_file, ppd_option);
-#ifdef HAVE_CUPS_API_1_2
coption = ppdFindCustomOption (ppd_file, ppd_option->keyword);
if (coption)
g_warning ("CUPS Backend: Multi-parameter PPD Custom Option not supported");
#endif
}
-#endif /* HAVE_CUPS_API_1_2 */
if (!option)
option = gtk_printer_option_new (gtk_name, label,