LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/avc - avc.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2024-11-21 22:18:42 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /**********************************************************************
       2             :  * $Id$
       3             :  *
       4             :  * Name:     avc.h
       5             :  * Project:  Arc/Info Vector coverage (AVC) BIN<->E00 conversion library
       6             :  * Language: ANSI C
       7             :  * Purpose:  Header file containing all definitions for the library.
       8             :  * Author:   Daniel Morissette, dmorissette@dmsolutions.ca
       9             :  *
      10             :  **********************************************************************
      11             :  * Copyright (c) 1999-2001, Daniel Morissette
      12             :  *
      13             :  * SPDX-License-Identifier: MIT
      14             :  **********************************************************************
      15             :  *
      16             :  * $Log: avc.h,v $
      17             :  * Revision 1.25  2008/07/23 20:51:38  dmorissette
      18             :  * Fixed GCC 4.1.x compile warnings related to use of char vs unsigned char
      19             :  * (GDAL/OGR ticket http://trac.osgeo.org/gdal/ticket/2495)
      20             :  *
      21             :  * Revision 1.24  2006/08/17 20:09:45  dmorissette
      22             :  * Update for 2.0.0 release
      23             :  *
      24             :  * Revision 1.23  2006/08/17 18:56:42  dmorissette
      25             :  * Support for reading standalone info tables (just tables, no coverage
      26             :  * data) by pointing AVCE00ReadOpen() to the info directory (bug 1549).
      27             :  *
      28             :  * Revision 1.22  2006/06/27 18:38:43  dmorissette
      29             :  * Cleaned up E00 reading (bug 1497, patch from James F.)
      30             :  *
      31             :  * Revision 1.21  2006/06/16 11:48:11  daniel
      32             :  * New functions to read E00 files directly as opposed to translating to
      33             :  * binary coverage. Used in the implementation of E00 read support in OGR.
      34             :  * Contributed by James E. Flemer. (bug 1497)
      35             :  *
      36             :  * Revision 1.20  2006/06/14 16:31:28  daniel
      37             :  * Added support for AVCCoverPC2 type (bug 1491)
      38             :  *
      39             :  * Revision 1.19  2005/06/03 03:49:58  daniel
      40             :  * Update email address, website url, and copyright dates
      41             :  *
      42             :  * Revision 1.18  2005/06/03 03:29:16  daniel
      43             :  * Ready for 1.3.0 release
      44             :  *
      45             :  * Revision 1.17  2004/02/11 05:49:44  daniel
      46             :  * Added support for deleted flag in arc.dir (bug 2332)
      47             :  *
      48             :  * Revision 1.16  2002/02/14 16:34:15  warmerda
      49             :  * fixed prototype name for AVCBinReadNextPrj
      50             :  *
      51             :  * Revision 1.15  2002/02/13 20:35:24  warmerda
      52             :  * added AVCBinReadObject
      53             :  *
      54             :  * Revision 1.14  2001/11/25 21:15:23  daniel
      55             :  * Added hack (AVC_MAP_TYPE40_TO_DOUBLE) to map type 40 fields bigger than 8
      56             :  * digits to double precision as we generate E00 output (bug599)
      57             :  *
      58             :  * Revision 1.13  2001/02/20 15:24:11  daniel
      59             :  * Updated AVC_VERSION="1.2.0 (2000-10-17)"
      60             :  *
      61             :  * Revision 1.12  2000/09/26 21:38:44  daniel
      62             :  * Updated AVC_VERSION
      63             :  *
      64             :  * Revision 1.11  2000/09/26 20:21:04  daniel
      65             :  * Added AVCCoverPC write
      66             :  *
      67             :  * Revision 1.10  2000/09/22 19:45:20  daniel
      68             :  * Switch to MIT-style license
      69             :  *
      70             :  * Revision 1.9  2000/05/29 15:31:30  daniel
      71             :  * Added Japanese DBCS support
      72             :  *
      73             :  * Revision 1.8  2000/01/10 02:56:01  daniel
      74             :  * Added read support for "weird" coverages
      75             :  *
      76             :  * Revision 1.7  1999/12/24 07:18:34  daniel
      77             :  * Added PC Arc/Info coverages support
      78             :  *
      79             :  * Revision 1.6  1999/08/23 18:15:56  daniel
      80             :  * Added AVCE00DeleteCoverage()
      81             :  *
      82             :  * Revision 1.5  1999/06/08 22:07:28  daniel
      83             :  * Added AVCReadWrite in AVCAccess type
      84             :  *
      85             :  * Revision 1.4  1999/05/17 16:16:41  daniel
      86             :  * Added RXP + TXT/TX6/TX7 write support
      87             :  *
      88             :  * Revision 1.3  1999/05/11 02:15:04  daniel
      89             :  * Added coverage write support
      90             :  *
      91             :  * Revision 1.2  1999/02/25 03:39:39  daniel
      92             :  * Added TXT, TX6/TX7, RXP and RPL support
      93             :  *
      94             :  * Revision 1.1  1999/01/29 16:29:24  daniel
      95             :  * Initial revision
      96             :  *
      97             :  **********************************************************************/
      98             : 
      99             : #ifndef AVC_H_INCLUDED_
     100             : #define AVC_H_INCLUDED_
     101             : 
     102             : #include "cpl_conv.h"
     103             : #include "cpl_string.h"
     104             : 
     105             : typedef struct DBFInfo *DBFHandle;
     106             : 
     107             : #include "avc_mbyte.h"
     108             : 
     109             : CPL_C_START
     110             : 
     111             : /*---------------------------------------------------------------------
     112             :  * Current version of the AVCE00 library... always useful!
     113             :  *--------------------------------------------------------------------*/
     114             : #define AVC_VERSION "2.0.0 (2006-08-17)"
     115             : 
     116             : /* Coverage precision
     117             :  */
     118             : #define AVC_DEFAULT_PREC 0
     119             : #define AVC_SINGLE_PREC 1
     120             : #define AVC_DOUBLE_PREC 2
     121             : 
     122             : /* AVC_FORMAT_DBF_FLOAT used as nPrecision value only for AVCPrintRealValue()
     123             :  */
     124             : #define AVC_FORMAT_DBF_FLOAT 42
     125             : 
     126             : /* Coverage file types
     127             :  */
     128             : typedef enum
     129             : {
     130             :     AVCFileUnknown = 0,
     131             :     AVCFileARC,
     132             :     AVCFilePAL,
     133             :     AVCFileCNT,
     134             :     AVCFileLAB,
     135             :     AVCFilePRJ,
     136             :     AVCFileTOL,
     137             :     AVCFileLOG,
     138             :     AVCFileTXT, /* TXT and TX6 share the same binary format */
     139             :     AVCFileTX6,
     140             :     AVCFileRXP,
     141             :     AVCFileRPL, /* RPL is a PAL for a region */
     142             :     AVCFileTABLE
     143             : } AVCFileType;
     144             : 
     145             : /* Read or Write access flag
     146             :  */
     147             : typedef enum
     148             : {
     149             :     AVCRead,
     150             :     AVCWrite,
     151             :     AVCReadWrite
     152             : } AVCAccess;
     153             : 
     154             : /* Coverage type: PC Arc/Info or Unix Arc/Info v7
     155             :  */
     156             : typedef enum
     157             : {
     158             :     AVCCoverTypeUnknown = 0,
     159             :     AVCCoverV7,
     160             :     AVCCoverPC,
     161             :     AVCCoverPC2,     /* Unknown version... hybrid between V7 and PC !!! */
     162             :     AVCCoverWeird,   /* Unknown version... hybrid between V7 and PC !!! */
     163             :     AVCCoverV7Tables /* Standalone tables, only an info directory     */
     164             : } AVCCoverType;
     165             : 
     166             : /* Enum for byte ordering
     167             :  */
     168             : typedef enum
     169             : {
     170             :     AVCBigEndian,   /* CPL_MSB, Motorola ordering */
     171             :     AVCLittleEndian /* CPL_LSB, Intel ordering */
     172             : } AVCByteOrder;
     173             : 
     174             : /* Macros to establish byte ordering for each coverage type
     175             :  * The rule until now: all coverage types use big endian (Motorola ordering)
     176             :  * except PC Arc/Info coverages variant 1 (AVCCoverPC).
     177             :  */
     178             : #define AVC_COVER_BYTE_ORDER(cover_type)                                       \
     179             :     (((cover_type) == AVCCoverPC) ? AVCLittleEndian : AVCBigEndian)
     180             : 
     181             : /*=====================================================================
     182             :                         Structures
     183             :  =====================================================================*/
     184             : 
     185             : /*---------------------------------------------------------------------
     186             :  * Structures defining various Arc/Info objects types.
     187             :  * These are shared by the Binary and the E00 functions.
     188             :  *--------------------------------------------------------------------*/
     189             : 
     190             : typedef struct AVCVertex_t
     191             : {
     192             :     double x; /* Even for single precision, we always         */
     193             :     double y; /* use doubles for the vertices in memory.      */
     194             : } AVCVertex;
     195             : 
     196             : /*---------------------------------------------------------------------
     197             :  * AVCArc: Information about an ARC
     198             :  *--------------------------------------------------------------------*/
     199             : typedef struct AVCArc_t
     200             : {
     201             :     GInt32 nArcId;
     202             :     GInt32 nUserId;
     203             :     GInt32 nFNode;
     204             :     GInt32 nTNode;
     205             :     GInt32 nLPoly;
     206             :     GInt32 nRPoly;
     207             :     GInt32 numVertices;
     208             :     AVCVertex *pasVertices;
     209             : } AVCArc;
     210             : 
     211             : /*---------------------------------------------------------------------
     212             :  * AVCPal: A PAL (Polygon Arc List) references all the arcs that
     213             :  *         constitute a polygon.
     214             :  *--------------------------------------------------------------------*/
     215             : typedef struct AVCPalArc_t
     216             : {
     217             :     GInt32 nArcId;
     218             :     GInt32 nFNode;
     219             :     GInt32 nAdjPoly;
     220             : } AVCPalArc;
     221             : 
     222             : typedef struct AVCPal_t
     223             : {
     224             :     GInt32 nPolyId;
     225             :     AVCVertex sMin;
     226             :     AVCVertex sMax;
     227             :     GInt32 numArcs;
     228             :     AVCPalArc *pasArcs;
     229             : } AVCPal;
     230             : 
     231             : /*---------------------------------------------------------------------
     232             :  * AVCCnt: Information about a CNT (polygon centroid)
     233             :  *--------------------------------------------------------------------*/
     234             : typedef struct AVCCnt_t
     235             : {
     236             :     GInt32 nPolyId;
     237             :     AVCVertex sCoord;
     238             :     GInt32 numLabels; /* 0 or 1 */
     239             :     GInt32 *panLabelIds;
     240             : } AVCCnt;
     241             : 
     242             : /*---------------------------------------------------------------------
     243             :  * AVCLab: Information about a LAB (polygon Label)
     244             :  *--------------------------------------------------------------------*/
     245             : typedef struct AVCLab_t
     246             : {
     247             :     GInt32 nValue;
     248             :     GInt32 nPolyId;
     249             :     AVCVertex sCoord1;
     250             :     AVCVertex sCoord2;
     251             :     AVCVertex sCoord3;
     252             : } AVCLab;
     253             : 
     254             : /*---------------------------------------------------------------------
     255             :  * AVCTol: Information about a TOL record (coverage tolerances)
     256             :  *--------------------------------------------------------------------*/
     257             : typedef struct AVCTol_t
     258             : {
     259             :     GInt32 nIndex;
     260             :     GInt32 nFlag;
     261             :     double dValue;
     262             : } AVCTol;
     263             : 
     264             : /*---------------------------------------------------------------------
     265             :  * AVCTxt: Information about a TXT/TX6/TX7 record (annotations)
     266             :  *--------------------------------------------------------------------*/
     267             : typedef struct AVCTxt_t
     268             : {
     269             :     GInt32 nTxtId;
     270             :     GInt32 nUserId;
     271             :     GInt32 nLevel;
     272             :     float f_1e2; /* Always (float)-1e+20, even for double precision! */
     273             :     GInt32 nSymbol;
     274             :     GInt32 numVerticesLine;
     275             :     GInt32 n28; /* Unknown value at byte 28 */
     276             :     GInt32 numChars;
     277             :     GInt32 numVerticesArrow;
     278             : 
     279             :     GInt16 anJust1[20];
     280             :     GInt16 anJust2[20];
     281             : 
     282             :     double dHeight;
     283             :     double dV2; /* ??? */
     284             :     double dV3; /* ??? */
     285             : 
     286             :     GByte *pszText; /* Needs to be unsigned char for DBCS */
     287             : 
     288             :     AVCVertex *pasVertices;
     289             : } AVCTxt;
     290             : 
     291             : /*---------------------------------------------------------------------
     292             :  * AVCRxp: Information about a RXP record (something related to regions...)
     293             :  *--------------------------------------------------------------------*/
     294             : typedef struct AVCRxp_t
     295             : {
     296             :     GInt32 n1;
     297             :     GInt32 n2;
     298             : } AVCRxp;
     299             : 
     300             : /*---------------------------------------------------------------------
     301             :  * AVCTableDef: Definition of an INFO table's structure.
     302             :  *               This info is read from several files:
     303             :  *                   info/arc.dir
     304             :  *                   info/arc####.dat
     305             :  *                   info/arc####.nit
     306             :  *
     307             :  *               And the data for the table itself is stored in a binary
     308             :  *               file in the coverage directory.
     309             :  *--------------------------------------------------------------------*/
     310             : 
     311             : typedef struct AVCFieldInfo_t
     312             : {
     313             :     char szName[17];
     314             :     GInt16 nSize;
     315             :     GInt16 v2;
     316             :     GInt16 nOffset;
     317             :     GInt16 v4;
     318             :     GInt16 v5;
     319             :     GInt16 nFmtWidth;
     320             :     GInt16 nFmtPrec;
     321             :     GInt16 nType1;
     322             :     GInt16 nType2;
     323             :     GInt16 v10;
     324             :     GInt16 v11;
     325             :     GInt16 v12;
     326             :     GInt16 v13;
     327             :     char szAltName[17];
     328             :     GInt16 nIndex; /* >0 if valid, or -1 if field is deleted */
     329             : } AVCFieldInfo;
     330             : 
     331             : #define AVC_FT_DATE 10
     332             : #define AVC_FT_CHAR 20
     333             : #define AVC_FT_FIXINT 30
     334             : #define AVC_FT_FIXNUM 40
     335             : #define AVC_FT_BININT 50
     336             : #define AVC_FT_BINFLOAT 60
     337             : 
     338             : typedef struct AVCTableDef_t
     339             : {
     340             :     /* Stuff read from the arc.dir file
     341             :      * (1 record, corresponding to this table, from the arc.dir file)
     342             :      */
     343             :     char szTableName[33];
     344             :     char szInfoFile[9];
     345             :     GInt16 numFields;
     346             :     GInt16 nRecSize;
     347             :     GInt32 numRecords;
     348             :     char szExternal[3];  /* "XX" or "  " */
     349             :     GInt16 bDeletedFlag; /* 1 if deleted, 0 if table is active */
     350             : 
     351             :     /* Data file path read from the arc####.dat file
     352             :      */
     353             :     char szDataFile[81];
     354             : 
     355             :     /* Field information read from the arc####.nit file
     356             :      */
     357             :     AVCFieldInfo *pasFieldDef;
     358             : } AVCTableDef;
     359             : 
     360             : typedef struct AVCField_t
     361             : {
     362             :     GInt16 nInt16;
     363             :     GInt32 nInt32;
     364             :     float fFloat;
     365             :     double dDouble;
     366             :     GByte *pszStr;
     367             : } AVCField;
     368             : 
     369             : /*---------------------------------------------------------------------
     370             :  * Stuff related to buffered reading of raw binary files
     371             :  *--------------------------------------------------------------------*/
     372             : 
     373             : #define AVCRAWBIN_READBUFSIZE 1024
     374             : 
     375             : typedef struct AVCRawBinFile_t
     376             : {
     377             :     VSILFILE *fp;
     378             :     char *pszFname;
     379             :     AVCAccess eAccess;
     380             :     AVCByteOrder eByteOrder;
     381             :     GByte abyBuf[AVCRAWBIN_READBUFSIZE];
     382             :     int nOffset;  /* Location of current buffer in the file */
     383             :     int nCurSize; /* Nbr of bytes currently loaded        */
     384             :     int nCurPos;  /* Next byte to read from abyBuf[]      */
     385             : 
     386             :     int nFileDataSize; /* File Size as stated in the header */
     387             :                        /* EOF=TRUE passed this point in file */
     388             :                        /* Set to -1 if not specified. */
     389             : 
     390             :     /* Handle on dataset's multibyte character encoding info. */
     391             :     AVCDBCSInfo *psDBCSInfo;
     392             : 
     393             : } AVCRawBinFile;
     394             : 
     395             : /*---------------------------------------------------------------------
     396             :  * Stuff related to reading and writing binary coverage files
     397             :  *--------------------------------------------------------------------*/
     398             : 
     399             : typedef struct AVCBinHeader_t
     400             : {
     401             :     GUInt32 nSignature;
     402             :     GInt32 nPrecision;  /* <0 for double prec., >0 for single prec. */
     403             :     GInt32 nRecordSize; /* nbr of 2 byte words, 0 for var. length   */
     404             :     GInt32 nLength;     /* Overall file length, in 2 byte words     */
     405             : } AVCBinHeader;
     406             : 
     407             : typedef struct AVCBinFile_t
     408             : {
     409             :     AVCRawBinFile *psRawBinFile;
     410             :     char *pszFilename;
     411             :     AVCRawBinFile *psIndexFile; /* Index file, Write mode only */
     412             : 
     413             :     DBFHandle hDBFFile; /* Used for AVCCoverPC/PC2 DBF TABLES only */
     414             :     int nCurDBFRecord;  /* 0-based record index in DBF file */
     415             : 
     416             :     AVCCoverType eCoverType;
     417             :     AVCFileType eFileType;
     418             :     int nPrecision; /* AVC_SINGLE/DOUBLE_PREC  */
     419             : 
     420             :     union
     421             :     {
     422             :         AVCTableDef *psTableDef;
     423             :     } hdr;
     424             : 
     425             :     /* cur.* : temp. storage used to read one record (ARC, PAL, ... or
     426             :      *         Table record) from the file.
     427             :      */
     428             :     union
     429             :     {
     430             :         AVCArc *psArc;
     431             :         AVCPal *psPal;
     432             :         AVCCnt *psCnt;
     433             :         AVCLab *psLab;
     434             :         AVCTol *psTol;
     435             :         AVCTxt *psTxt;
     436             :         AVCRxp *psRxp;
     437             :         AVCField *pasFields;
     438             :         char **papszPrj;
     439             :     } cur;
     440             : 
     441             : } AVCBinFile;
     442             : 
     443             : /*---------------------------------------------------------------------
     444             :  * Stuff related to the generation of E00
     445             :  *--------------------------------------------------------------------*/
     446             : 
     447             : /*---------------------------------------------------------------------
     448             :  *                        AVCE00GenInfo structure
     449             :  * This structure is used by the E00 generator functions to store
     450             :  * their buffer and their current state in case they need to be
     451             :  * called more than once for a given object type (i.e. ARC, PAL and IFO).
     452             :  *--------------------------------------------------------------------*/
     453             : 
     454             : typedef struct AVCE00GenInfo_t
     455             : {
     456             :     char *pszBuf;
     457             :     int nBufSize;
     458             : 
     459             :     int nPrecision; /* AVC_SINGLE/DOUBLE_PREC       */
     460             :     int iCurItem;
     461             :     int numItems;
     462             : } AVCE00GenInfo;
     463             : 
     464             : /*---------------------------------------------------------------------
     465             :  * Stuff related to the parsing of E00
     466             :  *--------------------------------------------------------------------*/
     467             : 
     468             : /*---------------------------------------------------------------------
     469             :  *                        AVCE00ParseInfo structure
     470             :  * This structure is used by the E00 parser functions to store
     471             :  * their buffer and their current state while parsing an object.
     472             :  *--------------------------------------------------------------------*/
     473             : 
     474             : struct AVCE00ParseInfo
     475             : {
     476             :     AVCFileType eFileType = AVCFileUnknown;
     477             :     int nPrecision = 0; /* AVC_SINGLE/DOUBLE_PREC       */
     478             :     int iCurItem = 0;
     479             :     int numItems = 0;
     480             :     int nStartLineNum = 0;
     481             :     int nCurLineNum = 0;
     482             : 
     483             :     int nCurObjectId = 0;
     484             :     GBool bForceEndOfSection = 0; /* For sections that don't have an */
     485             :                                   /* explicit end-of-section line.   */
     486             :     AVCFileType eSuperSectionType =
     487             :         AVCFileUnknown; /* For sections containing several files*/
     488             :     char *pszSectionHdrLine = nullptr; /* Used by supersection types      */
     489             : 
     490             :     struct
     491             :     {
     492             :         AVCTableDef *psTableDef = nullptr;
     493             :     } hdr;
     494             : 
     495             :     GBool bTableHdrComplete = 0; /* FALSE until table header is */
     496             :                                  /* finished parsing */
     497             :     int nTableE00RecLength = 0;
     498             : 
     499             :     /* cur.* : temp. storage used to store current object (ARC, PAL, ... or
     500             :      *         Table record) from the file.
     501             :      */
     502             :     union
     503             :     {
     504             :         AVCArc *psArc;
     505             :         AVCPal *psPal;
     506             :         AVCCnt *psCnt;
     507             :         AVCLab *psLab;
     508             :         AVCTol *psTol;
     509             :         AVCTxt *psTxt;
     510             :         AVCRxp *psRxp;
     511             :         AVCField *pasFields;
     512             :     } cur;
     513             : 
     514             :     CPLStringList aosPrj;
     515             : 
     516             :     char *pszBuf = nullptr; /* Buffer used only for TABLEs  */
     517             :     int nBufSize = 0;
     518             : 
     519          11 :     AVCE00ParseInfo()
     520          11 :     {
     521          11 :         cur.psArc = nullptr;
     522          11 :     }
     523             : };
     524             : 
     525             : /*---------------------------------------------------------------------
     526             :  * Stuff related to the transparent binary -> E00 conversion
     527             :  *--------------------------------------------------------------------*/
     528             : typedef struct AVCE00Section_t
     529             : {
     530             :     AVCFileType eType; /* File Type                      */
     531             :     char *pszName;     /* E00 section or Table Name      */
     532             :     char *pszFilename; /* Binary/E00 file filename       */
     533             :     int nLineNum;      /* E00 line number                */
     534             :     int nFeatureCount;
     535             : } AVCE00Section;
     536             : 
     537             : typedef struct AVCE00ReadInfo_t
     538             : {
     539             :     char *pszCoverPath;
     540             :     char *pszInfoPath;
     541             :     char *pszCoverName;
     542             :     AVCCoverType eCoverType;
     543             : 
     544             :     /* pasSections is built when the coverage is opened and describes
     545             :      * the skeleton of the E00 file.
     546             :      */
     547             :     AVCE00Section *pasSections;
     548             :     int numSections;
     549             : 
     550             :     /* If bReadAllSections=TRUE then reading automatically continues to
     551             :      * the next section when a section finishes. (This is the default)
     552             :      * Otherwise, you can use AVCE00ReadGotoSection() to read one section
     553             :      * at a time... this will set bReadAllSections=FALSE.
     554             :      */
     555             :     GBool bReadAllSections;
     556             : 
     557             :     /* Info about the file (or E00 section) currently being processed
     558             :      */
     559             :     int iCurSection;
     560             :     AVCBinFile *hFile;
     561             : 
     562             :     int iCurStep; /* AVC_GEN_* values, see below */
     563             :     AVCE00GenInfo *hGenInfo;
     564             : 
     565             :     /* Info related to multibyte character encoding
     566             :      */
     567             :     AVCDBCSInfo *psDBCSInfo;
     568             : 
     569             : } *AVCE00ReadPtr;
     570             : 
     571             : typedef struct AVCE00ReadInfoE00_t
     572             : {
     573             :     char *pszCoverPath;
     574             :     char *pszCoverName;
     575             : 
     576             :     AVCE00ParseInfo *hParseInfo;
     577             :     AVCFileType eCurFileType;
     578             : 
     579             :     /* pasSections is built when the coverage is opened and describes
     580             :      * the sections in the E00 file.
     581             :      */
     582             :     AVCE00Section *pasSections;
     583             :     int numSections;
     584             : 
     585             :     /* If bReadAllSections=TRUE then reading automatically continues to
     586             :      * the next section when a section finishes. (This is the default)
     587             :      * Otherwise, you can use AVCE00ReadGotoSectionE00() to read one
     588             :      * section at a time.
     589             :      */
     590             :     GBool bReadAllSections;
     591             : 
     592             :     /* File handle of the E00 file currently being processed
     593             :      */
     594             :     VSILFILE *hFile;
     595             : 
     596             : } *AVCE00ReadE00Ptr;
     597             : 
     598             : /* E00 generation steps... tells the AVCE00Read*() functions which
     599             :  * parts of the given E00 file are currently being processed.
     600             :  */
     601             : #define AVC_GEN_NOTSTARTED 0
     602             : #define AVC_GEN_DATA 1
     603             : #define AVC_GEN_ENDSECTION 2
     604             : #define AVC_GEN_TABLEHEADER 3
     605             : #define AVC_GEN_TABLEDATA 4
     606             : 
     607             : /*---------------------------------------------------------------------
     608             :  * Stuff related to the transparent E00 -> binary conversion
     609             :  *--------------------------------------------------------------------*/
     610             : typedef struct AVCE00WriteInfo_t
     611             : {
     612             :     char *pszCoverPath;
     613             :     char *pszInfoPath;
     614             :     char *pszCoverName;
     615             :     AVCCoverType eCoverType;
     616             : 
     617             :     /* Info about the file (or E00 section) currently being processed
     618             :      */
     619             :     AVCFileType eCurFileType;
     620             :     AVCBinFile *hFile;
     621             : 
     622             :     /* Requested precision for the new coverage... may differ from the
     623             :      * precision of the E00 input lines.  (AVC_SINGLE_PREC or AVC_DOUBLE_PREC)
     624             :      */
     625             :     int nPrecision;
     626             : 
     627             :     AVCE00ParseInfo *hParseInfo;
     628             : 
     629             :     /* Info related to multibyte character encoding
     630             :      */
     631             :     AVCDBCSInfo *psDBCSInfo;
     632             : 
     633             : } *AVCE00WritePtr;
     634             : 
     635             : /* Coverage generation steps... used to store the current state of the
     636             :  * AVCE00WriteNextLine() function.
     637             :  */
     638             : #define AVC_WR_TOPLEVEL 0
     639             : #define AVC_WR_READING_SECTION
     640             : 
     641             : /*=====================================================================
     642             :               Function prototypes (lower-level lib. functions)
     643             :  =====================================================================*/
     644             : 
     645             : /*---------------------------------------------------------------------
     646             :  * Functions related to buffered reading of raw binary files (and writing)
     647             :  *--------------------------------------------------------------------*/
     648             : AVCRawBinFile *AVCRawBinOpen(const char *pszFname, const char *pszAccess,
     649             :                              AVCByteOrder eFileByteOrder,
     650             :                              AVCDBCSInfo *psDBCSInfo);
     651             : void AVCRawBinClose(AVCRawBinFile *psInfo);
     652             : void AVCRawBinFSeek(AVCRawBinFile *psInfo, int nOffset, int nFrom);
     653             : GBool AVCRawBinEOF(AVCRawBinFile *psInfo);
     654             : void AVCRawBinSetFileDataSize(AVCRawBinFile *psInfo, int nDataSize);
     655             : int AVCRawBinIsFileGreaterThan(AVCRawBinFile *psFile, vsi_l_offset nSize);
     656             : 
     657             : void AVCRawBinReadBytes(AVCRawBinFile *psInfo, int nBytesToRead, GByte *pBuf);
     658             : GInt16 AVCRawBinReadInt16(AVCRawBinFile *psInfo);
     659             : GInt32 AVCRawBinReadInt32(AVCRawBinFile *psInfo);
     660             : float AVCRawBinReadFloat(AVCRawBinFile *psInfo);
     661             : double AVCRawBinReadDouble(AVCRawBinFile *psInfo);
     662             : void AVCRawBinReadString(AVCRawBinFile *psFile, int nBytesToRead, GByte *pBuf);
     663             : 
     664             : void AVCRawBinWriteBytes(AVCRawBinFile *psFile, int nBytesToWrite,
     665             :                          const GByte *pBuf);
     666             : void AVCRawBinWriteInt16(AVCRawBinFile *psFile, GInt16 n16Value);
     667             : void AVCRawBinWriteInt32(AVCRawBinFile *psFile, GInt32 n32Value);
     668             : void AVCRawBinWriteFloat(AVCRawBinFile *psFile, float fValue);
     669             : void AVCRawBinWriteDouble(AVCRawBinFile *psFile, double dValue);
     670             : void AVCRawBinWriteZeros(AVCRawBinFile *psFile, int nBytesToWrite);
     671             : void AVCRawBinWritePaddedString(AVCRawBinFile *psFile, int nFieldSize,
     672             :                                 const GByte *pszString);
     673             : 
     674             : /*---------------------------------------------------------------------
     675             :  * Functions related to reading the binary coverage files
     676             :  *--------------------------------------------------------------------*/
     677             : 
     678             : AVCBinFile *AVCBinReadOpen(const char *pszPath, const char *pszName,
     679             :                            AVCCoverType eCoverType, AVCFileType eType,
     680             :                            AVCDBCSInfo *psDBCSInfo);
     681             : void AVCBinReadClose(AVCBinFile *psFile);
     682             : 
     683             : int AVCBinReadRewind(AVCBinFile *psFile);
     684             : 
     685             : void *AVCBinReadObject(AVCBinFile *psFile, int iObjIndex);
     686             : void *AVCBinReadNextObject(AVCBinFile *psFile);
     687             : AVCArc *AVCBinReadNextArc(AVCBinFile *psFile);
     688             : AVCPal *AVCBinReadNextPal(AVCBinFile *psFile);
     689             : AVCCnt *AVCBinReadNextCnt(AVCBinFile *psFile);
     690             : AVCLab *AVCBinReadNextLab(AVCBinFile *psFile);
     691             : AVCTol *AVCBinReadNextTol(AVCBinFile *psFile);
     692             : AVCTxt *AVCBinReadNextTxt(AVCBinFile *psFile);
     693             : AVCRxp *AVCBinReadNextRxp(AVCBinFile *psFile);
     694             : AVCField *AVCBinReadNextTableRec(AVCBinFile *psFile);
     695             : char **AVCBinReadNextPrj(AVCBinFile *psFile);
     696             : 
     697             : char **AVCBinReadListTables(const char *pszInfoPath, const char *pszCoverName,
     698             :                             char ***ppapszArcDatFiles, AVCCoverType eCoverType,
     699             :                             AVCDBCSInfo *psDBCSInfo);
     700             : 
     701             : /*---------------------------------------------------------------------
     702             :  * Functions related to writing the binary coverage files
     703             :  *--------------------------------------------------------------------*/
     704             : AVCBinFile *AVCBinWriteCreate(const char *pszPath, const char *pszName,
     705             :                               AVCCoverType eCoverType, AVCFileType eType,
     706             :                               int nPrecision, AVCDBCSInfo *psDBCSInfo);
     707             : AVCBinFile *AVCBinWriteCreateTable(const char *pszInfoPath,
     708             :                                    const char *pszCoverName,
     709             :                                    AVCTableDef *psSrcTableDef,
     710             :                                    AVCCoverType eCoverType, int nPrecision,
     711             :                                    AVCDBCSInfo *psDBCSInfo);
     712             : void AVCBinWriteClose(AVCBinFile *psFile);
     713             : 
     714             : int AVCBinWriteHeader(AVCBinFile *psFile);
     715             : int AVCBinWriteObject(AVCBinFile *psFile, void *psObj);
     716             : int AVCBinWriteArc(AVCBinFile *psFile, AVCArc *psArc);
     717             : int AVCBinWritePal(AVCBinFile *psFile, AVCPal *psPal);
     718             : int AVCBinWriteCnt(AVCBinFile *psFile, AVCCnt *psCnt);
     719             : int AVCBinWriteLab(AVCBinFile *psFile, AVCLab *psLab);
     720             : int AVCBinWriteTol(AVCBinFile *psFile, AVCTol *psTol);
     721             : int AVCBinWritePrj(AVCBinFile *psFile, char **papszPrj);
     722             : int AVCBinWriteTxt(AVCBinFile *psFile, AVCTxt *psTxt);
     723             : int AVCBinWriteRxp(AVCBinFile *psFile, AVCRxp *psRxp);
     724             : int AVCBinWriteTableRec(AVCBinFile *psFile, AVCField *pasFields);
     725             : 
     726             : /*---------------------------------------------------------------------
     727             :  * Functions related to the generation of E00
     728             :  *--------------------------------------------------------------------*/
     729             : AVCE00GenInfo *AVCE00GenInfoAlloc(int nCoverPrecision);
     730             : void AVCE00GenInfoFree(AVCE00GenInfo *psInfo);
     731             : void AVCE00GenReset(AVCE00GenInfo *psInfo);
     732             : 
     733             : const char *AVCE00GenStartSection(AVCE00GenInfo *psInfo, AVCFileType eType,
     734             :                                   const char *pszFilename);
     735             : const char *AVCE00GenEndSection(AVCE00GenInfo *psInfo, AVCFileType eType,
     736             :                                 GBool bCont);
     737             : 
     738             : const char *AVCE00GenObject(AVCE00GenInfo *psInfo, AVCFileType eType,
     739             :                             void *psObj, GBool bCont);
     740             : const char *AVCE00GenArc(AVCE00GenInfo *psInfo, AVCArc *psArc, GBool bCont);
     741             : const char *AVCE00GenPal(AVCE00GenInfo *psInfo, AVCPal *psPal, GBool bCont);
     742             : const char *AVCE00GenCnt(AVCE00GenInfo *psInfo, AVCCnt *psCnt, GBool bCont);
     743             : const char *AVCE00GenLab(AVCE00GenInfo *psInfo, AVCLab *psLab, GBool bCont);
     744             : const char *AVCE00GenTol(AVCE00GenInfo *psInfo, AVCTol *psTol, GBool bCont);
     745             : const char *AVCE00GenTxt(AVCE00GenInfo *psInfo, AVCTxt *psTxt, GBool bCont);
     746             : const char *AVCE00GenTx6(AVCE00GenInfo *psInfo, AVCTxt *psTxt, GBool bCont);
     747             : const char *AVCE00GenPrj(AVCE00GenInfo *psInfo, char **papszPrj, GBool bCont);
     748             : const char *AVCE00GenRxp(AVCE00GenInfo *psInfo, AVCRxp *psRxp, GBool bCont);
     749             : 
     750             : const char *AVCE00GenTableHdr(AVCE00GenInfo *psInfo, AVCTableDef *psDef,
     751             :                               GBool bCont);
     752             : const char *AVCE00GenTableRec(AVCE00GenInfo *psInfo, int numFields,
     753             :                               AVCFieldInfo *pasDef, AVCField *pasFields,
     754             :                               GBool bCont);
     755             : 
     756             : /*---------------------------------------------------------------------
     757             :  * Functions related to parsing E00 lines
     758             :  *--------------------------------------------------------------------*/
     759             : AVCE00ParseInfo *AVCE00ParseInfoAlloc(void);
     760             : void AVCE00ParseInfoFree(AVCE00ParseInfo *psInfo);
     761             : void AVCE00ParseReset(AVCE00ParseInfo *psInfo);
     762             : 
     763             : AVCFileType AVCE00ParseSectionHeader(AVCE00ParseInfo *psInfo,
     764             :                                      const char *pszLine);
     765             : GBool AVCE00ParseSectionEnd(AVCE00ParseInfo *psInfo, const char *pszLine,
     766             :                             GBool bResetParseInfo);
     767             : AVCFileType AVCE00ParseSuperSectionHeader(AVCE00ParseInfo *psInfo,
     768             :                                           const char *pszLine);
     769             : GBool AVCE00ParseSuperSectionEnd(AVCE00ParseInfo *psInfo, const char *pszLine);
     770             : 
     771             : void *AVCE00ParseNextLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     772             : AVCArc *AVCE00ParseNextArcLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     773             : AVCPal *AVCE00ParseNextPalLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     774             : AVCCnt *AVCE00ParseNextCntLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     775             : AVCLab *AVCE00ParseNextLabLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     776             : AVCTol *AVCE00ParseNextTolLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     777             : AVCTxt *AVCE00ParseNextTxtLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     778             : AVCTxt *AVCE00ParseNextTx6Line(AVCE00ParseInfo *psInfo, const char *pszLine);
     779             : char **AVCE00ParseNextPrjLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     780             : AVCRxp *AVCE00ParseNextRxpLine(AVCE00ParseInfo *psInfo, const char *pszLine);
     781             : AVCTableDef *AVCE00ParseNextTableDefLine(AVCE00ParseInfo *psInfo,
     782             :                                          const char *pszLine);
     783             : AVCField *AVCE00ParseNextTableRecLine(AVCE00ParseInfo *psInfo,
     784             :                                       const char *pszLine);
     785             : 
     786             : /*---------------------------------------------------------------------
     787             :  * Misc. functions shared by several parts of the lib.
     788             :  *--------------------------------------------------------------------*/
     789             : int _AVCE00ComputeRecSize(int numFields, AVCFieldInfo *pasDef,
     790             :                           GBool bMapType40ToDouble);
     791             : 
     792             : void _AVCDestroyTableFields(AVCTableDef *psTableDef, AVCField *pasFields);
     793             : void _AVCDestroyTableDef(AVCTableDef *psTableDef);
     794             : AVCTableDef *_AVCDupTableDef(AVCTableDef *psSrcDef);
     795             : 
     796             : GBool AVCFileExists(const char *pszPath, const char *pszName);
     797             : char *AVCAdjustCaseSensitiveFilename(char *pszFname);
     798             : int AVCPrintRealValue(char *pszBuf, size_t nBufLen, int nPrecision,
     799             :                       AVCFileType eType, double dValue);
     800             : 
     801             : /*=====================================================================
     802             :               Function prototypes (THE PUBLIC ONES)
     803             :  =====================================================================*/
     804             : 
     805             : /*---------------------------------------------------------------------
     806             :  * Functions to read E00
     807             :  *--------------------------------------------------------------------*/
     808             : AVCE00ReadE00Ptr AVCE00ReadOpenE00(const char *pszE00FileName);
     809             : void AVCE00ReadCloseE00(AVCE00ReadE00Ptr psRead);
     810             : int AVCE00ReadRewindE00(AVCE00ReadE00Ptr psRead);
     811             : void *AVCE00ReadNextObjectE00(AVCE00ReadE00Ptr psRead);
     812             : 
     813             : AVCE00Section *AVCE00ReadSectionsListE00(AVCE00ReadE00Ptr psRead, int *numSect);
     814             : int AVCE00ReadGotoSectionE00(AVCE00ReadE00Ptr psRead, AVCE00Section *psSect,
     815             :                              GBool bContinue);
     816             : 
     817             : /*---------------------------------------------------------------------
     818             :  * Functions to make a binary coverage appear as E00
     819             :  *--------------------------------------------------------------------*/
     820             : 
     821             : AVCE00ReadPtr AVCE00ReadOpen(const char *pszCoverPath);
     822             : void AVCE00ReadClose(AVCE00ReadPtr psInfo);
     823             : const char *AVCE00ReadNextLine(AVCE00ReadPtr psInfo);
     824             : int AVCE00ReadRewind(AVCE00ReadPtr psInfo);
     825             : 
     826             : AVCE00Section *AVCE00ReadSectionsList(AVCE00ReadPtr psInfo, int *numSect);
     827             : int AVCE00ReadGotoSection(AVCE00ReadPtr psInfo, AVCE00Section *psSect,
     828             :                           GBool bContinue);
     829             : 
     830             : /*---------------------------------------------------------------------
     831             :  * Functions to write E00 lines to a binary coverage
     832             :  *--------------------------------------------------------------------*/
     833             : 
     834             : AVCE00WritePtr AVCE00WriteOpen(const char *pszCoverPath,
     835             :                                AVCCoverType eNewCoverType, int nPrecision);
     836             : void AVCE00WriteClose(AVCE00WritePtr psInfo);
     837             : int AVCE00WriteNextLine(AVCE00WritePtr psInfo, const char *pszLine);
     838             : int AVCE00DeleteCoverage(const char *pszCoverPath);
     839             : 
     840             : CPL_C_END
     841             : 
     842             : #endif /* AVC_H_INCLUDED_ */

Generated by: LCOV version 1.14