[net.sources.mac] MacWrite 1.0 to troff Conversion Program

mjk@ttrdc.UUCP (Mike Kelly) (05/07/85)

This program was posted a few months ago.  I pulled it off and had
to make some minor mods to make it run on 3b20s.  I haven't tested
it again on vaxes, but it should still work.  

I also wanted to make it work with the -mm macros provided with SV,
but they're missing a couple of features I needed.  I pulled -me
off of a nearby 4.2 system; you may have to do the same, or if there
aren't any problems, I'll post the -me macros as well.

This is a shell archive.  Delete the top part of this message (up to
the -----) and just sh the resulting file.  It will expand into five
files: Makefile, write.h, w2t.c, w2t.1 and write2troff.dl.  Type
make to build it.  

Mike Kelly
AT&T Teletype
--------------------  cut here -------------------- 
# To unbundle, sh this file.
echo w2t.c 1>&2
cat >w2t.c <<'End of w2t.c'
/*
    MacWrite to troff input converter.

    version 0.1, Michael Caplinger (mike@rice.arpa), October 1984.
    version 0.2-4, Van Jacobson (van@lbl-rtsg.arpa), Dec 84
		added byte swap routines for Vax, added translations
		for most of Mac's extended characters, added pass-
		through for tables & equations, changed font cmds
		from R-I-B-S form to 1-2-3-4 form to allow font
		changing with ditroff, corrected a couple of minor
		glitches, add "-p" flag to output space for pictures.
    version 0.5, Mike Kelly, (ihnp4!ttrdc!mjk), March 85.
		put in changes for System V (mainly just ifdefed
		ntohs for 3b20 -- you'll still need one for the Vax.
		Fixed problem with structure definitions on 3B's
*/

/*
    copyright (c) 1984, Michael Caplinger.
    May be freely redistributed, but this comment must remain in the
    program or any derivative.
*/

#define VERSION "0.5"

#include <stdio.h>
#include "write.h"


/* On the vax you'll need a swap-short routine.  The interface looks like:

		u_short	ntohs(s)

			ushort	s;

   This routine should return its argument byte swapped.

 */
#ifdef	u3b
#define ntohs(s) s
#else
unsigned short ntohs();
#endif

#define SWAP(s) (s)=ntohs(s);

/* Current Document Context */
int curPoint = 12;
int curStyle = 0;
int curFont;
int curJust = -1;
int curRight = -1;
int curLeft = -1;
int curSpacing = -1;
float curIndent = -1.;
float curLinelength = -1.0;
float curParIndent = -1.;

/* Program Option Flags */
int verbose = 0;
int wrap = 1;
int pflag = 0;
int basePoint = 0;		/* amount to reduce pointsizes by */
int raw = 0;

char	progname[20];


main(argc, argv)
char **argv;
{
    int f;

    strcpy(progname,argv[0]);
    setFlags(argc, argv);
    argv++;
    while(*argv) {
    	if(argv[0][0] != '-')
	    if( (f = open(argv[0], 0)) >= 0) processFile(f);
	argv++;
    }
}

processFile(f)
int f;
{
    struct global global;
    struct document text, header, footer;
    struct infoArrayElem *textInfo, *headerInfo, *footerInfo;
    char *data;
    struct textHeader *textHeader;
    struct paraHeader paraHeader;
    short formatRunLength;
    char *cp;
    int i, j, k, col;
    struct format *fp, *startfp, *endfp;
    struct ruler *ruler;
    int needSpace = 0;
    int skipBlanks = 0;
    int lastWasFormat = 0;
    int doingTable = 0;

    read(f, &global, 140);
    SWAP(global.versionNumber)
    SWAP(global.paraOffset)
    SWAP(global.paraCount)
    SWAP(global.headerParaCount)
    SWAP(global.footerParaCount)
    SWAP(global.activeDoc)
    SWAP(global.startPageNum)
    read(f, &text, 34);
    read(f, &header, 34);
    read(f, &footer, 34);
    debug("version %d\n", global.versionNumber);
    debug("%d paragraphs in main text\n", global.paraCount);
    
    textInfo = (struct infoArrayElem *) malloc(global.paraCount * 8);
    headerInfo = (struct infoArrayElem *) malloc(global.headerParaCount * 8);
    footerInfo = (struct infoArrayElem *) malloc(global.footerParaCount * 8);
    if( textInfo == (struct infoArrayElem *)0 ||
        headerInfo == (struct infoArrayElem *)0 ||
        footerInfo == (struct infoArrayElem *)0 )
	{
		fprintf(stderr,"%s: (Internal Error) Can't alloc.\n",progname);
		exit(-1);
	  }
    read(f, textInfo, global.paraCount * 8);
    for(j=0; j<global.paraCount; j++) {
	SWAP(textInfo[j].paraHeight)
	SWAP(textInfo[j].position)
    }
    read(f, headerInfo, global.headerParaCount * 8);
    for(j=0; j<global.headerParaCount; j++) {
	SWAP(headerInfo[j].paraHeight)
	SWAP(headerInfo[j].position)
    }
    read(f, footerInfo, global.footerParaCount * 8);
    for(j=0; j<global.footerParaCount; j++) {
	SWAP(footerInfo[j].paraHeight)
	SWAP(footerInfo[j].position)
    }

    doPrelude();
    for(j = 0; j < global.paraCount; j++) {
	read(f, &paraHeader, 4);
	SWAP(paraHeader.type)
	SWAP(paraHeader.dataLength)
	debug("type %d paragraph\n", paraHeader.type);
	debug("%d bytes in paragraph data\n", paraHeader.dataLength);
	data = (char *) malloc(paraHeader.dataLength);
	read(f, data, paraHeader.dataLength);
	debug("height %d, position %d, page #%d\n", textInfo[j].paraHeight,
	    textInfo[j].position, textInfo[j].pageNum);
	switch(paraHeader.type) {
	    case TEXTPARA:
		textHeader = (struct textHeader *) data;
		SWAP(textHeader->textLength)
		debug("%d bytes of text\n", textHeader->textLength);
		/* check for a null or empty paragraph */
		cp = data + 2;
		while( *cp == ' ' || *cp == '\t' )
		    cp++;
		if( *cp  == '\r' ) {
		    /* null paragraph */
		    needSpace++;
		    break;
		}
	        if(needSpace && !raw) {
		    if( needSpace > 1 )
			printf(".sp %d\n", needSpace);
		    else
			printf(".sp\n");
		    needSpace = 0;
		}
		cp = data + 2 + textHeader->textLength;
		if((int) cp & 0x1) cp++; /* even byte boundary */
		formatRunLength = ntohs(*(short *)cp);
		formatRunLength /= 6;
		debug("%d format items\n", formatRunLength);
		startfp = (struct format *) (cp + 2);
		SWAP(startfp->charPos)
		fp = startfp;
		for(k = 0; k < formatRunLength; k++) {
		    SWAP(fp->charPos)
		    debug("pos %d, pointsize %d, style 0x%0x, font %d\n",
			fp->charPos, fp->pointSize, fp->style, fp->fontNumber);
		    fp = (struct format *) ((int)fp + FORMAT_SIZE);
		}
		cp = data + 2;
		fp = startfp;
		endfp = fp + (formatRunLength - 1);
		if(*cp == '.' || (*cp == '\\' && *(cp + 1) == '*')) {
		    lastWasFormat = 1;
		    if ( (cp[1] == 'T' && cp[2] == 'S') ||
		         (cp[1] == 'E' && cp[2] == 'Q') )
			doingTable = 1;
		    else if ( (cp[1] == 'T' && cp[2] == 'E') ||
			      (cp[1] == 'E' && cp[2] == 'N') )
			doingTable = 0;
		}
		else {
		    if ( !lastWasFormat && !doingTable) {
		        printf(".pp\n");
		    }
		    lastWasFormat = 0;
		}

		/* delete any trailing whitespace */
		i = textHeader->textLength - 1;
		while( cp[i] == ' ' || cp[i] == '\t' )
		    i--;
		textHeader->textLength = i;

		col = 0;
		for(i = 0; i < textHeader->textLength; i++) {
		    if(i == fp->charPos) {
			col += doFormat(fp,i);
			if(fp != endfp)
			     fp = (struct format *) ((int)fp + FORMAT_SIZE);

		    }
		    if(wrap && *cp == ' ' && col > 65) {
			skipBlanks = 1;
			putchar('\n');
			col = -1;
			cp++;
			continue;
		    }
		    if(skipBlanks && *cp == ' ')
			;
		    else {
			col += putcharExtended(*cp);
			skipBlanks = 0;
		    }
		    cp++;
		}
		/* since we deleted trailing blanks & the final
		 * \r, we're guaranteed that we need a newline.
		 * But first reset the style since we will get
		 * a ".pp" before any text & -me will reset the
		 * style on the .pp.
		 */
		setStyle( 0 );
		putchar( '\n' );
		break;

	    case RULERPARA:
		ruler = (struct ruler *) data;
		SWAP(ruler->leftMargin)
		SWAP(ruler->rightMargin)
		SWAP(ruler->paraIndent)
		for(i=0; i<ruler->numTabs; i++) {
		    SWAP(ruler->tabs[i])
		}
		debug("leftMargin %d, right %d\n", 
		    ruler->leftMargin, ruler->rightMargin);
		debug("just %d, %d tabs, paraIndent %d\n",
		    ruler->justify, ruler->numTabs, ruler->paraIndent);
		doRuler(ruler);
		break;

	    case PICTUREPARA:
		if ( pflag ) {
		    printf(".sv %.1fi\n",
		           -textInfo[j].paraHeight/80. );
		}
		break;
	} /* switch */
	free(data);
    } /* for */
    free(textInfo);
    free(headerInfo);
    free(footerInfo);
}

doFormat(fp, inParagraph)
struct format *fp;
{
    if(fp->pointSize != curPoint) {
	if(!raw) {
	    if ( inParagraph )
		printf( "\\s%d\\&", fp->pointSize - basePoint);
	    else {
		printf(".sz %d\n", fp->pointSize - basePoint);
		printf(".nr pp %d\n", fp->pointSize - basePoint);
	    }
	}
	curPoint = fp->pointSize;
    }
    setStyle( fp->style );

    /* this should be the number of chars taken up by the format
    string, but I'm lazy. */
    return 4;
}

/* set current style to style byte */

#define	STYLE_MASK	(BOLD|SHADOW|ITALIC|UNDERLINE)

setStyle( style )
{
    static int isRaised = 0;
    static int isLowered = 0;
    int font;

    if ( style != curStyle ) {

	if( (font = style & STYLE_MASK) != (curStyle & STYLE_MASK) ) {

		/* do a font change */

	    if(font & (ITALIC|UNDERLINE))	/* italic or underline -> font 2 */
		printf("\\f2");
	    else if(font & (BOLD|SHADOW))	/* bold or shadow -> font 3 */
		printf("\\f3");
	    else
		printf("\\f1");			/* otherwise font 1 */
	}

	if(style & RAISE) {
	    printf("\\u");			/* raised text (superscript) */
	    isRaised = 1;
	} else if(isRaised) {
	    printf("\\d");
	    isRaised = 0;
	}
	if(style & LOWER) {
	    printf("\\d");			/* lowered text (subscript) */
	    isLowered = 1;
	} else if(isLowered) {
	    printf("\\u");
	    isLowered = 0;
	}
	curStyle = style;
    }
}

debug(f, a1, a2, a3, a4, a5, a6, a7, a8, a9)
char *f;
{
    if(verbose) fprintf(stdout, f, a1, a2, a3, a4, a5, a6, a7, a8, a9);
}

setFlags(argc, argv)
char **argv;
{

    if(argc == 1) {
    	printf("usage: %s [-r] [-p] [-d] [-w] [-s<pointadj>] files...\n", argv[0]);
	exit(1);
    }
    while(*argv) {
	if(argv[0][0] == '-') {
	    switch(argv[0][1]) {
		case 'd':
		    verbose = 1;
		    break;
		case 'p':
		    pflag = 1;
		    break;
		case 'w':
		    wrap = 0;
		    break;
		case 's':
		    basePoint = atoi(*argv + 2);
		    break;
		case 'r':
		    raw = 1;
		    break;
	    }
	}
	argv++;
    }
}

doRuler(ruler)
struct ruler *ruler;
{
    int i;

    if(curJust != ruler->justify) {
    	curJust = ruler->justify;
	printf(".br\n"); /* need to put out a break or the last bit of text
			    gets munged into the new formatting rules. */
	switch(curJust) {
	    case LEFTJUST:
		printf(".ad l\n");
		break;
	    case CENTERJUST:
		printf(".ad c\n");
		break;
	    case RIGHTJUST:
		printf(".ad r\n");
		break;
	    case BOTHJUST:
		printf(".ad b\n");
		break;
	}
    }
    if ( curSpacing != ruler->spacing ) {
	curSpacing = ruler->spacing;
	printf( ".vs %dp\n", (curSpacing+2)*(curPoint - basePoint + 4 )/2 );
	printf( ".nr $r \\n(.v/\\n(.s\n" ); /* isn't -me wonderful? */
    }
    if(curLeft != ruler->leftMargin || curRight != ruler->rightMargin) {
    	curLeft = ruler->leftMargin;
	curRight = ruler->rightMargin;
	/* set indent and line length */
	if ( curIndent != curLeft / 80. ) {
	    curIndent = curLeft / 80.;
	    printf(".ba %.1fi\n", curIndent);
	    printf(".nr $i %.1fi\n", curIndent);
	}
	if ( curLinelength != curRight / 80. ) {
	    curLinelength = curRight / 80.;
	    printf(".ll %.1fi\n", curLinelength);
	}
	if ( curParIndent != (ruler->paraIndent / 80. - curIndent) ) {
	    curParIndent = ruler->paraIndent / 80. - curIndent;
	    printf(".nr pi %.1fi\n", curParIndent );
	}
    }
    printf(".ta ");
    if ( ruler->numTabs <= 0 && curParIndent < 0 )
	printf("%.1fi", -curParIndent );
    else
	for(i = 0; i < ruler->numTabs; i++) {
	    printf("%.1fi ", ruler->tabs[i] / 10.0 / 8.0);
	}
    putchar('\n');
}


/* standard troff prelude */
doPrelude() {
    printf(".\" this file generated by WtoT version %s\n", 
	VERSION);
    printf(".po 1i\n");
    printf(".nr ps 0\n"); /* kill .pp's interpara spacing */
    printf(".nr pi 0\n");
#ifdef no
    printf(".de pp\n"); /* redefine the .pp macro */
    printf(".br\n.ti \\(pi\n");
    printf("..\n");
#endif
}

/* this table maps the Mac's extended character set into troff
 * characters.  It's set up for the standard Geneva font.  (it
 * should really be selected based on the current font)
 */
char *ctrans[] = {
	"\\(sq",	/* 0 */
	"\\(sq",	/* 1 */
	"\\(sq",	/* 2 */
	"\\(sq",	/* 3 */
	"\\(sq",	/* 4 */
	"\\(sq",	/* 5 */
	"\\(sq",	/* 6 */
	"\\(sq",	/* 7 */
	"\b",		/* 8 */
	"\t",		/* 9 */
	"\n",		/* 10 */
	"\\(sq",	/* 11 */
	"\f",		/* 12 */
	"\n",		/* 13 */
	"\\(sq",	/* 14 */
	"\\(sq",	/* 15 */
	"\\(sq",	/* 16 */
	"\\(sq",	/* 17 */
	"\\(sq",	/* 18 */
	"\\(sq",	/* 19 */
	"\\(sq",	/* 20 */
	"\\(sq",	/* 21 */
	"\\(sq",	/* 22 */
	"\\(sq",	/* 23 */
	"\\(sq",	/* 24 */
	"\\(sq",	/* 25 */
	"\\(sq",	/* 26 */
	"\\(sq",	/* 27 */
	"\\(sq",	/* 28 */
	"\\(sq",	/* 29 */
	"\\(sq",	/* 30 */
	"\\(sq",	/* 31 */
	" ",	/* 32 */
	"!",	/* 33 */
	"\"",	/* 34 */
	"#",	/* 35 */
	"$",	/* 36 */
	"%",	/* 37 */
	"&",	/* 38 */
	"'",	/* 39 */
	"(",	/* 40 */
	")",	/* 41 */
	"*",	/* 42 */
	"+",	/* 43 */
	",",	/* 44 */
	"-",	/* 45 */
	".",	/* 46 */
	"/",	/* 47 */
	"0",	/* 48 */
	"1",	/* 49 */
	"2",	/* 50 */
	"3",	/* 51 */
	"4",	/* 52 */
	"5",	/* 53 */
	"6",	/* 54 */
	"7",	/* 55 */
	"8",	/* 56 */
	"9",	/* 57 */
	":",	/* 58 */
	";",	/* 59 */
	"<",	/* 60 */
	"=",	/* 61 */
	">",	/* 62 */
	"?",	/* 63 */
	"@",	/* 64 */
	"A",	/* 65 */
	"B",	/* 66 */
	"C",	/* 67 */
	"D",	/* 68 */
	"E",	/* 69 */
	"F",	/* 70 */
	"G",	/* 71 */
	"H",	/* 72 */
	"I",	/* 73 */
	"J",	/* 74 */
	"K",	/* 75 */
	"L",	/* 76 */
	"M",	/* 77 */
	"N",	/* 78 */
	"O",	/* 79 */
	"P",	/* 80 */
	"Q",	/* 81 */
	"R",	/* 82 */
	"S",	/* 83 */
	"T",	/* 84 */
	"U",	/* 85 */
	"V",	/* 86 */
	"W",	/* 87 */
	"X",	/* 88 */
	"Y",	/* 89 */
	"Z",	/* 90 */
	"[",	/* 91 */
	"\\",	/* 92 */
	"]",	/* 93 */
	"^",	/* 94 -  hat accent */
	"_",	/* 95 */
	"\\(aa",	/* 96 -  acute accent */
	"a",	/* 97 */
	"b",	/* 98 */
	"c",	/* 99 */
	"d",	/* 100 */
	"e",	/* 101 */
	"f",	/* 102 */
	"g",	/* 103 */
	"h",	/* 104 */
	"i",	/* 105 */
	"j",	/* 106 */
	"k",	/* 107 */
	"l",	/* 108 */
	"m",	/* 109 */
	"n",	/* 110 */
	"o",	/* 111 */
	"p",	/* 112 */
	"q",	/* 113 */
	"r",	/* 114 */
	"s",	/* 115 */
	"t",	/* 116 */
	"u",	/* 117 */
	"v",	/* 118 */
	"w",	/* 119 */
	"x",	/* 120 */
	"y",	/* 121 */
	"z",	/* 122 */
	"{",	/* 123 */
	"|",	/* 124 */
	"}",	/* 125 */
	"~",		/* 126 -  circumflex accent */
	"\\(sq",	/* 127 */
	"\\(sq",	/* 128 */
	"\\o'A\\(de'",	/* 129 -  upper circle A (A) */
	"C",		/* 130 -  upper C with cedilla */
	"\\(sq",	/* 131 */
	"\\(sq",	/* 132 */
	"\\(sq",	/* 133 */
	"\\(sq",	/* 134 */
	"\\(sq",	/* 135 */
	"\\(sq",	/* 136 */
	"\\(sq",	/* 137 */
	"\\(sq",	/* 138 */
	"\\(sq",	/* 139 */
	"\\o'a\\(de'",	/* 140 -  lower a with circle */
	"c",		/* 141 -  c with cedilla */
	"\\(sq",	/* 142 */
	"\\(sq",	/* 143 */
	"\\(sq",	/* 144 */
	"\\(sq",	/* 145 */
	"\\(sq",	/* 146 */
	"\\(sq",	/* 147 */
	"\\(sq",	/* 148 */
	"\\(sq",	/* 149 */
	"\\(sq",	/* 150 */
	"\\(sq",	/* 151 */
	"\\(sq",	/* 152 */
	"\\(sq",	/* 153 */
	"\\(sq",	/* 154 */
	"\\(sq",	/* 155 */
	"\\(sq",	/* 156 */
	"\\(sq",	/* 157 */
	"\\(sq",	/* 158 */
	"\\(sq",	/* 159 */
	"\\(dg",	/* 160 -  dagger */
	"\\(de",	/* 161 -  degrees (shift option 8) */
	"\\(ct",	/* 162 -  cents */
	"\\f2\\o'L-'\\fP",	/* 163 -  pounds (currency) */
	"\\(sc",	/* 164 -  section mark */
	"\\(bu",	/* 165 -  bullet */
	"\\(rh",	/* 166 -  paragraph */
	"\\(*b",	/* 167 -  beta (german "ss") */
	"\\(rg",	/* 168 -  registered */
	"\\(co",	/* 169 -  copyright */
	"\\u\\s-4TM\\s0\\d",	/* 170 -  trademark */
	"\\(ag",	/* 171 -  grave accent */
	"\\(sq",	/* 172 -  oomlat accent */
	"\\(!=",	/* 173 -  not equal */
	"AE",		/* 174 -  upper AE (") */
	"\\o'O/'",	/* 175 -  slash upper O (O) */
	"\\(if",	/* 176 -  infinity */
	"\\(+-",	/* 177 -  plus minus (shift option =) */
	"\\(<=",	/* 178 -  <= */
	"\\(>=",	/* 179 -  >= */
	"\\o'Y-'",	/* 180 -  yen */
	"\\(*m",	/* 181 -  lower mu */
	"\\(pd",	/* 182 -  "partial" */
	"\\(*S",	/* 183 -  upper sigma */
	"\\(*P",	/* 184 -  upper PI (P) */
	"\\(*p",	/* 185 -  lower pi */
	"\\(is",	/* 186 -  integral sign */
	"\\ua\\d",	/* 187 -  underbar lowercase a */
	"\\uo\\d",	/* 188 -  underbar lowercase o */
	"\\(*W",	/* 189 -  upper omega */
	"ae",		/* 190 -  lower ae */
	"\\o'o/'",	/* 191 -  slashed lower o */
	"\\(sq",	/* 192 -  upside down ? (?) */
	"\\(*i",	/* 193 -  lower case i */
	"\\(no",	/* 194 -  negation */
	"\\(sr",	/* 195 -  square root or check mark */
	"\\f2f\\fP",	/* 196 -  script lower f */
	"\\(~=",	/* 197 -  approx */
	"\\(*D",	/* 198 -  triangle (upper delta) */
	"\\s-1<<\\s0",	/* 199 -  open double angle brackets */
	"\\s-1>>\\s0",	/* 200 -  close double angles */
	"...",		/* 201 -  elipses (3 dots) */
	"\\ ",		/* 202 -  unpaddable space */
	"\\o'`A'",	/* 203 -  `A */
	"\\o'~A'",	/* 203 -  A with circumflex */
	"\\o'~O'",	/* 203 -  O with circumflex */
	"OE",		/* 206 -  upper OE ligature (Q) */
	"oe",		/* 207 -  lower oe ligature */
	"\\(hy",	/* 208 -  hyphen */
	"\\(em",	/* 209 -  m dash (shift option -) */
	"``",		/* 210 -  back double quote */
	"''",		/* 211 -  close double quote */
	"`",		/* 212 -  back single quote */
	"'",		/* 213 -  close single quote */
	"\\(di",	/* 214 -  divide */
	"\\(gr",	/* 215 -  diamond (V) */
	"\\o'y\"'",	/* 216 -  y with umlat */
	"\\(sq",	/* 217 */
	"\\(sq",	/* 218 */
	"\\(sq",	/* 219 */
	"\\(sq",	/* 220 */
	"\\(sq",	/* 221 */
	"\\(sq",	/* 222 */
	"\\(sq",	/* 223 */
	"\\(sq",	/* 224 */
	"\\(sq",	/* 225 */
	"\\(sq",	/* 226 */
	"\\(sq",	/* 227 */
	"\\(sq",	/* 228 */
	"\\(sq",	/* 229 */
	"\\(sq",	/* 230 */
	"\\(sq",	/* 231 */
	"\\(sq",	/* 232 */
	"\\(sq",	/* 233 */
	"\\(sq",	/* 234 */
	"\\(sq",	/* 235 */
	"\\(sq",	/* 236 */
	"\\(sq",	/* 237 */
	"\\(sq",	/* 238 */
	"\\(sq",	/* 239 */
	"\\(sq",	/* 240 */
	"\\(sq",	/* 241 */
	"\\(sq",	/* 242 */
	"\\(sq",	/* 243 */
	"\\(sq",	/* 244 */
	"\\(sq",	/* 245 */
	"\\(sq",	/* 246 */
	"\\(sq",	/* 247 */
	"\\(sq",	/* 248 */
	"\\(sq",	/* 249 */
	"\\(sq",	/* 250 -  box (option h) */
	"\\(sq",	/* 251 -  box (option k) */
	"\\(sq",	/* 252 */
	"\\(sq",	/* 253 */
	"\\(sq",	/* 254 */
	"\\(sq",	/* 255 */
	0 };

putcharExtended(c)
unsigned char c;
{
    printf("%s", ctrans[c]);
    return( strlen( ctrans[c] ) );
}
End of w2t.c
echo write.h 1>&2
cat >write.h <<'End of write.h'
typedef unsigned char byte;

/* This is the first 140 bytes of a document */


struct global { /* should be 140 bytes */
    short versionNumber;
    short paraOffset;
    short paraCount;
    short headerParaCount;
    short footerParaCount;
    byte titlePage;
    byte scrapShow;
    byte footerDisplayed;
    byte headerDisplayed;
    byte rulersShowing;
    byte spare;
    short activeDoc; /* 0 = main, 1 = header, 2 = footer */
    short startPageNum;
    byte printingVars[120]; /* ??? */
};

#define MAINDOC 0
#define HEADERDOC 1
#define FOOTERDOC 2

struct endpoint {
    short paraNumber;
    short charPos;
};

struct position {
    short vert;
    short hor;
};

/* After global are three document structures: for the text, the
 * header and the footer (in that order).  */

struct document { /* should be 34 bytes */
    struct endpoint start;
    struct endpoint end;
    short vertOffset; /* always <= 0 */
    short needToRedraw;
    struct position pageNumberPos;
    struct position datePos;
    struct position timePos;
    struct position timeStringPos;
    byte iconRedraw;
    byte iconFlag;
    short activeFont;
    short activeStyle;
};
/* there is one of these for each paragraph in the text, header and
 * footer documents.  First come all the ones for the text; then
 * all the ones for the header; then all the ones for the footer.
 * You know how many of each from the paraCount, headerParaCount and
 * footerParaCount fields in the global structure.
 */

struct infoArrayElem { /* should be 8 bytes */
    short paraHeight;
    short position;
    byte pageNum; /* 0-based */
    byte unused[3];
};

/* After that comes the paragraphs.  */

/*
    paragraph data
    A text paragraph is a paraHeader followed by a textHeader followed by
    a variable number of format effectors.  The number of format effectors
    is given by a short following the paragraph text on the next even byte
    boundary.
*/

struct paraHeader {
    short type; /* 0=ruler, 1=text, 2=picture */
    short dataLength;
};

/* The types of paragraphs: */

#define RULERPARA 0
#define TEXTPARA 1
#define PICTUREPARA 2

struct textHeader {
    short textLength;
};

/*
    ASCII data follows.  On the even byte boundary following text there is
    a word for the format run length.  Each format consists of six bytes:
*/

struct format {
    short charPos;		/* char pos in paragraph format takes effect */
    byte pointSize;
    byte style;			/* style byte (see below) */
    byte unused;
    byte fontNumber;		/* MAC font number */
};

#define	FORMAT_SIZE	6	/* Kludge for C compilers that pad structures */

/* A ruler paragraph (type=RULER) */

struct ruler {
    short leftMargin;
    short rightMargin;
    byte justify;
    byte numTabs;
    byte filler; /* ??? */
    byte spacing;
    short paraIndent;
    short tabs[12];
};

#define LEFTJUST 0
#define CENTERJUST 1
#define RIGHTJUST 2
#define BOTHJUST 3

#define SINGLESPACE 0
#define DOUBLESPACE 1
#define TRIPLESPACE 2

/* bits for text styles */
/* the style byte in format effectors are combinations of these bits */

#define BOLD 0x1
#define ITALIC 0x2
#define	UNDERLINE 0x4
#define	OUTLINE 0x8
#define	SHADOW 0x10
#define RAISE 0x20
#define LOWER 0x40
End of write.h
echo Makefile 1>&2
cat >Makefile <<'End of Makefile'
CFLAGS=	-O -g

all:	w2t write2troff.data

w2t:	w2t.o
	cc -o w2t w2t.o

w2t.o:	w2t.c write.h
	cc $(CFLAGS) -c w2t.c

write2troff.data: write2troff.dl
	fromhex <write2troff.dl >write2troff.data
clean:
	rm -r w2t.o write2troff.data
End of Makefile
echo write2troff.dl 1>&2
cat >write2troff.dl <<'End of write2troff.dl'
@@@C@DJJ@@FL@@@E@@@FOO@@@@OOOOOO@@@@@@@A@@@B@@@@@@DH@@E@@@@@@@@@@B
O@@BH@OOMLOONL@BOD@BID@A@B@EBH@COL@@@A@@@@@@DH@@E@@@@@@@@@@BO@@BH@
@@E@@@B@@BH@@LH@@@AH@@@A@A@A@@@@@@@ABG@O@@@A@A@A@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@AH@@AA@@AH@@AAONED@@ADOOOB@@ANOOOB@@NLOOOB@AKJOO
OOOOOOOO@@@L@@@@@A@@@D@@@@@@@D@@@@@@@@@@@AOOOB@@AN@@AC@ABDOOOB@AKJ
OOOOOOOO@@OOOOOOOOOO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B@B@B@B@B@B@B@B@B@B@B@B@B@B@B@B@B@B@B@BMB@B@B@B@B@B@B@B@BM@MBM@@@F
@@@@@L@@@@@A@@@AA@AB@@@A@@@N@@@@@@@F@@@@@L@@@@@A@@@AA@@@|@@@EILLG
End of write2troff.dl
echo w2t.1 1>&2
cat >w2t.1 <<'End of w2t.1'
.TH W2T 1-local
.SH NAME
w2t \- convert MacWrite files to troff input files
.SH SYNOPSIS
.B w2t
[
.B \-sPointSize
] [
.B \-p
] [
.B \-d
] [
.B \-w
] [
.B \-r
]
file ...
.br
.SH DESCRIPTION
.I W2t
reads the
.I files
and produces a
.I troff
input file on the standard output.  The files should be .data files as
transferred by
.I macget(1).
.PP
By default, the output file will contain enough
.I -me
macro commands to cause the output to ``strongly resemble'' the MacWrite
output.  Currently, this means that justification, spacing, tabs,
paragraphing, and certain kinds of text attributes will be the same.  See
BUGS for a list of things that don't work.
.PP
The
.B -p
option saves space for pictures.  By default, pictures are ignored completely.
This option causes a `.sv' directive of enough space to hold the picture to
be output.
.PP
The
.B -r
option causes the output to have far fewer
.I troff
commands inserted.  Essentially, null paragraphs will be converted into .pp
macros, and text attributes will be converted.  This is useful because the
.I troff
to do a verbatim formatting job is rather ugly; this option can be used when
the Mac is just being used to draft the text prior to a more rigorous
formatting.
.PP
The
.B -s
.I pointsize
option is used to change the document type sizes.  This amount is
subtracted from all point sizes in the document.  By default, this value is
2.  This will convert most MacWrite documents from 12 point to 10 point.
.I Pointsize
can be zero (the MacWrite pointsizes will be used) or negative (the MacWrite
pointsizes will be scaled up).
.PP
The
.I -w
option turns intraparagraph wrapping off.  A MacWrite paragraph is a single
line of text with no newlines.
.I W2t
will wrap these lines at about 80 columns by default.  I have never seen an
application where this wrapping was undesirable, but...
.PP
The
.I -d
option causes an immense amount of debugging information to appear
interspersed with the output on stdout.
.PP
Since the table & math abilities of MacWrite are limitted,
.I tbl
and
.I eqn
can be included in the MacWrite document.  I.e., lines between .TS/.TE
or .EQ/.EN will be treated specially.  Other troff directives (lines
starting with a `.') will be passed through but may not do what you expect.
.PP
.SH "SEE ALSO"
macget(1)
.SH BUGS
.PP
Pictures are barely supported (you will need scissors & glue).
.PP
Headers and footers are ignored.
.PP
Decimal tabs are not handled correctly.
.PP
The output is heavily -me macro dependent.
.PP
.PP
All fonts map into troff's Times Roman.
.PP
Text attributes are not quite right.  Bold, italic, subscript, and
superscript work.  Underlining maps to italic.  Shadow maps to bold.
Mixed attributes map to either bold or italic.
.PP
All the special characters of the standard Mac Geneva font map into
some (reasonable?) troff character but the mapping is fixed.  Font dependent
character conversions (e.g., for the Princeton math font) should be supported.
.SH AUTHOR
Michael Caplinger, Rice University (mike@rice)
.br
Changes for Vax & some additions by Van Jacobson, Lawrence Berkeley Laboratory
(van@lbl-csam.arpa).
End of w2t.1