libopenraw
|
00001 /* 00002 * libopenraw - io.h 00003 * 00004 * Copyright (C) 2005 Hubert Figuiere 00005 * 00006 * This library is free software: you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public License 00008 * as published by the Free Software Foundation, either version 3 of 00009 * the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library. If not, see 00018 * <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 #ifndef __LIBOPENRAW_IO_H 00022 #define __LIBOPENRAW_IO_H 00023 00024 #include <sys/types.h> 00025 #include <unistd.h> 00026 #include <fcntl.h> 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 00034 typedef struct _IOFile *IOFileRef; 00035 00036 00038 struct io_methods { 00042 IOFileRef (*open)(const char *path, int mode); 00044 int (*close) (IOFileRef f); 00046 int (*seek) (IOFileRef f, off_t offset, int whence); 00048 int (*read) (IOFileRef f, void *buf, size_t count); 00049 00050 off_t (*filesize) (IOFileRef f); 00051 void* (*mmap) (IOFileRef f, size_t l, off_t offset); 00052 int (*munmap) (IOFileRef f, void *addr, size_t l); 00053 }; 00054 00055 extern struct io_methods* get_default_io_methods(void); 00056 00057 extern IOFileRef raw_open(struct io_methods * methods, const char *path, 00058 int mode); 00059 extern int raw_close(IOFileRef f); 00060 extern int raw_seek(IOFileRef f, off_t offset, int whence); 00061 extern int raw_read(IOFileRef f, void *buf, size_t count); 00062 extern off_t raw_filesize(IOFileRef f); 00063 extern void *raw_mmap(IOFileRef f, size_t l, off_t offset); 00064 extern int raw_munmap(IOFileRef f, void *addr, size_t l); 00065 00066 extern int raw_get_error(IOFileRef f); 00067 extern char *raw_get_path(IOFileRef f); 00068 00069 00070 #ifdef __cplusplus 00071 } 00072 #endif 00073 00074 00075 00076 #endif