This file contains functions relevant to the schedule of shows. This includes finding shows, printing things out, and adding shows.
Included Files
- #include </usr/lib/gcc-lib/i486-pc-linux-gnu/3.2.3/include/stdio.h>
- #include </usr/include/stdlib.h>
- #include </usr/include/string.h>
char PROCNAME[128]
struct tm* CUR_TIME
ubs_table GLOBAL
int LOGLEVEL
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]
All the known shows
struct show* ALLSHOWS
ubs_table SCHED
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
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
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
Initializes the week array, setting everything to default values.
int init_week ( void )
- int init_week
- Returns OK on success.