1 |
/* |
2 |
* libhfs - library for reading and writing Macintosh HFS volumes |
3 |
* |
4 |
* The iterator shown here iterates over the blocks of a fork. |
5 |
* |
6 |
* Copyright (C) 2000 Klaus Halfmann <klaus.halfmann@feri.de> |
7 |
* Original work by 1996-1998 Robert Leslie <rob@mars.org> |
8 |
* other work 2000 from Brad Boyer (flar@pants.nu) |
9 |
* |
10 |
* This program is free software; you can redistribute it and/or modify |
11 |
* it under the terms of the GNU General Public License as published by |
12 |
* the Free Software Foundation; either version 2 of the License, or |
13 |
* (at your option) any later version. |
14 |
* |
15 |
* This program is distributed in the hope that it will be useful, |
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 |
* GNU General Public License for more details. |
19 |
* |
20 |
* You should have received a copy of the GNU General Public License |
21 |
* along with this program; if not, write to the Free Software |
22 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 |
* |
24 |
*/ |
25 |
|
26 |
/* Structure of the blockiterator */ |
27 |
typedef struct |
28 |
{ |
29 |
volume* vol; // volume we iterate over |
30 |
UInt32 curr_block; // current, absolute block |
31 |
UInt32 block; // relative block in current extent |
32 |
UInt32 max_block; // Maximum allowed block |
33 |
UInt32 fileId; // id of file we iterate over |
34 |
int index; // 0 .. 7 in current extent |
35 |
hfsp_extent* file; // original extent record from file |
36 |
hfsp_extent* e; // current extentent under examination |
37 |
UInt8 forktype; // type of fork we iterate over |
38 |
UInt8 in_extent; // boolean 0 - in file extent |
39 |
// 1 - in extents file |
40 |
extent_record er; // record to iterate in extents file. |
41 |
} blockiter; |
42 |
|
43 |
/* Initialize iterator for a given fork */ |
44 |
extern void blockiter_init(blockiter* b, volume* vol, hfsp_fork_raw* f, |
45 |
UInt8 forktype, UInt32 fileId); |
46 |
|
47 |
/* find next block of the fork iterating over */ |
48 |
extern int blockiter_next(blockiter *b); |
49 |
|
50 |
/* skip the indicated number of blocks */ |
51 |
extern int blockiter_skip(blockiter *b, UInt32 skip); |
52 |
|
53 |
/* return current block */ |
54 |
static inline UInt32 blockiter_curr(blockiter *b) |
55 |
{ |
56 |
return b->e->start_block + b->block; |
57 |
} |
58 |
|
59 |
|