chiark / gitweb /
Import upstream version 5.3.
[mup] / mup / mupdisp / mupdisp.h
1
2 /* Copyright (c) 1995, 1996, 1998, 2000, 2001, 2006 by Arkkra Enterprises */
3 /* All rights reserved */
4
5 /* include file for Mup/Ghostscript display program */
6
7
8 #include <stdio.h>
9 #include <fcntl.h>
10 #include <sys/types.h>
11 #include <ctype.h>
12 #include <signal.h>
13 #include <string.h>
14 #include <stdlib.h>
15 #include <malloc.h>
16 #if !defined(linux) && !defined(__EMX__)
17 /* undef SIGCHLD to avoid conflict with Xos.h */
18 #undef SIGCHLD
19 #endif
20 #include <errno.h>
21
22 #ifdef __WATCOMC__
23 #ifndef __DOS__
24 #define __DOS__ 1
25 #endif
26 #endif
27
28 #if defined(__DOS__) || defined (__EMX__)
29 #include <io.h>
30 #endif
31
32 #ifdef __EMX__
33 #define unix    /* not really unix, but acts like it */
34 #endif
35 #include "dispttyp.h"
36
37 #ifdef XWINDOW
38 #ifdef linux
39 #undef SYSV
40 #undef _USHORT_H
41 #endif
42 /* X window includes */
43 #include <X11/Xlib.h>
44 #include <X11/Xutil.h>
45 #include <X11/Xos.h>
46 /* define XK_MISCELLANY so we can use XK_Return, etc */
47 #define XK_MISCELLANY 1
48 #include <X11/keysymdef.h>
49 #endif
50
51 /* macro for function templates if using ANSI C */
52 #ifdef __STDC__
53 #define P(parms)        parms
54 #else
55 #define P(parms)        ()
56 #endif
57
58 #define YES     1
59 #define NO      0
60
61 /* define screen and page dimensions */
62 /* we only handle the standard sizes that are less than 640 pixels wide.
63  * This includes letter, note, legal, a3, a4, a5, a6, flsa, flse,
64  * and halfletter  */
65 #define MAX_BYTES_PER_LINE      77      /* 612/8 rounded up */
66 #define MAX_LINES_PER_PAGE      1008    /* to handle legal size */
67
68 #define BITS_PER_LINE   Bits_per_line    /* horizontal pixels */
69 #define BYTES_PER_LINE  Bytes_per_line   /* Bits_per_line / 8 rounded up */
70 #define LINES_PER_PAGE  Lines_per_page   /* vertical pixels */
71 #define BYTES_PER_PAGE  (BYTES_PER_LINE * LINES_PER_PAGE)
72
73
74 /* default mode is not full page */
75 #define DFLT_MODE       NO
76
77 typedef void (*FUNC)();
78
79 /* list of supported $TERM types and which functions and parameters to use
80  * to implement them. To support a new terminal type, write appropriate
81  * functions, and add to the Config table in init.c.
82  */
83 struct CONFIG {
84         char    *termname;      /* $TERM value */
85         FUNC    setup;          /* call this to initialize */
86         FUNC    cleanup;        /* call this to clean up and exit */
87         FUNC    draw;           /* call this to draw a screen of the page */
88         FUNC    user_interf;    /* call this to read user input */
89         FUNC    error;          /* call this on bad user input */
90         FUNC    bitmap;         /* call this to display a bitmap */
91         int     vlines;         /* number of lines vertically on screen */
92         float   adjust;         /* aspect ratio adjustment */
93 };
94
95
96 /* information about a particular bitmap-ed page. */
97 struct Pginfo {
98         int     pagenum;        /* actual designated page number. If the mup
99                                  * -p option is used, this may start somewhere
100                                  * other than 1, and if -o is used, there
101                                  * may be gaps in the list */
102         int     seqnum;         /* page number from 0 to n-1. Multiplying this
103                                  * by the number of bytes per page in a bitmap
104                                  * gives the file offset for the page. */
105         long    begin;          /* where page begins in input */
106         long    end;            /* where page ends in input */
107         struct Pginfo   *next;  /* linked list link */
108         struct Pginfo   *prev;
109 };
110
111 /* globals */
112 extern struct CONFIG *Conf_info_p;
113 extern struct Pginfo *Pagehead; /* all page bitmaps */
114 extern struct Pginfo *Pagetail; /* where to add to list */
115 extern struct Pginfo *Currpage_p;       /* current page */
116 extern int Fullpgmode;  /* full page or partial page */
117 extern long Beginprolog;/* where in PostScript file the prolog begins */
118 extern long Endprolog;  /* where in PostScript file the prolog ends */
119 extern long Begin_offset;/* offset in file where current page begins */
120 extern int Pagenum;     /* current page number */
121 extern int Psfile;      /* PostScript temp file, file descriptor */
122 extern FILE *PS_file;   /* PostScript temp file */
123 extern int Fullbitmaps; /* temp file of full page bitmaps */
124 extern int Partbitmaps; /* temp file for bitmaps for scrollable pages */
125 extern int Nulldev;     /* /dev/null */
126 extern char Fullfile[]; /* name of gs output tmp file */
127 extern char Partfile[]; /* name of gs output tmp file */
128 extern char Mupfile[];  /* mup output temp file */
129 extern char **Argv;     /* global version of argv */
130 extern int Argc;        /* global version of argc */
131 extern char *Exit_errmsg;/* error message to print upon exit */
132 extern char *Gs_errfile;/* Ghostscript error file */
133 extern int Bits_per_line; /* pixels per line */
134 extern int Bytes_per_line;/* pixels per line divided by 8 and rounded up */
135 extern int Lines_per_page;/* vertical pixels */
136
137 /* misc functions */
138 extern int getpginfo P((int pgnum));
139 extern void user_interf P((void));
140 extern int scroll P((int line, int distance));
141 extern void generalcleanup P((int status));
142 extern int create_tmpfile P((char *tmpfname));
143 extern int gen1file P((int fullpgmode));
144 extern void get_paper_size P((int x, int y));
145 extern void run_mup P((char **argv));
146 extern void init P((void));
147 extern void do_cmd P((int c));
148
149 extern char *getenv();
150 extern long ftell();
151 #ifdef __STDC__
152 #include <unistd.h>
153 #else
154 extern long lseek();
155 #endif