Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1// SPDX-License-Identifier: 0BSD
2
4//
7//
8// Author: Lasse Collin
9//
11
17#define xmalloc(size) xrealloc(NULL, size)
18
19
22extern void *xrealloc(void *ptr, size_t size);
23
24
26extern char *xstrdup(const char *src);
27
28
40extern uint64_t str_to_uint64(const char *name, const char *value,
41 uint64_t min, uint64_t max);
42
43
47extern uint64_t round_up_to_mib(uint64_t n);
48
49
60extern const char *uint64_to_str(uint64_t value, uint32_t slot);
61
62
70
71
94extern const char *uint64_to_nicestr(uint64_t value,
95 enum nicestr_unit unit_min, enum nicestr_unit unit_max,
96 bool always_also_bytes, uint32_t slot);
97
98
103lzma_attribute((__format__(__printf__, 3, 4)))
104extern void my_snprintf(char **pos, size_t *left, const char *fmt, ...);
105
106
118extern bool is_tty(int fd);
119
120
125extern bool is_tty_stdin(void);
126
127
132extern bool is_tty_stdout(void);
const char * src
Definition lz4.h:866
#define min(a, b)
Definition compress42.c:304
size_t size
Definition platform.h:559
#define const
Definition zconf.h:230
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
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.
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
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
void bool is_tty_stdin(void)
Test if stdin is a terminal.
Definition util.c:264
bool is_tty_stdout(void)
Test if stdout is a terminal.
Definition util.c:277
char * xstrdup(const char *src) lzma_attribute((__malloc__))
Safe strdup() that never returns NULL.
Definition tar_1_33.c:3038
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
size_t const char bool is_tty(int fd)
Test if file descriptor is a terminal.
Definition util.c:264
size_t * left
Definition util.h:104
#define lzma_attribute(attr)
Definition lzma.h:259
#define lzma_attr_alloc_size(x)
Definition sysdefs.h:196
char name[NAME_LEN_MAX+1]
Name of the filter.
Definition string_conversion.c:450
const char * fmt
Definition message.h:50