v12i007: DVI2TTY: Part 1 of 2; supports VMS and symbol fonts

Marcel Mol marcel at duteca.tudelft.nl
Sat Apr 14 09:08:55 AEST 1990


Posting-number: Volume 12, Issue 7
Submitted-by: marcel at duteca.tudelft.nl (Marcel Mol)
Archive-name: dvi2tty2/part01

This is a new verion of dvi2tty. It includes a port to support VMS. I cannot
test it on VMS so I hope it still works. Furthermore this version supports
symbol fonts to a certain extend. Output of itemized lists and math (although
not right yet) are much more readable now.

-Marcel

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 2)."
# Contents:  README README.ORG DVI.format MANIFEST Makefile disdvi.c
#   dvi2tty.c commands.h
# Wrapped by marcel at duteca on Thu Mar  1 23:08:07 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1999 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X                DVI2TTY
X
X
Xdvi2tty is intended for previewing dvi-files on text-only
Xdevices (terminals and lineprinters).
XThe program is basicly an improved C version of the pascal
Xprogram written by Svante Lindahl (see README.ORG).
XI translated it because I could not find a pascal compiler 
Xon our machine that could compile it.
XThe program runs under UNIX and MSDOS without problems
XIt should also run under VMS. 
X(you may need some site dependend redefinitions, see below).
XUndocumented option: the -e option can be used to influence
Xthe width of spaces. With a negative value the number of spaces 
Xbetween words becomes less, with a positive value it becomes more.
XJust play around if you like, -e-11 worked nice with me.
X
X
X                DISDVI
X
XDisdvi is a simple hack that dumps a dvi file in a more readable form.
XIt is not a spectacular program but use it and improve as you wish.
XI'd appreciate any enhancements made, bug reports etc. mailed to me.
X  
X
X    COMPILING THE PROGRAMS
X
XDisdvi is rather simple and does not need any modifications.
XTo compile under VMS, you might need to define an extra macro:
XAdd a -DVMS on the command line, or add a line
X#define VMS
Xin the dvi2tty.h file.
XFor dvi2tty you may find the following problems:
X
X function strchr() can not be found:
X      Your are probably a BSD UNIX or alike.
X      Solution: #define strchr index
X '/usr/bin/pg' program not found.
X      Solution: change the DEFPAGER macro in dvi2tty.c
X To compile under VMS, you might need to define an extra macro:
X  Add a -DVMS on the command line, or add a line
X  #define VMS
X
XThats all, good luck.
X
X
X- Marcel 
X-----------------------------------------
X| Marcel J.E. Mol                       | They hate you if your're clever
X| Delft University of Technology        | And they despise the fool
X| The Netherlands                       | Till you're so fucking crazy
X| UUCP: marcel at duteca.tudelft.nl        | You can't follow the rules.
X-----------------------------------------			 - Lennon
END_OF_FILE
echo shar: 1 control character may be missing from \"'README'\"
if test 1999 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'README.ORG' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README.ORG'\"
else
echo shar: Extracting \"'README.ORG'\" \(1051 characters\)
sed "s/^X//" >'README.ORG' <<'END_OF_FILE'
X
Xdvitty is intended for previewing dvi-files on text-only devices
X(terminals and lineprinters). The output is not very pretty many
Xtimes, but it still saves quite a lot of work, especially if you
Xhave a little ways to walk to a laserprinter, for example.
X
XThe program was originally written in Hedrick-Pascal, running on
XTOPS-20, and was later ported to UNIX (BSD, Berkeley-pascal).
X
XIt is not very smart in all situations, but still serves it pur-
Xpose fairly well.
X
XFor information on how to use see the man-page.
X
XBefore compiling and installing inspect the  "compile-time cust-
Xomization constants" and change them to suit your site.
XThese constants configure default pager and a little more.
X
XPlease report complaints, suggestions, bugs and/or fixes to:
X
XSvante Lindahl, NADA, KTH            Numerical Analysis & Computer Science 
XUUCP: {seismo,mcvax}!enea!ttds!zap   Royal Institute of Technology, Sweden
XARPA: enea!ttds!zap at seismo.CSS.GOV   EAN: zap at cs.kth.sunet
X
XThe TOPS-20 version of the program can also be obtained from the above
Xaddress.
END_OF_FILE
if test 1051 -ne `wc -c <'README.ORG'`; then
    echo shar: \"'README.ORG'\" unpacked with wrong size!
fi
# end of 'README.ORG'
fi
if test -f 'DVI.format' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'DVI.format'\"
else
echo shar: Extracting \"'DVI.format'\" \(2573 characters\)
sed "s/^X//" >'DVI.format' <<'END_OF_FILE'
X/*
X
X
X================================================================================
X==                          DVI file format                                   ==
X================================================================================
Xno_ops          >= 0 bytes     (NOP, nops before the preamble)
Xpreamble_marker    1 ubyte     (PRE)
Xversion_id         1 ubyte     (should be version 2)
Xnumerator          4 ubytes    (numerater must equal the one in postamble)
Xdenominator        4 ubytes    (denominator must equal the one in postamble)
Xmagnification      4 ubytes    (magnification must equal the one in postamble)
Xid_len             1 ubyte     (lenght of identification string)
Xid_string     id_len ubytes    (identification string)
X
Xno_ops          >= 0 bytes     (NOP, nops before a page)
Xbegin_of_page      1 ubyte     (BOP)
Xpage_nr            4 sbytes    (page number)
Xdo_be_do          36 bytes     (filler ????)
Xprev_page_offset   4 sbytes    (offset in file where previous page starts, -1 for none)
X... PAGE DATA ...
Xend_of_page        1 ubyte     (EOP)
X
Xno_ops ???      >= 0 bytes     (NOPS, I think they are allowed here...)
Xpostamble_marker   1 ubyte     (POST)
Xlast_page_offset   4 sbytes    (offset in file where last page starts)
Xnumerator          4 ubytes    (numerater must equal the one in preamble)
Xdenominator        4 ubytes    (denominator must equal the one in preamble)
Xmagnification      4 ubytes    (magnification must equal the one in preamble)
Xmax_page_height    4 ubytes    (maximum page height)
Xmax_page_width     4 ubytes    (maximum page width)
Xmax_stack          2 ubytes    (maximum stack depth needed)
Xtotal_pages        2 ubytes    (number of pages in file)
X... FONT DEFINITIONS ...
X
Xpostamble_offset   4 sbytes    (offset in file where postamble starts)
Xversion_id         1 ubyte     (should be version 2)
Xtrailer         >= 4 ubytes    (TRAILER)
X<EOF>
X
X
XFONT DEFINITIONS:
X   do {
X      switch (c = getc(dvi_fp) {
X          case FNTDEF1  :
X          case FNTDEF2  :
X          case FNTDEF3  :
X          case FNTDEF4  :  define_font(c);
X          case POSTPOST : break;
X          default       : error;
X      }
X   } while (c != POSTPOST);
X
X===== A font def looks like:
X
X1,2,3 or 4 ubytes TeXfontnumber for FNTDEF1 .. FNTDEF4
X4 ubytes checksum
X4 ubytes scale
X4 ubytes design size
X1 byte deflen1
X1 byte deflen2
Xdeflen1 + deflen2 bytes fontname.
X
X===== A special looks like:
X
X1,2,3 or 4 ubytes telling length of special command for XXX1 .. XXX4
Xall bytes in the special command are used as defined in the dvi driver.
X
X
X*/
END_OF_FILE
if test 2573 -ne `wc -c <'DVI.format'`; then
    echo shar: \"'DVI.format'\" unpacked with wrong size!
fi
# end of 'DVI.format'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(437 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X README                     1	
X README.ORG                 1	
X DVI.format                 1	
X MANIFEST                   1	
X Makefile                   1	
X disdvi.c                   1	
X dvi2tty.c                  1	
X dvistuff.c                 2	
X commands.h                 1	
X dvi2tty.h                  2	
X dvi2tty.1                  2	
END_OF_FILE
if test 437 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(454 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile for dvi2tty and disdvi       23/01/89   M.J.E. Mol
X#
X# For BSD Unix use the following CFLAGS definition
X# CFLAGS = -Dstrchr=index
X#
X# This Makefile does not work for MSDOS. Make your 
X# own one, or compile by hand.
X#
XCFLAGS = 
X
Xall:	dvi2tty disdvi
X
Xdvi2tty:dvi2tty.o dvistuff.o
X	cc -o dvi2tty dvi2tty.o dvistuff.o
X
Xdisdvi:disdvi.c commands.h
X	cc -o disdvi disdvi.o
X
Xdvi2tty.o: dvi2tty.c dvi2tty.h
X
Xdvistuff.o: dvistuff.c dvi2tty.h commands.h
X
END_OF_FILE
if test 454 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'disdvi.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'disdvi.c'\"
else
echo shar: Extracting \"'disdvi.c'\" \(14923 characters\)
sed "s/^X//" >'disdvi.c' <<'END_OF_FILE'
X/*****************************************************************************/
X/*                                                                           */
X/*   disdvi  ---  disassembles TeX dvi files.                                */
X/*                                                                           */
X/*                                                                           */
X/*    2.0 23/01/89 M.J.E. Mol (c) 1989              marcel at duteca.tudelft.nl */
X/*    2.1 19/01/90 M.J.E. Mol    Maintain a list of fonts and                */
X/*                               show fontnames in font changes.             */
X/*                               Show character code when printing ligatures */
X/*                                                                           */
X/*                                                                           */
X/*****************************************************************************/
X
X
Xchar *disdvi = "@(#) disdvi.c  2.1 19/01/90 M.J.E. Mol (c) 1989, 1990";
X
X#include <stdio.h>
X#include <ctype.h>
X#include "commands.h"
X#if defined(MSDOS)
X#include <stdlib.h>
X#include <string.h>
X#include <fcntl.h>
X#endif
X
X#define LASTCHAR        127    /* max dvi character, above are commands    */
X
X#define get1()           num(1)
X#define get2()           num(2)
X#define get3()           num(3)
X#define get4()           num(4)
X#define sget1()         snum(1)
X#define sget2()         snum(2)
X#define sget3()         snum(3)
X#define sget4()         snum(4)
X
Xtypedef struct _font {
X    long    num;
X    struct _font * next;
X    char  * name;
X} font;
X
Xfont * fonts = NULL;
XFILE * dvifp;
Xchar * dvi_name;
Xlong   pc = 0;
X
Xchar *          malloc          ();
X
Xvoid            main            ();
Xvoid            bop             ();
Xvoid            preamble        ();
Xvoid            postamble       ();
Xvoid            postpostamble   ();
Xvoid            fontdef         ();
Xchar *          fontname        ();
Xvoid            special         ();
Xvoid            printnonprint   ();
Xunsigned long   num             ();
Xlong            snum            ();
X
X
X
X
X/*---------------------------------------------------------------------------*/
X
Xvoid main(argc, argv)
Xint argc;
Xchar **argv;
X{
X    register int opcode;                /* dvi opcode                        */
X    register int i;
X    int fontnum;
X
X    if (argc > 2) {
X        fprintf(stderr, "To many arguments\n");
X        fprintf(stderr, "Usage: %s [dvi-file]\n", *argv);
X        exit(1);
X    }
X
X    if (argc == 2) {
X        if ((i = strlen(argv[1])) == 0) {
X            fprintf(stderr, "Illegal empty filename\n");
X            fprintf(stderr, "Usage: %s [dvi-file]\n", *argv);
X            exit(2);
X        }
X        if ((i >= 5) && (argv[1][i-4] == '.') && (argv[1][i-3] == 'd') &&
X              (argv[1][i-2] == 'v') && (argv[1][i-1] == 'i'))
X            dvi_name = argv[1];
X        else {
X            dvi_name = malloc((i+5) * sizeof(char));
X            strcpy(dvi_name, argv[1]);
X            strcat(dvi_name, ".dvi");
X        }
X        if ((dvifp = fopen(dvi_name, "r")) == NULL) {
X            perror(dvi_name);
X            exit(3);
X        }
X    }
X    else
X        dvifp = stdin;
X
X#if defined(MSDOS)
X    setmode(fileno(dvifp), O_BINARY);
X#endif
X
X    while ((opcode = (int) get1()) != EOF) {    /* process until end of file */
X        printf("%06ld: ", pc - 1);
X        if ((opcode <= LASTCHAR) && isprint(opcode)) {
X            printf("Char:     ");
X            while ((opcode <= LASTCHAR) && isprint(opcode)) {
X                putchar(opcode);
X                opcode = (int) get1();
X            }
X            putchar('\n');
X            printf("%06ld: ", pc - 1);
X        }
X
X        if (opcode <= LASTCHAR) 
X            printnonprint(opcode);              /* it must be a non-printable */
X        else if ((opcode >= FONT_00) && (opcode <= FONT_63)) 
X            printf("FONT_%02d              /* %s */\n", opcode - FONT_00,
X                                    fontname(opcode - FONT_00));
X        else
X            switch (opcode) {
X                case SET1     :
X                case SET2     : 
X                case SET3     :
X                case SET4     : printf("SET%d:    %ld\n", opcode - SET1 + 1,
X                                                       num(opcode - SET1 + 1));
X                                break;
X                case SET_RULE : printf("SET_RULE: height: %ld\n", sget4());
X                                printf("%06ld: ", pc);
X                                printf("          length: %ld\n", sget4());
X                                break;
X                case PUT1     :
X                case PUT2     :
X                case PUT3     :
X                case PUT4     : printf("PUT%d:     %ld\n", opcode - PUT1 + 1,
X                                                       num(opcode - PUT1 + 1));
X                                break;
X                case PUT_RULE : printf("PUT_RULE: height: %ld\n", sget4());
X                                printf("%06ld: ", pc);
X                                printf("          length: %ld\n", sget4());
X                                break;
X                case NOP      : printf("NOP\n");  break;
X                case BOP      : bop();            break;
X                case EOP      : printf("EOP\n");  break;
X                case PUSH     : printf("PUSH\n"); break;
X                case POP      : printf("POP\n");  break;
X                case RIGHT1   :
X                case RIGHT2   : 
X                case RIGHT3   : 
X                case RIGHT4   : printf("RIGHT%d:   %ld\n", opcode - RIGHT1 + 1,
X                                                     snum(opcode - RIGHT1 + 1));
X                                break;
X                case W0       : printf("W0\n");   break;
X                case W1       : 
X                case W2       :
X                case W3       :
X                case W4       : printf("W%d:       %ld\n", opcode - W0,
X                                                      snum(opcode - W0));
X                                break;
X                case X0       : printf("X0\n");   break;
X                case X1       :
X                case X2       :
X                case X3       :
X                case X4       : printf("X%d:       %ld\n", opcode - X0,
X                                                      snum(opcode - X0));
X                                break;
X                case DOWN1    : 
X                case DOWN2    : 
X                case DOWN3    :
X                case DOWN4    : printf("DOWN%d:    %ld\n", opcode - DOWN1 + 1,
X                                                      snum(opcode - DOWN1 + 1));
X                                break;
X                case Y0       : printf("Y0\n");   break;
X                case Y1       :
X                case Y2       :
X                case Y3       :
X                case Y4       : printf("Y%d:       %ld\n", opcode - Y0,
X                                                      snum(opcode - Y0));
X                                break;
X                case Z0       : printf("Z0\n");   break;
X                case Z1       :
X                case Z2       :
X                case Z3       : 
X                case Z4       : printf("Z%d:       %ld\n", opcode - Z0,
X                                                      snum(opcode - Z0));
X                                break;
X                case FNT1     :
X                case FNT2     :
X                case FNT3     :
X                case FNT4     : fontnum = num(opcode -FNT1 + 1);
X                                printf("FNT%d:     %ld    /* %s */\n",
X                                       opcode - FNT1 + 1, fontnum,
X                                       fontname(fontnum));
X                                break;
X                case XXX1     : 
X                case XXX2     : 
X                case XXX3     :
X                case XXX4     : special(opcode - XXX1 + 1);     break;
X                case FNT_DEF1 :
X                case FNT_DEF2 :
X                case FNT_DEF3 :
X                case FNT_DEF4 : fontdef(opcode - FNT_DEF1 + 1); break;
X                case PRE      : preamble();                     break;
X                case POST     : postamble();                    break;
X                case POST_POST: postpostamble();                break;
X            }
X    }
X
X} /* main */
X
X
X/*----------------------------------------------------------------------------*/
X
X
Xvoid bop()
X{
X    int i;
X
X    printf("BOP       page number      : %ld", sget4());
X    for (i=0; i < 9; i++) {
X        if (i % 3 == 0)
X            printf("\n%06ld:         ", pc);
X        printf("  %6ld", sget4()); 
X    }
X    printf("\n%06ld: ", pc);
X    printf("          prev page offset : %06ld\n", sget4()); 
X
X} /* bop */
X
X
X/*---------------------------------------------------------------------------*/
X
Xvoid postamble() 
X{
X
X    printf("POST      last page offset : %06ld\n", sget4());
X    printf("%06ld: ", pc);
X    printf("          numerator        : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          denominator      : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          magnification    : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          max page height  : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          max page width   : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          stack size needed: %d\n", (int) get2());
X    printf("%06ld: ", pc);
X    printf("          number of pages  : %d\n", (int) get2());
X
X} /* postamble */
X
Xvoid preamble()
X{
X    register int i;
X
X    printf("PRE       version          : %d\n", (int) get1());
X    printf("%06ld: ", pc);
X    printf("          numerator        : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          denominator      : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          magnification    : %ld\n", get4());
X    printf("%06ld: ", pc);
X    i = (int) get1();
X    printf("          job name (%3d)   :", i);
X    while (i-- > 0)
X        putchar((int) get1());
X    putchar('\n');
X
X} /* preamble */
X
X
Xvoid postpostamble()
X{
X    register int i;
X 
X    printf("POSTPOST  postamble offset : %06ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          version          : %d\n", (int) get1());
X    while ((i = (int) get1()) == TRAILER) {
X        printf("%06d: ", pc - 1);
X        printf("TRAILER\n");
X    }
X    while (i != EOF) {
X        printf("%06ld: ", pc - 1);
X        printf("BAD DVI FILE END: 0x%02X\n", i);
X        i = (int) get1();
X    }
X
X} /* postpostamble */
X
X
X
Xvoid special(x)
Xregister int x;
X{
X    register long len;
X    register long i;
X
X    len = num(x);
X    printf("XXX%d:     %ld bytes\n", x, len);
X    printf("%06ld: ", pc);
X    for (i = 0; i < len; i++)      /* a bit dangerous ... */
X        putchar((int) get1());     /*   can be non-printables */
X    putchar('\n');
X
X} /* special */
X
X
X
Xvoid fontdef(x)
Xregister int x;
X{
X    register int i;
X    char * name;
X    font * fnt;
X    int namelen;
X    long fntnum;
X    int new = 0;
X
X    fntnum = num(x);
X    printf("FNT_DEF%d: %ld\n", x, fntnum);
X    printf("%06ld: ", pc);           /* avoid side-effect on pc in get4() */
X    printf("          checksum         : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          scale            : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          design           : %ld\n", get4());
X    printf("%06ld: ", pc);
X    printf("          name             : ");
X    namelen = (int) get1() + (int) get1();
X    fnt = fonts;
X    while (fnt != NULL && fnt->num != fntnum)
X        fnt = fnt->next;
X    if (fnt == NULL) {
X        if ((fnt = (font *) malloc(sizeof(font))) == NULL) {
X            perror("fontdef");
X            exit(1);
X        }
X        fnt->num = fntnum;
X        new = 1;
X    }
X    else
X        free(fnt->name);    /* free old name */
X    if ((name = (char *) malloc(namelen * sizeof(char))) == NULL) {
X        perror("fontdef");
X        exit(1);
X    }
X    
X    for (i = 0; i < namelen; i++)
X        name[i] = get1();
X    fnt->name = name;
X    if (new) {
X        fnt->next = fonts;
X        fonts = fnt;
X    }
X
X    printf("%s\n", name);
X
X} /* fontdef */
X
X
X
Xchar * fontname(fntnum)
Xlong fntnum;
X{
X    font * fnt;
X
X    fnt = fonts;
X    while (fnt != NULL && fnt->num != fntnum)
X        fnt = fnt->next;
X    if (fnt != NULL)
X        return fnt->name;
X    else
X        return "unknown fontname";
X   
X} /* fontname */
X
X
X
Xvoid printnonprint(ch)
Xregister int ch;
X{
X
X    printf("Char:     ");
X    switch (ch) {
X        case 11  :  printf("ff         /* ligature (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 12  :  printf("fi         /* ligature (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 13  :  printf("fl         /* ligature (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 14  :  printf("ffi        /* ligature (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 15  :  printf("ffl        /* ligature (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 16  :  printf("i          /* (non-printing) 0x%02X */", ch);
X                    break;
X        case 17  :  printf("j          /* (non-printing) 0x%02X */", ch);
X                    break;
X        case 25  :  printf("ss         /* german (non-printing) 0x%02X */", ch);
X                    break;
X        case 26  :  printf("ae         /* scadinavian (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 27  :  printf("oe         /* scadinavian (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 28  :  printf("o          /* scadinavian (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 29  :  printf("AE         /* scadinavian (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 30  :  printf("OE         /* scadinavian (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        case 31  :  printf("O          /* scadinavian (non-printing) 0x%02X */",
X                           ch);
X                    break;
X        default  :  printf("0x%02X", ch); break;
X    }
X    putchar('\n');
X
X}
X
X
X
Xunsigned long num(size)
Xregister int size;
X{
X    register int i;
X    register long x = 0;
X
X    pc += size;
X    for (i = 0; i < size; i++)
X        x = (x << 8) + (unsigned) getc(dvifp);
X    return x;
X
X} /* num */
X
X
X
Xlong snum(size)
Xregister int size;
X{
X    register int i;
X    register long x = 0;
X
X    pc += size;
X    x = getc(dvifp);
X    if (x & 0x80)
X        x -= 0x100;
X    for (i = 1; i < size; i++)
X        x = (x << 8) + (unsigned) getc(dvifp);
X    return x;
X
X} /* snum */
X
X
X
END_OF_FILE
if test 14923 -ne `wc -c <'disdvi.c'`; then
    echo shar: \"'disdvi.c'\" unpacked with wrong size!
fi
# end of 'disdvi.c'
fi
if test -f 'dvi2tty.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dvi2tty.c'\"
else
echo shar: Extracting \"'dvi2tty.c'\" \(24434 characters\)
sed "s/^X//" >'dvi2tty.c' <<'END_OF_FILE'
X/******************************************************************************
X * Marcel Mol: 1990-02-04  (UUCP: marcel at duteca.tudelft.nl)
X *               First attempt to recognize symbol fonts, so bullets (in
X *               itemized lists) are translated to a proper character instead
X *               an awfull ligature.
X *               Version 4.0.
X * Marcel Mol: 1990-02-01  (UUCP: marcel at duteca.tudelft.nl)
X *               Included port to VMS (off Joseph Vasallo and Seppo Rantala)
X *               into latest version. Hope things still work, cannot test it ...
X * Joseph Vasallo & Seppo Rantala: 1989-09-05 (Internet: rantala at tut.FI)
X *		 Ported to work under VAX/VMS V4.4 & VAXC V2.4 or higher.
X *		 Fixed bugs in using Swedish/Finnish characters.
X * Marcel Mol: 1989-02-14  (UUCP: duteca!marcel)
X *               Fixed check for .dvi extension.
X *               Allowed more ligatures.
X *               Fixed side effect bugs (2 gets as function arguments).
X *               Version 3.2.
X * Marcel Mol: 1989-01-19  (UUCP: duteca!marcel)
X *               Changed in option handling, no change
X *               in user interface (only the undocumented 
X *               feature -e).
X *               Version 3.1.
X * Marcel Mol: 1989-01-11  (UUCP: duteca!marcel)
X *               Changed some longs to ints.
X *               It now also runs on MSDOS Microsoft C 5.1
X *               New version: 3.0
X * Marcel Mol: 1989-01-03  (UUCP: duteca!marcel)
X *               Fixed a bugs concerning pager programs
X *               and scanning environment variable DVI2TTY.
X * Marcel Mol: 1988-10-25  (UUCP: duteca!marcel)
X *        dvi2tty.c dvi2tty.h dvistuff.c commands.h
X *               Converted program to C.
X *               improved spacing between words/characters.
X * bogart:/usr/alla/zap/dvitty/dvitty.p  1986-08-15 20:24:31,
X *               Version to be sent to mod.sources ready.
X * New option since last version:
X *   -Fprog      Pipe output to prog. Can be used to get a different
X *               pager than the default.
X * bogart:/usr/alla/zap/dvitty/dvitty.p  1986-01-13 21:49:31,
X *   Environment variable DVITTY is read and options can be set from it.
X *   These are the currently implemented options:
X *      -ofile   Write output to file, else write to stdout,
X *               possibly piped through a pager if stdout is a tty.
X *      -plist   Print pages whos TeX-page-number are in list.
X *               List is on the form  1,3:6,8  to choose pages
X *               1,3-6 and 8. TeX-nrs can be negative: -p-1:-4,4
X *      -Plist   Print pages whos sequential number are in list.
X *      -wn      Print the lines with width n characters, default is
X *               80. Wider lines gives better results.
X *      -q       Don't try to pipe to a pager.
X *      -f       Try to pipe to a pager if output is a tty.
X *      -Fname   Specify a pager program.                  
X *               Default of -q and -f is a compile time option, a constant.
X *      -l       Write '^L' instead of formfeed between pages.
X *      -u       Don't try to find Scandinavian characters (they will
X *               print as a:s and o:s if this option is choosen).
X *      -s       Scandinavian characters printed as }{|][\.
X *               Default of -s and -u is a compile time option, a constant.
X * bogart:/usr/alla/zap/dvitty/dvitty.p  1986-01-10 18:51:03,
X *   Argument parsing, and random access functions (external, in C)
X *   and other OS-dependent stuff (in C). Removed private 'pager' &
X *   tries to pipe through PAGER (environment var) or, if PAGER not
X *   defined, /usr/ucb/more. Some changes for efficency.
X * bogart:/usr/alla/svante/dvitty/dvitty.p  1985-07-15 20:51:00,
X *   The code for processing dvi-files running on UNIX (UCB-Pascal)
X *   but no argument parsing.
X * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.140, 30-Mar-85 05:43:56,
X *   Edit: Svante Lindahl
X * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.136, 15-Jan-85 13:52:59,
X *   Edit: Svante Lindahl, final Twenex version !!!??
X * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.121, 14-Jan-85 03:10:22,
X *   Edit: Svante Lindahl, cleaned up and fixed a lot of little things
X * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.25, 15-Dec-84 05:29:56,
X *   Edit: Svante Lindahl, COMND-interface, including command line scanning
X * VERA::SS:<SVANTE-LINDAHL.WORK>DVITTY.PAS.23, 10-Dec-84 21:24:41,
X *   Edit: Svante Lindahl, added command line scanning with Rscan-JSYS
X * VERA::<SVANTE-LINDAHL.DVITTY>DVITTY.PAS.48,  8-Oct-84 13:26:30,
X *  Edit: Svante Lindahl, fixed switch-parsing, destroyed by earlier patches
X * VERA::<SVANTE-LINDAHL.DVITTY>DVITTY.PAS.45, 29-Sep-84 18:29:53,
X *  Edit: Svante Lindahl
X *
X * dvitty - get an ascii representation of a dvi-file, suitable for ttys
X *
X * This program, and any documentation for it, is copyrighted by Svante
X * Lindahl. It may be copied for non-commercial use only, provided that
X * any and all copyright notices are preserved.
X *
X * Please report any bugs and/or fixes to:
X *
X * UUCP: {seismo,mcvax,cernvax,diku,ukc,unido}!enea!ttds!zap
X * ARPA: enea!ttds!zap at seismo.CSS.GOV
X *  or   Svante_Lindahl_NADA%QZCOM.MAILNET at MIT-MULTICS.ARPA
X * EAN:  zap at cs.kth.sunet
X */
X
X
X#include "dvi2tty.h"
X#if defined(VMS)
X#include unixio
X#endif
X
X    /*-----------------------------------------------------------------------*/
X    /* The following constants may be toggled before compilation to          */
X    /* customize the default behaviour of the program for your site.         */
X    /* Whichever their settings are, the defaults can be overridden at       */
X    /* runtime.                                                              */
X    /*-----------------------------------------------------------------------*/
X
X#define DEFSCAND    FALSE     /* default is Scandinavian, toggle this if you */
X                              /* don't have terminals with Scand. nat. chars */
X#define WANTPAGER   TRUE      /* default: try to pipe through a pager (like  */
X                              /* more) if stdout is tty and no -o switch     */
X#define DEFPAGER    "/usr/bin/pg"   /* CHANGE TO YOUR LOCAL PAGER            */
X
X    /*------------------ end of customization constants ---------------------*/
X
X#define MAXLEN          100    /* size of char-arrays for strings            */
X#if defined(MSDOS) || defined(VMS)
X#define OPTSET      "wepPousl"   /* legal options                            */
X#define OPTWARG     "wepPo"      /* options with argument                    */
X#else
X#define OPTSET      "wepPousqlfF"/* legal options                            */
X#define OPTWARG     "wepPoF"     /* options with argument                    */
X#endif
X
X/*
X * USAGE CODES
X */
X
X#define wrnge  1                /* width switch arg out of range     */
X#define ign    2                /* ignore cause, print 'Usage:..'    */
X#define nan    3                /* not a number where one expected   */
X#define gae    4                /* garbage at end                    */
X#define bdlst  5                /* bad page-numberlist               */
X#define onef   6                /* only one dvifile allowed          */
X#define bdopt  7                /* bad option                        */
X#define onepp  8                /* only one page list allowed        */
X#define noarg  9                /* argument expected                 */
X
Xchar *dvi2tty = "@(#) dvi2tty.c  4.0 04/02/90 M.J.E. Mol (c) 1989, 1990";
X
X/*---------------------------------------------------------------------------*/
X
Xprintlisttype * currentpage;    /* current page to print                     */
Xprintlisttype * firstpage;      /* first page selected                       */
Xprintlisttype * lastpage;       /* last page selected                        */
X
XFILE *          DVIfile;
XFILE *          output;
Xbool            outputtofile;   /* tells if output goes to file or stdout    */
Xint             ttywidth;       /* max nr of chars per printed line          */
Xint             espace;         /* to fake calcs with ttywidth               */
X
Xlong            foo;            /* utility variable, "register"              */
X#if !defined(MSDOS) && !defined(VMS)
Xbool            pager;          /* tells if output is piped to a pager       */
Xchar  *         path;           /* name of the pager to run                  */
X#endif
Xchar  *         progname;       /* our name                                  */
Xint             Argc;
Xchar **         Argv;
Xchar            DVIfilename[MAXLEN];
Xchar *          OUTfilename;
Xchar            optch;          /* for option handling                       */
X
X/*---------------------------------------------------------------------------*/
X
X#if defined(MSDOS)
Xvoid    main      (int, char **); 
Xvoid    setoption (char *);
Xvoid    getargs   (void);
Xvoid    getpages  (int, char *);
Xvoid    plcnxt    (int);
Xvoid    getfname   (char *);
Xint     getinteger(int *, int *, char *);
Xvoid    usage     (int);
X#else
Xchar *  getenv    ();
XFILE *  popen     ();
X
Xvoid    main      (); 
Xvoid    setoption ();
Xvoid    getargs   ();
Xvoid    getpages  ();
Xvoid    plcnxt    ();
Xvoid    getfname   ();
Xint     getinteger();
Xvoid    usage     ();
X#endif
X
X
X/****************************************************************************/
X/*                                                                          */
X/*                                 M A I N                                  */
X/*                                                                          */
X/****************************************************************************/
X
Xvoid main(argc, argv)
Xint argc;
Xchar ** argv;
X{
X
X    progname = *argv;
X    Argc = argc;
X    Argv = argv;
X
X    getargs();                              /* read command line arguments   */
X#if defined(MSDOS)
X    if ((DVIfile = fopen(DVIfilename, "rb")) == NULL)
X#else
X#if defined(VMS)
X    if ((DVIfile = fopen(DVIfilename, "r","ctx=rec")) == NULL)
X#else
X    if ((DVIfile = fopen(DVIfilename, "r")) == NULL)
X#endif
X#endif
X        errorexit(filop);                   /* can't open dvifile            */
X
X    if (outputtofile) {                     /* open the outfile, if needed   */
X        if ((output = fopen(OUTfilename, "w")) == NULL)
X            errorexit(filcr);
X#if !defined(MSDOS) && !defined(VMS)
X        pager = FALSE;
X#endif
X    }
X    else {
X        output = stdout;
X#if !defined(MSDOS) && !defined(VMS)
X        if (isatty(fileno(output)) && pager) {   /* try to pipe to a pager   */
X            if ((output = popen(path, "w")) == NULL) /* get pipe to pager    */
X                errorexit(pipcr);                /* make output to output    */
X        }
X        else
X            pager = FALSE;
X#endif
X    }
X
X    dvimain();
X
X#if !defined(MSDOS) && !defined(VMS)
X    if (pager)
X        pclose(output);                     /* close pipe to pager            */
X#endif
X
X    exit(0);
X
X} /* main */
X
X/*----------------------------------------------------------------------------*/
X
Xvoid setoption(optarg)
Xchar *optarg;
X{
X    int j = 0;
X    int ret;
X   
X    while (strchr(OPTSET, optch) != NULL) {
X        switch (optch) {
X#if !defined(MSDOS) && !defined(VMS)
X	    case 'q' : pager = FALSE; break;
X	    case 'f' : pager = TRUE; break;
X#endif
X	    case 'l' : noffd = TRUE; break;
X	    case 's' : scascii = TRUE; break;
X	    case 'u' : scascii = FALSE; break;
X            case 'P' :
X		       sequenceon = TRUE;     /* fall through */
X            case 'p' :
X                       if (pageswitchon)
X                           usage(onepp);
X                       getpages(j, optarg);
X                       break;
X            case 'w' :
X		       if (getinteger(&ttywidth, &j, optarg))
X                           usage(nan);
X                       if (optarg[j] != '\0') 
X                           usage(gae);
X                       if ((ttywidth < 16) || (ttywidth > 132))
X                           usage(wrnge);
X                       break;
X            case 'e' :
X		       if (getinteger(&espace, &j, optarg))
X                           usage(nan);
X                       if (optarg[j] != '\0') 
X                           usage(gae);
X                       break;
X            case 'o' :
X                       OUTfilename = optarg;
X		       outputtofile = TRUE;
X                       j = strlen(optarg);
X                       break;
X#if !defined(MSDOS) && !defined(VMS)
X            case 'F' :
X                       pager = TRUE;
X                       path = optarg;
X                       j = strlen(optarg);
X                       break;
X#endif
X            default  : 
X                       usage(bdopt);
X        }
X        if ((optch = optarg[j]) == '\0')
X            break;
X        j++;
X        if ((strchr(OPTWARG, optch) != NULL) && (optarg[j]='\0')) {
X                if (--Argc <= 0)
X                    usage(noarg);
X                optarg = *++Argv;
X                j = 0;
X            }
X    }
X} /* setoption */
X
X/*----------------------------------------------------------------------------*/
X
Xvoid getargs()
X{
X    char *str, *envp;
X    bool DVIfound;                      /* if a dvi filename found           */
X
X    if (Argc <= 1)
X        usage(ign);
X
X    pageswitchon = FALSE;       /* show all pages                            */
X    sequenceon   = FALSE;       /* selected pages are TeX-numbered           */
X    outputtofile = FALSE;       /* write to stdout                           */
X#if !defined(MSDOS) && !defined(VMS)
X    pager        = WANTPAGER;   /* want paging, compile time option          */
X#endif
X    noffd        = FALSE;       /* print formfeed between pages              */
X    scascii      = DEFSCAND;    /* scandinavian, compile time option         */
X    ttywidth     = 80;          /* default terminal width                    */
X    espace       = 0;           /* to fake ttywith calcs                     */
X    DVIfound     = FALSE;
X
X#if !defined(MSDOS) && !defined(VMS)
X    if ((path = getenv("PAGER")) == NULL)   /* find default pathname of page */
X            path = DEFPAGER;             /* program in case paging is wanted */
X#endif
X
X    if ((envp = getenv("DVI2TTY")) != NULL) {
X        while (*envp == ' ')
X             envp++;
X        while (*envp) {                     /* environment var args          */
X            if (strchr(OPTSET, optch = *envp++) != NULL) {
X                /*
X                 * we always pass one option, and arrange for optarg ourselfves,
X                 * so setoption does not mesh up Argv
X                 */
X                if (strchr(OPTWARG, optch) != NULL) {
X                    while (*envp == ' ') 
X                        envp++;
X                    if (*envp == '\0')
X                        usage(noarg);
X                    str = envp;             /* str points to optarg          */
X                    while ((*envp != ' ') && (*envp != '\0'))
X                        *envp++;            /* set envp just after optarg    */
X                    if (*envp != '\0')
X                        *envp++ = '\0';     /* end optarg string             */
X                }
X                else
X                    str = "";
X                setoption(str);
X            }
X            else
X                usage(bdopt);
X            while (*envp == ' ')
X                 envp++;
X        }
X    }
X
X    while (--Argc > 0) {                    /* command line args             */
X        str = *++Argv;
X        if (*str != '-') {                  /* argument is not an option     */
X            if (DVIfound)                   /* only one dvi file allowed     */
X                usage(onef);
X            getfname(str);
X            DVIfound = TRUE;
X        }
X        else if (strchr(OPTSET, optch = *++str) != NULL) {
X            str++;                      /* point to rest of argument if any  */
X            if ((strchr(OPTWARG, optch) != NULL) && (*str == '\0')) {
X                if (--Argc <= 0)
X                    usage(noarg);
X                str = *++Argv;
X            }
X            setoption(str);
X        }
X        else
X            usage(bdopt);
X    }
X
X    if (!DVIfound)
X        usage(ign);
X
X} /* getargs */
X
X/*---------------------------------------------------------------------------*/
X
Xvoid getpages(j, str)
Xint j;
Xchar *str;
X{
X    int i, c;
X    int num;
X
X    pageswitchon = TRUE;
X    firstpage = (printlisttype *) malloc(sizeof(printlisttype));
X    firstpage->all = FALSE;
X    firstpage->nxt = nil;
X    firstpage->pag = 0;
X    lastpage = firstpage;
X    currentpage = firstpage;
X    if (getinteger(&num, &j, str))
X        usage(nan);
X    plcnxt((int) num);
X    while (str[j]) {
X        c = str[j];
X        if (c == ',' || c == ':') {
X            j++;
X            if (getinteger(&num, &j, str))
X                usage(nan);
X        }
X        else
X            break;
X        if (c == ',')
X            plcnxt(num);
X        else {
X            if (currentpage->pag < 0) {
X                if (num > 0) {
X                    currentpage->all = TRUE;
X                    plcnxt(num);
X                }
X                else if (num < currentpage->pag)
X                    for (i = currentpage->pag - 1; i >= num; i--)
X                        plcnxt(i);
X                else
X                    usage(bdlst);
X            }
X            else {
X                if (num < currentpage->pag)
X                    usage(bdlst);
X                for (i = currentpage->pag + 1; i <= num; i++)
X                    plcnxt(i);
X            }
X        }
X    }
X    if ((str[j] != ' ') && (str[j] != NULL)) {
X        usage(gae);
X    }
X    currentpage = firstpage;
X
X} /* getpages */
X
X
Xvoid plcnxt(pagnr)      /* place page-nr next in list */
Xint pagnr;
X{
X    currentpage = lastpage;
X    currentpage->pag = pagnr;
X    lastpage = (printlisttype *) malloc(sizeof(printlisttype));
X    lastpage->all = FALSE;
X    lastpage->nxt = nil;
X    lastpage->pag = 0;
X    currentpage->nxt = lastpage;
X
X} /* plcnxt */
X
X/*----------------------------------------------------------------------------*/
X
Xvoid getfname(str)
Xchar *str;
X{
X    int   i;
X
X    i = strlen(str);
X    if (i == 0)
X        usage(ign);
X    strcpy(DVIfilename, str);
X    if (!((i >= 5) && (str[i-1] == 'i') && (str[i-2] == 'v') &&
X          (str[i-3] == 'd') && (str[i-4] == '.'))) {
X        strcat(DVIfilename, ".dvi");
X    }
X
X} /* getfname */
X
X/*----------------------------------------------------------------------------*/
X
Xint getinteger(dest, j, str)
Xint *dest;
Xint *j;
Xchar *str;
X{
X    int  cum;
X    int  sgn;
X    char ch;
X
X    ch = str[*j];
X    if (ch == '-') {
X        sgn = -1;
X        ch  = str[++(*j)];
X    }
X    else
X        sgn = 1;
X    if ((ch >= '0') && (ch <= '9')) {
X        cum = 0;
X        while ((ch >= '0') && (ch <= '9')) {
X            cum = cum*10 + ch - '0';
X            ch = str[++(*j)];
X        }
X        *dest = sgn * cum;
X        return 0;                   /* return ok */
X    }
X    return 1;                       /* return error */
X
X}   /* getinteger */
X
X/*----------------------------------------------------------------------------*/
X
Xvoid errorexit(errorcode)
Xint errorcode;
X{
X
X    fprintf(stderr, "%s: ", progname);
X    switch (errorcode) {
X        case  illop : fprintf(stderr, "Illegal op-code found: %d\n", opcode);
X                      break;
X        case  stkof : fprintf(stderr, "Stack overflow\n");
X                      break;
X        case  stkuf : fprintf(stderr, "Stack underflow\n");
X                      break;
X        case  stkrq : fprintf(stderr, "Cannot create dvi stack\n");
X                      break;
X        case  lnerq : fprintf(stderr, "Cannot allocate memory\n");
X                      break;
X        case  badid : fprintf(stderr, "Id-byte is not correct: %d\n ", opcode);
X                      break;
X        case  bdsgn : fprintf(stderr, "Bad signature: %d (not 223)\n",
X                                      (int) foo);
X                      break;
X        case  fwsgn : fprintf(stderr, "%d signature bytes (min. 4)\n",
X                                      (int) foo);
X                      break;
X        case  nopre : fprintf(stderr, "Missing preamble\n");
X                      break;
X        case  nobop : fprintf(stderr, "Missing beginning-of-page command\n");
X                      break;
X        case  nopp  : fprintf(stderr, "Missing post-post command\n");
X                      break;
X        case  bdpre : fprintf(stderr, "Preamble occured inside a page\n");
X                      break;
X        case  bdbop : fprintf(stderr, "BOP-command occured inside a page\n");
X                      break;
X        case  bdpst : fprintf(stderr, "Postamble occured before end-of-page\n");
X                      break;
X        case  bdpp  : fprintf(stderr, "Postpost occured before post-command\n");
X                      break;
X        case  nopst : fprintf(stderr, "Missing postamble\n");
X                      break;
X        case  illch : fprintf(stderr, "Character code out of range, 0..127\n");
X                      break;
X        case  filop : fprintf(stderr, "Cannot open dvifile\n");
X                      break;
X        case  filcr : fprintf(stderr, "Cannot create outfile\n");
X                      break;
X#if !defined(MSDOS) && !defined(VMS)
X        case  pipcr : fprintf(stderr, "Cannot create pipe to pager\n");
X                      break;
X#endif
X        default     : fprintf(stderr, "Unkown error code\n");
X                      break;
X    };
X    if (outputtofile)
X#if defined(VMS)
X        remove(OUTfilename);
X#else
X        unlink(OUTfilename);
X#endif
X    exit(errorcode);
X
X}  /* errorexit */
X
X/*----------------------------------------------------------------------------*/
X
Xvoid usage(uerr)
Xint uerr;
X{
X
X    if (uerr != ign) {
X        fprintf(stderr,"%s: ", progname);
X        switch (uerr) {
X            case   ign    : fprintf(stderr, "%s", Copyright);
X                            break;
X            case   wrnge  : fprintf(stderr, "width arg out of range:16-132");
X                            break;
X            case   nan    : fprintf(stderr, "numeric argument expected for option %c",
X                                            optch);
X                            break;
X            case   gae    : fprintf(stderr, "garbage in argument for option %c",
X                                            optch);
X                            break;
X            case   bdlst  : fprintf(stderr, "mal-formed list of pagenumbers");
X                            break;
X            case   onef   : fprintf(stderr, "only one infile argument allowed");
X                            break;
X            case   noarg  : fprintf(stderr, "option argument expected for option %c",
X                                            optch);
X                            break;
X            case   bdopt  : fprintf(stderr, "bad option %c", optch);
X                            break;
X            case   onepp  : fprintf(stderr, "only one pagelist allowed");
X                            break;
X            default       : fprintf(stderr, "unknown usage error");
X                            break;
X        }
X        fprintf(stderr, "\n");
X    }
X    fprintf(stderr, "Usage: %s [ options ] dvifile[.dvi]\n", progname);
X    fprintf(stderr, "Options are:\n");
X    fprintf(stderr,
X            " -ofile   Write output to file, else write to stdout.\n");
X    fprintf(stderr,
X            " -plist   Print pages whos TeX-page-number are in list.\n");
X    fprintf(stderr,
X            " -Plist   Print pages whos sequential number are in list.\n");
X    fprintf(stderr,
X            " -wn      Print the lines with width n characters, default 80.\n");
X#if !defined(MSDOS) && !defined(VMS)
X    fprintf(stderr, " -f       Try to pipe to a pager if output is a tty");
X    if (WANTPAGER)
X        fprintf(stderr, " (default).\n");
X    else
X        fprintf(stderr, ".\n");
X    fprintf(stderr, " -q       Don't try to pipe to a pager");
X    if (WANTPAGER)
X        fprintf(stderr, ".\n");
X    else
X        fprintf(stderr, " (default).\n");
X    fprintf(stderr, " -Fprog   Pipe output to pager prog.\n");
X#endif
X    fprintf(stderr,
X            " -l       Write ''^L'' instead of formfeed between pages.\n");
X    fprintf(stderr,
X            " -u       National Swedish/Finnish characters printed as aaoAAO");
X    if (DEFSCAND)
X        fprintf(stderr, ".\n");
X    else
X        fprintf(stderr, " (default).\n");
X    fprintf(stderr,
X            " -s       National Swedish/Finnish characters printed as }{|][\\");
X    if (DEFSCAND)
X        fprintf(stderr, " (default).\n");
X    else
X        fprintf(stderr, ".\n");
X    exit(uerr);
X
X} /* usage */
X
END_OF_FILE
if test 24434 -ne `wc -c <'dvi2tty.c'`; then
    echo shar: \"'dvi2tty.c'\" unpacked with wrong size!
fi
# end of 'dvi2tty.c'
fi
if test -f 'commands.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'commands.h'\"
else
echo shar: Extracting \"'commands.h'\" \(3506 characters\)
sed "s/^X//" >'commands.h' <<'END_OF_FILE'
X/* DVI COMMANDS */
X#define  SETC_000         0     /* typeset character 0 and move right */
X#define  SETC_127       127     /* typeset character 127 and move right */
X#define  SET1           128     /* typeset a character and move right */
X#define  SET2           129     /* ??? */
X#define  SET3           130     /* ??? */
X#define  SET4           131     /* ??? */
X#define  SET_RULE       132     /* typeset a rule and move right */
X#define  PUT1           133     /* typeset a character */
X#define  PUT2           134     /* ??? */
X#define  PUT3           135     /* ??? */
X#define  PUT4           136     /* ??? */
X#define  PUT_RULE       137     /* typeset a rule */
X#define  NOP            138     /* no operation */
X#define  BOP            139     /* beginning of page */
X#define  EOP            140     /* ending of page */
X#define  PUSH           141     /* save the current positions */
X#define  POP            142     /* restore previous positions */
X#define  RIGHT1         143     /* move right */
X#define  RIGHT2         144     /* ??? */
X#define  RIGHT3         145     /* ??? */
X#define  RIGHT4         146     /* ??? */
X#define  W0             147     /* move right by |w| */
X#define  W1             148     /* move right and set |w| */
X#define  W2             149     /* ??? */
X#define  W3             150     /* ??? */
X#define  W4             151     /* ??? */
X#define  X0             152     /* move right by |x| */
X#define  X1             153     /* move right and set |x| */
X#define  X2             154     /* ??? */
X#define  X3             155     /* ??? */
X#define  X4             156     /* ??? */
X#define  DOWN1          157     /* move down */
X#define  DOWN2          158     /* ??? */
X#define  DOWN3          159     /* ??? */
X#define  DOWN4          160     /* ??? */
X#define  Y0             161     /* move down by |y| */
X#define  Y1             162     /* move down and set |y| */
X#define  Y2             163     /* ??? */
X#define  Y3             164     /* ??? */
X#define  Y4             165     /* ??? */
X#define  Z0             166     /* move down by |z| */
X#define  Z1             167     /* move down and set |z| */
X#define  Z2             168     /* ??? */
X#define  Z3             169     /* ??? */
X#define  Z4             170     /* ??? */
X#define  FONT_00        171     /* set current font to 0 */
X#define  FONT_63        234     /* set current font to 0 */
X#define  FNT1           235     /* set current font */
X#define  FNT2           236     /* Same as FNT1, except that arg is 2 bytes */
X#define  FNT3           237     /* Same as FNT1, except that arg is 3 bytes */
X#define  FNT4           238     /* Same as FNT1, except that arg is 4 bytes */
X#define  XXX1           239     /* extension to \.DVI primitives */
X#define  XXX2           240     /* Like XXX1, but 0<=k<65536 */
X#define  XXX3           241     /* Like XXX1, but 0<=k<@t$2^{24}$@> */
X#define  XXX4           242     /* potentially long extension to \.DVI
X                                   primitives */
X#define  FNT_DEF1       243     /* define the meaning of a font number */
X#define  FNT_DEF2       244     /* ??? */
X#define  FNT_DEF3       245     /* ??? */
X#define  FNT_DEF4       246     /* ??? */
X#define  PRE            247     /* preamble */
X#define  POST           248     /* postamble beginning */
X#define  POST_POST      249     /* postamble ending */
X#define  TRAILER        223     /* trailer bytes in dvi file */
X
X        /*  undefined_commands           250,251,252,253,254,255 */
END_OF_FILE
if test 3506 -ne `wc -c <'commands.h'`; then
    echo shar: \"'commands.h'\" unpacked with wrong size!
fi
# end of 'commands.h'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
#########################################
# Marcel J.E. Mol                       ######################################
# Delft University of Technology          Pink Elephant Management Services  #
# The Netherlands                         Voorburg                           #
# UUCP: marcel at duteca.tudelft.nl          Tel: 070-694231                    #
#                                      	######################################
#########################################



More information about the Comp.sources.misc mailing list