[1] | 1 | /* $Id: string.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
[8245] | 3 | * IPRT - Internal RTStr header.
|
---|
[1] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[1] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
[5999] | 11 | *
|
---|
[96407] | 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
[5999] | 25 | * The contents of this file may alternatively be used under the terms
|
---|
| 26 | * of the Common Development and Distribution License Version 1.0
|
---|
[96407] | 27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
| 28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
[5999] | 29 | * CDDL are applicable instead of those of the GPL.
|
---|
| 30 | *
|
---|
| 31 | * You may elect to license modified versions of this file under the
|
---|
| 32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
[96407] | 33 | *
|
---|
| 34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
[1] | 35 | */
|
---|
| 36 |
|
---|
[76559] | 37 | #ifndef IPRT_INCLUDED_INTERNAL_string_h
|
---|
| 38 | #define IPRT_INCLUDED_INTERNAL_string_h
|
---|
[76513] | 39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 40 | # pragma once
|
---|
| 41 | #endif
|
---|
[1] | 42 |
|
---|
| 43 | #include <iprt/string.h>
|
---|
| 44 |
|
---|
[20374] | 45 | RT_C_DECLS_BEGIN
|
---|
[1] | 46 |
|
---|
| 47 | /** @def RTSTR_STRICT
|
---|
| 48 | * Enables strict assertions on bad string encodings.
|
---|
| 49 | */
|
---|
[25642] | 50 | #ifdef DOXYGEN_RUNNING
|
---|
[1] | 51 | # define RTSTR_STRICT
|
---|
| 52 | #endif
|
---|
| 53 | /*#define RTSTR_STRICT*/
|
---|
| 54 |
|
---|
| 55 | #ifdef RTSTR_STRICT
|
---|
| 56 | # define RTStrAssertMsgFailed(msg) AssertMsgFailed(msg)
|
---|
| 57 | # define RTStrAssertMsgReturn(expr, msg, rc) AssertMsgReturn(expr, msg, rc)
|
---|
| 58 | #else
|
---|
| 59 | # define RTStrAssertMsgFailed(msg) do { } while (0)
|
---|
| 60 | # define RTStrAssertMsgReturn(expr, msg, rc) do { if (!(expr)) return rc; } while (0)
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
[90821] | 63 | DECLHIDDEN(size_t) rtStrFormatBadPointer(size_t cch, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, int cchWidth,
|
---|
| 64 | unsigned fFlags, void const *pvStr, char szTmp[64], const char *pszTag, int cchTag);
|
---|
[36555] | 65 | DECLHIDDEN(size_t) rtstrFormatRt(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **ppszFormat, va_list *pArgs,
|
---|
| 66 | int cchWidth, int cchPrecision, unsigned fFlags, char chArgSize);
|
---|
| 67 | DECLHIDDEN(size_t) rtstrFormatType(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **ppszFormat, va_list *pArgs,
|
---|
| 68 | int cchWidth, int cchPrecision, unsigned fFlags, char chArgSize);
|
---|
[1] | 69 |
|
---|
[66415] | 70 | /**
|
---|
| 71 | * Format kernel address into @a pszBuf.
|
---|
| 72 | *
|
---|
| 73 | * @returns Number of bytes returned.
|
---|
| 74 | * @param pszBuf The return buffer.
|
---|
| 75 | * @param cbBuf The buffer size.
|
---|
| 76 | * @param uPtr The ring-0 pointer value.
|
---|
| 77 | * @param cchWidth The specified width, -1 if not given.
|
---|
| 78 | * @param cchPrecision The specified precision.
|
---|
| 79 | * @param fFlags Format flags, RTSTR_F_XXX.
|
---|
| 80 | */
|
---|
| 81 | DECLHIDDEN(size_t) rtStrFormatKernelAddress(char *pszBuf, size_t cbBuf, RTR0INTPTR uPtr, signed int cchWidth,
|
---|
| 82 | signed int cchPrecision, unsigned int fFlags);
|
---|
| 83 |
|
---|
[28903] | 84 | #ifdef RT_WITH_ICONV_CACHE
|
---|
[36555] | 85 | DECLHIDDEN(void) rtStrIconvCacheInit(struct RTTHREADINT *pThread);
|
---|
| 86 | DECLHIDDEN(void) rtStrIconvCacheDestroy(struct RTTHREADINT *pThread);
|
---|
[28903] | 87 | #endif
|
---|
| 88 |
|
---|
| 89 | /**
|
---|
| 90 | * Indexes into RTTHREADINT::ahIconvs
|
---|
| 91 | */
|
---|
| 92 | typedef enum RTSTRICONV
|
---|
| 93 | {
|
---|
| 94 | /** UTF-8 to the locale codeset (LC_CTYPE). */
|
---|
| 95 | RTSTRICONV_UTF8_TO_LOCALE = 0,
|
---|
| 96 | /** The locale codeset (LC_CTYPE) to UTF-8. */
|
---|
| 97 | RTSTRICONV_LOCALE_TO_UTF8,
|
---|
| 98 | /** UTF-8 to the filesystem codeset - if different from the locale codeset. */
|
---|
| 99 | RTSTRICONV_UTF8_TO_FS,
|
---|
| 100 | /** The filesystem codeset to UTF-8. */
|
---|
| 101 | RTSTRICONV_FS_TO_UTF8,
|
---|
| 102 | /** The end of the valid indexes. */
|
---|
| 103 | RTSTRICONV_END
|
---|
| 104 | } RTSTRICONV;
|
---|
| 105 |
|
---|
[36555] | 106 | DECLHIDDEN(int) rtStrConvert(const char *pchInput, size_t cchInput, const char *pszInputCS,
|
---|
| 107 | char **ppszOutput, size_t cbOutput, const char *pszOutputCS,
|
---|
| 108 | unsigned cFactor, RTSTRICONV enmCacheIdx);
|
---|
[92671] | 109 | DECLHIDDEN(void) rtStrLocalCacheInit(void **ppvTmpCache);
|
---|
| 110 | DECLHIDDEN(int) rtStrLocalCacheConvert(const char *pchInput, size_t cchInput, const char *pszInputCS,
|
---|
| 111 | char **ppszOutput, size_t cbOutput, const char *pszOutputCS,
|
---|
| 112 | void **ppvTmpCache);
|
---|
| 113 | DECLHIDDEN(void) rtStrLocalCacheDelete(void **ppvTmpCache);
|
---|
[36555] | 114 | DECLHIDDEN(const char *) rtStrGetLocaleCodeset(void);
|
---|
[92671] | 115 | DECLHIDDEN(bool) rtStrIsLocaleCodesetUtf8(void);
|
---|
| 116 | DECLHIDDEN(bool) rtStrIsCodesetUtf8(const char *pszCodeset);
|
---|
[36555] | 117 | DECLHIDDEN(int) rtUtf8Length(const char *psz, size_t cch, size_t *pcuc, size_t *pcchActual);
|
---|
[28903] | 118 |
|
---|
[43171] | 119 | DECLHIDDEN(int) rtStrToIpAddr6Str(const char *psz, char *pszAddrOut, size_t addrOutSize, char *pszPortOut, size_t portOutSize, bool followRfc);
|
---|
| 120 |
|
---|
[20374] | 121 | RT_C_DECLS_END
|
---|
[1] | 122 |
|
---|
[76585] | 123 | #endif /* !IPRT_INCLUDED_INTERNAL_string_h */
|
---|
[1] | 124 |
|
---|