This file contains functions for breaking up lines, which is used primarily in parsing the configuration files. It also contains other random string functions, like chomp and such.
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/unistd.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 does the same as "isblank()", but is included here for portability
int blank ( char ch )
- int blank
- Returns YES if the character is a space, tab, or newline, NO for any other character
- char ch
- A character
Behaves like perl's 'chomp' function. If the last character of a string is a newline, it removes it.
void chomp_line ( char* line )
- char* line
- The line to chomp
Breaks up a line into two parts, which are separated by a '=' character. An arbitrary amount of whitespace is permitted. If the line is blank, or it is a comment (contains a '#' character...a slight bug), it returns.
int parse_line ( char* line_buf, char* directive, char* argument )
- int parse_line
- Returns OK if the line is blank, OK if the line is a comment, OK if the line could be parsed, FAIL if nothing was found
- char* line_buf
- The line to parse
- char* directive
- The character array to store our results in for the directive
- char* argument
- The character array to store our results in for the argument
Tries to emulate perl's split function. It's a bit sloppy, but it seems to work.
int split_line ( char** dest_arr, char* line, int max )
- int split_line
- Returns the number of arguments
- char** dest_arr
- A pointer to a character array where the results of the split will be stored. This function does not malloc any of this memory out; the caller needs to do that ahead of time.
- char* line
- The line to be parsed
- int max
- Maximum number of characters to copy into each array entry
A cheap hack for a function that should really be in string.h (only the GNU libc seems to have it). This function does the same thing as strstr, except that it is case insensitive.
int ubs_strcasestr ( char* haystack, char* needle )
- int ubs_strcasestr
- Returns NO if no match is found, YES if a match is found
- char* haystack
- The string to be searched
- char* needle
- The string to locate within the 'haystack'
Strips leading and trailing whitespace from a string (I think).
int weed_white ( char* str )
- int weed_white
- Returns OK on success
- char* str
- A string to strip. Will be modified directly