diff options
author | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2007-03-14 16:55:44 +0000 |
---|---|---|
committer | jlovell <jlovell@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2007-03-14 16:55:44 +0000 |
commit | f7deaa1a21758ec90bf23314af018481ea8aea7f (patch) | |
tree | 28c1e9c935060b27e10b2e9daa788f69508f3726 /backend/parallel.c | |
parent | b86bc4cf571c35972a94a634ea884baff9799fa9 (diff) | |
download | cups-f7deaa1a21758ec90bf23314af018481ea8aea7f.tar.gz |
Load cups into easysw/current.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@279 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'backend/parallel.c')
-rw-r--r-- | backend/parallel.c | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/backend/parallel.c b/backend/parallel.c index c33fc10d2..4164e7895 100644 --- a/backend/parallel.c +++ b/backend/parallel.c @@ -1,9 +1,9 @@ /* - * "$Id: parallel.c 6181 2007-01-03 18:51:27Z mike $" + * "$Id: parallel.c 6178 2007-01-03 18:09:17Z mike $" * * Parallel port backend for the Common UNIX Printing System (CUPS). * - * Copyright 1997-2006 by Easy Software Products, all rights reserved. + * Copyright 1997-2007 by Easy Software Products, all rights reserved. * * These coded instructions, statements, and computer programs are the * property of Easy Software Products and are protected by Federal @@ -27,6 +27,7 @@ * * main() - Send a file to the specified parallel port. * list_devices() - List all parallel devices. + * side_cb() - Handle side-channel requests... */ /* @@ -66,7 +67,8 @@ * Local functions... */ -void list_devices(void); +static void list_devices(void); +static void side_cb(int print_fd, int device_fd, int use_bc); /* @@ -284,7 +286,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ lseek(print_fd, 0, SEEK_SET); } - tbytes = backendRunLoop(print_fd, device_fd, use_bc); + tbytes = backendRunLoop(print_fd, device_fd, use_bc, side_cb); if (print_fd != 0 && tbytes >= 0) fprintf(stderr, "INFO: Sent print file, " CUPS_LLFMT " bytes...\n", @@ -308,7 +310,7 @@ main(int argc, /* I - Number of command-line arguments (6 or 7) */ * 'list_devices()' - List all parallel devices. */ -void +static void list_devices(void) { #if defined(__hpux) || defined(__sgi) || defined(__sun) @@ -598,5 +600,70 @@ list_devices(void) /* - * End of "$Id: parallel.c 6181 2007-01-03 18:51:27Z mike $". + * 'side_cb()' - Handle side-channel requests... + */ + +static void +side_cb(int print_fd, /* I - Print file */ + int device_fd, /* I - Device file */ + int use_bc) /* I - Using back-channel? */ +{ + cups_sc_command_t command; /* Request command */ + cups_sc_status_t status; /* Request/response status */ + char data[2048]; /* Request/response data */ + int datalen; /* Request/response data size */ + + + datalen = sizeof(data); + + if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0)) + { + fputs("WARNING: Failed to read side-channel request!\n", stderr); + return; + } + + switch (command) + { + case CUPS_SC_CMD_DRAIN_OUTPUT : + if (tcdrain(device_fd)) + status = CUPS_SC_STATUS_IO_ERROR; + else + status = CUPS_SC_STATUS_OK; + + datalen = 0; + break; + + case CUPS_SC_CMD_GET_BIDI : + data[0] = use_bc; + datalen = 1; + break; + + case CUPS_SC_CMD_GET_DEVICE_ID : + memset(data, 0, sizeof(data)); + + if (backendGetDeviceID(device_fd, data, sizeof(data) - 1, + NULL, 0, NULL, NULL, 0)) + { + status = CUPS_SC_STATUS_NOT_IMPLEMENTED; + datalen = 0; + } + else + { + status = CUPS_SC_STATUS_OK; + datalen = strlen(data); + } + break; + + default : + status = CUPS_SC_STATUS_NOT_IMPLEMENTED; + datalen = 0; + break; + } + + cupsSideChannelWrite(command, status, data, datalen, 1.0); +} + + +/* + * End of "$Id: parallel.c 6178 2007-01-03 18:09:17Z mike $". */ |