Rizin
unix-like reverse engineering framework and cli tools
blast.h File Reference

Go to the source code of this file.

Typedefs

typedef unsigned(* blast_in) (void *how, unsigned char **buf)
 
typedef int(* blast_out) (void *how, unsigned char *buf, unsigned len)
 

Functions

int blast (blast_in infun, void *inhow, blast_out outfun, void *outhow, unsigned *left, unsigned char **in)
 

Typedef Documentation

◆ blast_in

typedef unsigned(* blast_in) (void *how, unsigned char **buf)

Definition at line 38 of file blast.h.

◆ blast_out

typedef int(* blast_out) (void *how, unsigned char *buf, unsigned len)

Definition at line 39 of file blast.h.

Function Documentation

◆ blast()

int blast ( blast_in  infun,
void *  inhow,
blast_out  outfun,
void *  outhow,
unsigned left,
unsigned char **  in 
)

Definition at line 383 of file blast.c.

385 {
386  struct state s; /* input/output state */
387  int err; /* return value */
388 
389  /* initialize input state */
390  s.infun = infun;
391  s.inhow = inhow;
392  if (left != NULL && *left) {
393  s.left = *left;
394  s.in = *in;
395  }
396  else
397  s.left = 0;
398  s.bitbuf = 0;
399  s.bitcnt = 0;
400 
401  /* initialize output state */
402  s.outfun = outfun;
403  s.outhow = outhow;
404  s.next = 0;
405  s.first = 1;
406 
407  /* return if bits() or decode() tries to read past available input */
408  if (setjmp(s.env) != 0) /* if came back here via longjmp(), */
409  err = 2; /* then skip decomp(), return error */
410  else
411  err = decomp(&s); /* decompress */
412 
413  /* return unused input */
414  if (left != NULL)
415  *left = s.left;
416  if (in != NULL)
417  *in = s.left ? s.in : NULL;
418 
419  /* write any leftover output and update the error code if needed */
420  if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0)
421  err = 1;
422  return err;
423 }
static bool err
Definition: armass.c:435
int decomp(struct state *s)
Definition: blast.c:282
const lzma_allocator const uint8_t * in
Definition: block.h:527
#define NULL
Definition: cris-opc.c:27
static RzSocket * s
Definition: rtr.c:28
Definition: dis.h:43
unsigned left
Definition: blast.c:46
blast_out outfun
Definition: blast.c:54
blast_in infun
Definition: blast.c:43
void * outhow
Definition: blast.c:55
void * inhow
Definition: blast.c:44

References decomp(), err, in, state::infun, state::inhow, state::left, NULL, state::outfun, state::outhow, and s.