unbound: sldns/parse.h File Reference

unbound 0.1

Macros | Typedefs | Enumerations | Functions
parse.h File Reference

Contains some low-level parsing functions, mostly used in the _frm_str family of functions. More...

## Macros
#define | LDNS_PARSE_SKIP_SPACE "\f\n\r\v"
#define | LDNS_PARSE_NORMAL " \f\n\r\t\v"
#define | LDNS_PARSE_NO_NL " \t"
#define | LDNS_MAX_LINELEN 10230
#define | LDNS_MAX_KEYWORDLEN 32

## Typedefs
typedef enum sldns_enum_directive | sldns_directive

## Enumerations
enum | sldns_enum_directive { LDNS_DIR_TTL , LDNS_DIR_ORIGIN , LDNS_DIR_INCLUDE }
| different type of directives in zone files We now deal with $TTL, $ORIGIN and $INCLUDE. More...

## Functions
ssize_t | sldns_fget_token (FILE *f, char *token, const char *delim, size_t limit)
| returns a token/char from the stream F.
ssize_t | sldns_fget_token_l (FILE *f, char *token, const char *delim, size_t limit, int *line_nr)
| returns a token/char from the stream F.
ssize_t | sldns_bget_token_par (struct sldns_buffer *b, char *token, const char *delim, size_t limit, int *par, const char *skipw)
| returns a token/char from the buffer b.
ssize_t | sldns_bget_token (struct sldns_buffer *b, char *token, const char *delim, size_t limit)
| returns a token/char from the buffer b.
ssize_t | sldns_fget_keyword_data (FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit)
ssize_t | sldns_fget_keyword_data_l (FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit, int *line_nr)
ssize_t | sldns_bget_keyword_data (struct sldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit)
int | sldns_bgetc (struct sldns_buffer *buffer)
| returns the next character from a buffer.
void | sldns_bskipcs (struct sldns_buffer *buffer, const char *s)
| skips all of the characters in the given string in the buffer, moving the position to the first character that is not in *s.
void | sldns_fskipcs (FILE *fp, const char *s)
| skips all of the characters in the given string in the fp, moving the position to the first character that is not in *s.
void | sldns_fskipcs_l (FILE *fp, const char *s, int *line_nr)
| skips all of the characters in the given string in the fp, moving the position to the first character that is not in *s.

## Detailed Description

Contains some low-level parsing functions, mostly used in the _frm_str family of functions.

## Enumeration Type Documentation

## ◆ sldns_enum_directive

enum sldns_enum_directive

different type of directives in zone files We now deal with $TTL, $ORIGIN and $INCLUDE.

The latter is not implemented in ldns (yet)

## Function Documentation

## ◆ sldns_fget_token()

ssize_t sldns_fget_token | ( | FILE * | f,
|  | char * | token,
|  | const char * | delim,
|  | size_t | limit )

returns a token/char from the stream F.

This function deals with ( and ) in the stream, and ignores them when encountered

Parameters

  [in] | *f | the file to read from
  [out] | *token | the read token is put here
  [in] | *delim | chars at which the parsing should stop
  [in] | *limit | how much to read. If 0 the builtin maximum is used

Returns
  0 on error of EOF of the stream F. Otherwise return the length of what is read

## ◆ sldns_fget_token_l()

ssize_t sldns_fget_token_l | ( | FILE * | f,
|  | char * | token,
|  | const char * | delim,
|  | size_t | limit,
|  | int * | line_nr )

returns a token/char from the stream F.

This function deals with ( and ) in the stream, and ignores when it finds them.

Parameters

  [in] | *f | the file to read from
  [out] | *token | the token is put here
  [in] | *delim | chars at which the parsing should stop
  [in] | *limit | how much to read. If 0 use builtin maximum
  [in] | line_nr | pointer to an integer containing the current line number (for debugging purposes)

Returns
  0 on error of EOF of F otherwise return the length of what is read

## ◆ sldns_bget_token_par()

ssize_t sldns_bget_token_par | ( | struct sldns_buffer * | b,
|  | char * | token,
|  | const char * | delim,
|  | size_t | limit,
|  | int * | par,
|  | const char * | skipw )

returns a token/char from the buffer b.

This function deals with ( and ) in the buffer, and ignores when it finds them.

Parameters

  [in] | *b | the buffer to read from
  [out] | *token | the token is put here
  [in] | *delim | chars at which the parsing should stop
  [in] | *limit | how much to read. If 0 the builtin maximum is used
  [in] | *par | if you pass nonNULL, set to 0 on first call, the parenthesis state is stored in it, for use on next call. User must check it is back to zero after last bget in string (for parse error). If you pass NULL, the entire parenthesized string is read in.
  [in] | skipw | string with whitespace to skip before the start of the token, like " ", or " \t", or NULL for none.

Returns
  0 on error of EOF of b. Otherwise return the length of what is read

## ◆ sldns_bget_token()

ssize_t sldns_bget_token | ( | struct sldns_buffer * | b,
|  | char * | token,
|  | const char * | delim,
|  | size_t | limit )

returns a token/char from the buffer b.

This function deals with ( and ) in the buffer, and ignores when it finds them.

Parameters

  [in] | *b | the buffer to read from
  [out] | *token | the token is put here
  [in] | *delim | chars at which the parsing should stop
  [in] | *limit | how much to read. If 0 the builtin maximum is used

Returns
  0 on error of EOF of b. Otherwise return the length of what is read

## ◆ sldns_bgetc()

int sldns_bgetc | ( | struct sldns_buffer * | buffer | ) |

returns the next character from a buffer.

Advances the position pointer with 1. When end of buffer is reached returns EOF. This is the buffer's equivalent for getc().

Parameters

  [in] | *buffer | buffer to read from

Returns
  EOF on failure otherwise return the character

References sldns_buffer::_position, sldns_buffer_available_at(), sldns_buffer_limit(), sldns_buffer_read_u8(), and sldns_buffer_set_position().

## ◆ sldns_bskipcs()

void sldns_bskipcs | ( | struct sldns_buffer * | buffer,
|  | const char * | s )

skips all of the characters in the given string in the buffer, moving the position to the first character that is not in *s.

Parameters

  [in] | *buffer | buffer to use
  [in] | *s | characters to skip

References sldns_buffer::_limit, sldns_buffer::_position, sldns_buffer_available_at(), and sldns_buffer_read_u8_at().

## ◆ sldns_fskipcs()

void sldns_fskipcs | ( | FILE * | fp,
|  | const char * | s )

skips all of the characters in the given string in the fp, moving the position to the first character that is not in *s.

Parameters

  [in] | *fp | file to use
  [in] | *s | characters to skip

## ◆ sldns_fskipcs_l()

void sldns_fskipcs_l | ( | FILE * | fp,
|  | const char * | s,
|  | int * | line_nr )

skips all of the characters in the given string in the fp, moving the position to the first character that is not in *s.

Parameters

  [in] | *fp | file to use
  [in] | *s | characters to skip
  [in] | line_nr | pointer to an integer containing the current line number (for debugging purposes)