1 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
3 * Copyright (c) 1994 Paul Vojta. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * xdvi is based on prior work as noted in the modification history, below.
31 * DVI previewer for X.
33 * Eric Cooper, CMU, September 1985.
35 * Code derived from dvi-imagen.c.
37 * Modification history:
38 * 1/1986 Modified for X.10 --Bob Scheifler, MIT LCS.
39 * 7/1988 Modified for X.11 --Mark Eichin, MIT
40 * 12/1988 Added 'R' option, toolkit, magnifying glass
41 * --Paul Vojta, UC Berkeley.
42 * 2/1989 Added tpic support --Jeffrey Lee, U of Toronto
43 * 4/1989 Modified for System V --Donald Richardson, Clarkson Univ.
44 * 3/1990 Added VMS support --Scott Allendorf, U of Iowa
45 * 7/1990 Added reflection mode --Michael Pak, Hebrew U of Jerusalem
46 * 1/1992 Added greyscale code --Till Brychcy, Techn. Univ. Muenchen
47 * and Lee Hetherington, MIT
48 * 4/1994 Added DPS support, bounding box
49 * --Ricardo Telichevesky
50 * and Luis Miguel Silveira, MIT RLE.
55 #include "kvs_debug.h"
59 #include <kmessagebox.h>
65 * General utility routines.
69 * Print error message and quit.
72 void oops(const QString
& message
)
74 kError(kvs::dvi
) << "Fatal Error:" << message
<< endl
;
76 KMessageBox::error( NULL
,
77 i18n("Fatal error.\n\n") +
80 This probably means that either you found a bug in Okular,\n\
81 or that the DVI file, or auxiliary files (such as font files, \n\
82 or virtual font files) were really badly broken.\n\
83 Okular will abort after this message. If you believe that you \n\
84 found a bug, or that Okular should behave better in this situation\n\
85 please report the problem."));
91 * Read size bytes from the FILE fp, constructing them into a
92 * signed/unsigned integer.
94 unsigned long num(FILE *fp
, int size
)
98 while (size
--) x
= (x
<< 8) | one(fp
);
102 long snum(FILE *fp
, int size
)
107 x
= (signed char) getc(fp
);
109 x
= (unsigned char) getc(fp
);
110 if (x
& 0x80) x
-= 0x100;
112 while (--size
) x
= (x
<< 8) | one(fp
);