diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2010-04-12 04:23:14 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2010-04-12 04:23:14 +0000 |
commit | 6d2f911bdd077fee9489b1084b960c4e68fc0658 (patch) | |
tree | 3da5defca13981b9eef673bbd8dbe639f9233c0a /cups/request.c | |
parent | 39ff2fe72b9fc06ae7acc909584f87874f3a71b8 (diff) | |
download | cups-6d2f911bdd077fee9489b1084b960c4e68fc0658.tar.gz |
Merge changes from CUPS 1.5svn-r9105.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@2070 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/request.c')
-rw-r--r-- | cups/request.c | 92 |
1 files changed, 90 insertions, 2 deletions
diff --git a/cups/request.c b/cups/request.c index 60d80e5a6..4285eeb87 100644 --- a/cups/request.c +++ b/cups/request.c @@ -20,9 +20,12 @@ * cupsDoIORequest() - Do an IPP request with file descriptors. * cupsDoRequest() - Do an IPP request. * cupsGetResponse() - Get a response to an IPP request. + * cupsLastError() - Return the last IPP status code. + * cupsLastErrorString() - Return the last IPP status-message. * cupsReadResponseData() - Read additional data after the IPP response. * cupsSendRequest() - Send an IPP request. * cupsWriteRequestData() - Write additional data after an IPP request. + * _cupsConnect() - Get the default server connection... * _cupsSetError() - Set the last IPP status code and status-message. * _cupsSetHTTPError() - Set the last error using the HTTP status. */ @@ -299,7 +302,7 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP /* * Delete the original request and return the response... */ - + ippDelete(request); return (response); @@ -478,6 +481,30 @@ cupsGetResponse(http_t *http, /* I - Connection to server or @code CUPS_HTTP /* + * 'cupsLastError()' - Return the last IPP status code. + */ + +ipp_status_t /* O - IPP status code from last request */ +cupsLastError(void) +{ + return (_cupsGlobals()->last_error); +} + + +/* + * 'cupsLastErrorString()' - Return the last IPP status-message. + * + * @since CUPS 1.2/Mac OS X 10.5@ + */ + +const char * /* O - status-message text from last request */ +cupsLastErrorString(void) +{ + return (_cupsGlobals()->last_status_message); +} + + +/* * 'cupsReadResponseData()' - Read additional data after the IPP response. * * This function is used after cupsGetResponse() to read the PPD or document @@ -524,7 +551,7 @@ cupsReadResponseData( * * Use httpWrite() to write any additional data (document, PPD file, etc.) * for the request, cupsGetResponse() to get the IPP response, and httpRead() - * to read any additional data following the response. Only one request can be + * to read any additional data following the response. Only one request can be * sent/queued at a time. * * Unlike cupsDoFileRequest(), cupsDoIORequest(), and cupsDoRequest(), the @@ -817,6 +844,67 @@ cupsWriteRequestData( /* + * '_cupsConnect()' - Get the default server connection... + */ + +http_t * /* O - HTTP connection */ +_cupsConnect(void) +{ + _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ + + + /* + * See if we are connected to the same server... + */ + + if (cg->http) + { + /* + * Compare the connection hostname, port, and encryption settings to + * the cached defaults; these were initialized the first time we + * connected... + */ + + if (strcmp(cg->http->hostname, cg->server) || + cg->ipp_port != _httpAddrPort(cg->http->hostaddr) || + (cg->http->encryption != cg->encryption && + cg->http->encryption == HTTP_ENCRYPT_NEVER)) + { + /* + * Need to close the current connection because something has changed... + */ + + httpClose(cg->http); + cg->http = NULL; + } + } + + /* + * (Re)connect as needed... + */ + + if (!cg->http) + { + if ((cg->http = httpConnectEncrypt(cupsServer(), ippPort(), + cupsEncryption())) == NULL) + { + if (errno) + _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0); + else + _cupsSetError(IPP_SERVICE_UNAVAILABLE, + _("Unable to connect to host."), 1); + } + } + + /* + * Return the cached connection... + */ + + return (cg->http); +} + + +/* * '_cupsSetError()' - Set the last IPP status code and status-message. */ |