parse.c File Reference

Go to the source code of this file.

Enumerations

enum  file_type2parse { zone_file_type , resolv_conf_file_type }
 

Functions

ssize_t ldns_fget_token (FILE *f, char *token, const char *delim, size_t limit)
 returns a token/char from the stream F. More...
 
ldns_status ldns_fget_token_l_st (FILE *f, char **token, size_t *limit, signed char fixed, const char *delim, int *line_nr)
 returns a token/char from the stream f. More...
 
ssize_t ldns_fget_token_l_resolv_conf (FILE *f, char *token, const char *delim, size_t limit, int *line_nr)
 returns a token/char from the stream F. More...
 
ssize_t ldns_fget_token_l (FILE *f, char *token, const char *delim, size_t limit, int *line_nr)
 returns a token/char from the stream F. More...
 
ssize_t ldns_fget_keyword_data (FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit)
 
ssize_t ldns_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 ldns_bget_token (ldns_buffer *b, char *token, const char *delim, size_t limit)
 returns a token/char from the buffer b. More...
 
void ldns_bskipcs (ldns_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. More...
 
void ldns_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. More...
 
void ldns_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. More...
 
ssize_t ldns_bget_keyword_data (ldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit)
 

Variables

ldns_lookup_table ldns_directive_types []
 

Enumeration Type Documentation

◆ file_type2parse

Enumerator
zone_file_type 
resolv_conf_file_type 

Definition at line 30 of file parse.c.

Function Documentation

◆ ldns_fget_token()

ssize_t ldns_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]*fthe file to read from
[out]*tokenthe read token is put here
[in]*delimchars at which the parsing should stop
[in]*limithow 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

Definition at line 25 of file parse.c.

References ldns_fget_token_l().

◆ ldns_fget_token_l_st()

ldns_status ldns_fget_token_l_st ( FILE *  f,
char **  token,
size_t *  limit,
signed char  fixed,
const char *  delim,
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]*fthe file to read from
[out]**tokenthis should be a reference to a string buffer in which the token is put. A new buffer will be allocated when *token is NULL and fixed is false. If the buffer is too small to hold the token, the buffer is reallocated with double the size (of limit). If fixed is true, the string buffer may not be NULL and limit must be set to the buffer size. In that case no reallocations will be done.
[in,out]*limitreference to the size of the token buffer. Will be reset to the new limit of the token buffer if the buffer is reallocated.
[in]fixedIf fixed is false, the token buffer is allowed to grow when needed (by way of reallocation). If true, the token buffer will not be resized.
[in]*delimchars at which the parsing should stop
[in]line_nrpointer to an integer containing the current line number (for debugging purposes)
Returns
LDNS_STATUS_OK on success, LDNS_STATUS_SYNTAX_EMPTY when no token was read and an error otherwise.

Definition at line 226 of file parse.c.

◆ ldns_fget_token_l_resolv_conf()

ssize_t ldns_fget_token_l_resolv_conf ( 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. This function also handles and ignores comments such as they can be used in resolv.conf files. Starting with either ; or #.

Parameters
[in]*fthe file to read from
[out]*tokenthe token is put here
[in]*delimchars at which the parsing should stop
[in]*limithow much to read. If 0 use builtin maximum
[in]line_nrpointer 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

Definition at line 234 of file parse.c.

References LDNS_MAX_LINELEN.

◆ ldns_fget_token_l()

ssize_t ldns_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. This function also handles and ignores zonefile format comments starting with ;

Parameters
[in]*fthe file to read from
[out]*tokenthe token is put here
[in]*delimchars at which the parsing should stop
[in]*limithow much to read. If 0 use builtin maximum
[in]line_nrpointer 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

Definition at line 247 of file parse.c.

References ldns_fget_token_l_st(), and LDNS_MAX_LINELEN.

◆ ldns_fget_keyword_data()

ssize_t ldns_fget_keyword_data ( FILE *  f,
const char *  keyword,
const char *  k_del,
char *  data,
const char *  d_del,
size_t  data_limit 
)

Definition at line 258 of file parse.c.

References ldns_fget_keyword_data_l().

◆ ldns_fget_keyword_data_l()

ssize_t ldns_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 
)

◆ ldns_bget_token()

ssize_t ldns_bget_token ( ldns_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]*bthe buffer to read from
[out]*tokenthe token is put here
[in]*delimchars at which the parsing should stop
[in]*limithow 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

Definition at line 301 of file parse.c.

References ldns_bgetc(), ldns_bskipcs(), and LDNS_PARSE_NORMAL.

◆ ldns_bskipcs()

void ldns_bskipcs ( ldns_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]*bufferbuffer to use
[in]*scharacters to skip
Returns
void

Definition at line 431 of file parse.c.

◆ ldns_fskipcs()

void ldns_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]*fpfile to use
[in]*scharacters to skip
Returns
void

Definition at line 454 of file parse.c.

References ldns_fskipcs_l().

◆ ldns_fskipcs_l()

void ldns_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]*fpfile to use
[in]*scharacters to skip
[in]line_nrpointer to an integer containing the current line number (for debugging purposes)
Returns
void

Definition at line 460 of file parse.c.

◆ ldns_bget_keyword_data()

ssize_t ldns_bget_keyword_data ( ldns_buffer b,
const char *  keyword,
const char *  k_del,
char *  data,
const char *  d_del,
size_t  data_limit 
)

Definition at line 485 of file parse.c.

References ldns_bget_token(), LDNS_FREE, LDNS_MAX_KEYWORDLEN, and LDNS_XMALLOC.

Variable Documentation

◆ ldns_directive_types

ldns_lookup_table ldns_directive_types[]
Initial value:
= {
{ LDNS_DIR_TTL, "$TTL" },
{ LDNS_DIR_ORIGIN, "$ORIGIN" },
{ LDNS_DIR_INCLUDE, "$INCLUDE" },
{ 0, NULL }
}
@ LDNS_DIR_TTL
Definition: parse.h:41
@ LDNS_DIR_INCLUDE
Definition: parse.h:43
@ LDNS_DIR_ORIGIN
Definition: parse.h:42

Definition at line 16 of file parse.c.