Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
pct.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Roc authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_address/pct.h
10//! @brief Percent-encoding and -decoding.
11
12#ifndef ROC_ADDRESS_PCT_H_
13#define ROC_ADDRESS_PCT_H_
14
15#include "roc_core/stddefs.h"
16
17namespace roc {
18namespace address {
19
20//! Percent-encoding mode.
21enum PctMode {
22 //! Percent-encode all symbols that are not unreserved.
24
25 //! Percent-encode all symbols that are not allowed in path.
27};
28
29//! Percent-encode an UTF-8 string.
30//
31//! @b Parameters
32//! - @p dst - destination buffer
33//! - @p dst_sz - destination buffer size
34//! - @p src - source string in UTF-8
35//! - @p src_sz - source string size
36//! - @p mode - encoding mode
37//!
38//! @returns
39//! number of characters written to destination buffer, excluding the terminating
40//! zero byte, or -1 if the buffer is too small or the source string is invalid.
41//!
42//! @remarks
43//! The source string should NOT be null-terminated.
44//! The source string size should NOT include the terminating zero byte.
45//! The destination buffer size SHOULD include the terminating zero byte.
46//! If the function succeeded, the resulting string is ALWAYS null-terminated,
47//! but the returned size EXCLUDES the terminating zero byte.
48ssize_t
49pct_encode(char* dst, size_t dst_sz, const char* src, size_t src_sz, PctMode mode);
50
51//! Percent-decode an UTF-8 string.
52//
53//! @b Parameters
54//! - @p dst - destination buffer
55//! - @p dst_sz - destination buffer size
56//! - @p src - source string in UTF-8
57//! - @p src_sz - source string size
58//!
59//! @returns
60//! number of characters written to destination buffer, excluding the terminating
61//! zero byte, or -1 if the buffer is too small or the source string is invalid.
62//!
63//! @remarks
64//! The source string should NOT be null-terminated.
65//! The source string size should NOT include the terminating zero byte.
66//! The destination buffer size SHOULD include the terminating zero byte.
67//! If the function succeeded, the resulting string is ALWAYS null-terminated,
68//! but the returned size EXCLUDES the terminating zero byte.
69ssize_t pct_decode(char* dst, size_t dst_sz, const char* src, size_t src_sz);
70
71} // namespace address
72} // namespace roc
73
74#endif // ROC_ADDRESS_PCT_H_
Root namespace.
ssize_t pct_encode(char *dst, size_t dst_sz, const char *src, size_t src_sz, PctMode mode)
Percent-encode an UTF-8 string.
PctMode
Percent-encoding mode.
Definition: pct.h:21
@ PctNonPath
Percent-encode all symbols that are not allowed in path.
Definition: pct.h:26
@ PctNonUnreserved
Percent-encode all symbols that are not unreserved.
Definition: pct.h:23
ssize_t pct_decode(char *dst, size_t dst_sz, const char *src, size_t src_sz)
Percent-decode an UTF-8 string.
Commonly used types and functions.