Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

util.c File Reference


Functions

char* alloca ()
RETSIGTYPE signalHandler (int sig)
 Signal handler to set shutdown flag. More...

char* ip2str (u_int32 ip)
 Gets the string representation of a given IP address. More...

void executeCmd (char *cmd,...)
 Executes a system command with the given parameters. More...

pid_t daemonize ()
 Make the current process a daemon. More...

void setSignals (int *fShutdown)
 Catches SIGTERM and SIGINT. More...


Variables

int* fShutdownp = NULL
 Pointer to the shutdown flag.


Function Documentation

char* alloca ( )
 

pid_t daemonize ( )
 

Make the current process a daemon.

Forks off and closes all files.

Returns:
0 on the daemon, pid on the parent (which exists) and -1 on error.

void executeCmd ( char * cmd,
... )
 

Executes a system command with the given parameters.

This function is just a wrapper arround fork/execv that forks and executes the given command. The full path to the command is <libexecdir>/wccpd/cmd. It will wait for the command to complete before it returns.

The variable length char* parameter list must be NULL terminated, and must not exceed MAX_CMDEXEC_ARGS parameters (not including neither the command name nor the trailing NULL).

Parameters:
cmd   the command to execute.

char * ip2str ( u_int32 ip )
 

Gets the string representation of a given IP address.

This function uses a statically allocated buffer, thus each call overwrites the previous call's result.

Parameters:
ip   the IP address to convert, in Network Byte Order.
Returns:
the quad-dot notation string of the given ip.

void setSignals ( int * fShutdown )
 

Catches SIGTERM and SIGINT.

Each time one of the signals is received, the integer pointed to by fShutdown is incremented.

Parameters:
fShutdown   a pointer to an integer to be incremented.

RETSIGTYPE signalHandler ( int sig ) [static]
 

Signal handler to set shutdown flag.

This signal handler just increments the variable pointed by fShutdownp, if non-NULL.

Parameters:
sig   the signal that was triggered.


Variable Documentation

int* fShutdownp = NULL [static]
 

Pointer to the shutdown flag.


Generated at Fri Jan 25 19:22:24 2002 for wccpd by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001