Rizin
unix-like reverse engineering framework and cli tools
zip_source_function.c File Reference
#include <stdlib.h>
#include "zipint.h"

Go to the source code of this file.

Functions

ZIP_EXTERN zip_source_tzip_source_function (zip_t *za, zip_source_callback zcb, void *ud)
 
ZIP_EXTERN zip_source_tzip_source_function_create (zip_source_callback zcb, void *ud, zip_error_t *error)
 
ZIP_EXTERN void zip_source_keep (zip_source_t *src)
 
zip_source_t_zip_source_new (zip_error_t *error)
 

Function Documentation

◆ _zip_source_new()

zip_source_t* _zip_source_new ( zip_error_t error)

Definition at line 76 of file zip_source_function.c.

76  {
78 
79  if ((src = (zip_source_t *)malloc(sizeof(*src))) == NULL) {
81  return NULL;
82  }
83 
84  src->src = NULL;
85  src->cb.f = NULL;
86  src->ud = NULL;
87  src->open_count = 0;
88  src->write_state = ZIP_SOURCE_WRITE_CLOSED;
89  src->source_closed = false;
90  src->source_archive = NULL;
91  src->refcount = 1;
92  zip_error_init(&src->error);
93  src->eof = false;
94  src->had_read_error = false;
95  src->bytes_read = 0;
96 
97  return src;
98 }
lzma_index * src
Definition: index.h:567
#define NULL
Definition: cris-opc.c:27
ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int)
Definition: zip_error.c:126
#define ZIP_ER_MEMORY
Definition: zip.h:119
ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull)
Definition: zip_error.c:59
void * malloc(size_t size)
Definition: malloc.c:123
void error(const char *msg)
Definition: untgz.c:593
@ ZIP_SOURCE_WRITE_CLOSED
Definition: zipint.h:376

References error(), malloc(), NULL, src, ZIP_ER_MEMORY, zip_error_init(), zip_error_set(), and ZIP_SOURCE_WRITE_CLOSED.

Referenced by zip_source_function_create(), and zip_source_layered_create().

◆ zip_source_function()

ZIP_EXTERN zip_source_t* zip_source_function ( zip_t za,
zip_source_callback  zcb,
void *  ud 
)

Definition at line 41 of file zip_source_function.c.

41  {
42  if (za == NULL) {
43  return NULL;
44  }
45 
46  return zip_source_function_create(zcb, ud, &za->error);
47 }
zip_error_t error
Definition: zipint.h:281
ZIP_EXTERN zip_source_t * zip_source_function_create(zip_source_callback zcb, void *ud, zip_error_t *error)
zip_t * za
Definition: ziptool.c:79

References zip::error, NULL, za, and zip_source_function_create().

Referenced by source_nul().

◆ zip_source_function_create()

ZIP_EXTERN zip_source_t* zip_source_function_create ( zip_source_callback  zcb,
void *  ud,
zip_error_t error 
)

Definition at line 51 of file zip_source_function.c.

51  {
52  zip_source_t *zs;
53 
54  if ((zs = _zip_source_new(error)) == NULL)
55  return NULL;
56 
57  zs->cb.f = zcb;
58  zs->ud = ud;
59 
61  if (zs->supports < 0) {
63  }
64 
65  return zs;
66 }
#define ZIP_SOURCE_SUPPORTS_READABLE
Definition: zip.h:249
@ ZIP_SOURCE_SUPPORTS
Definition: zip.h:234
ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t,...)
void * ud
Definition: zipint.h:389
zip_source_callback f
Definition: zipint.h:386
union zip_source::@410 cb
zip_int64_t supports
Definition: zipint.h:391
zip_source_t * _zip_source_new(zip_error_t *error)

References _zip_source_new(), zip_source::cb, error(), zip_source::f, NULL, zip_source::supports, zip_source::ud, zip_source_make_command_bitmap(), ZIP_SOURCE_SUPPORTS, and ZIP_SOURCE_SUPPORTS_READABLE.

Referenced by source_hole_create(), zip_source_buffer_fragment_with_attributes_create(), zip_source_file_common_new(), and zip_source_function().

◆ zip_source_keep()

ZIP_EXTERN void zip_source_keep ( zip_source_t src)

Definition at line 70 of file zip_source_function.c.

70  {
71  src->refcount++;
72 }

References src.

Referenced by _zip_open(), add_data(), main(), read_to_memory(), and zip_source_layered_create().