Unify format data access names
It's generally the pattern "struct format *format". Unify for easier readability. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
This commit is contained in:
1 parent
a631287e4c
commit
6c3bab2480
6 files changed
+647
-644
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -38,7 +38,7 @@
|
||||
#include "archive_private.h"
|
||||
#include "archive_read_private.h"
|
||||
|
||||
struct raw_info {
|
||||
struct raw {
|
||||
int64_t offset; /* Current position in the file. */
|
||||
int64_t unconsumed;
|
||||
int end_of_file;
|
||||
@@ -56,21 +56,21 @@ int
|
||||
archive_read_support_format_raw(struct archive *_a)
|
||||
{
|
||||
struct archive_read *a = (struct archive_read *)_a;
|
||||
struct raw_info *info;
|
||||
struct raw *raw;
|
||||
int r;
|
||||
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_raw");
|
||||
|
||||
info = calloc(1, sizeof(*info));
|
||||
if (info == NULL) {
|
||||
raw = calloc(1, sizeof(*raw));
|
||||
if (raw == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate raw_info data");
|
||||
"Can't allocate raw data");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
r = __archive_read_register_format(a,
|
||||
info,
|
||||
raw,
|
||||
"raw",
|
||||
archive_read_format_raw_bid,
|
||||
NULL,
|
||||
@@ -82,7 +82,7 @@ archive_read_support_format_raw(struct archive *_a)
|
||||
NULL,
|
||||
NULL);
|
||||
if (r != ARCHIVE_OK)
|
||||
free(info);
|
||||
free(raw);
|
||||
return (r);
|
||||
}
|
||||
|
||||
@@ -108,9 +108,9 @@ static int
|
||||
archive_read_format_raw_read_header(struct archive_read *a,
|
||||
struct archive_entry *entry)
|
||||
{
|
||||
struct raw_info *info = a->format->data;
|
||||
struct raw *raw = a->format->data;
|
||||
|
||||
if (info->end_of_file)
|
||||
if (raw->end_of_file)
|
||||
return (ARCHIVE_EOF);
|
||||
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_RAW;
|
||||
@@ -128,24 +128,24 @@ static int
|
||||
archive_read_format_raw_read_data(struct archive_read *a,
|
||||
const void **buff, size_t *size, int64_t *offset)
|
||||
{
|
||||
struct raw_info *info = a->format->data;
|
||||
struct raw *raw = a->format->data;
|
||||
ssize_t avail;
|
||||
|
||||
/* Consume the bytes we read last time. */
|
||||
if (info->unconsumed) {
|
||||
__archive_read_consume(a, info->unconsumed);
|
||||
info->unconsumed = 0;
|
||||
if (raw->unconsumed) {
|
||||
__archive_read_consume(a, raw->unconsumed);
|
||||
raw->unconsumed = 0;
|
||||
}
|
||||
|
||||
if (info->end_of_file)
|
||||
if (raw->end_of_file)
|
||||
return (ARCHIVE_EOF);
|
||||
|
||||
/* Get whatever bytes are immediately available. */
|
||||
*buff = __archive_read_ahead(a, 1, &avail);
|
||||
if (avail > 0) {
|
||||
/* Return the bytes we just read */
|
||||
*offset = info->offset;
|
||||
if (archive_ckd_add_i64(&info->offset, info->offset, avail)) {
|
||||
*offset = raw->offset;
|
||||
if (archive_ckd_add_i64(&raw->offset, raw->offset, avail)) {
|
||||
avail = INT64_MAX - *offset;
|
||||
if (avail == 0) {
|
||||
*size = 0;
|
||||
@@ -153,18 +153,18 @@ archive_read_format_raw_read_data(struct archive_read *a,
|
||||
}
|
||||
}
|
||||
*size = avail;
|
||||
info->unconsumed = avail;
|
||||
raw->unconsumed = avail;
|
||||
return (ARCHIVE_OK);
|
||||
} else if (0 == avail) {
|
||||
/* Record and return end-of-file. */
|
||||
info->end_of_file = 1;
|
||||
raw->end_of_file = 1;
|
||||
*size = 0;
|
||||
*offset = info->offset;
|
||||
*offset = raw->offset;
|
||||
return (ARCHIVE_EOF);
|
||||
} else {
|
||||
/* Record and return an error. */
|
||||
*size = 0;
|
||||
*offset = info->offset;
|
||||
*offset = raw->offset;
|
||||
return ((int)avail);
|
||||
}
|
||||
}
|
||||
@@ -172,23 +172,23 @@ archive_read_format_raw_read_data(struct archive_read *a,
|
||||
static int
|
||||
archive_read_format_raw_read_data_skip(struct archive_read *a)
|
||||
{
|
||||
struct raw_info *info = a->format->data;
|
||||
struct raw *raw = a->format->data;
|
||||
|
||||
/* Consume the bytes we read last time. */
|
||||
if (info->unconsumed) {
|
||||
__archive_read_consume(a, info->unconsumed);
|
||||
info->unconsumed = 0;
|
||||
if (raw->unconsumed) {
|
||||
__archive_read_consume(a, raw->unconsumed);
|
||||
raw->unconsumed = 0;
|
||||
}
|
||||
info->end_of_file = 1;
|
||||
raw->end_of_file = 1;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
archive_read_format_raw_cleanup(struct archive_read *a)
|
||||
{
|
||||
struct raw_info *info = a->format->data;
|
||||
struct raw *raw = a->format->data;
|
||||
|
||||
free(info);
|
||||
free(raw);
|
||||
a->format->data = NULL;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ typedef struct {
|
||||
char *str;
|
||||
} warc_strbuf_t;
|
||||
|
||||
struct warc_s {
|
||||
struct warc {
|
||||
/* Content length of the current record */
|
||||
int64_t cntlen;
|
||||
/* Bytes processed from the current record */
|
||||
@@ -143,20 +143,20 @@ int
|
||||
archive_read_support_format_warc(struct archive *_a)
|
||||
{
|
||||
struct archive_read *a = (struct archive_read *)_a;
|
||||
struct warc_s *w;
|
||||
struct warc *warc;
|
||||
int r;
|
||||
|
||||
archive_check_magic(_a, ARCHIVE_READ_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_read_support_format_warc");
|
||||
|
||||
if ((w = calloc(1, sizeof(*w))) == NULL) {
|
||||
if ((warc = calloc(1, sizeof(*warc))) == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate warc data");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
r = __archive_read_register_format(a,
|
||||
w,
|
||||
warc,
|
||||
"warc",
|
||||
archive_read_format_warc_bid,
|
||||
NULL,
|
||||
@@ -169,7 +169,7 @@ archive_read_support_format_warc(struct archive *_a)
|
||||
NULL);
|
||||
|
||||
if (r != ARCHIVE_OK) {
|
||||
free(w);
|
||||
free(warc);
|
||||
return (r);
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
@@ -178,13 +178,13 @@ archive_read_support_format_warc(struct archive *_a)
|
||||
static int
|
||||
archive_read_format_warc_cleanup(struct archive_read *a)
|
||||
{
|
||||
struct warc_s *w = a->format->data;
|
||||
struct warc *warc = a->format->data;
|
||||
|
||||
if (w->pool.len > 0U) {
|
||||
free(w->pool.str);
|
||||
if (warc->pool.len > 0U) {
|
||||
free(warc->pool.str);
|
||||
}
|
||||
archive_string_free(&w->sver);
|
||||
free(w);
|
||||
archive_string_free(&warc->sver);
|
||||
free(warc);
|
||||
a->format->data = NULL;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ archive_read_format_warc_read_header(struct archive_read *a,
|
||||
struct archive_entry *entry)
|
||||
{
|
||||
#define HDR_PROBE_LEN (12U)
|
||||
struct warc_s *w = a->format->data;
|
||||
struct warc *warc = a->format->data;
|
||||
unsigned int ver;
|
||||
const char *buf;
|
||||
ssize_t nrd;
|
||||
@@ -295,18 +295,18 @@ start_over:
|
||||
|
||||
/* Report this archive as WARC. */
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_WARC;
|
||||
if (ver != w->pver) {
|
||||
if (ver != warc->pver) {
|
||||
/* Format this entry's WARC version. */
|
||||
archive_string_sprintf(&w->sver,
|
||||
archive_string_sprintf(&warc->sver,
|
||||
"WARC/%u.%u", ver / 10000, (ver % 10000) / 100);
|
||||
/* Remember the version for later entries. */
|
||||
w->pver = ver;
|
||||
warc->pver = ver;
|
||||
}
|
||||
/* Parse the record type. */
|
||||
ftyp = warc_read_type(buf, eoh - buf);
|
||||
/* Save content state for subsequent read calls. */
|
||||
w->cntlen = cntlen;
|
||||
w->cntoff = 0;
|
||||
warc->cntlen = cntlen;
|
||||
warc->cntoff = 0;
|
||||
mtime = 0;/* Avoid compiler warnings on some platforms. */
|
||||
|
||||
switch (ftyp) {
|
||||
@@ -324,21 +324,21 @@ start_over:
|
||||
}
|
||||
/* Copy the name into the reusable string pool to avoid a malloc/free
|
||||
* roundtrip for each entry. */
|
||||
if (fnam.len + 1U > w->pool.len) {
|
||||
w->pool.len = ((fnam.len + 64U) / 64U) * 64U;
|
||||
tmp = realloc(w->pool.str, w->pool.len);
|
||||
if (fnam.len + 1U > warc->pool.len) {
|
||||
warc->pool.len = ((fnam.len + 64U) / 64U) * 64U;
|
||||
tmp = realloc(warc->pool.str, warc->pool.len);
|
||||
if (tmp == NULL) {
|
||||
archive_set_error(
|
||||
&a->archive, ENOMEM,
|
||||
"Out of memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
w->pool.str = tmp;
|
||||
warc->pool.str = tmp;
|
||||
}
|
||||
memcpy(w->pool.str, fnam.str, fnam.len);
|
||||
w->pool.str[fnam.len] = '\0';
|
||||
memcpy(warc->pool.str, fnam.str, fnam.len);
|
||||
warc->pool.str[fnam.len] = '\0';
|
||||
/* Hide the pool implementation behind the parsed string. */
|
||||
fnam.str = w->pool.str;
|
||||
fnam.str = warc->pool.str;
|
||||
|
||||
/* Use a Last-Modified record header when present; otherwise fall back
|
||||
* to WARC-Date. */
|
||||
@@ -399,20 +399,20 @@ static int
|
||||
archive_read_format_warc_read_data(struct archive_read *a, const void **buf,
|
||||
size_t *bsz, int64_t *off)
|
||||
{
|
||||
struct warc_s *w = a->format->data;
|
||||
struct warc *warc = a->format->data;
|
||||
const char *rab;
|
||||
ssize_t nrd;
|
||||
|
||||
if (w->unconsumed) {
|
||||
__archive_read_consume(a, w->unconsumed);
|
||||
w->unconsumed = 0;
|
||||
if (warc->unconsumed) {
|
||||
__archive_read_consume(a, warc->unconsumed);
|
||||
warc->unconsumed = 0;
|
||||
}
|
||||
|
||||
if (w->cntoff >= w->cntlen) {
|
||||
if (warc->cntoff >= warc->cntlen) {
|
||||
/* No data is available to return for this entry. */
|
||||
*buf = NULL;
|
||||
*bsz = 0U;
|
||||
*off = w->cntoff;
|
||||
*off = warc->cntoff;
|
||||
return (ARCHIVE_EOF);
|
||||
}
|
||||
|
||||
@@ -425,35 +425,35 @@ archive_read_format_warc_read_data(struct archive_read *a, const void **buf,
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated WARC file data");
|
||||
return (ARCHIVE_FATAL);
|
||||
} else if ((int64_t)nrd > w->cntlen - w->cntoff) {
|
||||
} else if ((int64_t)nrd > warc->cntlen - warc->cntoff) {
|
||||
/* Clamp reads to Content-Length. */
|
||||
nrd = w->cntlen - w->cntoff;
|
||||
nrd = warc->cntlen - warc->cntoff;
|
||||
}
|
||||
*off = w->cntoff;
|
||||
*off = warc->cntoff;
|
||||
*bsz = nrd;
|
||||
*buf = rab;
|
||||
|
||||
w->cntoff += nrd;
|
||||
w->unconsumed = nrd;
|
||||
warc->cntoff += nrd;
|
||||
warc->unconsumed = nrd;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
archive_read_format_warc_skip(struct archive_read *a)
|
||||
{
|
||||
struct warc_s *w = a->format->data;
|
||||
struct warc *warc = a->format->data;
|
||||
|
||||
if (w->cntoff > w->cntlen)
|
||||
if (warc->cntoff > warc->cntlen)
|
||||
return (ARCHIVE_FATAL);
|
||||
if (w->unconsumed) {
|
||||
__archive_read_consume(a, w->unconsumed);
|
||||
w->unconsumed = 0;
|
||||
if (warc->unconsumed) {
|
||||
__archive_read_consume(a, warc->unconsumed);
|
||||
warc->unconsumed = 0;
|
||||
}
|
||||
if (__archive_read_consume(a, w->cntlen - w->cntoff) < 0 ||
|
||||
if (__archive_read_consume(a, warc->cntlen - warc->cntoff) < 0 ||
|
||||
__archive_read_consume(a, 4U/*\r\n\r\n separator*/) < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
w->cntlen = 0;
|
||||
w->cntoff = 0;
|
||||
warc->cntlen = 0;
|
||||
warc->cntoff = 0;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "archive_write_private.h"
|
||||
#include "archive_write_set_format_private.h"
|
||||
|
||||
struct ar_w {
|
||||
struct ar {
|
||||
uint64_t entry_bytes_remaining;
|
||||
uint64_t entry_padding;
|
||||
int is_strtab;
|
||||
@@ -120,7 +120,7 @@ archive_write_set_format_ar_svr4(struct archive *_a)
|
||||
static int
|
||||
archive_write_set_format_ar(struct archive_write *a)
|
||||
{
|
||||
struct ar_w *ar;
|
||||
struct ar *ar;
|
||||
|
||||
/* If someone else was already registered, unregister them. */
|
||||
(void)__archive_write_unregister_format(a);
|
||||
@@ -147,7 +147,7 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
|
||||
int ret, append_fn;
|
||||
char buff[60];
|
||||
char *ss;
|
||||
struct ar_w *ar = a->format_data;
|
||||
struct ar *ar = a->format_data;
|
||||
struct archive_string se;
|
||||
const char *pathname;
|
||||
const char *filename;
|
||||
@@ -363,7 +363,7 @@ size:
|
||||
static ssize_t
|
||||
archive_write_ar_data(struct archive_write *a, const void *buff, size_t s)
|
||||
{
|
||||
struct ar_w *ar = a->format_data;
|
||||
struct ar *ar = a->format_data;
|
||||
int ret;
|
||||
|
||||
if (s > ar->entry_bytes_remaining)
|
||||
@@ -398,7 +398,7 @@ archive_write_ar_data(struct archive_write *a, const void *buff, size_t s)
|
||||
static int
|
||||
archive_write_ar_free(struct archive_write *a)
|
||||
{
|
||||
struct ar_w *ar = a->format_data;
|
||||
struct ar *ar = a->format_data;
|
||||
|
||||
if (ar == NULL)
|
||||
return (ARCHIVE_OK);
|
||||
@@ -416,7 +416,7 @@ archive_write_ar_free(struct archive_write *a)
|
||||
static int
|
||||
archive_write_ar_close(struct archive_write *a)
|
||||
{
|
||||
struct ar_w *ar = a->format_data;
|
||||
struct ar *ar = a->format_data;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
@@ -435,7 +435,7 @@ archive_write_ar_close(struct archive_write *a)
|
||||
static int
|
||||
archive_write_ar_finish_entry(struct archive_write *a)
|
||||
{
|
||||
struct ar_w *ar = a->format_data;
|
||||
struct ar *ar = a->format_data;
|
||||
int ret;
|
||||
|
||||
if (ar->entry_bytes_remaining != 0) {
|
||||
|
||||
@@ -117,7 +117,7 @@ struct mtree_entry {
|
||||
int64_t ino;
|
||||
};
|
||||
|
||||
struct mtree_writer {
|
||||
struct mtree {
|
||||
struct mtree_entry *mtree_entry;
|
||||
struct mtree_entry *root;
|
||||
struct mtree_entry *cur_dirent;
|
||||
@@ -220,10 +220,10 @@ static int attr_counter_inc(struct attr_counter **, struct attr_counter *,
|
||||
struct attr_counter *, struct mtree_entry *);
|
||||
static struct attr_counter * attr_counter_new(struct mtree_entry *,
|
||||
struct attr_counter *);
|
||||
static int attr_counter_set_collect(struct mtree_writer *,
|
||||
static int attr_counter_set_collect(struct mtree *,
|
||||
struct mtree_entry *);
|
||||
static void attr_counter_set_free(struct mtree_writer *);
|
||||
static int get_global_set_keys(struct mtree_writer *, struct mtree_entry *);
|
||||
static void attr_counter_set_free(struct mtree *);
|
||||
static int get_global_set_keys(struct mtree *, struct mtree_entry *);
|
||||
static int mtree_entry_add_child_tail(struct mtree_entry *,
|
||||
struct mtree_entry *);
|
||||
static int mtree_entry_create_virtual_dir(struct archive_write *, const char *,
|
||||
@@ -236,14 +236,14 @@ static int mtree_entry_exchange_same_entry(struct archive_write *,
|
||||
static void mtree_entry_free(struct mtree_entry *);
|
||||
static int mtree_entry_new(struct archive_write *, struct archive_entry *,
|
||||
struct mtree_entry **);
|
||||
static void mtree_entry_register_free(struct mtree_writer *);
|
||||
static void mtree_entry_register_init(struct mtree_writer *);
|
||||
static void mtree_entry_register_free(struct mtree *);
|
||||
static void mtree_entry_register_init(struct mtree *);
|
||||
static int mtree_entry_setup_filenames(struct archive_write *,
|
||||
struct mtree_entry *, struct archive_entry *);
|
||||
static int mtree_entry_tree_add(struct archive_write *, struct mtree_entry **);
|
||||
static void sum_init(struct mtree_writer *);
|
||||
static void sum_update(struct mtree_writer *, const void *, size_t);
|
||||
static void sum_final(struct mtree_writer *, struct reg_info *);
|
||||
static void sum_init(struct mtree *);
|
||||
static void sum_update(struct mtree *, const void *, size_t);
|
||||
static void sum_final(struct mtree *, struct reg_info *);
|
||||
static void sum_write(struct archive_string *, struct reg_info *);
|
||||
static int write_mtree_entry(struct archive_write *, struct mtree_entry *);
|
||||
static int write_dot_dot_entry(struct archive_write *, struct mtree_entry *);
|
||||
@@ -358,7 +358,7 @@ mtree_quote(struct archive_string *s, const char *str)
|
||||
* Indent a line as the mtree utility does so it is readable for people.
|
||||
*/
|
||||
static void
|
||||
mtree_indent(struct mtree_writer *mtree)
|
||||
mtree_indent(struct mtree *mtree)
|
||||
{
|
||||
int i, fn, nd, pd;
|
||||
const char *r, *s, *x;
|
||||
@@ -434,7 +434,7 @@ mtree_indent(struct mtree_writer *mtree)
|
||||
* collected by the attr_counter_set_collect() function.
|
||||
*/
|
||||
static void
|
||||
write_global(struct mtree_writer *mtree)
|
||||
write_global(struct mtree *mtree)
|
||||
{
|
||||
struct archive_string setstr;
|
||||
struct archive_string unsetstr;
|
||||
@@ -636,7 +636,7 @@ attr_counter_inc(struct attr_counter **top, struct attr_counter *ac,
|
||||
* Tabulate uid, gid, mode and fflags of a entry in order to be used for /set.
|
||||
*/
|
||||
static int
|
||||
attr_counter_set_collect(struct mtree_writer *mtree, struct mtree_entry *me)
|
||||
attr_counter_set_collect(struct mtree *mtree, struct mtree_entry *me)
|
||||
{
|
||||
struct attr_counter *ac, *last;
|
||||
struct attr_counter_set *acs = &mtree->acs;
|
||||
@@ -713,7 +713,7 @@ attr_counter_set_collect(struct mtree_writer *mtree, struct mtree_entry *me)
|
||||
}
|
||||
|
||||
static void
|
||||
attr_counter_set_free(struct mtree_writer *mtree)
|
||||
attr_counter_set_free(struct mtree *mtree)
|
||||
{
|
||||
struct attr_counter_set *acs = &mtree->acs;
|
||||
|
||||
@@ -724,7 +724,7 @@ attr_counter_set_free(struct mtree_writer *mtree)
|
||||
}
|
||||
|
||||
static int
|
||||
get_global_set_keys(struct mtree_writer *mtree, struct mtree_entry *me)
|
||||
get_global_set_keys(struct mtree *mtree, struct mtree_entry *me)
|
||||
{
|
||||
int keys;
|
||||
|
||||
@@ -913,7 +913,7 @@ static int
|
||||
archive_write_mtree_header(struct archive_write *a,
|
||||
struct archive_entry *entry)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
struct mtree_entry *mtree_entry;
|
||||
int r, r2;
|
||||
|
||||
@@ -956,7 +956,7 @@ archive_write_mtree_header(struct archive_write *a,
|
||||
static int
|
||||
write_mtree_entry(struct archive_write *a, struct mtree_entry *me)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
struct archive_string *str;
|
||||
int keys, ret;
|
||||
|
||||
@@ -1107,7 +1107,7 @@ write_mtree_entry(struct archive_write *a, struct mtree_entry *me)
|
||||
static int
|
||||
write_dot_dot_entry(struct archive_write *a, struct mtree_entry *n)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
int ret;
|
||||
|
||||
if (n->parentdir.s) {
|
||||
@@ -1142,7 +1142,7 @@ write_dot_dot_entry(struct archive_write *a, struct mtree_entry *n)
|
||||
static int
|
||||
write_mtree_entry_tree(struct archive_write *a)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
struct mtree_entry *np = mtree->root;
|
||||
struct archive_rb_node *n;
|
||||
int ret;
|
||||
@@ -1245,7 +1245,7 @@ write_mtree_entry_tree(struct archive_write *a)
|
||||
static int
|
||||
archive_write_mtree_finish_entry(struct archive_write *a)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
struct mtree_entry *me;
|
||||
|
||||
if ((me = mtree->mtree_entry) == NULL)
|
||||
@@ -1261,7 +1261,7 @@ archive_write_mtree_finish_entry(struct archive_write *a)
|
||||
static int
|
||||
archive_write_mtree_close(struct archive_write *a)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
int ret;
|
||||
|
||||
if (mtree->root != NULL) {
|
||||
@@ -1278,7 +1278,7 @@ archive_write_mtree_close(struct archive_write *a)
|
||||
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 *mtree = a->format_data;
|
||||
|
||||
if (n > mtree->entry_bytes_remaining)
|
||||
n = (size_t)mtree->entry_bytes_remaining;
|
||||
@@ -1297,7 +1297,7 @@ archive_write_mtree_data(struct archive_write *a, const void *buff, size_t n)
|
||||
static int
|
||||
archive_write_mtree_free(struct archive_write *a)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
|
||||
if (mtree == NULL)
|
||||
return (ARCHIVE_OK);
|
||||
@@ -1317,7 +1317,7 @@ static int
|
||||
archive_write_mtree_options(struct archive_write *a, const char *key,
|
||||
const char *value)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
int keybit = 0;
|
||||
|
||||
switch (key[0]) {
|
||||
@@ -1429,7 +1429,7 @@ static int
|
||||
archive_write_set_format_mtree_default(struct archive *_a, const char *fn)
|
||||
{
|
||||
struct archive_write *a = (struct archive_write *)_a;
|
||||
struct mtree_writer *mtree;
|
||||
struct mtree *mtree;
|
||||
|
||||
archive_check_magic(_a, ARCHIVE_WRITE_MAGIC, ARCHIVE_STATE_NEW, fn);
|
||||
|
||||
@@ -1480,7 +1480,7 @@ archive_write_set_format_mtree_classic(struct archive *_a)
|
||||
"archive_write_set_format_mtree_classic");
|
||||
if (r == ARCHIVE_OK) {
|
||||
struct archive_write *a = (struct archive_write *)_a;
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
|
||||
/* Set to output a mtree archive in classic format. */
|
||||
mtree->classic = 1;
|
||||
@@ -1492,7 +1492,7 @@ archive_write_set_format_mtree_classic(struct archive *_a)
|
||||
}
|
||||
|
||||
static void
|
||||
sum_init(struct mtree_writer *mtree)
|
||||
sum_init(struct mtree *mtree)
|
||||
{
|
||||
|
||||
mtree->compute_sum = 0;
|
||||
@@ -1553,7 +1553,7 @@ sum_init(struct mtree_writer *mtree)
|
||||
}
|
||||
|
||||
static void
|
||||
sum_update(struct mtree_writer *mtree, const void *buff, size_t n)
|
||||
sum_update(struct mtree *mtree, const void *buff, size_t n)
|
||||
{
|
||||
if (mtree->compute_sum & F_CKSUM) {
|
||||
/*
|
||||
@@ -1611,7 +1611,7 @@ sum_update(struct mtree_writer *mtree, const void *buff, size_t n)
|
||||
}
|
||||
|
||||
static void
|
||||
sum_final(struct mtree_writer *mtree, struct reg_info *reg)
|
||||
sum_final(struct mtree *mtree, struct reg_info *reg)
|
||||
{
|
||||
struct ae_digest digest;
|
||||
|
||||
@@ -1992,7 +1992,7 @@ mtree_entry_create_virtual_dir(struct archive_write *a, const char *pathname,
|
||||
}
|
||||
|
||||
static void
|
||||
mtree_entry_register_add(struct mtree_writer *mtree, struct mtree_entry *file)
|
||||
mtree_entry_register_add(struct mtree *mtree, struct mtree_entry *file)
|
||||
{
|
||||
file->next = NULL;
|
||||
*mtree->file_list.last = file;
|
||||
@@ -2000,14 +2000,14 @@ mtree_entry_register_add(struct mtree_writer *mtree, struct mtree_entry *file)
|
||||
}
|
||||
|
||||
static void
|
||||
mtree_entry_register_init(struct mtree_writer *mtree)
|
||||
mtree_entry_register_init(struct mtree *mtree)
|
||||
{
|
||||
mtree->file_list.first = NULL;
|
||||
mtree->file_list.last = &(mtree->file_list.first);
|
||||
}
|
||||
|
||||
static void
|
||||
mtree_entry_register_free(struct mtree_writer *mtree)
|
||||
mtree_entry_register_free(struct mtree *mtree)
|
||||
{
|
||||
struct mtree_entry *file, *file_next;
|
||||
|
||||
@@ -2070,7 +2070,7 @@ get_path_component(char *name, size_t n, const char *fn)
|
||||
static int
|
||||
mtree_entry_tree_add(struct archive_write *a, struct mtree_entry **filep)
|
||||
{
|
||||
struct mtree_writer *mtree = a->format_data;
|
||||
struct mtree *mtree = a->format_data;
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
char name[_MAX_FNAME];/* Included null terminator size. */
|
||||
#elif defined(NAME_MAX) && NAME_MAX >= 255
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
* Content-Length header.
|
||||
*/
|
||||
|
||||
struct warc_s {
|
||||
struct warc {
|
||||
unsigned int omit_warcinfo:1;
|
||||
|
||||
time_t now;
|
||||
@@ -127,7 +127,7 @@ int
|
||||
archive_write_set_format_warc(struct archive *_a)
|
||||
{
|
||||
struct archive_write *a = (struct archive_write *)_a;
|
||||
struct warc_s *w;
|
||||
struct warc *warc;
|
||||
|
||||
archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
|
||||
ARCHIVE_STATE_NEW, "archive_write_set_format_warc");
|
||||
@@ -135,20 +135,20 @@ archive_write_set_format_warc(struct archive *_a)
|
||||
/* If another format was already registered, unregister it. */
|
||||
(void)__archive_write_unregister_format(a);
|
||||
|
||||
w = malloc(sizeof(*w));
|
||||
if (w == NULL) {
|
||||
warc = malloc(sizeof(*warc));
|
||||
if (warc == NULL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate warc data");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
/* Emit a warcinfo record by default. */
|
||||
w->omit_warcinfo = 0U;
|
||||
warc->omit_warcinfo = 0U;
|
||||
/* Use the current time for WARC-Date values. */
|
||||
w->now = time(NULL);
|
||||
warc->now = time(NULL);
|
||||
/* Reset file type information. */
|
||||
w->typ = 0;
|
||||
warc->typ = 0;
|
||||
|
||||
a->format_data = w;
|
||||
a->format_data = warc;
|
||||
a->format_name = "WARC/1.0";
|
||||
a->format_options = _warc_options;
|
||||
a->format_write_header = _warc_header;
|
||||
@@ -166,12 +166,12 @@ archive_write_set_format_warc(struct archive *_a)
|
||||
static int
|
||||
_warc_options(struct archive_write *a, const char *key, const char *val)
|
||||
{
|
||||
struct warc_s *w = a->format_data;
|
||||
struct warc *warc = a->format_data;
|
||||
|
||||
if (strcmp(key, "omit-warcinfo") == 0) {
|
||||
if (val == NULL || strcmp(val, "true") == 0) {
|
||||
/* Option accepted. */
|
||||
w->omit_warcinfo = 1U;
|
||||
warc->omit_warcinfo = 1U;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
}
|
||||
@@ -184,12 +184,12 @@ _warc_options(struct archive_write *a, const char *key, const char *val)
|
||||
static int
|
||||
_warc_header(struct archive_write *a, struct archive_entry *entry)
|
||||
{
|
||||
struct warc_s *w = a->format_data;
|
||||
struct warc *warc = a->format_data;
|
||||
struct archive_string hdr;
|
||||
#define MAX_HDR_SIZE 512
|
||||
|
||||
/* Emit the warcinfo record if needed. */
|
||||
if (!w->omit_warcinfo) {
|
||||
if (!warc->omit_warcinfo) {
|
||||
ssize_t r;
|
||||
int rc;
|
||||
warc_essential_hdr_t wi = {
|
||||
@@ -201,8 +201,8 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
|
||||
/* Content type */"application/warc-fields",
|
||||
/* Content length */sizeof(warcinfo) - 1U,
|
||||
};
|
||||
wi.rtime = w->now;
|
||||
wi.mtime = w->now;
|
||||
wi.rtime = warc->now;
|
||||
wi.mtime = warc->now;
|
||||
|
||||
archive_string_init(&hdr);
|
||||
r = _popul_ehdr(&hdr, MAX_HDR_SIZE, wi);
|
||||
@@ -228,7 +228,7 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
|
||||
}
|
||||
|
||||
/* Mark the file header as written. */
|
||||
w->omit_warcinfo = 1U;
|
||||
warc->omit_warcinfo = 1U;
|
||||
archive_string_free(&hdr);
|
||||
}
|
||||
|
||||
@@ -238,9 +238,9 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
|
||||
w->typ = archive_entry_filetype(entry);
|
||||
w->entry_bytes_remaining = 0U;
|
||||
if (w->typ == AE_IFREG) {
|
||||
warc->typ = archive_entry_filetype(entry);
|
||||
warc->entry_bytes_remaining = 0U;
|
||||
if (warc->typ == AE_IFREG) {
|
||||
warc_essential_hdr_t rh = {
|
||||
WT_RSRC,
|
||||
/* URI */NULL,
|
||||
@@ -254,7 +254,7 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
|
||||
int rc;
|
||||
int64_t size;
|
||||
rh.tgturi = archive_entry_pathname(entry);
|
||||
rh.rtime = w->now;
|
||||
rh.rtime = warc->now;
|
||||
rh.mtime = archive_entry_mtime(entry);
|
||||
if (!archive_entry_size_is_set(entry)) {
|
||||
archive_set_error(&a->archive, -1,
|
||||
@@ -287,7 +287,7 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
|
||||
return (rc);
|
||||
}
|
||||
/* Save the remaining size for subsequent _data() calls. */
|
||||
w->entry_bytes_remaining = rh.cntlen;
|
||||
warc->entry_bytes_remaining = rh.cntlen;
|
||||
archive_string_free(&hdr);
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
@@ -300,14 +300,14 @@ _warc_header(struct archive_write *a, struct archive_entry *entry)
|
||||
static ssize_t
|
||||
_warc_data(struct archive_write *a, const void *buf, size_t len)
|
||||
{
|
||||
struct warc_s *w = a->format_data;
|
||||
struct warc *warc = a->format_data;
|
||||
|
||||
if (w->typ == AE_IFREG) {
|
||||
if (warc->typ == AE_IFREG) {
|
||||
int rc;
|
||||
|
||||
/* Never write more bytes than announced. */
|
||||
if ((uint64_t)len > w->entry_bytes_remaining) {
|
||||
len = (size_t)w->entry_bytes_remaining;
|
||||
if ((uint64_t)len > warc->entry_bytes_remaining) {
|
||||
len = (size_t)warc->entry_bytes_remaining;
|
||||
}
|
||||
|
||||
/* Write the entry data. */
|
||||
@@ -315,7 +315,7 @@ _warc_data(struct archive_write *a, const void *buf, size_t len)
|
||||
if (rc != ARCHIVE_OK) {
|
||||
return rc;
|
||||
}
|
||||
w->entry_bytes_remaining -= len;
|
||||
warc->entry_bytes_remaining -= len;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@@ -324,12 +324,12 @@ static int
|
||||
_warc_finish_entry(struct archive_write *a)
|
||||
{
|
||||
static const char _eor[] = "\r\n\r\n";
|
||||
struct warc_s *w = a->format_data;
|
||||
struct warc *warc = a->format_data;
|
||||
|
||||
if (w->typ == AE_IFREG) {
|
||||
if (warc->typ == AE_IFREG) {
|
||||
int rc;
|
||||
|
||||
if (w->entry_bytes_remaining != 0U) {
|
||||
if (warc->entry_bytes_remaining != 0U) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"WARC entry is shorter than Content-Length");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -341,7 +341,7 @@ _warc_finish_entry(struct archive_write *a)
|
||||
}
|
||||
}
|
||||
/* reset type info */
|
||||
w->typ = 0;
|
||||
warc->typ = 0;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
@@ -355,9 +355,9 @@ _warc_close(struct archive_write *a)
|
||||
static int
|
||||
_warc_free(struct archive_write *a)
|
||||
{
|
||||
struct warc_s *w = a->format_data;
|
||||
struct warc *warc = a->format_data;
|
||||
|
||||
free(w);
|
||||
free(warc);
|
||||
a->format_data = NULL;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user