1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
|
/*========================================================================*\
Copyright (c) 1990-1997 Paul Vojta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
PAUL VOJTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
NOTE:
xdvi is based on prior work, as noted in the modification history
in xdvi.c.
\*========================================================================*/
/*
* This file gathers all xdvi.h definitions useful for Win32.
* Written by Fabrice Popineau, Supelec from the original xdvi.h .
* This could be merged again at some point, but xdvi.h is already
* fullfiled.
*/
#ifndef WINDVI_H
#define WINDVI_H
#define TTF 0
#define T1 0
/********************************
* The C environment *
*******************************/
#include "c-auto.h"
#ifndef WORDS_BIGENDIAN
#define WORDS_BIGENDIAN 1
#endif
#ifdef WIN32
#include <win32lib.h>
#include <gs32lib.h>
#define WIN31 0
#define WIN95 WIN31+1
#define WIN98 WIN95+1
#define WINNT3 WIN98+1
#define WINNT4 WINNT3+1
#define WINNT5 WINNT4+1
extern int iSystemType;
/* Makes it easier to determine appropriate code paths: */
#if defined (WIN32)
#define IS_WIN32 TRUE
#else
#define IS_WIN32 FALSE
#endif
#define IS_NT (iSystemType >= WINNT3)
#define IS_WIN32S (iSystemType == WIN31)
#define IS_WIN95 (iSystemType == WIN95)
#define IS_WIN98 (iSystemType == WIN98)
#endif /* WIN32 */
#if STDC_HEADERS
# include <stddef.h>
# include <stdlib.h>
/* the following works around the wchar_t problem */
# ifndef WIN32
# include <X11/X.h>
# if HAVE_X11_XOSDEFS_H
# include <X11/Xosdefs.h>
# endif
# ifdef X_NOT_STDC_ENV
# undef X_NOT_STDC_ENV
# undef X_WCHAR
# include <X11/Xlib.h>
# define X_NOT_STDC_ENV
# endif
# endif /* !WIN32 */
#endif /* STDC_HEADERS */
/* Avoid name clashes with kpathsea. */
#define xfopen xdvi_xfopen
/* For wchar_t et al., that the X files might want. */
#include <kpathsea/systypes.h>
#include <kpathsea/c-memstr.h>
#include <kpathsea/c-fopen.h>
#include <kpathsea/c-pathmx.h>
#include <kpathsea/tex-file.h>
#ifndef WIN32
#include <X11/Xlib.h> /* include Xfuncs.h, if available */
#include <X11/Xutil.h> /* needed for XDestroyImage */
#include <X11/Xos.h>
#undef wchar_t
#if XlibSpecificationRelease >= 5
#include <X11/Xfuncs.h>
#endif
#endif
#ifdef WIN32
#define TOOLKIT 1
#define XtNumber(arr) (sizeof(arr)/sizeof(arr[0]))
typedef void * XtPointer;
typedef unsigned long Pixel;
typedef char Boolean;
typedef unsigned int Dimension;
#undef MOTIF
#undef BUTTONS
#undef CFG2RES
#else /* !WIN32 */
#ifndef NOTOOL
#include <X11/Intrinsic.h>
#if (defined(VMS) && (XtSpecificationRelease <= 4)) || defined(lint)
#include <X11/IntrinsicP.h>
#endif
#define TOOLKIT 1
#else /* NOTOOL */
#define XtNumber(arr) (sizeof(arr)/sizeof(arr[0]))
typedef unsigned long Pixel;
typedef char Boolean;
typedef unsigned int Dimension;
#undef TOOLKIT
#undef MOTIF
#undef BUTTONS
#undef CFG2RES
#endif /* NOTOOL */
#endif /* !WIN32 */
#if defined(CFG2RES) && !defined(SELFAUTO)
#define SELFAUTO 1
#endif
#if defined(SELFAUTO) && !defined(DEFAULT_CONFIG_PATH)
#define DEFAULT_CONFIG_PATH "$SELFAUTODIR:$SELFAUTOPARENT"
#endif
#undef CFGFILE /* no cheating */
#if defined(DEFAULT_CONFIG_PATH)
#define CFGFILE 1
#endif
typedef char Bool3; /* Yes/No/Maybe */
#define True 1
#define False 0
#define Maybe 2
#define INVALID_WIDTH 017777777777
#ifdef VMS
#include <string.h>
#define index strchr
#define rindex strrchr
#define bzero(a, b) (void) memset ((void *) (a), 0, (size_t) (b))
#define bcopy(a, b, c) (void) memmove ((void *) (b), (void *) (a), (size_t) (c))
#endif
#ifdef WIN32
#include <sys/types.h>
typedef long off_t;
#include <io.h>
#endif
#include <stdio.h>
#include <setjmp.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_DIRENT_H
# include <dirent.h>
# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
# if HAVE_SYS_NDIR_H
# include <sys/ndir.h>
# endif
# if HAVE_SYS_DIR_H
# include <sys/dir.h>
# endif
# if HAVE_NDIR_H
# include <ndir.h>
# endif
#endif
#ifndef NeedFunctionPrototypes
#if __STDC__
#define NeedFunctionPrototypes 1
#else /* STDC */
#define NeedFunctionPrototypes 0
#endif /* STDC */
#endif /* NeedFunctionPrototypes */
#if NeedFunctionPrototypes
#define ARGS(x) x
#else
#define ARGS(x) ()
#endif
#ifndef NeedWidePrototypes
#define NeedWidePrototypes NeedFunctionPrototypes
#endif
#include <kpathsea/c-vararg.h>
#ifndef _XFUNCPROTOBEGIN
#define _XFUNCPROTOBEGIN
#define _XFUNCPROTOEND
#endif
#ifndef _Xconst
#if __STDC__
#define _Xconst const
#else /* STDC */
#define _Xconst
#endif /* STDC */
#endif /* _Xconst */
#ifdef WIN32
#undef _Xconst
#define _Xconst
#endif
#ifndef VOLATILE
#if __STDC__ || (defined(__stdc__) && defined(__convex__))
#define VOLATILE volatile
#else
#define VOLATILE /* nothing */
#endif
#endif
#ifndef NORETURN
#ifdef __GNUC__
#define NORETURN volatile
#else
#define NORETURN /* nothing */
#endif
#endif
#ifndef OPEN_MODE
#define OPEN_MODE FOPEN_RBIN_MODE
#endif /* OPEN_MODE */
#ifndef VMS
#define OPEN_MODE_ARGS _Xconst char *
#else
#define OPEN_MODE_ARGS _Xconst char *, _Xconst char *
#endif
#define Printf (void) printf
#define Puts (void) puts
#define Fprintf (void) fprintf
#define Sprintf (void) sprintf
#define Fseek (void) fseek
#define Fread (void) fread
#define Fputs (void) fputs
#define Putc (void) putc
#define Putchar (void) putchar
#define Fclose (void) fclose
#define Fflush (void) fflush
#define Strcat (void) strcat
#define Strcpy (void) strcpy
#define Exit(n) (void) CleanExit(n)
#define GC HDC
#define Cursor HCURSOR
#define Window HWND
#define Widget HWND
#define caddr_t void*
#define XtNumber(arr) (sizeof(arr)/sizeof(arr[0]))
typedef COLORREF Pixel;
typedef RGBQUAD XColor;
typedef char Boolean;
typedef unsigned int Dimension;
typedef short Position;
typedef char Bool3; /* Yes/No/Maybe */
typedef struct _ximage {
int width;
int height;
unsigned int depth;
unsigned int *endian_permuted;
unsigned int bytes_per_line;
unsigned char *data; } XImage;
typedef struct BITMAPINFO_256 {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[256];
} BITMAPINFO_256;
#define DISP NULL
#define SCRN NULL
#define XYBitmap 0
#define ZPixmap 0
/* Macro to determine to round off the given value to the closest byte */
#define WIDTHBYTES(i) ((i+31)/32*4)
#define WhitePixelOfScreen(SCRN) PALETTERGB(255,255,255)
#define BlackPixelOfScreen(SCRN) PALETTERGB(0,0,0)
/* Bit Gravity */
#define ForgetGravity 0
#define NorthWestGravity 1
#define NorthGravity 2
#define NorthEastGravity 3
#define WestGravity 4
#define CenterGravity 5
#define EastGravity 6
#define SouthWestGravity 7
#define SouthGravity 8
#define SouthEastGravity 9
#define StaticGravity 10
#define NoValue 0x0000
#define XValue 0x0001
#define YValue 0x0002
#define WidthValue 0x0004
#define HeightValue 0x0008
#define AllValues 0x000F
#define XNegative 0x0010
#define YNegative 0x0020
#define USPosition (1L << 0) /* user specified x, y */
#define USSize (1L << 1) /* user specified width, height */
#define PPosition (1L << 2) /* program specified position */
#define PSize (1L << 3) /* program specified size */
#define PMinSize (1L << 4) /* program specified minimum size */
#define PMaxSize (1L << 5) /* program specified maximum size */
#define PResizeInc (1L << 6) /* program specified resize increments */
#define PAspect (1L << 7) /* program specified min and max aspect ratios */
#define PBaseSize (1L << 8) /* program specified base for incrementing */
#define PWinGravity (1L << 9) /* program specified window gravity */
extern int XParseGeometry (char *s, int *x, int *y,
unsigned int *w, unsigned int *h);
#ifdef HTEX
char *urlocalize ARGS((char *filename));
int lastwwwopen;
#endif
/********************************
* Types and data *
*******************************/
#ifndef EXTERN
#define EXTERN extern
#define INIT(x)
#endif
#define MAXDIM 32767
typedef unsigned char ubyte;
#if NeedWidePrototypes
typedef unsigned int wide_ubyte;
typedef int wide_bool;
#define WIDENINT (int)
#else
typedef ubyte wide_ubyte;
typedef Boolean wide_bool;
#define WIDENINT
#endif
#if defined(MAKETEXPK) && !defined(MKTEXPK)
#define MKTEXPK 1
#endif
/*
* pixel_conv is currently used only for converting absolute positions
* to pixel values; although normally it should be
* ((int) ((x) / shrink_factor + (1 << 15) >> 16)),
* the rounding is achieved instead by moving the constant 1 << 15 to
* PAGE_OFFSET in dvi_draw.c.
*/
#define pixel_conv(x) ((int) ((x) / shrink_factor >> 16))
#define pixel_round(x) ((int) ROUNDUP(x, shrink_factor << 16))
#define spell_conv0(n, f) ((long) (n * f))
#define spell_conv(n) spell_conv0(n, dimconv)
#define BMUNIT unsigned BMTYPE
#define BMBITS (8 * BMBYTES)
#define ADD(a, b) ((BMUNIT *) (((char *) a) + b))
#define SUB(a, b) ((BMUNIT *) (((char *) a) - b))
extern BMUNIT bit_masks[BMBITS + 1];
struct frame {
/* dvi_h and dvi_v is the horizontal and vertical baseline position
it is the responsebility of the set_char procedure to update
them. */
struct framedata {
long dvi_h, dvi_v, w, x, y, z;
int pxl_v;
} data;
struct frame *next, *prev;
};
#ifndef TEXXET
typedef long (*set_char_proc) ARGS((wide_ubyte));
#else
typedef void (*set_char_proc) ARGS((wide_ubyte, wide_ubyte));
#endif
struct drawinf { /* this information is saved when using virtual fonts */
struct framedata data;
struct font *fontp;
set_char_proc set_char_p;
int tn_table_len;
struct font **tn_table;
struct tn *tn_head;
ubyte *pos, *end;
struct font *virtual;
#ifdef TEXXET
int dir;
#endif
};
EXTERN struct drawinf currinf;
/* entries below with the characters 'dvi' in them are actually stored in
scaled pixel units */
#define DVI_H currinf.data.dvi_h
#define PXL_H pixel_conv(currinf.data.dvi_h)
#define DVI_V currinf.data.dvi_v
#define PXL_V currinf.data.pxl_v
#define WW currinf.data.w
#define XX currinf.data.x
#define YY currinf.data.y
#define ZZ currinf.data.z
#define ROUNDUP(x,y) (((x)+(y)-1)/(y))
EXTERN int current_page;
EXTERN int total_pages;
EXTERN int pageno_correct INIT(1);
EXTERN long magnification;
EXTERN double dimconv;
EXTERN double tpic_conv;
EXTERN int n_files_left INIT(24); /* for LRU closing of fonts */
EXTERN time_t dvi_time; /* last mod. time for dvi file */
EXTERN unsigned int page_w, page_h;
#if defined(GS_PATH) && !defined(PS_GS)
#define PS_GS
#endif
#if defined(PS_DPS) || defined(PS_NEWS) || defined(PS_GS)
#define PS 1
#else
#define PS 0
#endif
#if PS
EXTERN int scanned_page; /* last page prescanned */
EXTERN int scanned_page_bak; /* actual value of the above */
EXTERN int scanned_page_reset; /* number to reset the above to */
#endif
/*
* Table of page offsets in DVI file, indexed by page number - 1.
* Initialized in prepare_pages().
*/
EXTERN long *page_offset;
/*
* Mechanism for reducing repeated warning about specials, lost characters, etc.
*/
EXTERN Boolean warn_spec_now;
/*
* added Stefan Ulrich
*/
EXTERN Boolean delay_src INIT(False);
/*
* If we're in the middle of a PSFIG special.
*/
EXTERN Boolean psfig_begun INIT(False);
/* BEGIN CHUNK xdvi.h 1 */
#ifdef SRC_SPECIALS
EXTERN Boolean src_specials_are_evaluated INIT(False);
EXTERN Boolean src_EditorCmd_filename_first;
EXTERN int src_tickShape;
EXTERN int src_tick_height, src_tick_width; /* size of the src tick glyphs */
#define SPECIAL_SHAPE_MAX_NUM 4 /* number of different shapes (starting from 0)
for drawing src specials. Hardcoding these here is a bad idea ... */
EXTERN Cursor save_cursor;
#define SRC_WARNINGS_SILENT 0
#define SRC_WARNINGS_MEDIUM 1
#define SRC_WARNINGS_VERBOSE 2
#endif
/* END CHUNK xdvi.h 1 */
/*
* Bitmap structure for raster ops.
*/
struct bitmap {
unsigned short w, h; /* width and height in pixels */
short bytes_wide; /* scan-line width in bytes */
unsigned int endian_permuted;
char *bits; /* pointer to the bits */
};
/*
* Per-character information.
* There is one of these for each character in a font (raster fonts only).
* All fields are filled in at font definition time,
* except for the bitmap, which is "faulted in"
* when the character is first referenced.
*/
struct glyph {
long addr; /* address of bitmap in font file */
long dvi_adv; /* DVI units to move reference point */
short x, y; /* x and y offset in pixels */
struct bitmap bitmap; /* bitmap for character */
short x2, y2; /* x and y offset in pixels (shrunken bitmap) */
#ifdef GREY
XImage *image2;
char *pixmap2;
char *pixmap2_t;
#endif
struct bitmap bitmap2; /* shrunken bitmap for character */
};
/*
* Per character information for virtual fonts
*/
struct macro {
ubyte *pos; /* address of first byte of macro */
ubyte *end; /* address of last+1 byte */
long dvi_adv; /* DVI units to move reference point */
Boolean free_me; /* if free(pos) should be called when */
/* freeing space */
};
/*
* The layout of a font information block.
* There is one of these for every loaded font or magnification thereof.
* Duplicates are eliminated: this is necessary because of possible recursion
* in virtual fonts.
*
* Also note the strange units. The design size is in 1/2^20 point
* units (also called micro-points), and the individual character widths
* are in the TFM file in 1/2^20 ems units, i.e., relative to the design size.
*
* We then change the sizes to SPELL units (unshrunk pixel / 2^16).
*/
#define NOMAGSTP (-29999)
typedef void (*read_char_proc) ARGS((register struct font *, wide_ubyte));
struct font {
struct font *next; /* link to next font info block */
char *fontname; /* name of font */
float fsize; /* size information (dots per inch) */
int magstepval; /* magstep number * two, or NOMAGSTP */
FILE *file; /* open font file or NULL */
char *filename; /* name of font file */
long checksum; /* checksum */
unsigned short timestamp; /* for LRU management of fonts */
ubyte flags; /* flags byte (see values below) */
#ifdef Omega
wide_ubyte maxchar; /* largest character code */
#else
ubyte maxchar; /* largest character code */
#endif
double dimconv; /* size conversion factor */
set_char_proc set_char_p; /* proc used to set char */
/* these fields are used by (loaded) raster fonts */
read_char_proc read_char; /* function to read bitmap */
struct glyph *glyph;
/* these fields are used by (loaded) virtual fonts */
struct font **vf_table; /* list of fonts used by this vf */
struct tn *vf_chain; /* ditto, if TeXnumber >= VFTABLELEN */
struct font *first_font; /* first font defined */
struct macro *macro;
/* I suppose the above could be put into a union, but we */
/* wouldn't save all that much space. */
#ifdef T1
/* These were added for t1 use */
int t1id;
long scale;
#endif
/* BEGIN CHUNK xdvi.h 2 */
#ifdef SRC_SPECIALS
float pt_size; /* font size in pt, needed for specials evaluation */
#endif
/* END CHUNK xdvi.h 2 */
};
#define FONT_IN_USE 1 /* used for housekeeping */
#define FONT_LOADED 2 /* if font file has been read */
#define FONT_VIRTUAL 4 /* if font is virtual */
#define TNTABLELEN 30 /* length of TeXnumber array (dvi file) */
#define VFTABLELEN 5 /* length of TeXnumber array (virtual fonts) */
struct tn {
struct tn *next; /* link to next TeXnumber info block */
int TeXnumber; /* font number (in DVI file) */
struct font *fontp; /* pointer to the rest of the info */
};
EXTERN struct font *tn_table[TNTABLELEN];
EXTERN struct font *font_head INIT(NULL);
EXTERN struct tn *tn_head INIT(NULL);
#ifdef Omega
EXTERN wide_ubyte maxchar;
#else
EXTERN ubyte maxchar;
#endif
EXTERN unsigned short current_timestamp INIT(0);
/*
* Command line flags.
*/
extern struct _resource {
#if CFGFILE && TOOLKIT
_Xconst char *progname;
#endif
#if TOOLKIT
int shrinkfactor;
#endif
int _density;
#ifdef GREY
float _gamma;
#endif
int _pixels_per_inch;
Boolean _delay_rulers;
int _tick_length;
char *_tick_units;
_Xconst char *sidemargin;
_Xconst char *topmargin;
_Xconst char *xoffset;
_Xconst char *yoffset;
_Xconst char *paper;
_Xconst char *_alt_font;
Boolean makepk;
_Xconst char *mfmode;
Boolean _list_fonts;
Boolean reverse;
Boolean _warn_spec;
Boolean _hush_chars;
Boolean _hush_chk;
Boolean safer;
#if defined(VMS) || defined(WIN32) || !defined(TOOLKIT)
_Xconst char *fore_color;
_Xconst char *back_color;
#endif
Pixel _fore_Pixel;
Pixel _back_Pixel;
#ifdef TOOLKIT
Pixel _brdr_Pixel;
Pixel _hl_Pixel;
Pixel _cr_Pixel;
#endif
_Xconst char *icon_geometry;
Boolean keep_flag;
Boolean copy;
Boolean thorough;
#if PS
/* default is to use DPS, then NEWS, then GhostScript;
* we will figure out later on which one we will use */
Boolean _postscript;
Boolean prescan;
Boolean allow_shell;
#ifdef PS_DPS
Boolean useDPS;
#endif
#ifdef PS_NEWS
Boolean useNeWS;
#endif
#ifdef PS_GS
Boolean useGS;
Boolean gs_safer;
Boolean gs_alpha;
_Xconst char *gs_path;
_Xconst char *gs_palette;
#endif
#endif /* PS */
_Xconst char *debug_arg;
Boolean version_flag;
#ifdef BUTTONS
Boolean expert;
int shrinkbutton[4];
#endif
_Xconst char *mg_arg[5];
#ifdef GREY
Boolean _use_grey;
Bool3 install;
#endif
#ifdef GRID
int _grid_mode;
char *grid1_color, *grid2_color, *grid3_color;
#ifdef TOOLKIT
Pixel _grid1_Pixel, _grid2_Pixel, _grid3_Pixel;
#endif /* TOOLKIT */
#endif /* GRID */
#ifdef HTEX
Boolean _underline_link;
char *_browser;
char *_URLbase;
char *_scroll_pages;
#endif /* HTEX */
/* BEGIN CHUNK xdvi.h 3 */
#ifdef SRC_SPECIALS
int _src_specialFormat;
int _src_jumpButton;
int _src_tickShape;
char *_src_tickSize;
int _src_cursor_shape;
char *_src_editorCommand;
int _src_warn_verbosity;
Boolean _src_tickVisibility;
Boolean _src_evalMode;
#endif
/* END CHUNK xdvi.h 3 */
#ifdef WIN32
Boolean single_flag;
int numColors;
Boolean scan_flag;
Boolean log_flag;
Boolean in_memory;
Boolean use_xform;
Boolean book_mode;
#endif
} resource;
/* As a convenience, we define the field names without leading underscores
* to point to the field of the above record. Here are the global ones;
* the local ones are defined in each module. */
/* BEGIN CHUNK xdvi.h 4 */
#ifdef SRC_SPECIALS
#define src_cursor_shape resource._src_cursor_shape
#define src_editorCommand resource._src_editorCommand
#define src_warn_verbosity resource._src_warn_verbosity
#define src_tickShape resource._src_tickShape
#define src_tickVisibility resource._src_tickVisibility
#define src_evalMode resource._src_evalMode
#endif
/* END CHUNK xdvi.h 4 */
#define density resource._density
#define pixels_per_inch resource._pixels_per_inch
#define alt_font resource._alt_font
#define list_fonts resource._list_fonts
#define warn_spec resource._warn_spec
#define hush_chars resource._hush_chars
#define hush_chk resource._hush_chk
#ifdef GREY
#define use_grey resource._use_grey
#endif
#ifdef GRID
#define grid_mode resource._grid_mode
#endif /* GRID */
#ifdef HTEX
#define underline_link resource._underline_link
#define browser resource._browser
#define URLbase resource._URLbase
#define scroll_pages resource._scroll_pages
#define KPSE_DEBUG_HYPER 6
#endif
#ifndef TOOLKIT
EXTERN Pixel brdr_Pixel;
#ifdef GRID
EXTERN Pixel grid1_Pixel;
EXTERN Pixel grid2_Pixel;
EXTERN Pixel grid3_Pixel;
#endif /* GRID */
#endif
#ifdef GREY
EXTERN Pixel plane_masks[4];
EXTERN XColor fore_color_data, back_color_data;
#endif
extern struct mg_size_rec {
int w;
int h;
}
mg_size[5];
EXTERN int debug INIT(0);
#define DBG_BITMAP 1
#define DBG_DVI 2
#define DBG_PK 4
#define DBG_BATCH 8
#define DBG_EVENT 16
#define DBG_OPEN 32
#define DBG_PS 64
#define DBG_STAT 128
#define DBG_HASH 256
#define DBG_PATHS 512
#define DBG_EXPAND 1024
#define DBG_SEARCH 2048
#ifdef HTEX
#define DBG_HYPER 4096
#define DBG_ANCHOR 8192
#endif
/* BEGIN CHUNK xdvi.h 5 */
#ifdef SRC_SPECIALS
#define DBG_SRC_SPECIALS 16384
#endif
/* END CHUNK xdvi.h 5 */
#define DBG_ALL (~DBG_BATCH)
EXTERN int offset_x, offset_y;
EXTERN unsigned int unshrunk_paper_w, unshrunk_paper_h;
EXTERN unsigned int unshrunk_page_w, unshrunk_page_h;
EXTERN unsigned int unshrunk_dvifile_page_w, unshrunk_dvifile_page_h;
#ifdef GRID
EXTERN unsigned int unshrunk_paper_unit;
#endif /* GRID */
EXTERN char *temporary_dir INIT(NULL);
#ifdef HTEX
EXTERN int HTeXnext_extern; /* Bring up next file in new xdvi window */
EXTERN char *anchor_name INIT(NULL);
EXTERN Boolean URL_aware INIT(False);
EXTERN Boolean highlight INIT(False);
extern int HTeXAnestlevel; /* Hypertext nesting level */
extern int HTeXreflevel; /* flag for whether we are inside an href */
#endif
EXTERN char *dvi_name INIT(NULL);
EXTERN FILE *dvi_file; /* user's file */
EXTERN unsigned long dvipos;
EXTERN enum {CLEARED, SAVED, RESTORED} dvistate;
EXTERN _Xconst char *prog;
EXTERN int bak_shrink; /* last shrink factor != 1 */
EXTERN Dimension window_w, window_h;
EXTERN XImage *image;
EXTERN int backing_store;
EXTERN int home_x, home_y;
#ifndef WIN32
EXTERN Display *DISP;
EXTERN Screen *SCRN;
#ifdef GREY
EXTERN int screen_number;
EXTERN Visual *our_visual;
EXTERN unsigned int our_depth;
EXTERN Colormap our_colormap;
EXTERN GC copyGC;
#else
#define our_depth (unsigned int) DefaultDepthOfScreen(SCRN)
#define our_visual DefaultVisualOfScreen(SCRN)
#define our_colormap DefaultColormapOfScreen(SCRN)
#define copyGC DefaultGCOfScreen(SCRN)
#endif
#else /* WIN32 */
EXTERN char *sOutputName INIT(NULL);
EXTERN char ***sCmdArg INIT(NULL);
#endif /* !WIN32 */
EXTERN GC ruleGC;
EXTERN GC foreGC, highGC;
EXTERN GC foreGC2;
#ifdef GRID
EXTERN GC grid1GC, grid2GC, grid3GC;
#endif /* GRID */
EXTERN Boolean copy;
EXTERN Boolean allowDrawingChars;
EXTERN Cursor redraw_cursor, ready_cursor;
#ifdef GREY
EXTERN COLORREF palette[17];
EXTERN RGBQUAD pal_rgb[17];
EXTERN RGBQUAD pal_bw[17];
EXTERN RGBQUAD pal_mask[17];
EXTERN unsigned long *pixeltbl;
EXTERN Pixel *pixeltbl_t;
#endif /* GREY */
EXTERN Boolean canit INIT(False);
EXTERN jmp_buf canit_env;
EXTERN VOLATILE short event_counter INIT(0);
struct WindowRec {
Window win;
int shrinkfactor;
int base_x, base_y;
unsigned int width, height;
int min_x, max_x, min_y, max_y; /* for pending expose events */
};
extern struct WindowRec mane, alt, currwin;
EXTERN int min_x, max_x, min_y, max_y;
#define shrink_factor currwin.shrinkfactor
#if defined(TOOLKIT) && !defined(WIN32)
EXTERN Widget top_level, vport_widget, draw_widget, clip_widget;
#ifdef HTEX
EXTERN Widget pane_widget, anchor_search, anchor_info;
#endif
#ifdef MOTIF
EXTERN Widget shrink_button[4];
EXTERN Widget x_bar, y_bar; /* horizontal and vert. scroll bars */
#endif /* MOTIF */
#ifdef BUTTONS
#ifndef MOTIF
#define XTRA_WID 79
#else
#define XTRA_WID 120
#endif
EXTERN Widget form_widget;
#endif
#else /* !TOOLKIT || WIN32 */
EXTERN Window top_level;
#ifdef WIN32
EXTERN Widget anchor_search INIT(NULL);
EXTERN Widget anchor_info INIT(NULL);
#endif
#define BAR_WID 12 /* width of darkened area */
#define BAR_THICK 15 /* gross amount removed */
#endif /* TOOLKIT */
EXTERN jmp_buf dvi_env; /* mechanism to relay dvi file errors */
EXTERN _Xconst char *dvi_oops_msg; /* error message */
EXTERN char *ffline INIT(NULL); /* an array used by filefind to store */
/* the file name being formed. */
/* It expands as needed. */
/* Also used elsewhere. */
EXTERN int ffline_len INIT(0); /* current length of ffline[] */
#ifdef SELFAUTO
EXTERN _Xconst char *argv0; /* argv[0] */
#endif
#ifdef CFG2RES
struct cfg2res {
_Xconst char *cfgname; /* name in config file */
_Xconst char *resname; /* name of resource */
Boolean numeric; /* if numeric */
};
#endif
#if PS
extern struct psprocs {
void (*toggle) ARGS((void));
void (*destroy) ARGS((void));
void (*interrupt) ARGS((void));
void (*endpage) ARGS((void));
void (*drawbegin) ARGS((int, int, _Xconst char *));
void (*drawraw) ARGS((_Xconst char *));
void (*drawfile) ARGS((_Xconst char *, FILE *, _Xconst char *));
void (*drawend) ARGS((_Xconst char *));
void (*beginheader) ARGS((void));
void (*endheader) ARGS((void));
void (*newdoc) ARGS((void));
} psp, no_ps_procs;
#endif /* PS */
EXTERN BITMAPINFO_256 bmi1, bmi4, bmi8, bmi24;
EXTERN int nbDIBS INIT(0);
EXTERN HBITMAP oldmaneDIB INIT(NULL);
EXTERN HBITMAP oldmagDIB INIT(NULL);
EXTERN HBITMAP oldimageDIB INIT(NULL);
/* The default colors for the win32 color map */
typedef struct colormap_t
{
char *name;
COLORREF colorref;
} colormap_t;
extern colormap_t win32_color_map[];
extern int win32_color_map_size;
/********************************
* Procedures *
*******************************/
_XFUNCPROTOBEGIN
#ifdef BUTTONS
extern void create_buttons ARGS((XtArgVal));
#endif
#ifdef GREY
extern void init_plane_masks ARGS((void));
extern Boolean init_pix ARGS((COLORREF, COLORREF));
#endif
extern void init_colors ARGS((void));
extern Boolean reconfig ARGS((void));
#if defined(TOOLKIT) && !defined(WIN32)
extern void handle_key ARGS((Widget, XtPointer, XEvent *, Boolean *));
extern void handle_resize ARGS((Widget, XtPointer, XEvent *, Boolean *));
extern void handle_button ARGS((Widget, XtPointer, XEvent *, Boolean *));
extern void handle_motion ARGS((Widget, XtPointer, XEvent *, Boolean *));
extern void handle_release ARGS((Widget, XtPointer, XEvent *, Boolean *));
extern void handle_exp ARGS((Widget, XtPointer, XEvent *, Boolean *));
#endif
#ifdef MOTIF
extern void file_pulldown_callback ARGS((Widget, XtPointer, XtPointer));
extern void navigate_pulldown_callback ARGS((Widget, XtPointer, XtPointer));
extern void scale_pulldown_callback ARGS((Widget, XtPointer, XtPointer));
extern void set_shrink_factor ARGS((int));
#endif
extern void showmessage ARGS((_Xconst char *));
#if PS
extern void ps_read_events ARGS((wide_bool, wide_bool));
#define read_events(wait) ps_read_events(wait, True)
#else
extern void read_events ARGS((wide_bool));
#endif
extern void redraw_page ARGS((void));
extern void do_pages ARGS((void));
extern void reset_fonts ARGS((void));
extern void realloc_font ARGS((struct font *, wide_ubyte));
extern void realloc_virtual_font ARGS((struct font *, wide_ubyte));
extern Boolean load_font ARGS((struct font *));
extern struct font *define_font ARGS((FILE *, wide_ubyte,
struct font *, struct font **, unsigned int,
struct tn **));
extern void init_page ARGS((void));
extern void set_directory_dvifile ARGS((void));
extern void open_dvi_file ARGS((void));
extern Boolean check_dvi_file ARGS((void));
extern void put_border ARGS((int, int, unsigned int, unsigned int, GC));
#ifdef GRID
#ifdef WIN32
extern void put_grid ARGS((struct WindowRec *, unsigned int, GC, GC, GC));
#else
extern void put_grid ARGS((int, int, unsigned int, unsigned int, unsigned int, GC, GC, GC));
#endif
#endif /* GRID */
#ifndef TEXXET
extern long set_char ARGS((wide_ubyte));
extern long load_n_set_char ARGS((wide_ubyte));
extern long set_vf_char ARGS((wide_ubyte));
#if TTF
extern long set_ttf_char P1H(wide_ubyte);
#endif
#if T1
extern long set_t1_char P1H(wide_ubyte);
#endif
#else
extern void set_char ARGS((wide_ubyte, wide_ubyte));
extern void load_n_set_char ARGS((wide_ubyte, wide_ubyte));
extern void set_vf_char ARGS((wide_ubyte, wide_ubyte));
#if TTF
extern void set_ttf_char P2H(wide_ubyte, wide_ubyte);
#endif
#if T1
extern void set_t1_char P2H(wide_ubyte, wide_ubyte);
#endif
#endif
extern int tfmload P3H(char *, long *, long *);
#if TTF
extern void read_TTF_char P2H(struct font *, ubyte);
extern int find_TTF_font P1H(char *);
#endif
#if T1
extern void read_T1_char P2H(struct font *, ubyte);
extern int find_T1_font P1H(char *);
extern void init_t1 P1H(void);
#endif
extern int getpsinfo P1H(char *);
extern void draw_page P1H(void);
#if CFGFILE
#ifndef CFG2RES
extern void readconfig ARGS((void));
#else
extern void readconfig ARGS((_Xconst struct cfg2res *,
_Xconst struct cfg2res *, XtResource *, XtResource *));
#endif /* CFG2RES */
#endif /* CFGFILE */
extern void init_font_open ARGS((void));
#if T1
extern FILE *font_open P7H(char *, char **, double, int *, int,
char **,int *);
#else
extern FILE *font_open P6H(char *, char **, double, int *, int,
char **);
#endif
#if PS
extern void ps_newdoc ARGS((void));
extern void ps_destroy ARGS((void));
#endif
extern void applicationDoSpecial ARGS((char *, int));
#if PS
extern void scan_special ARGS((char *));
#endif
extern NORETURN void oops ARGS((_Xconst char *message, ...));
#ifndef KPATHSEA
extern void *xmalloc ARGS((unsigned));
extern void *xrealloc ARGS((void *, unsigned));
extern char *xstrdup ARGS((_Xconst char *, int));
extern char *xmemdump ARGS((_Xconst char *, int));
#endif
extern void expandline ARGS((int));
extern void alloc_bitmap ARGS((struct bitmap *));
#ifndef KPATHSEA
extern void xputenv ARGS((const char *, const char *));
#endif
#ifndef WIN32
extern int memicmp ARGS((_Xconst char *, _Xconst char *, size_t));
#endif
extern FILE *xfopen ARGS((_Xconst char *, OPEN_MODE_ARGS));
#ifdef HTEX
extern FILE *xfopen_local ARGS((_Xconst char *, OPEN_MODE_ARGS));
#else
#define xfopen_local xfopen
#endif
#ifndef WIN32
extern int xpipe ARGS((int *));
extern DIR *xdvi_xopendir ARGS((_Xconst char *));
extern _Xconst struct passwd *ff_getpw ARGS((_Xconst char **, _Xconst char *));
#endif
extern unsigned long num ARGS((FILE *, int));
extern long snum ARGS((FILE *, int));
extern void read_PK_index ARGS((struct font *, wide_bool));
extern void read_GF_index ARGS((struct font *, wide_bool));
#ifdef Omega
extern unsigned long read_VF_index ARGS((struct font *, wide_bool));
#else
extern void read_VF_index ARGS((struct font *, wide_bool));
#endif
#if PS
extern void drawbegin_none ARGS((int, int, _Xconst char *));
extern void beginheader_none ARGS(());
extern void draw_bbox ARGS((void));
extern void NullProc ARGS((void));
#ifdef PS_DPS
extern Boolean initDPS ARGS((void));
#endif
#ifdef PS_NEWS
extern Boolean initNeWS ARGS((void));
#endif
#ifdef PS_GS
extern Boolean initGS ARGS((void));
#endif
#ifdef WIN32
#include "gsdll.h"
#endif
#endif /* PS */
#ifdef HTEX
extern int open_www_file ARGS((void));
extern void cleanup_and_exit ARGS((int));
extern void htex_can_it ARGS((void));
extern void search_callback ARGS((Widget, XtPointer, XtPointer));
extern KPSEDLL string xgetcwd ARGS((void));
extern void detach_anchor ARGS((void));
extern FILE *xfopen_local ARGS((_Xconst char *, OPEN_MODE_ARGS));
extern char *MyStrAllocCopy ARGS((char **, char *));
extern int pointerlocate ARGS((int *, int *));
extern void htex_recordbits ARGS((int, int, int, int));
extern void htex_initpage ARGS((void));
extern void htex_donepage ARGS((int, int));
extern void htex_parsepages ARGS((void));
extern void htex_parse_page ARGS((int));
extern void htex_scanpage ARGS((int));
extern void htex_scanpage ARGS((int));
extern void htex_dospecial ARGS((long, int));
extern void htex_reinit ARGS((void));
extern void htex_do_loc ARGS((char *));
extern void add_search ARGS((char *, int));
extern int htex_handleref ARGS((int, int, int));
extern void htex_displayanchor ARGS((int, int, int));
extern void htex_goback ARGS((void));
extern int checkHyperTeX ARGS((char *, int));
extern void htex_handletag ARGS((char *, int));
extern void htex_anchor ARGS((int, char *, int));
extern void htex_dohref ARGS((char *));
extern void htex_drawboxes ARGS((void));
extern void htex_to_page ARGS((int));
extern void htex_to_anchor ARGS((int, int));
extern int htex_is_url ARGS((const char *));
extern void htex_do_url ARGS((char *));
extern void paint_anchor ARGS((char *));
extern int fetch_relative_url ARGS((char *, const char *, char *));
extern void wait_for_urls ARGS((void));
#endif
/* BEGIN CHUNK xdvi.h 7 */
#ifdef SRC_SPECIALS
/* functions in src_special.c */
extern void src_find_special ARGS((int, Position, Position));
extern void src_delete_all_specials ARGS((void));
extern void src_warn_outdated ARGS((void));
extern void src_eval_special ARGS((char *, Position, Position));
extern void src_check_editorCommand ARGS((void));
extern void src_cleanup ARGS((void));
// extern void src_do_special ARGS((float));
extern float src_look_forward ARGS((double));
#endif
/* END CHUNK xdvi.h 7 */
_XFUNCPROTOEND
#define one(fp) ((unsigned char) getc(fp))
#define sone(fp) ((long) one(fp))
#define two(fp) num (fp, 2)
#define stwo(fp) snum(fp, 2)
#define four(fp) num (fp, 4)
#define sfour(fp) snum(fp, 4)
#ifdef HTEX
/* From xhdvi/url.h */
/* Some URL stuff: */
typedef struct {
char *url; /* Full address of the URL we have locally */
char *file; /* Local file name it is stored as */
} FiletoURLconv;
#define FILELISTCHUNK 20
EXTERN FiletoURLconv *filelist INIT(NULL);
EXTERN int nURLs INIT(0);
#define exit(n) cleanup_and_exit(n)
#endif /* HTEX */
#define delay_rulers resource._delay_rulers
#define tick_units resource._tick_units
#define tick_length resource._tick_length
#define fore_Pixel resource._fore_Pixel
#define back_Pixel resource._back_Pixel
#if defined(TOOLKIT)
struct _resource resource;
#define brdr_Pixel resource._brdr_Pixel
#define hl_Pixel resource._hl_Pixel
#define cr_Pixel resource._cr_Pixel
#ifdef GRID
#define grid1_Pixel resource._grid1_Pixel
#define grid2_Pixel resource._grid2_Pixel
#define grid3_Pixel resource._grid3_Pixel
#endif /* GRID */
#else /* TOOLKIT */
static Pixel hl_Pixel, cr_Pixel;
#ifdef GRID
static Pixel grid1_Pixel, grid2_Pixel, grid3_Pixel;
#endif /* GRID */
#endif /* TOOLKIT */
#ifdef GREY
#define gamma resource._gamma
#endif
#include "patchlevel.h"
#ifdef Omega
static _Xconst char *version = "(Omega) oxdvik version 20a";
#else
static _Xconst char *version = "xdvik version 20a";
#endif
EXTERN char *display;
EXTERN char *geometry;
EXTERN char *margins;
EXTERN char *offsets;
EXTERN Boolean hush;
extern Boolean iconic;
extern Dimension bwidth;
EXTERN char *curr_page;
/* Win32 specific variables */
EXTERN HDC maneDC, maneDrawDC, maneDrawMemDC;
EXTERN HDC imageDC;
EXTERN HPEN forePen INIT(0);
EXTERN HPEN foreTPicPen INIT(0);
EXTERN HPEN backTPicPen INIT(0);;
EXTERN HBRUSH foreBrush INIT(0);
EXTERN HBRUSH backBrush INIT(0);
EXTERN HBRUSH foreTPicBrush INIT(0);
EXTERN HCURSOR hCursWait, hCursArrow, hCursCross, hCursSrc;
EXTERN int maneHorzRes;
EXTERN int maneVertRes;
EXTERN int maneLogPixelsX;
EXTERN int maneLogPixelsY;
EXTERN int maneBitsPixel;
EXTERN int maneSizePalette;
EXTERN int maneColorRes;
EXTERN int maneRasterCaps;
EXTERN int numColors; /* num colors actually used */
/* Utility functions */
typedef void (* PF_BSWAP)(void *, unsigned count);
int check_386();
void bswap_asm(void *p, unsigned count);
void bswap_c(void *p, unsigned count);
EXTERN PF_BSWAP bswap;
/*
Color functions
*/
#define COLOR_STACK_DEPTH 256
typedef struct _CRefStack {
COLORREF *s;
int max;
int i;
} CRefStack, *lpCRefStack;
EXTERN lpCRefStack color_stack;
EXTERN BOOL bColorPage; /* If there are no colors on the page, don't bother */
lpCRefStack InitCRefStack(int);
BOOL CRefIsEmpty(lpCRefStack);
void CRefPush(lpCRefStack, COLORREF);
COLORREF CRefPop(lpCRefStack);
COLORREF CRefTop(lpCRefStack);
lpCRefStack CRefSave(lpCRefStack);
void CRefRestore(lpCRefStack, lpCRefStack);
void CRefResetInit(lpCRefStack, COLORREF);
/*
Various variables
*/
extern Boolean psToDisplay;
extern BOOL bMagDisp, bSetHome;
extern BOOL isPrinting, isPrintingDvips;
extern BOOL bDrawKeep;
extern BOOL bSkipFirstClick;
extern unsigned char *gs_device;
extern COLORREF ColorInvert(COLORREF);
extern RGBQUAD Color2Quad(COLORREF);
extern void initialize_palette(void);
extern void setup_palette(RGBQUAD *, int);
extern void init_colors(void);
extern COLORREF string_to_colorref(char *);
extern void SetForeColor(COLORREF);
extern void SetBackColor(COLORREF);
extern void initcolor();
/*
Transformation matrix
*/
extern XFORM xfrmTransf, xfrmUnit, xfrmTemp;
EXTERN BOOL bMatrixUnit INIT(TRUE);
/*
* X11 replacements
*/
extern void XDrawLine(void *, HWND hwnd, HDC hdc,
int x1, int y1, int x2, int y2);
extern void XDrawPoint(void *, HWND hwnd, HDC hdc,
int x1, int y1);
extern void XFillRectangle(void *display, Window w, GC gc,
int, int, unsigned int, unsigned int);
#if 0
extern HWND XtInitialize(char* shell_name, char* app_class,
XrmOptionDescRec* options, Cardinal nul_options,
int *argc, char* argv[]);
extern void XtGetApplicationResources(HWND hwnd, XtPointer base,
XtResourceList resources,
Cardinal num_resources,
ArgList args, Cardinal num_args);
#endif
extern void ParseCmdLine(char *);
extern void XPutImage(void *, HWND hwnd, HDC hdc, XImage *img,
int src_x, int src_y,
int dest_x, int dest_y,
unsigned int width, unsigned int height);
extern void XClearWindow(void *, HWND );
extern void XFlush(void *);
extern void home(Boolean scrl);
extern void set_icon_and_title (char *dvi_name, char **icon_ret,
char **title_ret, int set_std);
extern FILE *XsraSelFile(Widget toplevel, char *prompt, char *ok,
char *cancel,
char *failed, char *init_path, char *mode,
int (*show_entry)(), char **name_return);
extern Boolean set_paper_type(void);
extern FILE* select_filename(int, int);
/* extern string_to_pixel(); */
extern void parse_options(int, char**);
extern int atopix(_Xconst char *);
extern int atopixunit(_Xconst char *);
extern char *pixtoa(int);
extern NORETURN void usage();
extern void FillDIB(struct glyph *g, struct bitmap *bm);
extern HBITMAP CreateDIB(HDC hdc, int x, int y, int bitCount, BITMAPINFO_256 *bmi, LPVOID *ppvBits);
extern void XClearArea(void *disp, HWND win, int x, int y, int width,
int height, int b);
void draw_rulers(unsigned int width, unsigned int height, HDC ourGC);
extern void bswap_asm(void *p, unsigned count);
extern void bswap_c(void *p, unsigned count);
extern void XPutPixel(XImage *img, int x, int y, COLORREF pixel);
extern XImage* XCreateImage(void* d, HDC, unsigned int depth,
int format, int offset, char* data,
unsigned int width, unsigned int height,
int bitmap_pad, int bytes_per_line);
extern COLORREF x_to_win32_color (const char * colorname);
extern void CleanUp(void);
extern void CleanExit(int code);
extern BOOL DibBlt (HDC hdc, INT x0, INT y0, INT dx, INT dy,
HANDLE hdib, INT x1, INT y1, LONG rop);
extern void XDestroyImage(XImage *img);
extern void pixel_to_unit();
extern Pixel string_to_pixel(const char **strp);
extern void init_colors();
extern const char * XGetDefault(void*, char*, char*);
extern void SaveOptions();
extern void FreeOptions();
extern void CloseCurrentFile();
extern void OpenCurrentFile(char *);
extern void SuspendCurrentFile();
extern void ResumeCurrentFile();
extern void NormalizeDviName();
extern RGBQUAD Color2Quad(COLORREF c);
extern void show_help();
extern void make_temporary_dir(char **);
extern void scan_colors(char *);
#ifdef HTEX
extern void htex_cleanup(int arg);
#endif
extern void remove_temporary_dir(void);
extern void emspecial(char *, int x, int y);
extern void CloseHandleAndClear(HANDLE *h);
#endif /* WINUTIL_H */
|