mirror of
https://github.com/sheumann/hush.git
synced 2025-02-09 02:31:20 +00:00
Move add_to_list from libunarchive to libbb so it can be of more general use (eg ifupdown). Changed the name to llist_add_to as i plan on adding more llist_ functions as needed (e.g. llist_free).
This commit is contained in:
parent
346cdb1dde
commit
66125c8065
@ -124,7 +124,7 @@ extern int ar_main(int argc, char **argv)
|
|||||||
/* TODO: This is the same as in tar, seperate function ? */
|
/* TODO: This is the same as in tar, seperate function ? */
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
archive_handle->filter = filter_accept_list;
|
archive_handle->filter = filter_accept_list;
|
||||||
archive_handle->accept = add_to_list(archive_handle->accept, argv[optind]);
|
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||||
optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ extern int cpio_main(int argc, char **argv)
|
|||||||
|
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
archive_handle->filter = filter_accept_list;
|
archive_handle->filter = filter_accept_list;
|
||||||
archive_handle->accept = add_to_list(archive_handle->accept, argv[optind]);
|
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||||
optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1330,10 +1330,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
|
|||||||
|
|
||||||
/* We dont care about data.tar.* or debian-binary, just control.tar.* */
|
/* We dont care about data.tar.* or debian-binary, just control.tar.* */
|
||||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||||
ar_handle->accept = add_to_list(NULL, "control.tar.gz");
|
ar_handle->accept = llist_add_to(NULL, "control.tar.gz");
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||||
ar_handle->accept = add_to_list(ar_handle->accept, "control.tar.bz2");
|
ar_handle->accept = llist_add_to(ar_handle->accept, "control.tar.bz2");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Assign the tar handle as a subarchive of the ar handle */
|
/* Assign the tar handle as a subarchive of the ar handle */
|
||||||
@ -1353,10 +1353,10 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
|
|||||||
|
|
||||||
/* We dont care about data.tar.* or debian-binary, just control.tar.* */
|
/* We dont care about data.tar.* or debian-binary, just control.tar.* */
|
||||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||||
tar_handle->accept = add_to_list(NULL, "data.tar.gz");
|
tar_handle->accept = llist_add_to(NULL, "data.tar.gz");
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||||
tar_handle->accept = add_to_list(ar_handle->accept, "data.tar.bz2");
|
tar_handle->accept = llist_add_to(ar_handle->accept, "data.tar.bz2");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Assign the tar handle as a subarchive of the ar handle */
|
/* Assign the tar handle as a subarchive of the ar handle */
|
||||||
@ -1365,7 +1365,7 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, const llist_t *accept)
|
static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *accept)
|
||||||
{
|
{
|
||||||
ar_handle->sub_archive->action_data = data_extract_to_buffer;
|
ar_handle->sub_archive->action_data = data_extract_to_buffer;
|
||||||
ar_handle->sub_archive->accept = accept;
|
ar_handle->sub_archive->accept = accept;
|
||||||
@ -1532,10 +1532,10 @@ int dpkg_main(int argc, char **argv)
|
|||||||
deb_file[deb_count] = (deb_file_t *) xmalloc(sizeof(deb_file_t));
|
deb_file[deb_count] = (deb_file_t *) xmalloc(sizeof(deb_file_t));
|
||||||
if (dpkg_opt & dpkg_opt_filename) {
|
if (dpkg_opt & dpkg_opt_filename) {
|
||||||
archive_handle_t *archive_handle;
|
archive_handle_t *archive_handle;
|
||||||
const llist_t *control_list = NULL;
|
llist_t *control_list = NULL;
|
||||||
|
|
||||||
/* Extract the control file */
|
/* Extract the control file */
|
||||||
control_list = add_to_list(NULL, "./control");
|
control_list = llist_add_to(NULL, "./control");
|
||||||
archive_handle = init_archive_deb_ar(argv[optind]);
|
archive_handle = init_archive_deb_ar(argv[optind]);
|
||||||
init_archive_deb_control(archive_handle);
|
init_archive_deb_control(archive_handle);
|
||||||
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
|
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
|
||||||
|
@ -27,7 +27,7 @@ extern int dpkg_deb_main(int argc, char **argv)
|
|||||||
archive_handle_t *tar_archive;
|
archive_handle_t *tar_archive;
|
||||||
int opt = 0;
|
int opt = 0;
|
||||||
#ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
#ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||||
const llist_t *control_tar_llist = NULL;
|
llist_t *control_tar_llist = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Setup the tar archive handle */
|
/* Setup the tar archive handle */
|
||||||
@ -39,16 +39,16 @@ extern int dpkg_deb_main(int argc, char **argv)
|
|||||||
ar_archive->filter = filter_accept_list_reassign;
|
ar_archive->filter = filter_accept_list_reassign;
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||||
ar_archive->accept = add_to_list(NULL, "data.tar.gz");
|
ar_archive->accept = llist_add_to(NULL, "data.tar.gz");
|
||||||
# ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
# ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||||
control_tar_llist = add_to_list(NULL, "control.tar.gz");
|
control_tar_llist = llist_add_to(NULL, "control.tar.gz");
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||||
ar_archive->accept = add_to_list(ar_archive->accept, "data.tar.bz2");
|
ar_archive->accept = llist_add_to(ar_archive->accept, "data.tar.bz2");
|
||||||
# ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
# ifndef CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||||
control_tar_llist = add_to_list(control_tar_llist, "control.tar.bz2");
|
control_tar_llist = llist_add_to(control_tar_llist, "control.tar.bz2");
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ extern int dpkg_deb_main(int argc, char **argv)
|
|||||||
* it should accept a second argument which specifies a
|
* it should accept a second argument which specifies a
|
||||||
* specific field to print */
|
* specific field to print */
|
||||||
ar_archive->accept = control_tar_llist;
|
ar_archive->accept = control_tar_llist;
|
||||||
tar_archive->accept = add_to_list(NULL, "./control");;
|
tar_archive->accept = llist_add_to(NULL, "./control");;
|
||||||
tar_archive->filter = filter_accept_list;
|
tar_archive->filter = filter_accept_list;
|
||||||
tar_archive->action_data = data_extract_to_stdout;
|
tar_archive->action_data = data_extract_to_stdout;
|
||||||
break;
|
break;
|
||||||
|
@ -53,7 +53,6 @@ LIBUNARCHIVE-y:= \
|
|||||||
\
|
\
|
||||||
archive_copy_file.o \
|
archive_copy_file.o \
|
||||||
\
|
\
|
||||||
add_to_list.o \
|
|
||||||
check_header_gzip.o \
|
check_header_gzip.o \
|
||||||
check_trailer_gzip.o \
|
check_trailer_gzip.o \
|
||||||
data_align.o \
|
data_align.o \
|
||||||
|
@ -171,7 +171,7 @@ extern char get_header_tar(archive_handle_t *archive_handle)
|
|||||||
archive_handle->action_header(archive_handle->file_header);
|
archive_handle->action_header(archive_handle->file_header);
|
||||||
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
|
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
|
||||||
archive_handle->action_data(archive_handle);
|
archive_handle->action_data(archive_handle);
|
||||||
archive_handle->passed = add_to_list(archive_handle->passed, archive_handle->file_header->name);
|
archive_handle->passed = llist_add_to(archive_handle->passed, archive_handle->file_header->name);
|
||||||
} else {
|
} else {
|
||||||
data_skip(archive_handle);
|
data_skip(archive_handle);
|
||||||
}
|
}
|
||||||
|
@ -583,13 +583,13 @@ static inline int writeTarFile(const char *tarName, const int verboseFlag,
|
|||||||
#endif /* tar_create */
|
#endif /* tar_create */
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_TAR_EXCLUDE
|
#ifdef CONFIG_FEATURE_TAR_EXCLUDE
|
||||||
static const llist_t *append_file_list_to_list(const char *filename, const llist_t *list)
|
static llist_t *append_file_list_to_list(const char *filename, llist_t *list)
|
||||||
{
|
{
|
||||||
FILE *src_stream = xfopen(filename, "r");
|
FILE *src_stream = xfopen(filename, "r");
|
||||||
char *line;
|
char *line;
|
||||||
while((line = get_line_from_file(src_stream)) != NULL) {
|
while((line = get_line_from_file(src_stream)) != NULL) {
|
||||||
chomp(line);
|
chomp(line);
|
||||||
list = add_to_list(list, line);
|
list = llist_add_to(list, line);
|
||||||
}
|
}
|
||||||
fclose(src_stream);
|
fclose(src_stream);
|
||||||
|
|
||||||
@ -708,7 +708,7 @@ int tar_main(int argc, char **argv)
|
|||||||
/* Setup an array of filenames to work with */
|
/* Setup an array of filenames to work with */
|
||||||
/* TODO: This is the same as in ar, seperate function ? */
|
/* TODO: This is the same as in ar, seperate function ? */
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
tar_handle->accept = add_to_list(tar_handle->accept, argv[optind]);
|
tar_handle->accept = llist_add_to(tar_handle->accept, argv[optind]);
|
||||||
optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ extern int unzip_main(int argc, char **argv)
|
|||||||
|
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
archive_handle->filter = filter_accept_list;
|
archive_handle->filter = filter_accept_list;
|
||||||
archive_handle->accept = add_to_list(archive_handle->accept, argv[optind]);
|
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||||
optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,4 +357,10 @@ typedef struct {
|
|||||||
extern procps_status_t * procps_scan(int save_user_arg0);
|
extern procps_status_t * procps_scan(int save_user_arg0);
|
||||||
extern unsigned short compare_string_array(const char *string_array[], const char *key);
|
extern unsigned short compare_string_array(const char *string_array[], const char *key);
|
||||||
|
|
||||||
|
typedef struct llist_s {
|
||||||
|
char *data;
|
||||||
|
struct llist_s *link;
|
||||||
|
} llist_t;
|
||||||
|
extern llist_t *llist_add_to(llist_t *old_head, char *new_item);
|
||||||
|
|
||||||
#endif /* __LIBCONFIG_H__ */
|
#endif /* __LIBCONFIG_H__ */
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#define ARCHIVE_EXTRACT_QUIET 8
|
#define ARCHIVE_EXTRACT_QUIET 8
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "libbb.h"
|
||||||
|
|
||||||
typedef struct file_headers_s {
|
typedef struct file_headers_s {
|
||||||
char *name;
|
char *name;
|
||||||
@ -21,17 +21,12 @@ typedef struct file_headers_s {
|
|||||||
dev_t device;
|
dev_t device;
|
||||||
} file_header_t;
|
} file_header_t;
|
||||||
|
|
||||||
typedef struct llist_s {
|
|
||||||
const char *data;
|
|
||||||
const struct llist_s *link;
|
|
||||||
} llist_t;
|
|
||||||
|
|
||||||
typedef struct archive_handle_s {
|
typedef struct archive_handle_s {
|
||||||
/* define if the header and data compenent should processed */
|
/* define if the header and data compenent should processed */
|
||||||
char (*filter)(struct archive_handle_s *);
|
char (*filter)(struct archive_handle_s *);
|
||||||
const llist_t *accept;
|
llist_t *accept;
|
||||||
const llist_t *reject;
|
llist_t *reject;
|
||||||
const llist_t *passed; /* List of files that have successfully been worked on */
|
llist_t *passed; /* List of files that have successfully been worked on */
|
||||||
|
|
||||||
/* Contains the processed header entry */
|
/* Contains the processed header entry */
|
||||||
file_header_t *file_header;
|
file_header_t *file_header;
|
||||||
@ -103,7 +98,6 @@ extern void archive_xread_all(const archive_handle_t *archive_handle, void *buf,
|
|||||||
extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count);
|
extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count);
|
||||||
|
|
||||||
extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary);
|
extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary);
|
||||||
extern const llist_t *add_to_list(const llist_t *old_head, const char *new_item);
|
|
||||||
extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd);
|
extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd);
|
||||||
extern const llist_t *find_list_entry(const llist_t *list, const char *filename);
|
extern const llist_t *find_list_entry(const llist_t *list, const char *filename);
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ LIBBB_SRC:= \
|
|||||||
get_last_path_component.c get_line_from_file.c herror_msg.c \
|
get_last_path_component.c get_line_from_file.c herror_msg.c \
|
||||||
herror_msg_and_die.c human_readable.c inet_common.c inode_hash.c \
|
herror_msg_and_die.c human_readable.c inet_common.c inode_hash.c \
|
||||||
interface.c isdirectory.c kernel_version.c last_char_is.c libc5.c \
|
interface.c isdirectory.c kernel_version.c last_char_is.c libc5.c \
|
||||||
loop.c make_directory.c mode_string.c \
|
llist_add_to.c loop.c make_directory.c mode_string.c \
|
||||||
module_syscalls.c mtab.c mtab_file.c my_getgrgid.c my_getgrnam.c \
|
module_syscalls.c mtab.c mtab_file.c my_getgrgid.c my_getgrnam.c \
|
||||||
my_getpwnam.c my_getpwnamegid.c my_getpwuid.c obscure.c parse_mode.c \
|
my_getpwnam.c my_getpwnamegid.c my_getpwuid.c obscure.c parse_mode.c \
|
||||||
parse_number.c perror_msg.c perror_msg_and_die.c print_file.c \
|
parse_number.c perror_msg.c perror_msg_and_die.c print_file.c \
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "unarchive.h"
|
#include "unarchive.h"
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
extern const llist_t *add_to_list(const llist_t *old_head, const char *new_item)
|
extern llist_t *llist_add_to(llist_t *old_head, char *new_item)
|
||||||
{
|
{
|
||||||
llist_t *new_head;
|
llist_t *new_head;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user