-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
tools.h
25 lines (18 loc) · 868 Bytes
/
tools.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef TOOLS_H_
#define TOOLS_H_
#include <stdlib.h>
#include <stdint.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
uint8_t *load_file(const char *filename, size_t *size_out);
uint8_t *load_gzfile(const char *filename, size_t *size_out);
int gcd(int a, int b); /* Greatest Common Divisor */
int find_pdx_file(const char *mdx_file_path, const char *pdx_filename, char *out, int out_len);
void csv_quote(char *str, size_t len);
// Execute fn for every file or for each file in every folder
// if recurse = 1, recurse subdirectories
// names and num_names can come from argv and argc
void each_file(const char **names, int num_names, void (*fn)(char *), int recurse);
void hex_dump(const uint8_t *data, size_t len);
int replace_ext(char *out, const size_t out_size, const char *in, const char *ext);
#endif /* TOOLS_H_ */