WordPerfect to roff translator (unfinished)
David MacKenzie
mackenzi at thor.acc.stolaf.edu
Fri Aug 4 15:25:27 AEST 1989
This is in response to several postings requesting a roff to
WordPerfect translator. I don't have one of those, but on 16 June an
unfinished WordPerfect to roff translator called `wpc' was posted to
comp.sources.d. I cleaned it up a lot and changed the name to
`wp2roff', but it still implements only basic functions. Still, it
contains fairly good documentation of the WP file format and could be
used as the basis of programs translating either way. I don't know if
I'll have much time to devote to it, though, so here is what I have at
the moment . . . .
#! /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 shell archive."
# Contents: Makefile wp2roff.c codes.c wp.h
# Wrapped by dave at edfdc on Fri Aug 4 01:22:57 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(316 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile for wp2roff
X# David MacKenzie <edf at rocky2.rockefeller.edu>
X# Latest revision: 08/04/89
X
XCFLAGS = -O
X
Xwpc: wp2roff.o codes.o
X $(CC) wp2roff.o codes.o -o wp2roff
X
Xwp2roff.o codes.o: wp.h
X
Xshar: wp2roff.shar
X
Xwp2roff.shar: Makefile wp2roff.c codes.c wp.h
X shar Makefile wp2roff.c codes.c wp.h > wp2roff.shar
END_OF_FILE
if test 316 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'wp2roff.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'wp2roff.c'\"
else
echo shar: Extracting \"'wp2roff.c'\" \(3330 characters\)
sed "s/^X//" >'wp2roff.c' <<'END_OF_FILE'
X/* wp2roff
X Convert from WordPerfect 4.2 to troff -me
X
X Usage: wp2roff inputfile...
X Writes to `inputfile.me'.
X
X By Hans Varkevisser <hans at let.vu.nl>
X Modified by David MacKenzie <edf at rocky2.rockefeller.edu>
X
X Latest revision: 08/04/89
X
X Not finished
X Public domain */
X
X#include <stdio.h>
X#include "wp.h"
X
X/* The length of `convert_buffer'.
X This is arbitrary -- what is a reasonable maximum? */
X#define CONVERT_LENGTH 1000
X
X/* The input stream. */
XFILE *in;
X
X/* The output stream. */
XFILE *out;
X
X/* The current code character read from the input. */
Xint code;
X
X/* If nonzero, the current code uses a newline at the end. */
Xint uses_end_nl;
X
X/* Current index in `convert_buffer'. */
Xint i;
X
X/* If true, read the next `code' from `convert_buffer', otherwise from `in'. */
Xboolean use_buffer;
X
X/* If true, the end of the input file has been reached. */
Xboolean input_exhausted;
X
X/* Temporary storage for long WordPerfect code sequences, which are
X always terminated with another instance of the code that initiated
X them. */
Xint convert_buffer[CONVERT_LENGTH];
X
Xvoid
Xread_code ()
X{
X if (use_buffer)
X code = convert_buffer[i++];
X else
X {
X code = getc (in);
X if (code == EOF)
X input_exhausted = true;
X }
X}
X
Xvoid
Xwrite_special_code ()
X{
X int savecode;
X
X if (uses_end_nl == 0 && codes[code].uses_start_nl)
X putc ('\n', out);
X
X switch (code)
X {
X case EXT_CHAR:
X read_code ();
X fputs (extchars[code], out);
X read_code ();
X break;
X default:
X if (use_buffer)
X {
X fputs (codes[code].troff_e, out);
X use_buffer = false;
X }
X else
X {
X fputs (codes[code].troff_b, out);
X /* Copy until a matching code is found to terminate the sequence. */
X savecode = code;
X i = 0;
X do
X {
X read_code ();
X convert_buffer[i++] = code;
X }
X while (code != savecode);
X i = 0;
X use_buffer = true;
X }
X break;
X }
X}
X
Xvoid
Xwrite_normal_code ()
X{
X int savecode;
X
X if (uses_end_nl == 0 && codes[code].uses_start_nl)
X putc ('\n', out);
X
X if (codes[code].number)
X {
X savecode = code;
X do
X read_code ();
X while (code != savecode);
X fputs (codes[code].troff_b, out);
X }
X else
X fputs (codes[code].troff_b, out);
X}
X
Xvoid
Xconvert_stream ()
X{
X use_buffer = false;
X input_exhausted = false;
X
X while (input_exhausted == false)
X {
X read_code ();
X uses_end_nl = codes[code].uses_end_nl;
X switch (codes[code].translation)
X {
X case 0: /* No translation. */
X putc (code, out);
X break;
X case 1: /* Normal translation. */
X write_normal_code ();
X break;
X case 2: /* Special translation. */
X write_special_code ();
X break;
X }
X }
X}
X
Xvoid
Xconvert_file (file)
X char *file;
X{
X char out_name[1024];
X
X in = fopen (file, "r");
X if (in == NULL)
X {
X perror (file);
X exit (1);
X }
X
X strcpy (out_name, file);
X strcat (out_name, ".me");
X out = fopen (out_name, "w");
X if (out == NULL)
X {
X perror (out_name);
X exit (1);
X }
X
X convert_stream ();
X fclose (in);
X fclose (out);
X}
X
Xint
Xmain (argc, argv)
X int argc;
X char *argv[];
X{
X int optind;
X
X if (argc == 1)
X {
X fprintf (stderr, "Usage: %s inputfile...\n", argv[0]);
X exit (1);
X }
X
X for (optind = 1; optind < argc; optind++)
X convert_file (argv[optind]);
X
X exit (0);
X}
END_OF_FILE
if test 3330 -ne `wc -c <'wp2roff.c'`; then
echo shar: \"'wp2roff.c'\" unpacked with wrong size!
fi
# end of 'wp2roff.c'
fi
if test -f 'codes.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'codes.c'\"
else
echo shar: Extracting \"'codes.c'\" \(28041 characters\)
sed "s/^X//" >'codes.c' <<'END_OF_FILE'
X/* codes.c */
X
X#include "wp.h"
X
X/* Table describing what to do with each character from the WP file. */
X
Xstruct wp_code codes[256] =
X {
X /* 000 */ {0, 0, " 0000", "e000", 0, 0, 0}, /* special */
X /* 001 */ {1, 0, " 0001", "e000", 0, 0, 0}, /* special */
X /* 002 */ {1, 0, "", "e000", 0, 0, 0}, /* PAGE NUMBER 4.2 */
X /* 003 */ {0, 0, " 0003", "e000", 0, 0, 0}, /* special */
X /* 004 */ {0, 0, " 0004", "e000", 0, 0, 0}, /* special */
X /* 005 */ {0, 0, " 0005", "e000", 0, 0, 0}, /* special */
X /* 006 */ {0, 0, " 0006", "e000", 0, 0, 0}, /* special */
X /* 007 */ {0, 0, " 0007", "e000", 0, 0, 0}, /* special */
X /* 008 */ {0, 0, " 0008", "e000", 0, 0, 0}, /* special */
X /* 009 */ {1, 0, "\t", "e000", 1, 1, 0}, /* TAB */
X /* 010 */ {1, 0, ".br\n", ".sp\n", 1, 1, 1}, /* HARD NEW LINE */
X /* 011 */ {1, 0, "", "e000", 1, 1, 0}, /* SOFT NEW PAGE */
X /* 012 */ {1, 0, ".bp\n", "e000", 1, 1, 1}, /* HARD NEW PAGE */
X /* 013 */ {1, 0, "\n", "e000", 1, 1, 0}, /* SOFT NEW LINE */
X /* 014 */ {1, 0, " 0014", "e000", 1, 1, 0}, /* special code */
X /* 015 */ {1, 0, " 0015", "e000", 1, 1, 0}, /* special code */
X /* 016 */ {0, 0, " 0016", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 017 */ {0, 0, " 0017", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 018 */ {0, 0, " 0018", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 019 */ {0, 0, " 0019", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 020 */ {0, 0, " 0020", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 021 */ {0, 0, " 0021", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 022 */ {0, 0, " 0022", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 023 */ {0, 0, " 0023", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 024 */ {0, 0, " 0024", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 025 */ {0, 0, " 0025", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 026 */ {0, 0, " 0026", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 027 */ {0, 0, " 0027", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 028 */ {0, 0, " 0028", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 029 */ {0, 0, " 0029", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 030 */ {0, 0, " 0030", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 031 */ {0, 0, " 0031", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 032 */ {1, 0, " ", "e000", 1, 0, 0}, /* ASCII CODE */
X /* 033 */ {0, 0, " 0033", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 034 */ {0, 0, " 0034", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 035 */ {0, 0, " 0035", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 036 */ {0, 0, " 0036", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 037 */ {0, 0, " 0037", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 038 */ {0, 0, " 0038", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 039 */ {0, 0, " 0039", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 040 */ {0, 0, " 0040", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 041 */ {0, 0, " 0041", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 042 */ {0, 0, " 0042", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 043 */ {0, 0, " 0043", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 044 */ {0, 0, " 0044", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 045 */ {0, 0, " 0045", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 046 */ {1, 0, "\\(md", "e000", 1, 0, 0}, /* ASCII CODE */
X /* 047 */ {0, 0, " 0047", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 048 */ {0, 0, " 0048", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 049 */ {0, 0, " 049", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 050 */ {0, 0, " 0050", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 051 */ {0, 0, " 0051", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 052 */ {0, 0, " 0052", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 053 */ {0, 0, " 0053", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 054 */ {0, 0, " 0054", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 055 */ {0, 0, " 0055", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 056 */ {0, 0, " 0056", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 057 */ {0, 0, " 0057", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 058 */ {0, 0, " 0058", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 059 */ {0, 0, " 0059", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 060 */ {0, 0, " 0060", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 061 */ {0, 0, " 0061", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 062 */ {0, 0, " 0062", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 063 */ {0, 0, " 0063", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 064 */ {0, 0, " 0064", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 065 */ {0, 0, " 0065", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 066 */ {0, 0, " 0066", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 067 */ {0, 0, " 0067", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 068 */ {0, 0, " 0068", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 069 */ {0, 0, " 0069", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 070 */ {0, 0, " 0070", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 071 */ {0, 0, " 0071", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 072 */ {0, 0, " 0072", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 073 */ {0, 0, " 0073", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 074 */ {0, 0, " 0074", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 075 */ {0, 0, " 0075", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 076 */ {0, 0, " 0076", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 077 */ {0, 0, " 0077", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 078 */ {0, 0, " 0078", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 079 */ {0, 0, " 0079", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 080 */ {0, 0, " 0080", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 081 */ {0, 0, " 0081", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 082 */ {0, 0, " 0082", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 083 */ {0, 0, " 0083", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 084 */ {0, 0, " 0084", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 085 */ {0, 0, " 0085", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 086 */ {0, 0, " 0086", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 087 */ {0, 0, " 0087", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 088 */ {0, 0, " 0088", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 089 */ {0, 0, " 0089", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 090 */ {0, 0, " 0090", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 091 */ {0, 0, " 0091", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 092 */ {0, 0, " 0092", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 093 */ {0, 0, " 0093", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 094 */ {0, 0, " 0094", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 095 */ {0, 0, " 0095", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 096 */ {0, 0, " 0096", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 097 */ {0, 0, " 0097", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 098 */ {0, 0, " 0098", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 099 */ {0, 0, " 0099", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 100 */ {0, 0, " 0100", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 101 */ {0, 0, " 0101", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 102 */ {0, 0, " 0102", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 103 */ {0, 0, " 0103", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 104 */ {0, 0, " 0104", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 105 */ {0, 0, " 0105", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 106 */ {0, 0, " 0106", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 107 */ {0, 0, " 0107", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 108 */ {0, 0, " 0108", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 109 */ {0, 0, " 0109", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 110 */ {0, 0, " 0110", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 111 */ {0, 0, " 0111", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 112 */ {0, 0, " 0112", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 113 */ {0, 0, " 0113", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 114 */ {0, 0, " 0114", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 115 */ {0, 0, " 0115", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 116 */ {0, 0, " 0116", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 117 */ {0, 0, " 0117", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 118 */ {0, 0, " 0118", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 119 */ {0, 0, " 0119", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 120 */ {0, 0, " 0120", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 121 */ {0, 0, " 0121", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 122 */ {0, 0, " 0122", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 123 */ {0, 0, " 0123", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 124 */ {0, 0, " 0124", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 125 */ {0, 0, " 0125", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 126 */ {0, 0, " 0126", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 127 */ {0, 0, " 0127", "e000", 0, 0, 0}, /* ASCII CODE */
X /* 128 */ {1, 0, " 0128", "e000", 0, 0, 0}, /* NO_OP */
X /* 129 */ {1, 0, " 0129", "e000", 0, 0, 0}, /* RIGHT JUST ON */
X /* 130 */ {1, 0, " 0130", "e000", 0, 0, 0}, /* RIGHT JUST OFF */
X /* 131 */ {1, 0, "\n", "e000", 0, 1, 0}, /* END CENTERED TEXT */
X /* 132 */ {1, 0, "", "e000", 0, 0, 0}, /* END ALIGNED TEXT */
X /* 133 */ {1, 0, " 0133", "e000", 0, 0, 0}, /* TEMP START MATH CALC */
X /* 134 */ {1, 0, " 0134", "e000", 0, 0, 0}, /* CENTER PAGE */
X /* 135 */ {1, 0, " 0135", "e000", 0, 0, 0}, /* BEGIN COLUMN MODE */
X /* 136 */ {1, 0, " 0136", "e000", 0, 0, 0}, /* END COLUMN MODE */
X /* 137 */ {1, 0, " 0137", "e000", 0, 0, 0}, /* TAB AFTER RIGHT MARGIN */
X /* 138 */ {1, 0, " 0138", "e000", 0, 0, 0}, /* WIDOW CONTROL ON */
X /* 139 */ {1, 0, " 0139", "e000", 0, 0, 0}, /* WIDOW CONTROL OFF */
X /* 140 */ {1, 0, "", "e000", 0, 0, 0}, /* HARD EOL AND SOFT EOP */
X /* 141 */ {1, 0, " 0141", "e000", 0, 0, 0}, /* FOOTNOTE NUMBER */
X /* 142 */ {1, 0, " 0142", "e000", 0, 0, 0}, /* RESERVED */
X /* 143 */ {1, 0, " 0143", "e000", 0, 0, 0}, /* RESERVED */
X /* 144 */ {1, 0, " 0144", "e000", 0, 0, 0}, /* RED LINE ON */
X /* 145 */ {1, 0, " 0145", "e000", 0, 0, 0}, /* RED LINE OFF */
X /* 146 */ {1, 0, " 0146", "e000", 0, 0, 0}, /* STRIKE OUT ON */
X /* 147 */ {1, 0, " 0147", "e000", 0, 0, 0}, /* STRIKE OUT OFF */
X /* 148 */ {1, 0, ".ft I\n", "e000", 0, 1, 1}, /* UNDERLINE ON */
X /* 149 */ {1, 0, ".ft R\n", "e000", 0, 1, 1}, /* UNDERLINE OFF */
X /* 150 */ {1, 0, " 0150", "e000", 0, 0, 0}, /* REVERSE VIDEO ON */
X /* 151 */ {1, 0, " 0151", "e000", 0, 0, 0}, /* REVERSE VIDEO OFF */
X /* 152 */ {1, 0, " 0152", "e000", 0, 0, 0}, /* TABLE OF PLACEHOLDER */
X /* 153 */ {1, 0, " 0153", "e000", 0, 0, 0}, /* OVERSTRIKE */
X /* 154 */ {1, 0, " 0154", "e000", 0, 0, 0}, /* CANCEL HYPH WORD */
X /* 155 */ {1, 0, " 0155", "e000", 0, 0, 0}, /* END OF GEN. TEXT */
X /* 156 */ {1, 0, ".ft R\n", "e000", 0, 1, 1}, /* BOLD OFF */
X /* 157 */ {1, 0, ".ft B\n", "e000", 0, 1, 1}, /* BOLD ON */
X /* 158 */ {1, 0, " 0158", "e000", 0, 0, 0}, /* HYPHENATION OFF */
X /* 159 */ {1, 0, " 0159", "e000", 0, 0, 0}, /* HYPHENATION ON */
X /* 160 */ {1, 0, " ", "e000", 0, 0, 0}, /* HARD SPACE */
X /* 161 */ {1, 0, "", "e000", 0, 0, 0}, /* DO SUBTOTAL */
X /* 162 */ {1, 0, "", "e000", 0, 0, 0}, /* SUBTOTAL ENTRY */
X /* 163 */ {1, 0, "", "e000", 0, 0, 0}, /* DO TOTAL */
X /* 164 */ {1, 0, " 0164", "e000", 0, 0, 0}, /* TOTAL ENTRY */
X /* 165 */ {1, 0, " 0165", "e000", 0, 0, 0}, /* DO GRAND TOTAL */
X /* 166 */ {1, 0, " 0166", "e000", 0, 0, 0}, /* MATH CALC COLUMN */
X /* 167 */ {1, 0, " 0167", "e000", 0, 0, 0}, /* BEGIN MATH MODE */
X /* 168 */ {1, 0, " 0168", "e000", 0, 0, 0}, /* END MATH MODE */
X /* 169 */ {1, 0, "-", "e000", 0, 0, 0}, /* HARD HYPHEN IN LINE */
X /* 170 */ {1, 0, "-", "e000", 0, 0, 0}, /* HARD HYPHEN AT EOL */
X /* 171 */ {1, 0, "-", "e000", 0, 0, 0}, /* HARD HYPHEN AT EOP */
X /* 172 */ {1, 0, "", "e000", 0, 0, 0}, /* SOFT HYPHEN */
X /* 173 */ {1, 0, "", "e000", 0, 0, 0}, /* SOFT HYPHEN AT EOL */
X /* 174 */ {0, 0, "", "e000", 0, 0, 0}, /* SOFT HYPHEN AT EOP */
X /* 175 */ {1, 0, " 0175", "e000", 0, 0, 0}, /* EOT COLUMNS AND EOL */
X /* 176 */ {1, 0, " 0176", "e000", 0, 0, 0}, /* EOT COLUMNS AND EOP */
X /* 177 */ {1, 0, " 0177", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 178 */ {1, 0, " 0178", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 179 */ {1, 0, " 0179", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 180 */ {1, 0, " 0180", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 181 */ {1, 0, " 0181", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 182 */ {1, 0, " 0182", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 183 */ {1, 0, " 0183", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 184 */ {1, 0, " 0184", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 185 */ {1, 0, " 0185", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 186 */ {1, 0, " 0186", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 187 */ {1, 0, " 0187", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 188 */ {1, 0, " 0188", "e000", 0, 0, 0}, /* SUPERSCRIPT */
X /* 189 */ {1, 0, " 0189", "e000", 0, 0, 0}, /* SUBSCRIPT */
X /* 190 */ {1, 0, " 0190", "e000", 0, 0, 0}, /* ADV. PRINTER 1/2 L UP */
X /* 191 */ {1, 0, " 0191", "e000", 0, 0, 0}, /* ADV. PRINTER 1/2 L DOWN */
X
X /** The next codes are multi-byte formatting codes
X The codes are in hex (<C0> = 192) */
X
X /* 192 */ {1, 1, "", "e000", 0, 0, 0}, /* MARGIN RESET */
X /* <C0><old left><old right><new left><new right><C0> */
X
X /* 193 */ {1, 1, " 0193", "e000", 0, 0, 0}, /* SPACING RESET */
X /* <C1><old spacing><new spacing><C1> */
X
X /* 194 */ {1, 1, " 0194", "e000", 0, 0, 0}, /* LEFT MARGIN RELEASE */
X /* <C2><# spaces to go left><C2> */
X
X /* 195 */ {1, 1, ".ce\n", "e000", 1, 1, 1}, /* CENTER FOLLOWING TEXT */
X /** <C3><type><center col#><start col#><C3><text><83>
X type=0 for centering between margins
X type=1 for centering around current column
X <83> is the code for ending centered text */
X
X /* 196 */ {1, 1, " 0196", "e000", 0, 0, 0}, /* ALIGN OR FLUSH RIGHT */
X /** <C4><align char><align col#><start col#><C4><text><84>
X If align char=12 (newline), this is a flush right command and the align
X col# is the right margin; otherwise, the align col# is the next tab stop.
X If the high bit of the align char is set, then this is a dot leader align
X or dot leader flush right.
X <84> is the code for ending aligned or flushed right */
X
X /* 197 */ {1, 1, " 0197", "e000", 0, 0, 0}, /* RESET HYPH ZONE */
X /* <C5><old left><old right><new left><new right><C5> */
X
X /* 198 */ {1, 1, " 0198", "e000", 0, 0, 0}, /* SET PAGE NO POSITION */
X /** <C6><old pos code><new pos code><C6>
X code: 0=none, 1=top left, 2=top center, 3=top right 4=top L&R, 5=bot left,
X 6=bot center, 7=bot right, 8=bot L&R */
X
X /* 199 */ {1, 1, " 0199", "e000", 0, 0, 0}, /* SET PAGE NUMBER */
X /** <C7><old# high ord><old# low ord><new# high ord><new# low ord><C7>
X Only the low order 15 bits determine the page number.
X If high bit is set the numbers are Roman numerals;
X if not, Arabic numbers. */
X
X /* 200 */ {1, 1, " 0200", "e000", 0, 0, 0}, /* SET PAGE NU COLUMN */
X /** <C8><old left><old center><old right><new left>
X <new center><new right><C8> */
X
X /* 201 */ {1, 1, " 0201", "e000", 0, 0, 0}, /* SET TABS */
X /** <C9><old tab table(20 bytes)><new tab table(20 bytes)> <C9>
X Each bit represents one character position from bit 0 to bit 159.
X There are a maximum of 160 characters allowed in a WordPerfect line. */
X
X /* 202 */ {1, 1, " 0202", "e000", 0, 0, 0}, /* CONDITIONAL EOP */
X /* <CA><number of single spaced lines not to be broken> <CA> */
X
X /* 203 */ {1, 1, "", "e000", 0, 0, 0}, /* SET PITCH OR FONT */
X /** <CB><old pitch><old font><new pitch><new font><CB>
X If the pitch is a negative value, then the font is proportional. */
X
X /* 204 */ {1, 1, "", "e000", 0, 0, 0}, /* SET TEMP. MARGIN */
X /* <CC><old tmpmargin><new tmpmargin><CC> */
X
X /* 205 */ {1, 1, " 0205", "e000", 0, 0, 0}, /* OLD END OF TEMP. MARGIN */
X /* no longer used <CD><tmpmargin><CD> */
X
X /* 206 */ {1, 1, " 0206", "e000", 0, 0, 0}, /* SET TOP MARGIN */
X /* <CE><old top margin><new top margin><CE> */
X
X /* 207 */ {1, 1, "", "e000", 0, 0, 0},/* SUPPRESS PAGE CHARACTERISTICS */
X /** <CF><suppress codes><CF>
X Codes (any or all bits may be inclusive or'd together):
X 1=all suppressed
X 2=page number suppressed
X 4=page numbers moved to bottom
X 10=all headers suppressed
X 20=header a suppressed
X 40=header b suppressed
X 100=footer a suppressed
X 200=footer b suppressed */
X
X /* 208 */ {1, 1, " 0208", "e000", 0, 0, 0}, /* SET FORM LENGTH */
X /** <D0><old form len><old # text lines><new form len>
X <new # text lines><D0> */
X
X /* 209 */ {2, 1, "[H//F]\n", "'\n", 1, 1, 1}, /* HEADER/FOOTER */
X /** <D1><old def byte<# half-lines use by header/footer>
X <FF><FF><lmargin><rmargin><text><FF>
X <#half-lines used by new header/footer><new def byte><D1>
X Def byte contents are type (two low-order bits> and
X occurence (six high bits). The low-order 2 bits of the
X Def byte MUST be correct
X Type Occurence
X 0 = header a 0 = never
X 1 = header b 1 = all pages
X 2 = footer a 2 = odd pages
X 3 = footer b 4 = even pages */
X
X /* 210 */ {1, 1, " 0210", "e000", 0, 0, 0}, /* FOOTNOTE */
X /** Not used in version 4.0 and above (see 343/E4)
X <D2><fn#><# half-lines><FF><lmargin><rmargin><text><D2> */
X
X /* 211 */ {1, 1, " 0211", "e000", 0, 0, 0}, /* SET FOOTNOTE NUMBER */
X /** not used in version 4.0 and above
X <D3><old line #><new line #><D3> */
X
X /* 212 */ {1, 1, " 0212", "e000", 0, 0, 0}, /* ADVANCE TO HALF LINE # */
X /** stored in half-line units
X <D4><old line #><advance to half line #><D4> */
X
X /* 213 */ {1, 1, " 0213", "e000", 0, 0, 0}, /* SET LINES PER INCH */
X /** 6 or 8 lpi are the only valid values
X <D5><old lpi code><new lpi code><D5> */
X
X /* 214 */ {1, 1, " 0214", "e000", 0, 0, 0}, /* SET EXTENDED TABS */
X /* <D6><old start><old increment><new start><new increment <D6> */
X
X /* 215 */ {1, 1, " 0215", "e000", 0, 0, 0}, /* DEFINE MATH COLUMNS */
X /** <D7><old column def (24 bytes)>[<old calc 0>]<0> [<old calc 1>]<0>
X [<old calc 2>]<0>[<old calc 3>] <0><D7><new column def (24 bytes)>
X [<new calc 0>] <0>[<new calc 1>]<0>[<new calc 2>]<0>[<new calc 3>]
X <0><D7>
X See "define columns"(code <DD>) for the 24 byte column definition */
X
X /* 216 */ {1, 1, " 0216", "e000", 0, 0, 0}, /* SET ALIGNMENT CHAR */
X /* <D8><old char><new char><D8> */
X
X /* 217 */ {1, 1, " 0217", "e000", 0, 0, 0}, /* SET LEFT MARGIN RELEASE */
X /** columns to go left -- not used in version 4.0 and above
X <D9><old #><new #><D9> */
X
X /* 218 */ {1, 1, " 0218", "e000", 0, 0, 0}, /* SET UNDERLINE MODE */
X /** <DA><old mode><new mode><DA>
X 0=normal underlining(breaks at word spaces)
X 1=double underlining(breaks)
X 2=single underlining(continuous)
X 3=double underlining(continuous) */
X
X /* 219 */ {1, 1, " 0219", "e000", 0, 0, 0}, /* SHEETFEED BIN NUMBER */
X /** <DB><old #><new #><DB>
X WordPerfect stores the number as one less than the bin number
X (bin #1 =0) */
X
X /* 220 */ {1, 1, "", "e000", 0, 0, 0}, /* EOP FUNCTION */
X /* <DC><# of half-lines at EOP, low 7 bits><high 7 bits> <# of half-lines
X used for footnotes> <# pages used for footnotes> <# footnotes on this
X page> <ceop flag><suppress code><DC> */
X
X /* 221 */ {1, 1, " 0221", "e000", 0, 0, 0}, /* DEFINE COLUMNS */
X /** <DD><old # cols><l1><r1><l2><r2><l3><r3><l4><r4> <l5><r5>
X <new # cols><l1><r1><l2><r2><l3><r3><l4><r4> <l5><r5> <DD>
X # cols:
X low-order 7 bits = the number
X high-order 1 bit = 1 if parallel colums */
X
X /* 222 */ {1, 1, "", "e000", 0, 0, 0}, /* END OF TEMP.MARGIN */
X /* <DE><old left tmp margin><old right tmp margin><DE> */
X
X /* 223 */ {1, 1, " 0223", "e000", 0, 0, 0}, /* INVISIBLE CHARS */
X /** <DF><text in 7-bit characters><DF>
X If a character has an ASCII code >= <6F> (ASCII 191) the text portion of
X this function represents it as <6F><(char-6F)>. For example, the
X character ASCII 232(E8) would appear as: <6F><(E8-6F)> or <6F><79>. */
X
X /* 224 */ {1, 1, "", "e000", 0, 0, 0}, /* LEFT/RIGHT TEMP.MARGIN */
X /** pre 4.0 format:
X <E0><new rt tmp margin><new lt tmp margin><E0>
X 4.0 and later format:
X <E0><0><difference between old and new left margin><E0> */
X
X /* 225 */ {2, 1, " 0225", "e000", 1, 0, 0}, /* EXTENDED CHAR */
X /* <E1><character><E1> */
X
X /* 226 */ {2, 1, ".f(\n", ".f)\n", 1, 1, 1}, /* NEW FOOTNOTE/ENDNOTE */
X /** <E2><def><a><b><c><d><old ftnote line><# lines page 1><# lines page 2>
X <# lines page n><# pages><FF> <l margin><r margin><text><E2>
X where:
X def:
X bit 0: 0= use numbers,1= use characters
X bit 1: 0= footnote, 1= endnote
X a,b: if def bit 0 is a 0 then a,b are footnote and
X endnote numbers.
X if def bit 0 is a 1 then a= # characters and
X b = a character
X c,d: numbers of lines in footnote/endnote
X NOTE: a,b and c,d are 14 bits numbers split into two
X 7 bit bytes, high-order byte first. For endnotes, there
X is only a null between <d> and <FF> */
X
X /* 227 */ {1, 1, " 0227", "e000", 0, 0, 0}, /* FOOTNOTE OPTIONS */
X /** <E3><old values 74 bytes><new values 74 bytes><E3>
X Byte Meaning
X 1 spacing in footnotes
X 2 spacing between footnotes
X 3 number of lines to keep together
X 4 flag byte (bits: b ln en ft n)
X n: 1 if numbering starts on each page
X en,ft 0= use numbers
X 1= use characters
X 2= use letters
X ln: 0= no line separator
X 1= 2 inch line
X 2= line from left to right margin
X b: 0= footnotes after text
X 1= footnotes at bottom of page
X 5 # of characters used in place of footnotenumbers
X 6-10 "numbering" characters (null terminated if <5)
X 11 # displayable chars in string for footnote(text)
X 12-26 string for footnote (text)
X 27 # displayable chars in string for endnote(text)
X 28-42 string for endnote (text)
X 43 # of displayable characters in string for
X footnote (note)
X 44-58 string for footnote (note)
X 59 # of displayable characters in string for
X endnote (note)
X 60-74 string for endnote (note) */
X
X /* 228 */ {1, 1, " 0228", "e000", 0, 0, 0}, /* NEW SET FOOTNOTE */
X /** <E4><old # high> old # low><new # high><new # low><E4>
X Footnote numbers are 14-bit numbers split into two 7-bits bytes,
X high-order byte first */
X
X /* 229 */ {1, 1, " 0229", "e000", 0, 0, 0}, /* PARAGRAPH NUMBER DEF */
X /** <E5><old 7 level numbers><old 7 def bytes>
X <new 7 level numbers><new 7 def bytes> <E5>
X A def byte is two nibbles:
X Style Punctuation
X (low nibble) (high nibble)
X 0 = caps Roman 0 = nothing
X 1 = lcase Roman 1 = "." after number
X 2 = caps letter 2 = ")" after number
X 3 = lcase letter 3 = "(" before ")" after
X 4 = Arabic
X 5 = Arabic with previous levels
X separated by "." (Ex.: 3.4.1) */
X
X /* 230 */ {1, 1, " 0230", "e000", 0, 0, 0}, /* PARAGRAPH NUMBER */
X /** <E6><new level #><def byte><old 7 numbers><E6>
X Level number is 0 for first level, 1 second etc. */
X
X /* 231 */ {1, 1, " 0231", "e000", 0, 0, 0}, /* BEGIN MARKED TEXT */
X /** <E9><def, info><5 byte definition><E9>
X The def, info byte is the same as the mark and end mark except that the
X low nibble is significant only for lists.
X For the table contents, the five definition bytes represents five levels.
X For index and lists only, the first definition byte is significant.
X Definition bytes:
X 0 = no page numbers
X 1 = page # after text, preceded by two spaces
X 2 = page # after text, in parentheses preceded by 1 space
X 3 = page # flush right
X 4 = page # flush right with dot leader */
X
X /* 232 */ {1, 1, " 0232", "e000", 0, 0, 0}, /* END MARKED TEXT */
X /* <EA>< 30 byte, null terminated format string><EA> */
X
X /* 233 */ {1, 1, " 0233", "e000", 0, 0, 0}, /* DEFINE MARKED TEXT */
X /* <EB>< 30 byte, null terminated format string><EB> */
X
X /* 234 */ {1, 1, " 0234", "e000", 0, 0, 0}, /* DEFINE INDEX MARK */
X /** <EC><def><# of half lines in block><EC>
X Def: 0 for block protect on 1 for block protect off */
X
X /* 235 */ {1, 1, " 0235", "e000", 0, 0, 0}, /* DATE/TIME FUNTION */
X
X /* 236 */ {1, 1, " 0236", "e000", 0, 0, 0}, /* BLOCK PROTECT */
X
X /* 237 */ {0, 0, " 0237", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X
X /* 238 */ {0, 0, " 0238", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X
X /* 239 */ {0, 0, " 0239", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 240 */ {0, 0, " 0240", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 241 */ {0, 0, " 0241", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 242 */ {0, 0, " 0242", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 243 */ {0, 0, " 0243", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 244 */ {0, 0, " 0244", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 245 */ {0, 0, " 0245", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 246 */ {0, 0, " 0246", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 247 */ {0, 0, " 0247", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 248 */ {0, 0, " 0248", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 249 */ {0, 0, " 0249", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 250 */ {0, 0, " 0250", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 251 */ {0, 0, " 0251", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 252 */ {0, 0, " 0252", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 253 */ {0, 0, " 0253", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 254 */ {0, 0, " 0254", "e000", 0, 0, 0}, /* NOT KNOWN YET */
X /* 255 */ {0, 0, " 0255", "e000", 0, 0, 0} /* NOT KNOWN YET */
X};
X
X/* Table to convert extended characters to troff codes */
X
Xchar *extchars[256] =
X {
X "\\000", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006", "\\007",
X "\\008", "\\009", "\\010", "\\011", "\\012", "\\013", "\\014", "\\015",
X "\\016", "\\017", "\\018", "\\019", "\\020", "\\021", "\\022", "\\023",
X "\\024", "\\025", "\\026", "\\027", "\\028", "\\029", "\\030", "\\031",
X "\\032", "\\033", "\\034", "\\035", "\\036", "\\037", "\\038", "\\039",
X "\\040", "\\041", "\\042", "\\043", "\\044", "\\045", "\\046", "\\047",
X "\\048", "\\049", "\\050", "\\051", "\\052", "\\053", "\\054", "\\055",
X "\\056", "\\057", "\\058", "\\059", "\\060", "\\061", "\\062", "\\063",
X "\\064", "\\065", "\\066", "\\067", "\\068", "\\069", "\\070", "\\071",
X "\\072", "\\073", "\\074", "\\075", "\\076", "\\077", "\\078", "\\079",
X "\\080", "\\081", "\\082", "\\083", "\\084", "\\085", "\\086", "\\087",
X "\\088", "\\089", "\\090", "\\091", "\\092", "\\093", "\\094", "\\095",
X "\\096", "\\097", "\\098", "\\099", "\\100", "\\101", "\\102", "\\103",
X "\\104", "\\105", "\\106", "\\107", "\\108", "\\109", "\\110", "\\111",
X "\\112", "\\113", "\\114", "\\115", "\\116", "\\117", "\\118", "\\119",
X "\\120", "\\121", "\\122", "\\123", "\\124", "\\125", "\\126", "\\127",
X /* 128 */
X "\\(,C", "\\(:u", "\\('e", "\\(^a", "\\(:a", "\\(`a", "\\(oa", "\\(,c",
X /* 136 */
X "\\(^e", "\\(:e", "\\(`e", "\\(:i", "\\(^i", "\\(`i", "\\(:A", "\\(oA",
X /* 144 */
X "\\('E", "\\(ae", "\\(AE", "\\(^o", "\\(:o", "\\(`o", "\\(^u", "\\(`u",
X /* 152 */
X "\\(:y", "\\(:O", "\\(:U", "\\(xx", "\\(Po", "\\(Ye", "\\(Pt", "\\(xx",
X /* 160 */
X "\\('a", "\\('i", "\\('o", "\\('u", "\\(~n", "\\(~N", "\\(of", "\\(Om",
X /* 168 */
X "\\(r?", "\\(xx", "\\(no", "\\(12", "\\(14", "\\(r!", "\\(Fo", "\\(Fc",
X /* 176 */
X "\\(bx", "\\(bx", "\\(bx", "\\179", "\\180", "\\181", "\\182", "\\183",
X /* 184 */
X "\\184", "\\185", "\\186", "\\187", "\\188", "\\189", "\\190", "\\191",
X /* 192 */
X "\\192", "\\193", "\\194", "\\195", "\\196", "\\197", "\\198", "\\199",
X /* 200 */
X "\\200", "\\201", "\\202", "\\203", "\\204", "\\205", "\\206", "\\207",
X /* 208 */
X "\\208", "\\209", "\\210", "\\211", "\\212", "\\213", "\\214", "\\215",
X /* 216 */
X "\\216", "\\217", "\\218", "\\219", "\\220", "\\221", "\\222", "\\223",
X /* 224 */
X "\\(*a", "\\(ss", "\\(*G", "\\(*p", "\\(*S", "\\(*s", "\\(*m", "\\(*t",
X /* 232 */
X "\\(*f", "\\(*T", "\\(*W", "\\(*d", "\\(if", "\\(/o", "\\(*e", "\\(ca",
X /* 240 */
X "\\(==", "\\(+-", "\\(>=", "\\(<=", "\\(is", "\\(rb", "\\(dv", "\\(~~",
X /* 248 */
X "\\(de", "\\(bu", "\\(md", "\\(sr", "\\(*y", "\\(ps", "\\(xx", "\\255"
X };
END_OF_FILE
if test 28041 -ne `wc -c <'codes.c'`; then
echo shar: \"'codes.c'\" unpacked with wrong size!
fi
# end of 'codes.c'
fi
if test -f 'wp.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'wp.h'\"
else
echo shar: Extracting \"'wp.h'\" \(805 characters\)
sed "s/^X//" >'wp.h' <<'END_OF_FILE'
X/* wp.h
X The definitions are WordPerfect 4.1 codes but work with 4.2. */
X
X/* Maximum length of a troff code string. */
X#define MAX_STRING 25
X
X/* Special types of characters. */
X#define HEADER_FOOTER 209
X#define EXT_CHAR 225
X#define FOOTNOTE 226
X
Xtypedef enum { false = 0, true = 1 } boolean;
X
Xstruct wp_code
X {
X int translation; /* 0= no translation, 1= translation, 2= special */
X int number; /* 0= 1 code, 1= long code */
X char troff_b[MAX_STRING]; /* begin code for troff -me macro */
X char troff_e[MAX_STRING]; /* end code for troff -me macro */
X int special; /* 1= special, 0= normal */
X int uses_end_nl; /* code uses a newline at end of code */
X int uses_start_nl; /* code needs a newline at beginning of code */
X };
X
Xextern struct wp_code codes[];
Xextern char *extchars[];
END_OF_FILE
if test 805 -ne `wc -c <'wp.h'`; then
echo shar: \"'wp.h'\" unpacked with wrong size!
fi
# end of 'wp.h'
fi
echo shar: End of shell archive.
exit 0
--
David MacKenzie
mackenzi at thor.stolaf.edu or edf at rocky2.rockefeller.edu
More information about the Alt.sources
mailing list