summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-13 09:49:10 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-13 10:48:09 (EDT)
commit6c5ea040feeab83ad27f58b5c5c5edb699fa545e (patch)
tree7d361ebffe4a6c250bc142a5e18b5f99ef848d5e
parent305667ec3b4816c44286de2a3177e0862596b655 (diff)
design.txt: Rework
-rw-r--r--design.txt49
1 files changed, 37 insertions, 12 deletions
diff --git a/design.txt b/design.txt
index 844e9cb..9fc1879 100644
--- a/design.txt
+++ b/design.txt
@@ -1,31 +1,56 @@
-file_read(buffer, size, user_data)
+file_read(user_data, buffer, *size)
file = user_data
- return fread(buffer, 1, size, file)
+ *size = fread(buffer, 1, *size, file)
extract(file_name, outer_member, inner_action)
- file = fopen(file_name, "rb")
+ FILE *file = fopen(file_name, "rb")
outer_gzip = gzip_init(&file_read, file)
outer_ustar = ustar_init(outer_gzip)
ustar_seek(outer_ustar, outer_member)
- inner_gzip = gzip_init(ustar_next_data_record, outer_ustar)
+ inner_gzip = gzip_init(&ustar_read, outer_ustar)
inner_ustar = ustar_init(inner_gzip)
inner_action(inner_ustar)
-print_data(data, size)
- fwrite(data, 1, size, stdout)
-
read_control(inner_ustar)
+ unsigned char buffer[512]
+ size
ustar_seek(inner_ustar, "control")
- ustar_read(inner_ustar, &print_data)
-
-print_member(member)
- printf("%s", member->name)
+ while ((ret = ustar_read(inner_ustar, buffer, &size)) == OK)
+ fwrite(buffer, 1 size, stdout)
+ if ret == ERROR
+ return
list_members(inner_ustar)
- ustar_list(inner_ustar, &print_member)
+ ustar_member member
+ while ((ret = ustar_list(inner_ustar, &member)) == OK)
+ printf("%s", member.name)
+ if ret == ERROR
+ return
main()
if -I
extract(argv[1], "control.tar.gz", &read_control)
else if -c
extract(argv[1], "data.tar.gz", &list_members)
+
+---
+
+struct gzip *
+gzip_init(int (*read)(void *, char *, size_t *), void *user_data)
+
+int
+gzip_read(struct gzip *gzip, void *record)
+
+---
+
+struct ustar *
+ustar_init(struct gzip *gzip)
+
+int
+ustar_list(struct ustar *ustar, ustar_member *member)
+
+int
+ustar_seek(ustruct star *ustar, const char *member)
+
+int
+ustar_read(struct ustar *ustar, char *buffer, size_t *size)