File lib/parse_line.c

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


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 blank()

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
Prototyped in: include/ubs.h
Called by: split_line()lib/parse_line.c
  weed_white()lib/parse_line.c

Global Function chomp_line()

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
Prototyped in: include/ubs.h
Calls: strlen()
Called by: check_against_cur()lib/get_song.c
  check_against_queue()lib/get_song.c
  get_song()lib/get_song.c

Global Function parse_line()

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
Prototyped in: include/ubs.h
Calls: weed_white()lib/parse_line.c
  bzero(), strchr(), strlen(), strncpy()

Global Function split_line()

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
Prototyped in: include/ubs.h
Calls: blank()lib/parse_line.c
  strlen(), strncpy()

Global Function ubs_strcasestr()

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'
Prototyped in: include/ubs.h
Calls: strlen(), strncasecmp()
Called by: check_against_tags()lib/music_info.c

Global Function weed_white()

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
Prototyped in: include/ubs.h
Calls: blank()lib/parse_line.c
  bzero(), strlen(), strncat(), strncpy()
Called by: parse_line()lib/parse_line.c