OpenCPN Partial API docs
Loading...
Searching...
No Matches
zuFile.h
Go to the documentation of this file.
1/**********************************************************************
2zyGrib: meteorological GRIB file viewer
3Copyright (C) 2008 - Jacques Zaninetti - http://www.zygrib.org
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17***********************************************************************/
39#ifndef ZU_FILE_H
40#define ZU_FILE_H
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46// zuFile : uniform interface for READING uncompressed, gziped and bziped files
47// (with fseek ftell not so bugged as in ... library)
48#include <stdio.h>
49#include <string.h>
50#include <stdlib.h>
51#include <ctype.h>
52
53#include <zlib.h>
54#include <bzlib.h>
55
56#define ZU_COMPRESS_AUTO -1
57#define ZU_COMPRESS_NONE 0
58#define ZU_COMPRESS_GZIP 1
59#define ZU_COMPRESS_BZIP 2
60
61#define ZU_BUFREADSIZE 256000
62
63typedef struct {
64 int type;
65 int ok;
66 char *fname;
67 long pos;
68
69 void *zfile; // exact file type depends of compress type
70
71 FILE *faux; // auxiliary file for bzip
72} ZUFILE;
73
74ZUFILE *zu_open(const char *fname, const char *mode,
75 int type = ZU_COMPRESS_AUTO);
76int zu_close(ZUFILE *f);
77
78int zu_can_read_file(const char *fname);
79
80int zu_read(ZUFILE *f, void *buf, long len);
81
82long zu_tell(ZUFILE *f);
83
84int zu_seek(ZUFILE *f, long offset, int whence); // TODO: whence=SEEK_END
85
86void zu_rewind(ZUFILE *f);
87
88long zu_filesize(ZUFILE *f);
89
90// for internal use :
91int zu_bzSeekForward(ZUFILE *f, unsigned long nbytes);
92
93#ifdef __cplusplus
94}
95#endif
96
97#endif