Rizin
unix-like reverse engineering framework and cli tools
libiberty.h File Reference
#include "ansidecl.h"
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  pex_time
 

Macros

#define basename   basename_cannot_be_used_without_a_prototype
 
#define ACONCAT(ACONCAT_PARAMS)
 
#define XALLOCA(T)   ((T *)alloca(sizeof(T)))
 
#define XNEW(T)   ((T *)xmalloc(sizeof(T)))
 
#define XCNEW(T)   ((T *)xcalloc(1, sizeof(T)))
 
#define XALLOCA(T)   ((T *)alloca(sizeof(T)))
 
#define XNEW(T)   ((T *)xmalloc(sizeof(T)))
 
#define XCNEW(T)   ((T *)xcalloc(1, sizeof(T)))
 
#define XDUP(T, P)   ((T *)xmemdup((P), sizeof(T), sizeof(T)))
 
#define XDELETE(P)   free((void *)(P))
 
#define XALLOCAVEC(T, N)   ((T *)alloca(sizeof(T) * (N)))
 
#define XNEWVEC(T, N)   ((T *)xmalloc(sizeof(T) * (N)))
 
#define XCNEWVEC(T, N)   ((T *)xcalloc((N), sizeof(T)))
 
#define XDUPVEC(T, P, N)   ((T *)xmemdup((P), sizeof(T) * (N), sizeof(T) * (N)))
 
#define XRESIZEVEC(T, P, N)   ((T *)xrealloc((void *)(P), sizeof(T) * (N)))
 
#define XDELETEVEC(P)   free((void *)(P))
 
#define XALLOCAVAR(T, S)   ((T *)alloca((S)))
 
#define XNEWVAR(T, S)   ((T *)xmalloc((S)))
 
#define XCNEWVAR(T, S)   ((T *)xcalloc(1, (S)))
 
#define XDUPVAR(T, P, S1, S2)   ((T *)xmemdup((P), (S1), (S2)))
 
#define XRESIZEVAR(T, P, S)   ((T *)xrealloc((P), (S)))
 
#define XOBNEW(O, T)   ((T *)obstack_alloc((O), sizeof(T)))
 
#define XOBNEWVEC(O, T, N)   ((T *)obstack_alloc((O), sizeof(T) * (N)))
 
#define XOBNEWVAR(O, T, S)   ((T *)obstack_alloc((O), (S)))
 
#define XOBFINISH(O, T)   ((T)obstack_finish((O)))
 
#define _hex_array_size   256
 
#define _hex_bad   99
 
#define hex_p(c)   (hex_value(c) != _hex_bad)
 
#define hex_value(c)   ((unsigned int)_hex_value[(unsigned char)(c)])
 
#define PEX_RECORD_TIMES   0x1
 
#define PEX_USE_PIPES   0x2
 
#define PEX_SAVE_TEMPS   0x4
 
#define PEX_LAST   0x1
 
#define PEX_SEARCH   0x2
 
#define PEX_SUFFIX   0x4
 
#define PEX_STDERR_TO_STDOUT   0x8
 
#define PEX_BINARY_INPUT   0x10
 
#define PEX_BINARY_OUTPUT   0x20
 
#define PEX_STDERR_TO_PIPE   0x40
 
#define PEX_BINARY_ERROR   0x80
 
#define PEXECUTE_FIRST   1
 
#define PEXECUTE_LAST   2
 
#define PEXECUTE_ONE   (PEXECUTE_FIRST + PEXECUTE_LAST)
 
#define PEXECUTE_SEARCH   4
 
#define PEXECUTE_VERBOSE   8
 
#define ARRAY_SIZE(a)   (sizeof(a) / sizeof((a)[0]))
 
#define alloca(x)   _alloca(x)
 
#define USE_C_ALLOCA   1
 
#define C_ALLOCA   1
 
#define ASTRDUP(X)
 

Functions

void unlock_stream (FILE *)
 
void unlock_std_streams (void)
 
FILE * fopen_unlocked (const char *, const char *)
 
FILE * fdopen_unlocked (int, const char *)
 
FILE * freopen_unlocked (const char *, const char *, FILE *)
 
char ** buildargv (const char *) ATTRIBUTE_MALLOC
 
void freeargv (char **)
 
char ** dupargv (char **) ATTRIBUTE_MALLOC
 
void expandargv PARAMS ((int *, char ***))
 
int writeargv PARAMS ((char **, FILE *))
 
const char * lbasename (const char *)
 
const char * dos_lbasename (const char *)
 
const char * unix_lbasename (const char *)
 
char * lrealpath (const char *)
 
char * concat (const char *,...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL
 
char * reconcat (char *, const char *,...) ATTRIBUTE_MALLOC ATTRIBUTE_SENTINEL
 
unsigned long concat_length (const char *,...) ATTRIBUTE_SENTINEL
 
char * concat_copy (char *, const char *,...) ATTRIBUTE_SENTINEL
 
char * concat_copy2 (const char *,...) ATTRIBUTE_SENTINEL
 
int fdmatch (int fd1, int fd2)
 
char * getpwd (void)
 
long get_run_time (void)
 
char * make_relative_prefix (const char *, const char *, const char *) ATTRIBUTE_MALLOC
 
char * make_relative_prefix_ignore_links (const char *, const char *, const char *) ATTRIBUTE_MALLOC
 
char * choose_temp_base (void) ATTRIBUTE_MALLOC
 
char * make_temp_file (const char *) ATTRIBUTE_MALLOC
 
int unlink_if_ordinary (const char *)
 
const char * spaces (int count)
 
int errno_max (void)
 
const char * strerrno (int)
 
int strtoerrno (const char *)
 
char * xstrerror (int)
 
int signo_max (void)
 
const char * strsigno (int)
 
int strtosigno (const char *)
 
int xatexit (void(*fn)(void))
 
void xexit (int status) ATTRIBUTE_NORETURN
 
void xmalloc_set_program_name (const char *)
 
void xmalloc_failed (size_t) ATTRIBUTE_NORETURN
 
void * xmalloc (size_t) ATTRIBUTE_MALLOC
 
void * xrealloc (void *, size_t)
 
void * xcalloc (size_t, size_t) ATTRIBUTE_MALLOC
 
char * xstrdup (const char *) ATTRIBUTE_MALLOC
 
char * xstrndup (const char *, size_t) ATTRIBUTE_MALLOC
 
void * xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC
 
double physmem_total (void)
 
double physmem_available (void)
 
unsigned int xcrc32 (const unsigned char *, int, unsigned int)
 
void hex_init (void)
 
struct pex_obj * pex_init (int flags, const char *pname, const char *tempbase)
 
const char * pex_run (struct pex_obj *obj, int flags, const char *executable, char *const *argv, const char *outname, const char *errname, int *err)
 
const char * pex_run_in_environment (struct pex_obj *obj, int flags, const char *executable, char *const *argv, char *const *env, const char *outname, const char *errname, int *err)
 
FILE * pex_input_file (struct pex_obj *obj, int flags, const char *in_name)
 
FILE * pex_input_pipe (struct pex_obj *obj, int binary)
 
FILE * pex_read_output (struct pex_obj *, int binary)
 
FILE * pex_read_err (struct pex_obj *, int binary)
 
int pex_get_status (struct pex_obj *, int count, int *vector)
 
int pex_get_times (struct pex_obj *, int count, struct pex_time *vector)
 
void pex_free (struct pex_obj *)
 
const char * pex_one (int flags, const char *executable, char *const *argv, const char *pname, const char *outname, const char *errname, int *status, int *err)
 
int pexecute (const char *, char *const *, const char *, const char *, char **, char **, int)
 
int pwait (int, int *, int)
 
int asprintf (char **, const char *,...) ATTRIBUTE_PRINTF_2
 
int vasprintf (char **, const char *, va_list) ATTRIBUTE_PRINTF(2
 
int void setproctitle (const char *name,...)
 
void * _alloca (size_t) ATTRIBUTE_MALLOC
 

Variables

char * libiberty_concat_ptr
 
const unsigned char _hex_value [_hex_array_size]
 
const char * libiberty_optr
 
char * libiberty_nptr
 
unsigned long libiberty_len
 

Macro Definition Documentation

◆ _hex_array_size

#define _hex_array_size   256

Definition at line 382 of file libiberty.h.

◆ _hex_bad

#define _hex_bad   99

Definition at line 383 of file libiberty.h.

◆ ACONCAT

#define ACONCAT (   ACONCAT_PARAMS)
Value:
(libiberty_concat_ptr = (char *)alloca(concat_length ACONCAT_PARAMS + 1), \
concat_copy2 ACONCAT_PARAMS)
char * libiberty_concat_ptr
unsigned long concat_length(const char *,...) ATTRIBUTE_SENTINEL
#define alloca(x)
Definition: libiberty.h:672

Definition at line 180 of file libiberty.h.

◆ alloca

#define alloca (   x)    _alloca(x)

Definition at line 672 of file libiberty.h.

◆ ARRAY_SIZE

#define ARRAY_SIZE (   a)    (sizeof(a) / sizeof((a)[0]))

Definition at line 651 of file libiberty.h.

◆ ASTRDUP

#define ASTRDUP (   X)
Value:
(libiberty_optr = (X), \
libiberty_len = strlen(libiberty_optr) + 1, \
libiberty_nptr = (char *)alloca(libiberty_len), \
#define X(x, b, m)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
char * libiberty_nptr
const char * libiberty_optr
unsigned long libiberty_len

Definition at line 680 of file libiberty.h.

◆ basename

#define basename   basename_cannot_be_used_without_a_prototype

Definition at line 114 of file libiberty.h.

◆ C_ALLOCA

#define C_ALLOCA   1

Definition at line 676 of file libiberty.h.

◆ hex_p

#define hex_p (   c)    (hex_value(c) != _hex_bad)

Definition at line 386 of file libiberty.h.

◆ hex_value

#define hex_value (   c)    ((unsigned int)_hex_value[(unsigned char)(c)])

Definition at line 389 of file libiberty.h.

◆ PEX_BINARY_ERROR

#define PEX_BINARY_ERROR   0x80

Definition at line 452 of file libiberty.h.

◆ PEX_BINARY_INPUT

#define PEX_BINARY_INPUT   0x10

Definition at line 433 of file libiberty.h.

◆ PEX_BINARY_OUTPUT

#define PEX_BINARY_OUTPUT   0x20

Definition at line 440 of file libiberty.h.

◆ PEX_LAST

#define PEX_LAST   0x1

Definition at line 420 of file libiberty.h.

◆ PEX_RECORD_TIMES

#define PEX_RECORD_TIMES   0x1

Definition at line 394 of file libiberty.h.

◆ PEX_SAVE_TEMPS

#define PEX_SAVE_TEMPS   0x4

Definition at line 400 of file libiberty.h.

◆ PEX_SEARCH

#define PEX_SEARCH   0x2

Definition at line 423 of file libiberty.h.

◆ PEX_STDERR_TO_PIPE

#define PEX_STDERR_TO_PIPE   0x40

Definition at line 448 of file libiberty.h.

◆ PEX_STDERR_TO_STDOUT

#define PEX_STDERR_TO_STDOUT   0x8

Definition at line 429 of file libiberty.h.

◆ PEX_SUFFIX

#define PEX_SUFFIX   0x4

Definition at line 426 of file libiberty.h.

◆ PEX_USE_PIPES

#define PEX_USE_PIPES   0x2

Definition at line 397 of file libiberty.h.

◆ PEXECUTE_FIRST

#define PEXECUTE_FIRST   1

Definition at line 604 of file libiberty.h.

◆ PEXECUTE_LAST

#define PEXECUTE_LAST   2

Definition at line 605 of file libiberty.h.

◆ PEXECUTE_ONE

#define PEXECUTE_ONE   (PEXECUTE_FIRST + PEXECUTE_LAST)

Definition at line 606 of file libiberty.h.

◆ PEXECUTE_SEARCH

#define PEXECUTE_SEARCH   4

Definition at line 607 of file libiberty.h.

◆ PEXECUTE_VERBOSE

#define PEXECUTE_VERBOSE   8

Definition at line 608 of file libiberty.h.

◆ USE_C_ALLOCA

#define USE_C_ALLOCA   1

Definition at line 674 of file libiberty.h.

◆ XALLOCA [1/2]

#define XALLOCA (   T)    ((T *)alloca(sizeof(T)))

Definition at line 350 of file libiberty.h.

◆ XALLOCA [2/2]

#define XALLOCA (   T)    ((T *)alloca(sizeof(T)))

Definition at line 350 of file libiberty.h.

◆ XALLOCAVAR

#define XALLOCAVAR (   T,
  S 
)    ((T *)alloca((S)))

Definition at line 367 of file libiberty.h.

◆ XALLOCAVEC

#define XALLOCAVEC (   T,
  N 
)    ((T *)alloca(sizeof(T) * (N)))

Definition at line 358 of file libiberty.h.

◆ XCNEW [1/2]

#define XCNEW (   T)    ((T *)xcalloc(1, sizeof(T)))

Definition at line 352 of file libiberty.h.

◆ XCNEW [2/2]

#define XCNEW (   T)    ((T *)xcalloc(1, sizeof(T)))

Definition at line 352 of file libiberty.h.

◆ XCNEWVAR

#define XCNEWVAR (   T,
  S 
)    ((T *)xcalloc(1, (S)))

Definition at line 369 of file libiberty.h.

◆ XCNEWVEC

#define XCNEWVEC (   T,
  N 
)    ((T *)xcalloc((N), sizeof(T)))

Definition at line 360 of file libiberty.h.

◆ XDELETE

#define XDELETE (   P)    free((void *)(P))

Definition at line 354 of file libiberty.h.

◆ XDELETEVEC

#define XDELETEVEC (   P)    free((void *)(P))

Definition at line 363 of file libiberty.h.

◆ XDUP

#define XDUP (   T,
  P 
)    ((T *)xmemdup((P), sizeof(T), sizeof(T)))

Definition at line 353 of file libiberty.h.

◆ XDUPVAR

#define XDUPVAR (   T,
  P,
  S1,
  S2 
)    ((T *)xmemdup((P), (S1), (S2)))

Definition at line 370 of file libiberty.h.

◆ XDUPVEC

#define XDUPVEC (   T,
  P,
  N 
)    ((T *)xmemdup((P), sizeof(T) * (N), sizeof(T) * (N)))

Definition at line 361 of file libiberty.h.

◆ XNEW [1/2]

#define XNEW (   T)    ((T *)xmalloc(sizeof(T)))

Definition at line 351 of file libiberty.h.

◆ XNEW [2/2]

#define XNEW (   T)    ((T *)xmalloc(sizeof(T)))

Definition at line 351 of file libiberty.h.

◆ XNEWVAR

#define XNEWVAR (   T,
  S 
)    ((T *)xmalloc((S)))

Definition at line 368 of file libiberty.h.

◆ XNEWVEC

#define XNEWVEC (   T,
  N 
)    ((T *)xmalloc(sizeof(T) * (N)))

Definition at line 359 of file libiberty.h.

◆ XOBFINISH

#define XOBFINISH (   O,
  T 
)    ((T)obstack_finish((O)))

Definition at line 378 of file libiberty.h.

◆ XOBNEW

#define XOBNEW (   O,
  T 
)    ((T *)obstack_alloc((O), sizeof(T)))

Definition at line 375 of file libiberty.h.

◆ XOBNEWVAR

#define XOBNEWVAR (   O,
  T,
  S 
)    ((T *)obstack_alloc((O), (S)))

Definition at line 377 of file libiberty.h.

◆ XOBNEWVEC

#define XOBNEWVEC (   O,
  T,
  N 
)    ((T *)obstack_alloc((O), sizeof(T) * (N)))

Definition at line 376 of file libiberty.h.

◆ XRESIZEVAR

#define XRESIZEVAR (   T,
  P,
  S 
)    ((T *)xrealloc((P), (S)))

Definition at line 371 of file libiberty.h.

◆ XRESIZEVEC

#define XRESIZEVEC (   T,
  P,
  N 
)    ((T *)xrealloc((void *)(P), sizeof(T) * (N)))

Definition at line 362 of file libiberty.h.

Function Documentation

◆ _alloca()

void* _alloca ( size_t  )

◆ asprintf()

int asprintf ( char **  ,
const char *  ,
  ... 
)

◆ buildargv()

char** buildargv ( const char *  )

◆ choose_temp_base()

char* choose_temp_base ( void  )

◆ concat()

char* concat ( const char *  ,
  ... 
)

◆ concat_copy()

char* concat_copy ( char *  ,
const char *  ,
  ... 
)

◆ concat_copy2()

char* concat_copy2 ( const char *  ,
  ... 
)

◆ concat_length()

unsigned long concat_length ( const char *  ,
  ... 
)

◆ dos_lbasename()

const char* dos_lbasename ( const char *  )

◆ dupargv()

char** dupargv ( char **  )

◆ errno_max()

int errno_max ( void  )

◆ fdmatch()

int fdmatch ( int  fd1,
int  fd2 
)

◆ fdopen_unlocked()

FILE* fdopen_unlocked ( int  ,
const char *   
)

◆ fopen_unlocked()

FILE* fopen_unlocked ( const char *  ,
const char *   
)

◆ freeargv()

void freeargv ( char **  )

◆ freopen_unlocked()

FILE* freopen_unlocked ( const char *  ,
const char *  ,
FILE *   
)

◆ get_run_time()

long get_run_time ( void  )

◆ getpwd()

char* getpwd ( void  )

◆ hex_init()

void hex_init ( void  )

◆ lbasename()

const char* lbasename ( const char *  )

◆ lrealpath()

char* lrealpath ( const char *  )

◆ make_relative_prefix()

char* make_relative_prefix ( const char *  ,
const char *  ,
const char *   
)

◆ make_relative_prefix_ignore_links()

char* make_relative_prefix_ignore_links ( const char *  ,
const char *  ,
const char *   
)

◆ make_temp_file()

char* make_temp_file ( const char *  )

◆ PARAMS() [1/2]

int writeargv PARAMS ( (char **, FILE *)  )

◆ PARAMS() [2/2]

void expandargv PARAMS ( (int *, char ***)  )

◆ pex_free()

void pex_free ( struct pex_obj *  )

◆ pex_get_status()

int pex_get_status ( struct pex_obj *  ,
int  count,
int vector 
)

◆ pex_get_times()

int pex_get_times ( struct pex_obj *  ,
int  count,
struct pex_time vector 
)

◆ pex_init()

struct pex_obj* pex_init ( int  flags,
const char *  pname,
const char *  tempbase 
)

◆ pex_input_file()

FILE* pex_input_file ( struct pex_obj *  obj,
int  flags,
const char *  in_name 
)

◆ pex_input_pipe()

FILE* pex_input_pipe ( struct pex_obj *  obj,
int  binary 
)

◆ pex_one()

const char* pex_one ( int  flags,
const char *  executable,
char *const argv,
const char *  pname,
const char *  outname,
const char *  errname,
int status,
int err 
)

◆ pex_read_err()

FILE* pex_read_err ( struct pex_obj *  ,
int  binary 
)

◆ pex_read_output()

FILE* pex_read_output ( struct pex_obj *  ,
int  binary 
)

◆ pex_run()

const char* pex_run ( struct pex_obj *  obj,
int  flags,
const char *  executable,
char *const argv,
const char *  outname,
const char *  errname,
int err 
)

◆ pex_run_in_environment()

const char* pex_run_in_environment ( struct pex_obj *  obj,
int  flags,
const char *  executable,
char *const argv,
char *const env,
const char *  outname,
const char *  errname,
int err 
)

◆ pexecute()

int pexecute ( const char *  ,
char *const ,
const char *  ,
const char *  ,
char **  ,
char **  ,
int   
)

◆ physmem_available()

double physmem_available ( void  )

◆ physmem_total()

double physmem_total ( void  )

◆ pwait()

int pwait ( int  ,
int ,
int   
)

◆ reconcat()

char* reconcat ( char *  ,
const char *  ,
  ... 
)

◆ setproctitle()

int void setproctitle ( const char *  name,
  ... 
)

Referenced by uv_set_process_title().

◆ signo_max()

int signo_max ( void  )

◆ spaces()

const char* spaces ( int  count)

◆ strerrno()

const char* strerrno ( int  )

◆ strsigno()

const char* strsigno ( int  )

◆ strtoerrno()

int strtoerrno ( const char *  )

◆ strtosigno()

int strtosigno ( const char *  )

◆ unix_lbasename()

const char* unix_lbasename ( const char *  )

◆ unlink_if_ordinary()

int unlink_if_ordinary ( const char *  )

◆ unlock_std_streams()

void unlock_std_streams ( void  )

◆ unlock_stream()

void unlock_stream ( FILE *  )

◆ vasprintf()

int vasprintf ( char **  ptr,
const char *  format_string,
va_list  vargs 
)

◆ xatexit()

int xatexit ( void(*)(void)  fn)

◆ xcalloc()

void* xcalloc ( size_t  ,
size_t   
)

◆ xcrc32()

unsigned int xcrc32 ( const unsigned char *  ,
int  ,
unsigned int   
)

◆ xexit()

void xexit ( int  status)

◆ xmalloc()

void* xmalloc ( size_t  )

◆ xmalloc_failed()

void xmalloc_failed ( size_t  )

◆ xmalloc_set_program_name()

void xmalloc_set_program_name ( const char *  )

◆ xmemdup()

void* xmemdup ( const void *  ,
size_t  ,
size_t   
)

◆ xrealloc()

void* xrealloc ( void *  ptr,
size_t  size 
)

Definition at line 25 of file util.c.

26 {
27  assert(size > 0);
28 
29  // Save ptr so that we can free it if realloc fails.
30  // The point is that message_fatal ends up calling stdio functions
31  // which in some libc implementations might allocate memory from
32  // the heap. Freeing ptr improves the chances that there's free
33  // memory for stdio functions if they need it.
34  void *p = ptr;
35  ptr = realloc(ptr, size);
36 
37  if (ptr == NULL) {
38  const int saved_errno = errno;
39  free(p);
40  message_fatal("%s", strerror(saved_errno));
41  }
42 
43  return ptr;
44 }
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
void * p
Definition: libc.cpp:67
void * realloc(void *ptr, size_t size)
Definition: malloc.c:144
assert(limit<=UINT32_MAX/2)
void message_fatal(const char *fmt,...)
Definition: message.c:777

◆ xstrdup()

char* xstrdup ( const char *  src)

Definition at line 48 of file util.c.

49 {
50  assert(src != NULL);
51  const size_t size = strlen(src) + 1;
52  char *dest = xmalloc(size);
53  return memcpy(dest, src, size);
54 }
lzma_index * src
Definition: index.h:567
#define xmalloc
Definition: disas-asm.h:43
char * dest
Definition: lz4.h:697

◆ xstrerror()

char* xstrerror ( int  )

◆ xstrndup()

char* xstrndup ( const char *  ,
size_t   
)

Variable Documentation

◆ _hex_value

const unsigned char _hex_value[_hex_array_size]
extern

◆ libiberty_concat_ptr

char* libiberty_concat_ptr
extern

◆ libiberty_len

unsigned long libiberty_len
extern

◆ libiberty_nptr

char* libiberty_nptr
extern

◆ libiberty_optr

const char* libiberty_optr
extern