[comp.soft-sys.andrew] ez -> text

janssen@parc.xerox.com (Bill Janssen) (12/13/90)

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 <stdio.h>
#include <mail.h> /* from andrew distribution */
#include <sys/file.h>

/* 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);
}

Craig_Everhart@TRANSARC.COM (12/13/90)

Doing ``make unscribe.test'' in the {andrew}/overhead/mail/lib build
directory will make a program functionally equivalent to Bill's
``ez2text'', with perhaps somewhat different calling conventions.

At present, the UnScribe package has no dependencies on ATK or dynamic
loading, so you don't have to set CLASSPATH or anything else.  This is a
weakness as well as a strength, I know.

		Craig

wjh+@ANDREW.CMU.EDU (Fred Hansen) (12/14/90)

In keeping with other ATK program names, a good name for ez->text might be

	fromez

It could have switches for varioius optional output formats.  (Of course
ezprint is already this.  It could have a -ASCII switch to output text.)

Fred Hansen