libopenraw
io.h
1 /*
2  * libopenraw - io.h
3  *
4  * Copyright (C) 2005 Hubert Figuiere
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef LIBOPENRAW_IO_H_
22 #define LIBOPENRAW_IO_H_
23 
24 #include <sys/types.h>
25 #include <unistd.h>
26 #include <fcntl.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 
34 typedef struct _IOFile *IOFileRef;
35 
36 
38 struct io_methods {
42  IOFileRef (*open)(const char *path, int mode);
44  int (*close) (IOFileRef f);
46  int (*seek) (IOFileRef f, off_t offset, int whence);
48  int (*read) (IOFileRef f, void *buf, size_t count);
49 
50  off_t (*filesize) (IOFileRef f);
51  void* (*mmap) (IOFileRef f, size_t l, off_t offset);
52  int (*munmap) (IOFileRef f, void *addr, size_t l);
53 };
54 
55 extern struct io_methods* get_default_io_methods(void);
56 
57 extern IOFileRef raw_open(struct io_methods * methods, const char *path,
58  int mode);
59 extern int raw_close(IOFileRef f);
60 extern int raw_seek(IOFileRef f, off_t offset, int whence);
61 extern int raw_read(IOFileRef f, void *buf, size_t count);
62 extern off_t raw_filesize(IOFileRef f);
63 extern void *raw_mmap(IOFileRef f, size_t l, off_t offset);
64 extern int raw_munmap(IOFileRef f, void *addr, size_t l);
65 
66 extern int raw_get_error(IOFileRef f);
67 extern char *raw_get_path(IOFileRef f);
68 
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 
75 
76 #endif
IOFileRef(* open)(const char *path, int mode)
Definition: io.h:42
int(* close)(IOFileRef f)
Definition: io.h:44
int(* read)(IOFileRef f, void *buf, size_t count)
Definition: io.h:48
int(* seek)(IOFileRef f, off_t offset, int whence)
Definition: io.h:46
Definition: io.h:38