libopenraw
Main Page
Related Pages
Namespaces
Classes
Files
File List
lib
io
io.c
1
/*
2
* libopenraw - io.c
3
*
4
* Copyright (C) 2005-2007 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
#include <stdlib.h>
22
#include <errno.h>
23
24
#include "libopenraw/io.h"
25
#include "io_private.h"
26
#include "posix_io.h"
27
#include "or_debug.h"
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
34
#define CHECK_PTR(p,r) \
35
if(p == NULL) { return r; }
36
42
struct
io_methods
* get_default_io_methods(
void
)
43
{
44
return
&posix_io_methods;
45
}
46
52
IOFileRef
raw_open(
struct
io_methods
* methods,
const
char
*path,
int
mode)
53
{
54
CHECK_PTR(methods, NULL);
55
return
methods->
open
(path, mode);
56
}
57
67
int
raw_close(
IOFileRef
f)
68
{
69
int
retval;
70
CHECK_PTR(f,-1);
71
retval = f->
methods
->
close
(f);
72
free(f);
73
return
retval;
74
}
75
76
84
int
raw_seek(
IOFileRef
f, off_t offset,
int
whence)
85
{
86
CHECK_PTR(f,-1);
87
return
f->
methods
->
seek
(f, offset, whence);
88
}
89
90
98
int
raw_read(
IOFileRef
f,
void
*buf,
size_t
count)
99
{
100
CHECK_PTR(f,-1);
101
return
f->
methods
->
read
(f, buf, count);
102
}
103
104
off_t raw_filesize(
IOFileRef
f)
105
{
106
CHECK_PTR(f,0);
107
return
f->
methods
->filesize(f);
108
}
109
110
void
*raw_mmap(
IOFileRef
f,
size_t
l, off_t offset)
111
{
112
CHECK_PTR(f,NULL);
113
return
f->
methods
->mmap(f, l, offset);
114
}
115
116
117
int
raw_munmap(
IOFileRef
f,
void
*addr,
size_t
l)
118
{
119
CHECK_PTR(f,-1);
120
return
f->
methods
->munmap(f, addr, l);
121
}
122
123
129
int
raw_get_error(
IOFileRef
f)
130
{
131
CHECK_PTR(f,EFAULT);
132
return
f->
error
;
133
}
134
135
144
char
*raw_get_path(
IOFileRef
f)
145
{
146
CHECK_PTR(f,NULL);
147
return
f->
path
;
148
}
149
150
151
#ifdef __cplusplus
152
}
153
#endif
154
Generated on Sat Jan 12 2013 13:31:44 for libopenraw by
1.8.3