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