From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 104d8a,dde16de6b4e3421c X-Google-Attributes: gid104d8a,public X-Google-Thread: 1164f8,dde16de6b4e3421c X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1993-12-02 06:48:51 PST Xref: gmd.de comp.periphs.printers:7010 comp.sys.dec:12179 Newsgroups: comp.periphs.printers,comp.sys.dec Path: gmd.de!newsserver.jvnc.net!yale.edu!nigel.msen.com!sdd.hp.com!vixen.cso.uiuc.edu!newsrelay.iastate.edu!news.iastate.edu!vislab.me.iastate.edu!pbergan From: pbergan@iastate.edu (Patrick J Bergan) Subject: Re: laserjet 4, jetdirect card and ultrix Message-ID: Sender: news@news.iastate.edu (USENET News System) Organization: Iowa State University, Ames IA References: <1993Dec1.150351.11039@roxi.rz.fht-mannheim.de> Date: Thu, 2 Dec 1993 14:24:49 GMT In <1993Dec1.150351.11039@roxi.rz.fht-mannheim.de> andre@borneo.dkfz-heidelberg.de (Andre Schroeter) writes: >i'm searching for drivers to print to a lj4 with a jet direct card from >ultrix. >who can help me?? Here you go. ----------------------------------------------------------- /* * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef lint char copyright[] = "@(#) Copyright (c) 1983 Regents of the University of California.\n\ All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)hplaserf.c 5.3 (Berkeley) 6/30/88"; #endif /* not lint */ /* * Filter that prints on a network print server. * The account file name is actually the hostname for the printer * It expects a line like: * hplaser 9100/tcp * in the /etc/services file * and an entry as follows in /etc/printcap hp|hp laserjetIII:\ :lp=/dev/null:sd=/usr/spool/hplaserd:lf=/var/log/lpd-errs:\ :if=/usr/libexec/lpr/hplaserf:\ :cf=/usr/libexec/lpr/hpsinglef:\ :vf=/usr/libexec/lpr/hpreversef:\ :mx#10000: * where hplaserf, hpsinglef and hpreversef are all links to the a.out * for this program. * This overloads the lpr command options such that: * -v prints in landscape * and -c prints single sided (the default is duplex) */ #include #include #include #include #include #include #include #include #include #define LINSIZ 2048 #define RETRYIT 1 #define notyet extern int errno; char buf[LINSIZ+1]; char *name; /* user's login name */ char *host; /* user's machine name */ char *acctfile=NULL; /* accounting information file */ main(argc, argv) int argc; char *argv[]; { register FILE *p = stdin, *sof; register int i, so; register char *cp; struct sockaddr_in saddr; struct hostent *hp; struct servent *sp; long timev; struct tm *tp; int tryagain; char *initstr; /* * The process name determines the printer configuration: * hplaserf - both sides, long bind (same way up) * hpsinglef - single sided * hpreversef - both sides, short bind (back page upside down) */ if (strcmp(*argv, "hpsinglef") == 0) initstr = "statusdict begin\nfalse setduplexmode\n"; else if (strcmp(*argv, "hpreversef") == 0) initstr = "statusdict begin\ntrue settumble\n"; else initstr = (char *)0; while (--argc) { if (*(cp = *++argv) == '-') { switch (cp[1]) { case 'n': argc--; name = *++argv; break; case 'h': argc--; host = *++argv; break; case 'w': break; case 'l': break; case 'i': break; case 'c': /* Print control chars */ break; } } else if (acctfile == NULL) /* first non-switched arg only */ acctfile = cp; } openlog("Hplaser: ", LOG_PID, LOG_ERR); /* Set up the socket */ do { if ((so = socket(AF_INET, SOCK_STREAM, 0)) < 0) { syslog(LOG_ERR, "Can't create socket"); exit(RETRYIT); } #ifdef notyet if ((hp = gethostbyname(acctfile)) == NULL) { syslog(LOG_ERR, "Can't get hostname '%s'",acctfile); exit(RETRYIT); } #else saddr.sin_addr.s_addr = inet_addr("129.186.2.132"); #endif if ((sp = getservbyname("hplaser", "tcp")) == NULL) { syslog(LOG_ERR, "Can't find portnum"); exit(RETRYIT); } saddr.sin_family = AF_INET; #ifdef notyet bcopy(hp->h_addr, &saddr.sin_addr, hp->h_length); #endif saddr.sin_port = sp->s_port; /* * Try to connect: * - if the connection fails loop so that lpd will try again */ if (connect(so, &saddr, sizeof(saddr)) < 0) { shutdown(so, 2); close(so); tryagain = 1; } else tryagain = 0; } while (tryagain); /* * Send initialization string, if any */ if (initstr && write(so, initstr, strlen(initstr)) < 0) { syslog(LOG_ERR, "Can't write to socket"); exit(RETRYIT); } /* * Send the file */ while ((i = fread(buf, sizeof(char), LINSIZ, p)) > 0) { if (write(so, buf, i) < 0) { syslog(LOG_ERR, "Write failed"); exit(RETRYIT); } } close(so); exit(0); } --------------------------------------------------------------- pbergan@iastate.edu --