init.c File Reference

Go to the source code of this file.

Defines

#define VF_VERSION   "0.3.3"
#define VF_READ_BUFSIZE   1024
#define VF_DEFAULT_HOST   "localhost"
#define VF_DEFAULT_PORT   25
#define VF_DEFAULT_LOGFILE   "/var/log/veldfire.log"
#define VF_DEFAULT_LOGLEVEL   3
#define VF_DEFAULT_CONFIGFILE   "/etc/veldfire/veldfire.conf"
#define VF_DEFAULT_SECTION   "veldfire"
#define VF_DEFAULT_TIMEOUT   60
#define VF_DEFAULT_MAXCONNECTION   128
#define VF_USER_CONFIGFILE   ".veldfirerc"
#define VF_ENV_FROM   "VELDFIRE_FROM"
#define VF_ENV_SUBJECT   "VELDFIRE_SUBJECT"
#define VF_ENV_HOST   "VELDFIRE_HOST"
#define VF_ENV_PORT   "VELDFIRE_PORT"
#define VF_ENV_LOGFILE   "VELDFIRE_LOGFILE"
#define VF_ENV_LOGLEVEL   "VELDFIRE_LOGLEVEL"
#define VF_ENV_CONFIGFILE   "VELDFIRE_CONFIGFILE"
#define VF_ENV_SECTION   "VELDFIRE_SECTION"
#define VF_ENV_REPORT   "VELDFIRE_REPORT"
#define VF_ENV_SENDTIMEOUT   "VELDFIRE_SENDTIMEOUT"
#define VF_ENV_RECVTIMEOUT   "VELDFIRE_RECVTIMEOUT"
#define VF_ENV_TIMEOUT   "VELDFIRE_TIMEOUT"
#define VF_ENV_MAXCONNECTION   "VELDFIRE_MAXCONNECTION"
#define VF_ENV_FOREGROUND   "VELDFIRE_FOREGROUND"
#define VF_ENV_PRINTLOG   "VELDFIRE_PRINTLOG"
#define VF_CONF_TO   "to"
#define VF_CONF_FROM   "from"
#define VF_CONF_SUBJECT   "subject"
#define VF_CONF_HOST   "host"
#define VF_CONF_PORT   "port"
#define VF_CONF_LOGFILE   "logfile"
#define VF_CONF_LOGLEVEL   "loglevel"
#define VF_CONF_REPORT   "report"
#define VF_CONF_MAXCONNECTION   "maxconnection"
#define VF_CONF_SENDTIMEOUT   "sendtimeout"
#define VF_CONF_RECVTIMEOUT   "recvtimeout"
#define VF_CONF_TIMEOUT   "timeout"
#define VF_CONF_BULK   "bulk"
#define VF_CONF_NOMESSAGE   "nomessage"
#define VF_CONF_DEBUG   "debug"
#define VF_CONF_FOREGROUND   "foreground"
#define VF_CONF_HEADER   "header"
#define VF_CONF_PRINTLOG   "printlog"
#define VF_USERAGENT   "User-Agent: Veldfire-" VF_VERSION

Functions

veldfire__veldfire_init (void)
 Obtain a veldfire structure in memory.
void __veldfire_defaults (veldfire *v)
 Set default values.
void __veldfire_env (veldfire *v)
 Read environment variables.
void __veldfire_configfile (veldfire *v)
 Read values from the configuration file.
void __veldfire_commandline (veldfire *v, int ac, char *av[])
 Read the command line options.
char ** __veldfire_add_header (veldfire *v, char *header)
 Add a header to our array.
void __veldfire_cleanup (veldfire *v)
 Free all allocated memory.
veldfireVF__init (int ac, char *av[])
 Initialise a veldfire data structure.
void VF__cleanup (veldfire *v)
 Release resources.
void VF__version (veldfire *v)
 Print a version information string.
void VF__help (veldfire *v)
 Usage message printed to standard out.
int VF__check_config (veldfire *v)
 Check the configuration for sanity.
char * VF__get_msg (veldfire *v)
 Get the email message, either via the terminal or via stdin (eg pipe).


Detailed Description

Author:
Jason Armstrong <ja@riverdrums.com>
Version:
Id
init.c,v 1.15 2006/02/11 20:40:21 riverdrums Exp
Todo:
  1. bulkmail option (sort, unspecified recipient)
  2. debug flag (don't send)
  3. output file (mailbox)
  4. charset setting

Definition in file init.c.


Define Documentation

#define VF_READ_BUFSIZE   1024
 

Read buffer increment

Definition at line 39 of file init.c.

Referenced by VF__get_msg().

#define VF_USER_CONFIGFILE   ".veldfirerc"
 

User configuration file

Definition at line 53 of file init.c.

Referenced by __veldfire_defaults().

#define VF_USERAGENT   "User-Agent: Veldfire-" VF_VERSION
 

User Agent Header

Definition at line 96 of file init.c.

Referenced by __veldfire_defaults().

#define VF_VERSION   "0.3.3"
 

Official Veldfire Version Number

Definition at line 38 of file init.c.

Referenced by VF__version().


Function Documentation

char ** __veldfire_add_header veldfire v,
char *  header
 

Add a header to our array.

Parameters:
v - Veldfire structure
header - Pointer to the header that we are going to add
This doesn't create the header array anew in memory, it just adds a pointer to the existing memory allocation.

Definition at line 431 of file init.c.

References _veldfire::headers.

Referenced by __veldfire_configfile(), and __veldfire_defaults().

void __veldfire_cleanup veldfire v  ) 
 

Free all allocated memory.

Parameters:
v - Veldfire structure

Definition at line 534 of file init.c.

References _veldfire::c, _veldfire::freemsg, _veldfire::headers, _veldfire::log, and _veldfire::msg.

Referenced by VF__cleanup(), VF__help(), VF__init(), and VF__version().

void __veldfire_commandline veldfire v,
int  ac,
char *  av[]
 

Read the command line options.

Parameters:
v - Veldfire structure
ac - Number of command line arguments
av - Array of arguments

Definition at line 365 of file init.c.

References _veldfire::prog, and VF__help().

Referenced by VF__init().

Here is the call graph for this function:

void __veldfire_configfile veldfire v  ) 
 

Read values from the configuration file.

Parameters:
v - Veldfire structure

Definition at line 256 of file init.c.

References __veldfire_add_header(), _veldfire::bulk, _veldfire::c, _veldfire::configfile, _veldfire::debug, _veldfire::foreground, _veldfire::from, _veldfire::host, _veldfire::logfile, _veldfire::loglevel, _veldfire::maxconnection, _veldfire::nomessage, _veldfire::port, _veldfire::printlog, _veldfire::recvtimeout, _veldfire::report, _veldfire::section, _veldfire::sendtimeout, _veldfire::subject, _veldfire::to, VF_CONF_BULK, VF_CONF_DEBUG, VF_CONF_FOREGROUND, VF_CONF_FROM, VF_CONF_HEADER, VF_CONF_HOST, VF_CONF_LOGFILE, VF_CONF_LOGLEVEL, VF_CONF_MAXCONNECTION, VF_CONF_NOMESSAGE, VF_CONF_PORT, VF_CONF_PRINTLOG, VF_CONF_RECVTIMEOUT, VF_CONF_REPORT, VF_CONF_SENDTIMEOUT, VF_CONF_SUBJECT, VF_CONF_TIMEOUT, and VF_CONF_TO.

Referenced by VF__init().

Here is the call graph for this function:

void __veldfire_defaults veldfire v  ) 
 

Set default values.

Parameters:
v - Veldfire structure
Todo:
Make the configfile a strdup() in all cases ...

Definition at line 173 of file init.c.

References __veldfire_add_header(), _veldfire::configfile, _veldfire::host, _veldfire::logfile, _veldfire::loglevel, _veldfire::maxconnection, _veldfire::port, _veldfire::recvtimeout, _veldfire::section, _veldfire::sendtimeout, VF_DEFAULT_CONFIGFILE, VF_DEFAULT_HOST, VF_DEFAULT_LOGFILE, VF_DEFAULT_LOGLEVEL, VF_DEFAULT_MAXCONNECTION, VF_DEFAULT_PORT, VF_DEFAULT_SECTION, VF_DEFAULT_TIMEOUT, VF_USER_CONFIGFILE, and VF_USERAGENT.

Referenced by VF__init().

Here is the call graph for this function:

void __veldfire_env veldfire v  ) 
 

Read environment variables.

Parameters:
v - Veldfire structure

Definition at line 225 of file init.c.

References _veldfire::configfile, _veldfire::foreground, _veldfire::from, _veldfire::host, _veldfire::logfile, _veldfire::loglevel, _veldfire::maxconnection, _veldfire::port, _veldfire::printlog, _veldfire::recvtimeout, _veldfire::report, _veldfire::section, _veldfire::sendtimeout, _veldfire::subject, VF_ENV_CONFIGFILE, VF_ENV_FOREGROUND, VF_ENV_FROM, VF_ENV_HOST, VF_ENV_LOGFILE, VF_ENV_LOGLEVEL, VF_ENV_MAXCONNECTION, VF_ENV_PORT, VF_ENV_PRINTLOG, VF_ENV_RECVTIMEOUT, VF_ENV_REPORT, VF_ENV_SECTION, VF_ENV_SENDTIMEOUT, VF_ENV_SUBJECT, and VF_ENV_TIMEOUT.

Referenced by VF__init().

veldfire * __veldfire_init void   ) 
 

Obtain a veldfire structure in memory.

Returns:
Pointer to a veldfire structure on success

NULL on error (malloc error)

Definition at line 155 of file init.c.

Referenced by VF__init().

int VF__check_config veldfire v  ) 
 

Check the configuration for sanity.

Parameters:
v - Veldfire structure
We check:

  1. We have a 'to' address
  2. All attached files exist and can be read

Definition at line 558 of file init.c.

References _veldfire::files, _veldfire::to, and VF__help().

Referenced by VF__init().

Here is the call graph for this function:

void VF__cleanup veldfire v  ) 
 

Release resources.

Parameters:
v - Veldfire structure

Definition at line 146 of file init.c.

References __veldfire_cleanup().

Referenced by main().

Here is the call graph for this function:

char* VF__get_msg veldfire v  ) 
 

Get the email message, either via the terminal or via stdin (eg pipe).

Parameters:
v - Veldfire structure
Returns:
Pointer to the message, which has been malloced and must be freed

Definition at line 613 of file init.c.

References _veldfire::freemsg, _veldfire::nomessage, and VF_READ_BUFSIZE.

Referenced by main().

void VF__help veldfire v  ) 
 

Usage message printed to standard out.

Parameters:
v - Veldfire structure

Definition at line 488 of file init.c.

References __veldfire_cleanup(), _veldfire::prog, VF_DEFAULT_CONFIGFILE, VF_DEFAULT_HOST, VF_DEFAULT_LOGFILE, VF_DEFAULT_LOGLEVEL, VF_DEFAULT_MAXCONNECTION, VF_DEFAULT_PORT, and VF_DEFAULT_SECTION.

Referenced by __veldfire_commandline(), and VF__check_config().

Here is the call graph for this function:

veldfire* VF__init int  ac,
char *  av[]
 

Initialise a veldfire data structure.

Parameters:
ac - Argument number
av - Array of command line arguments
Returns:
veldfire structure pointer on success

NULL on failure

Definition at line 117 of file init.c.

References __veldfire_cleanup(), __veldfire_commandline(), __veldfire_configfile(), __veldfire_defaults(), __veldfire_env(), __veldfire_init(), _veldfire::log, _veldfire::logfile, _veldfire::loglevel, _veldfire::printlog, and VF__check_config().

Referenced by main().

Here is the call graph for this function:

void VF__version veldfire v  ) 
 

Print a version information string.

Parameters:
v - Veldfire structure
This function frees resources and exits

Definition at line 475 of file init.c.

References __veldfire_cleanup(), and VF_VERSION.

Here is the call graph for this function:

 

 


Jason Armstrong <ja@riverdrums.com>