File src/ubs.c

This module acts as a frontend to all other UBS daemons. One ring to unite them all! Ehhgh. Anyways, it provides a somewhat user friendly shell which lets one view the status of the UBS, start and stop different modules, view log files, and other such things. The shell can either run in interactive mode (if no arguments are given), in which case it takes in user input, produces output, and goes through a standard REPL loop (read, evaluate, print, loop) like a normall shell. It can also run in non-interactive mode if arguments are given on the command line, in which case it runs the given command, prints the output to standard out, and exits. Web based frontends will probably end up using the non-interactive functionality of this program. Graphical or system frontends (such as GTK) will probably be best to re-implement the functionality of this code on their own.


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 Variable WEEK

An array that holds all of the half-hour slots for an entire week, which is the period of time that the ubs runs off of. This array contains integers which correspond to show ID's

int WEEK[7][48]
Included from include/ubs-sched.h


Global Variable ALLSHOWS

All the known shows

struct show* ALLSHOWS
Included from include/ubs-sched.h


Global Variable SCHED

ubs_table SCHED
Included from include/ubs-sched.h

Global Variable ALLEVENTS

All known events which were parsed in the configuration file

struct event* ALLEVENTS
Included from include/ubs-event.h


Global Variable EVENT

ubs_table EVENT
Included from include/ubs-event.h

Global Function main()

Main program function. If arguments are given, this program will exec them, placing the output on stdout. Otherwise, it will launch an interactive shell.

int main ( int argc, char* argv[] )

int main
Returns OK on success
int argc
Number of arguments on the command line, including program name
char* argv[]
Arguments to the program
Calls: chomp_line()lib/parse_line.c
  console_error()lib/logging.c
  init_week()src/schedule.c
  log_error_msg()lib/logging.c
  parse_command()src/ubs.c
  read_config()lib/read_config.c
  read_events()src/read_events.c
  read_sched()src/read_sched.c
  split_line()lib/parse_line.c
  ubs_init()lib/common.c
  ubs_table_add()lib/table.c
  ubs_table_data()lib/table.c
  ubs_table_init()lib/table.c
  atoi(), bzero(), chdir(), fgets(), fprintf(), free(), malloc(), strncpy()

Global Function parse_command()

The UBS shell just reads in user input, and passes it off to this function to do the brunt of the parsing work. This function expects to be given an array of values, and from there, it figures out which function to call.

int parse_command ( int cmdc, char** cmdv )

int parse_command
Returns OK on success, QUIT if the command was "exit" or "quit", or otherwise simply returns whatever the respective command is set to return
Prototyped in: include/ubs-main.h
Calls: cmd_events()src/cmd_events.c
  cmd_help()src/cmd_help.c
  cmd_log()src/cmd_log.c
  cmd_queue()src/cmd_queue.c
  cmd_restart()src/cmd_restart.c
  cmd_sched()src/cmd_sched.c
  cmd_search()src/cmd_search.c
  cmd_shows()src/cmd_shows.c
  cmd_start()src/cmd_start.c
  cmd_status()src/cmd_status.c
  cmd_stop()src/cmd_stop.c
  cmd_tag()src/cmd_tag.c
  version()lib/common.c
  fprintf(), strcasecmp()
Called by: main()src/ubs.c