archive_read_format_7zip_has_encrypted_entries(struct archive_read *a)
{
if (a && a->format) {
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
if (zip) {
return zip->has_encrypted_entries;
}
archive_read_format_7zip_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
struct _7zip_entry *zip_entry;
int r, ret = ARCHIVE_OK;
struct _7z_folder *folder = 0;
archive_read_format_7zip_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format->data;
ssize_t bytes;
int ret = ARCHIVE_OK;
- zip = (struct _7zip *)(a->format->data);
-
if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
zip->has_encrypted_entries = 0;
}
static int
archive_read_format_7zip_read_data_skip(struct archive_read *a)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format->data;
int r;
- zip = (struct _7zip *)(a->format->data);
-
if (zip->pack_stream_bytes_unconsumed)
read_consume(a);
static int
archive_read_format_7zip_cleanup(struct archive_read *a)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format->data;
- zip = (struct _7zip *)(a->format->data);
free_StreamsInfo(&(zip->si));
free(zip->entries);
free(zip->entry_names);
free(zip->sub_stream_buff[2]);
free(zip->tmp_stream_buff);
free(zip);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
static int
read_consume(struct archive_read *a)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
if (zip->pack_stream_bytes_unconsumed) {
int64_t r;
ppmd_read(void *p)
{
struct archive_read *a = ((IByteIn*)p)->a;
- struct _7zip *zip = (struct _7zip *)(a->format->data);
+ struct _7zip *zip = a->format->data;
Byte b;
if (zip->ppstream.avail_in == 0) {
static int
read_Folder(struct archive_read *a, struct _7z_folder *f)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const unsigned char *p;
size_t numInStreamsTotal = 0;
size_t numOutStreamsTotal = 0;
static int
read_CodersInfo(struct archive_read *a, struct _7z_coders_info *ci)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const unsigned char *p;
struct _7z_digests digest;
size_t dataStreamIndex, i;
static int
read_StreamsInfo(struct archive_read *a, struct _7z_stream_info *si)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const unsigned char *p;
size_t i;
read_Header(struct archive_read *a, struct _7z_header_info *h,
int check_header_id)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const unsigned char *p;
struct _7z_folder *folders;
struct _7z_stream_info *si = &(zip->si);
static int
read_Times(struct archive_read *a, int type)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const unsigned char *p;
struct _7zip_entry *entries = zip->entries;
unsigned char *timeBools = NULL;
static int
decode_encoded_header_info(struct archive_read *a, struct _7z_stream_info *si)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
int64_t pi_end;
errno = 0;
static const unsigned char *
header_bytes(struct archive_read *a, size_t rbytes)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const unsigned char *p;
if ((uint64_t)zip->header_bytes_remaining < rbytes)
get_uncompressed_data(struct archive_read *a, const void **buff, size_t size,
size_t minimum)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
ssize_t bytes_avail;
if (zip->codec == _7Z_COPY && zip->codec2 == -1) {
static ssize_t
extract_pack_stream(struct archive_read *a, size_t minimum)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
ssize_t bytes_avail;
int r;
static int
seek_pack(struct archive_read *a)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
int64_t pack_offset;
if (zip->pack_stream_remaining == 0) {
read_stream(struct archive_read *a, const void **buff, size_t size,
size_t minimum)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
int64_t skip_bytes = 0;
ssize_t r;
setup_decode_folder(struct archive_read *a, struct _7z_folder *folder,
int header)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const struct _7z_coder *coder1, *coder2;
const char *cname = (header)?"archive header":"file content";
size_t i;
static int
skip_stream(struct archive_read *a, int64_t skip_bytes)
{
- struct _7zip *zip = (struct _7zip *)a->format->data;
+ struct _7zip *zip = a->format->data;
const void *p;
int64_t skipped_bytes;
int64_t bytes = skip_bytes;
static int
archive_read_format_ar_cleanup(struct archive_read *a)
{
- struct ar *ar = (struct ar *)(a->format->data);
+ struct ar *ar = a->format->data;
free(ar->strtab);
free(ar);
archive_read_format_ar_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct ar *ar = (struct ar *)(a->format->data);
+ struct ar *ar = a->format->data;
int64_t unconsumed;
const void *header_data;
int ret;
archive_read_format_ar_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
- struct ar *ar = (struct ar *)(a->format->data);
+ struct ar *ar = a->format->data;
ssize_t bytes_read;
if (ar->entry_bytes_unconsumed) {
static int
archive_read_format_ar_skip(struct archive_read *a)
{
- struct ar *ar = (struct ar *)(a->format->data);
+ struct ar *ar = a->format->data;
if (__archive_read_consume(a,
ar->entry_bytes_remaining + ar->entry_padding +
static int
ar_parse_gnu_filename_table(struct archive_read *a)
{
- struct ar *ar = (struct ar *)(a->format->data);
+ struct ar *ar = a->format->data;
char *p;
size_t size;
archive_read_format_cab_options(struct archive_read *a,
const char *key, const char *val)
{
- struct cab *cab;
+ struct cab *cab = a->format->data;
int ret = ARCHIVE_FAILED;
- cab = (struct cab *)(a->format->data);
if (strcmp(key, "hdrcharset") == 0) {
if (val == NULL || val[0] == 0)
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
static int
cab_read_header(struct archive_read *a)
{
+ struct cab *cab = a->format->data;
const char *p;
- struct cab *cab;
struct cfheader *hd;
size_t bytes, len, maxlen, used;
ssize_t avail;
if ((p = __archive_read_ahead(a, 42, NULL)) == NULL)
return (truncated_error(a));
- cab = (struct cab *)(a->format->data);
if (cab->found_header == 0 &&
p[0] == 'M' && p[1] == 'Z') {
/* This is an executable? Must be self-extracting... */
archive_read_format_cab_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct cab *cab;
+ struct cab *cab = a->format->data;
struct cfheader *hd;
struct cffolder *prev_folder;
struct cffile *file;
struct archive_string_conv *sconv;
int err = ARCHIVE_OK, r;
-
- cab = (struct cab *)(a->format->data);
+
if (cab->found_header == 0) {
err = cab_read_header(a);
if (err < ARCHIVE_WARN)
archive_read_format_cab_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
int r;
switch (cab->entry_cffile->folder) {
static void
cab_checksum_update(struct archive_read *a, size_t bytes)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata = cab->entry_cfdata;
const unsigned char *p;
size_t sumbytes;
static int
cab_checksum_finish(struct archive_read *a)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata = cab->entry_cfdata;
int l;
static int
cab_next_cfdata(struct archive_read *a)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata = cab->entry_cfdata;
/* There are remaining bytes in current CFDATA, use it first. */
static const void *
cab_read_ahead_cfdata(struct archive_read *a, ssize_t *avail)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
int err;
err = cab_next_cfdata(a);
static const void *
cab_read_ahead_cfdata_none(struct archive_read *a, ssize_t *avail)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata;
const void *d;
static const void *
cab_read_ahead_cfdata_deflate(struct archive_read *a, ssize_t *avail)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata;
const void *d;
int r, mszip;
static const void *
cab_read_ahead_cfdata_lzx(struct archive_read *a, ssize_t *avail)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata;
const void *d;
int r;
static int64_t
cab_consume_cfdata(struct archive_read *a, int64_t consumed_bytes)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata;
int64_t cbytes, rbytes;
int err;
static int64_t
cab_minimum_consume_cfdata(struct archive_read *a, int64_t consumed_bytes)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfdata *cfdata;
int64_t cbytes, rbytes;
int err;
cab_read_data(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
ssize_t bytes_avail;
if (cab->entry_bytes_remaining == 0) {
static int
archive_read_format_cab_read_data_skip(struct archive_read *a)
{
- struct cab *cab;
+ struct cab *cab = a->format->data;
int64_t bytes_skipped;
int r;
- cab = (struct cab *)(a->format->data);
-
if (cab->end_of_archive)
return (ARCHIVE_EOF);
static int
archive_read_format_cab_cleanup(struct archive_read *a)
{
- struct cab *cab = (struct cab *)(a->format->data);
+ struct cab *cab = a->format->data;
struct cfheader *hd = &cab->cfheader;
uint16_t i;
archive_wstring_free(&cab->ws);
free(cab->uncompressed_buffer);
free(cab);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
static int
archive_read_format_cpio_bid(struct archive_read *a, int best_bid)
{
+ struct cpio *cpio = a->format->data;
const unsigned char *p;
- struct cpio *cpio;
int bid;
(void)best_bid; /* UNUSED */
- cpio = (struct cpio *)(a->format->data);
-
if ((p = __archive_read_ahead(a, 6, NULL)) == NULL)
return (-1);
archive_read_format_cpio_options(struct archive_read *a,
const char *key, const char *val)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format->data;
int ret = ARCHIVE_FAILED;
- cpio = (struct cpio *)(a->format->data);
if (strcmp(key, "compat-2x") == 0) {
/* Handle filenames as libarchive 2.x */
cpio->init_default_conversion = (val != NULL)?1:0;
archive_read_format_cpio_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format->data;
const void *h, *hl;
struct archive_string_conv *sconv;
size_t namelength;
int is_trailer;
int r;
- cpio = (struct cpio *)(a->format->data);
sconv = cpio->opt_sconv;
if (sconv == NULL) {
if (!cpio->init_default_conversion) {
archive_read_format_cpio_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
+ struct cpio *cpio = a->format->data;
ssize_t bytes_read;
- struct cpio *cpio;
-
- cpio = (struct cpio *)(a->format->data);
if (cpio->entry_bytes_unconsumed) {
__archive_read_consume(a, cpio->entry_bytes_unconsumed);
static int
archive_read_format_cpio_skip(struct archive_read *a)
{
- struct cpio *cpio = (struct cpio *)(a->format->data);
+ struct cpio *cpio = a->format->data;
int64_t to_skip = cpio->entry_bytes_remaining + cpio->entry_padding +
cpio->entry_bytes_unconsumed;
static int
archive_read_format_cpio_cleanup(struct archive_read *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format->data;
- cpio = (struct cpio *)(a->format->data);
/* Free inode->name map */
while (cpio->links_head != NULL) {
struct links_entry *lp = cpio->links_head->next;
cpio->links_head = lp;
}
free(cpio);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
static int
archive_read_format_iso9660_bid(struct archive_read *a, int best_bid)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
ssize_t bytes_read;
const unsigned char *p;
int seenTerminator;
if (best_bid > 48)
return (-1);
- iso9660 = (struct iso9660 *)(a->format->data);
-
/*
* Skip the first 32k (reserved area) and get the first
* 8 sectors of the volume descriptor table. Of course,
archive_read_format_iso9660_options(struct archive_read *a,
const char *key, const char *val)
{
- struct iso9660 *iso9660;
-
- iso9660 = (struct iso9660 *)(a->format->data);
+ struct iso9660 *iso9660 = a->format->data;
if (strcmp(key, "joliet") == 0) {
if (val == NULL || strcmp(val, "off") == 0 ||
static int
read_children(struct archive_read *a, struct file_info *parent)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
const unsigned char *b, *p;
struct file_info *multi;
size_t step, skip_size;
- iso9660 = (struct iso9660 *)(a->format->data);
/* flush any remaining bytes from the last round to ensure
* we're positioned */
if (iso9660->entry_bytes_unconsumed) {
archive_read_format_iso9660_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
struct file_info *file;
int r, rd_r = ARCHIVE_OK;
- iso9660 = (struct iso9660 *)(a->format->data);
-
if (!a->archive.archive_format) {
a->archive.archive_format = ARCHIVE_FORMAT_ISO9660;
a->archive.archive_format_name = "ISO9660";
zisofs_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
struct zisofs *zisofs;
const unsigned char *p;
size_t avail;
size_t uncompressed_size;
int r;
- iso9660 = (struct iso9660 *)(a->format->data);
zisofs = &iso9660->entry_zisofs;
p = __archive_read_ahead(a, 1, &bytes_read);
archive_read_format_iso9660_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
+ struct iso9660 *iso9660 = a->format->data;
ssize_t bytes_read;
- struct iso9660 *iso9660;
-
- iso9660 = (struct iso9660 *)(a->format->data);
if (iso9660->entry_bytes_unconsumed) {
__archive_read_consume(a, iso9660->entry_bytes_unconsumed);
static int
archive_read_format_iso9660_cleanup(struct archive_read *a)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
int r = ARCHIVE_OK;
- iso9660 = (struct iso9660 *)(a->format->data);
release_files(iso9660);
free(iso9660->read_ce_req.reqs);
archive_string_free(&iso9660->pathname);
free(iso9660->utf16be_path);
free(iso9660->utf16be_previous_path);
free(iso9660);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (r);
}
parse_file_info(struct archive_read *a, struct file_info *parent,
const unsigned char *isodirrec, size_t reclen)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
struct file_info *file, *filep;
size_t name_len;
const unsigned char *rr_start, *rr_end;
int32_t location;
int flags;
- iso9660 = (struct iso9660 *)(a->format->data);
-
if (reclen != 0)
dr_len = (size_t)isodirrec[DR_length_offset];
/*
parse_rockridge(struct archive_read *a, struct file_info *file,
const unsigned char *p, const unsigned char *end)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
int entry_seen = 0;
- iso9660 = (struct iso9660 *)(a->format->data);
-
while (p + 4 <= end /* Enough space for another entry. */
&& p[0] >= 'A' && p[0] <= 'Z' /* Sanity-check 1st char of name. */
&& p[1] >= 'A' && p[1] <= 'Z' /* Sanity-check 2nd char of name. */
register_CE(struct archive_read *a, int32_t location,
struct file_info *file)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format->data;
struct read_ce_queue *heap;
uint64_t offset, parent_offset;
size_t hole, parent;
- iso9660 = (struct iso9660 *)(a->format->data);
offset = ((uint64_t)location) * (uint64_t)iso9660->logical_block_size;
if (((file->mode & AE_IFMT) == AE_IFREG &&
offset >= file->offset) ||
archive_read_format_lha_options(struct archive_read *a,
const char *key, const char *val)
{
- struct lha *lha;
+ struct lha *lha = a->format->data;
int ret = ARCHIVE_FAILED;
- lha = (struct lha *)(a->format->data);
if (strcmp(key, "hdrcharset") == 0) {
if (val == NULL || val[0] == 0)
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
archive_read_format_lha_read_header(struct archive_read *a,
struct archive_entry *entry)
{
+ struct lha *lha = a->format->data;
struct archive_wstring linkname;
struct archive_wstring pathname;
- struct lha *lha;
const unsigned char *p;
const char *signature;
int err;
if (a->archive.archive_format_name == NULL)
a->archive.archive_format_name = "lha";
- lha = (struct lha *)(a->format->data);
lha->decompress_init = 0;
lha->end_of_entry = 0;
lha->end_of_entry_cleanup = 0;
static int
lha_end_of_entry(struct archive_read *a)
{
- struct lha *lha = (struct lha *)(a->format->data);
+ struct lha *lha = a->format->data;
int r = ARCHIVE_EOF;
if (!lha->end_of_entry_cleanup) {
archive_read_format_lha_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
- struct lha *lha = (struct lha *)(a->format->data);
+ struct lha *lha = a->format->data;
int r;
if (lha->entry_unconsumed) {
lha_read_data_none(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct lha *lha = (struct lha *)(a->format->data);
+ struct lha *lha = a->format->data;
ssize_t bytes_avail;
if (lha->entry_bytes_remaining == 0) {
lha_read_data_lzh(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct lha *lha = (struct lha *)(a->format->data);
+ struct lha *lha = a->format->data;
ssize_t bytes_avail;
int r;
static int
archive_read_format_lha_read_data_skip(struct archive_read *a)
{
- struct lha *lha;
+ struct lha *lha = a->format->data;
int64_t bytes_skipped;
- lha = (struct lha *)(a->format->data);
-
if (lha->entry_unconsumed) {
/* Consume as much as the decompressor actually used. */
__archive_read_consume(a, lha->entry_unconsumed);
static int
archive_read_format_lha_cleanup(struct archive_read *a)
{
- struct lha *lha = (struct lha *)(a->format->data);
+ struct lha *lha = a->format->data;
lzh_decode_free(&(lha->strm));
archive_string_free(&(lha->dirname));
archive_string_free(&(lha->gname));
archive_wstring_free(&(lha->ws));
free(lha);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
archive_read_format_mtree_options(struct archive_read *a,
const char *key, const char *val)
{
- struct mtree *mtree;
+ struct mtree *mtree = a->format->data;
- mtree = (struct mtree *)(a->format->data);
if (strcmp(key, "checkfs") == 0) {
/* Allows to read information missing from the mtree from the file system */
if (val == NULL || val[0] == 0) {
static int
cleanup(struct archive_read *a)
{
- struct mtree *mtree;
+ struct mtree *mtree = a->format->data;
struct mtree_entry *p, *q;
- mtree = (struct mtree *)(a->format->data);
-
/* Close any dangling file descriptor before freeing */
if (mtree->fd >= 0) {
close(mtree->fd);
free(mtree->buff);
free(mtree);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
static int
read_header(struct archive_read *a, struct archive_entry *entry)
{
- struct mtree *mtree;
+ struct mtree *mtree = a->format->data;
char *p;
int r, use_next;
- mtree = (struct mtree *)(a->format->data);
-
if (mtree->fd >= 0) {
close(mtree->fd);
mtree->fd = -1;
read_data(struct archive_read *a, const void **buff, size_t *size,
int64_t *offset)
{
+ struct mtree *mtree = a->format->data;
size_t bytes_to_read;
ssize_t bytes_read;
- struct mtree *mtree;
- mtree = (struct mtree *)(a->format->data);
if (mtree->fd < 0) {
*buff = NULL;
*offset = 0;
static int
skip(struct archive_read *a)
{
- struct mtree *mtree;
+ struct mtree *mtree = a->format->data;
- mtree = (struct mtree *)(a->format->data);
if (mtree->fd >= 0) {
close(mtree->fd);
mtree->fd = -1;
static int
rar_br_fillup(struct archive_read *a, struct rar_br *br)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
int n = CACHE_BITS - br->cache_avail;
for (;;) {
static int
rar_br_preparation(struct archive_read *a, struct rar_br *br)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
if (rar->bytes_remaining > 0) {
br->next_in = rar_read_ahead(a, 1, &(br->avail_in));
ppmd_read(void *p)
{
struct archive_read *a = ((IByteIn*)p)->a;
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
struct rar_br *br = &(rar->br);
Byte b;
if (!rar_br_read_ahead(a, br, 8))
archive_read_format_rar_has_encrypted_entries(struct archive_read *_a)
{
if (_a && _a->format) {
- struct rar * rar = (struct rar *)_a->format->data;
+ struct rar *rar = _a->format->data;
if (rar) {
return rar->has_encrypted_entries;
}
archive_read_format_rar_options(struct archive_read *a,
const char *key, const char *val)
{
- struct rar *rar;
+ struct rar *rar = a->format->data;
int ret = ARCHIVE_FAILED;
- rar = (struct rar *)(a->format->data);
if (strcmp(key, "hdrcharset") == 0) {
if (val == NULL || val[0] == 0)
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
archive_read_format_rar_read_header(struct archive_read *a,
struct archive_entry *entry)
{
+ struct rar *rar = a->format->data;
const void *h;
const char *p;
- struct rar *rar;
int64_t skip;
char head_type;
int ret;
if (a->archive.archive_format_name == NULL)
a->archive.archive_format_name = "RAR";
- rar = (struct rar *)(a->format->data);
-
/*
* It should be sufficient to call archive_read_next_header() for
* a reader to determine if an entry is encrypted or not. If the
archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
int ret;
if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
static int
archive_read_format_rar_read_data_skip(struct archive_read *a)
{
- struct rar *rar;
+ struct rar *rar = a->format->data;
int64_t bytes_skipped;
int ret;
- rar = (struct rar *)(a->format->data);
-
if (rar->bytes_unconsumed > 0) {
/* Consume as much as the decompressor actually used. */
__archive_read_consume(a, rar->bytes_unconsumed);
archive_read_format_rar_seek_data(struct archive_read *a, int64_t offset,
int whence)
{
+ struct rar *rar = a->format->data;
int64_t client_offset, ret;
size_t i;
- struct rar *rar = (struct rar *)(a->format->data);
if (rar->compression_method == COMPRESS_METHOD_STORE)
{
static int
archive_read_format_rar_cleanup(struct archive_read *a)
{
- struct rar *rar;
+ struct rar *rar = a->format->data;
- rar = (struct rar *)(a->format->data);
free_codes(a);
clear_filters(&rar->filters);
free(rar->filename);
free(rar->lzss.window);
__archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
free(rar);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
read_header(struct archive_read *a, struct archive_entry *entry,
char head_type)
{
+ struct rar *rar = a->format->data;
const void *h;
const char *p, *endp;
- struct rar *rar;
struct rar_header rar_header;
struct rar_file_header file_header;
int64_t header_size;
char *newptr;
size_t newsize;
- rar = (struct rar *)(a->format->data);
-
/* Setup a string conversion object for non-rar-unicode filenames. */
sconv = rar->opt_sconv;
if (sconv == NULL) {
read_symlink_stored(struct archive_read *a, struct archive_entry *entry,
struct archive_string_conv *sconv)
{
+ struct rar *rar = a->format->data;
const void *h;
const char *p;
- struct rar *rar;
int ret = (ARCHIVE_OK);
- rar = (struct rar *)(a->format->data);
if ((uintmax_t)rar->packed_size > SIZE_MAX)
{
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
read_data_stored(struct archive_read *a, const void **buff, size_t *size,
int64_t *offset)
{
- struct rar *rar;
+ struct rar *rar = a->format->data;
ssize_t bytes_avail;
- rar = (struct rar *)(a->format->data);
if (rar->bytes_remaining == 0 &&
!(rar->main_flags & MHD_VOLUME && rar->file_flags & FHD_SPLIT_AFTER))
{
if (looper++ > MAX_COMPRESS_DEPTH)
return (ARCHIVE_FAILED);
- struct rar *rar;
+ struct rar *rar = a->format->data;
int64_t start, end;
size_t bs;
int ret = (ARCHIVE_OK), sym, code, lzss_offset, length, i;
- rar = (struct rar *)(a->format->data);
-
do {
if (!rar->valid)
return (ARCHIVE_FAILED);
static int
parse_codes(struct archive_read *a)
{
+ struct rar *rar = a->format->data;
int i, j, val, n, r;
unsigned char bitlengths[MAX_SYMBOLS], zerocount, ppmd_flags;
unsigned int maxorder;
struct huffman_code precode;
- struct rar *rar = (struct rar *)(a->format->data);
struct rar_br *br = &(rar->br);
free_codes(a);
static void
free_codes(struct archive_read *a)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
free(rar->maincode.tree);
free(rar->offsetcode.tree);
free(rar->lowoffsetcode.tree);
static int
read_next_symbol(struct archive_read *a, struct huffman_code *code)
{
+ struct rar *rar = a->format->data;
unsigned char bit;
unsigned int bits;
int length, value, node;
- struct rar *rar;
struct rar_br *br;
if (!code->table)
return -1;
}
- rar = (struct rar *)(a->format->data);
br = &(rar->br);
/* Look ahead (peek) at bits */
static const unsigned char shortbits[] =
{ 2, 2, 3, 4, 5, 6, 6, 6 };
+ struct rar *rar = a->format->data;
int symbol, offs, len, offsindex, lensymbol, i, offssymbol, lowoffsetsymbol;
unsigned char newfile;
- struct rar *rar = (struct rar *)(a->format->data);
struct rar_br *br = &(rar->br);
if (rar->filters.filterstart < *end)
copy_from_lzss_window(struct archive_read *a, uint8_t *buffer,
int64_t startpos, int length)
{
+ struct rar *rar = a->format->data;
int windowoffs, firstpart;
- struct rar *rar = (struct rar *)(a->format->data);
windowoffs = lzss_offset_for_position(&rar->lzss, startpos);
firstpart = lzss_size(&rar->lzss) - windowoffs;
copy_from_lzss_window_to_unp(struct archive_read *a, const void **buffer,
int64_t startpos, size_t length)
{
+ struct rar *rar = a->format->data;
int windowoffs, firstpart;
- struct rar *rar = (struct rar *)(a->format->data);
if (length > rar->unp_buffer_size)
{
static const void *
rar_read_ahead(struct archive_read *a, size_t min, ssize_t *avail)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
const void *h;
int ret;
static int
parse_filter(struct archive_read *a, const uint8_t *bytes, uint16_t length, uint8_t flags)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
struct rar_filters *filters = &rar->filters;
struct memory_bit_reader br = { 0 };
static int
run_filters(struct archive_read *a)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
struct rar_filters *filters = &rar->filters;
struct rar_filter *filter = filters->stack;
struct rar_filter *f;
static int
read_filter(struct archive_read *a, int64_t *end)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
uint8_t flags, val, *code;
uint16_t length, i;
static int
rar_decode_byte(struct archive_read *a, uint8_t *byte)
{
- struct rar *rar = (struct rar *)(a->format->data);
+ struct rar *rar = a->format->data;
struct rar_br *br = &(rar->br);
if (!rar_br_read_ahead(a, br, 8))
return 0;
return (hdr->block_flags_u8 >> 6) & 1;
}
-static inline struct rar5* get_context(struct archive_read* a) {
- return (struct rar5*) a->format->data;
-}
-
/* Convenience functions used by filter implementations. */
static void circular_memcpy(uint8_t* dst, uint8_t* window, const ssize_t mask,
int64_t start, int64_t end)
}
static int run_filter(struct archive_read* a, struct filter_info* flt) {
+ struct rar5 *rar = a->format->data;
int ret;
- struct rar5* rar = get_context(a);
clear_data_ready_stack(rar);
free(rar->cstate.filtered_buf);
}
static int apply_filters(struct archive_read* a) {
+ struct rar5 *rar = a->format->data;
struct filter_info* flt;
- struct rar5* rar = get_context(a);
int ret;
rar->cstate.all_filters_applied = 0;
}
static int skip_unprocessed_bytes(struct archive_read* a) {
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
int ret;
if(rar->file.bytes_remaining) {
{
const size_t SMALLEST_RAR5_BLOCK_SIZE = 3;
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
uint32_t hdr_crc, computed_crc;
size_t raw_hdr_size = 0, hdr_size_len, hdr_size;
size_t header_id = 0;
}
static int skip_base_block(struct archive_read* a) {
+ struct rar5 *rar = a->format->data;
int ret;
- struct rar5* rar = get_context(a);
/* Create a new local archive_entry structure that will be operated on
* by header reader; operations on this archive_entry will be discarded.
static int rar5_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
int ret;
/*
static int decode_number(struct archive_read* a, struct decode_table* table,
const uint8_t* p, uint16_t* num)
{
+ struct rar5 *rar = a->format->data;
int i, bits, dist, ret;
uint16_t bitfield;
uint32_t pos;
- struct rar5* rar = get_context(a);
if(ARCHIVE_OK != (ret = read_bits_16(a, rar, p, &bitfield))) {
return ret;
/* The function will create a new filter, read its parameters from the input
* stream and add it to the filter collection. */
static int parse_filter(struct archive_read* ar, const uint8_t* p) {
+ struct rar5 *rar = ar->format->data;
uint32_t block_start, block_length;
uint16_t filter_type;
struct filter_info* filt = NULL;
- struct rar5* rar = get_context(ar);
int ret;
/* Read the parameters from the input stream. */
}
static int copy_string(struct archive_read* a, int len, int dist) {
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
const ssize_t cmask = rar->cstate.window_mask;
const uint64_t write_ptr = rar->cstate.write_ptr +
rar->cstate.solid_offset;
}
static int do_uncompress_block(struct archive_read* a, const uint8_t* p) {
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
uint16_t num;
int ret;
/* This function will switch the multivolume archive file to another file,
* i.e. from part03 to part 04. */
static int advance_multivolume(struct archive_read* a) {
+ struct rar5 *rar = a->format->data;
int lret;
- struct rar5* rar = get_context(a);
/* A small state machine that will skip unnecessary data, needed to
* switch from one multivolume to another. Such skipping is needed if
static int merge_block(struct archive_read* a, ssize_t block_size,
const uint8_t** p)
{
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
ssize_t cur_block_size, partial_offset = 0;
const uint8_t* lp;
int ret;
}
static int process_block(struct archive_read* a) {
+ struct rar5 *rar = a->format->data;
const uint8_t* p;
- struct rar5* rar = get_context(a);
int ret;
/* If we don't have any data to be processed, this most probably means
* */
static int do_uncompress_file(struct archive_read* a) {
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
int ret;
int64_t max_end_pos;
}
static int verify_checksums(struct archive_read* a) {
+ struct rar5 *rar = a->format->data;
int verify_crc;
- struct rar5* rar = get_context(a);
/* Check checksums only when actually unpacking the data. There's no
* need to calculate checksum when we're skipping data in solid archives
static int rar5_read_data(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset) {
+ struct rar5 *rar = a->format->data;
int ret;
- struct rar5* rar = get_context(a);
if (size)
*size = 0;
}
static int rar5_read_data_skip(struct archive_read *a) {
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
if(rar->main.solid && (rar->cstate.data_encrypted == 0)) {
/* In solid archives, instead of skipping the data, we need to
}
static int rar5_cleanup(struct archive_read *a) {
- struct rar5* rar = get_context(a);
+ struct rar5 *rar = a->format->data;
free(rar->cstate.window_buf);
free(rar->cstate.filtered_buf);
static int rar5_has_encrypted_entries(struct archive_read *_a) {
if (_a && _a->format) {
- struct rar5 *rar = (struct rar5 *)_a->format->data;
+ struct rar5 *rar = _a->format->data;
if (rar) {
return rar->has_encrypted_entries;
}
int
archive_read_support_format_raw(struct archive *_a)
{
- struct raw_info *info;
struct archive_read *a = (struct archive_read *)_a;
+ struct raw_info *info;
int r;
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
archive_read_format_raw_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct raw_info *info;
+ struct raw_info *info = a->format->data;
- info = (struct raw_info *)(a->format->data);
if (info->end_of_file)
return (ARCHIVE_EOF);
archive_read_format_raw_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
- struct raw_info *info;
+ struct raw_info *info = a->format->data;
ssize_t avail;
- info = (struct raw_info *)(a->format->data);
-
/* Consume the bytes we read last time. */
if (info->unconsumed) {
__archive_read_consume(a, info->unconsumed);
static int
archive_read_format_raw_read_data_skip(struct archive_read *a)
{
- struct raw_info *info = (struct raw_info *)(a->format->data);
+ struct raw_info *info = a->format->data;
/* Consume the bytes we read last time. */
if (info->unconsumed) {
static int
archive_read_format_raw_cleanup(struct archive_read *a)
{
- struct raw_info *info;
+ struct raw_info *info = a->format->data;
- info = (struct raw_info *)(a->format->data);
free(info);
a->format->data = NULL;
return (ARCHIVE_OK);
static int
archive_read_format_tar_cleanup(struct archive_read *a)
{
- struct tar *tar;
+ struct tar *tar = a->format->data;
- tar = (struct tar *)(a->format->data);
gnu_clear_sparse_list(tar);
archive_string_free(&tar->entry_pathname);
archive_string_free(&tar->entry_pathname_override);
archive_string_free(&tar->line);
archive_string_free(&tar->localname);
free(tar);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
archive_read_format_tar_options(struct archive_read *a,
const char *key, const char *val)
{
- struct tar *tar;
+ struct tar *tar = a->format->data;
int ret = ARCHIVE_FAILED;
- tar = (struct tar *)(a->format->data);
if (strcmp(key, "compat-2x") == 0) {
/* Handle UTF-8 filenames as libarchive 2.x */
tar->compat_2x = (val != NULL && val[0] != 0);
* probably not worthwhile just to support the relatively
* obscure tar->cpio conversion case.
*/
- struct tar *tar;
+ struct tar *tar = a->format->data;
const char *p;
const wchar_t *wp;
int r;
size_t l;
int64_t unconsumed = 0;
- tar = (struct tar *)(a->format->data);
-
/* Assign default device/inode values. */
archive_entry_set_dev(entry, 1 + tar->default_dev); /* Don't use zero. */
archive_entry_set_ino(entry, ++tar->default_inode); /* Don't use zero. */
archive_read_format_tar_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
+ struct tar *tar = a->format->data;
ssize_t bytes_read;
- struct tar *tar;
struct sparse_block *p;
- tar = (struct tar *)(a->format->data);
-
for (;;) {
/* Remove exhausted entries from sparse list. */
while (tar->sparse_list != NULL &&
static int
archive_read_format_tar_skip(struct archive_read *a)
{
+ struct tar *tar = a->format->data;
int64_t request;
- struct tar* tar;
-
- tar = (struct tar *)(a->format->data);
request = tar->entry_bytes_remaining + tar->entry_padding +
tar->entry_bytes_unconsumed;
static int
read_toc(struct archive_read *a)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
struct xar_file *file;
const unsigned char *b;
uint64_t toc_compressed_size;
ssize_t bytes;
int r;
- xar = (struct xar *)(a->format->data);
-
/*
* Read xar header.
*/
static int
xar_read_header(struct archive_read *a, struct archive_entry *entry)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
struct xar_file *file;
struct xattr *xattr;
int r;
- xar = (struct xar *)(a->format->data);
r = ARCHIVE_OK;
if (xar->offset == 0) {
xar_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
size_t used = 0;
int r;
- xar = (struct xar *)(a->format->data);
-
if (xar->entry_unconsumed) {
__archive_read_consume(a, xar->entry_unconsumed);
xar->entry_unconsumed = 0;
static int
xar_read_data_skip(struct archive_read *a)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
int64_t bytes_skipped;
- xar = (struct xar *)(a->format->data);
if (xar->end_of_file)
return (ARCHIVE_EOF);
bytes_skipped = __archive_read_consume(a, xar->entry_remaining +
static int
xar_cleanup(struct archive_read *a)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
struct hdlink *hdlink;
size_t i;
int r;
- xar = (struct xar *)(a->format->data);
checksum_cleanup(a);
r = decompression_cleanup(a);
hdlink = xar->hdlink_list;
static int
move_reading_point(struct archive_read *a, uint64_t offset)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
- xar = (struct xar *)(a->format->data);
if (xar->offset - xar->h_base != offset) {
/* Seek forward to the start of file contents. */
int64_t step;
static void
checksum_init(struct archive_read *a, int a_sum_alg, int e_sum_alg)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
- xar = (struct xar *)(a->format->data);
_checksum_init(&(xar->a_sumwrk), a_sum_alg);
_checksum_init(&(xar->e_sumwrk), e_sum_alg);
}
checksum_update(struct archive_read *a, const void *abuff, size_t asize,
const void *ebuff, size_t esize)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
- xar = (struct xar *)(a->format->data);
_checksum_update(&(xar->a_sumwrk), abuff, asize);
_checksum_update(&(xar->e_sumwrk), ebuff, esize);
}
checksum_final(struct archive_read *a, const void *a_sum_val,
size_t a_sum_len, const void *e_sum_val, size_t e_sum_len)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
int r;
- xar = (struct xar *)(a->format->data);
r = _checksum_final(&(xar->a_sumwrk), a_sum_val, a_sum_len);
if (r == ARCHIVE_OK)
r = _checksum_final(&(xar->e_sumwrk), e_sum_val, e_sum_len);
static int
decompression_init(struct archive_read *a, enum enctype encoding)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
const char *detail;
int r;
- xar = (struct xar *)(a->format->data);
xar->rd_encoding = encoding;
switch (encoding) {
case NONE:
decompress(struct archive_read *a, const void **buff, size_t *outbytes,
const void *b, size_t *used)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
void *outbuff;
size_t avail_in, avail_out;
int r;
- xar = (struct xar *)(a->format->data);
avail_in = *used;
outbuff = (void *)(uintptr_t)*buff;
if (outbuff == NULL) {
static int
decompression_cleanup(struct archive_read *a)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
int r;
- xar = (struct xar *)(a->format->data);
r = ARCHIVE_OK;
if (xar->stream_valid) {
if (inflateEnd(&(xar->stream)) != Z_OK) {
static void
checksum_cleanup(struct archive_read *a) {
- struct xar *xar;
-
- xar = (struct xar *)(a->format->data);
+ struct xar *xar = a->format->data;
_checksum_final(&(xar->a_sumwrk), NULL, 0);
_checksum_final(&(xar->e_sumwrk), NULL, 0);
static int
xml_start(struct archive_read *a, const char *name, struct xmlattr_list *list)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
struct xmlattr *attr;
- xar = (struct xar *)(a->format->data);
-
#if DEBUG
fprintf(stderr, "xml_sta:[%s]\n", name);
for (attr = list->first; attr != NULL; attr = attr->next)
static void
xml_end(void *userData, const char *name)
{
- struct archive_read *a;
- struct xar *xar;
-
- a = (struct archive_read *)userData;
- xar = (struct xar *)(a->format->data);
+ struct archive_read *a = (struct archive_read *)userData;
+ struct xar *xar = a->format->data;
#if DEBUG
fprintf(stderr, "xml_end:[%s]\n", name);
static int
xml_data(void *userData, const char *s, size_t len)
{
+ struct archive_read *a = (struct archive_read *)userData;
+ struct xar *xar = a->format->data;
uint64_t val;
- struct archive_read *a;
- struct xar *xar;
int r;
- a = (struct archive_read *)userData;
- xar = (struct xar *)(a->format->data);
-
#if DEBUG
{
char buff[1024];
static int
xml2_read_cb(void *context, char *buffer, int len)
{
- struct archive_read *a;
- struct xar *xar;
+ struct archive_read *a = (struct archive_read *)context;
+ struct xar *xar = a->format->data;
const void *d;
size_t outbytes;
size_t used = 0;
int r;
- a = (struct archive_read *)context;
- xar = (struct xar *)(a->format->data);
-
if (xar->toc_remaining <= 0)
return (0);
d = buffer;
xml2_error_hdr(void *arg, const char *msg, xmlParserSeverities severity,
xmlTextReaderLocatorPtr locator)
{
- struct archive_read *a;
+ struct archive_read *a = (struct archive_read *)arg;
(void)locator; /* UNUSED */
- a = (struct archive_read *)arg;
switch (severity) {
case XML_PARSER_SEVERITY_VALIDITY_WARNING:
case XML_PARSER_SEVERITY_WARNING:
static int
expat_read_toc(struct archive_read *a)
{
- struct xar *xar;
+ struct xar *xar = a->format->data;
XML_Parser parser;
struct expat_userData ud;
ud.state = ARCHIVE_OK;
ud.archive = a;
- xar = (struct xar *)(a->format->data);
-
/* Initialize XML Parser library. */
parser = XML_ParserCreate(NULL);
if (parser == NULL) {
asaRead(ISequentialStream *this, void *pv, ULONG cb, ULONG *pcbRead)
{
struct ArchiveStreamAdapter *asa = (struct ArchiveStreamAdapter *)this;
- struct archive_read *a;
- struct xar *xar;
+ struct archive_read *a = asa->a;
+ struct xar *xar = a->format->data;
const void *d = pv;
size_t outbytes = cb;
size_t used = 0;
int r;
- a = asa->a;
- xar = (struct xar *)(a->format->data);
-
*pcbRead = 0;
if (xar->toc_remaining <= 0)
ppmd_read(void* p) {
/* Get the handle to current decompression context. */
struct archive_read *a = ((IByteIn*)p)->a;
- struct zip *zip = (struct zip*) a->format->data;
+ struct zip *zip = a->format->data;
/* Fetch next byte. */
const uint8_t* data = __archive_read_ahead(a, 1, NULL);
zipx_read_header_and_decrypt(struct archive_read *a, const void **buf, size_t in_len,
size_t *out_len, size_t *consumed)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
const void *raw;
ssize_t bytes_avail;
size_t to_decrypt;
process_extra(struct archive_read *a, struct archive_entry *entry,
const char *p, size_t extra_length, struct zip_entry* zip_entry)
{
+ struct zip *zip = a->format->data;
unsigned offset = 0;
- struct zip *zip = (struct zip *)(a->format->data);
if (extra_length == 0) {
return ARCHIVE_OK;
static int
check_authentication_code(struct archive_read *a, const void *_p)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
/* Check authentication code. */
if (zip->hctx_valid) {
zip_read_data_none(struct archive_read *a, const void **_buff,
size_t *size, int64_t *offset)
{
- struct zip *zip;
+ struct zip *zip = a->format->data;
const char *buff;
ssize_t bytes_avail;
ssize_t trailing_extra;
(void)offset; /* UNUSED */
- zip = (struct zip *)(a->format->data);
trailing_extra = zip->hctx_valid ? AUTH_CODE_SIZE : 0;
if (zip->entry->zip_flags & ZIP_LENGTH_AT_END) {
zip_read_data_zipx_xz(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct zip* zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
int ret;
lzma_ret lz_ret;
const void* compressed_buf;
zip_read_data_zipx_lzma_alone(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct zip* zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
int ret;
lzma_ret lz_ret;
const void* compressed_buf;
zip_read_data_zipx_ppmd(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct zip* zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
int ret;
size_t consumed_bytes = 0;
zip_read_data_zipx_bzip2(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
ssize_t bytes_avail = 0, to_consume;
const void *compressed_buff;
const void *sp;
zip_read_data_zipx_zstd(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
ssize_t bytes_avail = 0, to_consume;
const void *compressed_buff;
const void *sp;
zip_read_data_deflate(struct archive_read *a, const void **buff,
size_t *size, int64_t *offset)
{
- struct zip *zip;
+ struct zip *zip = a->format->data;
ssize_t bytes_avail, to_consume = 0;
const void *compressed_buff;
const void *sp;
(void)offset; /* UNUSED */
- zip = (struct zip *)(a->format->data);
-
/* If the buffer hasn't been allocated, allocate it now. */
if (zip->uncompressed_buffer == NULL) {
zip->uncompressed_buffer_size = 256 * 1024;
static int
read_decryption_header(struct archive_read *a)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
const char *p;
unsigned int remaining_size;
unsigned int ts;
static int
zip_alloc_decryption_buffer(struct archive_read *a)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
size_t bs = 256 * 1024;
if (zip->decrypted_buffer == NULL) {
static int
init_traditional_PKWARE_decryption(struct archive_read *a)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
const void *p;
int retry;
int r;
static int
init_WinZip_AES_decryption(struct archive_read *a)
{
- struct zip *zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
const void *p;
const uint8_t *pv;
size_t key_len, salt_len;
archive_read_format_zip_read_data(struct archive_read *a,
const void **buff, size_t *size, int64_t *offset)
{
+ struct zip *zip = a->format->data;
int r;
- struct zip *zip = (struct zip *)(a->format->data);
if (zip->has_encrypted_entries ==
ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
static int
archive_read_format_zip_cleanup(struct archive_read *a)
{
- struct zip *zip;
+ struct zip *zip = a->format->data;
struct zip_entry *zip_entry, *next_zip_entry;
- zip = (struct zip *)(a->format->data);
-
#ifdef HAVE_ZLIB_H
if (zip->stream_valid)
inflateEnd(&zip->stream);
free(zip->v_data);
archive_string_free(&zip->format_name);
free(zip);
- (a->format->data) = NULL;
+ a->format->data = NULL;
return (ARCHIVE_OK);
}
archive_read_format_zip_has_encrypted_entries(struct archive_read *_a)
{
if (_a && _a->format) {
- struct zip * zip = (struct zip *)_a->format->data;
+ struct zip *zip = _a->format->data;
if (zip) {
return zip->has_encrypted_entries;
}
archive_read_format_zip_options(struct archive_read *a,
const char *key, const char *val)
{
- struct zip *zip;
+ struct zip *zip = a->format->data;
int ret = ARCHIVE_FAILED;
- zip = (struct zip *)(a->format->data);
if (strcmp(key, "compat-2x") == 0) {
/* Handle filenames as libarchive 2.x */
zip->init_default_conversion = (val != NULL) ? 1 : 0;
archive_read_format_zip_streamable_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct zip *zip;
+ struct zip *zip = a->format->data;
a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
if (a->archive.archive_format_name == NULL)
a->archive.archive_format_name = "ZIP";
- zip = (struct zip *)(a->format->data);
-
/*
* It should be sufficient to call archive_read_next_header() for
* a reader to determine if an entry is encrypted or not. If the
static int
archive_read_format_zip_read_data_skip_streamable(struct archive_read *a)
{
- struct zip *zip;
+ struct zip *zip = a->format->data;
int64_t bytes_skipped;
- zip = (struct zip *)(a->format->data);
bytes_skipped = __archive_read_consume(a, zip->unconsumed);
zip->unconsumed = 0;
if (bytes_skipped < 0)
static int
archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
{
- struct zip *zip = (struct zip *)a->format->data;
+ struct zip *zip = a->format->data;
int64_t file_size, current_offset;
const char *p;
int i, tail;
zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
struct zip_entry *rsrc)
{
- struct zip *zip = (struct zip *)a->format->data;
+ struct zip *zip = a->format->data;
unsigned char *metadata, *mp;
int64_t offset = archive_filter_bytes(&a->archive, 0);
size_t remaining_bytes, metadata_bytes;
archive_read_format_zip_seekable_read_header(struct archive_read *a,
struct archive_entry *entry)
{
- struct zip *zip = (struct zip *)a->format->data;
+ struct zip *zip = a->format->data;
struct zip_entry *rsrc;
int64_t offset;
int r, ret = ARCHIVE_OK;
static int
archive_read_format_zip_read_data_skip_seekable(struct archive_read *a)
{
- struct zip *zip;
- zip = (struct zip *)(a->format->data);
+ struct zip *zip = a->format->data;
zip->unconsumed = 0;
return (ARCHIVE_OK);
static int
_7z_options(struct archive_write *a, const char *key, const char *value)
{
- struct _7zip *zip;
-
- zip = (struct _7zip *)a->format_data;
+ struct _7zip *zip = a->format_data;
if (strcmp(key, "compression") == 0) {
const char *name = NULL;
static int
_7z_write_header(struct archive_write *a, struct archive_entry *entry)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
struct file *file;
int r;
- zip = (struct _7zip *)a->format_data;
zip->cur_file = NULL;
zip->entry_bytes_remaining = 0;
static int
write_to_temp(struct archive_write *a, const void *buff, size_t s)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
const unsigned char *p;
ssize_t ws;
- zip = (struct _7zip *)a->format_data;
-
/*
* Open a temporary file.
*/
compress_out(struct archive_write *a, const void *buff, size_t s,
enum la_zaction run)
{
- struct _7zip *zip = (struct _7zip *)a->format_data;
+ struct _7zip *zip = a->format_data;
int r;
if (run == ARCHIVE_Z_FINISH && zip->stream.total_in == 0 && s == 0)
static ssize_t
_7z_write_data(struct archive_write *a, const void *buff, size_t s)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
ssize_t bytes;
- zip = (struct _7zip *)a->format_data;
-
if (s > zip->entry_bytes_remaining)
s = (size_t)zip->entry_bytes_remaining;
if (s == 0 || zip->cur_file == NULL)
static int
_7z_finish_entry(struct archive_write *a)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
size_t s;
ssize_t r;
- zip = (struct _7zip *)a->format_data;
if (zip->cur_file == NULL)
return (ARCHIVE_OK);
static int
flush_wbuff(struct archive_write *a)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
int r;
size_t s;
- zip = (struct _7zip *)a->format_data;
s = sizeof(zip->wbuff) - zip->wbuff_remaining;
r = __archive_write_output(a, zip->wbuff, s);
if (r != ARCHIVE_OK)
static int
copy_out(struct archive_write *a, uint64_t offset, uint64_t length)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
int r;
- zip = (struct _7zip *)a->format_data;
if (zip->temp_offset > 0 &&
lseek(zip->temp_fd, offset, SEEK_SET) < 0) {
archive_set_error(&(a->archive), errno, "lseek failed");
static int
_7z_close(struct archive_write *a)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
unsigned char *wb;
uint64_t header_offset, header_size, header_unpacksize;
uint64_t length;
uint32_t header_crc32;
int r;
- zip = (struct _7zip *)a->format_data;
-
if (zip->total_number_entry > 0) {
struct archive_rb_node *n;
uint64_t data_offset, data_size, data_unpacksize;
static int
make_substreamsInfo(struct archive_write *a, struct coder *coders)
{
- struct _7zip *zip = (struct _7zip *)a->format_data;
+ struct _7zip *zip = a->format_data;
struct file *file;
int r;
uint64_t unpack_size, int num_coder, struct coder *coders, int substrm,
uint32_t header_crc)
{
- struct _7zip *zip = (struct _7zip *)a->format_data;
+ struct _7zip *zip = a->format_data;
uint8_t codec_buff[8];
int numFolders, fi;
int codec_size;
static int
make_time(struct archive_write *a, uint8_t type, unsigned flg, int ti)
{
+ struct _7zip *zip = a->format_data;
uint8_t filetime[8];
- struct _7zip *zip = (struct _7zip *)a->format_data;
struct file *file;
int r;
uint8_t b, mask;
make_header(struct archive_write *a, uint64_t offset, uint64_t pack_size,
uint64_t unpack_size, int codernum, struct coder *coders)
{
- struct _7zip *zip = (struct _7zip *)a->format_data;
+ struct _7zip *zip = a->format_data;
struct file *file;
int r;
uint8_t b, mask;
static int
_7z_free(struct archive_write *a)
{
- struct _7zip *zip = (struct _7zip *)a->format_data;
+ struct _7zip *zip = a->format_data;
/* Close the temporary file. */
if (zip->temp_fd >= 0)
file_new(struct archive_write *a, struct archive_entry *entry,
struct file **newfile)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
struct file *file;
const char *u16;
size_t u16len;
int ret = ARCHIVE_OK;
- zip = (struct _7zip *)a->format_data;
*newfile = NULL;
file = calloc(1, sizeof(*file));
ppmd_write(void *p, Byte b)
{
struct archive_write *a = ((IByteOut *)p)->a;
- struct _7zip *zip = (struct _7zip *)(a->format_data);
+ struct _7zip *zip = a->format_data;
struct la_zstream *lastrm = &(zip->stream);
struct ppmd_stream *strm;
_7z_compression_init_encoder(struct archive_write *a, unsigned compression,
int compression_level)
{
- struct _7zip *zip;
+ struct _7zip *zip = a->format_data;
int r;
- zip = (struct _7zip *)a->format_data;
switch (compression) {
case _7Z_DEFLATE:
r = compression_init_encoder_deflate(
int ret, append_fn;
char buff[60];
char *ss;
- struct ar_w *ar;
+ struct ar_w *ar = a->format_data;
struct archive_string se;
const char *pathname;
const char *filename;
int64_t size;
append_fn = 0;
- ar = (struct ar_w *)a->format_data;
ar->is_strtab = 0;
filename = NULL;
filename_length = 0;
static ssize_t
archive_write_ar_data(struct archive_write *a, const void *buff, size_t s)
{
- struct ar_w *ar;
+ struct ar_w *ar = a->format_data;
int ret;
- ar = (struct ar_w *)a->format_data;
if (s > ar->entry_bytes_remaining)
s = (size_t)ar->entry_bytes_remaining;
static int
archive_write_ar_free(struct archive_write *a)
{
- struct ar_w *ar;
-
- ar = (struct ar_w *)a->format_data;
+ struct ar_w *ar = a->format_data;
if (ar == NULL)
return (ARCHIVE_OK);
static int
archive_write_ar_close(struct archive_write *a)
{
- struct ar_w *ar;
+ struct ar_w *ar = a->format_data;
int ret;
/*
* If we haven't written anything yet, we need to write
* the ar global header now to make it a valid ar archive.
*/
- ar = (struct ar_w *)a->format_data;
if (!ar->wrote_global_header) {
ar->wrote_global_header = 1;
ret = __archive_write_output(a, "!<arch>\n", 8);
static int
archive_write_ar_finish_entry(struct archive_write *a)
{
- struct ar_w *ar;
+ struct ar_w *ar = a->format_data;
int ret;
- ar = (struct ar_w *)a->format_data;
-
if (ar->entry_bytes_remaining != 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Entry remaining bytes larger than 0");
archive_write_binary_options(struct archive_write *a, const char *key,
const char *val)
{
- struct cpio *cpio = (struct cpio *)a->format_data;
+ struct cpio *cpio = a->format_data;
int ret = ARCHIVE_FAILED;
if (strcmp(key, "hdrcharset") == 0) {
static struct archive_string_conv *
get_sconv(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
struct archive_string_conv *sconv;
- cpio = (struct cpio *)a->format_data;
sconv = cpio->opt_sconv;
if (sconv == NULL) {
if (!cpio->init_default_conversion) {
static int
write_header(struct archive_write *a, struct archive_entry *entry)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
const char *p, *path;
int ret, ret_final;
int64_t ino;
struct archive_entry *entry_main;
size_t len, pathlength;
- cpio = (struct cpio *)a->format_data;
ret_final = ARCHIVE_OK;
sconv = get_sconv(a);
static ssize_t
archive_write_binary_data(struct archive_write *a, const void *buff, size_t s)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
int ret;
- cpio = (struct cpio *)a->format_data;
if (s > cpio->entry_bytes_remaining)
s = (size_t)cpio->entry_bytes_remaining;
static int
archive_write_binary_free(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
- cpio = (struct cpio *)a->format_data;
free(cpio->ino_list);
free(cpio);
a->format_data = NULL;
static int
archive_write_binary_finish_entry(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
- cpio = (struct cpio *)a->format_data;
return (__archive_write_nulls(a, cpio->entry_bytes_remaining));
}
archive_write_newc_options(struct archive_write *a, const char *key,
const char *val)
{
- struct cpio *cpio = (struct cpio *)a->format_data;
+ struct cpio *cpio = a->format_data;
int ret = ARCHIVE_FAILED;
if (strcmp(key, "hdrcharset") == 0) {
static struct archive_string_conv *
get_sconv(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
struct archive_string_conv *sconv;
- cpio = (struct cpio *)a->format_data;
sconv = cpio->opt_sconv;
if (sconv == NULL) {
if (!cpio->init_default_conversion) {
static int
write_header(struct archive_write *a, struct archive_entry *entry)
{
+ struct cpio *cpio = a->format_data;
int64_t ino;
- struct cpio *cpio;
const char *p, *path;
int ret, ret_final;
char h[c_header_size];
size_t len, pathlength;
int pad;
- cpio = (struct cpio *)a->format_data;
ret_final = ARCHIVE_OK;
sconv = get_sconv(a);
static ssize_t
archive_write_newc_data(struct archive_write *a, const void *buff, size_t s)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
int ret;
- cpio = (struct cpio *)a->format_data;
if (s > cpio->entry_bytes_remaining)
s = (size_t)cpio->entry_bytes_remaining;
static int
archive_write_newc_free(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
- cpio = (struct cpio *)a->format_data;
free(cpio);
a->format_data = NULL;
return (ARCHIVE_OK);
static int
archive_write_newc_finish_entry(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
- cpio = (struct cpio *)a->format_data;
return (__archive_write_nulls(a,
cpio->entry_bytes_remaining + cpio->padding));
}
archive_write_odc_options(struct archive_write *a, const char *key,
const char *val)
{
- struct cpio *cpio = (struct cpio *)a->format_data;
+ struct cpio *cpio = a->format_data;
int ret = ARCHIVE_FAILED;
if (strcmp(key, "hdrcharset") == 0) {
static struct archive_string_conv *
get_sconv(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
struct archive_string_conv *sconv;
- cpio = (struct cpio *)a->format_data;
sconv = cpio->opt_sconv;
if (sconv == NULL) {
if (!cpio->init_default_conversion) {
static int
write_header(struct archive_write *a, struct archive_entry *entry)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
const char *p, *path;
int ret, ret_final;
int64_t ino;
struct archive_entry *entry_main;
size_t len, pathlength;
- cpio = (struct cpio *)a->format_data;
ret_final = ARCHIVE_OK;
sconv = get_sconv(a);
static ssize_t
archive_write_odc_data(struct archive_write *a, const void *buff, size_t s)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
int ret;
- cpio = (struct cpio *)a->format_data;
if (s > cpio->entry_bytes_remaining)
s = (size_t)cpio->entry_bytes_remaining;
static int
archive_write_odc_free(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
- cpio = (struct cpio *)a->format_data;
free(cpio->ino_list);
free(cpio);
a->format_data = NULL;
static int
archive_write_odc_finish_entry(struct archive_write *a)
{
- struct cpio *cpio;
+ struct cpio *cpio = a->format_data;
- cpio = (struct cpio *)a->format_data;
return (__archive_write_nulls(a,
cpio->entry_bytes_remaining));
}
archive_write_gnutar_options(struct archive_write *a, const char *key,
const char *val)
{
- struct gnutar *gnutar = (struct gnutar *)a->format_data;
+ struct gnutar *gnutar = a->format_data;
int ret = ARCHIVE_FAILED;
if (strcmp(key, "hdrcharset") == 0) {
static int
archive_write_gnutar_free(struct archive_write *a)
{
- struct gnutar *gnutar;
+ struct gnutar *gnutar = a->format_data;
- gnutar = (struct gnutar *)a->format_data;
free(gnutar);
a->format_data = NULL;
return (ARCHIVE_OK);
static int
archive_write_gnutar_finish_entry(struct archive_write *a)
{
- struct gnutar *gnutar;
+ struct gnutar *gnutar = a->format_data;
int ret;
- gnutar = (struct gnutar *)a->format_data;
ret = __archive_write_nulls(a,
gnutar->entry_bytes_remaining + gnutar->entry_padding);
gnutar->entry_bytes_remaining = gnutar->entry_padding = 0;
static ssize_t
archive_write_gnutar_data(struct archive_write *a, const void *buff, size_t s)
{
- struct gnutar *gnutar;
+ struct gnutar *gnutar = a->format_data;
int ret;
- gnutar = (struct gnutar *)a->format_data;
if (s > gnutar->entry_bytes_remaining)
s = (size_t)gnutar->entry_bytes_remaining;
ret = __archive_write_output(a, buff, s);
archive_write_gnutar_header(struct archive_write *a,
struct archive_entry *entry)
{
+ struct gnutar *gnutar = a->format_data;
char buff[512];
int r, ret, ret2 = ARCHIVE_OK;
char tartype;
- struct gnutar *gnutar;
struct archive_string_conv *sconv;
struct archive_entry *entry_main;
- gnutar = (struct gnutar *)a->format_data;
-
/* Setup default string conversion. */
if (gnutar->opt_sconv == NULL) {
if (!gnutar->init_default_conversion) {
archive_format_gnutar_header(struct archive_write *a, char h[512],
struct archive_entry *entry, char tartype)
{
+ struct gnutar *gnutar = a->format_data;
unsigned int checksum;
int i, ret;
size_t copy_length;
const char *p;
- struct gnutar *gnutar;
-
- gnutar = (struct gnutar *)a->format_data;
ret = 0;
static int
iso9660_write_header(struct archive_write *a, struct archive_entry *entry)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
struct isofile *file;
struct isoent *isoent;
int r, ret = ARCHIVE_OK;
- iso9660 = a->format_data;
-
iso9660->cur_file = NULL;
iso9660->bytes_remaining = 0;
iso9660->need_multi_extent = 0;
* order to reduce a extra memory copy.
*/
if (wb_remaining(a) == wb_buffmax() && s > (1024 * 16)) {
- struct iso9660 *iso9660 = (struct iso9660 *)a->format_data;
+ struct iso9660 *iso9660 = a->format_data;
xs = s % LOGICAL_BLOCK_SIZE;
iso9660->wbuff_offset += s - xs;
if (write_to_temp(a, buff, s - xs) != ARCHIVE_OK)
static int
iso9660_close(struct archive_write *a)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
int ret, blocks;
- iso9660 = a->format_data;
-
/*
* Write remaining data out to the temporary file.
*/
static int
iso9660_free(struct archive_write *a)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
int i, ret;
- iso9660 = a->format_data;
-
/* Close the temporary file. */
if (iso9660->temp_fd >= 0)
close(iso9660->temp_fd);
static inline unsigned char *
wb_buffptr(struct archive_write *a)
{
- struct iso9660 *iso9660 = (struct iso9660 *)a->format_data;
+ struct iso9660 *iso9660 = a->format_data;
return (&(iso9660->wbuff[sizeof(iso9660->wbuff)
- iso9660->wbuff_remaining]));
static int
wb_write_out(struct archive_write *a)
{
- struct iso9660 *iso9660 = (struct iso9660 *)a->format_data;
+ struct iso9660 *iso9660 = a->format_data;
size_t wsize, nw;
int r;
static int
wb_consume(struct archive_write *a, size_t size)
{
- struct iso9660 *iso9660 = (struct iso9660 *)a->format_data;
+ struct iso9660 *iso9660 = a->format_data;
if (size > iso9660->wbuff_remaining ||
iso9660->wbuff_remaining == 0) {
static int
wb_set_offset(struct archive_write *a, int64_t off)
{
- struct iso9660 *iso9660 = (struct iso9660 *)a->format_data;
+ struct iso9660 *iso9660 = a->format_data;
int64_t used, ext_bytes;
if (iso9660->wbuff_type != WB_TO_TEMP) {
static int
write_VD(struct archive_write *a, struct vdd *vdd)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
unsigned char *bp;
uint16_t volume_set_size = 1;
char identifier[256];
unsigned char vd_ver, fst_ver;
int r;
- iso9660 = a->format_data;
switch (vdd->vdd_type) {
case VDD_JOLIET:
vdt = VDT_SUPPLEMENTARY;
static int
write_VD_boot_record(struct archive_write *a)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
unsigned char *bp;
- iso9660 = a->format_data;
bp = wb_buffptr(a) -1;
/* Volume Descriptor Type */
set_VD_bp(bp, VDT_BOOT_RECORD, 1);
static int
write_information_block(struct archive_write *a)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
char buf[128];
const char *v;
int opt, r;
size_t info_size = LOGICAL_BLOCK_SIZE *
NON_ISO_FILE_SYSTEM_INFORMATION_BLOCK;
- iso9660 = (struct iso9660 *)a->format_data;
if (info_size > wb_remaining(a)) {
r = wb_write_out(a);
if (r != ARCHIVE_OK)
static int
isofile_gen_utility_names(struct archive_write *a, struct isofile *file)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
const char *pathname;
char *p, *dirname, *slash;
size_t len;
int ret = ARCHIVE_OK;
- iso9660 = a->format_data;
-
archive_string_empty(&(file->parentdir));
archive_string_empty(&(file->basename));
archive_string_empty(&(file->basename_utf16));
static int
isoent_tree(struct archive_write *a, struct isoent **isoentpp)
{
+ struct iso9660 *iso9660 = a->format_data;
#if defined(_WIN32) && !defined(__CYGWIN__)
char name[_MAX_FNAME];/* Included null terminator size. */
#elif defined(NAME_MAX) && NAME_MAX >= 255
#else
char name[256];
#endif
- struct iso9660 *iso9660 = a->format_data;
struct isoent *dent, *isoent, *np;
struct isofile *f1, *f2;
const char *fn, *p;
isoent_gen_iso9660_identifier(struct archive_write *a, struct isoent *isoent,
struct idr *idr)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
struct isoent *np;
char *p;
int l, r;
if (isoent->children.cnt == 0)
return (ARCHIVE_OK);
- iso9660 = a->format_data;
char_map = idr->char_map;
if (iso9660->opt.iso_level <= 3) {
allow_ldots = 0;
isoent_gen_joliet_identifier(struct archive_write *a, struct isoent *isoent,
struct idr *idr)
{
- struct iso9660 *iso9660;
+ struct iso9660 *iso9660 = a->format_data;
struct isoent *np;
unsigned char *p;
size_t l;
if (isoent->children.cnt == 0)
return (ARCHIVE_OK);
- iso9660 = a->format_data;
if (iso9660->opt.joliet == OPT_JOLIET_LONGNAME)
ffmax = 206;
else
archive_write_mtree_header(struct archive_write *a,
struct archive_entry *entry)
{
- struct mtree_writer *mtree= a->format_data;
+ struct mtree_writer *mtree = a->format_data;
struct mtree_entry *mtree_entry;
int r, r2;
static int
archive_write_mtree_close(struct archive_write *a)
{
- struct mtree_writer *mtree= a->format_data;
+ struct mtree_writer *mtree = a->format_data;
int ret;
if (mtree->root != NULL) {
static ssize_t
archive_write_mtree_data(struct archive_write *a, const void *buff, size_t n)
{
- struct mtree_writer *mtree= a->format_data;
+ struct mtree_writer *mtree = a->format_data;
if (n > mtree->entry_bytes_remaining)
n = (size_t)mtree->entry_bytes_remaining;
static int
archive_write_mtree_free(struct archive_write *a)
{
- struct mtree_writer *mtree= a->format_data;
+ struct mtree_writer *mtree = a->format_data;
if (mtree == NULL)
return (ARCHIVE_OK);
archive_write_mtree_options(struct archive_write *a, const char *key,
const char *value)
{
- struct mtree_writer *mtree= a->format_data;
+ struct mtree_writer *mtree = a->format_data;
int keybit = 0;
switch (key[0]) {
"archive_write_set_format_mtree_classic");
if (r == ARCHIVE_OK) {
struct archive_write *a = (struct archive_write *)_a;
- struct mtree_writer *mtree;
-
- mtree = (struct mtree_writer *)a->format_data;
+ struct mtree_writer *mtree = a->format_data;
/* Set to output a mtree archive in classic format. */
mtree->classic = 1;
static int
mtree_entry_tree_add(struct archive_write *a, struct mtree_entry **filep)
{
+ struct mtree_writer *mtree = a->format_data;
#if defined(_WIN32) && !defined(__CYGWIN__)
char name[_MAX_FNAME];/* Included null terminator size. */
#elif defined(NAME_MAX) && NAME_MAX >= 255
#else
char name[256];
#endif
- struct mtree_writer *mtree = (struct mtree_writer *)a->format_data;
struct mtree_entry *dent, *file, *np;
const char *fn, *p;
int l, r;
archive_write_pax_options(struct archive_write *a, const char *key,
const char *val)
{
- struct pax *pax = (struct pax *)a->format_data;
+ struct pax *pax = a->format_data;
int ret = ARCHIVE_FAILED;
if (strcmp(key, "hdrcharset") == 0) {
archive_write_pax_header(struct archive_write *a,
struct archive_entry *entry_original)
{
+ struct pax *pax = a->format_data;
struct archive_entry *entry_main;
const char *p;
const char *suffix;
int acl_types;
int sparse_count;
uint64_t sparse_total, real_size;
- struct pax *pax;
const char *hardlink;
const char *path = NULL, *linkpath = NULL;
const char *uname = NULL, *gname = NULL;
ret = ARCHIVE_OK;
need_extension = 0;
- pax = (struct pax *)a->format_data;
const time_t ustar_max_mtime = get_ustar_max_mtime();
static int
archive_write_pax_free(struct archive_write *a)
{
- struct pax *pax;
+ struct pax *pax = a->format_data;
- pax = (struct pax *)a->format_data;
if (pax == NULL)
return (ARCHIVE_OK);
static int
archive_write_pax_finish_entry(struct archive_write *a)
{
- struct pax *pax;
+ struct pax *pax = a->format_data;
uint64_t remaining;
int ret;
- pax = (struct pax *)a->format_data;
remaining = pax->entry_bytes_remaining;
if (remaining == 0) {
while (pax->sparse_list) {
static ssize_t
archive_write_pax_data(struct archive_write *a, const void *buff, size_t s)
{
- struct pax *pax;
+ struct pax *pax = a->format_data;
size_t ws;
size_t total;
int ret;
- pax = (struct pax *)a->format_data;
-
/*
* According to GNU PAX format 1.0, write a sparse map
* before the body.
static int
archive_write_raw_header(struct archive_write *a, struct archive_entry *entry)
{
- struct raw *raw = (struct raw *)a->format_data;
+ struct raw *raw = a->format_data;
if (archive_entry_filetype(entry) != AE_IFREG) {
archive_set_error(&a->archive, ERANGE,
static int
archive_write_raw_free(struct archive_write *a)
{
- struct raw *raw;
+ struct raw *raw = a->format_data;
- raw = (struct raw *)a->format_data;
free(raw);
a->format_data = NULL;
return (ARCHIVE_OK);
{
struct archive_write *a = (struct archive_write *)_a;
struct shar *shar;
+ int ret;
- int ret = archive_write_set_format_shar(&a->archive);
+ ret = archive_write_set_format_shar(&a->archive);
if (ret != ARCHIVE_OK)
return ret;
- shar = (struct shar *)a->format_data;
+
+ shar = a->format_data;
shar->dump = 1;
a->format_write_data = archive_write_shar_data_uuencode;
a->archive.archive_format = ARCHIVE_FORMAT_SHAR_DUMP;
static int
archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
{
+ struct shar *shar = a->format_data;
const char *linkname;
const char *name;
char *p, *pp;
- struct shar *shar;
- shar = (struct shar *)a->format_data;
if (!shar->wrote_header) {
archive_strcat(&shar->work, "#!/bin/sh\n");
archive_strcat(&shar->work, "# This is a shell archive\n");
static ssize_t
archive_write_shar_data_sed(struct archive_write *a, const void *buff, size_t n)
{
+ struct shar *shar = a->format_data;
static const size_t ensured = 65533;
- struct shar *shar;
const char *src;
char *buf, *buf_end;
int ret;
size_t written = n;
- shar = (struct shar *)a->format_data;
if (!shar->has_data || n == 0)
return (0);
archive_write_shar_data_uuencode(struct archive_write *a, const void *buff,
size_t length)
{
- struct shar *shar;
+ struct shar *shar = a->format_data;
const char *src;
size_t n;
int ret;
- shar = (struct shar *)a->format_data;
if (!shar->has_data)
return (ARCHIVE_OK);
src = (const char *)buff;
static int
archive_write_shar_finish_entry(struct archive_write *a)
{
+ struct shar *shar = a->format_data;
const char *g, *p, *u;
- struct shar *shar;
int ret;
- shar = (struct shar *)a->format_data;
if (shar->entry == NULL)
return (ARCHIVE_OK);
static int
archive_write_shar_close(struct archive_write *a)
{
- struct shar *shar;
+ struct shar *shar = a->format_data;
int ret;
/*
* fix them all up at end-of-archive.
*/
- shar = (struct shar *)a->format_data;
-
/*
* Only write the end-of-archive markers if the archive was
* actually started. This avoids problems if someone sets
static int
archive_write_shar_free(struct archive_write *a)
{
- struct shar *shar;
+ struct shar *shar = a->format_data;
- shar = (struct shar *)a->format_data;
if (shar == NULL)
return (ARCHIVE_OK);
archive_write_ustar_options(struct archive_write *a, const char *key,
const char *val)
{
- struct ustar *ustar = (struct ustar *)a->format_data;
+ struct ustar *ustar = a->format_data;
int ret = ARCHIVE_FAILED;
if (strcmp(key, "hdrcharset") == 0) {
static int
archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry)
{
+ struct ustar *ustar = a->format_data;
char buff[512];
int ret, ret2;
- struct ustar *ustar;
struct archive_entry *entry_main;
struct archive_string_conv *sconv;
- ustar = (struct ustar *)a->format_data;
-
/* Setup default string conversion. */
if (ustar->opt_sconv == NULL) {
if (!ustar->init_default_conversion) {
static int
archive_write_ustar_free(struct archive_write *a)
{
- struct ustar *ustar;
+ struct ustar *ustar = a->format_data;
- ustar = (struct ustar *)a->format_data;
free(ustar);
a->format_data = NULL;
return (ARCHIVE_OK);
static int
archive_write_ustar_finish_entry(struct archive_write *a)
{
- struct ustar *ustar;
+ struct ustar *ustar = a->format_data;
int ret;
- ustar = (struct ustar *)a->format_data;
ret = __archive_write_nulls(a,
ustar->entry_bytes_remaining + ustar->entry_padding);
ustar->entry_bytes_remaining = ustar->entry_padding = 0;
static ssize_t
archive_write_ustar_data(struct archive_write *a, const void *buff, size_t s)
{
- struct ustar *ustar;
+ struct ustar *ustar = a->format_data;
int ret;
- ustar = (struct ustar *)a->format_data;
if (s > ustar->entry_bytes_remaining)
s = (size_t)ustar->entry_bytes_remaining;
ret = __archive_write_output(a, buff, s);
archive_write_v7tar_options(struct archive_write *a, const char *key,
const char *val)
{
- struct v7tar *v7tar = (struct v7tar *)a->format_data;
+ struct v7tar *v7tar = a->format_data;
int ret = ARCHIVE_FAILED;
if (strcmp(key, "hdrcharset") == 0) {
static int
archive_write_v7tar_header(struct archive_write *a, struct archive_entry *entry)
{
+ struct v7tar *v7tar = a->format_data;
char buff[512];
int ret, ret2;
- struct v7tar *v7tar;
struct archive_entry *entry_main;
struct archive_string_conv *sconv;
- v7tar = (struct v7tar *)a->format_data;
-
/* Setup default string conversion. */
if (v7tar->opt_sconv == NULL) {
if (!v7tar->init_default_conversion) {
static int
archive_write_v7tar_free(struct archive_write *a)
{
- struct v7tar *v7tar;
+ struct v7tar *v7tar = a->format_data;
- v7tar = (struct v7tar *)a->format_data;
free(v7tar);
a->format_data = NULL;
return (ARCHIVE_OK);
static int
archive_write_v7tar_finish_entry(struct archive_write *a)
{
- struct v7tar *v7tar;
+ struct v7tar *v7tar = a->format_data;
int ret;
- v7tar = (struct v7tar *)a->format_data;
ret = __archive_write_nulls(a,
v7tar->entry_bytes_remaining + v7tar->entry_padding);
v7tar->entry_bytes_remaining = v7tar->entry_padding = 0;
static ssize_t
archive_write_v7tar_data(struct archive_write *a, const void *buff, size_t s)
{
- struct v7tar *v7tar;
+ struct v7tar *v7tar = a->format_data;
int ret;
- v7tar = (struct v7tar *)a->format_data;
if (s > v7tar->entry_bytes_remaining)
s = (size_t)v7tar->entry_bytes_remaining;
ret = __archive_write_output(a, buff, s);
static int
xar_options(struct archive_write *a, const char *key, const char *value)
{
- struct xar *xar;
-
- xar = (struct xar *)a->format_data;
+ struct xar *xar = a->format_data;
if (strcmp(key, "checksum") == 0) {
if (value == NULL)
static int
xar_write_header(struct archive_write *a, struct archive_entry *entry)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
struct file *file;
struct archive_entry *file_entry;
int r, r2;
- xar = (struct xar *)a->format_data;
xar->cur_file = NULL;
xar->bytes_remaining = 0;
static int
write_to_temp(struct archive_write *a, const void *buff, size_t s)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
const unsigned char *p;
ssize_t ws;
- xar = (struct xar *)a->format_data;
p = (const unsigned char *)buff;
while (s) {
ws = write(xar->temp_fd, p, s);
static ssize_t
xar_write_data(struct archive_write *a, const void *buff, size_t s)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
enum la_zaction run;
size_t size = 0;
size_t rsize;
int r;
- xar = (struct xar *)a->format_data;
-
if (s > xar->bytes_remaining)
s = (size_t)xar->bytes_remaining;
if (s == 0 || xar->cur_file == NULL)
static int
xar_finish_entry(struct archive_write *a)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
struct file *file;
size_t s;
ssize_t w;
- xar = (struct xar *)a->format_data;
if (xar->cur_file == NULL)
return (ARCHIVE_OK);
xmlwrite_fstring(struct archive_write *a, struct xml_writer *writer,
const char *key, const char *fmt, ...)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
va_list ap;
- xar = (struct xar *)a->format_data;
va_start(ap, fmt);
archive_string_empty(&xar->vstr);
archive_string_vsprintf(&xar->vstr, fmt, ap);
make_file_entry(struct archive_write *a, struct xml_writer *writer,
struct file *file)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
const char *filetype, *filelink, *fflags;
struct archive_string linkto;
struct heap_data *heap;
size_t len;
int r, r2;
- xar = (struct xar *)a->format_data;
r2 = ARCHIVE_OK;
/*
static int
make_toc(struct archive_write *a)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
struct file *np;
struct xml_writer *writer;
const char* content;
int algsize;
int r, ret;
- xar = (struct xar *)a->format_data;
-
ret = ARCHIVE_FATAL;
/*
static int
flush_wbuff(struct archive_write *a)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
int r;
size_t s;
- xar = (struct xar *)a->format_data;
s = sizeof(xar->wbuff) - xar->wbuff_remaining;
r = __archive_write_output(a, xar->wbuff, s);
if (r != ARCHIVE_OK)
static int
copy_out(struct archive_write *a, uint64_t offset, uint64_t length)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
int r;
- xar = (struct xar *)a->format_data;
if (lseek(xar->temp_fd, offset, SEEK_SET) < 0) {
archive_set_error(&(a->archive), errno, "lseek failed");
return (ARCHIVE_FATAL);
static int
xar_close(struct archive_write *a)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
unsigned char *wb;
uint64_t length;
int r;
- xar = (struct xar *)a->format_data;
-
/* Empty! */
if (xar->root->children.first == NULL)
return (ARCHIVE_OK);
static int
xar_free(struct archive_write *a)
{
- struct xar *xar;
-
- xar = (struct xar *)a->format_data;
+ struct xar *xar = a->format_data;
/* Close the temporary file. */
if (xar->temp_fd >= 0)
static int
file_gen_utility_names(struct archive_write *a, struct file *file)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
const char *pp;
char *p, *dirname, *slash;
size_t len;
int r = ARCHIVE_OK;
- xar = (struct xar *)a->format_data;
archive_string_empty(&(file->parentdir));
archive_string_empty(&(file->basename));
archive_string_empty(&(file->symlink));
static int
file_tree(struct archive_write *a, struct file **filepp)
{
+ struct xar *xar = a->format_data;
#if defined(_WIN32) && !defined(__CYGWIN__)
char name[_MAX_FNAME];/* Included null terminator size. */
#elif defined(NAME_MAX) && NAME_MAX >= 255
#else
char name[256];
#endif
- struct xar *xar = (struct xar *)a->format_data;
struct file *dent, *file, *np;
struct archive_entry *ent;
const char *fn, *p;
static int
file_register_hardlink(struct archive_write *a, struct file *file)
{
- struct xar *xar = (struct xar *)a->format_data;
+ struct xar *xar = a->format_data;
struct hardlink *hl;
const char *pathname;
static int
xar_compression_init_encoder(struct archive_write *a)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
int r;
- xar = (struct xar *)a->format_data;
switch (xar->opt_compression) {
case GZIP:
r = compression_init_encoder_gzip(
static int
save_xattrs(struct archive_write *a, struct file *file)
{
- struct xar *xar;
+ struct xar *xar = a->format_data;
const char *name;
const void *value;
struct heap_data *heap;
size_t size;
int count, r;
- xar = (struct xar *)a->format_data;
count = archive_entry_xattr_reset(file->entry);
if (count == 0)
return (ARCHIVE_OK);
static int
archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
{
+ struct zip *zip = a->format_data;
unsigned char local_header[32];
unsigned char local_extra[144];
- struct zip *zip = a->format_data;
unsigned char *e;
unsigned char *cd_extra;
size_t filename_length;
static ssize_t
archive_write_zip_data(struct archive_write *a, const void *buff, size_t s)
{
- int ret;
struct zip *zip = a->format_data;
+ int ret;
if ((int64_t)s > zip->entry_uncompressed_limit)
s = (size_t)zip->entry_uncompressed_limit;
static int
archive_write_zip_close(struct archive_write *a)
{
+ struct zip *zip = a->format_data;
uint8_t buff[64];
int64_t offset_start, offset_end;
- struct zip *zip = a->format_data;
struct cd_segment *segment;
int ret;
static int
archive_write_zip_free(struct archive_write *a)
{
- struct zip *zip;
+ struct zip *zip = a->format_data;
struct cd_segment *segment;
- zip = a->format_data;
while (zip->central_directory != NULL) {
segment = zip->central_directory;
zip->central_directory = segment->next;