X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Futil.h;h=911b7c5e2cc92e3897320e7d132dfd08abd8fdf8;hb=d574e10a584a4dca049fdfe3f0f7b0ddbba369aa;hp=a3984bb30c2eb2fb4048f119afc62347effdfb66;hpb=6f7956a06fcf92a304fae93e393e8eaee34e92d5;p=wimlib diff --git a/src/util.h b/src/util.h index a3984bb3..911b7c5e 100644 --- a/src/util.h +++ b/src/util.h @@ -30,17 +30,27 @@ # define HOT #endif /* __GNUC__ */ +#ifndef _NTFS_TYPES_H typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; typedef uint64_t u64; +#endif typedef unsigned uint; +#ifndef min #define min(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); \ (__a < __b) ? __a : __b; }) +#endif + +#ifndef max #define max(a, b) ({ typeof(a) __a = (a); typeof(b) __b = (b); \ (__a > __b) ? __a : __b; }) +#endif + +#ifndef swap #define swap(a, b) ({typeof(a) _a = a; (a) = (b); (b) = _a;}) +#endif #define ARRAY_LEN(array) (sizeof(array) / sizeof((array)[0])) @@ -99,7 +109,7 @@ extern void wimlib_warning(const char *format, ...) #ifdef ENABLE_CUSTOM_MEMORY_ALLOCATOR extern void *(*wimlib_malloc_func)(size_t); extern void (*wimlib_free_func)(void *); -extern void *(*wimlib_realloc)(void *, size_t); +extern void *(*wimlib_realloc_func)(void *, size_t); extern void *wimlib_calloc(size_t nmemb, size_t size); extern char *wimlib_strdup(const char *str); # define MALLOC wimlib_malloc_func @@ -124,17 +134,17 @@ extern char *utf16_to_utf8(const char *utf16_str, size_t utf16_len, extern char *utf8_to_utf16(const char *utf8_str, size_t utf8_len, size_t *utf16_len_ret); -extern void randomize_byte_array(void *p, size_t n); +extern void randomize_byte_array(u8 *p, size_t n); extern void randomize_char_array_with_alnum(char p[], size_t n); -extern int sha1sum(const char *filename, void *buf); - extern const char *path_next_part(const char *path, size_t *first_part_len_ret); extern const char *path_basename(const char *path); +extern const char *path_stream_name(const char *path); + extern void to_parent_name(char buf[], size_t len); extern void print_string(const void *string, size_t len);