libidn: stringprep.c File Reference

libidn 1.29

- Main Page
- Data Structures
- Files

- File List
- Globals

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

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

Definition at line 109 of file stringprep.c.

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

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

Definition at line 110 of file stringprep.c.

## Function Documentation

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, indicate how large the buffer holding the string is. This function will not read or write to characters outside that size.

The are one of Stringprep_profile_flags values, or 0.

The 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 367 of file stringprep.c.

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 ([] = 0). The output will not be zero terminated unless [] = 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, indicate how large the buffer holding the string is. This function will not read or write to code points outside that size.

The are one of Stringprep_profile_flags values, or 0.

The 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 146 of file stringprep.c.

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, indicate how large the buffer holding the string is. This function will not read or write to code points outside that size.

The are one of Stringprep_profile_flags values, or 0.

The 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 327 of file stringprep.c.

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 variable must be deallocated by the caller.

The are one of Stringprep_profile_flags values, or 0.

The 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 445 of file stringprep.c.