nsb@THUMPER.BELLCORE.COM (Nathaniel Borenstein) (12/12/90)
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); }