Article View: comp.text
Article #142Re: Need escape code for software switching of Postscript cartridges
From: Ronald Florence
Date: Tue, 07 Apr 1992 12:09
Date: Tue, 07 Apr 1992 12:09
89 lines
3091 bytes
3091 bytes
UMAB-BIOPHYS writes:
I recently acquired a HP C2089A Postscript Cartridge which I am
using with a HPLasterJet III printer. I also use a PacificPage
Postscript Cartridge with HPLazerJet IIID printer. [...]
Can someone please post germane details or perhaps send me a model
interface routine for a unix environment containing an example
of how the software switching is done.
This works on our small Sun network, running Sunos 4.1.1, with an
HPIIp and a PacificPage Postscript cartridge. The code detects
whether the file is Postscript or HP native-mode, and shifts the
printer state. Don't forget to create the STATEFILE before running
the filter.
----------------------------[lpIIp.c]---------------------------
/*
* lpIIp.c
* lpr (BSD or SunOS) "if" filter for lpIIp with Postscript cartridge
* Reads opening characters of file, checks STATEFILE, and issues
* sequence to shift to hp or postscript mode as needed.
*
* Use in /etc/printcap entry:
* lp|printer|oga-printer:\
* :lp=/dev/ttya:br#19200:ms=-parity:sh:mx#2000:\
* :if=/usr/local/bin/lpIIp:lf=/usr/adm/lpd-errs:
*
* ron@mlfarm.com, 26 Jun 1991
*/
#include <stdio.h>
#define STATEFILE "/var/spool/lpd/STATEFILE"
#define HPTOPS "\033E\033&l5257.1058J"
#define PSTOHP "\033&l1057.32259J"
#define HPTIMEOUT 30
#define HPRESET "\033E\033&k2G\033&l0l6d0E" /* reset, line-endings, */
/* portrait mode, 6 */
/* lines/inch, no top margin */
main()
{
char id[3], *mode, state[12];
FILE *sf;
int i, c, status = 0;
for (i=0; i <=2; i++)
id[i] = getchar();
if (!strncmp(id, "%!", 2))
mode = "postscript";
else mode = "hp";
if (!(sf = fopen(STATEFILE, "r")))
strcpy(state, "unknown");
else fgets(state, sizeof(state), sf);
(void) fclose(sf);
if (strncmp(state, mode, strlen(mode)))
{
if (!strcmp(mode, "hp"))
{
sleep(HPTIMEOUT);
fputs(PSTOHP, stdout);
}
else fputs(HPTOPS, stdout);
fflush(stdout);
if (!(sf = fopen(STATEFILE, "w")))
perror(STATEFILE);
else
{
fputs(mode, sf);
fputs("\n", sf);
(void) fclose(sf);
}
sleep(60);
if (!strcmp(mode, "hp"))
fputs(HPRESET, stdout);
}
for (i=0; i <=2; i++)
putchar(id[i]);
while ((c = getchar()) != EOF)
putchar(c);
if (!strcmp(mode, "hp"))
fputs("\033E", stdout);
else fputs("\04", stdout);
exit(0);
}
------------------------------[eof]-----------------------------
--
Ronald Florence
ron@mlfarm.com
Technical Details
Message-ID:
<1992Apr7.120908.6265@mlfarm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!hsi!mlfarm!rosie!ronReferences:
<1992Apr6.164518.1486@umbc3.umbc.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.text Path: arc1-ca.pugleaf.net!sparky!uunet!hsi!mlfarm!rosie!ron From: ron@mlfarm.com (Ronald Florence) Subject: Re: Need escape code for software switching of Postscript cartridges In-Reply-To: hybl@umbc4.umbc.edu's message of Mon, 6 Apr 1992 16:45:18 GMT Message-ID: <1992Apr7.120908.6265@mlfarm.com> Sender: news@rosie.mlfarm.com Organization: Maple Lawn Farm, Stonington, CT References: <1992Apr6.164518.1486@umbc3.umbc.edu> Date: Tue, 7 Apr 1992 12:09:08 GMT Lines: 89