Subject: bin/20736: Mods to /usr/src/usr.sbin/lpr/lpd/printjob.c for source filename
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jimd@siu.edu>
List: netbsd-bugs
Date: 03/16/2003 04:40:07
>Number: 20736
>Category: bin
>Synopsis: Add mods to lpr/lpd/printjob.c to pass filename to filter
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Mar 16 02:41:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: Jim Dutton
>Release: NetBSD 1.6
>Organization:
>Environment:
System: NetBSD amiga1.localnet10 1.6 NetBSD 1.6 (GENERIC) #0: Sun Sep 8 09:50:48 UTC 2002 autobuild@tgm.daemon.org:/autobuild/amiga/OBJ/autobuild/src/sys/arch/amiga/compile/GENERIC amiga
Architecture: m68k
Machine: amiga
>Description:
Add two variables and an extra pass through the LPD print control file
to extract the original/source file name, and add two parameters to
input filter parameter list, providing source file name to filter
similar to the "-fn" and subsequent parameter such as:
-w80 -l63 -i0 -n root -h amiga1.localnet10 /var/account/lp.printacct -fn djlpf.sh
This allows an input filter to make decisions based on the name of the
original/source print file without having to write the file on STDIN to
disk and then use disk-based methods to determine useful attributes
about the file (which will still lack the name of the source file).
Note that this patch has already been submitted to FreeBSD.org.
>How-To-Repeat:
>Fix:
*** printjob.c.orig Mon Jan 21 14:42:30 2002
--- printjob.c Sun Mar 16 04:18:58 2003
***************
*** 112,117 ****
--- 112,119 ----
/* indentation size in static characters */
static char indent[10] = "-i0";
static char jobname[100]; /* job or file name */
+ static char ofilename[100]; /* name of (source) file to print - JD*/
+ static long origfpos = 0L; /* original cfp file position - JD */
static char length[10] = "-l"; /* page length in lines */
static char logname[32]; /* user's login name */
static char pxlength[10] = "-y"; /* page length in pixels */
***************
*** 376,382 ****
*/
/* pass 1 */
-
while (getline(cfp))
switch (line[0]) {
case 'H':
--- 378,383 ----
***************
*** 420,426 ****
jobname[1] = '\0';
}
continue;
-
case 'C':
if (line[1] != '\0') {
strncpy(class, line+1, sizeof(class) - 1);
--- 421,426 ----
***************
*** 557,562 ****
--- 557,585 ----
(void)close(fi);
return(OK);
}
+
+ /*
+ * reset pointer to config file, parse cf for filename,
+ * reset pointer again to where it was before we got here
+ *
+ * JD 06 March 2003
+ *
+ */
+ origfpos = ftell(cfp); /* get previous file position */
+ fseek(cfp, 0L, 0); /* set file position to beginning of file */
+ strcpy(ofilename, ""); /* initialize variable */
+ while (getline(cfp))
+ switch (line[0]){
+ case 'N':
+ if (line[1] != '\0') {
+ strlcpy(ofilename, line + 1, sizeof(ofilename));
+ }
+ continue;
+ default: continue;
+ }
+ fseek(cfp, origfpos, 0); /* reset file pointer */
+ /*-------------------- JD */
+
switch (format) {
case 'p': /* print file using 'pr' */
if (IF == NULL) { /* use output filter */
***************
*** 674,679 ****
--- 697,707 ----
av[n++] = "-h";
av[n++] = fromhost;
av[n++] = AF;
+ /* added 20 Feb, 10 Mar 2003 - JD */
+ if (strcmp(ofilename, "") != 0) {
+ av[n++] = "-fn";
+ av[n++] = ofilename;
+ } /* JD */
av[n] = 0;
fo = pfd;
if (ofilter > 0) { /* stop output filter */
>Release-Note:
>Audit-Trail:
>Unformatted: