1 /*
2  *****************************************************************************
3  *
4  * MODULE:      Grass Include Files
5  * AUTHOR(S):   Original author unknown - probably CERL
6  *              Justin Hickey - Thailand - jhickey@hpcc.nectec.or.th
7  * PURPOSE:     This file contains definitions of variables and data types
8  *              for use with most, if not all, Grass programs. This file is
9  *              usually included in every Grass program.
10  * COPYRIGHT:   (C) 2000-2011 by the GRASS Development Team
11  *
12  *              This program is free software under the GNU General Public
13  *              License (>=v2). Read the file COPYING that comes with GRASS
14  *              for details.
15  *
16  *****************************************************************************/
17 
18 #ifndef GRASS_GIS_H
19 #define GRASS_GIS_H
20 
21 /*============================= Include Files ==============================*/
22 
23 /* System include files */
24 #include <stdio.h>
25 #include <stdarg.h>
26 #include <stdbool.h>
27 
28 
29 /* Grass and local include files */
30 #include <grass/config.h>
31 #include <grass/datetime.h>
32 #include <grass/version.h>
33 
34 /*=========================== Constants/Defines ============================*/
35 
36 #if !defined __GNUC__ || __GNUC__ < 2
37 #undef __attribute__
38 #define __attribute__(x)
39 #endif
40 
41 static const char *GRASS_copyright __attribute__ ((unused))
42     = "GRASS GNU GPL licensed Software";
43 
44 /* GRASS version, GRASS date, git short hash of last change in GRASS headers
45  * (and anything else in include)
46  */
47 #define GIS_H_VERSION GRASS_HEADERS_VERSION
48 /* git date of last change in GRASS headers
49  * (and anything else in include)
50  */
51 #define GIS_H_DATE    GRASS_HEADERS_DATE
52 
53 #define G_gisinit(pgm) G__gisinit(GIS_H_VERSION, (pgm))
54 #define G_no_gisinit() G__no_gisinit(GIS_H_VERSION)
55 
56 /* For boolean values and comparisons use the C99 type 'bool' with values 'true' */
57 /* and 'false' For historical reasons 'TRUE' and 'FALSE' are still valid.        */
58 #ifndef TRUE
59 #define TRUE true
60 #endif
61 
62 #ifndef FALSE
63 #define FALSE false
64 #endif
65 
66 #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
67 #define PRI_OFF_T	"lld"
68 #else
69 #define PRI_OFF_T	"ld"
70 #endif
71 
72 /*! \brief Cross-platform Newline Character */
73 #define NEWLINE     '\n'
74 #ifdef __MINGW32__
75 #  define HOST_NEWLINE "\r\n"
76 #else
77 #  define HOST_NEWLINE "\n"
78 #endif
79 
80 /*! \brief Generate warning if function return value is unused */
81 #if __GNUC__ && (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)
82 #   define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
83 #else
84 #   define WARN_UNUSED_RESULT
85 #endif
86 
87 /*!
88   \brief List of units
89 */
90 #define U_UNDEFINED    -1
91 #define U_UNKNOWN       0
92 #define U_ACRES		1
93 #define U_HECTARES	2
94 #define U_KILOMETERS	3
95 #define U_METERS	4
96 #define U_MILES		5
97 #define U_FEET		6
98 #define U_RADIANS	7
99 #define U_DEGREES	8
100 #define U_USFEET	9
101 /* Temporal units from the datetime library */
102 #define U_YEARS         DATETIME_YEAR
103 #define U_MONTHS        DATETIME_MONTH
104 #define U_DAYS          DATETIME_DAY
105 #define U_HOURS         DATETIME_HOUR
106 #define U_MINUTES       DATETIME_MINUTE
107 #define U_SECONDS       DATETIME_SECOND
108 
109 /*! \brief Projection code - XY coordinate system (unreferenced data) */
110 #define PROJECTION_XY     0
111 /*! \brief Projection code - UTM */
112 #define PROJECTION_UTM    1
113 /*! \brief Projection code - State Plane */
114 #define PROJECTION_SP     2
115 /*! \brief Projection code - Latitude-Longitude */
116 #define PROJECTION_LL     3
117 /*! \brief Projection code - other projection (other then noted above) */
118 #define PROJECTION_OTHER  99
119 
120 #define PROJECTION_FILE "PROJ_INFO"
121 #define UNIT_FILE       "PROJ_UNITS"
122 #define EPSG_FILE       "PROJ_EPSG"
123 #define WKT_FILE        "PROJ_WKT"
124 #define SRID_FILE       "PROJ_SRID"
125 
126 #ifdef __MINGW32__
127 #define CONFIG_DIR "GRASS7"
128 #else
129 #define CONFIG_DIR ".grass7"
130 #endif
131 
132 /* define PI and friends */
133 #undef M_PI
134 #define M_PI    3.14159265358979323846	/* pi */
135 
136 #undef M_PI_2
137 #define M_PI_2  1.57079632679489661923	/* pi/2 */
138 
139 #undef M_PI_4
140 #define M_PI_4  0.78539816339744830962	/* pi/4 */
141 
142 #undef M_R2D
143 #define M_R2D  57.295779513082320877    /* 180/pi */
144 
145 #undef M_D2R
146 #define M_D2R   0.017453292519943295769 /* pi/180 */
147 
148 /* epsilon (IEEE: 2.220446e-16) */
149 #define GRASS_EPSILON 1.0e-15
150 
151 /* Location of envariment variables */
152 #define G_VAR_GISRC    0
153 #define G_VAR_MAPSET   1
154 
155 /* Where to find/store variables */
156 #define G_GISRC_MODE_FILE     0	/* files */
157 #define G_GISRC_MODE_MEMORY   1	/* memory only */
158 
159 /* for G_parser() */
160 #define TYPE_INTEGER  1
161 #define TYPE_DOUBLE   2
162 #define TYPE_STRING   3
163 #define YES           1
164 #define NO            0
165 
166 /* File/directory name lengths */
167 #define GNAME_MAX 256
168 #define GMAPSET_MAX 256
169 
170 #define GPATH_MAX 4096
171 
172 /* Basename default separator */
173 #define GBASENAME_SEP "_"
174 
175 /* Macros for type size independent integers                    */
176 /* Use these for portability to ensure integers are truly 32bit */
177 /* and are handled in a uniform manner                          */
178 
179 /* Convert integer to 4 bytes - little endian */
180 #define serialize_int32_le(buf, x) do { \
181     (buf)[0] = ((x) >>  0) & 0xFF; \
182     (buf)[1] = ((x) >>  8) & 0xFF; \
183     (buf)[2] = ((x) >> 16) & 0xFF; \
184     (buf)[3] = ((x) >> 24) & 0xFF; \
185 } while(0)
186 
187 /* Convert 4 bytes to an integer - little endian */
188 #define deserialize_int32_le(buf) (((buf)[0] <<  0) | \
189                                    ((buf)[1] <<  8) | \
190                                    ((buf)[2] << 16) | \
191                                    ((buf)[3] << 24))
192 
193 /* Convert integer to 4 bytes - big endian */
194 #define serialize_int32_be(buf, x) do { \
195     (buf)[0] = ((x) >> 24) & 0xFF; \
196     (buf)[1] = ((x) >> 16) & 0xFF; \
197     (buf)[2] = ((x) >>  8) & 0xFF; \
198     (buf)[3] = ((x) >>  0) & 0xFF; \
199 } while(0)
200 
201 /* Convert 4 bytes to an integer - big endian */
202 #define deserialize_int32_be(buf) (((buf)[0] << 24) | \
203                                    ((buf)[1] << 16) | \
204                                    ((buf)[2] <<  8) | \
205                                    ((buf)[3] <<  0))
206 
207 /* Cross-platform Directory Separator Character and null device stuff */
208 #define GRASS_DIRSEP '/'
209 #ifdef __MINGW32__
210 #  define HOST_DIRSEP '\\'
211 #  define G_DEV_NULL "NUL:"
212 #else
213 #  define HOST_DIRSEP '/'
214 #  define G_DEV_NULL "/dev/null"
215 #endif
216 
217 /*!
218   \typedef STD_OPT
219   \brief Standard option identifiers (enum)
220 
221   Identifies of all recognized standard options.
222 
223   The term <em>old</em> in the descriptions means existing map which
224   is supposed to exist before the module is called.
225   On the other hand, the term <em>new</em> in the descriptions means
226   that the map is not supposed to exist and that module will create one.
227 
228   Used by the G_parser() system.
229 
230   IMPORTANT NOTE: when adding new item to STD_OPT you should also
231   update STD_OPT_STRINGS array in general/g.parser/standard_option.c.
232 
233 */
234 typedef enum
235 {
236     G_OPT_UNDEFINED,
237     G_OPT_DB_SQL,		/*!< SQL statements */
238     G_OPT_DB_WHERE,		/*!< SQL where conditions */
239     G_OPT_DB_TABLE,		/*!< table name */
240     G_OPT_DB_DRIVER,		/*!< driver name */
241     G_OPT_DB_DATABASE,		/*!< database name */
242     G_OPT_DB_SCHEMA,            /*!< database schema */
243     G_OPT_DB_COLUMN,		/*!< one attr column */
244     G_OPT_DB_COLUMNS,		/*!< one or more attr columns */
245     G_OPT_DB_KEYCOLUMN,         /*!< key column */
246 
247     G_OPT_I_GROUP,		/*!< old input imagery group */
248     G_OPT_I_SUBGROUP,		/*!< old input imagery subgroup */
249 
250     G_OPT_MEMORYMB,		/*!< Maximum memory to be used (in MB): cache size for raster rows */
251     G_OPT_R_INPUT,		/*!< old input raster map */
252     G_OPT_R_INPUTS,		/*!< old input raster maps */
253     G_OPT_R_OUTPUT,		/*!< new output raster map */
254     G_OPT_R_OUTPUTS,		/*!< new output raster maps */
255     G_OPT_R_MAP,		/*!< old input raster map */
256     G_OPT_R_MAPS,		/*!< old input rasters map */
257     G_OPT_R_BASE,		/*!< old input base raster map */
258     G_OPT_R_COVER,		/*!< old input cover raster map */
259     G_OPT_R_ELEV,		/*!< old input elevation raster map */
260     G_OPT_R_ELEVS,		/*!< old input elevation raster maps */
261     G_OPT_R_TYPE,               /*!< raster map type */
262     G_OPT_R_INTERP_TYPE,        /*!< interpolation type */
263     G_OPT_R_BASENAME_INPUT,     /*!< old input basename raster maps */
264     G_OPT_R_BASENAME_OUTPUT,    /*!< new output basename raster maps */
265 
266     G_OPT_R3_INPUT,		/*!< old input raster3d map */
267     G_OPT_R3_INPUTS,		/*!< old input raster3d maps */
268     G_OPT_R3_OUTPUT,		/*!< new output raster3d map */
269     G_OPT_R3_MAP,		/*!< old input raster3d map */
270     G_OPT_R3_MAPS,		/*!< old input raster3d maps */
271     G_OPT_R3_TYPE,              /*!< Type (FCELL or DCELL) of a new created raster3d map */
272     G_OPT_R3_PRECISION,         /*!< The precision of the new generated raster3d map */
273     G_OPT_R3_TILE_DIMENSION,    /*!< The tile dimension of a new generated raster3d map */
274     G_OPT_R3_COMPRESSION,       /*!< The kind of compression of a new created raster3d map */
275 
276     G_OPT_V_INPUT,		/*!< old input vector map */
277     G_OPT_V_INPUTS,		/*!< old input vector maps */
278     G_OPT_V_OUTPUT,		/*!< new output vector map */
279     G_OPT_V_MAP,		/*!< old input vector map */
280     G_OPT_V_MAPS,		/*!< old input vector maps */
281     G_OPT_V_TYPE,		/*!< primitive type */
282     G_OPT_V3_TYPE,		/*!< primitive type, 2D and 3D */
283     G_OPT_V_FIELD,		/*!< layer number (layers used to be called fields) */
284     G_OPT_V_FIELD_ALL,		/*!< layer number (layers used to be called fields) */
285     G_OPT_V_CAT,		/*!< one category */
286     G_OPT_V_CATS,		/*!< more categories */
287     G_OPT_V_ID, 		/*!< one feature id */
288     G_OPT_V_IDS,		/*!< more feature ids */
289 
290     G_OPT_F_INPUT,		/*!< old input file */
291     G_OPT_F_BIN_INPUT,		/*!< old binary input file */
292     G_OPT_F_OUTPUT,		/*!< new output file */
293     G_OPT_F_SEP,		/*!< data field separator */
294 
295     G_OPT_C,			/*!< color */
296     G_OPT_CN,			/*!< color or none */
297 
298     G_OPT_M_UNITS,              /*!< units */
299     G_OPT_M_DATATYPE,           /*!< datatype */
300     G_OPT_M_MAPSET,             /*!< mapset */
301     G_OPT_M_LOCATION,           /*!< location */
302     G_OPT_M_DBASE,              /*!< dbase */
303     G_OPT_M_COORDS,             /*!< coordinates */
304     G_OPT_M_COLR,               /*!< color rules */
305     G_OPT_M_DIR,                /*!< directory input */
306     G_OPT_M_REGION,             /*!< saved region */
307     G_OPT_M_NULL_VALUE,         /*!< null value string */
308     G_OPT_M_NPROCS,             /*!< number of threads for parallel computing */
309 
310     G_OPT_STDS_INPUT,           /*!< old input space time dataset of type strds, str3ds or stvds */
311     G_OPT_STDS_INPUTS,          /*!< old input space time datasets */
312     G_OPT_STDS_OUTPUT,          /*!< new output space time dataset */
313     G_OPT_STRDS_INPUT,          /*!< old input space time raster dataset */
314     G_OPT_STRDS_INPUTS,         /*!< old input space time raster datasets */
315     G_OPT_STRDS_OUTPUT,         /*!< new output space time raster dataset */
316     G_OPT_STRDS_OUTPUTS,        /*!< new output space time raster datasets */
317     G_OPT_STR3DS_INPUT,         /*!< old input space time raster3d dataset */
318     G_OPT_STR3DS_INPUTS,        /*!< old input space time raster3d datasets */
319     G_OPT_STR3DS_OUTPUT,        /*!< new output space time raster3d dataset */
320     G_OPT_STVDS_INPUT,          /*!< old input space time vector dataset */
321     G_OPT_STVDS_INPUTS,         /*!< old input space time vector datasets */
322     G_OPT_STVDS_OUTPUT,         /*!< new output space time vector dataset */
323     G_OPT_MAP_INPUT,            /*!< old input map of type raster, vector or raster3d  */
324     G_OPT_MAP_INPUTS,           /*!< old input maps of type raster, vector or raster3d  */
325     G_OPT_STDS_TYPE,            /*!< the type of a space time dataset: strds, str3ds, stvds */
326     G_OPT_MAP_TYPE,             /*!< The type of an input map: raster, vect, rast3d */
327     G_OPT_T_TYPE,               /*!< The temporal type of a space time dataset */
328     G_OPT_T_WHERE,              /*!< A temporal GIS framework SQL WHERE statement */
329     G_OPT_T_SAMPLE             /*!< Temporal sample methods */
330 
331 } STD_OPT;
332 
333 /*!
334   \typedef STD_FLG
335   \brief  Standard flag identifiers (enum)
336 
337   Identifies of all recognized standard flags.
338 
339   Used by the G_parser() system.
340 */
341 
342 /**/ typedef enum
343 {
344     G_FLG_UNDEFINED,
345     G_FLG_V_TABLE,		/*!< do not create attribute table */
346     G_FLG_V_TOPO               /*!< do not build topology */
347 } STD_FLG;
348 
349 /* Parser rules for G__option_rule() */
350 enum rule_type {
351     RULE_EXCLUSIVE,
352     RULE_REQUIRED,
353     RULE_REQUIRES,
354     RULE_REQUIRES_ALL,
355     RULE_EXCLUDES,
356     RULE_COLLECTIVE
357 };
358 
359 /* Message format */
360 #define G_INFO_FORMAT_STANDARD 0	/* GRASS_MESSAGE_FORMAT=standard or not defined */
361 #define G_INFO_FORMAT_GUI      1	/* GRASS_MESSAGE_FORMAT=gui */
362 #define G_INFO_FORMAT_SILENT   2	/* GRASS_MESSAGE_FORMAT=silent */
363 #define G_INFO_FORMAT_PLAIN    3	/* GRASS_MESSAGE_FORMAT=plain */
364 
365 /* Icon types */
366 #define G_ICON_CROSS  0
367 #define G_ICON_BOX    1
368 #define G_ICON_ARROW  2
369 
370 /* default colors */
371 #define DEFAULT_FG_COLOR "black"
372 #define DEFAULT_BG_COLOR "white"
373 #define DEFAULT_COLOR_TABLE "viridis"
374 
375 /* error codes */
376 #define G_FATAL_EXIT    0
377 #define G_FATAL_PRINT   1
378 #define G_FATAL_RETURN  2
379 
380 /*! \brief Endian check */
381 #define ENDIAN_LITTLE 0
382 #define ENDIAN_BIG    1
383 #define ENDIAN_OTHER  2
384 
385 /* for vector maps */
386 /*!
387   \brief Name of default key column
388 */
389 #define GV_KEY_COLUMN    "cat"
390 
391 /*!
392   \brief Element types identifiers (enum)
393 
394   Identifies various element types. Element can be raster map,
395   vector map, etc.
396 */
397 enum
398 {				/* Dir */
399     G_ELEMENT_RASTER = 1,	/*!< raster */
400     G_ELEMENT_RASTER3D = 2,	/*!< 3d raster */
401     G_ELEMENT_VECTOR = 3,	/*!< vector */
402     G_ELEMENT_ASCIIVECTOR = 4,	/*!< ASCII vector */
403     G_ELEMENT_LABEL = 5,	/*!< labels */
404     G_ELEMENT_REGION = 6,	/*!< region */
405     G_ELEMENT_GROUP = 7		/*!< group */
406 };
407 
408 /*=========================== Typedefs/Structures ==========================*/
409 
410 /*!
411   \brief 2D/3D raster map header (used also for region)
412 */
413 struct Cell_head
414 {
415     /*! \brief Max number of bytes per raster data value minus 1 (raster header only)
416 
417      Note: -1 for FP raster maps
418     */
419     int format;
420     /*! \brief Compression mode (raster header only)
421 
422       - 0: uncompressed
423       - 1: compressed
424       - -1: pre GRASS 3.0
425     */
426     int compressed;
427     /*! \brief Number of rows for 2D data */
428     int rows;
429     /*! \brief Number of rows for 3D data */
430     int rows3;
431     /*! \brief Number of columns for 2D data */
432     int cols;
433     /*! \brief Number of columns for 3D data */
434     int cols3;
435     /*! \brief number of depths for 3D data */
436     int depths;
437     /*! \brief Projection code
438 
439       - PROJECTION_XY
440       - PROJECTION_UTM
441       - PROJECTION_SP
442       - PROJECTION_LL
443       - PROJECTION_OTHER
444      */
445     int proj;
446     /*! \brief Projection zone (UTM) */
447     int zone;
448     /*! \brief Resolution - east to west cell size for 2D data */
449     double ew_res;
450     /*! \brief Resolution - east to west cell size for 3D data */
451     double ew_res3;
452     /*! \brief Resolution - north to south cell size for 2D data */
453     double ns_res;
454     /*! \brief Resolution - north to south cell size for 3D data */
455     double ns_res3;
456     /*! \brief Resolution - top to bottom cell size for 3D data */
457     double tb_res;
458     /*! \brief Extent coordinates (north) */
459     double north;
460     /*! \brief Extent coordinates (south) */
461     double south;
462     /*! \brief Extent coordinates (east) */
463     double east;
464     /*! \brief Extent coordinates (west) */
465     double west;
466     /*! \brief Extent coordinates (top) - 3D data*/
467     double top;
468     /*! \brief Extent coordinates (bottom) - 3D data */
469     double bottom;
470 };
471 
472 /*
473  ** Structure for I/O of 3dview files  (view.c)
474  */
475 struct G_3dview
476 {
477     char pgm_id[40];		/* user-provided identifier */
478     float from_to[2][3];	/* eye position & lookat position */
479     float fov;			/* field of view */
480     float twist;		/* right_hand rotation about from_to */
481     float exag;			/* terrain elevation exageration */
482     int mesh_freq;		/* cells per grid line */
483     int poly_freq;		/* cells per polygon */
484     int display_type;		/* 1 for mesh, 2 for poly, 3 for both */
485     int lightson;		/* boolean */
486     int dozero;			/* boolean */
487     int colorgrid;		/* boolean */
488     int shading;		/* boolean */
489     int fringe;			/* boolean */
490     int surfonly;		/* boolean */
491     int doavg;			/* boolean */
492     char grid_col[40];		/* colors */
493     char bg_col[40];		/* colors */
494     char other_col[40];		/* colors */
495     float lightpos[4];		/* east, north, height, 1.0 for local 0.0 infin */
496     float lightcol[3];		/* values between 0.0 to 1.0 for red, grn, blu */
497     float ambient;
498     float shine;
499     struct Cell_head vwin;
500 };
501 
502 struct Key_Value
503 {
504     int nitems;
505     int nalloc;
506     char **key;
507     char **value;
508 };
509 
510 /*!
511   \brief Structure that stores option information
512 
513   The descriptions member contains pairs of option and option
514   descriptions separated by semicolon ';'.
515   For example, when options member is set using:
516   \code
517   opt->options = "break,rmdupl"
518   \endcode
519   the descriptions member should be set to:
520   \verbatim
521   "break;break lines on intersections;"
522   "rmdupl;remove duplicates"
523   \endverbatim
524 
525   Parsed descriptions are stored in the same order as options.
526 
527   GUI dependency is a list of options (separated by commas) to be updated
528   if the value is changed.
529 
530   Used by the G_parser() system.
531 */
532 struct Option
533 {
534     const char *key;		/*!< Key word used on command line */
535     int type;			/*!< Option type */
536     int required;		/*!< REQUIRED or OPTIONAL */
537     int multiple;		/*!< Multiple entries OK */
538     const char *options;	/*!< Approved values or range or NULL */
539     const char **opts;		/*!< NULL or NULL terminated array of parsed options */
540     const char *key_desc;	/*!< one word describing the key */
541     const char *label;		/*!< Optional short label, used in GUI as item label */
542     const char *description;	/*!< String describing option */
543     const char *descriptions;	/*!< ';' separated pairs of option and option descriptions */
544     const char **descs;		/*!< parsed descriptions, array of either NULL or string */
545     char *answer;		/*!< Option answer */
546     const char *def;		/*!< Where original answer gets saved */
547     char **answers;		/*!< Option answers (for multiple=YES) */
548     struct Option *next_opt;	/*!< Pointer to next option struct */
549     const char *gisprompt;	/*!< Interactive prompt guidance */
550     const char *guisection;	/*!< GUI Layout guidance: ';' delimited hierarchical tree position */
551     const char *guidependency;  /*!< GUI dependency */
552     int (*checker)(const char *);/*!< Routine to check answer or NULL  */
553     int count;
554 };
555 
556 /*!
557   \brief Structure that stores flag info
558 
559   Used by the G_parser() system.
560 */
561 struct Flag
562 {
563     char key;			/*!< Key char used on command line */
564     char answer;		/*!< Stores flag state: 0/1 */
565     char suppress_required;	/*!< Suppresses checking of required options */
566     char suppress_overwrite;	/*!< Suppresses checking of existing output */
567     const char *label;		/*!< Optional short label, used in GUI as item label */
568     const char *description;	/*!< String describing flag meaning   */
569     const char *guisection;	/*!< GUI Layout guidance: ';' delimited hierarchical tree position */
570     struct Flag *next_flag;	/*!< Pointer to next flag struct */
571 };
572 
573 /*!
574   \brief Structure that stores module info
575 
576   Used by the G_parser() system.
577 */
578 struct GModule
579 {
580     const char *label;		/*!< Optional short description for GUI */
581     const char *description;	/*!< String describing module */
582     const char **keywords;	/*!< Keywords describing module */
583     /* further items are possible: author(s), version, year */
584     int overwrite;		/*!< overwrite old files */
585     int verbose;		/*!< print all information about progress and so on */
586 };
587 
588 struct TimeStamp
589 {
590     DateTime dt[2];		/* two datetimes */
591     int count;
592 };
593 
594 struct Counter {
595     int value;
596 };
597 
598 struct Popen {
599     FILE *fp;
600     int pid;
601 };
602 
603 typedef int CELL;
604 typedef double DCELL;
605 typedef float FCELL;
606 
607 /* 64 bit signed integer */
608 #if HAVE_INT64_T
609 #include <sys/types.h>
610 typedef int64_t grass_int64;
611 #elif defined(__MINGW32__)
612 typedef __int64 grass_int64;
613 #elif HAVE_LONG_LONG_INT
614 typedef long long int grass_int64;
615 #elif HAVE_LARGEFILES
616 typedef off_t grass_int64;
617 #else
618 #error "no 64 bit integer available"
619 #endif
620 
621 /* LCELL = large CELL, proposed new raster data type */
622 typedef grass_int64 LCELL;
623 
624 struct _Color_Value_
625 {
626     DCELL value;
627     unsigned char red;
628     unsigned char grn;
629     unsigned char blu;
630 };
631 
632 struct _Color_Rule_
633 {
634     struct _Color_Value_ low, high;
635     struct _Color_Rule_ *next;
636     struct _Color_Rule_ *prev;
637 };
638 
639 struct _Color_Info_
640 {
641     struct _Color_Rule_ *rules;
642     int n_rules;
643 
644     struct
645     {
646 	unsigned char *red;
647 	unsigned char *grn;
648 	unsigned char *blu;
649 	unsigned char *set;
650 	int nalloc;
651 	int active;
652     } lookup;
653 
654     struct
655     {
656 	DCELL *vals;
657 	/* pointers to color rules corresponding to the intervals btwn vals */
658 	struct _Color_Rule_ **rules;
659 	int nalloc;
660 	int active;
661     } fp_lookup;
662 
663     DCELL min, max;
664 };
665 
666 struct Colors
667 {
668     int version;		/* set by read_colors: -1=old,1=new */
669     DCELL shift;
670     int invert;
671     int is_float;		/* defined on floating point raster data? */
672     int null_set;		/* the colors for null are set? */
673     unsigned char null_red;
674     unsigned char null_grn;
675     unsigned char null_blu;
676     int undef_set;		/* the colors for cells not in range are set? */
677     unsigned char undef_red;
678     unsigned char undef_grn;
679     unsigned char undef_blu;
680     struct _Color_Info_ fixed;
681     struct _Color_Info_ modular;
682     DCELL cmin;
683     DCELL cmax;
684     int organizing;
685 };
686 
687 /*!
688   \brief List of integers
689 */
690 struct ilist
691 {
692     /*!
693       \brief Array of values
694     */
695     int *value;
696     /*!
697       \brief Number of values in the list
698     */
699     int n_values;
700     /*!
701       \brief Allocated space for values
702     */
703     int alloc_values;
704 };
705 
706 /*============================== Prototypes ================================*/
707 
708 /* Since there are so many prototypes for the gis library they are stored */
709 /* in the file gisdefs.h */
710 #include <grass/defs/gis.h>
711 
712 #endif /* GRASS_GIS_H */
713