1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright 2022 Oxide Computer Company
27  */
28 
29 #ifndef	_MDB_STRING_H
30 #define	_MDB_STRING_H
31 
32 #include <sys/types.h>
33 #include <strings.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	NTOS_UPCASE	0x1	/* Use upper-case hexadecimal digits */
40 #define	NTOS_UNSIGNED	0x2	/* Value is meant to be unsigned */
41 #define	NTOS_SIGNPOS	0x4	/* Prefix positive values with sign '+' */
42 #define	NTOS_SHOWBASE	0x8	/* Show base under appropriate circumstances */
43 
44 extern const char *numtostr(uintmax_t, int, uint_t);
45 extern uintmax_t mdb_strtonum(const char *, int);
46 extern ulong_t strntoul(const char *, size_t, int);
47 extern int strisnum(const char *);
48 extern int strisbasenum(const char *);
49 extern int strtoi(const char *);
50 
51 extern char *strdup(const char *);
52 extern char *strndup(const char *, size_t);
53 extern void strfree(char *);
54 
55 extern size_t stresc2chr(char *);
56 extern char *strchr2esc(const char *, size_t);
57 extern char *strchr2adb(const char *, size_t);
58 
59 extern char *strnchr(const char *, int, size_t);
60 
61 extern char *strsplit(char *, char);
62 extern char *strrsplit(char *, char);
63 extern const char *strnpbrk(const char *, const char *, size_t);
64 extern char *strabbr(char *, size_t);
65 
66 extern const char *strbasename(const char *);
67 extern char *strdirname(char *);
68 
69 extern const char *strbadid(const char *);
70 extern int strisprint(const char *);
71 
72 extern char *mdb_inet_ntop(int, const void *, char *, size_t);
73 
74 /*
75  * This is a private version of mdb's strtoull that allows us to modify the
76  * behavior. We expect this will get more nuanced when C23 lands and therefore
77  * it is not currently part of the module API.
78  */
79 typedef enum {
80 	MDB_STRTOULL_F_BASE_C	= 1 << 0	/* Default to ISO C's radix */
81 } mdb_strtoull_flags_t;
82 extern u_longlong_t mdb_strtoullx(const char *, mdb_strtoull_flags_t);
83 
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif	/* _MDB_STRING_H */
90