util.h (728B)
1#pragma once 2 3#include <stdio.h> 4#include <stdlib.h> 5 6#define MIN(a, b) ((a) < (b) ? (a) : (b)) 7#define MAX(a, b) ((a) < (b) ? (b) : (a)) 8#define CEILDIV(a, b) (((a) / (b)) + !!((a) % (b))) 9 10size_t u8strlen(const char *str); 11size_t u8strnlen(const char *str, size_t max); 12size_t u8rawlen(const char *str, size_t max); 13 14size_t print_pad(FILE *file, size_t len); 15size_t print_hex(FILE *file, const void *in, size_t len); 16 17size_t print_trunc(FILE *file, const char *str, size_t width); 18size_t print_left(FILE *file, const char *str, 19 size_t width, size_t padwidth); 20size_t print_center(FILE *file, const char *str, 21 size_t width, size_t padwidth); 22size_t print_right(FILE *file, const char *str, 23 size_t width, size_t padwidth); 24 25