diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-16 15:16:05 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-16 15:16:05 +0300 |
commit | 6b471bb614beaeadcfa08008918ef6a2d93ac7e0 (patch) | |
tree | fd46188956a5fb8c22801dc49efa5e8730b657c6 /src/io.c | |
parent | 0f6d96a4f5a904fd95b96e13715b50befa6a0ee9 (diff) | |
download | apk-tools-6b471bb614beaeadcfa08008918ef6a2d93ac7e0.tar.gz apk-tools-6b471bb614beaeadcfa08008918ef6a2d93ac7e0.tar.bz2 apk-tools-6b471bb614beaeadcfa08008918ef6a2d93ac7e0.tar.xz apk-tools-6b471bb614beaeadcfa08008918ef6a2d93ac7e0.zip |
various: new style index generation
change the index generation to do old index, or the new style index
where package identity is sha1 of control block and it's contained
within an .tar.gz to allow signing in future.
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -578,6 +578,45 @@ struct apk_ostream *apk_ostream_to_file(const char *file, mode_t mode) return apk_ostream_to_fd(fd); } +struct apk_counter_ostream { + struct apk_ostream os; + off_t *counter; +}; + +static size_t co_write(void *stream, const void *ptr, size_t size) +{ + struct apk_counter_ostream *cos = + container_of(stream, struct apk_counter_ostream, os); + + *cos->counter += size; + return size; +} + +static void co_close(void *stream) +{ + struct apk_counter_ostream *cos = + container_of(stream, struct apk_counter_ostream, os); + + free(cos); +} + +struct apk_ostream *apk_ostream_counter(off_t *counter) +{ + struct apk_counter_ostream *cos; + + cos = malloc(sizeof(struct apk_counter_ostream)); + if (cos == NULL) + return NULL; + + *cos = (struct apk_counter_ostream) { + .os.write = co_write, + .os.close = co_close, + .counter = counter, + }; + + return &cos->os; +} + size_t apk_ostream_write_string(struct apk_ostream *os, const char *string) { size_t len; |