File src/schedule.c

This file contains functions relevant to the schedule of shows. This includes finding shows, printing things out, and adding shows.


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 Function add_show()

This sets a slot in the global schedule (the 'week' array). The way the show ID's are done is kind of weird, and now that I'm going through this code much later, I realize that it is somewhat counter-intuitive. Anyways, the ALLSHOWS array is 0-indexed, and corresponds to the "pure" show ID. That is, if you want to get the information on the second show, you just access ALLSHOWS[1]. That being said, this information is also stored within the ALLSHOWS data structure in ALLSHOWS[].show_id . This represents the "true" ID, _which starts at 1_ (that's rather important, mind you). However, this information is stored differently within the actual schedule (yes, it would be just toooo easy to do it the obvious way, wouldn't it?). The week data structure is simply a large 2-D matrix of single integer values, where each value is: (ID * 10) + (Frequency) . Thus, everything in the matrix is a 2-digit number, with the first digit being the actual ID of the show in question, and the second digit being the priority of the show. Keep in mind that this ID is going to be one higher than the index in the ALLSHOWS array. Yes, this is dumb. Sorry. :/ This was done so that the scheduling algorithm could go through the week matrix and if two shows overlapped, then it would find out the priority and overwrite if necessary.

int add_show ( int show_num, int wday, int timeslot )

int add_show
Returns OK on success.
int show_num
The index of the show to add to the week. This index corresponds to the show's place in the ALLSHOWS array.
int wday
The weekday to add the show in
int timeslot
The timeslot to add the show in
Prototyped in: include/ubs-sched.h
Called by: init_week()src/schedule.c

Global Function dump_sched()

Prints the current schedule to standard output. Again, not used internally by the UBS. This will go through each day, and for each timeslot will print out the show that occupies that slot.

int dump_sched ( int format )

int dump_sched
Returns OK on success
int format
The output format
Prototyped in: include/ubs-sched.h
Calls: find_show()src/schedule.c
  fprintf()

Global Function find_show()

Returns the index in the ALLSHOWS array for a given timeslot (weekday and time of day)

int find_show ( int wday, int timeslot )

int find_show
Returns the index of the show, or -1 if no show is found
int wday
The weekday (0-6 for sunday-saturday, respectively)
int timeslot
The time of day. Time is handled kind of strangely by the UBS. Basically, it sees each day as being divided into 48 30-minute durations, and indexes them from 0-47. So slot 0 would correspond to 12.00am-12.30am, slot 1 would be 12.30am-1.00am, and so on
Prototyped in: include/ubs-sched.h
Calls: ubs_table_data()lib/table.c
  atoi()
Called by: cmd_shows()src/cmd_shows.c
  dump_sched()src/schedule.c
  sub_dump_sched()src/cmd_sched.c

Global Function init_week()

Initializes the week array, setting everything to default values.

int init_week ( void )

int init_week
Returns OK on success.
Prototyped in: include/ubs-sched.h
Calls: add_show()src/schedule.c
  log_error_msg()lib/logging.c
  ubs_table_data()lib/table.c
  atoi(), memset()