uriparser: UriBase.h File Reference

uriparser 0.9.1

Data Structures | Typedefs | Enumerations | Functions
UriBase.h File Reference

## Data Structures
struct | UriIp4Struct
struct | UriIp6Struct
struct | UriMemoryManagerStruct

## Typedefs
typedef int | UriBool
typedef struct UriIp4Struct | UriIp4
| More...
typedef struct UriIp6Struct | UriIp6
| More...
typedef void *(* | UriFuncMalloc) (struct UriMemoryManagerStruct *, size_t)
typedef void *(* | UriFuncCalloc) (struct UriMemoryManagerStruct *, size_t, size_t)
typedef void *(* | UriFuncRealloc) (struct UriMemoryManagerStruct *, void *, size_t)
typedef void *(* | UriFuncReallocarray) (struct UriMemoryManagerStruct *, void *, size_t, size_t)
typedef void(* | UriFuncFree) (struct UriMemoryManagerStruct *, void *)
typedef struct UriMemoryManagerStruct | UriMemoryManager
| More...
typedef enum UriBreakConversionEnum | UriBreakConversion
| More...
typedef enum UriNormalizationMaskEnum | UriNormalizationMask
| More...
typedef enum UriResolutionOptionsEnum | UriResolutionOptions
| More...

## Enumerations
enum | UriBreakConversionEnum { URI_BR_TO_LF, URI_BR_TO_CRLF, URI_BR_TO_CR, URI_BR_TO_UNIX = URI_BR_TO_LF, URI_BR_TO_WINDOWS = URI_BR_TO_CRLF, URI_BR_TO_MAC = URI_BR_TO_CR, URI_BR_DONT_TOUCH }
enum | UriNormalizationMaskEnum { URI_NORMALIZED = 0, URI_NORMALIZE_SCHEME = 1 << 0, URI_NORMALIZE_USER_INFO = 1 << 1, URI_NORMALIZE_HOST = 1 << 2, URI_NORMALIZE_PATH = 1 << 3, URI_NORMALIZE_QUERY = 1 << 4, URI_NORMALIZE_FRAGMENT = 1 << 5 }
enum | UriResolutionOptionsEnum { URI_RESOLVE_STRICTLY = 0, URI_RESOLVE_IDENTICAL_SCHEME_COMPAT = 1 << 0 }

## Functions
int | uriCompleteMemoryManager (UriMemoryManager *memory, UriMemoryManager *backend)
void * | uriEmulateCalloc (UriMemoryManager *memory, size_t nmemb, size_t size)
void * | uriEmulateReallocarray (UriMemoryManager *memory, void *ptr, size_t nmemb, size_t size)
int | uriTestMemoryManager (UriMemoryManager *memory)

## Detailed Description

Holds definitions independent of the encoding pass.

## Typedef Documentation

## ◆ UriBool

typedef int UriBool

Boolean type

## ◆ UriBreakConversion

typedef enum UriBreakConversionEnum UriBreakConversion

Specifies a line break conversion mode.Specifies a line break conversion mode.

## ◆ UriFuncCalloc

typedef void*(* UriFuncCalloc) (struct UriMemoryManagerStruct *, size_t, size_t)

Function signature that custom calloc(3) functions must conform to

Since
  0.9.0

## ◆ UriFuncFree

typedef void(* UriFuncFree) (struct UriMemoryManagerStruct *, void *)

Function signature that custom free(3) functions must conform to

Since
  0.9.0

## ◆ UriFuncMalloc

typedef void*(* UriFuncMalloc) (struct UriMemoryManagerStruct *, size_t)

Function signature that custom malloc(3) functions must conform to

Since
  0.9.0

## ◆ UriFuncRealloc

typedef void*(* UriFuncRealloc) (struct UriMemoryManagerStruct *, void *, size_t)

Function signature that custom realloc(3) functions must conform to

Since
  0.9.0

## ◆ UriFuncReallocarray

typedef void*(* UriFuncReallocarray) (struct UriMemoryManagerStruct *, void *, size_t, size_t)

Function signature that custom reallocarray(3) functions must conform to

Since
  0.9.0

## ◆ UriIp4

typedef struct UriIp4Struct UriIp4

Holds an IPv4 address.Holds an IPv4 address.

## ◆ UriIp6

typedef struct UriIp6Struct UriIp6

Holds an IPv6 address.Holds an IPv6 address.

## ◆ UriMemoryManager

typedef struct UriMemoryManagerStruct UriMemoryManager

Class-like interface of custom memory managers

See also
  uriCompleteMemoryManager
  uriEmulateCalloc
  uriEmulateReallocarray
  uriTestMemoryManager

Since
  0.9.0Class-like interface of custom memory managers

See also
  uriCompleteMemoryManager
  uriEmulateCalloc
  uriEmulateReallocarray
  uriTestMemoryManager

Since
  0.9.0

## ◆ UriNormalizationMask

typedef enum UriNormalizationMaskEnum UriNormalizationMask

Specifies which component of a URI has to be normalized.Specifies which component of a URI has to be normalized.

## ◆ UriResolutionOptions

typedef enum UriResolutionOptionsEnum UriResolutionOptions

Specifies how to resolve URI references.Specifies how to resolve URI references.

## Enumeration Type Documentation

## ◆ UriBreakConversionEnum

enum UriBreakConversionEnum

Specifies a line break conversion mode.

Enumerator
URI_BR_TO_LF | Convert to Unix line breaks ("\\x0a")
URI_BR_TO_CRLF | Convert to Windows line breaks ("\\x0d\\x0a")
URI_BR_TO_CR | Convert to Macintosh line breaks ("\\x0d")
URI_BR_TO_UNIX | Convert to Unix line breaks ("\\x0a")
URI_BR_TO_WINDOWS | Convert to Windows line breaks ("\\x0d\\x0a")
URI_BR_TO_MAC | Convert to Macintosh line breaks ("\\x0d")
URI_BR_DONT_TOUCH | Copy line breaks unmodified

## ◆ UriNormalizationMaskEnum

enum UriNormalizationMaskEnum

Specifies which component of a URI has to be normalized.

Enumerator
URI_NORMALIZED | Do not normalize anything
URI_NORMALIZE_SCHEME | Normalize scheme (fix uppercase letters)
URI_NORMALIZE_USER_INFO | Normalize user info (fix uppercase percent-encodings)
URI_NORMALIZE_HOST | Normalize host (fix uppercase letters)
URI_NORMALIZE_PATH | Normalize path (fix uppercase percent-encodings and redundant dot segments)
URI_NORMALIZE_QUERY | Normalize query (fix uppercase percent-encodings)
URI_NORMALIZE_FRAGMENT | Normalize fragment (fix uppercase percent-encodings)

## ◆ UriResolutionOptionsEnum

enum UriResolutionOptionsEnum

Specifies how to resolve URI references.

Enumerator
URI_RESOLVE_STRICTLY | Full RFC conformance
URI_RESOLVE_IDENTICAL_SCHEME_COMPAT | Treat URI to resolve with identical scheme as having no scheme

## Function Documentation

## ◆ uriCompleteMemoryManager()

int uriCompleteMemoryManager | ( | UriMemoryManager * | memory,
|  | UriMemoryManager * | backend
| ) |  |

Wraps a memory manager backend that only provides malloc and free to make a complete memory manager ready to be used.

The core feature of this wrapper is that you don't need to implement realloc if you don't want to. The wrapped memory manager uses backend->malloc, memcpy, and backend->free and soieof(size_t) extra bytes per allocation to emulate fallback realloc for you.

memory->calloc is uriEmulateCalloc. memory->free uses backend->free and handles the size header. memory->malloc uses backend->malloc and adds a size header. memory->realloc uses memory->malloc, memcpy, and memory->free and reads the size header. memory->reallocarray is uriEmulateReallocarray.

The internal workings behind memory->free, memory->malloc, and memory->realloc may change so the functions exposed by these function pointer sshould be consided internal and not public API.

Parameters

  memory | OUT: Where to write the wrapped memory manager to
  backend | IN: Memory manager to use as a backend

Returns
  Error code or 0 on success

See also
  uriEmulateCalloc
  uriEmulateReallocarray
  UriMemoryManager

Since
  0.9.0

## ◆ uriEmulateCalloc()

void* uriEmulateCalloc | ( | UriMemoryManager * | memory,
|  | size_t | nmemb,
|  | size_t | size
| ) |  |

Offers emulation of calloc(3) based on memory->malloc and memset. See "man 3 calloc" as well.

Parameters

  memory | IN: Memory manager to use, should not be NULL
  nmemb | IN: Number of elements to allocate
  size | IN: Size in bytes per element

Returns
  Pointer to allocated memory or NULL

See also
  uriCompleteMemoryManager
  uriEmulateReallocarray
  UriMemoryManager

Since
  0.9.0

## ◆ uriEmulateReallocarray()

void* uriEmulateReallocarray | ( | UriMemoryManager * | memory,
|  | void * | ptr,
|  | size_t | nmemb,
|  | size_t | size
| ) |  |

Offers emulation of reallocarray(3) based on memory->realloc. See "man 3 reallocarray" as well.

Parameters

  memory | IN: Memory manager to use, should not be NULL
  ptr | IN: Pointer allocated using memory->malloc/... or NULL
  nmemb | IN: Number of elements to allocate
  size | IN: Size in bytes per element

Returns
  Pointer to allocated memory or NULL

See also
  uriCompleteMemoryManager
  uriEmulateCalloc
  UriMemoryManager

Since
  0.9.0

## ◆ uriTestMemoryManager()

int uriTestMemoryManager | ( | UriMemoryManager * | memory | ) |

Run multiple tests against a given memory manager. For example, one test

1. allocates a small amount of memory,
2. writes some magic bytes to it,
3. reallocates it,
4. checks that previous values are still present,
5. and frees that memory.

It is recommended to compile with AddressSanitizer enabled to take full advantage of uriTestMemoryManager.

Parameters

  memory | IN: Memory manager to use, should not be NULL

Returns
  Error code or 0 on success

See also
  uriEmulateCalloc
  uriEmulateReallocarray
  UriMemoryManager

Since
  0.9.0