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

util.h File Reference

Go to the source code of this file.

Defines

#define STR(s)    #s
 Defines utility functions used by other modules.

#define XSTR(s)   STR(s)
 Stringifies a preprocessor define. More...

#define MAX_CMDEXEC_ARGS   32
 Maximum number of arguments to executeCmd, not including neither the command name nor the trailing NULL.


Functions

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...


Define Documentation

#define MAX_CMDEXEC_ARGS   32
 

Maximum number of arguments to executeCmd, not including neither the command name nor the trailing NULL.

#define STR( s )   #s
 

Defines utility functions used by other modules.

#define XSTR( s )   STR(s)
 

Stringifies a preprocessor define.

Makes a string from a preprocessor define. Usage: cc -DBASEDIR=/usr source.C

------- source.C ---------- include "util.h"

char* str = XSTR (BASEDIR); ------- end source.C ------

Parameters:
s   is the name of the preprocessor define.


Function Documentation

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.


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