39 #if defined(HAVE_WCHAR_H)
44 static int file_vprintf(RzMagic *ms,
const char *fmt, va_list ap) {
55 if (
len >
sizeof(cbuf)) {
62 if (nullbyte > 0 && nullbyte ==
sizeof(cbuf)) {
74 int obuflen = strlen(ms->o.buf);
118 if (!ms || ms->haderr) {
171 mime = ms->flags & RZ_MAGIC_MIME;
173 if ((!
mime || (
mime & RZ_MAGIC_MIME_TYPE)) &&
178 }
else if (nb == 1) {
179 if ((!
mime || (
mime & RZ_MAGIC_MIME_TYPE)) &&
180 file_printf(ms,
mime ?
"application/octet-stream" :
"very short file (no magic)") == -1) {
188 if ((ms->flags & RZ_MAGIC_NO_CHECK_COMPRESS) != 0 ||
192 if ((ms->flags & RZ_MAGIC_NO_CHECK_TAR) != 0 ||
195 if ((ms->flags & RZ_MAGIC_NO_CHECK_SOFT) != 0 ||
198 if ((ms->flags & RZ_MAGIC_NO_CHECK_ASCII) != 0 ||
201 if ((!
mime || (
mime & RZ_MAGIC_MIME_TYPE))) {
231 #define OCTALIFY(n, o) \
233 (void)(*(n)++ = '\\', \
234 *(n)++ = (((ut32) * (o) >> 6) & 3) + '0', \
235 *(n)++ = (((ut32) * (o) >> 3) & 7) + '0', \
236 *(n)++ = (((ut32) * (o) >> 0) & 7) + '0', \
240 char *pbuf, *
op, *np;
247 if (ms->flags & RZ_MAGIC_RAW) {
257 len = strlen(ms->o.buf);
263 if (!(pbuf =
realloc(ms->o.pbuf, psize))) {
275 size_t bytesconsumed;
286 if (bytesconsumed == (
size_t)(-1) ||
287 bytesconsumed == (
size_t)(-2)) {
293 (void)
memcpy(np,
op, bytesconsumed);
297 while (bytesconsumed-- > 0) {
310 for (np = ms->o.pbuf,
op = ms->o.buf; *
op;
op++) {
322 if (
level >= ms->c.len) {
323 size_t len = (ms->c.len += 20) *
sizeof(*ms->c.li);
330 ms->c.li[
level].got_match = 0;
331 ms->c.li[
level].last_match = 0;
332 ms->c.li[
level].last_cond = COND_NONE;
int file_ascmagic(RzMagic *ms, const ut8 *buf, size_t nbytes)
static RASN1String * newstr(const char *string)
const lzma_allocator const uint8_t size_t uint8_t * out
int file_is_tar(struct rz_magic_set *, const unsigned char *, size_t)
int file_zmagic(struct rz_magic_set *, int, const char *, const ut8 *, size_t)
int file_softmagic(struct rz_magic_set *, const unsigned char *, size_t, int)
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 mime
void file_oomem(RzMagic *ms, size_t len)
int file_check_mem(RzMagic *ms, unsigned int level)
int file_buffer(RzMagic *ms, int fd, const char *inname, const void *buf, size_t nb)
static void file_error_core(RzMagic *ms, int error, const char *f, va_list va, ut32 lineno)
const char * file_getbuffer(RzMagic *ms)
int file_printf(RzMagic *ms, const char *fmt,...)
void file_magerror(RzMagic *ms, const char *f,...)
void file_error(RzMagic *ms, int error, const char *f,...)
int file_reset(RzMagic *ms)
static int file_vprintf(RzMagic *ms, const char *fmt, va_list ap)
void file_badread(RzMagic *ms)
void file_badseek(RzMagic *ms)
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
void error(const char *msg)
static const z80_opcode fd[]