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