6 #define AR_MAGIC_HEADER "!<arch>\n"
7 #define AR_FILE_HEADER_END "`\n"
20 f->shared_buf = shared_buf;
57 if (
c ==
'\n' ||
c ==
'\0') {
67 #define VERIFY_AR_NUM_FIELD(x, s) \
68 x[sizeof(x) - 1] = '\0'; \
69 rz_str_trim_tail(x); \
70 if (x[0] != '\0' && (x[0] == '-' || !rz_str_isnumber(x))) { \
71 RZ_LOG_ERROR("ar: Malformed AR: bad %s in header at offset 0x%" PFMT64x "\n", s, h_off); \
101 if (
r !=
sizeof(
h)) {
125 if (
h.size[0] ==
'\0') {
131 h.timestamp[0] =
'\0';
137 if (!strcmp(
h.name,
"/")) {
145 }
else if (!strcmp(
h.name,
"//")) {
169 RZ_LOG_ERROR(
"ar: invalid ar file: invalid file name in header at: 0x%" PFMT64x "\n", h_off);
174 if (
tmp[0] ==
'\0') {
180 RZ_LOG_ERROR(
"ar: invalid ar file: invalid file name in header at: 0x%" PFMT64x "\n", h_off);
188 RZ_LOG_ERROR(
"ar: invalid ar file: invalid file name in header at: 0x%" PFMT64x "\n", h_off);
209 #undef VERIFY_AR_NUM_FIELD
250 shared = !rz_list_empty(
files);
343 if (!
f->shared_buf) {
RZ_API RzList * ar_open_all(const char *arname, int perm)
Open specific file withen a ar/lib file.
struct Filetable filetable
bool ar_check_magic(RzBuffer *b)
RZ_API int ar_write_at(RzArFp *f, ut64 off, void *buf, int count)
static char * name_from_table(ut64 off, filetable *tbl)
RZ_API int ar_read_at(RzArFp *f, ut64 off, void *buf, int count)
RZ_API RzArFp * ar_open_file(const char *arname, int perm, const char *filename)
Open specific file withen a ar/lib file.
#define AR_FILE_HEADER_END
static void arf_clean_name(RzArFp *arf)
#define VERIFY_AR_NUM_FIELD(x, s)
static int ar_parse_header(RzArFp *arf, filetable *tbl, ut64 arsize)
static RzArFp * arfp_new(RzBuffer *b, bool shared_buf)
RZ_API void ar_close(RzArFp *f)
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 count
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type special files
RZ_API void Ht_() free(HtName_(Ht) *ht)
static void list(RzEgg *egg)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_OWN void * rz_list_pop(RZ_NONNULL RzList *list)
Removes and returns the last element of the list.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API RZ_OWN void * rz_list_pop_head(RZ_NONNULL RzList *list)
Removes and returns the first element of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
#define header(is_bt, len_min, ret_op)
#define rz_return_val_if_fail(expr, val)
RZ_API ut64 rz_buf_tell(RZ_NONNULL RzBuffer *b)
Return the current cursor position.
RZ_API st64 rz_buf_seek(RZ_NONNULL RzBuffer *b, st64 addr, int whence)
Modify the current cursor position in the buffer.
RZ_API st64 rz_buf_write_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL const ut8 *buf, ut64 len)
Write len bytes of the buffer at the specified address.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API st64 rz_buf_read(RZ_NONNULL RzBuffer *b, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_file(const char *file, int perm, int mode)
Creates a new buffer from a file.
void(* RzListFree)(void *ptr)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API char RZ_API char * rz_str_newlen(const char *str, int len)
RZ_API RZ_BORROW char * rz_str_trim_tail(RZ_NONNULL char *str)
Removes whitespace characters (space, tab, newline etc.) from the end of a string and replaces them w...
RZ_API RzList * rz_str_split_duplist(const char *str, const char *c, bool trim)
Split the string str according to the substring c and returns a RzList with the result.
RZ_API bool rz_str_isnumber(const char *str)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()