util.h (1608B)
1 /* See LICENSE file for copyright and license details. */ 2 #include "arg.h" 3 4 #define UTF8_POINT(c) (((c) & 0xc0) != 0x80) 5 6 #undef MIN 7 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 8 #undef MAX 9 #define MAX(x,y) ((x) > (y) ? (x) : (y)) 10 #undef LIMIT 11 #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) 12 13 #define LEN(x) (sizeof (x) / sizeof *(x)) 14 15 /* eprintf.c */ 16 extern char *argv0; 17 18 /* agetcwd.c */ 19 char *agetcwd(void); 20 21 /* apathmax.c */ 22 void apathmax(char **, long *); 23 24 /* ealloc.c */ 25 void *ecalloc(size_t, size_t); 26 void *emalloc(size_t size); 27 void *erealloc(void *, size_t); 28 char *estrdup(const char *); 29 30 /* eprintf.c */ 31 void enprintf(int, const char *, ...); 32 void eprintf(const char *, ...); 33 void weprintf(const char *, ...); 34 35 /* estrtol.c */ 36 long estrtol(const char *, int); 37 38 /* estrtoul.c */ 39 unsigned long estrtoul(const char *, int); 40 41 /* explicit_bzero.c */ 42 #undef explicit_bzero 43 void explicit_bzero(void *, size_t); 44 45 /* putword.c */ 46 void putword(const char *); 47 48 /* recurse.c */ 49 void recurse(const char *, void (*)(const char *)); 50 51 /* strlcat.c */ 52 #undef strlcat 53 size_t strlcat(char *, const char *, size_t); 54 size_t estrlcat(char *, const char *, size_t); 55 56 /* strlcpy.c */ 57 #undef strlcpy 58 size_t strlcpy(char *, const char *, size_t); 59 size_t estrlcpy(char *, const char *, size_t); 60 61 /* strtonum.c */ 62 #undef strtonum 63 long long strtonum(const char *, long long, long long, const char **); 64 long long enstrtonum(int, const char *, long long, long long); 65 long long estrtonum(const char *, long long, long long); 66 67 /* tty.c */ 68 void devtotty(int, int *, int *); 69 int ttytostr(int, int, char *, size_t);