io.c

00001 /*
00002  * libopenraw - io.c
00003  *
00004  * Copyright (C) 2005-2006 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
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of 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, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 #include <stdlib.h>
00022 
00023 #include "libopenraw/io.h"
00024 #include "io_private.h"
00025 #include "posix_io.h"
00026 #include "or_debug.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00037 struct io_methods* get_default_io_methods(void)
00038 {
00039     return &posix_io_methods;
00040 }
00041 
00047 IOFileRef raw_open(struct io_methods * methods, const char *path, int mode)
00048 {
00049     return methods->open(path, mode);
00050 }
00051 
00061 int raw_close(IOFileRef f)
00062 {
00063     int retval = f->methods->close(f);
00064     free(f);
00065     return retval;
00066 }
00067 
00068 
00076 int raw_seek(IOFileRef f, off_t offset, int whence)
00077 {
00078     return f->methods->seek(f, offset, whence);
00079 }
00080 
00081 
00089 int raw_read(IOFileRef f, void *buf, size_t count)
00090 {
00091     return f->methods->read(f, buf, count);
00092 }
00093 
00094 off_t raw_filesize(IOFileRef f)
00095 {
00096     return f->methods->filesize(f);
00097 }
00098 
00099 void *raw_mmap(IOFileRef f, size_t l, off_t offset)
00100 {
00101     return f->methods->mmap(f, l, offset);
00102 }
00103 
00104 
00105 int raw_munmap(IOFileRef f, void *addr, size_t l)
00106 {
00107     return f->methods->munmap(f, addr, l);
00108 }
00109 
00110 
00116 int raw_get_error(IOFileRef f)
00117 {
00118     return f->error;
00119 }
00120 
00121 
00130 char *raw_get_path(IOFileRef f)
00131 {
00132     return f->path;
00133 }
00134 
00135 
00136 #ifdef __cplusplus
00137 };
00138 #endif
00139 

Generated on Sat Jan 27 11:36:13 2007 for libopenraw by  doxygen 1.4.7