1
/**********************************************************************
4
* This example program illustrates the use of the E00ReadCallbackOpen()
5
* and associated compressed E00 read functions.
6
**********************************************************************/
12
static const char *myReadNextLine(void *pRefData);
13
static void myReadRewind(void *pRefData);
15
int main(int argc, char *argv[])
22
if ((fp = fopen("test.e00", "rt")) == NULL)
25
printf("Cannot open input file test.e00\n");
29
/* Initialize reader */
30
hReadPtr = E00ReadCallbackOpen((void*)fp,
31
myReadNextLine, myReadRewind);
35
/* Read lines from input until we reach EOF */
36
while((pszLine = E00ReadNextLine(hReadPtr)) != NULL)
38
if (E00GetLastErrorNo() == 0)
39
printf("%s\n", pszLine);
42
/* An error happened while reading the last line... */
47
/* Close input file */
48
E00ReadClose(hReadPtr);
54
/* ERROR ... file is not a valid E00 */
62
/**********************************************************************
65
* My own implementation of the ReadNextLine() function to test the
66
* E00ReadCallbackOpen() functions.
68
* This function must return a reference to static buffer with the next
69
* line of input, or NULL when it reaches EOF.
70
**********************************************************************/
71
static const char *myReadNextLine(void *pRefData)
74
static char szBuf[256];
76
fp = (FILE *)pRefData;
78
if (fgets(szBuf, 255, fp) == NULL)
86
/**********************************************************************
89
* Callback function to rewind the file being read by myReadNextLine()
90
**********************************************************************/
91
static void myReadRewind(void *pRefData)
93
rewind((FILE *)pRefData);