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

Function wait_bc

backend/socket.c:457–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

455 */
456
457static ssize_t /* O - # bytes read or -1 on error */
458wait_bc(int device_fd, /* I - Socket */
459 int secs) /* I - Seconds to wait */
460{
461 struct timeval timeout; /* Timeout for select() */
462 fd_set input; /* Input set for select() */
463 ssize_t bytes; /* Number of back-channel bytes read */
464 char buffer[1024]; /* Back-channel buffer */
465
466
467 /*
468 * Wait up to "secs" seconds for backchannel data...
469 */
470
471 timeout.tv_sec = secs;
472 timeout.tv_usec = 0;
473
474 FD_ZERO(&input);
475 FD_SET(device_fd, &input);
476
477 if (select(device_fd + 1, &input, NULL, NULL, &timeout) > 0)
478 {
479 /*
480 * Grab the data coming back and spit it out to stderr...
481 */
482
483 if ((bytes = read(device_fd, buffer, sizeof(buffer))) > 0)
484 {
485 fprintf(stderr, "DEBUG: Received %d bytes of back-channel data\n",
486 (int)bytes);
487 cupsBackChannelWrite(buffer, (size_t)bytes, 1.0);
488 }
489
490 return (bytes);
491 }
492 else
493 return (-1);
494}

Callers 1

mainFunction · 0.85

Calls 1

cupsBackChannelWriteFunction · 0.85

Tested by

no test coverage detected