the duplicate copies of this function.
SVN-Revision: 2262
return (__archive_write_filter(a->filter_first, buff, length));
}
+int
+__archive_write_nulls(struct archive_write *a, size_t length)
+{
+ if (length == 0)
+ return (ARCHIVE_OK);
+
+ while (length > 0) {
+ size_t to_write = length < a->null_length ? length : a->null_length;
+ int r = __archive_write_output(a, a->nulls, to_write);
+ if (r < ARCHIVE_OK)
+ return (r);
+ length -= to_write;
+ }
+ return (ARCHIVE_OK);
+}
+
static int
archive_write_client_open(struct archive_write_filter *f)
{
struct archive_write_filter *__archive_write_allocate_filter(struct archive *);
int __archive_write_output(struct archive_write *, const void *, size_t);
+int __archive_write_nulls(struct archive_write *, size_t);
int __archive_write_filter(struct archive_write_filter *, const void *, size_t);
int __archive_write_open_filter(struct archive_write_filter *);
int __archive_write_close_filter(struct archive_write_filter *);
archive_write_cpio_finish_entry(struct archive_write *a)
{
struct cpio *cpio;
- size_t to_write;
- int ret;
cpio = (struct cpio *)a->format_data;
- ret = ARCHIVE_OK;
- while (cpio->entry_bytes_remaining > 0) {
- to_write = cpio->entry_bytes_remaining < a->null_length ?
- cpio->entry_bytes_remaining : a->null_length;
- ret = __archive_write_output(a, a->nulls, to_write);
- if (ret != ARCHIVE_OK)
- return (ret);
- cpio->entry_bytes_remaining -= to_write;
- }
- return (ret);
+ return (__archive_write_nulls(a, cpio->entry_bytes_remaining));
}
archive_write_newc_finish_entry(struct archive_write *a)
{
struct cpio *cpio;
- size_t to_write;
- int ret;
cpio = (struct cpio *)a->format_data;
- while (cpio->entry_bytes_remaining > 0) {
- to_write = cpio->entry_bytes_remaining < a->null_length ?
- cpio->entry_bytes_remaining : a->null_length;
- ret = __archive_write_output(a, a->nulls, to_write);
- if (ret != ARCHIVE_OK)
- return (ret);
- cpio->entry_bytes_remaining -= to_write;
- }
- ret = __archive_write_output(a, a->nulls, cpio->padding);
- return (ret);
+ return (__archive_write_nulls(a, cpio->entry_bytes_remaining + cpio->padding));
}
static void sparse_list_clear(struct pax *);
static int sparse_list_add(struct pax *, int64_t, int64_t);
static char *url_encode(const char *in);
-static int write_nulls(struct archive_write *, size_t);
/*
* Set output format to 'restricted pax' format.
return (ARCHIVE_FATAL);
}
/* Pad out the end of the entry. */
- r = write_nulls(a, pax->entry_padding);
+ r = __archive_write_nulls(a, pax->entry_padding);
if (r != ARCHIVE_OK) {
/* If a write fails, we're pretty much toast. */
return (ARCHIVE_FATAL);
static int
archive_write_pax_close(struct archive_write *a)
{
- return (write_nulls(a, 512 * 2));
+ return (__archive_write_nulls(a, 512 * 2));
}
static int
pax->sparse_list = sb;
}
}
- ret = write_nulls(a, remaining + pax->entry_padding);
+ ret = __archive_write_nulls(a, remaining + pax->entry_padding);
pax->entry_bytes_remaining = pax->entry_padding = 0;
return (ret);
}
-static int
-write_nulls(struct archive_write *a, size_t padding)
-{
- int ret;
- size_t to_write;
-
- while (padding > 0) {
- to_write = padding < a->null_length ? padding : a->null_length;
- ret = __archive_write_output(a, a->nulls, to_write);
- if (ret != ARCHIVE_OK)
- return (ret);
- padding -= to_write;
- }
- return (ARCHIVE_OK);
-}
-
static ssize_t
archive_write_pax_data(struct archive_write *a, const void *buff, size_t s)
{
archive_strlen(&(pax->sparse_map)));
if (ret != ARCHIVE_OK)
return (ret);
- ret = write_nulls(a, pax->sparse_map_padding);
+ ret = __archive_write_nulls(a, pax->sparse_map_padding);
if (ret != ARCHIVE_OK)
return (ret);
archive_string_empty(&(pax->sparse_map));
static int format_256(int64_t, char *, int);
static int format_number(int64_t, char *, int size, int max, int strict);
static int format_octal(int64_t, char *, int);
-static int write_nulls(struct archive_write *a, size_t);
/*
* Set output format to 'ustar' format.
static int
archive_write_ustar_close(struct archive_write *a)
{
- return (write_nulls(a, 512*2));
+ return (__archive_write_nulls(a, 512*2));
}
static int
int ret;
ustar = (struct ustar *)a->format_data;
- ret = write_nulls(a,
+ ret = __archive_write_nulls(a,
ustar->entry_bytes_remaining + ustar->entry_padding);
ustar->entry_bytes_remaining = ustar->entry_padding = 0;
return (ret);
}
-static int
-write_nulls(struct archive_write *a, size_t padding)
-{
- int ret;
- size_t to_write;
-
- while (padding > 0) {
- to_write = padding < a->null_length ? padding : a->null_length;
- ret = __archive_write_output(a, a->nulls, to_write);
- if (ret != ARCHIVE_OK)
- return (ret);
- padding -= to_write;
- }
- return (ARCHIVE_OK);
-}
-
static ssize_t
archive_write_ustar_data(struct archive_write *a, const void *buff, size_t s)
{