1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
/**********************************************************************
* $Id: e00compr.h,v 1.10 2009-02-24 20:03:50 aboudreault Exp $
*
* Name: e00compr.h
* Project: Compressed E00 Read/Write library
* Language: ANSI C
* Purpose: Header file containing all definitions for the library.
* Author: Daniel Morissette, dmorissette@mapgears.com
*
* $Log: e00compr.h,v $
* Revision 1.10 2009-02-24 20:03:50 aboudreault
* Added a short manual pages (#1875)
* Updated documentation and code examples (#247)
*
* Revision 1.9 2005-09-17 14:22:05 daniel
* Switch to MIT license, update refs to website and email address, and
* prepare for 1.0.0 release.
*
* Revision 1.8 1999/03/03 18:47:07 daniel
* Moved extern "C" after #include lines (form MSVC++ 6)
*
* Revision 1.7 1999/02/25 18:47:40 daniel
* Now use CPL for Error handling, Memory allocation, and File access.
*
* Revision 1.6 1999/01/08 17:40:33 daniel
* Added E00Read/WriteCallbakcOpen()
*
* Revision 1.5 1998/11/13 15:39:45 daniel
* Added functions for write support.
*
* Revision 1.4 1998/11/02 18:37:03 daniel
* New file header, and added E00ErrorReset()
*
* Revision 1.1 1998/10/29 13:26:00 daniel
* Initial revision
*
**********************************************************************
* Copyright (c) 1998-2005, Daniel Morissette
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
**********************************************************************/
#ifndef _E00COMPR_H_INCLUDED_
#define _E00COMPR_H_INCLUDED_
#include <stdio.h>
#include "cpl_port.h"
#include "cpl_conv.h"
#include "cpl_error.h"
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------------
* Current version of the library... always useful!
*--------------------------------------------------------------------*/
#define E00COMPR_VERSION "1.0.0 (2005-09-17)"
/*=====================================================================
Data types and constants
=====================================================================*/
#define E00_READ_BUF_SIZE 256 /* E00 lines are always 80 chars or less */
/* for both compressed and uncompressed */
/* files, except the first line (the EXP)*/
/* for which there is no known limit */
/* We'll assume that it can't be longer */
/* than 256 chars */
#define E00_WRITE_BUF_SIZE 256 /* This buffer must be big enough to hold*/
/* at least 2 lines of compressed output */
/* (i.e. 160 chars)... but just in case */
/* compressing a line would ever result */
/* in it becoming bigger than its source */
/* we'll set the size to 256 chars! */
#define E00_COMPR_NONE 0 /* Compression levels to use when writing*/
#define E00_COMPR_PARTIAL 1
#define E00_COMPR_FULL 2
/*---------------------------------------------------------------------
* E00ReadPtr
*
* A E00ReadPtr handle is used to hold information about the compressed
* file currently being read.
*--------------------------------------------------------------------*/
struct _E00ReadInfo
{
FILE *fp; /* Input file handle */
int bEOF; /* Reached EOF? */
int bIsCompressed; /* 1 if file is compressed, 0 if not */
int nInputLineNo;
int iInBufPtr; /* Last character processed in szInBuf */
char szInBuf[E00_READ_BUF_SIZE]; /* compressed input buffer */
char szOutBuf[E00_READ_BUF_SIZE];/* uncompressed output buffer */
/* pRefData, pfnReadNextLine() and pfnReadRewind() are used only
* when the file is opened with E00ReadCallbackOpen()
* (and in this case the FILE *fp defined above is not used)
*/
void * pRefData;
const char * (*pfnReadNextLine)(void *);
void (*pfnReadRewind)(void *);
};
typedef struct _E00ReadInfo *E00ReadPtr;
/*---------------------------------------------------------------------
* E00WritePtr
*
* A E00WritePtr handle is used to hold information about the
* file currently being written.
*--------------------------------------------------------------------*/
struct _E00WriteInfo
{
FILE *fp; /* Output file handle */
int nComprLevel;
int nSrcLineNo;
int iOutBufPtr; /* Current position in szOutBuf */
char szOutBuf[E00_WRITE_BUF_SIZE]; /* compressed output buffer */
/* pRefData and pfnWriteNextLine() are used only
* when the file is opened with E00WriteCallbackOpen()
* (and in this case the FILE *fp defined above is not used)
*/
void *pRefData;
int (*pfnWriteNextLine)(void *, const char *);
};
typedef struct _E00WriteInfo *E00WritePtr;
/*=====================================================================
Function prototypes
=====================================================================*/
E00ReadPtr E00ReadOpen(const char *pszFname);
E00ReadPtr E00ReadCallbackOpen(void *pRefData,
const char * (*pfnReadNextLine)(void *),
void (*pfnReadRewind)(void *));
void E00ReadClose(E00ReadPtr psInfo);
const char *E00ReadNextLine(E00ReadPtr psInfo);
void E00ReadRewind(E00ReadPtr psInfo);
E00WritePtr E00WriteOpen(const char *pszFname, int nComprLevel);
E00WritePtr E00WriteCallbackOpen(void *pRefData,
int (*pfnWriteNextLine)(void *, const char *),
int nComprLevel);
void E00WriteClose(E00WritePtr psInfo);
int E00WriteNextLine(E00WritePtr psInfo, const char *pszLine);
#ifdef __cplusplus
}
#endif
#endif /* _E00COMPR_H_INCLUDED_ */
|