libidn: stringprep.c File Reference

libidn 1.41

Macros | Functions
stringprep.c File Reference
`#include <stdlib.h>`
`#include <string.h>`
`#include "stringprep.h"`

Go to the source code of this file.

## Macros
#define | INVERTED(x) ((x) & ((~0UL) >> 1))
#define | UNAPPLICAPLEFLAGS(flags, profileflags)

## Functions
int | stringprep_4i (uint32_t *ucs4, size_t *len, size_t maxucs4len, Stringprep_profile_flags flags, const Stringprep_profile *profile)
int | stringprep_4zi (uint32_t *ucs4, size_t maxucs4len, Stringprep_profile_flags flags, const Stringprep_profile *profile)
int | stringprep (char *in, size_t maxlen, Stringprep_profile_flags flags, const Stringprep_profile *profile)
int | stringprep_profile (const char *in, char **out, const char *profile, Stringprep_profile_flags flags)

## Macro Definition Documentation

## ◆ INVERTED

#define INVERTED | ( |  | x | ) | ((x) & ((~0UL) >> 1))

Definition at line 145 of file stringprep.c.

## ◆ UNAPPLICAPLEFLAGS

#define UNAPPLICAPLEFLAGS | ( |  | flags,
|  |  | profileflags
| ) |  |

Value:
((!INVERTED(profileflags) && !(profileflags & flags) && profileflags) || \
( INVERTED(profileflags) && (profileflags & flags)))
INVERTED
#define INVERTED(x)
Definition: stringprep.c:145

Definition at line 146 of file stringprep.c.

## Function Documentation

## ◆ stringprep()

int stringprep | ( | char * | in,
|  | size_t | maxlen,
|  | Stringprep_profile_flags | flags,
|  | const Stringprep_profile * | profile
| ) |  |

stringprep:

Parameters

  in | input/ouput array with string to prepare.
  maxlen | maximum length of input/output array.
  flags | a Stringprep_profile_flags value, or 0.
  profile | pointer to Stringprep_profile to use.

Prepare the input zero terminated UTF-8 string according to the stringprep profile, and write back the result to the input string.

Note that you must convert strings entered in the systems locale into UTF-8 before using this function, see stringprep_locale_to_utf8().

Since the stringprep operation can expand the string, @maxlen indicate how large the buffer holding the string is. This function will not read or write to characters outside that size.

The @flags are one of Stringprep_profile_flags values, or 0.

The @profile contain the Stringprep_profile instructions to perform. Your application can define new profiles, possibly re-using the generic stringprep tables that always will be part of the library, or use one of the currently supported profiles.

Return value: Returns STRINGPREP_OK iff successful, or an error code.

Definition at line 415 of file stringprep.c.

## ◆ stringprep_4i()

int stringprep_4i | ( | uint32_t * | ucs4,
|  | size_t * | len,
|  | size_t | maxucs4len,
|  | Stringprep_profile_flags | flags,
|  | const Stringprep_profile * | profile
| ) |  |

stringprep_4i:

Parameters

  ucs4 | input/output array with string to prepare.
  len | on input, length of input array with Unicode code points, on exit, length of output array with Unicode code points.
  maxucs4len | maximum length of input/output array.
  flags | a Stringprep_profile_flags value, or 0.
  profile | pointer to Stringprep_profile to use.

Prepare the input UCS-4 string according to the stringprep profile, and write back the result to the input string.

The input is not required to be zero terminated (@ucs4[@len] = 0). The output will not be zero terminated unless @ucs4[@len] = 0. Instead, see stringprep_4zi() if your input is zero terminated or if you want the output to be.

Since the stringprep operation can expand the string, @maxucs4len indicate how large the buffer holding the string is. This function will not read or write to code points outside that size.

The @flags are one of Stringprep_profile_flags values, or 0.

The @profile contain the Stringprep_profile instructions to perform. Your application can define new profiles, possibly re-using the generic stringprep tables that always will be part of the library, or use one of the currently supported profiles.

Return value: Returns STRINGPREP_OK iff successful, or an Stringprep_rc error code.

Definition at line 182 of file stringprep.c.

## ◆ stringprep_4zi()

int stringprep_4zi | ( | uint32_t * | ucs4,
|  | size_t | maxucs4len,
|  | Stringprep_profile_flags | flags,
|  | const Stringprep_profile * | profile
| ) |  |

stringprep_4zi:

Parameters

  ucs4 | input/output array with zero terminated string to prepare.
  maxucs4len | maximum length of input/output array.
  flags | a Stringprep_profile_flags value, or 0.
  profile | pointer to Stringprep_profile to use.

Prepare the input zero terminated UCS-4 string according to the stringprep profile, and write back the result to the input string.

Since the stringprep operation can expand the string, @maxucs4len indicate how large the buffer holding the string is. This function will not read or write to code points outside that size.

The @flags are one of Stringprep_profile_flags values, or 0.

The @profile contain the Stringprep_profile instructions to perform. Your application can define new profiles, possibly re-using the generic stringprep tables that always will be part of the library, or use one of the currently supported profiles.

Return value: Returns STRINGPREP_OK iff successful, or an Stringprep_rc error code.

Definition at line 375 of file stringprep.c.

## ◆ stringprep_profile()

int stringprep_profile | ( | const char * | in,
|  | char ** | out,
|  | const char * | profile,
|  | Stringprep_profile_flags | flags
| ) |  |

stringprep_profile:

Parameters

  in | input array with UTF-8 string to prepare.
  out | output variable with pointer to newly allocate string.
  profile | name of stringprep profile to use.
  flags | a Stringprep_profile_flags value, or 0.

Prepare the input zero terminated UTF-8 string according to the stringprep profile, and return the result in a newly allocated variable.

Note that you must convert strings entered in the systems locale into UTF-8 before using this function, see stringprep_locale_to_utf8().

The output @out variable must be deallocated by the caller.

The @flags are one of Stringprep_profile_flags values, or 0.

The @profile specifies the name of the stringprep profile to use. It must be one of the internally supported stringprep profiles.

Return value: Returns STRINGPREP_OK iff successful, or an error code.

Definition at line 495 of file stringprep.c.