tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

decode_rust_punycode.h (2049B)


      1 // Copyright 2024 The Abseil Authors
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     https://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 #ifndef ABSL_DEBUGGING_INTERNAL_DECODE_RUST_PUNYCODE_H_
     16 #define ABSL_DEBUGGING_INTERNAL_DECODE_RUST_PUNYCODE_H_
     17 
     18 #include "absl/base/config.h"
     19 #include "absl/base/nullability.h"
     20 
     21 namespace absl {
     22 ABSL_NAMESPACE_BEGIN
     23 namespace debugging_internal {
     24 
     25 struct DecodeRustPunycodeOptions {
     26  const char* punycode_begin;
     27  const char* punycode_end;
     28  char* out_begin;
     29  char* out_end;
     30 };
     31 
     32 // Given Rust Punycode in `punycode_begin .. punycode_end`, writes the
     33 // corresponding UTF-8 plaintext into `out_begin .. out_end`, followed by a NUL
     34 // character, and returns a pointer to that final NUL on success.  On failure
     35 // returns a null pointer, and the contents of `out_begin .. out_end` are
     36 // unspecified.
     37 //
     38 // Failure occurs in precisely these cases:
     39 //   - Any input byte does not match [0-9a-zA-Z_].
     40 //   - The first input byte is an underscore, but no other underscore appears in
     41 //     the input.
     42 //   - The delta sequence does not represent a valid sequence of code-point
     43 //     insertions.
     44 //   - The plaintext would contain more than 256 code points.
     45 //
     46 // DecodeRustPunycode is async-signal-safe with bounded runtime and a small
     47 // stack footprint, making it suitable for use in demangling Rust symbol names
     48 // from a signal handler.
     49 absl::Nullable<char*> DecodeRustPunycode(DecodeRustPunycodeOptions options);
     50 
     51 }  // namespace debugging_internal
     52 ABSL_NAMESPACE_END
     53 }  // namespace absl
     54 
     55 #endif  // ABSL_DEBUGGING_INTERNAL_DECODE_RUST_PUNYCODE_H_