Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
masterfile.h File Reference

Master file reading routines. More...

#include <stdio.h>
#include "dnsmessage.h"
#include "domainfn.h"
+ Include dependency graph for masterfile.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define POSLIB_MF_AUTOPROBE   1
#define POSLIB_MF_NOSOA   2

Typedefs

typedef void(* comment_callback )(void *user_dat, const char *comment)
 comment callback function
typedef void(* error_callback )(void *user_dat, const char *fname, int linenum, const char *message)
 error callback function
typedef void(* rr_callback )(void *user_dat, DnsRR *rr)
 compiled RR callback function
typedef void(* rr_literal_callback )(void *user_dat, const char *dom, const char *ttl, const char *type, const char *rrdata, domainname origin)
 literal RR callback function

Functions

bool file_exists (const char *file)
 check for existence of file
domainname guess_zone_name (const char *file)
 guess zone name from file name
void read_master_file (const char *file, domainname &znroot, void *userdat, error_callback err, rr_callback rr_cb, rr_literal_callback rrl_cb, comment_callback comm_cb, int flags)
 read master files
FILE * try_fopen (const char *file, const char *mode)
 try and open a file
FILE * try_fopen_r (const char *file)
 try and open a file for reading

Detailed Description

Master file reading routines.

In this file, you will find everything you need to start reading and interpreting master files today!

Macro Definition Documentation

#define POSLIB_MF_AUTOPROBE   1

ignore given znroot and guess from file name

#define POSLIB_MF_NOSOA   2

Do not require SOA record

Typedef Documentation

typedef void(* comment_callback)(void *user_dat, const char *comment)

comment callback function

Callback function for line comments, that is lines beginning with a ';' sign. These can be used to embed configuration options in master files.

See Also
read_master_file
Parameters
user_datUser data supplied to read_master_file
commentThe comment (with the initial ';' chomped off)
typedef void(* error_callback)(void *user_dat, const char *fname, int linenum, const char *message)

error callback function

This user callback function will be called by read_master_file if a non-terminal error has occured in the master file (e.g. one RR could not be read). It can be handled by the application to display the error message.

See Also
read_master_file
Parameters
user_datUser data supplied to read_master_file
fnameFile name of the master file
linenumCurrent line number
messageThe error message
typedef void(* rr_callback)(void *user_dat, DnsRR *rr)

compiled RR callback function

Callback function getting a compiled resource record.

See Also
read_master_file
Parameters
user_datUser data supplied to read_master_file
rrThe RR
typedef void(* rr_literal_callback)(void *user_dat, const char *dom, const char *ttl, const char *type, const char *rrdata, domainname origin)

literal RR callback function

Callback function getting literal RR data back from the reader. This can be used by editors to preserve the way the user spelled an RR, for example by using '2h' instead of 7200. The implication of this is that there is no guarantee the actual RR data has the right syntax. If however this is not the case, the error callback is called. If the data contains data relative to a non-znroot origin, it is converted to make it relative to the zone root.

See Also
read_master_file
Parameters
user_datUser data supplied to read_master_file
domThe domain name
ttlTTL value
typeThe RR type
rrdataThe RR data
originThe zone root

Function Documentation

bool file_exists ( const char *  file)

check for existence of file

This function tests whether the given file exists and is a common file.

Parameters
filefile name
Returns
true if the file exists, false otherwise
domainname guess_zone_name ( const char *  file)

guess zone name from file name

This function will do an educated guess on the zone name for a given file. For example, a file called 'db.acdam.net' will probably be of the 'acdam.net' zone. Supported are the 'db.' prefix and the '.prm' postfix.

Parameters
filefile name
Returns
Guess for zone name
void read_master_file ( const char *  file,
domainname znroot,
void *  userdat,
error_callback  err,
rr_callback  rr_cb,
rr_literal_callback  rrl_cb,
comment_callback  comm_cb,
int  flags 
)

read master files

This function will read the given master file for you, calling the supplied callbacks when nessecary. This function contains a fairly simple lexical analyzer which supports most standard master file features, but not the '$include' functionality. If the function detects a syntax error, it will call the error callback function, but it will continue reading the file.

Parameters
fileMaster file to open
znrootRoot domain of zone
userdatUser data supplied to callbacks
errError callback function called when an error occurs
rr_cbCallback called for each RR, passing binary data (optional)
rrl_cbCallback called for each RR, passing literal data (optional)
comm_cbCallback for comments (optional)
flagsOne of POSLIB_MF_AUTOPROBE, POSLIB_MF_NOSOA

< ignore given znroot and guess from file name

< Start of Authority RR type

< Do not require SOA record

< Start of Authority RR type

< Start of Authority RR type

< Start of Authority RR type

< Do not require SOA record

FILE* try_fopen ( const char *  file,
const char *  mode 
)

try and open a file

This function tests whether the given filename is a directory, and if it isn't, it will try opening it and return a C-style FILE* pointer.

Parameters
filefile name
modeaccess mode
Returns
FILE* pointer, or NULL on error
FILE* try_fopen_r ( const char *  file)

try and open a file for reading

This function tests whether the given filename is a directory, and if it isn't, it will try opening it and return a C-style FILE* pointer.

Parameters
filefile name
Returns
FILE* pointer, or NULL on error