FreeCalypso > hg > freecalypso-reveng
comparison mpffs/ls.c @ 39:9bc7f0e03fa8
iterate_extra_chunks() function written, mpffs-ls converted to use it
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jul 2013 06:49:50 +0000 |
parents | 0bf037ba4149 |
children |
comparison
equal
deleted
inserted
replaced
38:e9c6d6615f32 | 39:9bc7f0e03fa8 |
---|---|
16 extern struct objinfo root; | 16 extern struct objinfo root; |
17 extern int verbose; | 17 extern int verbose; |
18 | 18 |
19 char workpath[512]; | 19 char workpath[512]; |
20 | 20 |
21 void | |
22 extra_chunk_callback(obj, opaque) | |
23 struct objinfo *obj; | |
24 u_long opaque; | |
25 { | |
26 size_t *accump = (size_t *) opaque; | |
27 struct chunkinfo chi; | |
28 | |
29 size_extra_chunk(obj, &chi); | |
30 *accump += chi.len; | |
31 } | |
32 | |
21 size_t | 33 size_t |
22 get_file_size(head) | 34 get_file_size(head) |
23 struct objinfo *head; | 35 struct objinfo *head; |
24 { | 36 { |
25 int ent; | |
26 struct objinfo ch; | |
27 struct chunkinfo chi; | 37 struct chunkinfo chi; |
28 size_t accum; | 38 size_t accum; |
29 | 39 |
30 size_head_chunk(head, &chi); | 40 size_head_chunk(head, &chi); |
31 accum = chi.len; | 41 accum = chi.len; |
32 for (ent = head->descend; ent != 0xFFFF; ent = ch.descend) { | 42 iterate_extra_chunks(head->descend, extra_chunk_callback, |
33 ch.entryno = ent; | 43 (u_long) &accum); |
34 get_index_entry(&ch); | |
35 if (ch.type != 0xF4) { | |
36 fprintf(stderr, | |
37 "file continuation object at index %x: type %02X != expected F4\n", | |
38 ent, ch.type); | |
39 break; | |
40 } | |
41 validate_chunk(&ch); | |
42 size_extra_chunk(&ch, &chi); | |
43 accum += chi.len; | |
44 if (ch.sibling != 0xFFFF) | |
45 fprintf(stderr, | |
46 "warning: file continuation object (index %x) has a non-nil sibling pointer\n", | |
47 ent); | |
48 } | |
49 return(accum); | 44 return(accum); |
50 } | 45 } |
51 | 46 |
52 dump_dir(firstent, path_prefix) | 47 dump_dir(firstent, path_prefix) |
53 { | 48 { |