Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

poslib/masterfile.h File Reference

Master file reading routines. More...

Go to the source code of this file.


Defines

#define  POSLIB_MF_AUTOPROBE   1 /**< ignore given znroot and guess from file name */
#define  POSLIB_MF_NOSOA   2 /**< Do not require SOA record */

Typedefs

typedef void(*  error_callback )(void *user_dat, const char *fname, int linenum, const char *message)
  error 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

typedef void(*  rr_callback )(void *user_dat, DnsRR *rr)
  compiled RR callback function

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


Functions

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

domainname  guess_zone_name (const char *file)
  guess zone name from file name

FILE *  try_fopen_r (const char *file)
  try and open a file for reading

FILE *  try_fopen (const char *file, const char *mode)
  try and open a file

bool  file_exists (const char *file)
  check for existence of file


Detailed Description

Master file reading routines.

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

Definition in file masterfile.h.


Define Documentation

#define POSLIB_MF_AUTOPROBE   1 /**< ignore given znroot and guess from file name */
 

ignore given znroot and guess from file name

Definition at line 91 of file masterfile.h.

#define POSLIB_MF_NOSOA   2 /**< Do not require SOA record */
 

Do not require SOA record

Definition at line 92 of file masterfile.h.


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_dat  User data supplied to read_master_file
comment  The comment (with the initial ';' chomped off)

Definition at line 89 of file masterfile.h.

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_dat  User data supplied to read_master_file
fname  File name of the master file
linenum  Current line number
message  The error message

Definition at line 48 of file masterfile.h.

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_dat  User data supplied to read_master_file
rr  The RR

Definition at line 78 of file masterfile.h.

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_dat  User data supplied to read_master_file
dom  The domain name
ttl  TTL value
type  The RR type
rrdata  The RR data
origin  The zone root

Definition at line 68 of file masterfile.h.


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:
file  file 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:
file  file 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:
file  Master file to open
znroot  Root domain of zone
userdat  User data supplied to callbacks
err  Error callback function called when an error occurs
rr_cb  Callback called for each RR, passing binary data (optional)
rrl_cb  Callback called for each RR, passing literal data (optional)
comm_cb  Callback for comments (optional)
flags  One of POSLIB_MF_AUTOPROBE, POSLIB_MF_NOSOA

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:
file  file name
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:
file  file name
Returns:
FILE* pointer, or NULL on error

Generated on Fri Dec 24 19:55:15 2004 for Poslib by doxygen 1.3.7