Rizin
unix-like reverse engineering framework and cli tools
util.h
Go to the documentation of this file.
1 //
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
12 
18 #define xmalloc(size) xrealloc(NULL, size)
19 
20 
22 extern void *xrealloc(void *ptr, size_t size)
23  lzma_attribute((__malloc__)) lzma_attr_alloc_size(2);
24 
25 
27 extern char *xstrdup(const char *src) lzma_attribute((__malloc__));
28 
29 
41 extern uint64_t str_to_uint64(const char *name, const char *value,
43 
44 
49 
50 
61 extern const char *uint64_to_str(uint64_t value, uint32_t slot);
62 
63 
70 };
71 
72 
95 extern const char *uint64_to_nicestr(uint64_t value,
96  enum nicestr_unit unit_min, enum nicestr_unit unit_max,
97  bool always_also_bytes, uint32_t slot);
98 
99 
104 extern void my_snprintf(char **pos, size_t *left, const char *fmt, ...)
105  lzma_attribute((__format__(__printf__, 3, 4)));
106 
107 
109 extern bool is_empty_filename(const char *filename);
110 
111 
116 extern bool is_tty_stdin(void);
117 
118 
123 extern bool is_tty_stdout(void);
lzma_index * src
Definition: index.h:567
static int value
Definition: cmd_api.c:93
int max
Definition: enough.c:225
voidpf void uLong size
Definition: ioapi.h:138
const char * filename
Definition: ioapi.h:137
#define const
Definition: ansidecl.h:240
#define lzma_attribute(attr)
Definition: lzma.h:259
int n
Definition: mipsasm.c:19
#define min(a, b)
Definition: qsort.h:83
unsigned int uint32_t
Definition: sftypes.h:29
unsigned long uint64_t
Definition: sftypes.h:28
Definition: z80asm.h:102
int pos
Definition: main.c:11
#define lzma_attr_alloc_size(x)
Definition: sysdefs.h:196
void * xrealloc(void *ptr, size_t size) lzma_attribute((__malloc__)) lzma_attr_alloc_size(2)
Safe realloc() that never returns NULL.
Definition: util.c:25
uint64_t str_to_uint64(const char *name, const char *value, uint64_t min, uint64_t max)
Fancy version of strtoull()
Definition: util.c:58
const char * uint64_to_str(uint64_t value, uint32_t slot)
Convert uint64_t to a string.
Definition: util.c:171
void bool is_empty_filename(const char *filename)
Check if filename is empty and print an error message.
Definition: util.c:264
bool is_tty_stdin(void)
Test if stdin is a terminal.
Definition: util.c:276
const char * uint64_to_nicestr(uint64_t value, enum nicestr_unit unit_min, enum nicestr_unit unit_max, bool always_also_bytes, uint32_t slot)
Convert uint64_t to a nice human readable string.
Definition: util.c:187
char * xstrdup(const char *src) lzma_attribute((__malloc__))
Safe strdup() that never returns NULL.
Definition: util.c:48
nicestr_unit
Definition: util.h:64
@ NICESTR_MIB
Definition: util.h:67
@ NICESTR_KIB
Definition: util.h:66
@ NICESTR_B
Definition: util.h:65
@ NICESTR_TIB
Definition: util.h:69
@ NICESTR_GIB
Definition: util.h:68
void my_snprintf(char **pos, size_t *left, const char *fmt,...) lzma_attribute((__format__(__printf__
Wrapper for snprintf() to help constructing a string in pieces.
bool is_tty_stdout(void)
Test if stdout is a terminal.
Definition: util.c:289
uint64_t round_up_to_mib(uint64_t n)
Round an integer up to the next full MiB and convert to MiB.
Definition: util.c:139