diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-06-26 16:36:26 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-06-26 16:36:26 +0000 |
commit | 5ef5614c31d26a87d9d92e97bed7df7993296682 (patch) | |
tree | eb23ddaddaee372a31bfc6c19b1a685a0801f8de | |
parent | ce98c19dfe7bcfb3174c0898f3c001c38c6d44c6 (diff) | |
download | busybox-w32-5ef5614c31d26a87d9d92e97bed7df7993296682.tar.gz busybox-w32-5ef5614c31d26a87d9d92e97bed7df7993296682.tar.bz2 busybox-w32-5ef5614c31d26a87d9d92e97bed7df7993296682.zip |
Don't use void * to pass pointers of known type
-rw-r--r-- | include/libbb.h | 18 | ||||
-rw-r--r-- | libbb/libbb.h | 18 | ||||
-rw-r--r-- | libbb/unarchive.c | 29 |
3 files changed, 37 insertions, 28 deletions
diff --git a/include/libbb.h b/include/libbb.h index 3b0ced7d1..c29955b3b 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -212,9 +212,19 @@ char *xreadlink(const char *path); | |||
212 | char *concat_path_file(const char *path, const char *filename); | 212 | char *concat_path_file(const char *path, const char *filename); |
213 | char *last_char_is(const char *s, int c); | 213 | char *last_char_is(const char *s, int c); |
214 | 214 | ||
215 | void *get_header_ar(FILE *in_file); | 215 | typedef struct file_headers_s { |
216 | void *get_header_cpio(FILE *src_stream); | 216 | char *name; |
217 | void *get_header_tar(FILE *tar_stream); | 217 | char *link_name; |
218 | off_t size; | ||
219 | uid_t uid; | ||
220 | gid_t gid; | ||
221 | mode_t mode; | ||
222 | time_t mtime; | ||
223 | dev_t device; | ||
224 | } file_header_t; | ||
225 | file_header_t *get_header_ar(FILE *in_file); | ||
226 | file_header_t *get_header_cpio(FILE *src_stream); | ||
227 | file_header_t *get_header_tar(FILE *tar_stream); | ||
218 | 228 | ||
219 | enum extract_functions_e { | 229 | enum extract_functions_e { |
220 | extract_verbose_list = 1, | 230 | extract_verbose_list = 1, |
@@ -229,7 +239,7 @@ enum extract_functions_e { | |||
229 | extract_unconditional = 512, | 239 | extract_unconditional = 512, |
230 | extract_create_leading_dirs = 1024 | 240 | extract_create_leading_dirs = 1024 |
231 | }; | 241 | }; |
232 | char *unarchive(FILE *src_stream, void *(*get_header)(FILE *), | 242 | char *unarchive(FILE *src_stream, file_header_t *(*get_header)(FILE *), |
233 | const int extract_function, const char *prefix, char **extract_names); | 243 | const int extract_function, const char *prefix, char **extract_names); |
234 | char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, | 244 | char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, |
235 | const char *prefix, const char *filename); | 245 | const char *prefix, const char *filename); |
diff --git a/libbb/libbb.h b/libbb/libbb.h index 3b0ced7d1..c29955b3b 100644 --- a/libbb/libbb.h +++ b/libbb/libbb.h | |||
@@ -212,9 +212,19 @@ char *xreadlink(const char *path); | |||
212 | char *concat_path_file(const char *path, const char *filename); | 212 | char *concat_path_file(const char *path, const char *filename); |
213 | char *last_char_is(const char *s, int c); | 213 | char *last_char_is(const char *s, int c); |
214 | 214 | ||
215 | void *get_header_ar(FILE *in_file); | 215 | typedef struct file_headers_s { |
216 | void *get_header_cpio(FILE *src_stream); | 216 | char *name; |
217 | void *get_header_tar(FILE *tar_stream); | 217 | char *link_name; |
218 | off_t size; | ||
219 | uid_t uid; | ||
220 | gid_t gid; | ||
221 | mode_t mode; | ||
222 | time_t mtime; | ||
223 | dev_t device; | ||
224 | } file_header_t; | ||
225 | file_header_t *get_header_ar(FILE *in_file); | ||
226 | file_header_t *get_header_cpio(FILE *src_stream); | ||
227 | file_header_t *get_header_tar(FILE *tar_stream); | ||
218 | 228 | ||
219 | enum extract_functions_e { | 229 | enum extract_functions_e { |
220 | extract_verbose_list = 1, | 230 | extract_verbose_list = 1, |
@@ -229,7 +239,7 @@ enum extract_functions_e { | |||
229 | extract_unconditional = 512, | 239 | extract_unconditional = 512, |
230 | extract_create_leading_dirs = 1024 | 240 | extract_create_leading_dirs = 1024 |
231 | }; | 241 | }; |
232 | char *unarchive(FILE *src_stream, void *(*get_header)(FILE *), | 242 | char *unarchive(FILE *src_stream, file_header_t *(*get_header)(FILE *), |
233 | const int extract_function, const char *prefix, char **extract_names); | 243 | const int extract_function, const char *prefix, char **extract_names); |
234 | char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, | 244 | char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, |
235 | const char *prefix, const char *filename); | 245 | const char *prefix, const char *filename); |
diff --git a/libbb/unarchive.c b/libbb/unarchive.c index 4847aab6b..fe061ea12 100644 --- a/libbb/unarchive.c +++ b/libbb/unarchive.c | |||
@@ -27,18 +27,6 @@ | |||
27 | #include <utime.h> | 27 | #include <utime.h> |
28 | #include "libbb.h" | 28 | #include "libbb.h" |
29 | 29 | ||
30 | typedef struct file_headers_s { | ||
31 | char *name; | ||
32 | char *link_name; | ||
33 | off_t size; | ||
34 | uid_t uid; | ||
35 | gid_t gid; | ||
36 | mode_t mode; | ||
37 | time_t mtime; | ||
38 | dev_t device; | ||
39 | } file_header_t; | ||
40 | |||
41 | |||
42 | extern void seek_sub_file(FILE *src_stream, const int count); | 30 | extern void seek_sub_file(FILE *src_stream, const int count); |
43 | extern char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry, | 31 | extern char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry, |
44 | const int function, const char *prefix); | 32 | const int function, const char *prefix); |
@@ -223,7 +211,7 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f | |||
223 | #endif | 211 | #endif |
224 | 212 | ||
225 | #ifdef L_unarchive | 213 | #ifdef L_unarchive |
226 | char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *), | 214 | char *unarchive(FILE *src_stream, file_header_t *(*get_headers)(FILE *), |
227 | const int extract_function, const char *prefix, char **extract_names) | 215 | const int extract_function, const char *prefix, char **extract_names) |
228 | { | 216 | { |
229 | file_header_t *file_entry; | 217 | file_header_t *file_entry; |
@@ -232,7 +220,7 @@ char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *), | |||
232 | char *buffer = NULL; | 220 | char *buffer = NULL; |
233 | 221 | ||
234 | archive_offset = 0; | 222 | archive_offset = 0; |
235 | while ((file_entry = (file_header_t *) get_headers(src_stream)) != NULL) { | 223 | while ((file_entry = get_headers(src_stream)) != NULL) { |
236 | found = FALSE; | 224 | found = FALSE; |
237 | if (extract_names[0] != NULL) { | 225 | if (extract_names[0] != NULL) { |
238 | for(i = 0; extract_names[i] != 0; i++) { | 226 | for(i = 0; extract_names[i] != 0; i++) { |
@@ -253,7 +241,7 @@ char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *), | |||
253 | #endif | 241 | #endif |
254 | 242 | ||
255 | #ifdef L_get_header_ar | 243 | #ifdef L_get_header_ar |
256 | void *get_header_ar(FILE *src_stream) | 244 | file_header_t *get_header_ar(FILE *src_stream) |
257 | { | 245 | { |
258 | file_header_t *typed; | 246 | file_header_t *typed; |
259 | union { | 247 | union { |
@@ -347,7 +335,7 @@ struct hardlinks { | |||
347 | struct hardlinks *next; | 335 | struct hardlinks *next; |
348 | }; | 336 | }; |
349 | 337 | ||
350 | void *get_header_cpio(FILE *src_stream) | 338 | file_header_t *get_header_cpio(FILE *src_stream) |
351 | { | 339 | { |
352 | file_header_t *cpio_entry = NULL; | 340 | file_header_t *cpio_entry = NULL; |
353 | char cpio_header[110]; | 341 | char cpio_header[110]; |
@@ -457,7 +445,7 @@ void *get_header_cpio(FILE *src_stream) | |||
457 | #endif | 445 | #endif |
458 | 446 | ||
459 | #ifdef L_get_header_tar | 447 | #ifdef L_get_header_tar |
460 | void *get_header_tar(FILE *tar_stream) | 448 | file_header_t *get_header_tar(FILE *tar_stream) |
461 | { | 449 | { |
462 | union { | 450 | union { |
463 | unsigned char raw[512]; | 451 | unsigned char raw[512]; |
@@ -525,7 +513,8 @@ void *get_header_tar(FILE *tar_stream) | |||
525 | tar_entry->gid = strtol(tar.formated.gid, NULL, 8); | 513 | tar_entry->gid = strtol(tar.formated.gid, NULL, 8); |
526 | tar_entry->size = strtol(tar.formated.size, NULL, 8); | 514 | tar_entry->size = strtol(tar.formated.size, NULL, 8); |
527 | tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8); | 515 | tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8); |
528 | tar_entry->link_name = strlen(tar.formated.linkname) ? xstrdup(tar.formated.linkname) : NULL; | 516 | tar_entry->link_name = strlen(tar.formated.linkname) ? |
517 | xstrdup(tar.formated.linkname) : NULL; | ||
529 | tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) + | 518 | tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) + |
530 | strtol(tar.formated.devminor, NULL, 8); | 519 | strtol(tar.formated.devminor, NULL, 8); |
531 | 520 | ||
@@ -534,8 +523,8 @@ void *get_header_tar(FILE *tar_stream) | |||
534 | #endif | 523 | #endif |
535 | 524 | ||
536 | #ifdef L_deb_extract | 525 | #ifdef L_deb_extract |
537 | char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, | 526 | char *deb_extract(const char *package_filename, FILE *out_stream, |
538 | const char *prefix, const char *filename) | 527 | const int extract_function, const char *prefix, const char *filename) |
539 | { | 528 | { |
540 | FILE *deb_stream; | 529 | FILE *deb_stream; |
541 | FILE *uncompressed_stream = NULL; | 530 | FILE *uncompressed_stream = NULL; |