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 
96 ldns_status ldns_fget_token_l_st(FILE *f, char **token, size_t *limit, bool fixed, const char *delim, int *line_nr);
97 
108 ssize_t ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit);
109 
110 /*
111  * searches for keyword and delim in a file. Gives everything back
112  * after the keyword + k_del until we hit d_del
113  * \param[in] f file pointer to read from
114  * \param[in] keyword keyword to look for
115  * \param[in] k_del keyword delimeter
116  * \param[out] data the data found
117  * \param[in] d_del the data delimeter
118  * \param[in] data_limit maximum size the the data buffer
119  * \return the number of character read
120  */
121 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);
122 
123 /*
124  * searches for keyword and delim. Gives everything back
125  * after the keyword + k_del until we hit d_del
126  * \param[in] f file pointer to read from
127  * \param[in] keyword keyword to look for
128  * \param[in] k_del keyword delimeter
129  * \param[out] data the data found
130  * \param[in] d_del the data delimeter
131  * \param[in] data_limit maximum size the the data buffer
132  * \param[in] line_nr pointer to an integer containing the current line number (for
133 debugging purposes)
134  * \return the number of character read
135  */
136 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);
137 
138 /*
139  * searches for keyword and delim in a buffer. Gives everything back
140  * after the keyword + k_del until we hit d_del
141  * \param[in] b buffer pointer to read from
142  * \param[in] keyword keyword to look for
143  * \param[in] k_del keyword delimeter
144  * \param[out] data the data found
145  * \param[in] d_del the data delimeter
146  * \param[in] data_limit maximum size the the data buffer
147  * \return the number of character read
148  */
149 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);
150 
158 int ldns_bgetc(ldns_buffer *buffer);
159 
167 void ldns_bskipcs(ldns_buffer *buffer, const char *s);
168 
176 void ldns_fskipcs(FILE *fp, const char *s);
177 
178 
187 void ldns_fskipcs_l(FILE *fp, const char *s, int *line_nr);
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* LDNS_PARSE_H */
implementation of buffers to ease operations
Definition: buffer.h:50
@ LDNS_DIR_ORIGIN
Definition: parse.h:42
int ldns_bgetc(ldns_buffer *buffer)
returns the next character from a buffer.
Definition: buffer.c:157
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:274
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:404
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:427
enum ldns_enum_status ldns_status
Definition: error.h:146
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:239
enum ldns_enum_directive ldns_directive
Definition: parse.h:45
ldns_enum_directive
different type of directives in zone files We now deal with $TTL, $ORIGIN and $INCLUDE.
Definition: parse.h:39
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
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:458
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_DIR_INCLUDE
Definition: parse.h:43
@ LDNS_DIR_TTL
Definition: parse.h:41
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:220
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:231
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:433