libgeotiff
cpl_serv.h
1 /******************************************************************************
2  * Copyright (c) 1998, Frank Warmerdam
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  ******************************************************************************
22  *
23  * cpl_serv.h
24  *
25  * This include file derived and simplified from the GDAL Common Portability
26  * Library.
27  */
28 
29 #ifndef CPL_SERV_H_INCLUDED
30 #define CPL_SERV_H_INCLUDED
31 
32 /* ==================================================================== */
33 /* Standard include files. */
34 /* ==================================================================== */
35 
36 #include "geo_config.h"
37 #include <stdio.h>
38 
39 #include <math.h>
40 
41 #ifdef HAVE_STRING_H
42 # include <string.h>
43 #endif
44 #if defined(HAVE_STRINGS_H) && !defined(HAVE_STRING_H)
45 # include <strings.h>
46 #endif
47 #ifdef HAVE_STDLIB_H
48 # include <stdlib.h>
49 #endif
50 
51 /**********************************************************************
52  * Do we want to build as a DLL on windows?
53  **********************************************************************/
54 #if !defined(CPL_DLL)
55 # if defined(_WIN32) && defined(BUILD_AS_DLL)
56 # define CPL_DLL __declspec(dllexport)
57 # else
58 # define CPL_DLL
59 # endif
60 #endif
61 
62 /* ==================================================================== */
63 /* Other standard services. */
64 /* ==================================================================== */
65 #ifdef __cplusplus
66 # define CPL_C_START extern "C" {
67 # define CPL_C_END }
68 #else
69 # define CPL_C_START
70 # define CPL_C_END
71 #endif
72 
73 #ifndef NULL
74 # define NULL 0
75 #endif
76 
77 #ifndef FALSE
78 # define FALSE 0
79 #endif
80 
81 #ifndef TRUE
82 # define TRUE 1
83 #endif
84 
85 #ifndef MAX
86 # define MIN(a,b) ((a<b) ? a : b)
87 # define MAX(a,b) ((a>b) ? a : b)
88 #endif
89 
90 #ifndef NULL
91 #define NULL 0
92 #endif
93 
94 #ifndef ABS
95 # define ABS(x) ((x<0) ? (-1*(x)) : x)
96 #endif
97 
98 #ifndef EQUAL
99 #if defined(_WIN32) && !defined(__CYGWIN__)
100 # define EQUALN(a,b,n) (strnicmp(a,b,n)==0)
101 # define EQUAL(a,b) (stricmp(a,b)==0)
102 #else
103 # define EQUALN(a,b,n) (strncasecmp(a,b,n)==0)
104 # define EQUAL(a,b) (strcasecmp(a,b)==0)
105 #endif
106 #endif
107 
108 /* ==================================================================== */
109 /* VSI Services (just map directly onto Standard C services. */
110 /* ==================================================================== */
111 
112 #define VSIFOpen fopen
113 #define VSIFClose fclose
114 #define VSIFEof feof
115 #define VSIFPrintf fprintf
116 #define VSIFPuts fputs
117 #define VSIFPutc fputc
118 #define VSIFGets fgets
119 #define VSIRewind rewind
120 #define VSIFSeek fseek
121 #define VSIFTell ftell
122 #define VSIFRead fread
123 
124 #ifndef notdef
125 #define VSICalloc(x,y) _GTIFcalloc(x*y)
126 #define VSIMalloc _GTIFcalloc
127 #define VSIFree _GTIFFree
128 #define VSIRealloc _GTIFrealloc
129 #else
130 #define VSICalloc(x,y) (((char *) _GTIFcalloc(x*y+4)) + 4)
131 #define VSIMalloc(x) (((char *) _GTIFcalloc((x)+4)) + 4)
132 #define VSIFree(x) _GTIFFree(((char *) (x)) - 4)
133 #define VSIRealloc(p,n) (((char *) _GTIFrealloc(((char *)p)-4,(n)+4)) + 4)
134 #endif
135 
136 /* -------------------------------------------------------------------- */
137 /* Safe malloc() API. Thin cover over VSI functions with fatal */
138 /* error reporting if memory allocation fails. */
139 /* -------------------------------------------------------------------- */
140 CPL_C_START
141 
142 #define CPLMalloc gtCPLMalloc
143 #define CPLCalloc gtCPLCalloc
144 #define CPLRealloc gtCPLRealloc
145 #define CPLStrdup gtCPLStrdup
146 
147 void CPL_DLL *CPLMalloc( int );
148 void CPL_DLL *CPLCalloc( int, int );
149 void CPL_DLL *CPLRealloc( void *, int );
150 char CPL_DLL *CPLStrdup( const char * );
151 
152 #define CPLFree(x) { if( x != NULL ) VSIFree(x); }
153 
154 /* -------------------------------------------------------------------- */
155 /* Read a line from a text file, and strip of CR/LF. */
156 /* -------------------------------------------------------------------- */
157 
158 #define CPLReadLine gtCPLReadLine
159 
160 const char CPL_DLL *CPLReadLine( FILE * );
161 
162 /*=====================================================================
163  Error handling functions (cpl_error.c)
164  =====================================================================*/
165 
166 typedef enum
167 {
168  CE_None = 0,
169  CE_Log = 1,
170  CE_Warning = 2,
171  CE_Failure = 3,
172  CE_Fatal = 4
173 } CPLErr;
174 
175 #define CPLError gtCPLError
176 #define CPLErrorReset gtCPLErrorReset
177 #define CPLGetLastErrorNo gtCPLGetLastErrorNo
178 #define CPLGetLastErrorMsg gtCPLGetLastErrorMsg
179 #define CPLSetErrorHandler gtCPLSetErrorHandler
180 #define _CPLAssert gt_CPLAssert
181 
182 void CPL_DLL CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...);
183 void CPL_DLL CPLErrorReset();
184 int CPL_DLL CPLGetLastErrorNo();
185 const char CPL_DLL * CPLGetLastErrorMsg();
186 void CPL_DLL CPLSetErrorHandler(void(*pfnErrorHandler)(CPLErr,int,
187  const char *));
188 void CPL_DLL _CPLAssert( const char *, const char *, int );
189 
190 #ifdef DEBUG
191 # define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
192 #else
193 # define CPLAssert(expr)
194 #endif
195 
196 CPL_C_END
197 
198 /* ==================================================================== */
199 /* Well known error codes. */
200 /* ==================================================================== */
201 
202 #define CPLE_AppDefined 1
203 #define CPLE_OutOfMemory 2
204 #define CPLE_FileIO 3
205 #define CPLE_OpenFailed 4
206 #define CPLE_IllegalArg 5
207 #define CPLE_NotSupported 6
208 #define CPLE_AssertionFailed 7
209 #define CPLE_NoWriteAccess 8
210 
211 /*=====================================================================
212  Stringlist functions (strlist.c)
213  =====================================================================*/
214 CPL_C_START
215 
216 #define CSLAddString gtCSLAddString
217 #define CSLCount gtCSLCount
218 #define CSLGetField gtCSLGetField
219 #define CSLDestroy gtCSLDestroy
220 #define CSLDuplicate gtCSLDuplicate
221 #define CSLTokenizeString gtCSLTokenizeString
222 #define CSLTokenizeStringComplex gtCSLTokenizeStringComplex
223 
224 char CPL_DLL **CSLAddString(char **papszStrList, const char *pszNewString);
225 int CPL_DLL CSLCount(char **papszStrList);
226 const char CPL_DLL *CSLGetField( char **, int );
227 void CPL_DLL CSLDestroy(char **papszStrList);
228 char CPL_DLL **CSLDuplicate(char **papszStrList);
229 
230 char CPL_DLL **CSLTokenizeString(const char *pszString );
231 char CPL_DLL **CSLTokenizeStringComplex(const char *pszString,
232  const char *pszDelimiter,
233  int bHonourStrings, int bAllowEmptyTokens );
234 
235 /* ==================================================================== */
236 /* .csv file related functions (from cpl_csv.c) */
237 /* ==================================================================== */
238 
239 typedef enum {
240  CC_ExactString,
241  CC_ApproxString,
242  CC_Integer
243 } CSVCompareCriteria;
244 
245 #define CSVFilename gtCSVFilename
246 #define CSVReadParseLine gtCSVReadParseLine
247 #define CSVScanLines gtCSVScanLines
248 #define CSVScanFile gtCSVScanFile
249 #define CSVScanFileByName gtCSVScanFileByName
250 #define CSVGetFieldId gtCSVGetFieldId
251 #define CSVDeaccess gtCSVDeaccess
252 #define CSVGetField gtCSVGetField
253 #define SetCSVFilenameHook gtSetCSVFilenameHook
254 #define CSVGetFileFieldId gtCSVGetFileFieldId
255 
256 const char CPL_DLL *CSVFilename( const char * );
257 
258 char CPL_DLL **CSVReadParseLine( FILE * );
259 char CPL_DLL **CSVScanLines( FILE *, int, const char *, CSVCompareCriteria );
260 char CPL_DLL **CSVScanFile( const char *, int, const char *,
261  CSVCompareCriteria );
262 char CPL_DLL **CSVScanFileByName( const char *, const char *, const char *,
263  CSVCompareCriteria );
264 int CPL_DLL CSVGetFieldId( FILE *, const char * );
265 int CPL_DLL CSVGetFileFieldId( const char *, const char * );
266 
267 void CPL_DLL CSVDeaccess( const char * );
268 
269 const char CPL_DLL *CSVGetField( const char *, const char *, const char *,
270  CSVCompareCriteria, const char * );
271 
272 void CPL_DLL SetCSVFilenameHook( const char *(*)(const char *) );
273 
274 CPL_C_END
275 
276 #endif /* ndef CPL_SERV_H_INCLUDED */
void CPL_DLL SetCSVFilenameHook(const char *(*CSVFileOverride)(const char *))
Definition: cpl_csv.c:1012

Generated for libgeotiff by doxygen 1.8.6