🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.soft-sys.andrew
Article #1279

New program: ezview

#1279
From: Nathaniel Borenstein
Date: Tue, 11 Dec 1990 19:27
69 lines
2612 bytes
I've written a very tiny new program that is actually quite useful. 
Called "ezview", it will run ezview on a file if ez can be run, and will
otherwise use the "unscribe" routines to display (on stdout) the
"unformatted" version of a file.  This yields a single program that
anyone can run to view an ATK file -- if they're running X and ez is
installed, it will simply run ez, but otherwise it will show them
something prettier than the raw datastream (e.g. with "A raster appeared
here but could not be displayed.")

To add this program to your distribution, you only need to do four things:

1.  Modify contrib/Imakefile to include "ezview" on the SUBDIRS line.

2.  Create contrib/ezview.

3.  Put two new files (Imakefile and ezview.c) into contrib/ezview.

4.  Recompile (easiest way is to cd to contrib and type "make Makefiles
SUBDIR=ezview", and then cd to contrib/ezview and type "make Install".)

The two new files, both very tiny, follow below:

________________________________________________________________
Imakefile:
________________________________________________________________
OBJS               =       ezview.o

LIBS= \
        ${BASEDIR}/lib/libmail.a \
    ${UTILLIB}

NormalObjectRule()

ProgramTarget(ezview, ${OBJS}, ${LIBS} , )

DependTarget()

InstallProgram(ezview, ${DESTDIR}/bin)
________________________________________________________________
ezview.c
________________________________________________________________
#include <stdio.h>
#include <mail.h> /* from andrew distribution */
#include <sys/file.h>

/* Compile this with cc -I$ANDREWDIR/include ezview.c
$ANDREWDIR/lib/libmail.a $ANDREWDIR/lib/libutil.a -o ezview */

main(argc, argv)
int argc;
char **argv;
{
    struct ScribeState ScribeState;
    int bytes, code, fd;
    char BigBuf[5000];

    if (argc < 2) exit(-1);
    sprintf(BigBuf, "ez -d %s", argv[1]);
    if (!getenv("DISPLAY") || system(BigBuf)) {
	fd = open(argv[1], O_RDONLY);
	if (fd < 0) exit(-1);
	code = UnScribeInit("12", &ScribeState);
	while ((bytes = read(fd, BigBuf, sizeof(BigBuf) - 1)) > 0) {
	    UnScribe(code, &ScribeState, BigBuf, bytes, stdout);
	}
	UnScribeFlush(code, &ScribeState, stdout);
    }
    exit(0);
}
Technical Details
Message-ID: <EbNHANi0M2Yt84WL0w@thumper.bellcore.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!THUMPER.BELLCORE.COM!nsb

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!ogicse!ucsd!ucbvax!THUMPER.BELLCORE.COM!nsb
From: nsb@THUMPER.BELLCORE.COM (Nathaniel Borenstein)
Newsgroups: comp.soft-sys.andrew
Subject: New program:  ezview
Message-ID: <EbNHANi0M2Yt84WL0w@thumper.bellcore.com>
Date: 11 Dec 90 19:27:21 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The Internet
Lines: 69