Rizin
unix-like reverse engineering framework and cli tools
zip_set_archive_flag.c File Reference
#include "zipint.h"

Go to the source code of this file.

Functions

ZIP_EXTERN int zip_set_archive_flag (zip_t *za, zip_flags_t flag, int value)
 

Function Documentation

◆ zip_set_archive_flag()

ZIP_EXTERN int zip_set_archive_flag ( zip_t za,
zip_flags_t  flag,
int  value 
)

Definition at line 39 of file zip_set_archive_flag.c.

39  {
40  unsigned int new_flags;
41 
42  if (value)
43  new_flags = za->ch_flags | flag;
44  else
45  new_flags = za->ch_flags & ~flag;
46 
47  if (new_flags == za->ch_flags)
48  return 0;
49 
50  if (ZIP_IS_RDONLY(za)) {
52  return -1;
53  }
54 
55  if ((flag & ZIP_AFL_RDONLY) && value && (za->ch_flags & ZIP_AFL_RDONLY) == 0) {
56  if (_zip_changed(za, NULL)) {
58  return -1;
59  }
60  }
61 
62  za->ch_flags = new_flags;
63 
64  return 0;
65 }
static int value
Definition: cmd_api.c:93
#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_AFL_RDONLY
Definition: zip.h:94
#define ZIP_ER_CHANGED
Definition: zip.h:120
#define ZIP_ER_RDONLY
Definition: zip.h:130
unsigned int ch_flags
Definition: zipint.h:284
zip_error_t error
Definition: zipint.h:281
int _zip_changed(const zip_t *za, zip_uint64_t *survivorsp)
Definition: zip_close.c:655
#define ZIP_IS_RDONLY(za)
Definition: zipint.h:479
zip_t * za
Definition: ziptool.c:79

References _zip_changed(), zip::ch_flags, zip::error, NULL, value, za, ZIP_AFL_RDONLY, ZIP_ER_CHANGED, ZIP_ER_RDONLY, zip_error_set(), and ZIP_IS_RDONLY.