apk-tools/src/apk_io.h

74 lines
2.2 KiB
C
Raw Normal View History

2008-11-07 15:11:08 +00:00
/* apk_io.h - Alpine Package Keeper (APK)
*
* Copyright (C) 2008 Timo Teräs <timo.teras@iki.fi>
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation. See http://www.gnu.org/ for details.
*/
#ifndef APK_IO
#define APK_IO
#include "apk_defines.h"
#include "apk_blob.h"
struct apk_file_info {
char *name;
char *link_target;
char *uname;
char *gname;
off_t size;
uid_t uid;
gid_t gid;
mode_t mode;
time_t mtime;
dev_t device;
csum_t csum;
};
2008-11-07 15:11:08 +00:00
struct apk_istream {
size_t (*read)(void *stream, void *ptr, size_t size);
void (*close)(void *stream);
};
struct apk_bstream {
size_t (*read)(void *stream, void **ptr);
2008-11-28 14:28:54 +00:00
void (*close)(void *stream, csum_p csum, size_t *size);
2008-11-07 15:11:08 +00:00
};
2008-11-28 14:28:54 +00:00
struct apk_ostream {
size_t (*write)(void *stream, const void *buf, size_t size);
void (*close)(void *stream);
};
2009-01-06 17:59:50 +00:00
struct apk_istream *apk_bstream_gunzip(struct apk_bstream *, int);
2008-11-28 14:28:54 +00:00
struct apk_ostream *apk_ostream_gzip(struct apk_ostream *);
2008-11-27 19:06:45 +00:00
2008-11-07 15:11:08 +00:00
struct apk_istream *apk_istream_from_fd(int fd);
struct apk_istream *apk_istream_from_file(const char *file);
2008-11-28 14:28:54 +00:00
struct apk_istream *apk_istream_from_file_gz(const char *file);
2008-11-28 13:03:27 +00:00
struct apk_istream *apk_istream_from_url(const char *url);
2009-01-15 10:55:26 +00:00
struct apk_istream *apk_istream_from_url_gz(const char *url);
2008-11-07 15:11:08 +00:00
size_t apk_istream_skip(struct apk_istream *istream, size_t size);
size_t apk_istream_splice(void *stream, int fd, size_t size,
apk_progress_cb cb, void *cb_ctx);
2008-11-07 15:11:08 +00:00
struct apk_bstream *apk_bstream_from_istream(struct apk_istream *istream);
struct apk_bstream *apk_bstream_from_fd(int fd);
2008-11-28 13:03:27 +00:00
struct apk_bstream *apk_bstream_from_file(const char *file);
struct apk_bstream *apk_bstream_from_url(const char *url);
2008-11-07 15:11:08 +00:00
2008-11-28 14:28:54 +00:00
struct apk_ostream *apk_ostream_to_fd(int fd);
struct apk_ostream *apk_ostream_to_file(const char *file, mode_t mode);
struct apk_ostream *apk_ostream_to_file_gz(const char *file, mode_t mode);
2009-04-16 14:05:27 +00:00
size_t apk_ostream_write_string(struct apk_ostream *ostream, const char *string);
2008-11-27 19:06:45 +00:00
2008-11-07 15:11:08 +00:00
apk_blob_t apk_blob_from_istream(struct apk_istream *istream, size_t size);
2008-11-27 14:59:04 +00:00
apk_blob_t apk_blob_from_file(const char *file);
2008-11-07 15:11:08 +00:00
int apk_file_get_info(const char *filename, struct apk_file_info *fi);
2008-11-07 15:11:08 +00:00
#endif