Don't use void * to pass pointers of known type

This commit is contained in:
Eric Andersen 2001-06-26 16:36:26 +00:00
parent ce98c19dfe
commit 5ef5614c31
3 changed files with 37 additions and 28 deletions

View File

@ -212,9 +212,19 @@ char *xreadlink(const char *path);
char *concat_path_file(const char *path, const char *filename); char *concat_path_file(const char *path, const char *filename);
char *last_char_is(const char *s, int c); char *last_char_is(const char *s, int c);
void *get_header_ar(FILE *in_file); typedef struct file_headers_s {
void *get_header_cpio(FILE *src_stream); char *name;
void *get_header_tar(FILE *tar_stream); char *link_name;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
dev_t device;
} file_header_t;
file_header_t *get_header_ar(FILE *in_file);
file_header_t *get_header_cpio(FILE *src_stream);
file_header_t *get_header_tar(FILE *tar_stream);
enum extract_functions_e { enum extract_functions_e {
extract_verbose_list = 1, extract_verbose_list = 1,
@ -229,7 +239,7 @@ enum extract_functions_e {
extract_unconditional = 512, extract_unconditional = 512,
extract_create_leading_dirs = 1024 extract_create_leading_dirs = 1024
}; };
char *unarchive(FILE *src_stream, void *(*get_header)(FILE *), char *unarchive(FILE *src_stream, file_header_t *(*get_header)(FILE *),
const int extract_function, const char *prefix, char **extract_names); const int extract_function, const char *prefix, char **extract_names);
char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function,
const char *prefix, const char *filename); const char *prefix, const char *filename);

View File

@ -212,9 +212,19 @@ char *xreadlink(const char *path);
char *concat_path_file(const char *path, const char *filename); char *concat_path_file(const char *path, const char *filename);
char *last_char_is(const char *s, int c); char *last_char_is(const char *s, int c);
void *get_header_ar(FILE *in_file); typedef struct file_headers_s {
void *get_header_cpio(FILE *src_stream); char *name;
void *get_header_tar(FILE *tar_stream); char *link_name;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
dev_t device;
} file_header_t;
file_header_t *get_header_ar(FILE *in_file);
file_header_t *get_header_cpio(FILE *src_stream);
file_header_t *get_header_tar(FILE *tar_stream);
enum extract_functions_e { enum extract_functions_e {
extract_verbose_list = 1, extract_verbose_list = 1,
@ -229,7 +239,7 @@ enum extract_functions_e {
extract_unconditional = 512, extract_unconditional = 512,
extract_create_leading_dirs = 1024 extract_create_leading_dirs = 1024
}; };
char *unarchive(FILE *src_stream, void *(*get_header)(FILE *), char *unarchive(FILE *src_stream, file_header_t *(*get_header)(FILE *),
const int extract_function, const char *prefix, char **extract_names); const int extract_function, const char *prefix, char **extract_names);
char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function,
const char *prefix, const char *filename); const char *prefix, const char *filename);

View File

@ -27,18 +27,6 @@
#include <utime.h> #include <utime.h>
#include "libbb.h" #include "libbb.h"
typedef struct file_headers_s {
char *name;
char *link_name;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
dev_t device;
} file_header_t;
extern void seek_sub_file(FILE *src_stream, const int count); extern void seek_sub_file(FILE *src_stream, const int count);
extern char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry, extern char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *file_entry,
const int function, const char *prefix); const int function, const char *prefix);
@ -223,7 +211,7 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f
#endif #endif
#ifdef L_unarchive #ifdef L_unarchive
char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *), char *unarchive(FILE *src_stream, file_header_t *(*get_headers)(FILE *),
const int extract_function, const char *prefix, char **extract_names) const int extract_function, const char *prefix, char **extract_names)
{ {
file_header_t *file_entry; file_header_t *file_entry;
@ -232,7 +220,7 @@ char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *),
char *buffer = NULL; char *buffer = NULL;
archive_offset = 0; archive_offset = 0;
while ((file_entry = (file_header_t *) get_headers(src_stream)) != NULL) { while ((file_entry = get_headers(src_stream)) != NULL) {
found = FALSE; found = FALSE;
if (extract_names[0] != NULL) { if (extract_names[0] != NULL) {
for(i = 0; extract_names[i] != 0; i++) { for(i = 0; extract_names[i] != 0; i++) {
@ -253,7 +241,7 @@ char *unarchive(FILE *src_stream, void *(*get_headers)(FILE *),
#endif #endif
#ifdef L_get_header_ar #ifdef L_get_header_ar
void *get_header_ar(FILE *src_stream) file_header_t *get_header_ar(FILE *src_stream)
{ {
file_header_t *typed; file_header_t *typed;
union { union {
@ -347,7 +335,7 @@ struct hardlinks {
struct hardlinks *next; struct hardlinks *next;
}; };
void *get_header_cpio(FILE *src_stream) file_header_t *get_header_cpio(FILE *src_stream)
{ {
file_header_t *cpio_entry = NULL; file_header_t *cpio_entry = NULL;
char cpio_header[110]; char cpio_header[110];
@ -457,7 +445,7 @@ void *get_header_cpio(FILE *src_stream)
#endif #endif
#ifdef L_get_header_tar #ifdef L_get_header_tar
void *get_header_tar(FILE *tar_stream) file_header_t *get_header_tar(FILE *tar_stream)
{ {
union { union {
unsigned char raw[512]; unsigned char raw[512];
@ -525,7 +513,8 @@ void *get_header_tar(FILE *tar_stream)
tar_entry->gid = strtol(tar.formated.gid, NULL, 8); tar_entry->gid = strtol(tar.formated.gid, NULL, 8);
tar_entry->size = strtol(tar.formated.size, NULL, 8); tar_entry->size = strtol(tar.formated.size, NULL, 8);
tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8); tar_entry->mtime = strtol(tar.formated.mtime, NULL, 8);
tar_entry->link_name = strlen(tar.formated.linkname) ? xstrdup(tar.formated.linkname) : NULL; tar_entry->link_name = strlen(tar.formated.linkname) ?
xstrdup(tar.formated.linkname) : NULL;
tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) + tar_entry->device = (strtol(tar.formated.devmajor, NULL, 8) << 8) +
strtol(tar.formated.devminor, NULL, 8); strtol(tar.formated.devminor, NULL, 8);
@ -534,8 +523,8 @@ void *get_header_tar(FILE *tar_stream)
#endif #endif
#ifdef L_deb_extract #ifdef L_deb_extract
char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, char *deb_extract(const char *package_filename, FILE *out_stream,
const char *prefix, const char *filename) const int extract_function, const char *prefix, const char *filename)
{ {
FILE *deb_stream; FILE *deb_stream;
FILE *uncompressed_stream = NULL; FILE *uncompressed_stream = NULL;