4 * Written by Eryk Vershen
8 * Copyright 1997,1998 by Apple Computer, Inc.
11 * Permission to use, copy, modify, and distribute this software and
12 * its documentation for any purpose and without fee is hereby granted,
13 * provided that the above copyright notice appears in all copies and
14 * that both the copyright notice and this permission notice appear in
15 * supporting documentation.
17 * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
18 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE.
21 * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
22 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
24 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
25 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 // for malloc() & free()
55 static long media_kind
= 0;
58 * Forward declarations
66 allocate_media_kind(void)
76 return (MEDIA
) malloc(size
);
91 media_granularity(MEDIA m
)
102 media_total_size(MEDIA m
)
107 return m
->size_in_bytes
;
113 read_media(MEDIA m
, long long offset
, unsigned long count
, void *address
)
117 if (m
!= 0 && m
->do_read
!= 0) {
118 //printf("media: read type %d, offset %Ld, count %d\n\t", m->kind, offset, count);
119 result
= (*m
->do_read
)(m
, offset
, count
, address
);
120 //printf(" - returns %d\n", result);
129 write_media(MEDIA m
, long long offset
, unsigned long count
, void *address
)
133 if (m
!= 0 && m
->do_write
!= 0) {
134 //printf("media: write type %d, offset %Ld, count %d\n\t", m->kind, offset, count);
135 result
= (*m
->do_write
)(m
, offset
, count
, address
);
136 //printf(" - returns %d\n", result);
151 if (m
->do_close
!= 0) {
161 os_reload_media(MEDIA m
)
163 if (m
!= 0 && m
->do_os_reload
!= 0) {
164 (*m
->do_os_reload
)(m
);
169 #if !defined(__linux__) && !defined(__unix__)
176 new_media_iterator(long size
)
178 return (MEDIA_ITERATOR
) malloc(size
);
183 private_delete_media_iterator(MEDIA_ITERATOR m
)
193 reset_media_iterator(MEDIA_ITERATOR m
)
195 if (m
!= 0 && m
->do_reset
!= 0) {
202 step_media_iterator(MEDIA_ITERATOR m
)
206 if (m
!= 0 && m
->do_step
!= 0) {
207 result
= (*m
->do_step
)(m
);
216 delete_media_iterator(MEDIA_ITERATOR m
)
222 if (m
->do_delete
!= 0) {
226 private_delete_media_iterator(m
);