1 #ifndef	__HP2XX_H
2 #define	__HP2XX_H
3 /*
4    Copyright (c) 1991 - 1994 Heinz W. Werntges.  All rights reserved.
5    Distributed by Free Software Foundation, Inc.
6 
7 This file is part of HP2xx.
8 
9 HP2xx is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
11 to anyone for the consequences of using it or for whether it serves any
12 particular purpose or works at all, unless he says so in writing.  Refer
13 to the GNU General Public License, Version 2 or later, for full details.
14 
15 Everyone is granted permission to copy, modify and redistribute
16 HP2xx, but only under the conditions described in the GNU General Public
17 License.  A copy of this license is supposed to have been
18 given to you along with HP2xx so you can know your rights and
19 responsibilities.  It should be in a file named COPYING.  Among other
20 things, the copyright notice and this notice must be preserved on all
21 copies.
22 
23 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
24 */
25 
26 /** hp2xx.h: Header for Project "hp2xx"
27  **
28  ** 91/01/13  V 1.00  HWW  Originating
29  ** 91/01/19  V 1.01  HWW  Reorganized
30  ** 91/01/31  V 1.02  HWW  Tested on SUN; some flags added
31  ** 91/02/15  V 1.03  HWW  SUN release; stdlib.h supported
32  ** 91/02/18  V 1.04  HWW  plot_picbuf() is macro; new type: HPGL_Pt
33  ** 91/06/18  V 1.05  HWW  New PAR elements; ANSI_C supported
34  ** 91/06/15  V 1.06  HWW  VGA options added (PC only)
35  ** 91/06/20  V 1.07  HWW  Rotation added
36  ** 91/09/08  V 1.08  HWW  ATARI 32K format added
37  ** 91/10/09  V 1.08a HWW  ATARI 32K format: modified
38  ** 91/10/14  V 1.09  HWW  ATARI: PAC format with compression now,
39  **			     hwtools.h: excerpt incorporated
40  ** 91/10/20  V 1.09b HWW  PAC (compression) removed; atari --> pic (renamed)
41  ** 91/10/25  V 1.10  HWW  VAX_C: M_PI added
42  ** 91/11/20  V 1.11  HWW  SPn; support
43  ** 91/12/22  V 1.11b HWW  Some redefs in PS part
44  ** 92/01/11  V 1.12  HWW  Norbert Meyer's ATARI portability changes built in
45  ** 92/01/26  V 1.12a HWW  Some prototypes added
46  ** 92/01/31  V 1.12c HWW  M_PI def changed ; SUNVIEW etc. + comments added
47  ** 92/02/06  V 1.12d HWW  arcs(), circles() added
48  ** 92/02/19  V 1.13c HWW  LB etc. supported
49  ** 92/02/21  V 1.14a HWW  PG supported
50  ** 92/05/06  V 1.14b HWW  Log files & color supported (starting)
51  ** 92/05/19  V 2.00a HWW  Color supported
52  ** 92/05/28  V 2.00b HWW  Some prototypes changed/added
53  ** 92/06/09  V 2.00c HWW  debugged (GNU)
54  ** 92/10/15  V 2.01a HWW  LineType added
55  ** 92/11/08  V 2.01c HWW  page --> first_page, last_page; GNU --> DJ_GR
56  ** 92/12/13  V 2.02a HWW  truesize flag added; colors renamed
57  ** 93/04/13  V 2.10a HWW  User-serviceable parts & redundant prototypes
58  **			   removed
59  ** 93/05/23  V 2.10b HWW  READ_BIN, WRITE_BIN: Now ok for OS/2, too
60  ** 93/07/25  V 2.10c HWW  Some prototypes added
61  ** 93/09/02  V 2.10d HWW  Some #defines added;
62  **			   rect(), to_rgip(): prototypes added
63  ** 94/01/02  V 2.11a HWW  PlotCmd_from_tmpfile(): new type; center_mode
64  ** 94/02/10  V 3.00  HWW  New concept: Now three central parameter structs ...
65  ** 95/03/23  V 3.01  E.B  gnuplot ascii format added
66  **/
67 
68 #include "pendef.h"
69 
70 /**
71  ** Working with Pure C (the official descendant of Borland's
72  ** Turbo C for Atari computers)
73  **/
74 
75 #ifdef __PUREC__		/* __PUREC__ is pre-defined by the Pure-C  compiler */
76 #ifndef PURE_C
77 #define PURE_C
78 #endif
79 #endif
80 
81 /**
82  ** Automatic definition of obsolete symbol by Turbo-C and Pure-C:
83  **/
84 
85 #ifdef __TURBOC__
86 
87 #ifndef TURBO_C
88 #define TURBO_C
89 #endif
90 
91 #endif
92 
93 
94 
95 #ifdef GNU
96 #define   getch getkey
97 #endif
98 
99 
100 #ifndef M_PI
101 #define M_PI	3.141592654	/* Some machines don't know PI */
102 #endif
103 
104 #ifndef EOF
105 #define EOF (-1)
106 #endif
107 
108 #ifndef	MIN
109 #define MIN(x,y)  ((x)<(y) ? (x) : (y))
110 #endif
111 
112 #ifndef	MAX
113 #define MAX(x,y)  ((x)<(y) ? (y) : (x))
114 #endif
115 
116 
117 #define	TRUE	1
118 #define	FALSE	0
119 
120 /**
121  ** Exit codes
122  **/
123 
124 #ifdef VAX
125 /**
126  ** Only VAX exit code 0 provokes error treatment:
127  **/
128 #define ERROR 0
129 #define NOERROR 1
130 #define COPYNOTE 2
131 
132 #else				/* !VAX (regular case)  */
133 
134 #define ERROR (-1)
135 #define NOERROR 0
136 #define COPYNOTE 1
137 
138 #endif
139 
140 #define	ESC	'\033'
141 #define	_CR	'\015'
142 #define	FF	'\014'
143 #define	LF	'\012'
144 #define	BEL	'\007'
145 
146 #define MM_TO_PS_POINT 2.834646
147 
148 #define	MAX_LB_LEN	150	/* Max num of chars per label   */
149 
150 #define MAXPOLY 20480		/* Size of polygon vertex buffer */
151 
152 #ifndef VOID
153 #ifdef	__STDC__
154 #define	VOID	void
155 #else
156 #define	VOID	char
157 #endif
158 #endif				/* ifndef VOID */
159 
160 /* #endif */
161 
162 /**
163  ** Misc. typedefs
164  **/
165 
166 typedef unsigned char Byte;
167 
168 
169 #define VERS_NO "3.4.4"
170 #define VERS_DATE "03/06/22"
171 #define VERS_COPYRIGHT  "(c) 1991 - 1994 (V3.20) Heinz W. Werntges"
172 #if defined(AMIGA)
173 #define VERS_ADDITIONS     "\tAmiga additions (V 2.00) by Claus Langhans (92/12/16)\n"
174 #elif defined (ATARI)
175 #define VERS_ADDITIONS     "\tAtari additions (V 2.10) by N. Meyer / J. Eggers / A. Schwab  (93/01/xx)\n"
176 #else
177 #define VERS_ADDITIONS "                              (c) 1999 - 2003 Martin Kroeker\n"
178 #endif
179 
180 
181 /**
182  ** When adding your special mode, add a symbol here.
183  ** Please note the alphabetical order (and keep it).
184  **/
185 
186 typedef enum {
187 	XX_CAD, XX_CS, XX_DXF, XX_EM, XX_EMF, XX_EMP, XX_EPIC, XX_EPS,
188 	    XX_ESC2, XX_FIG, XX_GPT, XX_HPGL,
189 	XX_ILBM, XX_IMG, XX_JPG,
190 	XX_MF, XX_NC, XX_PBM, XX_PCL, XX_PCX, XX_PAC, XX_PDF, XX_PIC,
191 	    XX_PNG, XX_PRE,
192 	XX_RGIP, XX_SVG, XX_TIFF, XX_TERM	/* Dummy: terminator    */
193 } hp2xx_mode;
194 
195 
196 
197 /**
198  ** This struct handles a single row of our raster picture buffer
199  **/
200 
201 typedef struct Row {
202 	Byte *buf;		/* Ptr to actual data buffer which holds the bits       */
203 	int index;		/* Index of this row. Unique for each row. Ordered      */
204 	struct Row *prev, *next;	/* Rows are elements of a double-linked list    */
205 } RowBuf;
206 
207 
208 /**
209  ** Struct holding the whole raster picture
210  **/
211 
212 typedef struct {
213 	int nr, nc, nb;		/* Number of rows / columns / bytes per row     */
214 	int depth;		/* Depth: Number of bit planes (1 to 4)         */
215 	RowBuf *row;		/* Array pointer of all rows                    */
216 	char *sf_name;		/* Swapfile name                                */
217 	FILE *sd;		/* Swapfile pointer                             */
218 } PicBuf;
219 
220 
221 typedef struct {
222 	float x, y;
223 } HPGL_Pt;
224 
225 
226 typedef enum {
227 	NOP, MOVE_TO, DRAW_TO, PLOT_AT, SET_PEN, DEF_PW, DEF_PC, DEF_LA,
228 	    CMD_EOF
229 } PlotCmd;
230 
231 
232 typedef struct {
233 	hp2xx_mode mode;
234 	char *modestr;
235 } mode_list;
236 
237 /**
238  ** Input parameters: Used mainly during input file processing
239  **/
240 
241 typedef struct {		/* Corresponding option(s)        */
242 	int first_page, last_page;	/* -P first_page:last_page      */
243 	int center_mode;	/* -C                           */
244 	int truesize;		/* -t                           */
245 	int hwcolor;		/* -c                           */
246 	int hwsize;		/* -p                           */
247 	double width, height;	/* -w width -h height           */
248 	double aspectfactor;	/* -a aspectfactor              */
249 	double rotation;	/* -r rotation                  */
250 	double x0, x1, y0, y1;	/* -x x0 -X x1 -y y0 -Y y1      */
251 	double xoff, yoff;	/* -o xoff  -O yoff             */
252 	HPGL_Pt hwlimit;	/* -W p2.x -H p2.y		*/
253 	char *in_file;		/* Input file name ("-" = stdin) */
254 	FILE *hd;		/* (internally needed)          */
255 } IN_PAR;
256 
257 
258 
259 /**
260  ** Output parameters: Used mainly during output file generation
261  **/
262 
263 typedef struct {		/* Corresponding option(s)        */
264 	Byte vga_mode;		/* -V vga_mode                  */
265 	int vga_width;		/* (internally needed)          */
266 	int dpi_x, dpi_y;	/* -d dpi_x  -y dpi_y           */
267 	int init_p;		/* -i  (PCL only)               */
268 	int init_p3gui;		/* -I  (PCL only)               */
269 	int formfeed;		/* -F  (PCL only)               */
270 	int specials;		/* -s specials  (PCL only)      */
271 	int pagecount;		/* for naming multi-page output */
272 	char *outfile;		/* -f outfile ("-" = stdout)    */
273 	double xmin, ymin, xmax, ymax;	/* (internally needed)          */
274 	double xoff, yoff;	/* Internal copies from IN_PAR  */
275 	double width, height;	/* Internal copies from IN_PAR  */
276 	double HP_to_xdots;	/* (internally needed)          */
277 	double HP_to_ydots;	/* (internally needed)          */
278 	PicBuf *picbuf;		/* (internally needed)          */
279 	double zengage, zretract;	/* z min/max for 3d (currently only nc) */
280 } OUT_PAR;
281 
282 
283 
284 /**
285  ** General parameters: Used at various places
286  **/
287 
288 typedef struct {		/* Corresponding option(s)        */
289 	char *mode;		/* -m mode                      */
290 	char *logfile;		/* -l logfile                   */
291 	char *swapfile;		/* -s swapfile                  */
292 	int quiet;		/* -q                           */
293 	int nofill;		/* -n                           */
294 	int no_ps;		/* -N                           */
295 	int extraclip;		/* -e extraclip                 */
296 	PEN_W maxpensize;	/* (internally needed)          */
297 	int is_color;		/* (internally needed)          */
298 	int maxcolor;		/* (internally needed)          */
299 	FILE *td;		/* (internally needed)          */
300 	hp2xx_mode xx_mode;	/* (internally needed)          */
301 	int maxpens;		/* (internally needed)          */
302 	int mapzero;		/* remapping of pen 0		*/
303 } GEN_PAR;
304 
305 
306 typedef struct {
307 	int abs;
308 	int up;
309 	int sbmode;
310 	int fract;
311 	int pen;
312 	int rect;
313 } PE_flags;
314 
315 
316 #define	DEFAULT_PEN_NO		1
317 
318 #define	FLAGSTATE(flag)		(flag) ? "ON" : "off"
319 
320 
321 #if defined(TURBO_C) || defined (GNU) || defined (OS2) || defined (_NO_VCL)
322 #define	READ_BIN	"rb"
323 #define	WRITE_BIN	"w+b"
324 #else
325 #define	READ_BIN	"r"
326 #define	WRITE_BIN	"w+"
327 #endif
328 
329 
330 /**
331  ** Prototypes:
332  **/
333 
334 void Send_version(void);
335 void Send_Copyright(void);
336 void usage_msg(const GEN_PAR *, const IN_PAR *, const OUT_PAR *);
337 void print_supported_modes(void);
338 void preset_par(GEN_PAR *, IN_PAR *, OUT_PAR *);
339 void reset_par(IN_PAR *);
340 void autoset_outfile_name(const char *, const char *, char **);
341 
342 int HPGL_to_TMP(GEN_PAR *, IN_PAR *);
343 int TMP_to_VEC(const GEN_PAR *, const OUT_PAR *);
344 int TMP_to_BUF(const GEN_PAR *, OUT_PAR *);
345 int BUF_to_RAS(const GEN_PAR *, OUT_PAR *);
346 
347 void cleanup_g(GEN_PAR *);
348 void cleanup_i(IN_PAR *);
349 void cleanup_o(OUT_PAR *);
350 void cleanup(GEN_PAR *, IN_PAR *, OUT_PAR *);
351 
352 void Eprintf(const char *, ...);
353 void PError(const char *);
354 void SilentWait(void);
355 void NormalWait(void);
356 
357 void plot_user_char(FILE *, short);
358 void read_HPGL(GEN_PAR *, const IN_PAR *);
359 void adjust_input_transform(const GEN_PAR *, const IN_PAR *, OUT_PAR *);
360 PlotCmd PlotCmd_from_tmpfile(void);
361 void HPGL_Pt_from_tmpfile(HPGL_Pt *);
362 void Pen_action_to_tmpfile(PlotCmd, const HPGL_Pt *, int);
363 /*int read_float(float *, FILE *);*/
364 double ceil_with_tolerance(double, double);
365 void line(int relative, HPGL_Pt p);
366 int read_PE_flags(GEN_PAR *, int, FILE *, PE_flags *);
367 int read_PE_coord(int, FILE *, PE_flags *, float *);
368 int read_PE_pair(int, FILE *, PE_flags *, HPGL_Pt *);
369 void read_PE(GEN_PAR *, FILE *);
370 int decode_PE_char(int, PE_flags *);
371 int isPEterm(int, PE_flags *);
372 void to_ATARI(GEN_PAR *, FILE *);
373 int to_mftex(const GEN_PAR *, const OUT_PAR *, int);
374 int to_eps(const GEN_PAR *, const OUT_PAR *);
375 int to_rgip(const GEN_PAR *, const OUT_PAR *);
376 int to_fig(const GEN_PAR *, const OUT_PAR *);
377 
378 void size_PicBuf(const GEN_PAR *, const OUT_PAR *, int *, int *);
379 PicBuf *allocate_PicBuf(const GEN_PAR *, int, int);
380 void free_PicBuf(PicBuf *);
381 void tmpfile_to_PicBuf(const GEN_PAR *, const OUT_PAR *);
382 int index_from_PicBuf(const PicBuf *, const DevPt *);
383 int index_from_RowBuf(const RowBuf *, int, const PicBuf *);
384 RowBuf *get_RowBuf(const PicBuf *, int);
385 
386 int PicBuf_to_PCL(const GEN_PAR *, const OUT_PAR *);
387 int PicBuf_to_PCX(const GEN_PAR *, const OUT_PAR *);
388 int PicBuf_to_PNG(const GEN_PAR *, const OUT_PAR *);
389 #ifdef JPG
390 int PicBuf_to_JPG(const GEN_PAR *, const OUT_PAR *);
391 #endif
392 int PicBuf_to_TIF(const GEN_PAR *, const OUT_PAR *);
393 int PicBuf_to_IMG(const GEN_PAR *, const OUT_PAR *);
394 int PicBuf_to_PBM(const GEN_PAR *, const OUT_PAR *);
395 int PicBuf_to_ILBM(const GEN_PAR *, const OUT_PAR *);
396 #ifdef EPSON
397 int PicBuf_to_ESCP2(const GEN_PAR *, const OUT_PAR *);
398 #endif
399 #ifdef USEPDF
400 int to_pdf(const GEN_PAR *, const OUT_PAR *);
401 #endif
402 
403 #ifdef PIC_PAC
404 int PicBuf_to_PIC(const GEN_PAR *, const OUT_PAR *);
405 int PicBuf_to_PAC(const GEN_PAR *, const OUT_PAR *);
406 #endif				/* PIC_PAC */
407 
408 int PicBuf_to_AMIGA(const GEN_PAR *, const OUT_PAR *);
409 int PicBuf_to_ATARI(const GEN_PAR *, const OUT_PAR *);
410 int PicBuf_to_DJ_GR(const GEN_PAR *, const OUT_PAR *);
411 int PicBuf_to_Dummy(void);
412 int PicBuf_to_PM(const GEN_PAR *, const OUT_PAR *);
413 int PicBuf_to_OS2(const GEN_PAR *, const OUT_PAR *);
414 int PicBuf_to_Sunview(const GEN_PAR *, const OUT_PAR *);
415 int PicBuf_to_UIS(const GEN_PAR *, const OUT_PAR *);
416 int PicBuf_to_HGC(const GEN_PAR *, const OUT_PAR *);
417 int PicBuf_to_VGA(const GEN_PAR *, const OUT_PAR *);
418 int PicBuf_to_X11(const GEN_PAR *, OUT_PAR *);
419 
420 #ifdef EMF
421 int to_emf(const GEN_PAR * pg, const OUT_PAR * po);
422 int to_emw(const GEN_PAR * pg, const OUT_PAR * po);
423 int to_emp(const GEN_PAR * pg, const OUT_PAR * po);
424 #endif
425 
426 void fill(HPGL_Pt polygon[], int numpoints, HPGL_Pt P1, HPGL_Pt P2,
427 	  int scale_flag, int filltype, float spacing, float hatchangle);
428 
429 /*std_main*/
430 void action_oldstyle(GEN_PAR *, IN_PAR *, OUT_PAR *);
431 /*to_fig*/
432 void fig_poly_end(PEN_W, int, int, int, FILE *, int, long *, long *);
433 /*to_x11*/
434 void win_close(void);
435 
436 #endif				/*      __HP2XX_H       */
437