Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!parc.xerox.com!janssen From: janssen@parc.xerox.com (Bill Janssen) Newsgroups: comp.soft-sys.andrew Subject: ez -> text Message-ID: Date: 13 Dec 90 01:28:18 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 59 Thanks to Nathaniel for providing the insight into the UnScribe routines I've been waiting for. I re-wrote his code a bit, turning it into even a simpler program, that just unscribes (called ez2text). Now it's easy to wrap in a shell script, to do what ezview does, and even more (mine sets up the CLASSPATH, and defines LD_LIBRARY_PATH, etc.). Enjoy. Imakefile: ====================================================================== OBJS2 = ez2text.o CFLAGS = -Bstatic LIBS= ${BASEDIR}/lib/libmail.a ${UTILLIB} NormalObjectRule() ProgramTarget(ez2text, ${OBJS2}, ${LIBS} , ) DependTarget() InstallProgram(ez2text, ${DESTDIR}/bin) C code: ====================================================================== #include #include /* from andrew distribution */ #include /* Compile this with cc -I$ANDREWDIR/include ez2text.c $ANDREWDIR/lib/libmail.a $ANDREWDIR/lib/libutil.a -o ez2text */ main(argc, argv) int argc; char **argv; { struct ScribeState ScribeState; int bytes, code, fd; char BigBuf[5000]; if (argc < 2) { fprintf (stderr, "Usage: ez2text filename\n"); exit(1); } fd = open(argv[1], O_RDONLY); if (fd < 0) { fprintf (stderr, "ez2text: Couldn't open file %s.\n", argv[1]); 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); close (fd); exit(0); }