ldns  1.7.0
parse.h
Go to the documentation of this file.
1 /*
2  * parse.h
3  *
4  * a Net::DNS like library for C
5  * LibDNS Team @ NLnet Labs
6  * (c) NLnet Labs, 2005-2006
7  * See the file LICENSE for the license
8  */
9 
10 #ifndef LDNS_PARSE_H
11 #define LDNS_PARSE_H
12 
13 #include <ldns/common.h>
14 #include <ldns/buffer.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define LDNS_PARSE_SKIP_SPACE "\f\n\r\v"
21 #define LDNS_PARSE_NORMAL " \f\n\r\t\v"
22 #define LDNS_PARSE_NO_NL " \t"
23 #define LDNS_MAX_LINELEN 10230
24 #define LDNS_MAX_KEYWORDLEN 32
25 
26 
40 {
44 };
46 
57 ssize_t ldns_fget_token(FILE *f, char *token, const char *delim, size_t limit);
58 
70 ssize_t ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr);
71 
82 ssize_t ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit);
83 
84 /*
85  * searches for keyword and delim in a file. Gives everything back
86  * after the keyword + k_del until we hit d_del
87  * \param[in] f file pointer to read from
88  * \param[in] keyword keyword to look for
89  * \param[in] k_del keyword delimeter
90  * \param[out] data the data found
91  * \param[in] d_del the data delimeter
92  * \param[in] data_limit maximum size the the data buffer
93  * \return the number of character read
94  */
95 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);
96 
97 /*
98  * searches for keyword and delim. Gives everything back
99  * after the keyword + k_del until we hit d_del
100  * \param[in] f file pointer to read from
101  * \param[in] keyword keyword to look for
102  * \param[in] k_del keyword delimeter
103  * \param[out] data the data found
104  * \param[in] d_del the data delimeter
105  * \param[in] data_limit maximum size the the data buffer
106  * \param[in] line_nr pointer to an integer containing the current line number (for
107 debugging purposes)
108  * \return the number of character read
109  */
110 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);
111 
112 /*
113  * searches for keyword and delim in a buffer. Gives everything back
114  * after the keyword + k_del until we hit d_del
115  * \param[in] b buffer pointer to read from
116  * \param[in] keyword keyword to look for
117  * \param[in] k_del keyword delimeter
118  * \param[out] data the data found
119  * \param[in] d_del the data delimeter
120  * \param[in] data_limit maximum size the the data buffer
121  * \return the number of character read
122  */
123 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);
124 
132 int ldns_bgetc(ldns_buffer *buffer);
133 
141 void ldns_bskipcs(ldns_buffer *buffer, const char *s);
142 
150 void ldns_fskipcs(FILE *fp, const char *s);
151 
152 
161 void ldns_fskipcs_l(FILE *fp, const char *s, int *line_nr);
162 
163 #ifdef __cplusplus
164 }
165 #endif
166 
167 #endif /* LDNS_PARSE_H */
ldns_struct_buffer
implementation of buffers to ease operations
Definition: buffer.h:50
LDNS_DIR_ORIGIN
@ LDNS_DIR_ORIGIN
Definition: parse.h:42
ldns_bgetc
int ldns_bgetc(ldns_buffer *buffer)
returns the next character from a buffer.
Definition: buffer.c:157
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:223
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:353
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:376
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:188
buffer.h
ldns_directive
enum ldns_enum_directive ldns_directive
Definition: parse.h:45
ldns_enum_directive
ldns_enum_directive
different type of directives in zone files We now deal with $TTL, $ORIGIN and $INCLUDE.
Definition: parse.h:39
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_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:407
common.h
LDNS_DIR_INCLUDE
@ LDNS_DIR_INCLUDE
Definition: parse.h:43
LDNS_DIR_TTL
@ LDNS_DIR_TTL
Definition: parse.h:41
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:31
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:180
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:382