Summary2: How to print more than 80 char in a line

From: Benlu Jiang <jiang_at_csdeca.cs.missouri.edu>
Date: Thu, 19 Oct 1995 10:58:58 -0500

Several people are interested in the filter code.
I include Alex's printcap and hplaser.c below.

Benlu Jiang
-----------------
>From george_at_mms.water.ci.detroit.mi.us Wed Oct 18 08:24:07 1995
Received: by mms.water.ci.detroit.mi.us; id AA12044; Wed, 18 Oct 1995 09:22:23 -0400
Date: Wed, 18 Oct 1995 09:22:23 -0400 (EDT)
From: "Alex M. George" <george_at_mms.water.ci.detroit.mi.us>
To: Benlu Jiang <jiang_at_csdeca.cs.missouri.edu>
Subject: Re: How to print more than 80 char in a line
In-Reply-To: <9510172210.AA07639_at_csdeca.cs.missouri.edu>
Message-Id: <Pine.OSF.3.91.951018091535.23207A-100000_at_mms.water.ci.detroit.mi.us>
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Status: R

This is a copy of part of my /etc/printcap file. Note the if filters are
the one I made and the of filter stay the same as hplaserof. I am
sending the c sources in the following mail. Please cut the header and
the tail the line with (~~~~~~~~~~~~~~~~~~~) and the following. Compile
it in your system...

# cc -o hplaser hplaser.c
# cc -o hp4plus hp4plus.c
..........

and use the executable in the :if: in your printcap... I don't have a
filter for Hp4Si yet....

Hope this work for you and you are more welcome to modify the code to fit
your need. Have fun!!!
                                        Alex.

# Computer Services - Livernois Center
# Connected to HELEN at PORT_14
# HpLaserJetIIID
lp|lp0|0|Ted|ted|TED:\
        :af=/usr/adm/ted_acct:\
        :br#9600:\
        :ct=LAT:\
        :fc#0177777:\
        :fs#03:\
        :if=/info4/filters/hplaser:\
        :lf=/usr/adm/ted_err:\
        :lp=/dev/tty02:\
        :mx#0:\
        :of=/usr/lbin/hplaserof:\
        :pl#66:\
        :pw#200:\
        :rw:\
        :sd=/usr/spool/lpd_ted:\
        :sh:\
        :xc#0177777:\
        :xf=/usr/lbin/xf:\
        :xs#044000:
# HP LaserJet III in clerks at maintenance trailer
# Connection: PORT_15 on HECTOR as tty0c
lp4|4|clerk1|CLERK1:\
        :af=/usr/adm/clerk1_acct:\
        :br#9600:\
        :ct=LAT:\
        :fc#0177777:\
        :fs#023:\
        :if=/info4/filters/hplaser:\
        :lf=/usr/adm/clerk1_err:\
        :lp=/dev/tty0c:\
        :mx#0:\
        :of=/usr/lbin/hplaserof:\
        :op=PORT_15:\
        :pl#62:\
        :pw#200:\
        :sd=/usr/spool/lpd_clerk1:\
        :sh:\
        :ts=HECTOR:\
        :uv=4.0:\
        :xc#0177777:\
        :xf=/usr/lbin/xf:\
        :xs#044000:
# HP4Si High speed printer in maintenance trailer.
# Connection: PORT_11 on TROY, tty0d
lp5|5|plan1|PLAN1:\
        :af=/usr/adm/plan1_acct:\
        :br#9600:\
        :ct=LAT:\
        :fc#0177777:\
        :fs#03:\
        :if=/usr/lbin/hplaserof:\
        :lf=/usr/adm/plan1_err:\
        :lp=/dev/tty0d:\
        :mx#0:\
        :of=/usr/lbin/hplaserof:\
        :pl#66:\
        :rw:\
        :sd=/usr/spool/lpd_plan1:\
        :uv=4.0:\
        :xc#0177777:\
        :xf=/usr/lbin/xf:\
        :xs#044000:
# HP Laser printer at Shipping and Receiving.
# Connection: PORT_6 on HOMER, tty0a
lp7|7|stores2|STORES2:\
        :af=/usr/adm/stores2_acct:\
        :br#9600:\
        :ct=LAT:\
        :fc#0177777:\
        :fs#023:\
        :if=/info4/filters/hp4plus:\
        :lf=/usr/adm/stores2_err:\
        :lp=/dev/tty0a:\
        :mx#0:\
        :of=/usr/lbin/hplaserof:\
        :op=PORT_6:\
        :pl#62:\
        :pw#200:\
        :sd=/usr/spool/lpd_stores2:\
        :sh:\
        :ts=HOMER:\
        :uv=4.0:\
        :xc#0177777:\
        :xf=/usr/lbin/xf:\
        :xs#044000:\
        :uv=4.0:
# HP LaserJetIII printer located in the Maintenance Trailer
# Connection PORT_10 TROY tty0h - 10-25-94 - JR.
lp9|9|plan2|PLAN2:\
        :af=/usr/adm/plan2_acct:\
        :br#9600:\
        :ct=LAT:\
        :fc#0177777:\
        :fs#023:\
        :if=/info4/filters/hplaser:\
        :lf=/usr/adm/plan2_err:\
        :lp=/dev/tty0h:\
        :mx#0:\
        :of=/usr/lbin/hplaserof:\
        :sd=/usr/spool/lpd_plan2:\
        :uv=4.0:\
        :xc#0177777:\
        :xf=/usr/lib/lpdfilters/xf:\
        :xs#044000:
# HP Laser IV for Sr. Foreman at Maintenance Trailer
# Connection: HECTOR PORT_5 tty0i - 10-25-94 - JR.
lp10|10|maint1|MAINT1:\
        :af=/usr/adm/maint1_acct:\
        :br#9600:\
        :ct=LAT:\
        :fc#0177777:\
        :fs#23:\
        :if=/info4/filters/hplaser:\
        :lf=/usr/adm/maint1_err:\
        :lp=/dev/tty0i:\
        :mx#0:\
        :of=/usr/lbin/hplaserof:\
        :sd=/usr/spool/lpd_maint1:\
        :uv=4.0:\
        :xc#0177777:\
        :xf=/usr/lib/lpdfilters/xf:\
        :xs#044000:


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail Address: george_at_mms.water.ci.detroit.mi.us
Telephone: (313) 297-8398, 9204


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


/*******************************************************/
/* */
/* PROGRAM: hplazer4.c */
/* AUTHOR: Alex M. George */
/* DATE: December, 21, 1993 */
/* VERSION: 1.01 */
/* */
/* Designed by Alex George to work with landscape */
/* script on November, 23, 1993. */
/* */
/* This program creates a printer filter for the */
/* HPLazerJet printers. It will provide the */
/* capability for reports to be printed in landscape */
/* or in potrait accrding to the document send over. */
/* */
/* Modified on January 27, 1994 by Alex M. George to */
/* set the default pitch to 16.5-16.7 */
/*******************************************************/

#include <stdio.h>

#define MAXBUF 10000
void main ( /* int argc, char *argv [] */)
{
   int c, i = 0, j = 0, k = 0, length = 0, lines = 0, nlines, npages;
   char buffer[MAXBUF];


/* The following section put input in buffer and determine the longest
 * line of the text for font selection.
 * Code added by Alex M. George on 11-23-93.
 * Last edited by Alex M. George on 11-23-93.
 */
 
while (((c = getchar()) != '\f') && (c != EOF) && (i < MAXBUF))
{
        if ((c == '\n') || (c == '\r')) { /* end of a line */
                lines++; /* add one to line count */
                buffer[i++] = c; /* store character in buffer */
                if ( k > length) /* greater than longest read */
                        length = k;
                k = 0; /* reset line length counter */
        }
        else {
                buffer[i++] = c; /* store character in buffer */
                k++;
        }
}
if (c == '\f') { /* line feed back in buffer */
        buffer[i] = c;
}

printf ("\033\046\153\062\123"); /* pitch mode condensed 16.5-16.7 */

if (length <= 80) { /* potrait 12pts */
        printf ("\033\046\154\060\117"); /* portrait */
        printf ("\033\050\163\064\060\071\071\124"); /* select courier font*/
/* printf ("\033\046\15312\110"); /* select HMI 10 cpi */
        printf ("\033\050\163\012"); /* 10 cpi-removed \110 */
}
else if (length <= 96) { /* potrait 10pts */
        printf ("\033\046\154\060\117"); /* portrait */
        printf ("\033\050\163\064\060\071\071\124"); /* select courier font*/
/* printf ("\033\046\15310\110"); /* select HMI 12 cpi */
        printf ("\033\050\163\014"); /* 12 cpi-removed \110 */
}
else if (length <= 100) { /* landscape 12pts */
        printf ("\033\046\154\061\117"); /* landscape */
        printf ("\033\046\1411\120"); /* rotate 90 degrees */
        printf ("\033\050\163\064\060\071\071\124"); /* select courier font*/
/* printf ("\033\046\15312\110"); /* select HMI 10 cpi */
        printf ("\033\050\163\012"); /* 10 cpi-removed \110 */
}
else if (length <= 120) { /* landscape 10pts */
/* printf ("\033\046\154\061\117"); /* landscape */
        printf ("\033\046\1411\120"); /* rotate 90 degrees */
        printf ("\033\050\163\064\060\071\071\124"); /* select courier font*/
/* printf ("\033\050\163\064\061\060\062\124"); /*select letter gothic*/
/* printf ("\033\046\15310\110"); /* select HMI 12 cpi */
        printf ("\033\050\163\014"); /* 12 cpi-removed \110 */
}
else if (length <= 164) { /* landscape 8pts */
        printf ("\033\046\154\061\117"); /* landscape */
        printf ("\033\046\1411\120"); /* rotate 90 degrees */
        printf ("\033\050\163\064\060\071\071\124"); /* select courier font*/
/* printf ("\033\050\163\064\061\060\062\124"); /*select letter gothic*/
/* printf ("\033\046\1538\110"); /* select HMI 15 cpi */
        printf ("\033\050\163\017"); /* 15 cpi-remove \110 */
}
else { /* landscape 8pts with 17 cpi */
        printf ("\033\046\154\061\117"); /* landscape */
        printf ("\033\046\1411\120"); /* rotate 90 degrees */
        printf ("\033\050\163\064\060\071\071\124"); /* select courier font*/
/* printf ("\033\050\163\064\061\060\062\124"); /*select letter gothic*/
/* printf ("\033\046\1537\110"); /* select HMI 17 cpi */
        printf ("\033\050\163\021"); /* 17 cpi-removed \110 */
}

if (length >= 100) { /* only for landscape printing */
        if (lines <= 45)
                printf ("\033\046\154\066\104"); /* 45 lines/page */
        else /* if (lines <= 60) */
                printf ("\033\046\154\070\104"); /* 60 lines/page */
/* else printf ("\033\046\154\061\062\104"); /* 90 lines/page */
}


for (k = 0; i >= k; k++)
        printf ("%c", buffer[k]);




   /* loop through remaining data. */

if ( c != EOF) /* if buffer hits eof then forget it */
  while ((c = getchar()) != EOF)
      {
      if ( c == '\n' || c == '\r' )
         nlines++;
      if ( nlines > length || c == '\f' )
         {
         nlines = 0;
         npages++;
         }
      putchar (c);
      }
   /* Reset printer back into normal mode. */
        printf ("\033\046\154\060\117"); /* portrait */
        printf ("\033\050\163\064\060\071\071\124"); /* select courier font*/
        printf ("\033\046\15312\110"); /* select HMI 10 cpi */
/* printf ("\033\046\153\060\110"); /* select pitch back to 10 */
        printf ("\033\046\154\070\104"); /* 60 lines/page */
   
}



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
E-Mail Address: george_at_mms.water.ci.detroit.mi.us
Telephone: (313) 297-8398, 9204
Received on Thu Oct 19 1995 - 17:39:49 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:46 NZDT