Date: Fri, 7 Mar 2003 17:44:08 -0600 (CST) From: jimd@siu.edu To: FreeBSD-gnats-submit@FreeBSD.org Subject: i386/49023: Mod to LPD (printjob.c) to pass source filename to input filters Message-ID: <200303072344.h27Ni82b042657@dutton3.it.siu.edu>
next in thread | raw e-mail | index | archive | help
>Number: 49023 >Category: i386 >Synopsis: Mod to LPD (printjob.c) to pass source filename to input filters >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Fri Mar 07 15:40:01 PST 2003 >Closed-Date: >Last-Modified: >Originator: JD >Release: FreeBSD 4.7-RELEASE i386 >Organization: >Environment: System: FreeBSD xxxxxxxxx 4.7-RELEASE FreeBSD 4.7-RELEASE #2: Thu Jan 30 14:21:04 CST 2003 xxxx:/usr/src/sys/compile/XSYSTEM i386 >Description: Add small section to PRINTJOB.C in /usr/src/usr.sbin/lpr/lpd to extract the source file name from the (LPD) control file and pass it to the input filter, along with another "identifying" parameter, at the end of the current/normal parameter string. The last two parameters below are what get added to the input filter parameter list: -w132 -l66 -i0 -n xxxx -h xxxx /var/account/lp.printacct -fn .cshrc This will allow remote LPD's to do special actions on print files based on their original source file name, and is really intended for use in an input filter so it can achieve specialization without having to use other, external, methods to derive meaningful identifying information about the file waiting for it on STDIN. >How-To-Repeat: >Fix: *** printjob.c.orig Wed Feb 19 17:42:35 2003 --- printjob.c Fri Mar 7 16:53:30 2003 *************** *** 114,119 **** --- 114,121 ---- /* 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 */ *************** *** 439,445 **** */ /* pass 1 */ - while (getline(cfp)) switch (line[0]) { case 'H': --- 441,446 ---- *************** *** 479,485 **** } else strcpy(jobname, " "); continue; - case 'C': if (line[1] != '\0') strlcpy(class, line + 1, sizeof(class)); --- 480,485 ---- *************** *** 645,650 **** --- 645,674 ---- (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)); + } + else strcpy(ofilename, " "); + continue; + default: continue; + } + fseek(cfp, origfpos, 0); /* reset file pointer */ + /*-------------------- JD */ + switch (format) { case 'p': /* print file using 'pr' */ if (pp->filters[LPF_INPUT] == NULL) { /* use output filter */ *************** *** 780,785 **** --- 804,811 ---- av[n++] = "-h"; av[n++] = origin_host; av[n++] = pp->acct_file; + av[n++] = "-fn"; /* added 20 Feb 2003 - JD */ + av[n++] = ofilename; /* added 20 Feb 2003 - JD */ av[n] = 0; fo = pfd; if (of_pid > 0) { /* stop output filter */ >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303072344.h27Ni82b042657>