Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!rutgers!husc6!ddl From: ddl@husc6.harvard.edu (Dan Lanciani) Newsgroups: comp.protocols.appletalk Subject: Re: banner pages with CAP? Message-ID: <3962@husc6.harvard.edu> Date: 1 Feb 88 01:14:55 GMT References: <574@acornrc.UUCP> <8801261521.AA02893@columbia.edu> Organization: Harvard University, Cambridge MA Lines: 243 In article <8801261521.AA02893@columbia.edu>, cck@cunixc.columbia.EDU (Charlie C. Kim) writes: | The input filter is supposed to process a file called ".banner" | created by the output filter. papif doesn't process the .banner file. | lnof doesn't create one. Strangely, the version of lnof we got does create one. | To do things correctly, papif needs to be modified. (The banner | should go down in the same job stream to prevent interleaving of pages | from other jobs). Transcript's psbanner program can be used, but some | care needs to be taken (with all the transcript programs). I modified papif to grind lpd's standard banner through pstext because I didn't like the idea of parsing the "short-form" lpr banner to recover the information to print a fancy burst page. (Though I never understood why Transcript does this rather than using the appropriate arguments.) I also added to papif the ability to return output from a job to its originator, although this uses a feature of lpd that seems to have changed in real 4.3. Sigh. Anyway, here are some context diffs; use part or all at your own risk... By the way, has anyone noticed that leaving the STATUS feature enabled reduces reliability? Dan Lanciani ddl@harvard.* *** /usr/src/local/at/cap/samples/papif.c Sat Jan 16 22:07:00 1988 --- /users/isr/isr-staff/staffs/ddl/src/cap/papif.c Sat Jan 30 20:11:03 1988 *************** *** 1,6 **** ! static char rcsid[] = "$Author: cck $ $Date: 87/08/06 17:48:02 $"; ! static char rcsident[] = "$Header: papif.c,v 1.24 87/08/06 17:48:02 cck Rel $"; ! static char revision[] = "$Revision: 1.24 $"; /* * papif - UNIX AppleTalk test program: simple line printer input filter --- 1,5 ---- ! #define PSTEXT "/usr/vendor/lib/ps/pstext" ! #define NOSTATUS /* * papif - UNIX AppleTalk test program: simple line printer input filter *************** *** 45,51 **** int cno; int ppid; int pid; ! char host[30],printer[30],user[30]; #define RFLOWQ 8 #ifndef SFLOWQ # define SFLOWQ 8 --- 44,50 ---- int cno; int ppid; int pid; ! char host[30],printer[30],user[30],group[30]; #define RFLOWQ 8 #ifndef SFLOWQ # define SFLOWQ 8 *************** *** 56,61 **** --- 55,62 ---- char rbuf[BUFMAX+10]; int xdebug = TRUE; char *ptime(); + FILE *pout; + int didout; /* quit gets called when we've been killed by lprm via SIGINT */ quit() *************** *** 91,96 **** --- 92,100 ---- case 'p': /* printer name */ strcpy(printer,argv[++i]); break; + case 'g': /* group name */ + strcpy(group,argv[++i]); + break; case 'n': /* user name */ strcpy(user,argv[++i]); break; *************** *** 122,128 **** --- 126,134 ---- strcpy(printer, pgmname); } + char tname[] = "/tmp/papifXXXXXX"; + /* * our "input" filter - send input to laserwriter * *************** *** 166,171 **** --- 172,181 ---- nbpInit(); PAPInit(); /* init PAP printer routines */ + mktemp(tname); + if(!(pout = fopen(tname, "w"))) + pout = stderr; + /* log message */ fprintf(stderr,"PAPIF: Starting job for %s@%s at %s on printer %s\n", user,host,ptime(),lwname); *************** *** 175,187 **** #endif signal(SIGINT,quit); /* this is what lprm sends us */ - #ifdef notdef - if ((bannerfd = open(".banner", 0)) >= 0) { - sendbanner(ptr, bannerfd); /* don't care if we can't send it */ - close(bannerfd); - } - #endif - cno = openlw(lwname); #ifndef NOSTATUS --- 185,190 ---- *************** *** 202,212 **** --- 205,235 ---- sendfile(cno); /* send file to laserwriter */ + #ifdef PSTEXT + close(0); + wait(0); + if (!index(host, '@') && !open(".banner", 0)) { + pstext(); + sendfile(cno); + } + #endif + epc = getpagecount(cno); /* get the page count */ PAPClose(cno); if (acctfile != NULL) doacct(spc, epc, acctfile, user, host); + if(pout != stderr) { + fclose(pout); + if(didout || index(host, '@')) { + if(!fork()) { + execl("/usr/local/bin/returnfile", "returnfile", host, user, tname, 0); + exit(1); + } + } + else + unlink(tname); + } exit(lpd_OK); /* exit okay */ } *************** *** 320,327 **** fprintf(stderr,"PAPRead error %d\n",rcomp); break; } else if (rlen > 0) { ! rbuf[rlen] = '\0'; ! fprintf(stderr,"%s",rbuf); } paperr = PAPRead(cno, rbuf, &rlen, &eof, &rcomp); if (paperr < 0) { --- 343,350 ---- fprintf(stderr,"PAPRead error %d\n",rcomp); break; } else if (rlen > 0) { ! write(fileno(pout), rbuf, rlen); ! didout = 1; } paperr = PAPRead(cno, rbuf, &rlen, &eof, &rcomp); if (paperr < 0) { *************** *** 353,360 **** fprintf(stderr,"PAPRead error %d\n",rcomp); break; } else if (rlen > 0) { ! rbuf[rlen] = '\0'; ! fprintf(stderr,"%s",rbuf); } if (eof) break; PAPRead(cno, rbuf, &rlen, &eof, &rcomp); --- 376,383 ---- fprintf(stderr,"PAPRead error %d\n",rcomp); break; } else if (rlen > 0) { ! write(fileno(pout), rbuf, rlen); ! didout = 1; } if (eof) break; PAPRead(cno, rbuf, &rlen, &eof, &rcomp); *************** *** 423,429 **** if (epc >= spc && epc > 0 && spc > 0) { if (user[0] != '\0' && acctfile && access(acctfile, 02) >= 0 && (afd = fopen(acctfile, "a")) != NULL) ! fprintf(afd,"%7.2f\t%s:%s\n", (float)(epc-spc), host, user); } else fprintf(stderr, "Problems getting pagecount: start %d, end %d\n",spc,epc); } --- 446,452 ---- if (epc >= spc && epc > 0 && spc > 0) { if (user[0] != '\0' && acctfile && access(acctfile, 02) >= 0 && (afd = fopen(acctfile, "a")) != NULL) ! fprintf(afd,"%7.2f %-16s %-20s %-8s\n", (float)(epc-spc), host, group, user); } else fprintf(stderr, "Problems getting pagecount: start %d, end %d\n",spc,epc); } *************** *** 553,559 **** for (i = 0 ; i < NSIG ; i++) signal(i, SIG_IGN); sprintf(retry, ! "(sleep 2;/etc/lpc abort %s;sleep 2;/etc/lpc start %s)&", printer, printer); system(retry); exit(lpd_REPRINT); --- 576,582 ---- for (i = 0 ; i < NSIG ; i++) signal(i, SIG_IGN); sprintf(retry, ! "(sleep 3;/etc/lpc abort %s;sleep 3;/etc/lpc start %s)&", printer, printer); system(retry); exit(lpd_REPRINT); *************** *** 564,569 **** } #endif IDLESTUFF pstatus(status.StatusStr); ! sleep(10); /* update every 10 seconds */ } while (1); } --- 587,592 ---- } #endif IDLESTUFF pstatus(status.StatusStr); ! sleep(30); /* update every 10 seconds */ } while (1); }