Design of Toolbox

1 Name

Classname: Toolbox
Declaration:
class Toolbox
Toolbox();
~Toolbox();
..
};
Based On:
iostream.h, string.h and some others
Properties:
The Toolbox provides a wealth of extra methods you might need in your CGI-application. It is not directly connected to the library and compiled in by default but may be very useful.

2 Purpose

The Toolbox' purpose is to provide a set of functions/methods for the CGI-programmer which far too-often has to write the same functions over and over again. I have collected in this class a few functions which I use frequently, and I hope you'll find use for them too.

3 Description

3.1 Methods


3.1.1 Basic Methods
void constructor Toolbox()
Description: Your basic constructor which initializes the workingdirectory to "." (dot).


void constructor Toolbox(const char *workdir)
Description: Initializes the working directory to workdir


void constructor Toolbox(const Toolbox &ct)
Description: A copy-constructor


void operator =(const Toolbox &ct)
Description: Your assignment-operator


virtual void destructor ~Toolbox()
Description: Your destructive element

3.1.2 Random Methods
void method pseudoinit(MYINT tmp_seed=NULL)
Description: Initializes the random-number generator


void method pseudorand(void )
Description: Returns a pseudo-random number


void method getRandomNumber(void )
Equivalent to: pseudorand( )

3.1.3 Fancy methods
int method paranoidsystem(const char *command) const
Description: For those of us who're paranoid and need to call system( )


void method crashAndBurn(const char *bailoutMsg, int crashLevel) const
Description: Primitive example of a crash-and-burn method

3.1.4 Checkpoint Charlie
int method isDirectory(const char *path) const

int method isFile(const char *file) const

int method isLink(const char *file) const

void method getFilesize(const char *file) const
3.1.5 Files and stuff
int method readinfile(ostream &doc, const char *filename, const char *directory=NULL) const
Description: Reads in a file from the given area


void method gethtmlfiles(const char *directory=NULL) const
Description: Returns the HTML-files


int method listhtmlfiles(ostream &doc, const char *directory, int (*lister)(ostream &doc, const char* file)) const
Description: Lists the HTML-files with the lister-functions


void method getfiles(const char *directory=NULL, const char *fileExtension=NULL) const
Description: Returns an array with the files in the given directory


int method listfiles(ostream &doc, const char *directory, const char *fileExtension, int (*lister)(ostream &doc, const char* file)) const
Description: Lists the files with the given lister-function.


char *method getUserPath(const char *user) const
Description: Returns the userpath for the given user. Only available on unix-systems.

3.1.6 Protected Methods
int method fileselecter(dirent *entry, const char *extension) const
Description: For internal use only


char *method correctdir(const char *dir) const
Description: For internal use only

4 Maintenance

Information about bugs, errors, problems, etc. should be sent to stig@ii.uib.no
Written by: Stig Erik Sandø
Version: Document created with SDS v0.20