[libimdb-commit] CVS: libimdb/parser imdbDict.c,1.1,1.2 imdbParser.c,1.3,1.4 private.h,1.1,1.2
Status: Pre-Alpha
Brought to you by:
jveldhuis
|
From: Jerry V. <jve...@us...> - 2003-08-28 15:25:05
|
Update of /cvsroot/libimdb/libimdb/parser
In directory sc8-pr-cvs1:/tmp/cvs-serv20497/parser
Modified Files:
imdbDict.c imdbParser.c private.h
Log Message:
a flurry of documentation done
Index: imdbDict.c
===================================================================
RCS file: /cvsroot/libimdb/libimdb/parser/imdbDict.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** imdbDict.c 16 Jun 2003 04:18:38 -0000 1.1
--- imdbDict.c 28 Aug 2003 15:25:00 -0000 1.2
***************
*** 25,35 ****
/*#include "private.h"*/
! struct imdbDict_s
! {
! int fd;
! char dir[1024];
! imdbParser_t *parser;
};
static inline void
writeIt(int fd, char *in)
--- 25,41 ----
/*#include "private.h"*/
! /**
! * management structure for internal state information
! * for imdbDict_t to work
! */
! struct imdbDict_s {
! int fd; /**< file descriptor we're writting to */
! char dir[1024]; /**< directory path of output files */
! imdbParser_t *parser; /**< imdbParser to parse list files */
};
+ /**
+ * @todo - not used
+ */
static inline void
writeIt(int fd, char *in)
***************
*** 93,96 ****
--- 99,107 ----
}
+ /**
+ * our list entry callback function
+ * @returns 0 if everything is okay and we should continue
+ * @returns non-zero if parse should abort.
+ */
static int
listentry_cb(jlogHandle_t *logh,
***************
*** 149,152 ****
--- 160,166 ----
}
+ /**
+ * allocate new imdbDict for use
+ */
imdbDict_t *
imdbDict_create(jlogHandle_t *logh,
***************
*** 173,176 ****
--- 187,193 ----
}
+ /**
+ * deallocate new imdbDict for use
+ */
int
imdbDict_destroy(jlogHandle_t *logh,
***************
*** 182,185 ****
--- 199,208 ----
}
+ /**
+ * index movies info a 'moviedb.idx' file.
+ *
+ * @returns 0 upon success
+ * @returns -1 if process was aborted for some reason
+ */
int
imdbDict_indexMovies(jlogHandle_t *logh,
Index: imdbParser.c
===================================================================
RCS file: /cvsroot/libimdb/libimdb/parser/imdbParser.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** imdbParser.c 21 Aug 2003 22:44:31 -0000 1.3
--- imdbParser.c 28 Aug 2003 15:25:01 -0000 1.4
***************
*** 82,85 ****
--- 82,88 ----
#endif
+ /**
+ * set progresss callbacks for start/progress/finished points in the parse.
+ */
int
imdbParser_setProgressCallbacks(jlogHandle_t *logh,
***************
*** 102,105 ****
--- 105,111 ----
}
+ /**
+ * disable all progress callbacks
+ */
int
imdbParser_disableProgressCallbacks(jlogHandle_t *logh,
***************
*** 109,112 ****
--- 115,126 ----
}
+ /**
+ * allocate new imdbParser with progress callbacks disabled.
+ *
+ * @returns NULL on:
+ * - PARE_INVALID_ARGUMENT
+ * - PARE_DIRECTORY_READ_FAILURE
+ * - PARE_BAD_MEM
+ */
imdbParser_t *
imdbParser_open(jlogHandle_t *logh,
***************
*** 148,151 ****
--- 162,169 ----
}
+ /**
+ * set user handle so list entry callbacks and progress callbacks
+ * have some sense of where they are.
+ */
void *
imdbParser_setUserHandle(jlogHandle_t *logh,
***************
*** 158,161 ****
--- 176,182 ----
}
+ /**
+ * get the last user handle set via 'imdbParser_setUserHandle'
+ */
void *
imdbParser_getUserHandle(jlogHandle_t *logh,
***************
*** 165,168 ****
--- 186,194 ----
}
+ /**
+ * unallocate a imdbParser handle.
+ *
+ * @returns -1 on PARE_INVALID_ARGUMENT (parser handle is invalid)
+ */
int
imdbParser_close(jlogHandle_t *logh,
***************
*** 181,191 ****
}
struct line_s {
! char *buf;
! int used;
! int size;
! int number;
};
static int
readLine(jlogHandle_t *logh, FILE *fp, struct line_s *line)
--- 207,229 ----
}
+ /**
+ * private management structure for tracking parsed lines
+ * along with memory management.
+ */
struct line_s {
! char *buf; /**< pointer to allocated buffer containing a single line of input */
! int used; /**< number of characters in buf used */
! int size; /**< size of allocated buffer 'buf' points in bytes */
! int number; /**< what line number is this */
};
+ /** @def INC
+ * how much should we expand the buffer by if we need more ?
+ */
+ #define INC 256
+
+ /**
+ * read a single line from the specified input file pointer.
+ */
static int
readLine(jlogHandle_t *logh, FILE *fp, struct line_s *line)
***************
*** 211,216 ****
while ( line->buf[line->used-1] != '\n' ) {
- #define INC 256
-
line->buf=realloc(line->buf, line->size+INC);
if ( line->buf == NULL ) {
--- 249,252 ----
***************
*** 433,436 ****
--- 469,477 ----
}
+ /**
+ * decode a movie label into its parts.
+ * @returns 0 upon success
+ * @returns -1 on PARE_FORMAT_ERROR
+ */
int
imdbParser_decodeMovieLabel(jlogHandle_t *logh,
***************
*** 578,581 ****
--- 619,636 ----
}
+ /**
+ * initiate parsing the movies list file.
+ *
+ * @returns -1 on:
+ * - PARE_INVALID_ARGUMENT
+ * - PARE_READ_FAILED
+ * - PARE_BAD_MEM
+ * - PARE_LIST_FILE_MISSING_INITIAL_SEPARATOR
+ * - PARE_LIST_FILE_MISSING_FINAL_SEPARATOR
+ * @returns 0 upon success
+ *
+ * @returns non-zero if listEntry_cb returns non-zero to signal
+ * abort (better not be -1)
+ */
int
imdbParser_moviesParse(jlogHandle_t *logh,
***************
*** 790,793 ****
--- 845,862 ----
}
+ /**
+ * file parser for directors, actors and actresses list files
+ *
+ * @returns -1 on:
+ * - PARE_INVALID_ARGUMENT
+ * - PARE_READ_FAILED
+ * - PARE_BAD_MEM
+ * - PARE_LIST_FILE_MISSING_INITIAL_SEPARATOR
+ * - PARE_LIST_FILE_MISSING_FINAL_SEPARATOR
+ * @returns 0 upon success
+ *
+ * @returns non-zero if listEntry_cb returns non-zero to signal
+ * abort (better not be -1)
+ */
static int
imdbParser_castOrDirectorsParse(jlogHandle_t *logh,
***************
*** 937,941 ****
break;
}
! PARE_LIST_FILE_MISSING_INITIAL_SEPARATOR_FAILURE(logh, pathname, msg, int, -1);
}
}
--- 1006,1010 ----
break;
}
! PARE_LIST_FILE_MISSING_INITIAL_SEPARATORn_FAILURE(logh, pathname, msg, int, -1);
}
}
***************
*** 1028,1032 ****
*gt='\0';
while (isspace(*aka)) {
! *aka++;
}
*gt=')';
--- 1097,1101 ----
*gt='\0';
while (isspace(*aka)) {
! aka++;
}
*gt=')';
***************
*** 1194,1198 ****
if ( sepFound != 3 ) {
! PARE_LIST_FILE_MISSING_FINAL_SEPARATOR_FAILURE(logh, pathname, "line starting with '-------'", int, -1);
}
--- 1263,1267 ----
if ( sepFound != 3 ) {
! PARE_LIST_FILE_MISSING_FINAL_SEPARATO_RFAILURE(logh, pathname, "line starting with '-------'", int, -1);
}
***************
*** 1200,1203 ****
--- 1269,1275 ----
}
+ /**
+ * initiate parsing the directors list file.
+ */
int
imdbParser_directorsParse(jlogHandle_t *logh,
***************
*** 1209,1212 ****
--- 1281,1287 ----
}
+ /**
+ * initiate parsing the actors list file.
+ */
int
imdbParser_actorsParse(jlogHandle_t *logh,
***************
*** 1218,1221 ****
--- 1293,1299 ----
}
+ /**
+ * initiate parsing the actresses list file.
+ */
int
imdbParser_actressesParse(jlogHandle_t *logh,
Index: private.h
===================================================================
RCS file: /cvsroot/libimdb/libimdb/parser/private.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** private.h 16 Jun 2003 04:18:38 -0000 1.1
--- private.h 28 Aug 2003 15:25:01 -0000 1.2
***************
*** 4,22 ****
*/
! /*typedef void (FormatError_cb_t)(jlogHandle_t *logh,
! imdbParser_t *parser,
! const char *pathname,
! int lineNumber,
! const char *message);*/
!
! typedef struct movieStats_s {
! int numTVMiniSeries;
! int numMovie;
! int numTVSeries;
! int numTVMovie;
! int numVideoMovie;
! int numVideoGame;
! } movieStats_t;
!
struct imdbParser_s
{
--- 4,10 ----
*/
! /**
! * management structure for imdbParser
! */
struct imdbParser_s
{
***************
*** 24,51 ****
char *dbsDir;
! /*FormatError_cb_t *formatError_cb;*/
!
progressStarting_cb_t *progressStarting_cb;
progressUpdate_cb_t *progressUpdate_cb;
progressFinished_cb_t *progressFinished_cb;
ListEntry_cb_t *listEntry_cb;
struct {
! movieStats_t movieList;
struct {
! int numDirectors;
! movieStats_t movies;
} directorsList;
struct {
! int numActors;
! movieStats_t movies;
} actorsList;
struct {
! int numActresses;
! movieStats_t movies;
} actressesList;
--- 12,48 ----
char *dbsDir;
! /** progress callback - processing started callback */
progressStarting_cb_t *progressStarting_cb;
+
+ /** progress callback - processing progress callback */
progressUpdate_cb_t *progressUpdate_cb;
+
+ /** progress callback - processing finished callback */
progressFinished_cb_t *progressFinished_cb;
+ /** callback for each list entry */
ListEntry_cb_t *listEntry_cb;
+ /** running statistics collected during parse */
struct {
! struct {
! int numTVMiniSeries; /**< self described */
! int numMovie; /**< self described */
! int numTVSeries; /**< self described */
! int numTVMovie; /**< self described */
! int numVideoMovie; /**< self described */
! int numVideoGame; /**< self described */
! } movieList;
struct {
! int numDirectors; /**< self described */
} directorsList;
struct {
! int numActors; /**< self described */
} actorsList;
struct {
! int numActresses; /**< self described */
} actressesList;
|