parse.h
Go to the documentation of this file.
/*
* parse.h
*
* a Net::DNS like library for C
* LibDNS Team @ NLnet Labs
* (c) NLnet Labs, 2005-2006
* See the file LICENSE for the license
*/
#ifndef LDNS_PARSE_H
#define LDNS_PARSE_H
#include <ldns/common.h>
#include <ldns/buffer.h>
#ifdef __cplusplus
extern "C" {
#endif
#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
enum ldns_enum_directive
{
LDNS_DIR_TTL,
LDNS_DIR_ORIGIN,
LDNS_DIR_INCLUDE
};
typedef enum ldns_enum_directive ldns_directive;
ssize_t ldns_fget_token(FILE *f, char *token, const char *delim, size_t limit);
ssize_t ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr);
ssize_t ldns_fget_token_l_resolv_conf(FILE *f, char *token, const char *delim, size_t limit, int *line_nr);
ldns_status ldns_fget_token_l_st(FILE *f, char **token, size_t *limit, bool fixed, const char *delim, int *line_nr);
ssize_t ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit);
/*
* searches for keyword and delim in a file. Gives everything back
* after the keyword + k_del until we hit d_del
* \param[in] f file pointer to read from
* \param[in] keyword keyword to look for
* \param[in] k_del keyword delimiter
* \param[out] data the data found
* \param[in] d_del the data delimiter
* \param[in] data_limit maximum size the data buffer
* \return the number of character read
*/
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);
/*
* searches for keyword and delim. Gives everything back
* after the keyword + k_del until we hit d_del
* \param[in] f file pointer to read from
* \param[in] keyword keyword to look for
* \param[in] k_del keyword delimiter
* \param[out] data the data found
* \param[in] d_del the data delimiter
* \param[in] data_limit maximum size the data buffer
* \param[in] line_nr pointer to an integer containing the current line number (for
debugging purposes)
* \return the number of character read
*/
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);
/*
* searches for keyword and delim in a buffer. Gives everything back
* after the keyword + k_del until we hit d_del
* \param[in] b buffer pointer to read from
* \param[in] keyword keyword to look for
* \param[in] k_del keyword delimiter
* \param[out] data the data found
* \param[in] d_del the data delimiter
* \param[in] data_limit maximum size the data buffer
* \return the number of character read
*/
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);
void ldns_bskipcs(ldns_buffer *buffer, const char *s);
void ldns_fskipcs(FILE *fp, const char *s);
void ldns_fskipcs_l(FILE *fp, const char *s, int *line_nr);
#ifdef __cplusplus
}
#endif
#endif /* LDNS_PARSE_H */
buffer.h
This file contains the definition of ldns_buffer, and functions to manipulate those.
common.h
Common definitions for LDNS.
ldns_status
enum ldns_enum_status ldns_status
Definition error.h:148
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.
Definition parse.c:247
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.
Definition parse.c:234
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.
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 parse.c:258
ldns_directive
enum ldns_enum_directive ldns_directive
Definition parse.h:45
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 parse.c:485
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.
Definition parse.c:25
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...
Definition parse.c:454
ldns_enum_directive
ldns_enum_directive
different type of directives in zone files We now deal with $TTL, $ORIGIN and $INCLUDE.
Definition parse.h:40
LDNS_DIR_TTL
@ LDNS_DIR_TTL
Definition parse.h:41
LDNS_DIR_INCLUDE
@ LDNS_DIR_INCLUDE
Definition parse.h:43
LDNS_DIR_ORIGIN
@ LDNS_DIR_ORIGIN
Definition parse.h:42
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 chara...
Definition parse.c:431
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...
Definition parse.c:460
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 parse.c:266
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.
Definition parse.c:301
ldns_bgetc
int ldns_bgetc(ldns_buffer *buffer)
returns the next character from a buffer.
Definition buffer.c:157
ldns_struct_buffer
implementation of buffers to ease operations
Definition buffer.h:51