diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-10-25 14:57:14 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-10-25 14:57:14 +0000 |
commit | e9fc78157043a07adae6ed39939e269b6b3524d0 (patch) | |
tree | 9507853496d8e563687a06a99a37f4bab704e2f3 | |
parent | 633f153808c3ec316f023cdb72b98c4e5a929bca (diff) | |
download | busybox-w32-e9fc78157043a07adae6ed39939e269b6b3524d0.tar.gz busybox-w32-e9fc78157043a07adae6ed39939e269b6b3524d0.tar.bz2 busybox-w32-e9fc78157043a07adae6ed39939e269b6b3524d0.zip |
libunarchive, and recovery from my previous commit
-rw-r--r-- | include/libbb.h | 77 | ||||
-rw-r--r-- | include/unarchive.h | 42 |
2 files changed, 42 insertions, 77 deletions
diff --git a/include/libbb.h b/include/libbb.h index 90b1c25c6..2dcfa1f4d 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -212,39 +212,6 @@ char *last_char_is(const char *s, int c); | |||
212 | 212 | ||
213 | extern long arith (const char *startbuf, int *errcode); | 213 | extern long arith (const char *startbuf, int *errcode); |
214 | 214 | ||
215 | typedef struct file_headers_s { | ||
216 | char *name; | ||
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); | ||
228 | |||
229 | enum extract_functions_e { | ||
230 | extract_verbose_list = 1, | ||
231 | extract_list = 2, | ||
232 | extract_one_to_buffer = 4, | ||
233 | extract_to_stdout = 8, | ||
234 | extract_all_to_fs = 16, | ||
235 | extract_preserve_date = 32, | ||
236 | extract_data_tar_gz = 64, | ||
237 | extract_control_tar_gz = 128, | ||
238 | extract_unzip_only = 256, | ||
239 | extract_unconditional = 512, | ||
240 | extract_create_leading_dirs = 1024, | ||
241 | extract_quiet = 2048, | ||
242 | extract_exclude_list = 4096 | ||
243 | }; | ||
244 | char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *), | ||
245 | const int extract_function, const char *prefix, char **include_name, char **exclude_name); | ||
246 | char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, | ||
247 | const char *prefix, const char *filename); | ||
248 | int read_package_field(const char *package_buffer, char **field_name, char **field_value); | 215 | int read_package_field(const char *package_buffer, char **field_name, char **field_value); |
249 | char *fgets_str(FILE *file, const char *terminating_string); | 216 | char *fgets_str(FILE *file, const char *terminating_string); |
250 | 217 | ||
@@ -318,49 +285,5 @@ extern const char * const can_not_create_raw_socket; | |||
318 | /* The following devices are the same on devfs and non-devfs systems. */ | 285 | /* The following devices are the same on devfs and non-devfs systems. */ |
319 | #define CURRENT_TTY "/dev/tty" | 286 | #define CURRENT_TTY "/dev/tty" |
320 | #define CONSOLE_DEV "/dev/console" | 287 | #define CONSOLE_DEV "/dev/console" |
321 | typedef struct deb_file_s { | ||
322 | char *filename; | ||
323 | char *control_file; | ||
324 | unsigned short node:14; | ||
325 | } deb_file_t; | ||
326 | |||
327 | typedef struct node_s { | ||
328 | /* This are always used by dpkg */ | ||
329 | unsigned short name:14; | ||
330 | unsigned short epoch:4; | ||
331 | unsigned short version:12; | ||
332 | unsigned short revision:8; | ||
333 | unsigned short essential:1; | ||
334 | unsigned short state_want:3; | ||
335 | unsigned short state_flag:2; | ||
336 | unsigned short state_status:3; | ||
337 | unsigned short pool_flag:2; | ||
338 | unsigned short source:11; | ||
339 | unsigned short filename:11; | ||
340 | unsigned short num_of_edges:7; | ||
341 | unsigned short *edge; | ||
342 | #ifdef BB_FEATURE_DPKG_LIST_SHORT_DESCRIPTIONS | ||
343 | char *description_short; /* This is used by dpkg -l */ | ||
344 | #endif | ||
345 | } node_t; | ||
346 | |||
347 | /* All these are in deb_functs.c */ | ||
348 | extern void deb_initialise_hashtables(short type); | ||
349 | extern void write_status_file(deb_file_t **deb_file); | ||
350 | extern void configure_package(deb_file_t *deb_file); | ||
351 | extern void unpack_package(deb_file_t *deb_file); | ||
352 | extern void remove_package(const unsigned int node_num); | ||
353 | extern void index_status_file(const char *filename); | ||
354 | extern void find_deps(const char *package_name); | ||
355 | extern void purge_package(const unsigned int node_num); | ||
356 | extern node_t *parse_package_metadata(char *control_buffer); | ||
357 | extern unsigned short search_node_ht(node_t *search_node, unsigned short operator); | ||
358 | extern void add_node(node_t *node, unsigned short node_num); | ||
359 | extern node_t *initialise_node(const char *package_name); | ||
360 | extern char *get_name_ht(unsigned short name_num); | ||
361 | extern void free_hashtables(void); | ||
362 | extern node_t *get_node_ht(unsigned short node_num); | ||
363 | extern char *version_revision(unsigned short version_num, unsigned short revision_num); | ||
364 | extern void free_node(node_t *node); | ||
365 | 288 | ||
366 | #endif /* __LIBCONFIG_H__ */ | 289 | #endif /* __LIBCONFIG_H__ */ |
diff --git a/include/unarchive.h b/include/unarchive.h new file mode 100644 index 000000000..c4400981d --- /dev/null +++ b/include/unarchive.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #include <stdio.h> // for off_t | ||
2 | |||
3 | enum extract_functions_e { | ||
4 | extract_verbose_list = 1, | ||
5 | extract_list = 2, | ||
6 | extract_one_to_buffer = 4, | ||
7 | extract_to_stdout = 8, | ||
8 | extract_all_to_fs = 16, | ||
9 | extract_preserve_date = 32, | ||
10 | extract_data_tar_gz = 64, | ||
11 | extract_control_tar_gz = 128, | ||
12 | extract_unzip_only = 256, | ||
13 | extract_unconditional = 512, | ||
14 | extract_create_leading_dirs = 1024, | ||
15 | extract_quiet = 2048, | ||
16 | extract_exclude_list = 4096 | ||
17 | }; | ||
18 | |||
19 | typedef struct file_headers_s { | ||
20 | char *name; | ||
21 | char *link_name; | ||
22 | off_t size; | ||
23 | uid_t uid; | ||
24 | gid_t gid; | ||
25 | mode_t mode; | ||
26 | time_t mtime; | ||
27 | dev_t device; | ||
28 | } file_header_t; | ||
29 | |||
30 | file_header_t *get_header_ar(FILE *in_file); | ||
31 | file_header_t *get_header_cpio(FILE *src_stream); | ||
32 | file_header_t *get_header_tar(FILE *tar_stream); | ||
33 | |||
34 | void seek_sub_file(FILE *src_stream, const int count); | ||
35 | |||
36 | extern off_t archive_offset; | ||
37 | |||
38 | char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_headers)(FILE *), | ||
39 | const int extract_function, const char *prefix, char **include_name, char **exclude_name); | ||
40 | |||
41 | char *deb_extract(const char *package_filename, FILE *out_stream, const int extract_function, | ||
42 | const char *prefix, const char *filename); | ||