xref: /openbsd/sbin/fdisk/misc.h (revision 2ad00dad)
1 /*	$OpenBSD: misc.h,v 1.50 2023/03/25 20:34:28 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 struct unit_type {
20 	char		*ut_abbr;
21 	int64_t		 ut_conversion;
22 	char		*ut_lname;
23 };
24 
25 #ifndef nitems
26 #define	nitems(_a)	(sizeof((_a)) / sizeof((_a)[0]))
27 #endif
28 
29 #define	WHITESPACE	" \f\n\r\t\v"
30 #define	UNTRIMMED	0
31 #define	TRIMMED		1
32 #define	LINEBUFSZ	100
33 
34 double		 units_size(const char *, const uint64_t,
35     const struct unit_type **);
36 void		 string_from_line(char *, const size_t, const int);
37 int		 ask_yn(const char *);
38 int		 hex_octet(char *);
39 uint64_t	 getuint64(const char *, uint64_t, const uint64_t,
40     const uint64_t);
41