#include <cassert>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cerrno>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include "hash.h"
#include "id.h"
#include "data.h"
#include "trace.h"
#include "kbase.h"
#include "dictionary.h"
#include "util.h"
#include "ondisk.h"
#include "calendar.h"
#include "gabbie.h"
#include "tv.h"
#include "time.h"
Classes | |
struct | TvHeader |
TvHeader: Data structure at start of file. More... | |
struct | ChannelRecord |
ChannelRecord: On-disk record (representation) for a channel. More... | |
struct | Channel |
struct | ProgramRecord |
class | IndexNode |
Defines | |
#define | TV_ADDR(a) (((int)a) + sTvData) |
#define | TV_UNDO_ADDR(a) (((int)a) - (int)sTvData) |
#define | CHAN_SIZE 1024 |
Functions | |
char * | SkipWhiteSpace (char *p) |
char * | FindStr (char *sub, char *p) |
FindStr: Find sub in p, return pointer to where found, or NULL if not. | |
char | StrFxCmp (char *a, char *b) |
StrFxCmp: Fixed length strcmp based on length of first string. | |
void | StrCharReplace (char *p, char a, char b) |
In string *p, replace any occurence of char a with char b. | |
void | StrReplace (char *src, int srcLen, char *targ, char *repl) |
If src contains targ, replace with repl. Src must be large enough. | |
void | AddNumberToIndex (int num, int pos, Id cat) |
int | IsPunc (char c) |
Returns 1 if c is punctuation (except '^' and '-'); returns 0 otherwise. | |
void | RawIndexAdd (Id id, int pos, Id cat) |
The actual add, after the processing. | |
int | Exclude (char *p) |
void | AddToIndex (Id id, int pos, Id cat) |
void | ReadChannel (FILE *fp, char *p) |
char * | StrExtract (char *p) |
StrExtract: Extract the part of the string between "> <". | |
void | ReadProgram (FILE *fp, char *p) |
void | UpdateChannel (int key, void *value) |
Updates one ChannelRecord. | |
void | WriteIndexRecords (int key, void *value) |
void | ReadTVListings (char *fileName) |
Read an xml file of TV listings created by grabtv. | |
void | PrintProgram (ProgramRecord *pProg, int verbosity=0) |
Print a program record. | |
int | FindChannel (Id id) |
Find channel indexed by id, and return file offset, or 0 if not found. | |
int | ChanCompare (void *p1, void *p2) |
Helper function for sorting channels. | |
int | NewProgCompare (void *p1, void *p2) |
int | ProgCompare (void *p1, void *p2) |
Data * | DisplayName (Context *pContext) |
Data * | QueryPrograms (double startTime, double nowTime, double endTime, Data *pFavChan, Context *p) |
Variables | |
char * | sTvData = NULL |
Static pointer to mmap'd TV on-disk data. | |
CalendarDisk * | sTvCalendar = NULL |
HashDisk * | sTvIndex = NULL |
int | sPrintProgMode = 0 |
sPrintProgMode == 1, print end times - currently not used | |
Data * | spFavChan = NULL |
ChannelRecord * | sChanArray [CHAN_SIZE] |
Phase 1 write to disk:
Phase 2 read from disk / process statements/queries:
Phase 3 Generalized OnDisk function
tv.c Design notes:
Indices:
TODO: 1. Enhance class Data so it can work in memory and on-disk. TODO: 2. Convert the TV database to class Data (not special structures)
TODO: I'm having a tough time deciding if credits should be indexed separately (index of writers, index of actors), or just Index person->program, and then scan to see if writer, etc. Need a vision for how to index, what to index.
TODO: Need general database creation mechanism - but - kinda need to do a first one to understand how to generalize. Note: Need to look into just using MYSQL.
Data Types:
|
|
|
|
|
|
|
|
|
|
|
Helper function for sorting channels.
|
|
|
|
Return true if string is one of "The the And and For for", which are excluded from indexing. |
|
Find channel indexed by id, and return file offset, or 0 if not found.
|
|
FindStr: Find sub in p, return pointer to where found, or NULL if not.
|
|
Returns 1 if c is punctuation (except '^' and '-'); returns 0 otherwise.
|
|
|
|
Print a program record.
|
|
|
|
|
|
The actual add, after the processing.
|
|
|
|
ReadProgram() reads an XML record for a program in a TV listing, builds the on-disk ProgramRecord and writes it to disk. ReadProgram() adds entries to indices for this program. ReadProgram() is called by ReadTVListings(). |
|
Read an xml file of TV listings created by grabtv. ReadTvListings() reads an xml file of TV listings created by grabtv. This function is called by DoCommand() in gabbie.c. This function calls ReadProgram() to process program information and calls ReadChannel() to process channel information. This function writes out a binary file to DATA/tv_data.gab with channel and program information. The DATA/tv_data.gab file is used by Tv::OpenTvFile(). |
|
|
|
In string *p, replace any occurence of char a with char b.
|
|
StrExtract: Extract the part of the string between "> <".
|
|
StrFxCmp: Fixed length strcmp based on length of first string.
|
|
If src contains targ, replace with repl. Src must be large enough.
|
|
Updates one ChannelRecord.
|
|
|
|
|
|
|
|
sPrintProgMode == 1, print end times - currently not used
|
|
|
|
Static pointer to mmap'd TV on-disk data.
|
|
|