1 /*--------------------------------------------------------------------
2  *
3  *	Copyright (c) 2012-2021 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
4  *	See LICENSE.TXT file for copying and redistribution conditions.
5  *
6  *	This program is free software; you can redistribute it and/or modify
7  *	it under the terms of the GNU Lesser General Public License as published by
8  *	the Free Software Foundation; version 3 or any later version.
9  *
10  *	This program is distributed in the hope that it will be useful,
11  *	but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *	GNU Lesser General Public License for more details.
14  *
15  *	Contact info: www.generic-mapping-tools.org
16  *--------------------------------------------------------------------*/
17 /*
18  * gmt_resources.h contains the definitions for the six GMT resources
19  * GMT_DATASET, GMT_GRID, GMT_IMAGE, GMT_PALETTE, GMT_POSTSCRIPT
20  * as well as the two auxiliary resources GMT_MATRIX and GMT_VECTOR,
21  * as well as all named enums.
22  *
23  * Author:	Paul Wessel
24  * Date:	13-JUN-2016
25  * Version:	6 API
26  */
27 
28 /*!
29  * \file gmt_resources.h
30  * \brief Definitions for the GMT resources (GMT_GRID, GMT_DATASET, etc...)
31  */
32 
33 #ifndef GMT_RESOURCES_H
34 #define GMT_RESOURCES_H
35 
36 #ifdef DOUBLE_PRECISION_GRID
37 /* Build GMT using double-precision for grids.  Untested and caveat emptor */
38 typedef double gmt_grdfloat;
39 #else
40 /* GMT default is single-precision grids */
41 typedef float gmt_grdfloat;
42 #endif
43 
44 /*============================================================ */
45 /*=============== Constants Public Declaration =============== */
46 /*============================================================ */
47 
48 /* Here are structure definitions and constants (enums) needed by the
49  * public GMT API. Note: As this is C, some structures will contain
50  * members we do not disclose in the API documentation but of course
51  * the variables are accessible just like the "public" ones.  There
52  * is no guarantee that the "private" members cannot change over time.
53  */
54 
55 /*! Session modes for GMT_Create_Session. Do NOT change first 4 as affects GMT.jl */
56 enum GMT_enum_session {
57 	GMT_SESSION_NORMAL    = 0,	/* Typical mode to GMT_Create_Session */
58 	GMT_SESSION_NOEXIT    = 1,	/* Call return and not exit when error */
59 	GMT_SESSION_EXTERNAL  = 2,	/* Called by an external API (e.g., MATLAB, Python). */
60 	GMT_SESSION_COLMAJOR  = 4,	/* External API uses column-major formats (e.g., MATLAB, FORTRAN). [Row-major format] */
61 	GMT_SESSION_LOGERRORS = 8,	/* External API uses column-major formats (e.g., MATLAB, FORTRAN). [Row-major format] */
62 	GMT_SESSION_RUNMODE   = 16,	/* If set enable GMT's modern runmode. [Classic] */
63 	GMT_SESSION_NOHISTORY = 32,	/* Do not use gmt.history at all [Let modules decide] */
64 	GMT_SESSION_NOGDALCLOSE = 64	/* Do not call GDALDestroyDriverManager when using GDAL functions */
65 };
66 
67 /*! Logging settings */
68 enum GMT_enum_log {
69 	GMT_LOG_OFF	= 0,	/* Let errors go to stderr [Default] */
70 	GMT_LOG_ONCE	= 1,	/* Redirect log errors to new source until end of module */
71 	GMT_LOG_SET	= 2	/* Change log error destination until changed or session ends */
72 };
73 
74 /*! Miscellaneous settings */
75 enum GMT_enum_api {
76 	GMT_USAGE	= 0,	/* Want to report full program usage message */
77 	GMT_SYNOPSIS	= 1,	/* Just want the synopsis of usage */
78 	GMT_PAD_DEFAULT = 2,	/* Default is 2 rows and 2 cols for grid padding */
79 	GMT_VF_LEN	= 32	/* Bytes needed to hold the @GMTAPI@-* virtual file names */
80 };
81 
82 /*! These data primitive identifiers are as follows: */
83 enum GMT_enum_type {
84 	GMT_CHAR	=    0,  /* int8_t, 1-byte signed integer type */
85 	GMT_UCHAR	=    1,  /* uint8_t, 1-byte unsigned integer type */
86 	GMT_SHORT	=    2,  /* int16_t, 2-byte signed integer type */
87 	GMT_USHORT	=    3,  /* uint16_t, 2-byte unsigned integer type */
88 	GMT_INT		=    4,  /* int32_t, 4-byte signed integer type */
89 	GMT_UINT	=    5,  /* uint32_t, 4-byte unsigned integer type */
90 	GMT_LONG	=    6,  /* int64_t, 8-byte signed integer type */
91 	GMT_ULONG	=    7,  /* uint64_t, 8-byte unsigned integer type */
92 	GMT_FLOAT	=    8,  /* 4-byte data float type */
93 	GMT_DOUBLE	=    9,  /* 8-byte data float type */
94 	GMT_TEXT	=   16,  /* Arbitrarily long text string [OGR/GMT use only and GMT_Put_Vector only] */
95 	GMT_DATETIME	=   32,  /* string with date/time info [OGR/GMT use and GMT_Put_Vector only] */
96 	GMT_N_TYPES	=   12,  /* The number of supported data types above */
97 	GMT_VIA_CHAR	=  100,  /* int8_t, 1-byte signed integer type */
98 	GMT_VIA_UCHAR	=  200,  /* uint8_t, 1-byte unsigned integer type */
99 	GMT_VIA_SHORT	=  300,  /* int16_t, 2-byte signed integer type */
100 	GMT_VIA_USHORT	=  400,  /* uint16_t, 2-byte unsigned integer type */
101 	GMT_VIA_INT	=  500,  /* int32_t, 4-byte signed integer type */
102 	GMT_VIA_UINT	=  600,  /* uint32_t, 4-byte unsigned integer type */
103 	GMT_VIA_LONG	=  700,  /* int64_t, 8-byte signed integer type */
104 	GMT_VIA_ULONG	=  800,  /* uint64_t, 8-byte unsigned integer type */
105 	GMT_VIA_FLOAT	=  900,  /* 4-byte data float type */
106 	GMT_VIA_DOUBLE	= 1000   /* 8-byte data float type */
107 };
108 
109 #ifdef DOUBLE_PRECISION_GRID
110 #define GMT_GRDFLOAT GMT_DOUBLE
111 #else
112 #define GMT_GRDFLOAT GMT_FLOAT
113 #endif
114 
115 /*! These are the 5 methods for i/o; used as arguments in the API that expects a "method" */
116 
117 enum GMT_enum_method {
118 	GMT_IS_FILE	 =    0,	/* Entity is a filename */
119 	GMT_IS_STREAM	 =    1,	/* Entity is an open stream */
120 	GMT_IS_FDESC	 =    2,	/* Entity is an open file descriptor */
121 	GMT_IS_DUPLICATE =   16,	/* Entity is a memory location that should be duplicated */
122 	GMT_IS_REFERENCE =   32,	/* Entity is a memory location that should be referenced */
123 	GMT_IS_OUTPUT	 = 1024		/* When creating a resource as a container for output */
124 };
125 
126 /* A Grid can come from a grid OR User Matrix, and Data can come from DATASET or via Vectors|Matrix */
127 
128 enum GMT_enum_via {
129 	GMT_VIA_NONE		=   0,	/* No via anything */
130 	GMT_VIA_MODULE_INPUT	=  64,	/* To flag resources destined for another module's "command-line" input */
131 	GMT_VIA_VECTOR		= 128,	/* A data item masquerading as a vector */
132 	GMT_VIA_MATRIX		= 256	/* A data item masquerading as a matrix */
133 };
134 
135 /* We may allocate just a container, just the data (if container was allocated earlier), or both: */
136 enum GMT_enum_container {
137 	GMT_CONTAINER_AND_DATA	= 0U,   /* Create|Read|write both container and the data array */
138 	GMT_CONTAINER_ONLY	= 1U,   /* Create|read|write the container but no data array */
139 	GMT_DATA_ONLY		= 2U,   /* Create|Read|write the container's array only */
140 	GMT_WITH_STRINGS	= 32U,  /* Allocate string array also [DATASET, MATRIX, VECTOR only] */
141 	GMT_CUBE_IS_STACK	= 64U,	/* Set if source was a stack of 2-D grids */
142 	GMT_NO_STRINGS		= 0U    /* Do not allocate string array also [Default] */
143 };
144 
145 /*! These are the 5 families of data types, + a coordinate array + 3 help containers for vector, matrix, and coordinates */
146 enum GMT_enum_family {
147 	GMT_IS_DATASET    = 0,	/* Entity is a data table */
148 	GMT_IS_GRID       = 1,	/* Entity is a grid */
149 	GMT_IS_IMAGE      = 2,	/* Entity is a 1- or 3-layer unsigned char image */
150 	GMT_IS_PALETTE    = 3,	/* Entity is a color palette table */
151 	GMT_IS_POSTSCRIPT = 4,	/* Entity is a PostScript content struct */
152 	GMT_IS_MATRIX	  = 5,	/* Entity is user matrix */
153 	GMT_IS_VECTOR	  = 6,	/* Entity is set of user vectors */
154 	GMT_IS_CUBE	  = 7,	/* Entity is set of user vectors */
155 	GMT_IS_COORD	  = 8,	/* Entity is a double coordinate array */
156 	GMT_N_FAMILIES	  = 9	/* Total number of families [API Developers only]  */
157 };
158 
159 enum GMT_enum_CPT {
160 	GMT_IS_PALETTE_KEY    = 1024,	/* Strings to GMT_Put_Strings are keys */
161 	GMT_IS_PALETTE_LABEL  = 2048	/* Strings to GMT_Put_Strings are labels */
162 };
163 
164 #define GMT_IS_CPT	GMT_IS_PALETTE		/* Backwards compatibility for < 5.3.3; */
165 
166 /*! These are modes for handling comments */
167 enum GMT_enum_comment {
168 	GMT_COMMENT_IS_TEXT	= 0,        /* Comment is a text string */
169 	GMT_COMMENT_IS_OPTION	= 1U,   /* Comment is a linked list of GMT_OPTION structures */
170 	GMT_COMMENT_IS_COMMAND	= 2U,   /* Comment replaces header->command */
171 	GMT_COMMENT_IS_REMARK	= 4U,   /* Comment replaces header->remark */
172 	GMT_COMMENT_IS_TITLE	= 8U,   /* Comment replaces header->title */
173 	GMT_COMMENT_IS_NAME_X	= 16U,  /* Comment replaces header->x_units [grids only] */
174 	GMT_COMMENT_IS_NAME_Y	= 32U,  /* Comment replaces header->y_units [grids only] */
175 	GMT_COMMENT_IS_NAME_Z	= 64U,  /* Comment replaces header->z_units [grids only] */
176 	GMT_COMMENT_IS_COLNAMES	= 128U, /* Comment replaces header->colnames [tables only] */
177 	GMT_COMMENT_IS_RESET	= 256U, /* Wipe existing header first [append] */
178 	GMT_COMMENT_IS_MULTISEG = 512U  /* Comment is in fact a multisegment record */
179 };
180 
181 enum GMT_enum_apierr {
182 	GMT_NOTSET  = -1,	/* When something is not set */
183 	GMT_NOERROR = 0		/* Return code when all is well */
184 };
185 
186 enum GMT_enum_module {
187 	GMT_MODULE_USAGE		= -9,	/* What GMT_Call_Module returns if told to print usage only */
188 	GMT_MODULE_SYNOPSIS		= -8,	/* What GMT_Call_Module returns if told to print synopsis only */
189 	GMT_MODULE_CLASSIC		= -7,	/* mode for GMT_Call_Module to print list of all classic modules */
190 	GMT_MODULE_LIST			= -6,	/* mode for GMT_Call_Module to print list of all modern modules */
191 	GMT_MODULE_CLASSIC_CORE	= -5,	/* mode for GMT_Call_Module to print list of all classic modules (core only) */
192 	GMT_MODULE_LIST_CORE	= -4,	/* mode for GMT_Call_Module to print list of all modern modules (core only) */
193 	GMT_MODULE_EXIST		= -3,	/* mode for GMT_Call_Module to return 0 if it exists */
194 	GMT_MODULE_PURPOSE		= -2,	/* mode for GMT_Call_Module to print purpose of module, or all modules */
195 	GMT_MODULE_OPT			= -1,	/* Gave linked list of option structures to GMT_Call_Module */
196 	GMT_MODULE_CMD			=  0,	/* Gave an array of text strings (argv[]) to GMT_Call_Module */
197 	GMT_MODULE_HELP     	 	=  0,	/* Mode for GMT_Show_ModuleInfo to do gmt --help */
198 	GMT_MODULE_SHOW_MODERN   	=  1,	/* Mode for GMT_Show_ModuleInfo to list all modern modules in gmt --show-modules */
199 	GMT_MODULE_SHOW_CLASSIC  	=  2,	/* Mode for GMT_Show_ModuleInfo to list all classic modules in gmt --show-classic */
200 	GMT_MODULE_KEYS  		=  0,	/* Mode for GMT_Get_ModuleInfo to request the module keys */
201 	GMT_MODULE_GROUP   		=  1	/* Mode for GMT_Get_ModuleInfo to request the module group */
202 };
203 
204 /* Array indices for input/output/stderr variables */
205 
206 enum GMT_enum_std {
207 	GMT_IN	= 0,	/* stdin */
208 	GMT_OUT	= 1,	/* stdout */
209 	GMT_ERR	= 2,	/* stderr */
210 	GMT_IO	= 2	/* Both input and output */
211 };
212 
213 /* There are 3 named columns */
214 enum GMT_enum_dimensions {
215 	GMT_X	= 0,	/* x or lon is in 0th column */
216 	GMT_Y	= 1,	/* y or lat is in 1st column */
217 	GMT_Z	= 2	/* z is in 2nd column */
218 };
219 
220 enum GMT_enum_freg {
221 	GMT_ADD_FILES_IF_NONE =  1,	/* Tell GMT_Init_IO we conditionally want to register all input files in the option list if nothing else is registered */
222 	GMT_ADD_FILES_ALWAYS  =  2,	/* Tell GMT_Init_IO to always register all input files in the option list */
223 	GMT_ADD_STDIO_IF_NONE =  4,	/* Tell GMT_Init_IO we conditionally want to register std(in|out) if nothing else has been registered */
224 	GMT_ADD_STDIO_ALWAYS  =  8,	/* Tell GMT_Init_IO to always register std(in|out) */
225 	GMT_ADD_EXISTING      = 16,	/* Tell GMT_Init_IO to only use already registered resources */
226 	GMT_ADD_DEFAULT       =  6	/* Tell GMT_Init_IO to register files, and if none are found then std(in|out), but only if nothing was registered before this call */
227 };
228 
229 /* Three constants for GMT_Get_DataPath modes */
230 enum GMT_enum_files {
231 	GMT_FILE_LOCAL        =  0,	/* Tell GMT_Get_DataPath to only consider local files and ignore remote files */
232 	GMT_FILE_REMOTE       =  1,	/* Tell GMT_Get_DataPath to try to download remote files if given such files (@filename) */
233 	GMT_FILE_CHECK        =  2,	/* Tell GMT_Get_DataPath to only return error codes but not update the path */
234 };
235 
236 enum GMT_enum_ioset {
237 	GMT_IO_DONE = 0,	/* Tell GMT_End_IO we are done but nothing special is to be done. */
238 	GMT_IO_ASCII = 512,	/* Force ASCII mode for reading (ignoring current io settings). */
239 	GMT_IO_RESET = 32768,	/* Tell GMT_End_IO that accessed resources should be made read/write-able again. */
240 	GMT_IO_UNREG = 16384	/* Tell GMT_End_IO to unregister all accessed resources. */
241 };
242 
243 enum GMT_enum_read {
244 	GMT_READ_NORMAL = 0,	/* Normal read mode [Default] */
245 	GMT_READ_DATA	= 1,	/* Read ASCII data record and return double array */
246 	GMT_READ_TEXT	= 2,	/* Read ASCII data record and return text string */
247 	GMT_READ_MIXED	= 3,	/* Read ASCII data record and return double array but tolerate conversion errors */
248 	GMT_READ_FILEBREAK = 4	/* Add to mode to indicate we want to know when each file end is reached [continuous] */
249 };
250 
251 enum GMT_enum_write {
252 	GMT_WRITE_DATA = 1,		/* Write double array to output */
253 	GMT_WRITE_TEXT = 2,		/* Write ASCII current record to output */
254 	GMT_WRITE_MIXED = 3,		/* Write mixed numerical/text record to output */
255 	GMT_WRITE_TABLE_HEADER = 4,	/* Write current record as table header to output */
256 	GMT_WRITE_SEGMENT_HEADER = 8,	/* Write segment header record to output */
257 	GMT_WRITE_TABLE_START = 16,	/* Write common header block to output (optional title + command line) */
258 	GMT_WRITE_SET = 0,		/* Write all output tables and all their segments to one destination [Default] */
259 	GMT_WRITE_OGR = 1,		/* Output OGR/GMT format [Requires proper -a setting] */
260 	GMT_WRITE_TABLE = 2,		/* Write each output table and all their segments to separate destinations */
261 	GMT_WRITE_SEGMENT = 3,		/* Write all output tables' segments to separate destinations */
262 	GMT_WRITE_TABLE_SEGMENT = 4,	/* Same as 2 but if no filenames we use both tbl and seg with format */
263 	GMT_WRITE_NORMAL = 0,		/* Write header and contents of this entity (table or segment) */
264 	GMT_WRITE_HEADER = 1,		/* Only write header and not the contents of this entity (table or segment) */
265 	GMT_WRITE_SKIP = 2,		/* Entirely skip this entity on output (table or segment) */
266 	GMT_WRITE_NOLF = 32,		/* Do not write LF at end of ASCII record, and not increment output rec number */
267 	GMT_STRICT_CONVERSION = 1024,	/* Do not convert text to double unless is is viable */
268 	GMT_LAX_CONVERSION = 2048	/* Convert text to double if at least one field can be converted */
269 };
270 
271 enum GMT_enum_header {
272 	GMT_HEADER_OFF = 0,	/* Disable header blocks out as default */
273 	GMT_HEADER_ON = 1	/* Enable header blocks out as default */
274 };
275 
276 enum GMT_enum_data {
277 	GMT_DATA_IS_GEO = 256	/*  Data are geographic, not Cartesian */
278 };
279 
280 enum GMT_enum_alloc {
281 	GMT_ALLOC_EXTERNALLY = 0,	/* Allocated outside of GMT: We cannot reallocate or free this memory */
282 	GMT_ALLOC_INTERNALLY = 1,	/* Allocated by GMT: We may reallocate as needed and free when no longer needed */
283 	GMT_ALLOC_NORMAL = 0,		/* Normal allocation of new dataset based on shape of input dataset */
284 	GMT_ALLOC_VERTICAL = 4,		/* Allocate a single table for data set to hold all input tables by vertical concatenation */
285 	GMT_ALLOC_HORIZONTAL = 8,	/* Allocate a single table for data set to hold all input tables by horizontal (paste) concatenations */
286 	GMT_ALLOC_VIA_ICOLS = 16	/* Follow -i settings when doing the duplication */
287 };
288 
289 enum GMT_enum_duplicate {
290 	GMT_DUPLICATE_NONE  = 0,	/* Duplicate data set structure but no allocate&copy of data records|grid|image */
291 	GMT_DUPLICATE_ALLOC = 1,	/* Duplicate data set structure and allocate space for data records|grid|image, but no copy */
292 	GMT_DUPLICATE_DATA  = 2,	/* Duplicate data set structure, allocate space for data records|grid|image, and copy */
293 	GMT_DUPLICATE_RESET = 4		/* During duplicate, reset copy to normal system grid pad if original is different */
294 };
295 
296 /* Various directions and modes to call the FFT */
297 enum GMT_enum_FFT {
298 	GMT_FFT_FWD     = 0U,	/* forward Fourier transform */
299 	GMT_FFT_INV     = 1U,	/* inverse Fourier transform */
300 	GMT_FFT_REAL    = 0U,	/* real-input FT (currently unsupported) */
301 	GMT_FFT_COMPLEX = 1U	/* complex-input Fourier transform */
302 };
303 
304 /* Various modes to select time in GMT_Message */
305 enum GMT_enum_time {
306 	GMT_TIME_NONE    = 0U,	/* Do not report time */
307 	GMT_TIME_CLOCK   = 1U,	/* Report absolute time formatted via FORMAT_TIME_STAMP */
308 	GMT_TIME_ELAPSED = 2U,	/* Report elapsed time since last time mark reset */
309 	GMT_TIME_RESET   = 4U	/* Reset time mark */
310 };
311 
312 /* Verbosity levels */
313 enum GMT_enum_verbose {
314 	GMT_MSG_QUIET		= 0,   	/* No messages whatsoever */
315 	GMT_MSG_NOTICE		= 1,	/* Special notices */
316 	GMT_MSG_ERROR		= 2,	/* Errors only */
317 	GMT_MSG_WARNING		= 3,	/* Adds warnings */
318 	GMT_MSG_TICTOC		= 4,	/* Add timings */
319 	GMT_MSG_INFORMATION	= 5,	/* Adds informational messages */
320 	GMT_MSG_COMPAT		= 6,	/* Compatibility warnings */
321 	GMT_MSG_DEBUG		= 7,	/* Debug messages for developers mostly */
322 	/* For API backwards compatibility only */
323 	GMT_MSG_NORMAL		= 2,	/* Now GMT_MSG_ERROR */
324 	GMT_MSG_VERBOSE		= 5,	/* Now GMT_MSG_WARNING  */
325 	GMT_MSG_LONG_VERBOSE	= 6		/* Now GMT_MSG_INFORMATION */
326 };
327 
328 /* GMT_RECORD Declaration */
329 
330 struct GMT_RECORD {
331 	double *data;	/* Points to the current record's leading numerical data array (or NULL)*/
332 	char *text;	/* Points to the start of the current record's trailing text (or NULL); */
333 };
334 
335 /*============================================================ */
336 /*===============+ GMT_GRID Public Declaration =============== */
337 /*============================================================ */
338 
339 enum GMT_enum_reg {	/* Public constants for grid registration */
340 	GMT_GRID_NODE_REG	= 0U,
341 	GMT_GRID_PIXEL_REG	= 1U,
342 	GMT_GRID_DEFAULT_REG	= 1024U	/* Means select whatever is implied via -r */
343 };
344 
345 enum GMT_enum_gridindex {
346         GMT_XLO = 0U,	/* Index for west or xmin value */
347         GMT_XHI = 1U,	/* Index for east or xmax value */
348         GMT_YLO = 2U,	/* Index for south or ymin value */
349         GMT_YHI = 3U,	/* Index for north or ymax value */
350         GMT_ZLO = 4U,	/* Index for zmin value */
351         GMT_ZHI = 5U	/* Index for zmax value */
352 };
353 
354 enum GMT_enum_dimindex {
355         GMT_TBL = 0U,	/* Index for number of tables in dimension array */
356         GMT_SEG = 1U,	/* Index for number of segments in dimension array */
357         GMT_ROW = 2U,	/* Index for number of rows in dimension array */
358         GMT_COL = 3U	/* Index for number of columns in dimension array [DATASET only] */
359 };
360 
361 enum GMT_enum_gridio {
362 	GMT_GRID_IS_CARTESIAN	   = 0U,    /* Grid is not geographic but Cartesian */
363 	GMT_GRID_IS_REAL	   = 0U,    /* Read|write a normal real-valued grid */
364 	GMT_GRID_IS_COMPLEX_REAL   = 4U,    /* Read|write the real component to/from a complex grid */
365 	GMT_GRID_IS_COMPLEX_IMAG   = 8U,    /* Read|write the imaginary component to/from a complex grid */
366 	GMT_GRID_IS_COMPLEX_MASK   = 12U,   /* To mask out the real|imag flags */
367 	GMT_GRID_NO_HEADER	   = 16U,   /* Write a native grid without the leading grid header */
368 	GMT_GRID_ROW_BY_ROW	   = 32U,   /* Read|write the grid array one row at the time sequentially */
369 	GMT_GRID_ROW_BY_ROW_MANUAL = 64U,   /* Read|write the grid array one row at the time in any order */
370 	GMT_GRID_XY		   = 128U,  /* Allocate and initialize x,y vectors */
371 	GMT_GRID_IS_GEO		   = 256U,  /* Grid is a geographic grid, not Cartesian [Deprecated, use GMT_DATA_IS_GEO instead] */
372 	GMT_GRID_IS_IMAGE	   = 512U,   /* Grid may be an image, only allowed with GMT_CONTAINER_ONLY */
373 	GMT_IMAGE_NO_INDEX	   = 4096,	/* If reading an indexed grid, convert to rgb so we can interpolate */
374 	GMT_IMAGE_ALPHA_LAYER  = 8192,	/* Place any alpha layer in the image band, not alpha array */
375 	GMT_GRID_NEEDS_PAD1	   = 65536,	/* This module requires grids or images to have at least 1 boundary pad all around */
376 	GMT_GRID_NEEDS_PAD2	   = 131072	/* This module requires grids or images to have at least 2 boundary pad all around */
377 };
378 
379 #define GMT_GRID_ALL		0U   /* Backwards compatibility for < 5.3.3; See GMT_CONTAINER_AND_DATA */
380 #define GMT_GRID_HEADER_ONLY	1U   /* Backwards compatibility for < 5.3.3; See GMT_CONTAINER_ONLY */
381 #define GMT_GRID_DATA_ONLY	2U   /* Backwards compatibility for < 5.3.3; See GMT_DATA_ONLY */
382 
383 /* These lengths (except GMT_GRID_VARNAME_LEN80) must NOT be changed as they are part of grd definition */
384 enum GMT_enum_grdlen {
385 	GMT_GRID_UNIT_LEN80     = 80U,
386 	GMT_GRID_TITLE_LEN80    = 80U,
387 	GMT_GRID_VARNAME_LEN80  = 80U,
388 	GMT_GRID_COMMAND_LEN320 = 320U,
389 	GMT_GRID_REMARK_LEN160  = 160U,
390 	GMT_GRID_NAME_LEN256	= 256U,
391 	GMT_GRID_HEADER_SIZE    = 892U
392 };
393 
394 /* Note: GMT_GRID_HEADER_SIZE is 4 less than sizeof (struct GMT_GRID_HEADER) on
395  * 64 bit systems due to alignment.  Since the GMT_GRID_HEADER was designed
396  * during the 32-bit era its size in files is 892.  For backwards compatibility
397  * we continue to enforce this header size by writing the structure components
398  * separately. */
399 
400 struct GMT_GRID_HEADER {
401 	/* Variables we document for the API:
402 	 * == Do not change the type of the following three items.
403 	 * == They are copied verbatim to the native grid header and must be 4-byte unsigned ints. */
404 	uint32_t n_columns;              /* Number of columns */
405 	uint32_t n_rows;                 /* Number of rows */
406 	uint32_t registration;           /* GMT_GRID_NODE_REG (0) for node grids, GMT_GRID_PIXEL_REG (1) for pixel grids */
407 
408 	/* -- Here is the possible location for data structure padding:
409 	 *    A double is 8-byte aligned on Windows. */
410 
411 	/* == The types of the following 12 elements must not be changed.
412 	 * == They are also copied verbatim to the native grid header. */
413 	double wesn[4];                        /* Min/max x and y coordinates */
414 	double z_min;                          /* Minimum z value */
415 	double z_max;                          /* Maximum z value */
416 	double inc[2];                         /* x and y increment */
417 	double z_scale_factor;                 /* grd values must be multiplied by this */
418 	double z_add_offset;                   /* After scaling, add this */
419 	char x_units[GMT_GRID_UNIT_LEN80];     /* units in x-direction */
420 	char y_units[GMT_GRID_UNIT_LEN80];     /* units in y-direction */
421 	char z_units[GMT_GRID_UNIT_LEN80];     /* grid value units */
422 	char title[GMT_GRID_TITLE_LEN80];      /* name of data set */
423 	char command[GMT_GRID_COMMAND_LEN320]; /* name of generating command */
424 	char remark[GMT_GRID_REMARK_LEN160];   /* comments re this data set */
425 
426 	/* Items not stored in the data file for grids but explicitly used in macros computing node numbers */
427 	size_t nm;                  /* Number of data items in this grid (n_columns * n_rows) [padding is excluded] */
428 	size_t size;                /* Actual number of items (not bytes) required to hold this grid (= mx * my), per band (for images) */
429 	unsigned int bits;          /* Bits per data value (e.g., 32 for ints/floats; 8 for bytes) */
430 	unsigned int complex_mode;  /* 0 = normal, GMT_GRID_IS_COMPLEX_REAL = real part of complex grid, GMT_GRID_IS_COMPLEX_IMAG = imag part of complex grid */
431 	unsigned int type;          /* Grid format */
432 	unsigned int n_bands;       /* Number of bands [1]. Used with IMAGE containers and macros to get ij index from row,col, band */
433 	unsigned int mx, my;        /* Actual dimensions of the grid in memory, allowing for the padding */
434 	unsigned int pad[4];        /* Padding on west, east, south, north sides [2,2,2,2] */
435 	char   mem_layout[4];       /* Three or Four char codes T|B R|C S|R|S (grd) or B|L|P + A|a (img) describing array layout in mem and interleaving */
436 	gmt_grdfloat  nan_value;    /* Missing value as stored in grid file */
437 	double xy_off;              /* 0.0 (registration == GMT_GRID_NODE_REG) or 0.5 ( == GMT_GRID_PIXEL_REG) */
438 	char *ProjRefPROJ4;         /* To store a referencing system string in PROJ.4 format */
439 	char *ProjRefWKT;           /* To store a referencing system string in WKT format */
440 	int ProjRefEPSG;            /* To store a referencing system EPSG code */
441 	void *hidden;               /* Lower-level information for GMT use only */
442 };
443 
444 /* grd is stored in rows going from west (xmin) to east (xmax)
445  * first row in file has yvalue = north (ymax).
446  * This is SCANLINE orientation.*/
447 
448 /*-----------------------------------------------------------------------------------------
449  *	Notes on registration:
450 
451 	Assume x_min = y_min = 0 and x_max = y_max = 10 and x_inc = y_inc = 1.
452 	For a normal node grid we have:
453 		(1) n_columns = (x_max - x_min) / x_inc + 1 = 11
454 		    n_rows = (y_max - y_min) / y_inc + 1 = 11
455 		(2) node # 0 is at (x,y) = (x_min, y_max) = (0,10) and represents the surface
456 		    value in a box with dimensions (1,1) centered on the node.
457 	For a pixel grid we have:
458 		(1) n_columns = (x_max - x_min) / x_inc = 10
459 		    n_rows = (y_max - y_min) / y_inc = 10
460 		(2) node # 0 is at (x,y) = (x_min + 0.5*x_inc, y_max - 0.5*y_inc) = (0.5, 9.5)
461 		    and represents the surface value in a box with dimensions (1,1)
462 		    centered on the node.
463 -------------------------------------------------------------------------------------------*/
464 
465 struct GMT_GRID {	/* To hold a GMT gmt_grdfloat grid and its header in one container */
466 	struct GMT_GRID_HEADER *header;	/* Pointer to full GMT header for the grid */
467 	gmt_grdfloat *data;             /* Pointer to the gmt_grdfloat grid */
468 	double *x, *y;                  /* Vector of coordinates */
469 	void *hidden;                   /* Row-by-row machinery information [NULL] */
470 };
471 
472 /*============================================================ */
473 /*============== GMT_DATASET Public Declaration ============== */
474 /*============================================================ */
475 
476 /* GIS geometries, with GMT_IS_NONE as 16 for no such thing */
477 enum GMT_enum_geometry {
478 	GMT_IS_POINT	= 1U,
479 	GMT_IS_LINE	= 2U,
480 	GMT_IS_POLY	= 4U,
481 	GMT_IS_LP	= 6U,	/* Could be any one of LINE or POLY */
482 	GMT_IS_PLP	= 7U,	/* Could be any one of POINT, LINE, POLY */
483 	GMT_IS_SURFACE	= 8U,
484 	GMT_IS_VOLUME	= 9U,
485 	GMT_IS_NONE	= 16U,	/* Non-geographical items like color palettes */
486 	GMT_IS_TEXT	= 32U	/* Text strings which triggers ASCII text reading */
487 };
488 
489 /* These are two polygon modes */
490 enum GMT_enum_pol {
491 	GMT_IS_PERIMETER =  0,
492 	GMT_IS_HOLE      = 1U
493 };
494 
495 /* Modes for setting columns for rec-by-rec input/output */
496 enum GMT_enum_columns {
497 	GMT_COL_FIX = 0,		/* Specify fixed numerical columns to read, anything beyond is considered trailing text */
498 	GMT_COL_ADD = 1,		/* Add to current number of columns */
499 	GMT_COL_SUB = 2,		/* Subtract from current number of columns */
500 	GMT_COL_VAR = 3,		/* Input ASCII records have variable number of columns */
501 	GMT_COL_FIX_NO_TEXT = 4		/* Specify fixed numerical columns to read, skip any trailing text */
502 };
503 
504 /* Return codes for GMT_Get_Record: */
505 
506 enum GMT_enum_ascii_input_return {	/* Bit flag related to record i/o */
507 	GMT_IO_DATA_RECORD    =  0,		/* Read a data record and had no issues */
508 	GMT_IO_TABLE_HEADER   =  1U,	/* Read a table header */
509 	GMT_IO_SEGMENT_HEADER =  2U,	/* Read a segment header */
510 	GMT_IO_ANY_HEADER     =  3U,	/* Read either table or segment header */
511 	GMT_IO_MISMATCH       =  4U,	/* Read incorrect number of columns */
512 	GMT_IO_EOF            =  8U,	/* Read end-of-file */
513 	GMT_IO_NAN            = 16U,	/* Read a NaN record */
514 	GMT_IO_NEW_SEGMENT    = 18U,	/* Read either segment header or NaN-record */
515 	GMT_IO_GAP            = 32U,	/* Determined a gap should occur before this record */
516 	GMT_IO_LINE_BREAK     = 58U,	/* Segment break caused by seg header, gap, nan, or EOF */
517 	GMT_IO_NEXT_FILE      = 64U	/* Like EOF except for an individual file (with more files to follow) */
518 };
519 
520 /* Here are the GMT data types used for tables */
521 
522 struct GMT_DATASEGMENT {    /* For holding segment lines in memory */
523 	/* Variables we document for the API: */
524 	uint64_t n_rows;        /* Number of points in this segment */
525 	uint64_t n_columns;     /* Number of fields in each record (>= 2) */
526 	double *min;            /* Minimum coordinate for each column */
527 	double *max;            /* Maximum coordinate for each column */
528 	double **data;          /* Data x,y, and possibly other columns */
529 	char *label;            /* Label string (if applicable) */
530 	char *header;           /* Segment header (if applicable) */
531 	char **text;            /* text beyond the data */
532 	void *hidden;		/* Book-keeping variables "hidden" from the API */
533 };
534 
535 struct GMT_DATATABLE {	/* To hold an array of line segment structures and header information in one container */
536 	/* Variables we document for the API: */
537 	unsigned int n_headers; /* Number of file header records (0 if no header) */
538 	uint64_t n_columns;     /* Number of columns (fields) in each record */
539 	uint64_t n_segments;    /* Number of segments in the array */
540 	uint64_t n_records;     /* Total number of data records across all segments */
541 	double *min;            /* Minimum coordinate for each column */
542 	double *max;            /* Maximum coordinate for each column */
543 	char **header;          /* Array with all file header records, if any) */
544 	struct GMT_DATASEGMENT **segment;	/* Pointer to array of segments */
545 	void *hidden;		/* Book-keeping variables "hidden" from the API */
546 };
547 
548 /* The main GMT Data Containers used in the API: */
549 
550 struct GMT_DATASET {	/* Single container for an array of GMT tables (files) */
551 	/* Variables we document for the API: */
552 	uint64_t n_tables;		/* The total number of tables (files) contained */
553 	uint64_t n_columns;		/* The number of data columns */
554 	uint64_t n_segments;		/* The total number of segments across all tables */
555 	uint64_t n_records;		/* The total number of data records across all tables */
556 	double *min;			/* Minimum coordinate for each column */
557 	double *max;			/* Maximum coordinate for each column */
558 	struct GMT_DATATABLE **table;	/* Pointer to array of tables */
559 	enum GMT_enum_read type;	/* The datatype (numerical, text, or mixed) of this dataset */
560 	enum GMT_enum_geometry geometry;/* The geometry of this dataset */
561 	char *ProjRefPROJ4;             /* To store a referencing system string in PROJ.4 format */
562 	char *ProjRefWKT;               /* To store a referencing system string in WKT format */
563 	int ProjRefEPSG;                /* To store a referencing system EPSG code */
564 	void *hidden;			/* Book-keeping variables "hidden" from the API */
565 };
566 
567 /*============================================================ */
568 /*============== GMT_PALETTE Public Declaration ============== */
569 /*============================================================ */
570 
571 enum GMT_enum_color {
572 	GMT_RGB			= 0,
573 	GMT_CMYK		= 1,
574 	GMT_HSV			= 2,
575 	GMT_COLORINT		= 4,
576 	GMT_NO_COLORNAMES	= 8
577 };
578 
579 enum GMT_enum_bfn {
580 	GMT_BGD = 0,
581 	GMT_FGD = 1,
582 	GMT_NAN = 2
583 };
584 
585 enum GMT_enum_cpt {
586 	GMT_CPT_REQUIRED = 0,
587 	GMT_CPT_OPTIONAL = 1
588 };
589 
590 enum GMT_enum_cptflags {
591 	GMT_CPT_NO_BNF     = 1,
592 	GMT_CPT_EXTEND_BNF = 2,
593 	GMT_CPT_HARD_HINGE = 4,
594 	GMT_CPT_SOFT_HINGE = 8,
595 	GMT_CPT_TIME       = 16,
596 	GMT_CPT_COLORLIST  = 32,
597 	GMT_CPT_HINGED     = 4	/* Backwards compatibility with 6.0 API */
598 };
599 
600 /* Here is the definition of the GMT_PALETTE structure that is used in programs
601  * that deals with coloring of items as a function of z-lookup.  Note that rgb
602  * arrays have 4 items as the 4th value could be a non-zero transparency (when supported).
603  */
604 
605 struct GMT_LUT {
606 	double z_low, z_high, i_dz;
607 	double rgb_low[4], rgb_high[4], rgb_diff[4];
608 	double hsv_low[4], hsv_high[4], hsv_diff[4];
609 	unsigned int annot;	/* 1 for Lower, 2 for Upper, 3 for Both */
610 	unsigned int skip;	/* true means skip this slice */
611 	struct GMT_FILL *fill;	/* For patterns instead of color */
612 	char *label;		/* For non-number labels */
613 	char *key;		/* For non-number categories */
614 };
615 
616 struct GMT_BFN {		/* For back-, fore-, and nan-colors */
617 	double rgb[4];		/* Red, green, blue, and alpha */
618 	double hsv[4];		/* Hue, saturation, value, alpha */
619 	unsigned int skip;	/* true means skip this slice */
620 	struct GMT_FILL *fill;	/* For patterns instead of color */
621 };
622 
623 struct GMT_PALETTE {		/* Holds all pen, color, and fill-related parameters */
624 	/* Variables we document for the API: */
625 	struct GMT_LUT *data;		/* CPT lookup table read by gmtlib_read_cpt */
626 	struct GMT_BFN bfn[3];		/* Structures with back/fore/nan colors */
627 	unsigned int n_headers;		/* Number of CPT header records (0 if no header) */
628 	unsigned int n_colors;		/* Number of colors in CPT lookup table */
629 	unsigned int mode;		/* Flags controlling use of BFN colors */
630 	unsigned int model;		/* RGB, HSV, CMYK */
631 	unsigned int is_wrapping;	/* If 1 then we must wrap around to find color - can never be F or B */
632 	unsigned int is_gray;		/* 1 if only grayshades are needed */
633 	unsigned int is_bw;		/* 1 if only black and white are needed */
634 	unsigned int is_continuous;	/* 1 if continuous color tables have been given */
635 	unsigned int has_pattern;	/* 1 if CPT contains any patterns */
636 	unsigned int has_hinge;		/* 1 if CPT is hinged at hinge (below) */
637 	unsigned int has_range;		/* 1 if CPT has a natural range (minmax below) */
638 	unsigned int categorical;	/* 1 if CPT applies to categorical data, and 2 if key is a string */
639 	double minmax[2];		/* Min/max z-value for a default range, if given */
640 	double hinge;			/* z-value for hinged CPTs */
641 	double wrap_length;		/* z-length of active CPT */
642 	char **header;			/* Array with all CPT header records, if any) */		/* Content not counted by sizeof (struct) */
643 	void *hidden;			/* Book-keeping variables "hidden" from the API */
644 };
645 
646 /*============================================================ */
647 /*=============== GMT_IMAGE Public Declaration =============== */
648 /*============================================================ */
649 
650 /* The GMT_IMAGE container is used to pass user images in from the GDAL bridge */
651 
652 struct GMT_IMAGE {	/* Single container for a user image of data */
653 	/* Variables we document for the API: */
654 	enum GMT_enum_type type;        /* Data type, e.g. GMT_FLOAT */
655 	int *colormap;                  /* Array with color lookup values */
656 	int n_indexed_colors;           /* Number of colors in a paletted image */
657 	struct GMT_GRID_HEADER *header; /* Pointer to full GMT header for the image */
658 	unsigned char *data;            /* Pointer to actual image */
659 	unsigned char *alpha;           /* Pointer to an optional transparency layer stored in a separate variable */
660 	const char *color_interp;
661 	double *x, *y;                  /* Vector of coordinates */
662 	void *hidden;			/* Book-keeping variables "hidden" from the API */
663 };
664 
665 /*==================================================================== */
666 /*================= GMT_POSTSCRIPT Public Declaration ================ */
667 /*==================================================================== */
668 
669 /* The GMT_POSTSCRIPT container is used to pass PostScript objects */
670 
671 enum GMT_enum_ps {
672 	GMT_PS_EMPTY    = 0,
673 	GMT_PS_HEADER   = 1,
674 	GMT_PS_TRAILER  = 2,
675 	GMT_PS_COMPLETE = 3
676 };
677 
678 struct GMT_POSTSCRIPT {	/* Single container for a chunk of PostScript */
679 	/* Variables we document for the API: */
680 	size_t n_bytes;             /* Length of data array */
681 	unsigned int mode;          /* GMT_PS_HEADER = Has header, GMT_PS_TRAILER = Has trailer, GMT_PS_COMPLETE = Has both */
682 	unsigned int n_headers;     /* Number of PS header records (0 if no header) */
683 	char *data;		    /* Pointer to actual PS text */
684 	char **header;		    /* Array with all PS header records, if any) */		/* Content not counted by sizeof (struct) */
685 	void *hidden;		/* Book-keeping variables "hidden" from the API */
686 };
687 
688 /*============================================================ */
689 /*============= GMT_UNIVECTOR Public Declaration ============= */
690 /*============================================================ */
691 
692 /* This union is used to hold any type of array */
693 union GMT_UNIVECTOR {
694 	/* Universal vector of any data type can be held here */
695 	uint8_t  *uc1; /* Unsigned 1-byte int */
696 	int8_t   *sc1; /* Signed 1-byte int */
697 	uint16_t *ui2; /* Unsigned 2-byte int */
698 	int16_t  *si2; /* Signed 2-byte int */
699 	uint32_t *ui4; /* Unsigned 4-byte int */
700 	int32_t  *si4; /* Signed 4-byte int */
701 	uint64_t *ui8; /* Unsigned 8-byte int */
702 	int64_t  *si8; /* Signed 8-byte int */
703 	float    *f4;  /* 4-byte float */
704 	double   *f8;  /* 8-byte float */
705 };
706 
707 /*============================================================ */
708 /*=============== GMT_VECTOR Public Declaration ============== */
709 /*============================================================ */
710 
711 struct GMT_VECTOR {	/* Single container for user vector(s) of data */
712 	/* Variables we document for the API: */
713 	uint64_t n_columns;		/* Number of vectors */
714 	uint64_t n_rows;		/* Number of rows in each vector */
715 	unsigned int n_headers;		/* Number of CPT header records (0 if no header) */
716 	enum GMT_enum_reg registration;	/* 0 for gridline and 1 for pixel registration  */
717 	enum GMT_enum_type *type;	/* Array of data types (type of each uni-vector, e.g. GMT_FLOAT */
718 	double range[2];		/* Contains tmin/tmax (or 0/0 if not equidistant) */
719 	union GMT_UNIVECTOR *data;	/* Array of uni-vectors */
720 	char **text;			/* Pointer to optional array of strings [NULL] */
721 	char command[GMT_GRID_COMMAND_LEN320]; /* name of generating command */
722 	char remark[GMT_GRID_REMARK_LEN160];   /* comments re this data set */
723 	char **header;		        /* Array with all Vector header records, if any) */		/* Content not counted by sizeof (struct) */
724 	char *ProjRefPROJ4;             /* To store a referencing system string in PROJ.4 format */
725 	char *ProjRefWKT;               /* To store a referencing system string in WKT format */
726 	int ProjRefEPSG;                /* To store a referencing system EPSG code */
727 	void *hidden;			/* Book-keeping variables "hidden" from the API */
728 };
729 
730 /*============================================================ */
731 /*=============== GMT_MATRIX Public Declaration ============== */
732 /*============================================================ */
733 
734 enum GMT_enum_fmt {
735 	GMT_IS_ROW_FORMAT	= 1,	/* 2-D grid is C-style with rows: as index increase we move across rows */
736 	GMT_IS_COL_FORMAT	= 2	/* 2-D grid is Fortran-style with columns: as index increase we move down columns  */
737 };
738 
739 /* These containers are used to pass user vectors and matrices in/out of GMT */
740 
741 struct GMT_MATRIX {	/* Single container for a user matrix of data */
742 	/* Variables we document for the API: */
743 	uint64_t n_rows;		/* Number of rows in this matrix */
744 	uint64_t n_columns;		/* Number of columns in this matrix */
745 	uint64_t n_layers;		/* Number of layers in a 3-D matrix [1] */
746 	unsigned int n_headers;		/* Number of CPT header records (0 if no header) */
747 	enum GMT_enum_fmt shape;	/* 0 = C (rows) and 1 = Fortran (cols) */
748 	enum GMT_enum_reg registration;	/* 0 for gridline and 1 for pixel registration  */
749 	size_t dim;			/* Allocated length of longest C or Fortran dim */
750 	size_t size;			/* Byte length of data */
751 	enum GMT_enum_type type;	/* Data type, e.g. GMT_FLOAT */
752 	double range[6];		/* Contains xmin/xmax/ymin/ymax[/zmin/zmax] */
753 	double inc[3];			/* Contains xinc/yinc[/zinc] */
754 	union GMT_UNIVECTOR data;	/* Union with pointer to actual matrix of the chosen type */
755 	char **text;			/* Pointer to optional array of strings [NULL] */
756 	char command[GMT_GRID_COMMAND_LEN320]; /* name of generating command */
757 	char remark[GMT_GRID_REMARK_LEN160];   /* comments re this data set */
758 	char **header;		        /* Array with all Matrix header records, if any) */		/* Content not counted by sizeof (struct) */
759 	char *ProjRefPROJ4;             /* To store a referencing system string in PROJ.4 format */
760 	char *ProjRefWKT;               /* To store a referencing system string in WKT format */
761 	int ProjRefEPSG;                /* To store a referencing system EPSG code */
762 	void *hidden;			/* Book-keeping variables "hidden" from the API */
763 };
764 
765 /*============================================================ */
766 /*============== GMT_CUBE Public Declaration ============= */
767 /*==============        EXPERIMENTAL!!!!         ============= */
768 /*============================================================ */
769 
770 /* These containers are used to pass user cubes in/out of GMT */
771 
772 struct GMT_CUBE {
773 	/* Handling of 3-D data cubes in GMT requires a common 2-D header and extended parameters for the 3rd dimension */
774 	/* These are the same as for GMT_GRID: */
775 	struct GMT_GRID_HEADER *header;		/* Pointer to full GMT 2-D header for a layer (common to all layers) */
776 	gmt_grdfloat *data;             	/* Pointer to the gmt_grdfloat 3-D cube - a stack of 2-D padded grids */
777 	double *x, *y;                  	/* Vector of plane coordinates common to all layers */
778 	void *hidden;                   	/* Row-by-row machinery information [NULL] */
779 	/* These are extensions for 3D cubes. Note: We use header->n_bands for the number of layers for 3-D cubes  */
780 	unsigned int mode;			/* GMT_CUBE_IS_STACK if input dataset was a list of 2-D grids rather than a single cube */
781 	double z_range[2];			/* Minimum/max z values (complements header->wesn[4]) */
782 	double z_inc;				/* z increment (complements inc[2]) (0 if variable z spacing */
783 	double *z;					/* Array of z values (complements x, y) */
784 	char name[GMT_GRID_VARNAME_LEN80];	/* Name of the 3-D variable, if read from file (or empty if just one) */
785 	char units[GMT_GRID_UNIT_LEN80];	/* Units in 3rd direction (complements x_units, y_units, z_units)  */
786 };
787 
788 /*============================================================ */
789 /*=============== GMT_OPTION Public Declaration ============== */
790 /*============================================================ */
791 
792 enum GMT_enum_opt {
793 	GMT_OPT_USAGE =     '?',	/* Command-line option for full usage */
794 	GMT_OPT_SYNOPSIS =  '^',	/* Command-line option for synopsis */
795 	GMT_OPT_PARAMETER = '-',	/* Command-line option for GMT defaults parameter */
796 	GMT_OPT_INFILE =    '<',	/* Command-line option for input file */
797 	GMT_OPT_OUTFILE =   '>'		/* Command-line option for output file */
798 };
799 
800 /* This struct is used to pass program options in/out of GMT modules */
801 
802 struct GMT_OPTION {              /* Structure for a single GMT command option */
803 	char option;                 /* 1-char command line -<option> (e.g. D in -D) identifying the option (* if file) */
804 	char *arg;                   /* If not NULL, contains the argument for this option */
805 	struct GMT_OPTION *next;     /* Pointer to next option in a linked list */
806 	struct GMT_OPTION *previous; /* Pointer to previous option in a linked list */
807 };
808 
809 /*============================================================ */
810 /*  struct GMT_RESOURCE is for API Developers only   ========= */
811 /*============================================================ */
812 
813 struct GMT_RESOURCE {	/* Information related to passing resources between GMT and external APIs */
814 	enum GMT_enum_family family;	/* GMT data family, i.e., GMT_IS_DATASET, GMT_IS_GRID, etc. */
815 	enum GMT_enum_geometry geometry;/* One of the recognized GMT geometries */
816 	enum GMT_enum_std direction;	/* Either GMT_IN or GMT_OUT */
817 	struct GMT_OPTION *option;	/* Pointer to the corresponding module option */
818 	char name[GMT_VF_LEN];		/* Virtual file name for resource */
819 	int pos;			/* Corresponding index into external object in|out arrays */
820 	int mode;			/* Either primary (0) or secondary (1) resource */
821 	void *object;			/* Pointer to the actual GMT object */
822 };
823 
824 /*============================================================ */
825 /*  struct GMT_MODULEINFO is for supplement Developers only == */
826 /*============================================================ */
827 
828 /* Shared library structure: name (classic and modern), library, purpose, keys for each module */
829 struct GMT_MODULEINFO {
830 	const char *mname;            /* Program (modern) name */
831 	const char *cname;            /* Program (classic) name */
832 	const char *component;        /* Component (core, supplement, custom) */
833 	const char *purpose;          /* Program purpose */
834 	const char *keys;             /* Program option info for external APIs */
835 };
836 
837 #endif /* GMT_RESOURCES_H */
838