5 #define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b))
22 #define OPTIONS_REGRESS "F:Hm"
24 #define USAGE_REGRESS " [-Hm] [-F fragment-size]"
26 #define GETOPT_REGRESS \
28 source_type = SOURCE_TYPE_HOLE; \
31 source_type = SOURCE_TYPE_IN_MEMORY; \
34 fragment_size = strtoull(optarg, NULL, 10); \
39 #define DISPATCH_REGRESS \
40 {"add_nul", 2, "name length", "add NUL bytes", add_nul}, \
41 {"cancel", 1, "limit", "cancel writing archive when limit% have been written (calls print_progress)", cancel}, \
42 {"is_seekable", 1, "index", "report if entry is seekable", is_seekable}, \
43 {"seek", 2, "index offset", "seek in entry to offset", seek}, \
44 {"unchange", 1, "index", "revert changes for entry", unchange_one}, \
45 {"unchange_all", 0, "", "revert all changes", unchange_all}, \
46 { "zin_close", 1, "index", "close input zip_source (for internal tests)", zin_close }
71 fprintf(stderr,
"can't create zip_source for length: %s\n",
zip_strerror(
za));
94 percent = strtoll(
argv[0],
NULL, 10);
95 if (percent > 100 || percent < 0) {
96 fprintf(stderr,
"invalid percentage '%" PRId64 "' for cancel (valid: 0 <= x <= 100)\n", percent);
154 fprintf(stderr,
"can't revert changes to archive: %s\n",
zip_strerror(
za));
181 fprintf(stderr,
"invalid argument '%" PRIu64 "', only %u zip sources open\n",
idx,
z_in_count);
200 if (strcmp(
archive,
"/dev/stdin") == 0) {
219 if (strcmp(
archive,
"/dev/stdin") == 0) {
236 if (
fstat(fileno(fp), &st) < 0) {
248 if (fread(
buf, (
size_t)st.st_size, 1, fp) < 1) {
264 if ((fragments =
malloc(
sizeof(fragments[0]) * nfragments)) ==
NULL) {
269 for (
i = 0;
i < nfragments;
i++) {
272 #ifndef __clang_analyzer__
275 free(fragments[
i].data);
284 if (fread(fragments[
i].data, left, 1, fp) < 1) {
285 #ifndef __clang_analyzer__
288 free(fragments[
i].data);
299 for (
i = 0;
i < nfragments;
i++) {
300 free(fragments[
i].data);
421 fprintf(stderr,
"unlink failed: %s\n", strerror(errno));
430 fprintf(stderr,
"malloc failed: %s\n", strerror(errno));
442 fprintf(stderr,
"fopen failed: %s\n", strerror(errno));
446 if (fwrite(
buf, zst.
size, 1, fp) < 1) {
447 fprintf(stderr,
"fwrite failed: %s\n", strerror(errno));
453 if (fclose(fp) != 0) {
454 fprintf(stderr,
"fclose failed: %s\n", strerror(errno));
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset fstat
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
ZIP_EXTERN int zip_source_close(zip_source_t *_Nonnull)
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
ZIP_EXTERN int zip_file_is_seekable(zip_file_t *_Nonnull)
ZIP_EXTERN zip_t *_Nullable zip_open_from_source(zip_source_t *_Nonnull, int, zip_error_t *_Nullable)
ZIP_EXTERN zip_int64_t zip_source_read(zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t)
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment_create(const zip_buffer_fragment_t *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable)
ZIP_EXTERN int zip_unchange(zip_t *_Nonnull, zip_uint64_t)
ZIP_EXTERN zip_int64_t zip_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull)
ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_create(const void *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable)
ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull)
ZIP_EXTERN zip_error_t *_Nonnull zip_source_error(zip_source_t *_Nonnull)
ZIP_EXTERN zip_int8_t zip_fseek(zip_file_t *_Nonnull, zip_int64_t, int)
ZIP_EXTERN int zip_source_stat(zip_source_t *_Nonnull, zip_stat_t *_Nonnull)
enum zip_source_cmd zip_source_cmd_t
ZIP_EXTERN zip_error_t *_Nonnull zip_get_error(zip_t *_Nonnull)
ZIP_EXTERN int zip_register_cancel_callback_with_state(zip_t *_Nonnull, zip_cancel_callback _Nullable, void(*_Nullable)(void *_Nullable), void *_Nullable)
ZIP_EXTERN int zip_close(zip_t *_Nonnull)
ZIP_EXTERN int zip_source_open(zip_source_t *_Nonnull)
ZIP_EXTERN int zip_unchange_all(zip_t *_Nonnull)
ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t,...)
ZIP_EXTERN zip_source_t *_Nullable zip_source_function(zip_t *_Nonnull, zip_source_callback _Nonnull, void *_Nullable)
ZIP_EXTERN int zip_error_code_zip(const zip_error_t *_Nonnull)
ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable)
ZIP_EXTERN const char *_Nonnull zip_error_strerror(zip_error_t *_Nonnull)
ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t)
ZIP_EXTERN void zip_source_keep(zip_source_t *_Nonnull)
ZIP_EXTERN zip_int64_t zip_error_to_data(const zip_error_t *_Nonnull, void *_Nonnull, zip_uint64_t)
ZIP_EXTERN const char *_Nonnull zip_strerror(zip_t *_Nonnull)
#define ZIP_SOURCE_GET_ARGS(type, data, len, error)
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char argv
static static fork const void static count static fd const char static mode unlink
static struct sockaddr static addrlen static backlog const void static flags void flags
void print_progress(uv_async_t *handle)
void error(const char *msg)