| 1457 | */ |
| 1458 | |
| 1459 | int /* O - 0 on success, -1 on error */ |
| 1460 | cupsFilePutChar(cups_file_t *fp, /* I - CUPS file */ |
| 1461 | int c) /* I - Character to write */ |
| 1462 | { |
| 1463 | /* |
| 1464 | * Range check input... |
| 1465 | */ |
| 1466 | |
| 1467 | if (!fp || (fp->mode != 'w' && fp->mode != 's')) |
| 1468 | return (-1); |
| 1469 | |
| 1470 | if (fp->mode == 's') |
| 1471 | { |
| 1472 | /* |
| 1473 | * Send character immediately over socket... |
| 1474 | */ |
| 1475 | |
| 1476 | char ch; /* Output character */ |
| 1477 | |
| 1478 | |
| 1479 | ch = (char)c; |
| 1480 | |
| 1481 | if (send(fp->fd, &ch, 1, 0) < 1) |
| 1482 | return (-1); |
| 1483 | } |
| 1484 | else |
| 1485 | { |
| 1486 | /* |
| 1487 | * Buffer it up... |
| 1488 | */ |
| 1489 | |
| 1490 | if (fp->ptr >= fp->end) |
| 1491 | if (cupsFileFlush(fp)) |
| 1492 | return (-1); |
| 1493 | |
| 1494 | *(fp->ptr) ++ = (char)c; |
| 1495 | } |
| 1496 | |
| 1497 | fp->pos ++; |
| 1498 | |
| 1499 | DEBUG_printf(("4cupsFilePutChar: pos=" CUPS_LLFMT, CUPS_LLCAST fp->pos)); |
| 1500 | |
| 1501 | return (0); |
| 1502 | } |
| 1503 | |
| 1504 | |
| 1505 | /* |