/*
- * "$Id: parallel.c,v 1.20 2000/04/27 21:31:38 mike Exp $"
+ * "$Id: parallel.c,v 1.21 2000/06/27 20:15:54 mike Exp $"
*
* Parallel port backend for the Common UNIX Printing System (CUPS).
*
FILE *fp; /* Print file */
int copies; /* Number of copies to print */
int fd; /* Parallel device */
- size_t nbytes, /* Number of bytes written */
+ int wbytes; /* Number of bytes written */
+ size_t nbytes, /* Number of bytes read */
tbytes; /* Total number of bytes written */
- char buffer[8192]; /* Output buffer */
+ char buffer[8192], /* Output buffer */
+ *bufptr; /* Pointer into buffer */
struct termios opts; /* Parallel port options */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
* Write the print data to the printer...
*/
- if (write(fd, buffer, nbytes) < nbytes)
+ tbytes += nbytes;
+ bufptr = buffer;
+
+ while (nbytes > 0)
{
- perror("ERROR: Unable to send print file to printer");
- break;
+ if ((wbytes = write(fd, bufptr, nbytes)) < 0)
+ if (errno == ENOTTY)
+ wbytes = write(fd, bufptr, nbytes);
+
+ if (wbytes < 0)
+ {
+ perror("ERROR: Unable to send print file to printer");
+ break;
+ }
+
+ nbytes -= wbytes;
+ bufptr += wbytes;
}
- else
- tbytes += nbytes;
if (argc > 6)
fprintf(stderr, "INFO: Sending print file, %u bytes...\n", tbytes);
/*
- * End of "$Id: parallel.c,v 1.20 2000/04/27 21:31:38 mike Exp $".
+ * End of "$Id: parallel.c,v 1.21 2000/06/27 20:15:54 mike Exp $".
*/
/*
- * "$Id: serial.c,v 1.16 2000/04/27 21:31:38 mike Exp $"
+ * "$Id: serial.c,v 1.17 2000/06/27 20:15:54 mike Exp $"
*
* Serial port backend for the Common UNIX Printing System (CUPS).
*
FILE *fp; /* Print file */
int copies; /* Number of copies to print */
int fd; /* Parallel device */
- size_t nbytes, /* Number of bytes written */
+ int wbytes; /* Number of bytes written */
+ size_t nbytes, /* Number of bytes read */
tbytes; /* Total number of bytes written */
- char buffer[8192]; /* Output buffer */
+ char buffer[8192], /* Output buffer */
+ *bufptr; /* Pointer into buffer */
struct termios opts; /* Parallel port options */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
* Write the print data to the printer...
*/
- if (write(fd, buffer, nbytes) < nbytes)
+ tbytes += nbytes;
+ bufptr = buffer;
+
+ while (nbytes > 0)
{
- perror("ERROR: Unable to send print file to printer");
- break;
+ if ((wbytes = write(fd, bufptr, nbytes)) < 0)
+ if (errno == ENOTTY)
+ wbytes = write(fd, bufptr, nbytes);
+
+ if (wbytes < 0)
+ {
+ perror("ERROR: Unable to send print file to printer");
+ break;
+ }
+
+ nbytes -= wbytes;
+ bufptr += wbytes;
}
- else
- tbytes += nbytes;
if (argc > 6)
fprintf(stderr, "INFO: Sending print file, %u bytes...\n", tbytes);
/*
- * End of "$Id: serial.c,v 1.16 2000/04/27 21:31:38 mike Exp $".
+ * End of "$Id: serial.c,v 1.17 2000/06/27 20:15:54 mike Exp $".
*/
/*
- * "$Id: usb.c,v 1.8 2000/06/02 20:58:59 mike Exp $"
+ * "$Id: usb.c,v 1.9 2000/06/27 20:15:54 mike Exp $"
*
* USB port backend for the Common UNIX Printing System (CUPS).
*
FILE *fp; /* Print file */
int copies; /* Number of copies to print */
int fd; /* Parallel device */
- size_t nbytes, /* Number of bytes written */
+ int wbytes; /* Number of bytes written */
+ size_t nbytes, /* Number of bytes read */
tbytes; /* Total number of bytes written */
- char buffer[8192]; /* Output buffer */
+ char buffer[8192], /* Output buffer */
+ *bufptr; /* Pointer into buffer */
struct termios opts; /* Parallel port options */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
* Write the print data to the printer...
*/
- if (write(fd, buffer, nbytes) < nbytes)
+ tbytes += nbytes;
+ bufptr = buffer;
+
+ while (nbytes > 0)
{
- perror("ERROR: Unable to send print file to printer");
- break;
+ if ((wbytes = write(fd, bufptr, nbytes)) < 0)
+ if (errno == ENOTTY)
+ wbytes = write(fd, bufptr, nbytes);
+
+ if (wbytes < 0)
+ {
+ perror("ERROR: Unable to send print file to printer");
+ break;
+ }
+
+ nbytes -= wbytes;
+ bufptr += wbytes;
}
- else
- tbytes += nbytes;
if (argc > 6)
fprintf(stderr, "INFO: Sending print file, %u bytes...\n", tbytes);
/*
- * End of "$Id: usb.c,v 1.8 2000/06/02 20:58:59 mike Exp $".
+ * End of "$Id: usb.c,v 1.9 2000/06/27 20:15:54 mike Exp $".
*/