| 693 | */ |
| 694 | |
| 695 | static int /* O - Zero on success, non-zero on failure */ |
| 696 | lpd_queue(const char *hostname, /* I - Host to connect to */ |
| 697 | http_addrlist_t *addrlist, /* I - List of host addresses */ |
| 698 | const char *printer, /* I - Printer/queue name */ |
| 699 | int print_fd, /* I - File to print */ |
| 700 | int snmp_fd, /* I - SNMP socket */ |
| 701 | int mode, /* I - Print mode */ |
| 702 | const char *user, /* I - Requesting user */ |
| 703 | const char *title, /* I - Job title */ |
| 704 | int copies, /* I - Number of copies */ |
| 705 | int banner, /* I - Print LPD banner? */ |
| 706 | int format, /* I - Format specifier */ |
| 707 | int order, /* I - Order of data/control files */ |
| 708 | int reserve, /* I - Reserve ports? */ |
| 709 | int manual_copies,/* I - Do copies by hand... */ |
| 710 | int timeout, /* I - Timeout... */ |
| 711 | int contimeout, /* I - Connection timeout */ |
| 712 | const char *orighost) /* I - job-originating-host-name */ |
| 713 | { |
| 714 | char localhost[255]; /* Local host name */ |
| 715 | int error; /* Error number */ |
| 716 | struct stat filestats; /* File statistics */ |
| 717 | int lport; /* LPD connection local port */ |
| 718 | int fd; /* LPD socket */ |
| 719 | char control[10240], /* LPD control 'file' */ |
| 720 | *cptr; /* Pointer into control file string */ |
| 721 | char status; /* Status byte from command */ |
| 722 | int delay; /* Delay for retries... */ |
| 723 | char addrname[256]; /* Address name */ |
| 724 | http_addrlist_t *addr; /* Socket address */ |
| 725 | int have_supplies; /* Printer supports supply levels? */ |
| 726 | int copy; /* Copies written */ |
| 727 | time_t start_time; /* Time of first connect */ |
| 728 | ssize_t nbytes; /* Number of bytes written */ |
| 729 | off_t tbytes; /* Total bytes written */ |
| 730 | char buffer[32768]; /* Output buffer */ |
| 731 | #ifdef _WIN32 |
| 732 | DWORD tv; /* Timeout in milliseconds */ |
| 733 | #else |
| 734 | struct timeval tv; /* Timeout in secs and usecs */ |
| 735 | #endif /* _WIN32 */ |
| 736 | |
| 737 | |
| 738 | /* |
| 739 | * Remember when we started trying to connect to the printer... |
| 740 | */ |
| 741 | |
| 742 | start_time = time(NULL); |
| 743 | |
| 744 | /* |
| 745 | * Loop forever trying to print the file... |
| 746 | */ |
| 747 | |
| 748 | while (!abort_job) |
| 749 | { |
| 750 | /* |
| 751 | * First try to reserve a port for this connection... |
| 752 | */ |
no test coverage detected