00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef CPL_SERV_H_INCLUDED
00030 #define CPL_SERV_H_INCLUDED
00031
00032
00033
00034
00035
00036 #include "geo_config.h"
00037 #include <stdio.h>
00038
00039 #include <math.h>
00040
00041 #ifdef HAVE_STRING_H
00042 # include <string.h>
00043 #endif
00044 #if defined(HAVE_STRINGS_H) && !defined(HAVE_STRING_H)
00045 # include <strings.h>
00046 #endif
00047 #ifdef HAVE_STDLIB_H
00048 # include <stdlib.h>
00049 #endif
00050
00051
00052
00053
00054 #if !defined(CPL_DLL)
00055 # if defined(_WIN32) && defined(BUILD_AS_DLL)
00056 # define CPL_DLL __declspec(dllexport)
00057 # else
00058 # define CPL_DLL
00059 # endif
00060 #endif
00061
00062
00063
00064
00065 #ifdef __cplusplus
00066 # define CPL_C_START extern "C" {
00067 # define CPL_C_END }
00068 #else
00069 # define CPL_C_START
00070 # define CPL_C_END
00071 #endif
00072
00073 #ifndef NULL
00074 # define NULL 0
00075 #endif
00076
00077 #ifndef FALSE
00078 # define FALSE 0
00079 #endif
00080
00081 #ifndef TRUE
00082 # define TRUE 1
00083 #endif
00084
00085 #ifndef MAX
00086 # define MIN(a,b) ((a<b) ? a : b)
00087 # define MAX(a,b) ((a>b) ? a : b)
00088 #endif
00089
00090 #ifndef NULL
00091 #define NULL 0
00092 #endif
00093
00094 #ifndef ABS
00095 # define ABS(x) ((x<0) ? (-1*(x)) : x)
00096 #endif
00097
00098 #ifndef EQUAL
00099 #if defined(_WIN32) && !defined(__CYGWIN__)
00100 # define EQUALN(a,b,n) (strnicmp(a,b,n)==0)
00101 # define EQUAL(a,b) (stricmp(a,b)==0)
00102 #else
00103 # define EQUALN(a,b,n) (strncasecmp(a,b,n)==0)
00104 # define EQUAL(a,b) (strcasecmp(a,b)==0)
00105 #endif
00106 #endif
00107
00108
00109
00110
00111
00112 #define VSIFOpen fopen
00113 #define VSIFClose fclose
00114 #define VSIFEof feof
00115 #define VSIFPrintf fprintf
00116 #define VSIFPuts fputs
00117 #define VSIFPutc fputc
00118 #define VSIFGets fgets
00119 #define VSIRewind rewind
00120 #define VSIFSeek fseek
00121 #define VSIFTell ftell
00122 #define VSIFRead fread
00123
00124 #ifndef notdef
00125 #define VSICalloc(x,y) _GTIFcalloc(x*y)
00126 #define VSIMalloc _GTIFcalloc
00127 #define VSIFree _GTIFFree
00128 #define VSIRealloc _GTIFrealloc
00129 #else
00130 #define VSICalloc(x,y) (((char *) _GTIFcalloc(x*y+4)) + 4)
00131 #define VSIMalloc(x) (((char *) _GTIFcalloc((x)+4)) + 4)
00132 #define VSIFree(x) _GTIFFree(((char *) (x)) - 4)
00133 #define VSIRealloc(p,n) (((char *) _GTIFrealloc(((char *)p)-4,(n)+4)) + 4)
00134 #endif
00135
00136
00137
00138
00139
00140 CPL_C_START
00141
00142 #define CPLMalloc gtCPLMalloc
00143 #define CPLCalloc gtCPLCalloc
00144 #define CPLRealloc gtCPLRealloc
00145 #define CPLStrdup gtCPLStrdup
00146
00147 void CPL_DLL *CPLMalloc( int );
00148 void CPL_DLL *CPLCalloc( int, int );
00149 void CPL_DLL *CPLRealloc( void *, int );
00150 char CPL_DLL *CPLStrdup( const char * );
00151
00152 #define CPLFree(x) { if( x != NULL ) VSIFree(x); }
00153
00154
00155
00156
00157
00158 #define CPLReadLine gtCPLReadLine
00159
00160 const char CPL_DLL *CPLReadLine( FILE * );
00161
00162
00163
00164
00165
00166 typedef enum
00167 {
00168 CE_None = 0,
00169 CE_Log = 1,
00170 CE_Warning = 2,
00171 CE_Failure = 3,
00172 CE_Fatal = 4
00173 } CPLErr;
00174
00175 #define CPLError gtCPLError
00176 #define CPLErrorReset gtCPLErrorReset
00177 #define CPLGetLastErrorNo gtCPLGetLastErrorNo
00178 #define CPLGetLastErrorMsg gtCPLGetLastErrorMsg
00179 #define CPLSetErrorHandler gtCPLSetErrorHandler
00180 #define _CPLAssert gt_CPLAssert
00181
00182 void CPL_DLL CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...);
00183 void CPL_DLL CPLErrorReset();
00184 int CPL_DLL CPLGetLastErrorNo();
00185 const char CPL_DLL * CPLGetLastErrorMsg();
00186 void CPL_DLL CPLSetErrorHandler(void(*pfnErrorHandler)(CPLErr,int,
00187 const char *));
00188 void CPL_DLL _CPLAssert( const char *, const char *, int );
00189
00190 #ifdef DEBUG
00191 # define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
00192 #else
00193 # define CPLAssert(expr)
00194 #endif
00195
00196 CPL_C_END
00197
00198
00199
00200
00201
00202 #define CPLE_AppDefined 1
00203 #define CPLE_OutOfMemory 2
00204 #define CPLE_FileIO 3
00205 #define CPLE_OpenFailed 4
00206 #define CPLE_IllegalArg 5
00207 #define CPLE_NotSupported 6
00208 #define CPLE_AssertionFailed 7
00209 #define CPLE_NoWriteAccess 8
00210
00211
00212
00213
00214 CPL_C_START
00215
00216 #define CSLAddString gtCSLAddString
00217 #define CSLCount gtCSLCount
00218 #define CSLGetField gtCSLGetField
00219 #define CSLDestroy gtCSLDestroy
00220 #define CSLDuplicate gtCSLDuplicate
00221 #define CSLTokenizeString gtCSLTokenizeString
00222 #define CSLTokenizeStringComplex gtCSLTokenizeStringComplex
00223
00224 char CPL_DLL **CSLAddString(char **papszStrList, const char *pszNewString);
00225 int CPL_DLL CSLCount(char **papszStrList);
00226 const char CPL_DLL *CSLGetField( char **, int );
00227 void CPL_DLL CSLDestroy(char **papszStrList);
00228 char CPL_DLL **CSLDuplicate(char **papszStrList);
00229
00230 char CPL_DLL **CSLTokenizeString(const char *pszString );
00231 char CPL_DLL **CSLTokenizeStringComplex(const char *pszString,
00232 const char *pszDelimiter,
00233 int bHonourStrings, int bAllowEmptyTokens );
00234
00235
00236
00237
00238
00239 typedef enum {
00240 CC_ExactString,
00241 CC_ApproxString,
00242 CC_Integer
00243 } CSVCompareCriteria;
00244
00245 #define CSVFilename gtCSVFilename
00246 #define CSVReadParseLine gtCSVReadParseLine
00247 #define CSVScanLines gtCSVScanLines
00248 #define CSVScanFile gtCSVScanFile
00249 #define CSVScanFileByName gtCSVScanFileByName
00250 #define CSVGetFieldId gtCSVGetFieldId
00251 #define CSVDeaccess gtCSVDeaccess
00252 #define CSVGetField gtCSVGetField
00253 #define SetCSVFilenameHook gtSetCSVFilenameHook
00254 #define CSVGetFileFieldId gtCSVGetFileFieldId
00255
00256 const char CPL_DLL *CSVFilename( const char * );
00257
00258 char CPL_DLL **CSVReadParseLine( FILE * );
00259 char CPL_DLL **CSVScanLines( FILE *, int, const char *, CSVCompareCriteria );
00260 char CPL_DLL **CSVScanFile( const char *, int, const char *,
00261 CSVCompareCriteria );
00262 char CPL_DLL **CSVScanFileByName( const char *, const char *, const char *,
00263 CSVCompareCriteria );
00264 int CPL_DLL CSVGetFieldId( FILE *, const char * );
00265 int CPL_DLL CSVGetFileFieldId( const char *, const char * );
00266
00267 void CPL_DLL CSVDeaccess( const char * );
00268
00269 const char CPL_DLL *CSVGetField( const char *, const char *, const char *,
00270 CSVCompareCriteria, const char * );
00271
00272 void CPL_DLL SetCSVFilenameHook( const char *(*)(const char *) );
00273
00274 CPL_C_END
00275
00276 #endif