VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/string.h@ 97698

Last change on this file since 97698 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.0 KB
Line 
1/* $Id: string.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * IPRT - Internal RTStr header.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
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 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
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
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.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_INTERNAL_string_h
38#define IPRT_INCLUDED_INTERNAL_string_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/string.h>
44
45RT_C_DECLS_BEGIN
46
47/** @def RTSTR_STRICT
48 * Enables strict assertions on bad string encodings.
49 */
50#ifdef DOXYGEN_RUNNING
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
63DECLHIDDEN(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);
65DECLHIDDEN(size_t) rtstrFormatRt(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **ppszFormat, va_list *pArgs,
66 int cchWidth, int cchPrecision, unsigned fFlags, char chArgSize);
67DECLHIDDEN(size_t) rtstrFormatType(PFNRTSTROUTPUT pfnOutput, void *pvArgOutput, const char **ppszFormat, va_list *pArgs,
68 int cchWidth, int cchPrecision, unsigned fFlags, char chArgSize);
69
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 */
81DECLHIDDEN(size_t) rtStrFormatKernelAddress(char *pszBuf, size_t cbBuf, RTR0INTPTR uPtr, signed int cchWidth,
82 signed int cchPrecision, unsigned int fFlags);
83
84#ifdef RT_WITH_ICONV_CACHE
85DECLHIDDEN(void) rtStrIconvCacheInit(struct RTTHREADINT *pThread);
86DECLHIDDEN(void) rtStrIconvCacheDestroy(struct RTTHREADINT *pThread);
87#endif
88
89/**
90 * Indexes into RTTHREADINT::ahIconvs
91 */
92typedef 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
106DECLHIDDEN(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);
109DECLHIDDEN(void) rtStrLocalCacheInit(void **ppvTmpCache);
110DECLHIDDEN(int) rtStrLocalCacheConvert(const char *pchInput, size_t cchInput, const char *pszInputCS,
111 char **ppszOutput, size_t cbOutput, const char *pszOutputCS,
112 void **ppvTmpCache);
113DECLHIDDEN(void) rtStrLocalCacheDelete(void **ppvTmpCache);
114DECLHIDDEN(const char *) rtStrGetLocaleCodeset(void);
115DECLHIDDEN(bool) rtStrIsLocaleCodesetUtf8(void);
116DECLHIDDEN(bool) rtStrIsCodesetUtf8(const char *pszCodeset);
117DECLHIDDEN(int) rtUtf8Length(const char *psz, size_t cch, size_t *pcuc, size_t *pcchActual);
118
119DECLHIDDEN(int) rtStrToIpAddr6Str(const char *psz, char *pszAddrOut, size_t addrOutSize, char *pszPortOut, size_t portOutSize, bool followRfc);
120
121RT_C_DECLS_END
122
123#endif /* !IPRT_INCLUDED_INTERNAL_string_h */
124
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette