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 
71 ssize_t ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr);
72 
86 ssize_t ldns_fget_token_l_resolv_conf(FILE *f, char *token, const char *delim, size_t limit, int *line_nr);
87 
112 ldns_status ldns_fget_token_l_st(FILE *f, char **token, size_t *limit, bool fixed, const char *delim, int *line_nr);
113 
124 ssize_t ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit);
125 
126 /*
127  * searches for keyword and delim in a file. Gives everything back
128  * after the keyword + k_del until we hit d_del
129  * \param[in] f file pointer to read from
130  * \param[in] keyword keyword to look for
131  * \param[in] k_del keyword delimiter
132  * \param[out] data the data found
133  * \param[in] d_del the data delimiter
134  * \param[in] data_limit maximum size the data buffer
135  * \return the number of character read
136  */
137 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);
138 
139 /*
140  * searches for keyword and delim. Gives everything back
141  * after the keyword + k_del until we hit d_del
142  * \param[in] f file pointer to read from
143  * \param[in] keyword keyword to look for
144  * \param[in] k_del keyword delimiter
145  * \param[out] data the data found
146  * \param[in] d_del the data delimiter
147  * \param[in] data_limit maximum size the data buffer
148  * \param[in] line_nr pointer to an integer containing the current line number (for
149 debugging purposes)
150  * \return the number of character read
151  */
152 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);
153 
154 /*
155  * searches for keyword and delim in a buffer. Gives everything back
156  * after the keyword + k_del until we hit d_del
157  * \param[in] b buffer pointer to read from
158  * \param[in] keyword keyword to look for
159  * \param[in] k_del keyword delimiter
160  * \param[out] data the data found
161  * \param[in] d_del the data delimiter
162  * \param[in] data_limit maximum size the data buffer
163  * \return the number of character read
164  */
165 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);
166 
174 int ldns_bgetc(ldns_buffer *buffer);
175 
183 void ldns_bskipcs(ldns_buffer *buffer, const char *s);
184 
192 void ldns_fskipcs(FILE *fp, const char *s);
193 
194 
203 void ldns_fskipcs_l(FILE *fp, const char *s, int *line_nr);
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 #endif /* LDNS_PARSE_H */
This file contains the definition of ldns_buffer, and functions to manipulate those.
Common definitions for LDNS.
enum ldns_enum_status ldns_status
Definition: error.h:148
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
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_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.
Definition: parse.c:226
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
enum ldns_enum_directive ldns_directive
Definition: parse.h:45
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
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
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
different type of directives in zone files We now deal with $TTL, $ORIGIN and $INCLUDE.
Definition: parse.h:40
@ LDNS_DIR_TTL
Definition: parse.h:41
@ LDNS_DIR_INCLUDE
Definition: parse.h:43
@ LDNS_DIR_ORIGIN
Definition: parse.h:42
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
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
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
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
int ldns_bgetc(ldns_buffer *buffer)
returns the next character from a buffer.
Definition: buffer.c:157
implementation of buffers to ease operations
Definition: buffer.h:51