Contains some low-level parsing functions, mostly used in the _frm_str family of functions. More...
Go to the source code of this file.
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 ldns_enum_directive | ldns_directive |
Enumerations | |
enum | ldns_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 | ldns_fget_token (FILE *f, char *token, const char *delim, size_t limit) |
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... | |
ldns_status | ldns_fget_token_l_st (FILE *f, char **token, size_t *limit, bool fixed, const char *delim, int *line_nr) |
returns a token/char from the stream f. More... | |
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... | |
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_keyword_data (ldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit) |
int | ldns_bgetc (ldns_buffer *buffer) |
returns the next character from a buffer. 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... | |
Contains some low-level parsing functions, mostly used in the _frm_str family of functions.
Definition in file parse.h.
typedef enum ldns_enum_directive ldns_directive |
enum ldns_enum_directive |
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
[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 |
Definition at line 25 of file parse.c.
References 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.
[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) |
Definition at line 220 of file parse.c.
References ldns_fget_token_l_st(), and LDNS_MAX_LINELEN.
ldns_status ldns_fget_token_l_st | ( | FILE * | f, |
char ** | token, | ||
size_t * | limit, | ||
bool | 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.
[in] | *f | the file to read from |
[out] | **token | this 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] | *limit | reference to the size of the token buffer. Will be reset to the new limit of the token buffer if the buffer is reallocated. |
[in] | fixed | If 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] | *delim | chars at which the parsing should stop |
[in] | line_nr | pointer to an integer containing the current line number (for debugging purposes) |
Definition at line 31 of file parse.c.
References ldns_fskipcs_l(), LDNS_MAX_LINELEN, LDNS_PARSE_NORMAL, LDNS_STATUS_ERR, LDNS_STATUS_MEM_ERR, LDNS_STATUS_NULL, LDNS_STATUS_OK, LDNS_STATUS_SYNTAX_EMPTY, LDNS_STATUS_SYNTAX_ERR, LDNS_XMALLOC, and LDNS_XREALLOC.
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.
[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 |
Definition at line 274 of file parse.c.
References ldns_bgetc(), ldns_bskipcs(), and LDNS_PARSE_NORMAL.
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 231 of file parse.c.
References 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 | ||
) |
Definition at line 239 of file parse.c.
References ldns_fget_token(), ldns_fget_token_l(), LDNS_FREE, LDNS_MAX_KEYWORDLEN, and LDNS_XMALLOC.
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 458 of file parse.c.
References ldns_bget_token(), LDNS_FREE, LDNS_MAX_KEYWORDLEN, and LDNS_XMALLOC.
int ldns_bgetc | ( | ldns_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().
[in] | *buffer | buffer to read from |
void ldns_bskipcs | ( | ldns_buffer * | buffer, |
const char * | s | ||
) |
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.
[in] | *fp | file to use |
[in] | *s | characters to skip |
Definition at line 427 of file parse.c.
References 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.
[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) |