| 1 |
/* dtl.h |
| 2 |
|
| 3 |
This file is public domain. |
| 4 |
Originally written 1995, Geoffrey Tobin. |
| 5 |
The author has expressed the hope that any modification will retain enough content to remain useful. He would also appreciate being acknowledged as the original author in the documentation. |
| 6 |
This declaration added 2008/11/14 by Clea F. Rees with the permission of Geoffrey Tobin. |
| 7 |
|
| 8 |
- header for dv2dt.c and dt2dv.c, conversion programs |
| 9 |
for human-readable "DTL" <-> DVI. |
| 10 |
- (ANSI C) version 0.6.0 - 18:31 GMT +11 Wed 8 March 1995 |
| 11 |
- author: Geoffrey Tobin [email protected] |
| 12 |
- patch: Michal Tomczak-Jaegermann [email protected] |
| 13 |
- Reference: "The DVI Driver Standard, Level 0", |
| 14 |
by The TUG DVI Driver Standards Committee. |
| 15 |
Appendix A, "Device-Independent File Format". |
| 16 |
*/ |
| 17 |
|
| 18 |
/* variety of DTL produced */ |
| 19 |
#define VARIETY "sequences-6" |
| 20 |
|
| 21 |
/* version of DTL programs */ |
| 22 |
#define VERSION "0.6.0" |
| 23 |
|
| 24 |
/* Test for ANSI/ISO Standard C */ |
| 25 |
#if (defined(_MSC_VER) || defined(__cplusplus) || defined(__STDC__) || defined(c_plusplus)) |
| 26 |
#define STDC 1 |
| 27 |
#else |
| 28 |
#define STDC 0 |
| 29 |
#endif |
| 30 |
|
| 31 |
/* Version (Traditional or ANSI) of C affects prototype and type definitions */ |
| 32 |
#if STDC |
| 33 |
#define ARGS(parenthesized_list) parenthesized_list |
| 34 |
#else /* NOT STDC */ |
| 35 |
#define ARGS(parenthesized_list) () |
| 36 |
#endif /* NOT STDC */ |
| 37 |
|
| 38 |
#if defined(FILE_BEGIN) |
| 39 |
#undef FILE_BEGIN |
| 40 |
#endif |
| 41 |
#if STDC |
| 42 |
#define Void void |
| 43 |
#define VOID void |
| 44 |
#define FILE_BEGIN SEEK_SET |
| 45 |
#else /* NOT STDC */ |
| 46 |
#define Void int |
| 47 |
#define VOID |
| 48 |
#define FILE_BEGIN 0 |
| 49 |
#endif /* NOT STDC */ |
| 50 |
|
| 51 |
/* types to store 4 byte signed and unsigned integers */ |
| 52 |
typedef long S4; |
| 53 |
typedef unsigned long U4; |
| 54 |
/* scanf and printf formats to read or write those */ |
| 55 |
#define SF4 "%ld" |
| 56 |
#define UF4 "%lu" |
| 57 |
/* 4 byte hexadecimal */ |
| 58 |
/* #define XF4 "%04lx" */ |
| 59 |
#define XF4 "%lx" |
| 60 |
/* 4 byte octal */ |
| 61 |
#define OF4 "%lo" |
| 62 |
|
| 63 |
/* type for byte count for DVI file */ |
| 64 |
/* COUNT must be large enough to hold a U4 (unsigned 4 byte) value */ |
| 65 |
typedef U4 COUNT; |
| 66 |
|
| 67 |
/* size of a TeX and DVI word is 32 bits; in some systems a `long int' is needed */ |
| 68 |
typedef long int word_t; |
| 69 |
/* format for a DVI word */ |
| 70 |
#define WF "%ld" |
| 71 |
|
| 72 |
/* string of 8-bit characters for machine: keyboard, screen, memory */ |
| 73 |
|
| 74 |
#define MAXSTRLEN 256 |
| 75 |
typedef char String[MAXSTRLEN+1]; |
| 76 |
|
| 77 |
/* string s of length l and maximum length m */ |
| 78 |
typedef struct {int l; int m; char * s;} Lstring; |
| 79 |
|
| 80 |
int debug = 0; /* normally, debugging is off */ |
| 81 |
|
| 82 |
/* Is each DTL command parenthesised by a BCOM and an ECOM? */ |
| 83 |
|
| 84 |
int group = 0; /* by default, no grouping */ |
| 85 |
|
| 86 |
/* signals of beginning and end of a command and its arguments */ |
| 87 |
/* these apply only if group is nonzero */ |
| 88 |
|
| 89 |
# define BCOM "{" |
| 90 |
# define ECOM "}" |
| 91 |
|
| 92 |
# define BCOM_CHAR '{' |
| 93 |
# define ECOM_CHAR '}' |
| 94 |
|
| 95 |
/* beginning and end of a message string */ |
| 96 |
|
| 97 |
#define BMES "'" |
| 98 |
#define EMES BMES |
| 99 |
|
| 100 |
#define BMES_CHAR '\'' |
| 101 |
#define EMES_CHAR BMES_CHAR |
| 102 |
|
| 103 |
/* beginning and end of sequence of font characters */ |
| 104 |
|
| 105 |
#define BSEQ "(" |
| 106 |
#define ESEQ ")" |
| 107 |
|
| 108 |
#define BSEQ_CHAR '(' |
| 109 |
#define ESEQ_CHAR ')' |
| 110 |
|
| 111 |
/* escape and quote characters */ |
| 112 |
|
| 113 |
#define ESC_CHAR '\\' |
| 114 |
#define QUOTE_CHAR '\"' |
| 115 |
|
| 116 |
/* command names in DTL */ |
| 117 |
|
| 118 |
#define SETCHAR "\\" |
| 119 |
#define SET "s" |
| 120 |
#define SET1 "s1" |
| 121 |
#define SET2 "s2" |
| 122 |
#define SET3 "s3" |
| 123 |
#define SET4 "s4" |
| 124 |
#define SETRULE "sr" |
| 125 |
#define PUT "p" |
| 126 |
#define PUT1 "p1" |
| 127 |
#define PUT2 "p2" |
| 128 |
#define PUT3 "p3" |
| 129 |
#define PUT4 "p4" |
| 130 |
#define PUTRULE "pr" |
| 131 |
#define NOP "nop" |
| 132 |
#define BOP "bop" |
| 133 |
#define EOP "eop" |
| 134 |
#define PUSH "[" |
| 135 |
#define POP "]" |
| 136 |
#define RIGHT "r" |
| 137 |
#define RIGHT1 "r1" |
| 138 |
#define RIGHT2 "r2" |
| 139 |
#define RIGHT3 "r3" |
| 140 |
#define RIGHT4 "r4" |
| 141 |
#define W "w" |
| 142 |
#define W0 "w0" |
| 143 |
#define W1 "w1" |
| 144 |
#define W2 "w2" |
| 145 |
#define W3 "w3" |
| 146 |
#define W4 "w4" |
| 147 |
#define X "x" |
| 148 |
#define X0 "x0" |
| 149 |
#define X1 "x1" |
| 150 |
#define X2 "x2" |
| 151 |
#define X3 "x3" |
| 152 |
#define X4 "x4" |
| 153 |
#define DOWN "d" |
| 154 |
#define DOWN1 "d1" |
| 155 |
#define DOWN2 "d2" |
| 156 |
#define DOWN3 "d3" |
| 157 |
#define DOWN4 "d4" |
| 158 |
#define Y "y" |
| 159 |
#define Y0 "y0" |
| 160 |
#define Y1 "y1" |
| 161 |
#define Y2 "y2" |
| 162 |
#define Y3 "y3" |
| 163 |
#define Y4 "y4" |
| 164 |
#define Z "z" |
| 165 |
#define Z0 "z0" |
| 166 |
#define Z1 "z1" |
| 167 |
#define Z2 "z2" |
| 168 |
#define Z3 "z3" |
| 169 |
#define Z4 "z4" |
| 170 |
#define FONT "f" |
| 171 |
#define FONT1 "f1" |
| 172 |
#define FONT2 "f2" |
| 173 |
#define FONT3 "f3" |
| 174 |
#define FONT4 "f4" |
| 175 |
#define FONTDEF "fd" |
| 176 |
#define FONTNUM "fn" |
| 177 |
#define SPECIAL "special" |
| 178 |
#define PRE "pre" |
| 179 |
#define POST "post" |
| 180 |
#define POSTPOST "post_post" |
| 181 |
#define OPCODE "opcode" |
| 182 |
|
| 183 |
/* end dtl.h */ |