MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsWriteRequestData

Function cupsWriteRequestData

cups/request.c:910–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

908 */
909
910http_status_t /* O - @code HTTP_STATUS_CONTINUE@ if OK or HTTP status on error */
911cupsWriteRequestData(
912 http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
913 const char *buffer, /* I - Bytes to write */
914 size_t length) /* I - Number of bytes to write */
915{
916 int wused; /* Previous bytes in buffer */
917
918
919 /*
920 * Get the default connection as needed...
921 */
922
923 DEBUG_printf(("cupsWriteRequestData(http=%p, buffer=%p, length=" CUPS_LLFMT ")", (void *)http, (void *)buffer, CUPS_LLCAST length));
924
925 if (!http)
926 {
927 _cups_globals_t *cg = _cupsGlobals();
928 /* Pointer to library globals */
929
930 if ((http = cg->http) == NULL)
931 {
932 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No active connection"), 1);
933 DEBUG_puts("1cupsWriteRequestData: Returning HTTP_STATUS_ERROR.");
934 return (HTTP_STATUS_ERROR);
935 }
936 }
937
938 /*
939 * Then write to the HTTP connection...
940 */
941
942 wused = http->wused;
943
944 if (httpWrite2(http, buffer, length) < 0)
945 {
946 DEBUG_puts("1cupsWriteRequestData: Returning HTTP_STATUS_ERROR.");
947 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(http->error), 0);
948 return (HTTP_STATUS_ERROR);
949 }
950
951 /*
952 * Finally, check if we have any pending data from the server...
953 */
954
955 if (length >= HTTP_MAX_BUFFER ||
956 http->wused < wused ||
957 (wused > 0 && (size_t)http->wused == length))
958 {
959 /*
960 * We've written something to the server, so check for response data...
961 */
962
963 if (_httpWait(http, 0, 1))
964 {
965 http_status_t status; /* Status from _httpUpdate */
966
967 _httpUpdate(http, &status);

Callers 9

do_testFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
cgiPrintCommandFunction · 0.85
mainFunction · 0.85
print_fileFunction · 0.85
mainFunction · 0.85
cupsPrintFiles2Function · 0.85
cupsDoIORequestFunction · 0.85

Calls 8

_cupsGlobalsFunction · 0.85
_cupsSetErrorFunction · 0.85
httpWrite2Function · 0.85
_httpWaitFunction · 0.85
_httpUpdateFunction · 0.85
_cupsSetHTTPErrorFunction · 0.85
httpUpdateFunction · 0.85
httpFlushFunction · 0.85

Tested by 2

print_fileFunction · 0.68
mainFunction · 0.68