#include <stdio.h>
Go to the source code of this file.
|
| #define | SIZE_T_FORMAT "%zu" |
| |
| #define | KB 1024 |
| |
| #define | MB (1024 * KB) |
| |
| #define | DIM(S_ARR_) (sizeof(S_ARR_) / sizeof(S_ARR_[0])) |
| |
| #define | MIN(A_, B_) ((A_) < (B_) ? (A_) : (B_)) |
| |
| #define | MAX(A_, B_) ((A_) > (B_) ? (A_) : (B_)) |
| |
| #define | ALIGN(VAL_, ALIGNMENT_) (((VAL_) + ((ALIGNMENT_) - 1)) & ~((ALIGNMENT_) - 1)) |
| |
| #define | read_u32_be(buf) (unsigned int)(((buf)[0] << 24) + ((buf)[1] << 16) + ((buf)[2] << 8) + ((buf)[3])) |
| |
| #define | read_u32_le(buf) (unsigned int)(((buf)[1] << 24) + ((buf)[0] << 16) + ((buf)[3] << 8) + ((buf)[2])) |
| |
| #define | write_u32_be(buf, val) |
| |
| #define | read_u16_be(buf) (((buf)[0] << 8) + ((buf)[1])) |
| |
| #define | write_u16_be(buf, val) |
| |
| #define | fprint_nibble(FP, NIB_) fputc((NIB_) < 10 ? ('0' + (NIB_)) : ('A' + (NIB_) - 0xA), FP) |
| |
| #define | fprint_byte(FP, BYTE_) |
| |
| #define | print_nibble(NIB_) fprint_nibble(stdout, NIB_) |
| |
| #define | print_byte(BYTE_) fprint_byte(stdout, BYTE_) |
| |
| #define | MAX_DIR_FILES 128 |
| |
| #define | ERROR(...) fprintf(stderr, __VA_ARGS__) |
| |
| #define | INFO(...) if (g_verbosity) printf(__VA_ARGS__) |
| |
| #define | INFO_HEX(...) if (g_verbosity) print_hex(__VA_ARGS__) |
| |
|
| int | read_s16_be (unsigned char *buf) |
| |
| float | read_f32_be (unsigned char *buf) |
| |
| int | is_power2 (unsigned int val) |
| |
| void | fprint_hex (FILE *fp, const unsigned char *buf, int length) |
| |
| void | fprint_hex_source (FILE *fp, const unsigned char *buf, int length) |
| |
| void | print_hex (const unsigned char *buf, int length) |
| |
| void | swap_bytes (unsigned char *data, long length) |
| |
| void | reverse_endian (unsigned char *data, long length) |
| |
| long | filesize (const char *file_name) |
| |
| void | touch_file (const char *filename) |
| |
| long | read_file (const char *file_name, unsigned char **data) |
| |
| long | write_file (const char *file_name, unsigned char *data, long length) |
| |
| void | generate_filename (const char *in_name, char *out_name, char *extension) |
| |
| char * | basename (const char *name) |
| |
| void | make_dir (const char *dir_name) |
| |
| long | copy_file (const char *src_name, const char *dst_name) |
| |
| void | dir_list_ext (const char *dir, const char *extension, dir_list *list) |
| |
| void | dir_list_free (dir_list *list) |
| |
| int | str_ends_with (const char *str, const char *suffix) |
| |
◆ ALIGN
| #define ALIGN |
( |
|
VAL_, |
|
|
|
ALIGNMENT_ |
|
) |
| (((VAL_) + ((ALIGNMENT_) - 1)) & ~((ALIGNMENT_) - 1)) |
◆ DIM
| #define DIM |
( |
|
S_ARR_ | ) |
(sizeof(S_ARR_) / sizeof(S_ARR_[0])) |
◆ ERROR
| #define ERROR |
( |
|
... | ) |
fprintf(stderr, __VA_ARGS__) |
◆ fprint_byte
| #define fprint_byte |
( |
|
FP, |
|
|
|
BYTE_ |
|
) |
| |
Value:do { \
fprint_nibble(FP, (BYTE_) >> 4); \
fprint_nibble(FP, (BYTE_) & 0x0F); \
} while(0)
◆ fprint_nibble
| #define fprint_nibble |
( |
|
FP, |
|
|
|
NIB_ |
|
) |
| fputc((NIB_) < 10 ? ('0' + (NIB_)) : ('A' + (NIB_) - 0xA), FP) |
◆ INFO
◆ INFO_HEX
◆ KB
◆ MAX
| #define MAX |
( |
|
A_, |
|
|
|
B_ |
|
) |
| ((A_) > (B_) ? (A_) : (B_)) |
◆ MAX_DIR_FILES
| #define MAX_DIR_FILES 128 |
◆ MB
◆ MIN
| #define MIN |
( |
|
A_, |
|
|
|
B_ |
|
) |
| ((A_) < (B_) ? (A_) : (B_)) |
◆ print_byte
◆ print_nibble
◆ read_u16_be
| #define read_u16_be |
( |
|
buf | ) |
(((buf)[0] << 8) + ((buf)[1])) |
◆ read_u32_be
| #define read_u32_be |
( |
|
buf | ) |
(unsigned int)(((buf)[0] << 24) + ((buf)[1] << 16) + ((buf)[2] << 8) + ((buf)[3])) |
◆ read_u32_le
| #define read_u32_le |
( |
|
buf | ) |
(unsigned int)(((buf)[1] << 24) + ((buf)[0] << 16) + ((buf)[3] << 8) + ((buf)[2])) |
◆ SIZE_T_FORMAT
| #define SIZE_T_FORMAT "%zu" |
◆ write_u16_be
| #define write_u16_be |
( |
|
buf, |
|
|
|
val |
|
) |
| |
Value:do { \
(buf)[0] = ((val) >> 8) & 0xFF; \
(buf)[1] = ((val)) & 0xFF; \
} while(0)
◆ write_u32_be
| #define write_u32_be |
( |
|
buf, |
|
|
|
val |
|
) |
| |
Value:do { \
(buf)[0] = ((val) >> 24) & 0xFF; \
(buf)[1] = ((val) >> 16) & 0xFF; \
(buf)[2] = ((val) >> 8) & 0xFF; \
(buf)[3] = (val) & 0xFF; \
} while(0)
◆ basename()
◆ copy_file()
◆ dir_list_ext()
◆ dir_list_free()
◆ filesize()
◆ fprint_hex()
◆ fprint_hex_source()
◆ generate_filename()
◆ is_power2()
| int is_power2 |
( |
unsigned int |
val | ) |
|
◆ make_dir()
◆ print_hex()
◆ read_f32_be()
| float read_f32_be |
( |
unsigned char * |
buf | ) |
|
◆ read_file()
◆ read_s16_be()
| int read_s16_be |
( |
unsigned char * |
buf | ) |
|
◆ reverse_endian()
| void reverse_endian |
( |
unsigned char * |
data, |
|
|
long |
length |
|
) |
| |
◆ str_ends_with()
◆ swap_bytes()
| void swap_bytes |
( |
unsigned char * |
data, |
|
|
long |
length |
|
) |
| |
◆ touch_file()
◆ write_file()
| long write_file |
( |
const char * |
file_name, |
|
|
unsigned char * |
data, |
|
|
long |
length |
|
) |
| |
◆ g_verbosity