Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
masterfile.cpp File Reference
#include <cstdio>
#include "masterfile.h"
#include "exception.h"
#include "rr.h"
#include "lexfn.h"
#include "sysstring.h"
#include <sys/stat.h>
+ Include dependency graph for masterfile.cpp:

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
std::string rrdata_convertdoms (rr_type *rr, domainname znroot, domainname origin, char *ptr)
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

Variables

const char pathdelim = '/'

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

std::string rrdata_convertdoms ( rr_type rr,
domainname  znroot,
domainname  origin,
char *  ptr 
)
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

Variable Documentation

const char pathdelim = '/'