jw@pan.UUCP (Jamie Watson) (08/09/89)
The queuing system backend programs provided with AIX (piobe and lp) absolutely insist on sending various kinds of escape sequences and control characters to the printer. After complaining about this to IBM repeatedly, trying every printer type definition available, including "osp" and "opp", editing the /etc/qconfig and /etc/ddi/* files, and trying every conceivable setting of the "splp" command, I finally gave up and wrote the following trivial backend. This program does just enough to qualify as a "friendly" backend. It opens and updates the statusfile, it passes fatal error messages to the qdaemon process correctly, and it exits with appropriate status. It does not print any burst pages and it does not write charge information to the status file. It does not print multiple copies, primarily because it doesn't know what to do between copies (send form feed, count lines or whatever). It also doesn't attempt to set any characteristics of the output line, regardless of whether it is a serial or parallel device. I assume that one would use the "splp" command in /etc/rc.include for this. This program must be linked with the AIX queue backend library (libqb.a). #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: rawbe.c # Wrapped by jw@pan on Wed Aug 9 11:22:23 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'rawbe.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rawbe.c'\" else echo shar: Extracting \"'rawbe.c'\" \(1258 characters\) sed "s/^X//" >'rawbe.c' <<'END_OF_FILE' X#include <fcntl.h> X#include <sys/stat.h> X#include <IN/standard.h> X Xextern int errno; Xextern void exit(); X Xmain (argc, argv) Xint argc; Xchar **argv; X{ X int fd, nc, tc, statusfile = 0; X char buf[1024]; X struct stat st; X X while (--argc && **++argv == '-') { X if (strncmp(*argv, "-statusfile", 11) == 0) { X statusfile++; X if (log_init() == -1) { X (void)log_message("log_init() failed\n"); X exit(EXITBAD); X } X } X else { X (void)log_message("invalid flag \"%s\"\n", *argv); X exit(EXITBAD); X } X } X while (argc--) { X if ((fd = open(*argv, O_RDONLY)) < 0) { X (void)log_message("open failed on %s, error %d\n", *argv, errno); X exit(EXITBAD); X } X if (fstat(fd, &st) < 0) { X (void)log_message("stat() failed on %s, error %d\n", *argv, errno); X exit(EXITBAD); X } X tc = 0; X while ((nc = read(fd, buf, sizeof(buf))) > 0) { X if (statusfile) { X tc += nc * 100; X (void)log_progress(0, (int)(tc/st.st_size)); X } X if (write(1, buf, (unsigned)nc) != nc) { X (void)log_message("%s: output write fail, error %d\n", nc, errno); X exit(EXITBAD); X } X } X if (close(fd) < 0) { X (void)log_message("close() failed\n"); X exit(EXITBAD); X } X argv++; X } X exit(EXITOK); X} END_OF_FILE if test 1258 -ne `wc -c <'rawbe.c'`; then echo shar: \"'rawbe.c'\" unpacked with wrong size! fi # end of 'rawbe.c' fi echo shar: End of shell archive. exit 0