Skip to content

Commit

Permalink
Move resolv.conf token parser to parse.h
Browse files Browse the repository at this point in the history
Including a doxygen comment stating the limitations
  • Loading branch information
wtoorop committed May 15, 2024
1 parent 1acfcb2 commit 6acd12d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 17 additions & 1 deletion ldns/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ 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 when it finds them.
* and ignores when it finds them. This function also handles and ignores
* zonefile format comments starting with ;
* \param[in] *f the file to read from
* \param[out] *token the token is put here
* \param[in] *delim chars at which the parsing should stop
Expand All @@ -69,6 +70,21 @@ 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);

/**
* returns a token/char from the stream F.
* This function deals with ( and ) in the stream,
* and ignores when it finds them. This function also handles and ignores
* comments such as they can be used in resolv.conf files. Starting with
* either ; or #.
* \param[in] *f the file to read from
* \param[out] *token the token is put here
* \param[in] *delim chars at which the parsing should stop
* \param[in] *limit how much to read. If 0 use builtin maximum
* \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
* \return 0 on error of EOF of F otherwise return the length of what is read
*/
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.
* This function deals with ( and ) in the stream,
Expand Down
2 changes: 0 additions & 2 deletions resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,6 @@ ldns_resolver_new_frm_fp(ldns_resolver **res, FILE *fp)
return ldns_resolver_new_frm_fp_l(res, fp, NULL);
}

ssize_t ldns_fget_token_l_resolv_conf(FILE *f, char *token, const char *delim,
size_t limit, int *line_nr);
ldns_status
ldns_resolver_new_frm_fp_l(ldns_resolver **res, FILE *fp, int *line_nr)
{
Expand Down

0 comments on commit 6acd12d

Please sign in to comment.