Rizin
unix-like reverse engineering framework and cli tools
zip_source_file.h
Go to the documentation of this file.
1 /*
2  zip_source_file.h -- header for common file operations
3  Copyright (C) 2020-2022 Dieter Baron and Thomas Klausner
4 
5  This file is part of libzip, a library to manipulate ZIP archives.
6  The authors can be contacted at <info@libzip.org>
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions
10  are met:
11  1. Redistributions of source code must retain the above copyright
12  notice, this list of conditions and the following disclaimer.
13  2. Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in
15  the documentation and/or other materials provided with the
16  distribution.
17  3. The names of the authors may not be used to endorse or promote
18  products derived from this software without specific prior
19  written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
22  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 
35  zip_uint64_t size; /* must be valid for regular files */
36  time_t mtime; /* must always be valid, is initialized to current time */
37  bool exists; /* must always be valid */
38  bool regular_file; /* must always be valid */
39 };
40 
44 
46  zip_error_t error; /* last error information */
48 
49  /* reading */
50  char *fname; /* name of file to read from */
51  void *f; /* file to read from */
52  zip_stat_t st; /* stat information passed in */
53  zip_file_attributes_t attributes; /* additional file attributes */
54  zip_error_t stat_error; /* error returned for stat */
55  zip_uint64_t start; /* start offset of data to read */
56  zip_uint64_t len; /* length of the file, 0 for up to EOF */
57  zip_uint64_t offset; /* current offset relative to start (0 is beginning of part we read) */
58 
59  /* writing */
60  char *tmpname;
61  void *fout;
62 
64  void *ops_userdata;
65 };
66 
67 
68 /* The following methods must be implemented to support each feature:
69  - close, read, seek, and stat must always be implemented.
70  - To support specifying the file by name, open, and strdup must be implemented.
71  - For write support, the file must be specified by name and close, commit_write, create_temp_output, remove, rollback_write, and tell must be implemented.
72  - create_temp_output_cloning is always optional. */
73 
85  char *(*string_duplicate)(zip_source_file_context_t *ctx, const char *);
88 };
89 
size_t len
Definition: 6502dis.c:15
static struct @29 ops[]
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 start
Definition: sflib.h:133
voidpf uLong offset
Definition: ioapi.h:144
voidpf void * buf
Definition: ioapi.h:138
int time_t
Definition: sftypes.h:66
#define f(i)
Definition: sha256.c:46
Definition: gzappend.c:170
Definition: sftypes.h:80
Definition: zip.h:284
zip_file_attributes_t attributes
zip_source_file_operations_t * ops
zip_int64_t(* create_temp_output_cloning)(zip_source_file_context_t *ctx, zip_uint64_t len)
void(* rollback_write)(zip_source_file_context_t *ctx)
bool(* seek)(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence)
zip_int64_t(* commit_write)(zip_source_file_context_t *ctx)
bool(* open)(zip_source_file_context_t *ctx)
zip_int64_t(* write)(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len)
zip_int64_t(* read)(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len)
zip_int64_t(* create_temp_output)(zip_source_file_context_t *ctx)
zip_int64_t(* remove)(zip_source_file_context_t *ctx)
zip_int64_t(* tell)(zip_source_file_context_t *ctx, void *f)
void(* close)(zip_source_file_context_t *ctx)
Definition: zip.h:300
#define bool
Definition: sysdefs.h:146
void error(const char *msg)
Definition: untgz.c:593
zip_source_t * zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error)
uint64_t zip_uint64_t
Definition: zipconf.h:39
int64_t zip_int64_t
Definition: zipconf.h:38