17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*46f52c84SRobert Mustacchi * 26*46f52c84SRobert Mustacchi * Copyright 2022 Oxide Computer Company 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _MDB_STRING_H 307c478bd9Sstevel@tonic-gate #define _MDB_STRING_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <strings.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #ifdef __cplusplus 367c478bd9Sstevel@tonic-gate extern "C" { 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #define NTOS_UPCASE 0x1 /* Use upper-case hexadecimal digits */ 407c478bd9Sstevel@tonic-gate #define NTOS_UNSIGNED 0x2 /* Value is meant to be unsigned */ 417c478bd9Sstevel@tonic-gate #define NTOS_SIGNPOS 0x4 /* Prefix positive values with sign '+' */ 427c478bd9Sstevel@tonic-gate #define NTOS_SHOWBASE 0x8 /* Show base under appropriate circumstances */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate extern const char *numtostr(uintmax_t, int, uint_t); 454585130bSYuri Pankov extern uintmax_t mdb_strtonum(const char *, int); 467c478bd9Sstevel@tonic-gate extern ulong_t strntoul(const char *, size_t, int); 477c478bd9Sstevel@tonic-gate extern int strisnum(const char *); 487c478bd9Sstevel@tonic-gate extern int strisbasenum(const char *); 497c478bd9Sstevel@tonic-gate extern int strtoi(const char *); 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate extern char *strdup(const char *); 527c478bd9Sstevel@tonic-gate extern char *strndup(const char *, size_t); 537c478bd9Sstevel@tonic-gate extern void strfree(char *); 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate extern size_t stresc2chr(char *); 567c478bd9Sstevel@tonic-gate extern char *strchr2esc(const char *, size_t); 577c478bd9Sstevel@tonic-gate extern char *strchr2adb(const char *, size_t); 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate extern char *strnchr(const char *, int, size_t); 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate extern char *strsplit(char *, char); 627c478bd9Sstevel@tonic-gate extern char *strrsplit(char *, char); 637c478bd9Sstevel@tonic-gate extern const char *strnpbrk(const char *, const char *, size_t); 647c478bd9Sstevel@tonic-gate extern char *strabbr(char *, size_t); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate extern const char *strbasename(const char *); 677c478bd9Sstevel@tonic-gate extern char *strdirname(char *); 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate extern const char *strbadid(const char *); 707c478bd9Sstevel@tonic-gate extern int strisprint(const char *); 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate extern char *mdb_inet_ntop(int, const void *, char *, size_t); 737c478bd9Sstevel@tonic-gate 74*46f52c84SRobert Mustacchi /* 75*46f52c84SRobert Mustacchi * This is a private version of mdb's strtoull that allows us to modify the 76*46f52c84SRobert Mustacchi * behavior. We expect this will get more nuanced when C23 lands and therefore 77*46f52c84SRobert Mustacchi * it is not currently part of the module API. 78*46f52c84SRobert Mustacchi */ 79*46f52c84SRobert Mustacchi typedef enum { 80*46f52c84SRobert Mustacchi MDB_STRTOULL_F_BASE_C = 1 << 0 /* Default to ISO C's radix */ 81*46f52c84SRobert Mustacchi } mdb_strtoull_flags_t; 82*46f52c84SRobert Mustacchi extern u_longlong_t mdb_strtoullx(const char *, mdb_strtoull_flags_t); 83*46f52c84SRobert Mustacchi 84*46f52c84SRobert Mustacchi 857c478bd9Sstevel@tonic-gate #ifdef __cplusplus 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate #endif 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #endif /* _MDB_STRING_H */ 90