1 /*--------------------------------------------------------------------
2  *
3  *	Copyright (c) 2009-2021 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
4  *
5  *	This program is free software; you can redistribute it and/or modify
6  *	it under the terms of the GNU Lesser General Public License as published by
7  *	the Free Software Foundation; version 3 or any later version.
8  *
9  *	This program is distributed in the hope that it will be useful,
10  *	but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *	GNU Lesser General Public License for more details.
13  *
14  *--------------------------------------------------------------------*/
15 /*
16  * This include file must be included by all programs using postscriptlight
17  *
18  * Authors:	Paul Wessel, Dept. of Geology and Geophysics, SOEST, U Hawaii
19  *			   pwessel@hawaii.edu
20  *		Remko Scharroo, Altimetrics
21  *			   remko@altimetrics.com
22  * Version:	6.0 [64-bit enabled API edition, decoupled from GMT]
23  * Date:	13-OCT-2017
24  */
25 
26 /*!
27  * \file postscriptlight.h
28  * \brief Include file that must be included by all programs using postscriptlight
29  */
30 
31 #ifndef _POSTSCRIPTLIGHT_H
32 #define _POSTSCRIPTLIGHT_H
33 
34 #define PSL_WITH_GMT4_SUPPORT	/* For as long as we want to be backwards compatible with GMT4 vectors */
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /* CMake definitions: This must be first! */
41 #include "psl_config.h"
42 
43 /* Declaration modifiers for DLL support (MSC et al) */
44 #include "declspec.h"
45 
46 #include <stdio.h>
47 
48 #define PSL_MaxOpStack_Size	300000	/* As of GhostSCript 9.50; see declaration in gs_init.ps */
49 
50 /* Number of PostScript points in one inch */
51 
52 #define PSL_POINTS_PER_INCH	72.0
53 #define PSL_DOTS_PER_INCH	1200.0	/* Effective dots per inch resolution */
54 #define PSL_DOTS_PER_INCH_PATTERN	300.0	/* Effective dots per inch resolution for a bitmap pattern -Gp */
55 #define PSL_ALL_CLIP		INT_MAX	/* Terminates all clipping */
56 
57 /* PSL codes for geometric symbols as expected by PSL_plotsymbol */
58 
59 #define PSL_STAR		((int)'a')
60 #define PSL_CIRCLE		((int)'c')
61 #define PSL_DIAMOND		((int)'d')
62 #define PSL_ELLIPSE		((int)'e')
63 #define PSL_OCTAGON		((int)'g')
64 #define PSL_HEXAGON		((int)'h')
65 #define PSL_INVTRIANGLE		((int)'i')
66 #define PSL_ROTRECT		((int)'j')
67 #define PSL_MARC		((int)'m')
68 #define PSL_PENTAGON		((int)'n')
69 #define PSL_DOT			((int)'p')
70 #define PSL_RECT		((int)'r')
71 #define PSL_RNDRECT		((int)'R')
72 #define PSL_SQUARE		((int)'s')
73 #define PSL_TRIANGLE		((int)'t')
74 #define PSL_VECTOR		((int)'v')
75 #define PSL_WEDGE		((int)'w')
76 #define PSL_CROSS		((int)'x')
77 #define PSL_YDASH		((int)'y')
78 #define PSL_PLUS		((int)'+')
79 #define PSL_XDASH		((int)'-')
80 
81 /* PSL codes for vector attributes */
82 
83 enum PSL_enum_vecattr {
84 	PSL_VEC_ARROW		= 0,		/* Default head symbol is arrow */
85 	PSL_VEC_TERMINAL	= 1,		/* Cross-bar normal to vector */
86 	PSL_VEC_CIRCLE		= 2,		/* Circle as vector head */
87 	PSL_VEC_SQUARE		= 3,		/* Square as vector head */
88 	PSL_VEC_TAIL		= 4,		/* Vector tail */
89 	PSL_VEC_ARROW_PLAIN	= 5,		/* Stylized vector head (just triangle lines; cannot be filled) */
90 	PSL_VEC_TAIL_PLAIN	= 6,		/* Stylized vector tail (just inward triangle lines; cannot be filled) */
91 	PSL_VEC_BEGIN		= 1,		/* Place vector head at beginning of vector. Add PSL_VEC_BEGIN_L for left only, PSL_VEC_BEGIN_R for right only */
92 	PSL_VEC_END			= 2,		/* Place vector head at end of vector.  Add PSL_VEC_END_L for left only, and PSL_VEC_END_R for right only */
93 	PSL_VEC_HEADS		= 3,		/* Mask for either head end */
94 	PSL_VEC_BEGIN_L		= 4,		/* Left-half head at beginning */
95 	PSL_VEC_BEGIN_R		= 8,		/* Right-half head at beginning */
96 	PSL_VEC_END_L		= 16,		/* Left-half head at end */
97 	PSL_VEC_END_R		= 32,		/* Right-half head at end */
98 	PSL_VEC_JUST_B		= 0,		/* Align vector beginning at (x,y) */
99 	PSL_VEC_JUST_C		= 64,		/* Align vector center at (x,y) */
100 	PSL_VEC_JUST_E		= 128,		/* Align vector end at (x,y) */
101 	PSL_VEC_JUST_S		= 256,		/* Align vector center at (x,y) */
102 	PSL_VEC_ANGLES		= 512,		/* Got start/stop angles instead of az, length */
103 	PSL_VEC_POLE		= 1024,		/* Got pole of small/great circle */
104 	PSL_VEC_OUTLINE		= 2048,		/* Draw vector head outline using default pen */
105 	PSL_VEC_OUTLINE2	= 4096,		/* Draw vector head outline using supplied v_pen */
106 	PSL_VEC_FILL		= 8192,		/* Fill vector head using default fill */
107 	PSL_VEC_FILL2		= 16384,	/* Fill vector head using supplied v_fill) */
108 	PSL_VEC_MARC90		= 32768,	/* Matharc only: if angles subtend 90, draw straight angle symbol */
109 	PSL_VEC_OFF_BEGIN	= 65536,	/* Starting point of vector should be moved a distance along the line */
110 	PSL_VEC_OFF_END		= 131072,	/* End point of vector should be moved a distance along the line */
111 	PSL_VEC_MID_FWD		= 262144,	/* End point of vector should be moved a distance along the line */
112 	PSL_VEC_MID_BWD		= 524288,	/* End point of vector should be moved a distance along the line */
113 	PSL_VEC_COMPONENTS	= 1048576,	/* Not yet needed in postscriptlight: Got vector dx, dy Cartesian components */
114 	PSL_VEC_SCALE		= 2097152};	/* Not yet needed in postscriptlight: If not set we determine the required inch-to-degree scale */
115 
116 enum PSL_enum_vecdim {	/* Indices into the dim[] array passed to psl_vector */
117 	PSL_VEC_XTIP 			= 0,	/* x-coordinate of tip of vector in inches */
118 	PSL_VEC_YTIP 			= 1,	/* y-coordinate of tip of vector in inches */
119 	PSL_VEC_TAIL_WIDTH		= 2,	/* Width of tail stem (pen width) in inches */
120 	PSL_VEC_HEAD_LENGTH		= 3,	/* Length of the vector head in inches */
121 	PSL_VEC_HEAD_WIDTH		= 4,	/* Width of the vector head in inches */
122 	PSL_VEC_HEAD_SHAPE		= 5,	/* Shape (0-2) of the vector head */
123 	PSL_VEC_STATUS			= 6,	/* Sum of all vector bit flags */
124 	PSL_VEC_HEAD_TYPE_BEGIN	= 7,	/* Type of vector head at beginning of vector */
125 	PSL_VEC_HEAD_TYPE_END	= 8,	/* Type of vector head at end of vector */
126 	PSL_VEC_TRIM_BEGIN		= 9,	/* Amount of line trim at beginning of vector in inches*/
127 	PSL_VEC_TRIM_END		= 10,	/* Amount of line trim at end of vector in inches*/
128 	PSL_VEC_HEAD_PENWIDTH	= 11};	/* Pen width of vector head outline */
129 
130 enum PSL_enum_wedgedim {	/* Indices into the dim[] array passed to psl_wedge */
131 	 PSL_WEDGE_RADIUS_O    = 0,	/* Outer radius of wedge in inches */
132 	 PSL_WEDGE_ANGLE_BEGIN = 1,	/* Begin angle in degrees */
133 	 PSL_WEDGE_ANGLE_END   = 2,	/* End angle in degrees */
134 	 PSL_WEDGE_STATUS      = 3,	/* Status bit flags */
135 	 PSL_WEDGE_RADIUS_I    = 4, 	/* Inner radius of wedge in inches */
136 	 PSL_WEDGE_DR          = 5, 	/* Radial increment in inches */
137 	 PSL_WEDGE_DA          = 6, 	/* Azimuthal increment in degrees */
138 	 PSL_WEDGE_ACTION      = 7 };	/* Sets filling (1) and/or outline (2) */
139 
140 enum PSL_enum_matharcdim {	/* Indices into the dim[] array passed to psl_matharc */
141 	 PSL_MATHARC_RADIUS			= 0,	/* Radius of arc in inches */
142 	 PSL_MATHARC_ANGLE_BEGIN	= 1,	/* Begin angle in degrees */
143 	 PSL_MATHARC_ANGLE_END		= 2,	/* End angle in degrees */
144 	 PSL_MATHARC_HEAD_LENGTH	= 3,	/* Length of the vector head in inches */
145 	 PSL_MATHARC_HEAD_WIDTH		= 4,	/* Width of the vector head in inches */
146 	 PSL_MATHARC_ARC_PENWIDTH	= 5,	/* Pen width of arc in inches  */
147 	 PSL_MATHARC_HEAD_SHAPE		= 6,	/* Shape (0-2) of the vector head */
148 	 PSL_MATHARC_STATUS			= 7,	/* Sum of all vector bit flags */
149 	 PSL_MATHARC_HEAD_TYPE_BEGIN= 8,	/* Type of vector head at beginning of vector */
150 	 PSL_MATHARC_HEAD_TYPE_END	= 9,	/* Type of vector head at end of vector */
151 	 PSL_MATHARC_TRIM_BEGIN		= 10,	/* Amount of line trim at beginning of vector in degrees */
152 	 PSL_MATHARC_TRIM_END		= 11,	/* Amount of line trim at end of vector in degrees */
153 	 PSL_MATHARC_HEAD_PENWIDTH	= 12};	/* Pen width of vector head outline in inches  */
154 
155 /* PSL macros for dealing with vector attributes */
156 
157 #define PSL_vec_justify(status) ((status>>6)&3)			/* Return justification as 0-3 */
158 #define PSL_vec_head(status) ((status)&3)			/* Return head selection as 0-3 */
159 #define PSL_vec_side(status,head) (((status>>(2+2*head))&3) ? 2*((status>>(2+2*head))&3)-3 : 0)	/* Return side selection for this head as 0,-1,+1 */
160 #define PSL_vec_outline(status) ((status&PSL_VEC_OUTLINE) || (status&PSL_VEC_OUTLINE2))	/* Return true if outline is currently selected */
161 #define PSL_vec_fill(status) ((status&PSL_VEC_FILL) || (status&PSL_VEC_FILL2))		/* Return true if fill is currently selected */
162 
163 /* PSL codes for arguments of PSL_beginplot and other routines */
164 
165 enum PSL_enum_const {PSL_CM	= 0,
166 	PSL_INCH		= 1,
167 	PSL_METER		= 2,
168 	PSL_PT			= 3,
169 	PSL_BEGIN		= 0,
170 	PSL_END			= 1,
171 	PSL_FINALIZE		= 1,
172 	PSL_OVERLAY		= 1,
173 	PSL_MEMORY		= 2,
174 	PSL_CHANGESET		= 4,
175 	PSL_MEM_ALLOC		= 2097152, /* 2 Mb of memory */
176 	PSL_INIT		= 0,
177 	PSL_LANDSCAPE		= 0,
178 	PSL_PORTRAIT		= 1,
179 	PSL_ASCII85		= 0,
180 	PSL_HEX			= 1,
181 	PSL_NONE		= 0,
182 	PSL_RLE			= 1,
183 	PSL_LZW			= 2,
184 	PSL_DEFLATE		= 3,
185 	PSL_EO_CLIP		= 4,
186 	PSL_NO			= 0,
187 	PSL_YES			= 1,
188 	PSL_FWD			= 0,
189 	PSL_INV			= 1,
190 	PSL_OUTLINE		= 1,
191 	PSL_LINEAR		= 0,
192 	PSL_BEZIER		= 1,
193 	PSL_MAX_EPS_FONTS	= 6,
194 	PSL_MAX_DIMS		= 13,		/* Max number of dim arguments to PSL_plot_symbol */
195 	PSL_N_PATTERNS		= 91,		/* Current number of predefined patterns + 1, # 91 is user-supplied */
196 	PSL_FONTNAME_LEN	= 64,		/* Max length of font names */
197 	PSL_BUFSIZ		= 4096U};
198 
199 /* PSL codes for pen movements (used by PSL_plotpoint, PSL_plotline, PSL_plotarc) */
200 
201 enum PSL_enum_move {PSL_DRAW	= 0,
202 	PSL_MOVE		= 1,
203 	PSL_STROKE		= 2,
204 	PSL_REL			= 4,
205 	PSL_CLOSE		= 8,
206 	PSL_CLIP		= 16};
207 
208 /* PSL codes for text and paragraph justification */
209 
210 enum PSL_enum_just {PSL_BL	= 1,
211 	PSL_BC			= 2,
212 	PSL_BR			= 3,
213 	PSL_ML			= 5,
214 	PSL_MC			= 6,
215 	PSL_MR			= 7,
216 	PSL_TL			= 9,
217 	PSL_TC			= 10,
218 	PSL_TR			= 11,
219 	PSL_NO_DEF		= 12,
220 	PSL_JUST		= 4};
221 
222 /* PSL code for rectangle shapes */
223 
224 enum PSL_enum_rect {PSL_RECT_STRAIGHT	= 0,
225 	PSL_RECT_ROUNDED,
226 	PSL_RECT_CONVEX,
227 	PSL_RECT_CONCAVE};
228 
229 /* PSL codes for line settings */
230 
231 enum PSL_enum_line {PSL_BUTT_CAP	= 0,
232 	PSL_ROUND_CAP			= 1,
233 	PSL_SQUARE_CAP			= 2,
234 	PSL_MITER_JOIN			= 0,
235 	PSL_ROUND_JOIN			= 1,
236 	PSL_BEVEL_JOIN			= 2,
237 	PSL_MITER_DEFAULT		= 35};
238 
239 /* PSL codes for text clipping (PSL_plottextline) */
240 
241 enum PSL_enum_txt {PSL_TXT_INIT	= 1,
242 	PSL_TXT_SHOW		= 2,
243 	PSL_TXT_CLIP_ON		= 4,
244 	PSL_TXT_DRAW		= 8,
245 	PSL_TXT_CLIP_OFF	= 16,
246 	PSL_TXT_ROUND		= 32,
247 	PSL_TXT_CURVED		= 64,
248 	PSL_TXT_FILLBOX		= 128,
249 	PSL_TXT_DRAWBOX		= 256,
250 	PSL_TXT_FILLPEN		= 512,
251 	PSL_TXT_PENFILL		= 1024};
252 
253 /* PSL codes for text hyphen substitution (PSL_settextmode) */
254 
255 enum PSL_enum_txtmode {PSL_TXTMODE_HYPHEN	= 0,
256 	PSL_TXTMODE_MINUS			= 1};
257 
258 /* Verbosity levels */
259 
260 enum PSL_enum_verbose {
261 	PSL_MSG_QUIET = 0,		/* No messages whatsoever */
262 	PSL_MSG_ERROR,			/* Errors only */
263 	PSL_MSG_WARNING,		/* Warnings */
264 	PSL_MSG_TICTOC,			/* Tic-toc elapsed time message */
265 	PSL_MSG_INFORMATION,	/* Informational messages */
266 	PSL_MSG_COMPAT,			/* Compatibility warnings */
267 	PSL_MSG_DEBUG,			/* Debug messages */
268 	/* For API backwards compatibility only */
269 	PSL_MSG_NORMAL = 1,			/* Now PSL_MSG_ERROR */
270 	PSL_MSG_VERBOSE = 4,		/* Now PSL_MSG_WARNING */
271 	PSL_MSG_LONG_VERBOSE = 5	/* Now PSL_MSG_INFORMATION */
272 	};
273 
274 /* Color spaces */
275 
276 enum PSL_enum_color {PSL_RGB = 0,
277 	PSL_CMYK,
278 	PSL_HSV,
279 	PSL_GRAY};
280 
281 /* Color types */
282 
283 enum PSL_enum_fill {PSL_IS_STROKE = 0,
284 	PSL_IS_FILL,
285 	PSL_IS_FONT};
286 
287 /* PSL error codes */
288 
289 enum PSL_enum_err {PSL_BAD_VALUE = -99,	/* Bad value */
290 	PSL_BAD_JUST,		/* Bad text or paragraph justification */
291 	PSL_READ_FAILURE,	/* Read failure from a file */
292 	PSL_NO_POLYGON,		/* Less than 3 points */
293 	PSL_BAD_TEXT,		/* Text is too long */
294 	PSL_BAD_WIDTH,		/* Negative line width */
295 	PSL_NO_PATH,		/* Less than 2 points given as path */
296 	PSL_BAD_SYMBOL,		/* Unknown symbol type */
297 	PSL_BAD_SIZE,		/* Size is negative */
298 	PSL_BAD_RANGE,		/* Range defined by min/max exceeds limit */
299 	PSL_BAD_FLAG,		/* A flag is outside required range */
300 	PSL_NO_SESSION,		/* No active session */
301 	PSL_NO_ERROR = 0};	/* No errors, all is OK */
302 
303 /*--------------------------------------------------------------------
304  *			PSL PARAMETERS DEFINITIONS
305  *--------------------------------------------------------------------*/
306 
307 struct PSL_FONT {	/* Definition */
308 	char name[PSL_FONTNAME_LEN];/* Name of this font */
309 	double height;		/* Height of A for unit fontsize */
310 	int encoded;		/* true if we never should re-encode this font (e.g. symbols) */
311 				/* This is also changed to true after we do re-encode a font */
312 	int encoded_orig;	/* The original setting that we can reset the array to */
313 };
314 
315 struct PSL_CTRL {
316 	struct INIT {	/* Parameters set by user via PSL_beginplot() */
317 		FILE *err;			/* Error stream (NULL means stderr)		*/
318 		char *encoding;			/* The encoding name. e.g. ISO-8859-1		*/
319 		char *session;			/* The session name (NULL)			*/
320 		int runmode;			/* Nonzero if we are being called from a multi-module environment (0 for commandline)	*/
321 		int unit;			/* 0 = cm, 1 = inch, 2 = meter			*/
322 		int copies;			/* Number of copies for this plot		*/
323 		double page_rgb[4];		/* RGB color for background paper [white]	*/
324 		double page_size[2];		/* Width and height of paper used in points	*/
325 		double magnify[2];		/* Global scale values [1/1]			*/
326 	} init;
327 	struct CURRENT {	/* Variables and settings that changes via PSL_* calls */
328 		char string[PSL_BUFSIZ];	/* Last text string plotted			*/
329 		char style[512];		/* Current setdash pattern			*/
330 		char bw_format[8];		/* Format used for grayshade value		*/
331 		char rgb_format[64];		/* Same, for RGB color triplets			*/
332 		char hsv_format[64];		/* Same, for HSV color triplets	(HSB in PS)	*/
333 		char cmyk_format[64];		/* Same, for CMYK color quadruples		*/
334 		char transparency_mode[16];	/* PDF transparency mode			*/
335 		double linewidth;		/* Current pen thickness			*/
336 		double rgb[3][4];		/* Current stroke, fill, and fs fill rgb	*/
337 		double offset;			/* Current setdash offset			*/
338 		double transparency;		/* Current transparency	[deprecated]			*/
339 		double transparencies[2];		/* Current transparencies				*/
340 		double fontsize;		/* Current font size				*/
341 		double subsupsize;		/* Fractional size of super/sub-scripts		*/
342 		double scapssize;		/* Fractional size of small caps		*/
343 		double sub_down;		/* Fractional fontsize shift down for subscript */
344 		double sup_up[2];		/* Fractional fontsize shift up for superscript */
345 						/* [0] is for lower-case, [1] is for uppercase  */
346 		int nclip;			/* Clip depth 					*/
347 		int font_no;			/* Current font number				*/
348 		int outline;			/* Current outline				*/
349 		int complete;			/* true for executing a custom PSL_plot_completion procedure once */
350 		int use_minus;			/* true for replacing hyphen code with minus codes */
351 	} current;
352 	struct INTERNAL {	/* Variables used internally only */
353 		char *SHAREDIR;			/* Pointer to path of directory with postscriptlight subdirectory */
354 		char *USERDIR;			/* Pointer to path of directory with user definitions */
355 		char *buffer;			/* Pointer to buffer where PS will be "written" when memory == 1 */
356 		char *user_image[PSL_N_PATTERNS];	/* Name of user patterns		*/
357 		char origin[2];			/* 'r', 'a', 'f', 'c' depending on reference for new origin x and y coordinate */
358 		double offset[2];		/* Origin offset [1/1]				*/
359 		double prev_offset[2];		/* Previous Origin offset [1/1]				*/
360 		double p_width;			/* Paper width in points, set in PSL_beginplot();	*/
361 		double p_height;		/* Paper height in points, set in PSL_beginplot();	*/
362 		double dpu;			/* PS dots per unit.  Must be set through PSL_beginplot();		*/
363 		double dpp;			/* PS dots per point.  Must be set through PSL_beginplot();		*/
364 		double x2ix;			/* Scales user x to PS dots			*/
365 		double y2iy;			/* Scales user y to PS dots			*/
366 		double p2u;			/* Scales dimensions in points (e.g., fonts, linewidths) to user units (e.g. inch)		*/
367 		double axis_limit[4];		/* The current xmin, xmax, ymin, ymax settings for axes */
368 		double axis_pos[2];		/* Lower left placement for axes		*/
369 		double axis_dim[2];		/* Lengths of axes 				*/
370 		int verbose;			/* Verbosity level (0-4): see PSL_MSG_*	*/
371 		int comments;			/* true for writing comments to output, false strips all comments */
372 		int overlay;			/* true if overlay (-O)				*/
373 		int landscape;			/* 1 = Landscape, 0 = Portrait		*/
374 		int memory;			/* 1 = write to memory, 0 = write to output	*/
375 		int text_init;			/* true after PSL_text.ps has been loaded	*/
376 		int image_format;		/* 0 writes images in ASCII, 2 uses binary	*/
377 		int N_FONTS;			/* Total no of fonts;  To add more, modify the file PSL_custom_fonts.txt */
378 		int compress;			/* Compresses images with (1) RLE or (2) LZW (3) DEFLATE or (0) None */
379 		int deflate_level; 		/* Compression level for DEFLATE (1-9, default 0) */
380 		int call_level; 		/* Level in a series of module calls from GMT */
381 		int color_mode;			/* 0 = rgb, 1 = cmyk, 2 = hsv (only 1-2 for images)	*/
382 		int line_cap;			/* 0, 1, or 2 for butt, round, or square [butt]	*/
383 		int line_join;			/* 0, 1, or 2 for miter, arc, or bevel [miter]	*/
384 		int miter_limit;		/* Acute angle threshold 0-180; 0 means PS default [0] */
385 		int ix, iy;			/* Absolute coordinates of last point		*/
386 		int n_userimages;		/* Number of specified custom patterns		*/
387 		int x0, y0;			/* x,y PS offsets				*/
388 		int pmode;			/* Mode of buffer plot (1 = has header, 2 = has trailer, 3 = both) */
389 		size_t n_alloc;			/* Allocation length of buffer			*/
390 		size_t n;			/* Length of buffer				*/
391 		FILE *fp;			/* PS output file pointer. NULL = stdout	*/
392 		struct PSL_FONT *font;		/* Pointer to array of font structures 		*/
393 		struct PSL_PATTERN {
394 			int nx, ny;	/* Dimension of pattern image */
395 			int status, depth, dpi;
396 			double f_rgb[4], b_rgb[4];
397 		} pattern[PSL_N_PATTERNS*2];
398 	} internal;
399 };
400 
401 struct imageinfo {
402 	int magic;		/* magic number */
403 	int width;		/* width (pixels) of image */
404 	int height;		/* height (pixels) of image */
405 	int depth;		/* depth (1, 8, or 24 bits) of pixel; 0 for EPS */
406 	int length;		/* length (bytes) of image */
407 	int type;		/* type of file; see RT_* below */
408 	int maptype;	/* type of colormap; see RMT_* below */
409 	int maplength;	/* length (bytes) of following map */
410 	int xorigin;	/* x-coordinate of origin (EPS only) */
411 	int yorigin;	/* y-coordinate of origin (EPS only) */
412 	double llx, lly, trx, try; /* Four corners of the (HiRes)BoundingBox (EPS only) */
413 	/* color map follows for maplength bytes, followed by image */
414 };
415 
416 #define	RAS_MAGIC	0x59a66a95	/* Magic number for Sun rasterfile */
417 #define EPS_MAGIC	0x25215053	/* Magic number for EPS file */
418 #define RT_OLD		0		/* Old-style, unencoded Sun rasterfile */
419 #define RT_STANDARD	1		/* Standard, unencoded Sun rasterfile */
420 #define RT_BYTE_ENCODED	2		/* Run-length-encoded Sun rasterfile */
421 #define RT_FORMAT_RGB	3		/* [X]RGB instead of [X]BGR Sun rasterfile */
422 #define RT_EPS		4		/* Encapsulated PostScript format */
423 #define RMT_NONE	0		/* maplength is expected to be 0 */
424 #define RMT_EQUAL_RGB	1		/* red[maplength/3], green[], blue[] follow */
425 
426 /* Public functions */
427 
428 EXTERN_MSC struct PSL_CTRL *New_PSL_Ctrl (char *session);
429 EXTERN_MSC int PSL_beginaxes (struct PSL_CTRL *PSL, double llx, double lly, double width, double height, double x0, double y0, double x1, double y1);
430 EXTERN_MSC int PSL_beginclipping (struct PSL_CTRL *PSL, double *x, double *y, int n, double rgb[], int flag);
431 EXTERN_MSC int PSL_beginlayer (struct PSL_CTRL *PSL, int layer);
432 EXTERN_MSC int PSL_beginplot (struct PSL_CTRL *PSL, FILE *fp, int orientation, int overlay, int color_mode, char origin[], double offset[], double page_size[], char *title, int font_no[]);
433 EXTERN_MSC int PSL_beginsession (struct PSL_CTRL *PSL, unsigned int search, char *sharedir, char *userdir);
434 EXTERN_MSC int PSL_copy (struct PSL_CTRL *PSL, const char *txt);
435 EXTERN_MSC int PSL_endaxes (struct PSL_CTRL *PSL);
436 EXTERN_MSC int PSL_endclipping (struct PSL_CTRL *PSL, int mode);
437 EXTERN_MSC int PSL_endlayer (struct PSL_CTRL *PSL);
438 EXTERN_MSC int PSL_endplot (struct PSL_CTRL *PSL, int lastpage);
439 EXTERN_MSC int PSL_endsession (struct PSL_CTRL *PSL);
440 EXTERN_MSC char * PSL_getplot (struct PSL_CTRL *PSL);
441 EXTERN_MSC char * PSL_makecolor (struct PSL_CTRL *PSL, double rgb[]);
442 EXTERN_MSC char * PSL_makefont (struct PSL_CTRL *PSL, double size, double rgb[]);
443 EXTERN_MSC char * PSL_makefontsize (struct PSL_CTRL *PSL, double size);
444 EXTERN_MSC char * PSL_makepen (struct PSL_CTRL *PSL, double linewidth, double rgb[], char *pattern, double offset);
445 EXTERN_MSC int PSL_plotarc (struct PSL_CTRL *PSL, double x, double y, double radius, double az1, double az2, int type);
446 EXTERN_MSC int PSL_plotaxis (struct PSL_CTRL *PSL, double annotation_int, char *label, double annotfontsize, int side);
447 EXTERN_MSC int PSL_plotbitimage (struct PSL_CTRL *PSL, double x, double y, double xsize, double ysize, int justify, unsigned char *buffer, int nx, int ny, double f_rgb[], double b_rgb[]);
448 EXTERN_MSC int PSL_plotcolorimage (struct PSL_CTRL *PSL, double x, double y, double xsize, double ysize, int justify, unsigned char *buffer, int nx, int ny, int nbits);
449 EXTERN_MSC int PSL_plotepsimage (struct PSL_CTRL *PSL, double x, double y, double xsize, double ysize, int justify, unsigned char *buffer, struct imageinfo *h);
450 EXTERN_MSC int PSL_plotlatexeps (struct PSL_CTRL *PSL, double x, double y, double xsize, double ysize, int justify, unsigned char *buffer, double *rgb, struct imageinfo *h);
451 EXTERN_MSC int PSL_plotline (struct PSL_CTRL *PSL, double *x, double *y, int n, int type);
452 EXTERN_MSC int PSL_plotcurve (struct PSL_CTRL *PSL, double *x, double *y, int n, int type);
453 EXTERN_MSC int PSL_plotparagraph (struct PSL_CTRL *PSL, double x, double y, double fontsize, char *paragraph, double angle, int justify);
454 EXTERN_MSC int PSL_plotparagraphbox (struct PSL_CTRL *PSL, double x, double y, double fontsize, char *paragraph, double angle, int justify, double offset[], int mode);
455 EXTERN_MSC int PSL_plotpoint (struct PSL_CTRL *PSL, double x, double y, int pen);
456 EXTERN_MSC int PSL_plotbox (struct PSL_CTRL *PSL, double x0, double y0, double x1, double y1);
457 EXTERN_MSC int PSL_plotpolygon (struct PSL_CTRL *PSL, double *x, double *y, int n);
458 EXTERN_MSC int PSL_plotsegment (struct PSL_CTRL *PSL, double x0, double y0, double x1, double y1);
459 EXTERN_MSC int PSL_plotsymbol (struct PSL_CTRL *PSL, double x, double y, double param[], int symbol);
460 EXTERN_MSC int PSL_plottext (struct PSL_CTRL *PSL, double x, double y, double fontsize, char *text, double angle, int justify, int mode);
461 EXTERN_MSC int PSL_plottextbox (struct PSL_CTRL *PSL, double x, double y, double fontsize, char *text, double angle, int justify, double offset[], int mode);
462 EXTERN_MSC int PSL_plottextline (struct PSL_CTRL *PSL, double x[], double y[], int np[], int n_segments, void *arg1, void *arg2, char *label[], double angle[], int nlabel_per_seg[], double fontsize, int justify, double offset[], int mode);
463 EXTERN_MSC int PSL_loadimage (struct PSL_CTRL *PSL, char *file, struct imageinfo *header, unsigned char **image);
464 EXTERN_MSC int PSL_loadeps (struct PSL_CTRL *PSL, char *file, struct imageinfo *h, unsigned char **picture);
465 EXTERN_MSC int PSL_setcolor (struct PSL_CTRL *PSL, double rgb[], int mode);
466 EXTERN_MSC int PSL_setcurrentpoint (struct PSL_CTRL *PSL, double x, double y);
467 EXTERN_MSC int PSL_setexec (struct PSL_CTRL *PSL, int action);
468 EXTERN_MSC int PSL_setdefaults (struct PSL_CTRL *PSL, double xyscales[], double page_rgb[], char *encoding);
469 EXTERN_MSC int PSL_setdash (struct PSL_CTRL *PSL, char *pattern, double offset);
470 EXTERN_MSC int PSL_setfill (struct PSL_CTRL *PSL, double rgb[], int outline);
471 EXTERN_MSC int PSL_setfont (struct PSL_CTRL *PSL, int font_no);
472 EXTERN_MSC int PSL_setfontdims (struct PSL_CTRL *PSL, double supsub, double scaps, double sup_lc, double sup_uc, double sdown);
473 EXTERN_MSC int PSL_setformat (struct PSL_CTRL *PSL, int n_decimals);
474 EXTERN_MSC int PSL_setimage (struct PSL_CTRL *PSL, int image_no, char *imagefile, unsigned char *image, int image_dpi, unsigned int dim[], double f_rgb[], double b_rgb[]);
475 EXTERN_MSC int PSL_setlinecap (struct PSL_CTRL *PSL, int cap);
476 EXTERN_MSC int PSL_setlinejoin (struct PSL_CTRL *PSL, int join);
477 EXTERN_MSC int PSL_setlinewidth (struct PSL_CTRL *PSL, double linewidth);
478 EXTERN_MSC int PSL_setmiterlimit (struct PSL_CTRL *PSL, int limit);
479 EXTERN_MSC int PSL_setorigin (struct PSL_CTRL *PSL, double x, double y, double angle, int mode);
480 EXTERN_MSC int PSL_setparagraph (struct PSL_CTRL *PSL, double line_space, double par_width, int par_just);
481 EXTERN_MSC int PSL_setpattern (struct PSL_CTRL *PSL, int image_no, char *imagefile, int image_dpi, double f_rgb[], double b_rgb[]);
482 EXTERN_MSC int PSL_settextmode (struct PSL_CTRL *PSL, int mode);
483 EXTERN_MSC int PSL_settransparencies (struct PSL_CTRL *PSL, double *transparencies);
484 EXTERN_MSC int PSL_settransparencymode (struct PSL_CTRL *PSL, const char *mode);
485 EXTERN_MSC int PSL_definteger (struct PSL_CTRL *PSL, const char *param, int value);
486 EXTERN_MSC int PSL_defpen (struct PSL_CTRL *PSL, const char *param, double width, char *style, double offset, double rgb[]);
487 EXTERN_MSC int PSL_defpoints (struct PSL_CTRL *PSL, const char *param, double fontsize);
488 EXTERN_MSC int PSL_defcolor (struct PSL_CTRL *PSL, const char *param, double rgb[]);
489 EXTERN_MSC int PSL_deftextdim (struct PSL_CTRL *PSL, const char *dim, double fontsize, char *text);
490 EXTERN_MSC int PSL_defunits (struct PSL_CTRL *PSL, const char *param, double value);
491 
492 EXTERN_MSC unsigned char *psl_gray_encode (struct PSL_CTRL *PSL, size_t *nbytes, unsigned char *input);
493 EXTERN_MSC void psl_set_txt_array (struct PSL_CTRL *PSL, const char *param, char *array[], int n);
494 EXTERN_MSC void psl_set_int_array (struct PSL_CTRL *PSL, const char *param, int *array, int n);
495 EXTERN_MSC char *psl_prepare_text (struct PSL_CTRL *PSL, char *text);
496 
497 /* Used indirectly by FORTRAN wrapper PSL_free_ . */
498 EXTERN_MSC int PSL_free_nonmacro (void *addr);
499 
500 /* Definition for printing a message. When DEBUG is on, also print source file and line number.
501  * Use this for various progress statements, debugging to see certain variables, and even fatal
502  * error messages. */
503 /* For FORTRAN there is PSL_command_ that only accepts one text argument */
504 EXTERN_MSC int PSL_command (struct PSL_CTRL *C, const char *format, ...);
505 EXTERN_MSC int PSL_comment (struct PSL_CTRL *C, const char *format, ...);
506 EXTERN_MSC int PSL_initerr (struct PSL_CTRL *C, const char *format, ...);
507 EXTERN_MSC int PSL_message (struct PSL_CTRL *C, int level, const char *format, ...);
508 EXTERN_MSC FILE *PSL_fopen (struct PSL_CTRL *C, char *file, char *mode);
509 EXTERN_MSC int PSL_fclose (struct PSL_CTRL *C);
510 
511 #ifdef PSL_WITH_GMT4_SUPPORT
512 /* Backwards compatible vector symbol from GMT 4 days */
513 EXTERN_MSC void psl_vector_v4 (struct PSL_CTRL *PSL, double x, double y, double param[], double rgb[], int outline);
514 #endif
515 
516 /* Deprecated */
517 EXTERN_MSC int PSL_settransparency (struct PSL_CTRL *PSL, double transparency);
518 
519 /*! Macro for free that explicitly checks for NULL pointer and sets freed pointer to NULL */
520 #define PSL_free(ptr) (free((void *)(ptr)),(ptr)=NULL)
521 
522 #ifdef __cplusplus
523 }
524 #endif
525 
526 #endif /* _POSTSCRIPTLIGHT_H */
527