OpenCPN Partial API docs
Loading...
Searching...
No Matches
zu_file.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***********************************************************************/
18
42#ifndef ZU_FILE_H
43#define ZU_FILE_H
44
45#define ZU_COMPRESS_AUTO (-1)
46#define ZU_COMPRESS_NONE 0
47#define ZU_COMPRESS_GZIP 1
48#define ZU_COMPRESS_BZIP 2
49
50#define ZU_BUFREADSIZE 256000
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56// zuFile : uniform interface for READING uncompressed, gziped and bziped files
57// (with fseek ftell not so bugged as in ... library)
58#include <stdio.h>
59#include <string.h>
60#include <stdlib.h>
61#include <ctype.h>
62
63#include <zlib.h>
64#include <bzlib.h>
65
66typedef struct {
67 int type;
68 int ok;
69 char *fname;
70 long pos;
71
72 void *zfile; // exact file type depends of compress type
73
74 FILE *faux; // auxiliary file for bzip
75} ZUFILE;
76
77ZUFILE *zu_open(const char *fname, const char *mode,
78 int type = ZU_COMPRESS_AUTO);
79int zu_close(ZUFILE *f);
80
81int zu_can_read_file(const char *fname);
82
83int zu_read(ZUFILE *f, void *buf, long len);
84
85long zu_tell(ZUFILE *f);
86
87int zu_seek(ZUFILE *f, long offset, int whence); // TODO: whence=SEEK_END
88
89void zu_rewind(ZUFILE *f);
90
91long zu_filesize(ZUFILE *f);
92
93// for internal use :
94int zu_bzSeekForward(ZUFILE *f, unsigned long nbytes);
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif