| 1 |
/* |
| 2 |
* dvi2tty |
| 3 |
* Copyright (C) 2003 Marcel J.E. Mol <[email protected]> |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License |
| 7 |
* as published by the Free Software Foundation; either version 2 |
| 8 |
* of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#define Progname "dvi2tty" |
| 22 |
#define Copyright "Copyright (C) 1984, 1985, 1986 Svante Lindahl.\n\ |
| 23 |
Copyright (C) 1989-2010 M.J.E. Mol, MESA Consulting B.V." |
| 24 |
|
| 25 |
|
| 26 |
#if defined(KPATHSEA) |
| 27 |
# define NO_DEBUG 1 |
| 28 |
# include <kpathsea/config.h> |
| 29 |
# include <kpathsea/readable.h> |
| 30 |
#if defined(WIN32) |
| 31 |
# include <kpathsea/variable.h> |
| 32 |
#endif |
| 33 |
# include <sys/types.h> |
| 34 |
# include <sys/stat.h> |
| 35 |
#else |
| 36 |
# define TRUE 1 |
| 37 |
# define FALSE 0 |
| 38 |
#endif |
| 39 |
|
| 40 |
#include <stdio.h> |
| 41 |
#include <string.h> |
| 42 |
#include <stdlib.h> |
| 43 |
#include <stdbool.h> |
| 44 |
|
| 45 |
#if (defined(WIN32) && !defined(__MINGW32__)) |
| 46 |
# include <fcntl.h> |
| 47 |
typedef void *HANDLE; |
| 48 |
typedef unsigned long DWORD; |
| 49 |
#define STD_OUTPUT_HANDLE ((DWORD)-11) |
| 50 |
#define STD_ERROR_HANDLE ((DWORD)-12) |
| 51 |
#endif |
| 52 |
|
| 53 |
#define nil NULL |
| 54 |
|
| 55 |
/* |
| 56 |
* Define the maximum width of the terminal |
| 57 |
* (this is also used to define the with of the line structure in dvistuff.c) |
| 58 |
*/ |
| 59 |
#define MAXTERMWIDTH 332 |
| 60 |
|
| 61 |
#include <ptexenc/ptexenc.h> |
| 62 |
#include <ptexenc/unicode.h> |
| 63 |
|
| 64 |
/* internal encoding for NTT JTeX : "euc" */ |
| 65 |
#define JTEX_INTERNAL_ENC "euc" |
| 66 |
|
| 67 |
/* internal encoding for ASCII pTeX : "euc" or "sjis" */ |
| 68 |
#define PTEX_INTERNAL_ENC "euc" |
| 69 |
|
| 70 |
/* internal encoding for upTeX : "uptex" */ |
| 71 |
#define UPTEX_INTERNAL_ENC "uptex" |
| 72 |
|
| 73 |
/* |
| 74 |
* ERROR CODES , don't start with 0 |
| 75 |
*/ |
| 76 |
|
| 77 |
#define illop 1 /* illegal op-code */ |
| 78 |
#define stkof 2 /* stack over-flow */ |
| 79 |
#define stkuf 3 /* stack under-flow */ |
| 80 |
#define stkrq 4 /* stack requirement */ |
| 81 |
#define lnerq 5 /* line allocation */ |
| 82 |
#define badid 6 /* id is not right */ |
| 83 |
#define bdsgn 7 /* signature is wrong */ |
| 84 |
#define fwsgn 8 /* too few signatures */ |
| 85 |
#define nopre 9 /* no pre-amble where expected */ |
| 86 |
#define nobop 10 /* no bop-command where expected */ |
| 87 |
#define nopp 11 /* no postpost where expected */ |
| 88 |
#define bdpre 12 /* unexpected preamble occured */ |
| 89 |
#define bdbop 13 /* unexpected bop-command occured */ |
| 90 |
#define bdpst 14 /* unexpected post-command occured */ |
| 91 |
#define bdpp 15 /* unexpected postpost */ |
| 92 |
#define nopst 16 /* no post-amble where expected */ |
| 93 |
#define illch 17 /* character code out of range */ |
| 94 |
#define filop 18 /* cannot access file */ |
| 95 |
#define filcr 19 /* cannot creat file */ |
| 96 |
#define pipcr 20 /* cannot creat pipe */ |
| 97 |
#define bdfnt 21 /* fail to get font info */ |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
/* |
| 102 |
* Type definitions |
| 103 |
*/ |
| 104 |
|
| 105 |
/* C23 makes "bool" into a keyword; must use <stdbool.h> as above. */ |
| 106 |
/* typedef char bool; */ |
| 107 |
|
| 108 |
typedef struct prlistptr { /* list of pages selected for output */ |
| 109 |
int pag; /* number of pages */ |
| 110 |
bool all; /* pages in interval selected */ |
| 111 |
struct prlistptr *prv; /* previous item in list */ |
| 112 |
struct prlistptr *nxt; /* next item in list */ |
| 113 |
} printlisttype; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
/* |
| 118 |
* Variable definitions |
| 119 |
*/ |
| 120 |
|
| 121 |
extern bool outputtofile; /* output to file or stdout(dvi2tty.c)*/ |
| 122 |
extern bool pageswitchon; /* user-set pages to print(dvistuff.c)*/ |
| 123 |
extern bool sequenceon; /* not TeX pagenrs (dvistuff.c) */ |
| 124 |
extern bool scascii; /* Scand. nat. chars (dvistuff.c) */ |
| 125 |
extern bool latin1; /* latin1 chars (dvistuff.c) */ |
| 126 |
extern bool utf8; /* print by utf8 encoding (dvistuff.c) */ |
| 127 |
extern bool noligaturefi; /* do not use ligature for ff,fi,fl,ffi,ffl (dvistuff.c) */ |
| 128 |
extern bool accent; /* Output accent stuff(dvistuff.c) */ |
| 129 |
extern bool ttfont; /* tt font assumed (dvistuff.c) */ |
| 130 |
extern bool jautodetect; /* Autodetect NTT jTeX, ASCII pTeX and upTeX (dvistuff.c) */ |
| 131 |
extern bool nttj; /* NTT jTeX font support (dvistuff.c) */ |
| 132 |
extern bool asciip; /* ASCII pTeX font support (dvistuff.c) */ |
| 133 |
extern bool uptex; /* upTeX font support (dvistuff.c) */ |
| 134 |
extern bool japan; /* japanized TeX font support (dvistuff.c) */ |
| 135 |
extern bool noffd; /* output ^L or formfeed (dvistuff.c) */ |
| 136 |
extern bool printfont; /* include font switches (dvistuff.c) */ |
| 137 |
extern bool compose; /* try to compose a combining character sequence (dvistuff.c) */ |
| 138 |
extern bool allchar; /* output all characters (dvistuff.c) */ |
| 139 |
|
| 140 |
extern printlisttype *currentpage; /* current page to print (dvi2tty.c) */ |
| 141 |
extern printlisttype *firstpage; /* first page selected (dvi2tty.c) */ |
| 142 |
extern printlisttype *lastpage; /* last page selected (dvi2tty.c) */ |
| 143 |
|
| 144 |
extern int ttywidth; /* screen width (dvi2tty.c) */ |
| 145 |
extern int espace; /* extra screen width (dvi2tty.c) */ |
| 146 |
extern long foo; /* temporary 'register' (dvi2tty.c) */ |
| 147 |
extern long lineheight; /* height of a line (dvistuff.c) */ |
| 148 |
extern int opcode; /* dvi opcode (dvistuff.c) */ |
| 149 |
extern const char * delim; /* printer font delim (dvistuff.c) */ |
| 150 |
|
| 151 |
extern FILE *DVIfile; /* dvi file (dvi2tty.c) */ |
| 152 |
extern FILE *output; /* output file (dvi2tty.c) */ |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
/* |
| 157 |
* Funtion declarations |
| 158 |
*/ |
| 159 |
|
| 160 |
/* dvi2tty.c */ |
| 161 |
void errorexit(int errorcode); |
| 162 |
|
| 163 |
/* dvistuff.c */ |
| 164 |
void dvimain(void); |