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

Function http_read_buffered

cups/http.c:4262–4292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4260 */
4261
4262static ssize_t /* O - Number of bytes read or -1 on error */
4263http_read_buffered(http_t *http, /* I - HTTP connection */
4264 char *buffer, /* I - Buffer */
4265 size_t length) /* I - Maximum bytes to read */
4266{
4267 ssize_t bytes; /* Bytes read */
4268
4269
4270 DEBUG_printf(("7http_read_buffered(http=%p, buffer=%p, length=" CUPS_LLFMT ") used=%d", (void *)http, (void *)buffer, CUPS_LLCAST length, http->used));
4271
4272 if (http->used > 0)
4273 {
4274 if (length > (size_t)http->used)
4275 bytes = (ssize_t)http->used;
4276 else
4277 bytes = (ssize_t)length;
4278
4279 DEBUG_printf(("8http_read_buffered: Grabbing %d bytes from input buffer.",
4280 (int)bytes));
4281
4282 memcpy(buffer, http->buffer, (size_t)bytes);
4283 http->used -= (int)bytes;
4284
4285 if (http->used > 0)
4286 memmove(http->buffer, http->buffer + bytes, (size_t)http->used);
4287 }
4288 else
4289 bytes = http_read(http, buffer, length, http->wait_value);
4290
4291 return (bytes);
4292}
4293
4294
4295/*

Callers 2

httpRead2Function · 0.85
http_read_chunkFunction · 0.85

Calls 1

http_readFunction · 0.85

Tested by

no test coverage detected