File lib/common.c

Contains functions common to most UBS daemons. This includes the version information, signal, and configuration defaults.


Included Files


Global Variable PROCNAME

char PROCNAME[128]
Included from include/ubs.h

Global Variable CUR_TIME

struct tm* CUR_TIME
Included from include/ubs.h

Global Variable GLOBAL

ubs_table GLOBAL
Included from include/ubs.h

Global Variable LOGLEVEL

int LOGLEVEL
Included from include/ubs.h

Global Function check_running()

Sees if a UBS process is already running before starting.

int check_running ( void )

int check_running
Returns OK if not running, FAIL if the process is already started.
Prototyped in: include/ubs.h
Calls: ping_pid()

Global Function set_defaults()

Copies default values into the global context.

void set_defaults ( void )
set_defaults Returns nothing.

Prototyped in: include/ubs.h
Calls: strcmp(), ubs_table_add()
Called by: ubs_init()lib/common.c


Global Function sig_poll()

The polling signal is used to see if the daemon is alive. Anyone can send a polling signal (currently defined as SIGURG (SIGUSR isn't defined on all unix platforms, and SIGUSR is pretty much unused, in case you were wondering.

void sig_poll ( int sig )

int sig
The number of the signal received
Prototyped in: include/ubs.h
Calls: log_error_msg()
Used in: ubs_init()lib/common.c

Global Function sig_quit()

By default, the main UBS daemons bind a number of various quit common signals (SIGINT, SIGHUP, SIGQUIT, and so forth). This is where they go to die. Before the program exits (or crashes, as the case may be), it's nice to log it and such. This could probably be expanded to include more information for debugging in the future.

void sig_quit ( int sig )

int sig
The number of the signal received
Prototyped in: include/ubs.h
Calls: exit(), log_error_msg(), record_status(), snprintf(), unlink()
Used in: ubs_init()lib/common.c

Global Function ubs_init()

Called by all UBS events and daemons upon initialization. This binds all the default signals, and copies default values into the GLOBAL configuration. Also records the process name and other good stuff. This should be called right after the GLOBAL table is initialized.

int ubs_init ( char* pname )

int ubs_init
Returns OK on success
char* pname
The program name, same as argv[0]
Prototyped in: include/ubs.h
Calls: set_defaults()lib/common.c
  console_error(), signal(), srand(), strncpy(), strrchr(), time()
References Functions: sig_poll()lib/common.c
  sig_quit()lib/common.c

Global Function version()

Displays a quick blurb about the program and the current version. The version number is declared in config.h, which is generated by autoconf.

void version ( void )
Prototyped in: include/ubs.h
Calls: printf()