| 1371 | */ |
| 1372 | |
| 1373 | static ssize_t /* O - Bytes read/write or -1 */ |
| 1374 | cups_raster_io(cups_raster_t *r, /* I - Raster stream */ |
| 1375 | unsigned char *buf, /* I - Buffer for read/write */ |
| 1376 | size_t bytes) /* I - Number of bytes to read/write */ |
| 1377 | { |
| 1378 | ssize_t count, /* Number of bytes read/written */ |
| 1379 | total; /* Total bytes read/written */ |
| 1380 | |
| 1381 | |
| 1382 | DEBUG_printf(("5cups_raster_io(r=%p, buf=%p, bytes=" CUPS_LLFMT ")", (void *)r, (void *)buf, CUPS_LLCAST bytes)); |
| 1383 | |
| 1384 | for (total = 0; total < (ssize_t)bytes; total += count, buf += count) |
| 1385 | { |
| 1386 | count = (*r->iocb)(r->ctx, buf, bytes - (size_t)total); |
| 1387 | |
| 1388 | DEBUG_printf(("6cups_raster_io: count=%d, total=%d", (int)count, (int)total)); |
| 1389 | if (count == 0) |
| 1390 | break; |
| 1391 | // { |
| 1392 | // DEBUG_puts("6cups_raster_io: Returning 0."); |
| 1393 | // return (0); |
| 1394 | // } |
| 1395 | else if (count < 0) |
| 1396 | { |
| 1397 | DEBUG_puts("6cups_raster_io: Returning -1 on error."); |
| 1398 | return (-1); |
| 1399 | } |
| 1400 | |
| 1401 | #ifdef DEBUG |
| 1402 | r->iocount += (size_t)count; |
| 1403 | #endif /* DEBUG */ |
| 1404 | } |
| 1405 | |
| 1406 | DEBUG_printf(("6cups_raster_io: iocount=" CUPS_LLFMT, CUPS_LLCAST r->iocount)); |
| 1407 | DEBUG_printf(("6cups_raster_io: Returning " CUPS_LLFMT ".", CUPS_LLCAST total)); |
| 1408 | |
| 1409 | return (total); |
| 1410 | } |
| 1411 | |
| 1412 | |
| 1413 | /* |
no outgoing calls
no test coverage detected