1 /* $OpenBSD: misc.h,v 1.46 2021/09/13 15:07:51 krw Exp $ */ 2 3 /* 4 * Copyright (c) 1997 Tobias Weingartner 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _MISC_H 20 #define _MISC_H 21 22 struct unit_type { 23 char *ut_abbr; 24 int64_t ut_conversion; 25 char *ut_lname; 26 }; 27 28 #ifndef nitems 29 #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) 30 #endif 31 32 #define WHITESPACE " \f\n\r\t\v" 33 #define UNTRIMMED 0 34 #define TRIMMED 1 35 36 double units_size(const char *, const uint64_t, 37 const struct unit_type **); 38 void string_from_line(char *, const size_t, const int); 39 int ask_yn(const char *); 40 int hex_octet(char *); 41 uint64_t getuint64(const char *, uint64_t, const uint64_t, const uint64_t); 42 char *utf16le_to_string(const uint16_t *); 43 uint16_t *string_to_utf16le(const char *); 44 45 #endif /* _MISC_H */ 46