"Fossies" - the Fresh Open Source Software Archive

Member "libgeotiff-1.6.0/cpl_serv.h" (12 Apr 2019, 8608 Bytes) of package /linux/privat/libgeotiff-1.6.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "cpl_serv.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.5.1_vs_1.6.0.

    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(_WIN32)
   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(GTIF_DLL)
   55 #  if defined(_WIN32) && defined(BUILD_AS_DLL)
   56 #    define GTIF_DLL     __declspec(dllexport)
   57 #  else
   58 #    define GTIF_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 #   if     (_MSC_FULL_VER >= 15000000)
  101 #       define EQUALN(a,b,n)           (_strnicmp(a,b,n)==0)
  102 #       define EQUAL(a,b)              (_stricmp(a,b)==0)
  103 #   else
  104 #       define EQUALN(a,b,n)           (strnicmp(a,b,n)==0)
  105 #       define EQUAL(a,b)              (stricmp(a,b)==0)
  106 #   endif
  107 #else
  108 #  define EQUALN(a,b,n)           (strncasecmp(a,b,n)==0)
  109 #  define EQUAL(a,b)              (strcasecmp(a,b)==0)
  110 #endif
  111 #endif
  112 
  113 /* ==================================================================== */
  114 /*      VSI Services (just map directly onto Standard C services.       */
  115 /* ==================================================================== */
  116 
  117 #define VSIFOpen    fopen
  118 #define VSIFClose   fclose
  119 #define VSIFEof     feof
  120 #define VSIFPrintf  fprintf
  121 #define VSIFPuts    fputs
  122 #define VSIFPutc    fputc
  123 #define VSIFGets    fgets
  124 #define VSIRewind   rewind
  125 #define VSIFSeek        fseek
  126 #define VSIFTell        ftell
  127 #define VSIFRead        fread
  128 
  129 #ifndef notdef
  130 #define VSICalloc(x,y)  _GTIFcalloc((x)*(y))
  131 #define VSIMalloc   _GTIFcalloc
  132 #define VSIFree         _GTIFFree
  133 #define VSIRealloc      _GTIFrealloc
  134 #else
  135 #define VSICalloc(x,y)  (((char *) _GTIFcalloc((x)*(y)+4)) + 4)
  136 #define VSIMalloc(x)    (((char *) _GTIFcalloc((x)+4)) + 4)
  137 #define VSIFree(x)      _GTIFFree(((char *) (x)) - 4)
  138 #define VSIRealloc(p,n) (((char *) _GTIFrealloc(((char *)(p))-4,(n)+4)) + 4)
  139 #endif
  140 
  141 
  142 #if !defined(GTIFAtof) 
  143 #  define GTIFAtof atof 
  144 #endif 
  145 
  146 
  147 /* -------------------------------------------------------------------- */
  148 /*      Safe malloc() API.  Thin cover over VSI functions with fatal    */
  149 /*      error reporting if memory allocation fails.                     */
  150 /* -------------------------------------------------------------------- */
  151 CPL_C_START
  152 
  153 #define CPLMalloc  gtCPLMalloc
  154 #define CPLCalloc  gtCPLCalloc
  155 #define CPLRealloc gtCPLRealloc
  156 #define CPLStrdup  gtCPLStrdup
  157 
  158 void GTIF_DLL *CPLMalloc( int );
  159 void GTIF_DLL *CPLCalloc( int, int );
  160 void GTIF_DLL *CPLRealloc( void *, int );
  161 char GTIF_DLL *CPLStrdup( const char * );
  162 
  163 #define CPLFree(x)  { if( x != NULL ) VSIFree(x); }
  164 
  165 /* -------------------------------------------------------------------- */
  166 /*      Locale insensitive string to float conversion.                  */
  167 /* -------------------------------------------------------------------- */
  168 /*double GTIFAtof(const char *nptr); */
  169 double GTIFStrtod(const char *nptr, char **endptr);
  170 
  171 /* -------------------------------------------------------------------- */
  172 /*      Read a line from a text file, and strip of CR/LF.               */
  173 /* -------------------------------------------------------------------- */
  174 
  175 #define CPLReadLine gtCPLReadLine
  176 
  177 const char GTIF_DLL *CPLReadLine( FILE * );
  178 
  179 /*=====================================================================
  180                    Error handling functions (cpl_error.c)
  181  =====================================================================*/
  182 
  183 typedef enum
  184 {
  185     CE_None = 0,
  186     CE_Log = 1,
  187     CE_Warning = 2,
  188     CE_Failure = 3,
  189     CE_Fatal = 4
  190 } CPLErr;
  191 
  192 #define CPLError      gtCPLError
  193 #define CPLErrorReset gtCPLErrorReset
  194 #define CPLGetLastErrorNo gtCPLGetLastErrorNo
  195 #define CPLGetLastErrorMsg gtCPLGetLastErrorMsg
  196 #define CPLSetErrorHandler gtCPLSetErrorHandler
  197 #define _CPLAssert    gt_CPLAssert
  198 
  199 void GTIF_DLL CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...);
  200 void GTIF_DLL CPLErrorReset();
  201 int  GTIF_DLL CPLGetLastErrorNo();
  202 const char GTIF_DLL * CPLGetLastErrorMsg();
  203 void GTIF_DLL CPLSetErrorHandler(void(*pfnErrorHandler)(CPLErr,int,
  204                                                        const char *));
  205 void GTIF_DLL _CPLAssert( const char *, const char *, int );
  206 
  207 #ifdef DEBUG
  208 #  define CPLAssert(expr)  ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__))
  209 #else
  210 #  define CPLAssert(expr)
  211 #endif
  212 
  213 CPL_C_END
  214 
  215 /* ==================================================================== */
  216 /*      Well known error codes.                                         */
  217 /* ==================================================================== */
  218 
  219 #define CPLE_AppDefined         1
  220 #define CPLE_OutOfMemory        2
  221 #define CPLE_FileIO         3
  222 #define CPLE_OpenFailed         4
  223 #define CPLE_IllegalArg         5
  224 #define CPLE_NotSupported       6
  225 #define CPLE_AssertionFailed        7
  226 #define CPLE_NoWriteAccess      8
  227 
  228 /*=====================================================================
  229                    Stringlist functions (strlist.c)
  230  =====================================================================*/
  231 CPL_C_START
  232 
  233 #define CSLAddString gtCSLAddString
  234 #define CSLCount     gtCSLCount
  235 #define CSLGetField  gtCSLGetField
  236 #define CSLDestroy   gtCSLDestroy
  237 #define CSLDuplicate gtCSLDuplicate
  238 #define CSLTokenizeString gtCSLTokenizeString
  239 #define CSLTokenizeStringComplex gtCSLTokenizeStringComplex
  240 
  241 char GTIF_DLL   **CSLAddString(char **papszStrList, const char *pszNewString);
  242 int  GTIF_DLL   CSLCount(char **papszStrList);
  243 const char GTIF_DLL *CSLGetField( char **, int );
  244 void GTIF_DLL   CSLDestroy(char **papszStrList);
  245 char GTIF_DLL   **CSLDuplicate(char **papszStrList);
  246 
  247 char GTIF_DLL   **CSLTokenizeString(const char *pszString );
  248 char GTIF_DLL   **CSLTokenizeStringComplex(const char *pszString,
  249                                    const char *pszDelimiter,
  250                                    int bHonourStrings, int bAllowEmptyTokens );
  251 
  252 /*
  253  * The following functions were used up to libgeotiff 1.4.X series, but
  254  * are now no-operation, since there is no longer any CSV use in libgeotiff.
  255  */
  256 #define SetCSVFilenameHook gtSetCSVFilenameHook
  257 void GTIF_DLL SetCSVFilenameHook( const char *(*CSVFileOverride)(const char *) );
  258 
  259 
  260 CPL_C_END
  261 
  262 #endif /* ndef CPL_SERV_H_INCLUDED */