libimdb-commit Mailing List for libimdb (Page 2)
Status: Pre-Alpha
Brought to you by:
jveldhuis
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(35) |
Jul
|
Aug
(29) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
|---|
|
From: Jerry V. <jve...@us...> - 2003-08-17 16:41:54
|
Update of /cvsroot/libimdb/libimdb/parser
In directory sc8-pr-cvs1:/tmp/cvs-serv24662
Modified Files:
imdbParser.c
Log Message:
removed some dead code, fixed failure to check malloc failure
Index: imdbParser.c
===================================================================
RCS file: /cvsroot/libimdb/libimdb/parser/imdbParser.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** imdbParser.c 16 Jun 2003 04:18:38 -0000 1.1
--- imdbParser.c 17 Aug 2003 16:41:51 -0000 1.2
***************
*** 391,397 ****
}
! /** @todo - malloc not checked */
!
! static inline void
subLine(struct line_s *line, struct line_s *newline, int start, int length)
{
--- 391,395 ----
}
! static inline int
subLine(struct line_s *line, struct line_s *newline, int start, int length)
{
***************
*** 410,413 ****
--- 408,414 ----
}
newline->buf=malloc(length+1);
+ if ( newline->buf == NULL ) {
+ return(-1);
+ }
newline->used=length;
newline->size=length+1;
***************
*** 415,427 ****
newline->buf[newline->used]='\0';
}
}
! static inline void
splitLine(struct line_s *line, struct line_s *newline, int start)
{
! subLine(line, newline, start, TO_END_OF_LINE);
line->used=start;
line->buf[line->used]='\0';
! //return(start);
}
--- 416,434 ----
newline->buf[newline->used]='\0';
}
+ return(0);
}
! /**
! * @todo not used
! */
! static inline int
splitLine(struct line_s *line, struct line_s *newline, int start)
{
! if ( subLine(line, newline, start, TO_END_OF_LINE) != 0 ) {
! return(-1);
! }
line->used=start;
line->buf[line->used]='\0';
! return(0);
}
***************
*** 480,483 ****
--- 487,495 ----
else {
results->type=isMovie;
+ /*if ( year != NULL ) {
+ char buf[1024];
+ sprintf(buf, "extra qualifier(s) %s %s", year, st);
+ PARE_FORMAT_ERROR_FAILURE(logh, pathname, line.number, buf, int, -1);
+ }*/
year=st;
}
***************
*** 798,802 ****
char *initHeader;
char *initHeaderUL;
- movieStats_t *movieStats;
PAR_ENTER2(logh,
--- 810,813 ----
***************
*** 817,821 ****
/* reset stats */
parser->stats.directorsList.numDirectors=0;
- movieStats=&(parser->stats.directorsList.movies);
break;
case LIST_ACTORS:
--- 828,831 ----
***************
*** 827,831 ****
/* reset stats */
parser->stats.actorsList.numActors=0;
- movieStats=&(parser->stats.actorsList.movies);
break;
case LIST_ACTRESSES:
--- 837,840 ----
***************
*** 837,851 ****
/* reset stats */
parser->stats.actressesList.numActresses=0;
- movieStats=&(parser->stats.actressesList.movies);
break;
default:
abort();
}
- movieStats->numTVMiniSeries=0;
- movieStats->numMovie=0;
- movieStats->numTVSeries=0;
- movieStats->numTVMovie=0;
- movieStats->numVideoMovie=0;
- movieStats->numVideoGame=0;
if ( access(pathname, R_OK) != 0 ) {
--- 846,853 ----
***************
*** 957,965 ****
}
else {
- /*MovieType_e type=isMovie;
- int yearNumber;
- char *year=NULL;
- char *romanNumberalsInYear=NULL;
- */
int billing=-1;
int narrator=0;
--- 959,962 ----
***************
*** 973,977 ****
t--;
}
! subLine(&line, ¤tName, 0, (t-line.buf+1));
}
--- 970,976 ----
t--;
}
! if ( subLine(&line, ¤tName, 0, (t-line.buf+1)) != 0 ) {
! PARE_BAD_MEM_FAILURE(logh, int, -1);
! }
}
***************
*** 1013,1017 ****
gt=lc;
! subLine(&line, &characterName, (lt+1-line.buf), (gt-lt-1));
/*PAR_DEBUG1(logh, "character info:'%s'", characterName.buf);*/
--- 1012,1018 ----
gt=lc;
! if ( subLine(&line, &characterName, (lt+1-line.buf), (gt-lt-1)) != 0 ) {
! PARE_BAD_MEM_FAILURE(logh, int, -1);
! }
/*PAR_DEBUG1(logh, "character info:'%s'", characterName.buf);*/
***************
*** 1030,1034 ****
}
*gt=')';
! subLine(&characterName, &characterNameAka, (aka-characterName.buf), (gt-aka));
/*PAR_DEBUG1(logh, "character aka info:'%s'", characterNameAka.buf);*/
deleteChars(&characterName, (lt-characterName.buf-1), (gt-lt+2));
--- 1031,1037 ----
}
*gt=')';
! if ( subLine(&characterName, &characterNameAka, (aka-characterName.buf), (gt-aka)) != 0 ){
! PARE_BAD_MEM_FAILURE(logh, int, -1);
! }
/*PAR_DEBUG1(logh, "character aka info:'%s'", characterNameAka.buf);*/
deleteChars(&characterName, (lt-characterName.buf-1), (gt-lt+2));
***************
*** 1080,1223 ****
}
- #if 0
- /* whats left is movie and date and type info */
- if ( *(line.buf+line.used-1) == ')' ) {
- char *st=strrchr(line.buf, '(');
- if ( st == NULL ) {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number, "mismatched paren");
- continue;
- }
- else {
- char *c;
- for (c=st-1; isspace(*st) ; c--) {
- /* empty */
- }
- line.used=c-line.buf;
- line.buf[line.used]='\0';
- }
-
- if ( strcmp(st, "(TV)") == 0) {
- type=isTVMovie;
- }
- else if ( strcmp(st, "(mini)") == 0) {
- type=isTVMiniSeries;
- }
- else if ( strcmp(st, "(V)") == 0 ) {
- type=isVideoMovie;
- }
- else if ( strcmp(st, "(VG)") == 0 ) {
- type=isVideoGame;
- }
- else {
- type=isMovie;
- year=st;
- }
- }
- if ( year == NULL ) {
- char *st=strrchr(line.buf, '(');
- if ( st == NULL ) {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number, "missing year");
- continue;
- }
- else {
- char *c;
- for (c=st-1; isspace(*st) ; c--) {
- /* empty */
- }
- line.used=c-line.buf;
- line.buf[line.used]='\0';
- }
- year=st;
- }
-
- /*dumpLine("Post-removal of ending () stuff", &line);*/
-
- /* @todo - pull off ending (year) */
- year++;
- *(year+strlen(year)-1)='\0';
-
- //fprintf(stderr, "year=%s\n", year);
- if ( strlen(year) > 4 ) {
- if ( (romanNumberalsInYear=strrchr(year, '/')) != NULL ) {
- /* remember roman numberals may follow year */
- *romanNumberalsInYear++='\0';
- yearNumber=atoi(year);
- }
- }
- if ( strlen(year) == 4 ) {
- if ( strcmp(year, "????") == 0 ) {
- yearNumber=0;
- }
- else if ( isdigit(year[0]) &&
- isdigit(year[1]) &&
- isdigit(year[2]) &&
- isdigit(year[3]) ) {
- yearNumber=atoi(year);
- }
- else {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "unable to decode year from entry");
- continue;
- }
- }
- else {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "unable to decode year from entry");
- continue;
- }
-
- /* remove double quotes from tv show/movies */
- if ( line.buf[0] == '"' && *(line.buf+line.used-1) == '\"' ) {
- /*dumpLine("had leading/ending \"", &line);*/
- deleteChars(&line, 0, 1);
- deleteChars(&line, line.used-1, 1);
- switch(type) {
- case isTVMiniSeries:
- /* leave as is */
- break;
- case isMovie:
- /* switch to tvseries from default */
- type=isTVSeries;
- break;
- case isTVSeries:
- case isTVMovie:
- case isVideoMovie:
- case isVideoGame:
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "movie type %d looks like it also is a tv show ?");
- continue;
- break;
- }
- }
- else {
- if ( type == isTVMiniSeries ) {
- PARE_FORMAT_ERROR_F(logh, pathname, line.number,
- "mini series that doesn't look like it was made for tv ?");
- }
- }
-
- /** add in stats :) */
- switch(type) {
- case isTVMiniSeries:
- movieStats->numTVMiniSeries++;
- break;
- case isMovie:
- movieStats->numMovie++;
- break;
- case isTVSeries:
- movieStats->numTVSeries++;
- break;
- case isTVMovie:
- movieStats->numTVMovie++;
- break;
- case isVideoMovie:
- movieStats->numVideoMovie++;
- break;
- case isVideoGame:
- movieStats->numVideoGame++;
- break;
- }
- #endif
-
//fprintf(stderr, "%d: %s\n", line.number, line.buf);
count++;
--- 1083,1086 ----
***************
*** 1333,1344 ****
PARE_LIST_FILE_MISSING_FINAL_SEPARATOR_FAILURE(logh, pathname, "line starting with '-------'", int, -1);
}
-
- fprintf(stderr, "%d,%d,%d,%d,%d,%d\n",
- movieStats->numTVMiniSeries,
- movieStats->numMovie,
- movieStats->numTVSeries,
- movieStats->numTVMovie,
- movieStats->numVideoMovie,
- movieStats->numVideoGame);
PAR_SUCCESS(logh, int, 0);
--- 1196,1199 ----
|
|
From: Jerry V. <jve...@us...> - 2003-08-17 16:41:04
|
Update of /cvsroot/libimdb/libimdb/demo/dumpMovies
In directory sc8-pr-cvs1:/tmp/cvs-serv24433
Modified Files:
main.c
Log Message:
minor debugging added
Index: main.c
===================================================================
RCS file: /cvsroot/libimdb/libimdb/demo/dumpMovies/main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** main.c 16 Jun 2003 04:18:37 -0000 1.1
--- main.c 17 Aug 2003 16:41:02 -0000 1.2
***************
*** 25,36 ****
case LIST_DIRECTORS: {
const struct DirectorInList_s *data=entry;
! /*fprintf(stdout, "%d:%s type=%d, title=%s (%04d)\n", data->number, data->name, data->movieType,
! data->movieTitle, data->movieYear);*/
break;
}
case LIST_ACTORS: {
const struct ActorInList_s *data=entry;
! /*fprintf(stdout, "%d:%s type=%d, title=%s (%04d)\n", data->number, data->name, data->movieType,
! data->movieTitle, data->movieYear);*/
break;
}
--- 25,36 ----
case LIST_DIRECTORS: {
const struct DirectorInList_s *data=entry;
! /*fprintf(stdout, "%d:%s movieLabel=%s\n", data->number, data->name, data->movieLabel);*/
break;
}
case LIST_ACTORS: {
const struct ActorInList_s *data=entry;
! if ( data->number % 100000 == 0 ) {
! /*fprintf(stdout, "%d:%s movieLabel=%s\n", data->number, data->name, data->movieLabel);*/
! }
break;
}
|
|
From: Jerry V. <jve...@us...> - 2003-08-17 16:40:06
|
Update of /cvsroot/libimdb/libimdb
In directory sc8-pr-cvs1:/tmp/cvs-serv24248
Modified Files:
TODO
Log Message:
added...removed...
Index: TODO
===================================================================
RCS file: /cvsroot/libimdb/libimdb/TODO,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TODO 16 Jun 2003 04:49:19 -0000 1.2
--- TODO 17 Aug 2003 16:40:04 -0000 1.3
***************
*** 1,5 ****
This file contains random thoughts and on-going todo lists over
! the span of prototyping this stupid project the last couple
of months. Most of which either won't make any sense or
is beyond the scope of this project trying to figure out
--- 1,5 ----
This file contains random thoughts and on-going todo lists over
! the span of prototyping this project the last couple
of months. Most of which either won't make any sense or
is beyond the scope of this project trying to figure out
***************
*** 58,61 ****
--- 58,63 ----
libjlog
+ - optional compile time in/out features
+
- main log_open should initialize default
logtracker and logtee from env variables
***************
*** 71,77 ****
modules supported ? Would require that
enum gets initialized though.
! - one enum should alwyas be MOD_OKAY=0
! - completely separate tree for jvlog ?
- can success/failure callback be combined
--- 73,79 ----
modules supported ? Would require that
enum gets initialized though.
! - one enum should always be MOD_OKAY=0
! - completely separate tree for jlog ?
- can success/failure callback be combined
***************
*** 81,86 ****
- LOGerror_e should become LOGvalues_e
! and include LOG_SUCCESS=0, enum values should be negative
! for error
- how can we get gcc to check __attribute()__ stuff ?
--- 83,88 ----
- LOGerror_e should become LOGvalues_e
! and include LOG_SUCCESS=0, enum value initializers
! should be negative for error
- how can we get gcc to check __attribute()__ stuff ?
***************
*** 108,111 ****
--- 110,115 ----
Utility for downloading/managing ftp list files
+ - could just check to see what tv_imdb does now
+ - give Ed credit for this code.
What is this thing for ?
***************
*** 113,117 ****
- look at what Scott did for mysql loading.
! - look at xmltv2db on sf for a basic example of
putting data into jdbc database - now sure how useful this is.
--- 117,121 ----
- look at what Scott did for mysql loading.
! - look at building a imdb2db on sf for a basic example of
putting data into jdbc database - now sure how useful this is.
***************
*** 120,123 ****
--- 124,129 ----
- can probably just include it.
+ - test harness could validate findings with moviedb-3.21 results
+
- need bigger picture plan... what is libimdb ?
- for use with tv_imdb ?
***************
*** 173,174 ****
--- 179,193 ----
for queries ?
perl use Soap::Lite package (www.soaplite.com)
+
+ Dealing with format errors etc
+ ------------------------------
+ How do we deal with list files whose format it wrong ?
+ - may want to certify list files (filename:checksum)
+ - movie labels (name qualifiers etc) that are to be dropped
+ because of these kinds of problems.
+ - only fixes problems with movie labels.
+
+ - could just public file:line numbers to ignore.
+ - dynamically load exceptions file ?
+
+ </end>
|
|
From: Jerry V. <jve...@us...> - 2003-08-16 23:51:47
|
Update of /cvsroot/libimdb/libimdb In directory sc8-pr-cvs1:/tmp/cvs-serv18154 Modified Files: README Log Message: spelling errors Index: README =================================================================== RCS file: /cvsroot/libimdb/libimdb/README,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README 16 Jun 2003 04:43:03 -0000 1.2 --- README 16 Aug 2003 23:51:44 -0000 1.3 *************** *** 1,10 **** # $Id$ ! The first this you need to know is this project is currently in pre-Alpha stages. The build environment is still under construction. You'll also probably be missing pieces like the correct version of swig etc. I'm currently developing ! under RH 9, so you'll have better luck if that's where ! you are. You'll need SWIG Version 1.3.19 --- 1,9 ---- # $Id$ ! The first thing you need to know is this project is currently in pre-Alpha stages. The build environment is still under construction. You'll also probably be missing pieces like the correct version of swig etc. I'm currently developing ! under RH 9, so you'll have better luck if that's where you are. You'll need SWIG Version 1.3.19 |
|
From: Jerry V. <jve...@us...> - 2003-08-16 21:16:56
|
Update of /cvsroot/libimdb/web In directory sc8-pr-cvs1:/tmp/cvs-serv29157 Modified Files: generate.pl Log Message: xmltv -> XMLTV Index: generate.pl =================================================================== RCS file: /cvsroot/libimdb/web/generate.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** generate.pl 16 Aug 2003 21:12:02 -0000 1.2 --- generate.pl 16 Aug 2003 21:12:58 -0000 1.3 *************** *** 112,116 **** <p>History: The need for this project has really grown out of the tv_imdb filter written for ! <a href="http:://sourceforge.net/projects/xmltv">xmltv</a>. This perl script preprocessors a subset of the imdb list files, creates a couple of simple flat file indexes, which are then used to augment tv listing data with information from imdb. As more users started --- 112,116 ---- <p>History: The need for this project has really grown out of the tv_imdb filter written for ! <a href="http:://sourceforge.net/projects/xmltv">XMLTV</a>. This perl script preprocessors a subset of the imdb list files, creates a couple of simple flat file indexes, which are then used to augment tv listing data with information from imdb. As more users started |
|
From: Jerry V. <jve...@us...> - 2003-08-16 21:15:50
|
Update of /cvsroot/libimdb/web In directory sc8-pr-cvs1:/tmp/cvs-serv29835 Modified Files: generate.pl Log Message: fixed url Index: generate.pl =================================================================== RCS file: /cvsroot/libimdb/web/generate.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** generate.pl 16 Aug 2003 21:12:58 -0000 1.3 --- generate.pl 16 Aug 2003 21:15:35 -0000 1.4 *************** *** 112,116 **** <p>History: The need for this project has really grown out of the tv_imdb filter written for ! <a href="http:://sourceforge.net/projects/xmltv">XMLTV</a>. This perl script preprocessors a subset of the imdb list files, creates a couple of simple flat file indexes, which are then used to augment tv listing data with information from imdb. As more users started --- 112,116 ---- <p>History: The need for this project has really grown out of the tv_imdb filter written for ! <a href="http://sourceforge.net/projects/xmltv">XMLTV</a>. This perl script preprocessors a subset of the imdb list files, creates a couple of simple flat file indexes, which are then used to augment tv listing data with information from imdb. As more users started |
|
From: Jerry V. <jve...@us...> - 2003-08-16 21:15:00
|
Update of /cvsroot/libimdb/web
In directory sc8-pr-cvs1:/tmp/cvs-serv28996
Modified Files:
generate.pl
Log Message:
added about and news for beta release coming
Index: generate.pl
===================================================================
RCS file: /cvsroot/libimdb/web/generate.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** generate.pl 16 Jun 2003 03:43:41 -0000 1.1
--- generate.pl 16 Aug 2003 21:12:02 -0000 1.2
***************
*** 84,88 ****
<dd>Wim Mortier's <a href="http://home.planetinternet.be/%7Eic521102/">SyncIMDB</a></dd>
<dd>Thorsten M. Wahl's <a href="http://www.amdbfront.com/">AMDbFront and JMDb</a></dd>
- </dt>
</dl>
!;
--- 84,87 ----
***************
*** 109,113 ****
<a name="about"></a>
<h2>About LibIMDB</h2>
! <p>Not sure what we want here yet.</p>
|;
--- 108,128 ----
<a name="about"></a>
<h2>About LibIMDB</h2>
! <p>The LibIMDB Project is about creating useful, and hopefully simple
! interfaces to the contents of imdb plain-text files.</p>
!
! <p>History: The need for this project has really grown out of the tv_imdb filter written for
! <a href="http:://sourceforge.net/projects/xmltv">xmltv</a>. This perl script preprocessors
! a subset of the imdb list files, creates a couple of simple flat file indexes, which are
! then used to augment tv listing data with information from imdb. As more users started
! using tv_imdb, the more apparent it was that its scalability in its current design was limited.
! We quickly found that there were a lot of projects that used imdb data, but almost all
! scraped the data by querying and parsing html from the imdb web site. This was not an option
! for a program like tv_imdb which likes doing its own fuzzy title searches and whose users
! would easily kill the imdb site with so many queries. There are a handful of projects
! that were closer to what we needed, but none shared source nor provide the level of
! interfacing we required. So LibIMDB was started, spun as a separate project from tv_imdb
! to allow others to benefit from our effort.</p>
! <br>
! <p>
|;
***************
*** 116,119 ****
--- 131,143 ----
<h2>News</h2>
<p>Beta release is coming...</p>
+ <dl>
+ <dt>The first beta release (sometime in the fall) will include:</dt>
+ <dd>1. linux only (others planed)</dd>
+ <dd>2. dynamic and static libraries</dd>
+ <dd>3. a minimal set of demonstration programs (written in C)</dd>
+ <dd>4. beta release of a java interface (using jni via swig)</dd>
+ <dd>5. support for parsing the actors, actresses and directors list files.</dd>
+ <dd>6. basic parsing error reporting and recovery</dd>
+ </dl>
|;
***************
*** 129,133 ****
<h2>Support</h2>
<p>The best way to get support is to subscribe and submit a question to one of the mailing lists.</p>
! <p>Try looking <a href="http://sourceforge.net/mail/?group_id=@@SOURCEFORGE_GROUP_ID@@">here</a>.</p
|;
--- 153,157 ----
<h2>Support</h2>
<p>The best way to get support is to subscribe and submit a question to one of the mailing lists.</p>
! <p>Try looking <a href="http://sourceforge.net/mail/?group_id=@@SOURCEFORGE_GROUP_ID@@">here</a>.</p>
|;
***************
*** 135,140 ****
<a name="apidocs"></a>
<h2>Api Documentation</h2>
! <p>There will probably be a couple of api layers to use.</p>
! <p>coming soon...</p
|;
--- 159,164 ----
<a name="apidocs"></a>
<h2>Api Documentation</h2>
! <p>There will probably be a couple of apis to choose from. Initial plans are for a C level,
! a JNI (java) interface and possibly (given time) a perl package.</p>
|;
|
|
From: Jerry V. <jve...@us...> - 2003-08-16 21:14:12
|
Update of /cvsroot/libimdb/web In directory sc8-pr-cvs1:/tmp/cvs-serv29607 Modified Files: Makefile Log Message: fixed install/test-install Index: Makefile =================================================================== RCS file: /cvsroot/libimdb/web/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Makefile 16 Jun 2003 03:57:50 -0000 1.1 --- Makefile 16 Aug 2003 21:14:10 -0000 1.2 *************** *** 8,14 **** ./generate.pl test_install ! install: rm -rf /home/groups/l/li/libimdb/htdocs/test_install mkdir /home/groups/l/li/libimdb/htdocs/test_install ./generate.pl /home/groups/l/li/libimdb/htdocs/test_install --- 8,19 ---- ./generate.pl test_install ! test-install: rm -rf /home/groups/l/li/libimdb/htdocs/test_install mkdir /home/groups/l/li/libimdb/htdocs/test_install ./generate.pl /home/groups/l/li/libimdb/htdocs/test_install + + install: + rm -rf /home/groups/l/li/libimdb/htdocs + mkdir /home/groups/l/li/libimdb/htdocs + ./generate.pl /home/groups/l/li/libimdb/htdocs |
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:49:21
|
Update of /cvsroot/libimdb/libimdb
In directory sc8-pr-cvs1:/tmp/cvs-serv17167
Modified Files:
TODO
Log Message:
added some
Index: TODO
===================================================================
RCS file: /cvsroot/libimdb/libimdb/TODO,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TODO 16 Jun 2003 04:43:03 -0000 1.1
--- TODO 16 Jun 2003 04:49:19 -0000 1.2
***************
*** 1,8 ****
Short list to get things out.
! - build env
! - roll out c library
! - roll out beta java interface
! - simple web page and setup of cvs, mailing lists etc.
- will want to use something like mpatrol to assess what
the memory requirements are for different parts of the
--- 1,16 ----
+ This file contains random thoughts and on-going todo lists over
+ the span of prototyping this stupid project the last couple
+ of months. Most of which either won't make any sense or
+ is beyond the scope of this project trying to figure out
+ why I'm building this beast.
+
Short list to get things out.
! - build env clean up
! - roll out basic c interface (imdbParser)
! - create api docs via doxygen
! - post to web
! - roll out beta java interface - may require some reworking
! of current prototype
- will want to use something like mpatrol to assess what
the memory requirements are for different parts of the
***************
*** 22,26 ****
-----------------
! Since movie lables are the key to the database, maybe a temperary
(option) on-disk db database to hold the movie info and rest of
them return references to entries via a movie key. The user does
--- 30,34 ----
-----------------
! Since movie labels are the key to the database, maybe a temperary
(option) on-disk db database to hold the movie info and rest of
them return references to entries via a movie key. The user does
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:43:06
|
Update of /cvsroot/libimdb/libimdb
In directory sc8-pr-cvs1:/tmp/cvs-serv16121
Modified Files:
README
Added Files:
TODO
Log Message:
moved to TODO, new README in place
--- NEW FILE: TODO ---
Short list to get things out.
- build env
- roll out c library
- roll out beta java interface
- simple web page and setup of cvs, mailing lists etc.
- will want to use something like mpatrol to assess what
the memory requirements are for different parts of the
library.
- need to version things.
libimdb_getVersion();
libimdb_getListFileInfo(); ??
- is it easy to convert lfetch to a c program ?
libimdb_updateListFile();
- look at perl script to just get list files
- look at perl script to get and merge list diff files.
Things to be done
-----------------
Since movie lables are the key to the database, maybe a temperary
(option) on-disk db database to hold the movie info and rest of
them return references to entries via a movie key. The user does
a second set of lookups when the movie detail is needed. Making
it optional means not paying the disk price and instead paying
the memory price. (may also just be a runtime optional though,
since we may want to use an in-memory db still - this could be
substituted for a non-db solution later).
Guess that means we may need to lookup movies by key, but also
generate a list of movie label based results when searching by
title. This may require a second pass over the movie database.
Need to take a closer look at all the list file to assess if
this is the best strategy.
Simpler scan actor db one at a time - callbacks get a single actors
and multiple movie keys (and char info).
perl interface and callback using swig'd interface
- build simple example and look for help via
perl5 book and swig mailing list.
- support callback or first/next... processing ?
- first/next might be just simpler for perl
- probably pretty easy to support both.
libjlog
- main log_open should initialize default
logtracker and logtee from env variables
- do we want this to happen every log_open ?
- yes
- how do we define filters ?
- file/func filters
- in/out filters
- regexp ?
- config file
- can mklog.pl generate/manage the list of
modules supported ? Would require that
enum gets initialized though.
- one enum should alwyas be MOD_OKAY=0
- completely separate tree for jvlog ?
- can success/failure callback be combined
with current callback mechanism ?
- support success call from void function
- LOGerror_e should become LOGvalues_e
and include LOG_SUCCESS=0, enum values should be negative
for error
- how can we get gcc to check __attribute()__ stuff ?
nuke build environment and re-write.
- use simple gmake makefiles that need to be
massaged to work....
- could have basic configure at the top.
- swig generation should be separate target and
not part of normal build.
- change name of .javaswig file to not specify
packaging, explicit move command and rmdir
with warnings if files end up lying around
- cvs ci should include java generated c etc.
- can I or should I use sysinclude.h ?
- probably don't need it... would need to test port to
cygwin for compiling into a dll.
- clean up in order - remove NATIVE_WINDOWS
Utility for downloading/managing ftp list files
What is this thing for ?
------------------------
- look at what Scott did for mysql loading.
- look at xmltv2db on sf for a basic example of
putting data into jdbc database - now sure how useful this is.
- support gzip'd list files.
- www.gzip.org/zlib
- can probably just include it.
- need bigger picture plan... what is libimdb ?
- for use with tv_imdb ?
- maybe tv_imdb just uses a libimdb database
- libimdb's own database could just be a
series of text files in sorted key order.
then use look to locate things.
- perl interface kept simple, while libimdb
could use binary search algorithm.
- still doesn't require mysql and is platform
independent.
- what other db options are out there ? gdbm ?
- nothing to say we can't use dynamic libimdb.so
for searching, provide a generic interface
that includes what you want for tv_imdb
Then just have java and a perl interface.
- guess a perl script is the easies to load
things into mysql ?
- xml output of db entry (probably useful for
debugging as well).
- xmlrpc ? what is it, is it useful here ?
- linux and windows supported ?
- load imdb data into hsqldb / mysqldb
- how do we standardize on db tables ?
- how do you look flexible ?
- interface must support db clean, load
- way in the future what can we do about doing
minimal updates ? Can we only update the table
entries that changed since the last fresh build ?
Maybe the parse should support an update
operation ? How do we identify things that have
to be removed ? Can we ? Maybe intermediate db
(flat sorted index) and a compare or refresh mysql
utility.
- query data
- do all of this from java and perl
- can I build a java centric database loader (int hsqldb ?)
- what kind of progress bars are in java ?
- JFreeChart to plot things ?
- number of actors / movie
- years of movies ?
- present stats generated from loader ?
- actors to actresses totals
- movie ratings (user rated) against years
- what about a imdb server that has XML-RPC interfaces
for queries ?
perl use Soap::Lite package (www.soaplite.com)
Index: README
===================================================================
RCS file: /cvsroot/libimdb/libimdb/README,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** README 16 Jun 2003 04:18:37 -0000 1.1
--- README 16 Jun 2003 04:43:03 -0000 1.2
***************
*** 1,169 ****
! Short list to get things out.
! - build env
! - roll out c library
! - roll out beta java interface
! - simple web page and setup of cvs, mailing lists etc.
! - will want to use something like mpatrol to assess what
! the memory requirements are for different parts of the
! library.
! - need to version things.
! libimdb_getVersion();
!
! libimdb_getListFileInfo(); ??
!
! - is it easy to convert lfetch to a c program ?
! libimdb_updateListFile();
!
! - look at perl script to just get list files
! - look at perl script to get and merge list diff files.
!
! Things to be done
! -----------------
!
! Since movie lables are the key to the database, maybe a temperary
! (option) on-disk db database to hold the movie info and rest of
! them return references to entries via a movie key. The user does
! a second set of lookups when the movie detail is needed. Making
! it optional means not paying the disk price and instead paying
! the memory price. (may also just be a runtime optional though,
! since we may want to use an in-memory db still - this could be
! substituted for a non-db solution later).
!
! Guess that means we may need to lookup movies by key, but also
! generate a list of movie label based results when searching by
! title. This may require a second pass over the movie database.
!
! Need to take a closer look at all the list file to assess if
! this is the best strategy.
!
! Simpler scan actor db one at a time - callbacks get a single actors
! and multiple movie keys (and char info).
!
! perl interface and callback using swig'd interface
! - build simple example and look for help via
! perl5 book and swig mailing list.
!
! - support callback or first/next... processing ?
! - first/next might be just simpler for perl
! - probably pretty easy to support both.
!
! libjlog
! - main log_open should initialize default
! logtracker and logtee from env variables
! - do we want this to happen every log_open ?
! - yes
! - how do we define filters ?
! - file/func filters
! - in/out filters
! - regexp ?
! - config file
!
! - can mklog.pl generate/manage the list of
! modules supported ? Would require that
! enum gets initialized though.
! - one enum should alwyas be MOD_OKAY=0
!
! - completely separate tree for jvlog ?
!
! - can success/failure callback be combined
! with current callback mechanism ?
!
! - support success call from void function
!
! - LOGerror_e should become LOGvalues_e
! and include LOG_SUCCESS=0, enum values should be negative
! for error
!
! - how can we get gcc to check __attribute()__ stuff ?
!
! nuke build environment and re-write.
!
! - use simple gmake makefiles that need to be
! massaged to work....
!
! - could have basic configure at the top.
!
! - swig generation should be separate target and
! not part of normal build.
! - change name of .javaswig file to not specify
! packaging, explicit move command and rmdir
! with warnings if files end up lying around
!
! - cvs ci should include java generated c etc.
!
! - can I or should I use sysinclude.h ?
! - probably don't need it... would need to test port to
! cygwin for compiling into a dll.
!
! - can probably keep it if I get rid of Precise/Invidi
! related bits (NATIVE_WINDOWS)
! (switch if !defined(NATIVE_WINDOWS) to if defined(LINUX))
! etc.
!
! Utility for downloading/managing ftp list files
!
! What is this thing for ?
! ------------------------
! - look at what Scott did for mysql loading.
!
! - look at xmltv2db on sf for a basic example of
! putting data into jdbc database - now sure how useful this is.
!
! - support gzip'd list files.
! - www.gzip.org/zlib
! - can probably just include it.
!
! - need bigger picture plan... what is libimdb ?
! - for use with tv_imdb ?
! - maybe tv_imdb just uses a libimdb database
! - libimdb's own database could just be a
! series of text files in sorted key order.
! then use look to locate things.
! - perl interface kept simple, while libimdb
! could use binary search algorithm.
! - still doesn't require mysql and is platform
! independent.
! - what other db options are out there ? gdbm ?
! - nothing to say we can't use dynamic libimdb.so
! for searching, provide a generic interface
! that includes what you want for tv_imdb
! Then just have java and a perl interface.
!
! - guess a perl script is the easies to load
! things into mysql ?
!
! - xml output of db entry (probably useful for
! debugging as well).
!
! - xmlrpc ? what is it, is it useful here ?
!
! - linux and windows supported ?
! - load imdb data into hsqldb / mysqldb
! - how do we standardize on db tables ?
! - how do you look flexible ?
! - interface must support db clean, load
! - way in the future what can we do about doing
! minimal updates ? Can we only update the table
! entries that changed since the last fresh build ?
! Maybe the parse should support an update
! operation ? How do we identify things that have
! to be removed ? Can we ? Maybe intermediate db
! (flat sorted index) and a compare or refresh mysql
! utility.
! - query data
! - do all of this from java and perl
! - can I build a java centric database loader (int hsqldb ?)
! - what kind of progress bars are in java ?
! - JFreeChart to plot things ?
! - number of actors / movie
! - years of movies ?
! - present stats generated from loader ?
! - actors to actresses totals
! - movie ratings (user rated) against years
! - what about a imdb server that has XML-RPC interfaces
! for queries ?
! perl use Soap::Lite package (www.soaplite.com)
--- 1,19 ----
+ # $Id$
! The first this you need to know is this project is currently
! in pre-Alpha stages. The build environment is still under
! construction. You'll also probably be missing pieces like
! the correct version of swig etc. I'm currently developing
! under RH 9, so you'll have better luck if that's where
! you are.
! You'll need SWIG Version 1.3.19
! current status
! - the jlog library works okay
! - the parser library works (imdbDict.c will be changing alot)
! - the java classes basically work
! - the perl test code is completely broken.
! - everything else is a crap shoot.
! jerry
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:37:14
|
Update of /cvsroot/libimdb/libimdb/perl
In directory sc8-pr-cvs1:/tmp/cvs-serv15088
Added Files:
Log.perlswig Makefile test.pl
Log Message:
initial checkin
--- NEW FILE: Log.perlswig ---
%{
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_STDARG
#define _USE_TYPES
#define _USE_STRINGS
#define _USE_ASSERT
#include "sysincludes.h"
#include "log/log.h"
%}
%include "typemaps.i"
%include "../../include/mytypemaps.i"
%typemap(jni) logHandle_t * "jlong"
%typemap(jtype) logHandle_t * "long"
%typemap(jstype) logHandle_t * "org.libimdb.swig.Log"
%typemap(javain) logHandle_t * "org.libimdb.swig.Log.getCPtr($javainput)"
%typemap(javaout) logHandle_t * {return new org.libimdb.swig.Log($jnicall);}
@todo - write perl specific entry points that it easier to use from
perl (or write swig code).
ie: log_getMessageDetails could return a char **, then write
a perl module that decodes each entry into a perl object :)
Could look at perl C interface to determine if you can send an
array back with different types in it.... pain probably.
@todo - need to investigate calling a method on a perl object from C..
May be hard to find a decent example, but again could call back
with an array of strings instead. Could try and submit a
minimal example to the swig mailing list and ask for help.
%include "../../include/log/log.h"
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:37:11 jveldhuis Exp $
#
include ../config.mk
include ../constants.mk
CPPFLAGS += -I../include -I$(PERL_INCLUDE)
CFLAGS:=-g
LIBS= ../parser/$(BUILD_DIR)/libimdbParser.a \
../liblog/$(BUILD_DIR)/liblog.a
SWIG_MODULE=Log
LIB_BASE = Log
LIB_VERSION = 1.0
build:
$(MAKE) $(MYDYNAMIC) DYNAMIC=$(MYDYNAMIC)
install:; @true;
test:
LD_LIBRARY_PATH=bdir-LINUX ./test.pl
include ../rules.mk
--- NEW FILE: test.pl ---
#!/usr/bin/perl -w
use strict;
use lib 'gen_LINUX';
use Log;
my $log = Log::log_openMain(undef, "test.pl", "main", 7);
print "".Log::log_getModuleShortNames($log)."\n";
print "".$log."\n";
exit 0;
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:36:43
|
Update of /cvsroot/libimdb/libimdb/perl In directory sc8-pr-cvs1:/tmp/cvs-serv14996/perl Log Message: Directory /cvsroot/libimdb/libimdb/perl added to the repository |
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/java
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/java
Added Files:
JLog.swig JLog_jni.c JLog_jni.h Makefile Parser.swig
Parser_jni.c Parser_jni.h bytetypemaps.i inttypemaps.i
javahead.c longtypemaps.i mytypemaps.i
Log Message:
initial checkin
--- NEW FILE: JLog.swig ---
%{
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_STDARG
#define _USE_TYPES
#define _USE_STRINGS
#define _USE_ASSERT
#include "sysincludes.h"
#include "jlog/jlog.h"
#include "JLog_jni.h"
%}
%include "typemaps.i"
%include "mytypemaps.i"
#ifdef SWIGJAVA
%typemap(in, numinputs=0) (JNIEnv *env) %{ $1=jenv; %}
%typemap(in, numinputs=0) (jclass clazz) %{ $1=jcls; %}
#endif
%typemap(jni) JLog_t * "jlong"
%typemap(jtype) JLog_t * "long"
%typemap(jstype) JLog_t * "org.libimdb.swig.JLog"
%typemap(javain) JLog_t * "org.libimdb.swig.JLog.getCPtr($javainput)"
%typemap(javaout) JLog_t * {return new org.libimdb.swig.JLog($jnicall);}
%include "JLog_jni.h"
--- NEW FILE: JLog_jni.c ---
/**
* @file
*
* The functions here are provide a wrapper for jlogHandle functions.
*
* @verbatim $Id: JLog_jni.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
static char rcs_id[] = "$Id: JLog_jni.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ASSERT
#define _USE_MALLOC
#include "sysincludes.h"
#include "jlog/jlog.h"
#include <jni.h>
#include "JLog_jni.h"
struct JLog_s {
JNIEnv *env;
jmethodID jmethod_jcb;
jobject jobj;
jlogHandle_t *logh;
jlogCallbackHandle_t *jlog_cb;
};
static void
jlog_eventCallback(jlogHandle_t *logh, const char *srcfile, const char *srcfunc,
int srcline, jlogModule_e module, jlogReportLevel_e jlogReportLevel,
int messageNumber, const char *messageText, void *cb_userdata)
{
JLog_t *jl=cb_userdata;
(*(jl->env))->CallIntMethod(jl->env, jl->jobj, jl->jmethod_jcb,
(*(jl->env))->NewStringUTF(jl->env, srcfile),
(*(jl->env))->NewStringUTF(jl->env, srcfunc),
srcline, (int)module,(int)jlogReportLevel,
messageNumber,
(*(jl->env))->NewStringUTF(jl->env, messageText));
}
JLog_t *
JLog_create(void)
{
JLog_t *jl;
jl=malloc(sizeof(struct JLog_s));
if ( jl == NULL ) {
return(NULL);
}
jl->env=NULL;
jl->jmethod_jcb=0;
jl->jobj=NULL;
jl->logh=jlog_openNew();
jl->jlog_cb=jlogCallback_create(jlog_eventCallback, jl);
if ( jl->jlog_cb == NULL ) {
jlog_close(jl->logh);
free(jl);
return(NULL);
}
return(jl);
}
static int
JLog_init(JNIEnv *env,
JLog_t *jl,
jobject jobj)
{
jclass class;
/* may fail in malloc call */
if ( jlog_registerEventCallback(jl->logh, jl->jlog_cb) == -1 ) {
return(-1);
}
class=(*env)->GetObjectClass(env, jobj);
jl->env=env;
jl->jobj=jobj;
jl->jmethod_jcb=(*env)->GetMethodID(env, class,
"JLogMessage_cb",
"(Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;)I");
if ( jl->jmethod_jcb == 0 ) {
return(-1);
}
/* testing
jlog_eventCallback(jl->logh, __FILE__, __FUNC__,
__LINE__, MOD_ALL, JLOGT_CRITICAL,
1, "This is the test", jl);*/
return(0);
}
int
JLog_uninitialize(JLog_t *jl)
{
if ( jl->jmethod_jcb != 0 ) {
if ( jlog_unregisterEventCallback(jl->logh, jl->jlog_cb) != 0 ) {
abort();
}
jl->env=NULL;
jl->jobj=NULL;
jl->jmethod_jcb=0;
}
return(0);
}
jlogHandle_t *
JLog_jlog(JLog_t *j)
{
assert(j!=NULL);
return(j->logh);
}
JLog_t *
JLog_initialize(JNIEnv *env,
jobject jobj)
{
jmethodID jcb;
jclass class;
jlong r;
JLog_t *jl;
class=(*env)->GetObjectClass(env, jobj);
jcb=(*env)->GetStaticMethodID(env, class,
"getCPtr",
"(Lorg/libimdb/swig/JLog;)J");
if ( jcb == 0 ) {
/*PAR_FAILURE(NULL, jlogHandle_t *, NULL); */
return(NULL);
}
r=(*env)->CallStaticLongMethod(env, class, jcb, jobj, 0);
if ( r == 0 ) {
/*PAR_FAILURE(NULL, jlogHandle_t *, NULL); */
return(NULL);
}
jl=*(JLog_t **)&r;
if ( JLog_init(env, jl, jobj) != 0 ) {
return(NULL);
}
return(jl);
}
int
JLog_destroy(JLog_t *jl)
{
if ( jl == NULL ) {
return(-1);
}
if ( jl->jmethod_jcb != 0 ) {
JLog_uninitialize(jl);
}
jlogCallback_destroy(jl->jlog_cb);
if ( jlog_close(jl->logh) != 0 ) {
abort();
}
free(jl);
return(0);
}
int
JLog_setNotificationLevel(JLog_t *jl,
JLogReportLevel_e level)
{
jlogReportLevel_e jlogRL=-1;
switch(level) {
case JLOG_DEBUG:
jlogRL=JLOGT_DEBUG;
break;
case JLOG_ERROR:
jlogRL=JLOGT_ERROR;
break;
case JLOG_CRITICAL:
jlogRL=JLOGT_CRITICAL;
break;
}
if ( jlogRL == -1 ) {
abort();
}
return(jlogCallback_setNotificationLevel(jl->jlog_cb, MOD_ALL, jlogRL));
}
--- NEW FILE: JLog_jni.h ---
/**
@file
Shared include with both JLog.swig and JLog_jni.c
(ensures consistancy)
@verbatim $Id: JLog_jni.h,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
#ifdef SWIGJAVA
%typemap(jni) (jobject jobj) "/*jni*/jobject"
%typemap(jtype) (jobject jobj) "/*jtype*/Object"
%typemap(jstype) (jobject jobj) "/*jstype*/Object"
%typemap(javain) (jobject jobj) %{/*javain*/$javainput%}
%typemap(in) (jobject jobj) %{ $1=jarg2; %}
%typemap(freearg) (jobject jobj) %{%}
%apply (jobject jobj) {(jobject jobj)};
#endif /* SWIGJAVA */
#ifndef SWIG
typedef struct JLog_s JLog_t;
#endif
JLog_t *
JLog_create(void);
#ifndef SWIG
JLog_t *
JLog_initialize(JNIEnv *env,
jobject jobj);
jlogHandle_t *
JLog_jlog(JLog_t *j);
int
JLog_uninitialize(JLog_t *jl);
#endif
int
JLog_destroy(JLog_t *jl);
#ifndef SWIG
/* look out of date
jlogHandle_t *
JLog_jlogHandle(JLog_t *jl);
*/
#endif
typedef enum {
JLOG_DEBUG=2, /**< debug message */
JLOG_ERROR=1, /**< error message */
JLOG_CRITICAL=0, /**< critical error message */
} JLogReportLevel_e;
int
JLog_setNotificationLevel(JLog_t *jl,
JLogReportLevel_e level);
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $
#
include ../config.mk
include ../constants.mk
LIB_BASE := imdbParser_java
LIB_VERSION :=1.0
LDFLAGS +=-L../libjlog/$(BUILD_CFG) -L../parser/$(BUILD_CFG)
LIBS =-limdbParser -ljlog
CFLAGS_DROP =-Wmissing-prototypes
CCFLAGS_DROP=-Wmissing-prototypes
CPPFLAGS += -DSWIG_NOINCLUDE -I. -I../include
GENERATED_FILES=gen_$(BUILD_OS)/JLog_swig.c gen_$(BUILD_OS)/Parser_swig.c
build: $(GENERATED_FILES)
$(MAKE) $(MYDYNAMIC) DYNAMIC=$(MYDYNAMIC) SRCS="$(SRCS) $(GENERATED_FILES)"
mkdir -p $(BUILD_CFG)
$(JAVAC) -d $(BUILD_CFG) $(JAVAC_FLAGS) -sourcepath org -classpath org `find org -name \*.java`
gen_$(BUILD_OS)/JLog_swig.c:
mkdir -p org/libimdb/swig/gen
swig -java -module JLog -Wall -I. -I../include \
-package org.libimdb.swig.gen \
-o org/libimdb/swig/gen/JLog_swig.c JLog.swig
mkdir -p gen_$(BUILD_OS)
mv org/libimdb/swig/gen/JLog_swig.c gen_$(BUILD_OS)/JLog_swig.c
gen_$(BUILD_OS)/Parser_swig.c:
mkdir -p org/libimdb/swig/gen
swig -java -module Parser -Wall -I. -I../include \
-package org.libimdb.swig.gen \
-o org/libimdb/swig/gen/Parser_swig.c Parser.swig
mkdir -p gen_$(BUILD_OS)
mv org/libimdb/swig/gen/Parser_swig.c gen_$(BUILD_OS)/Parser_swig.c
clobber::
$(RM) -rf $(BUILD_CFG) gen_$(OS)
$(RM) -rf org/libimdb/swig/gen
run:
LD_LIBRARY_PATH=$(BUILD_CFG):../parser/$(BUILD_CFG):../libjlog/$(BUILD_CFG):/usr/local/lib \
$(JAVA) -classpath $(BUILD_CFG) org.libimdb.swig.Parser
include ../rules.mk
--- NEW FILE: Parser.swig ---
%{
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_TYPES
#define _USE_STRINGS
#define _USE_ASSERT
#include "sysincludes.h"
#include "jlog/parerr.h"
#include "libimdb/parser.h"
#include "JLog_jni.h"
#include "Parser_jni.h"
%}
%pragma(java) jniclassclassmodifiers="public"
%include "typemaps.i"
%include "mytypemaps.i"
%include "inttypemaps.i"
%include "longtypemaps.i"
%include "bytetypemaps.i"
#ifdef SWIGJAVA
%typemap(in, numinputs=0) (JNIEnv *env) %{ $1=jenv; %}
%typemap(in, numinputs=0) (jclass clazz) %{ $1=jcls; %}
#endif
%typemap(jni) JLog_t * "jlong"
%typemap(jtype) JLog_t * "long"
%typemap(jstype) JLog_t * "org.libimdb.swig.JLog"
%typemap(javain) JLog_t * "org.libimdb.swig.JLog.getCPtr($javainput)"
%typemap(javaout) JLog_t * {return new org.libimdb.swig.JLog($jnicall);}
%typemap(jni) imdbParser_t * "jlong"
%typemap(jtype) imdbParser_t * "long"
%typemap(jstype) imdbParser_t * "org.libimdb.swig.Parser"
%typemap(javain) imdbParser_t * "org.libimdb.swig.Parser.getCPtr($javainput)"
%typemap(javaout) imdbParser_t * {return new org.libimdb.swig.Parser($jnicall);}
%include "Parser_jni.h"
--- NEW FILE: Parser_jni.c ---
/**
* @file
* The functions here are provide a wrapper for libimdb functions.
* They try and simplify the swig interface, provide jni callbacks
* into java for libimdb callbacks.
*
* @verbatim $Id: Parser_jni.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
static char rcs_id[] = "$Id: Parser_jni.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_IO
#define _USE_ASSERT
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_TYPES
#define _USE_CTYPE
#define _USE_MALLOC
#define _USE_LIMITS
#define _USE_TIME
#include "sysincludes.h"
#include "jlog/parerr.h"
#include "libimdb/parser.h"
#include <jni.h>
#include "JLog_jni.h"
#include "Parser_jni.h"
struct jniData_s {
JNIEnv *env;
jobject jparserobject;
jmethodID movieListEntry_jcb;
jmethodID directorListEntry_jcb;
jmethodID actorListEntry_jcb;
jmethodID actressListEntry_jcb;
jobject jprogressobject;
jmethodID progressStarting_jcb;
jmethodID progressUpdate_jcb;
jmethodID progressFinished_jcb;
};
static int
listentry_cb(jlogHandle_t *logh,
imdbParser_t *imdbh,
const ListFile_e lf,
const void *entry)
{
int r=-1;
struct jniData_s *jniData=imdbParser_getUserHandle(logh, imdbh);
switch(lf) {
case LIST_MOVIES:
{
const struct MovieInList_s *data=entry;
r=(*(jniData->env))->CallIntMethod(jniData->env,
jniData->jparserobject,
jniData->movieListEntry_jcb,
data->lineNumber,
data->number,
data->type,
(*(jniData->env))->NewStringUTF(jniData->env, data->title),
data->year);
}
break;
case LIST_DIRECTORS:
{
const struct DirectorInList_s *data=entry;
r=(*(jniData->env))->CallIntMethod(jniData->env,
jniData->jparserobject,
jniData->directorListEntry_jcb,
data->lineNumber,
data->number,
(*(jniData->env))->NewStringUTF(jniData->env, data->name),
(*(jniData->env))->NewStringUTF(jniData->env, data->movieLabel));
}
break;
case LIST_ACTORS:
{
const struct ActorInList_s *data=entry;
r=(*(jniData->env))->CallIntMethod(jniData->env,
jniData->jparserobject,
jniData->actorListEntry_jcb,
data->lineNumber,
data->number,
(*(jniData->env))->NewStringUTF(jniData->env, data->name),
data->billing,
data->isNarrator,
(*(jniData->env))->NewStringUTF(jniData->env, data->characterName),
(*(jniData->env))->NewStringUTF(jniData->env, data->characterNameAka),
(*(jniData->env))->NewStringUTF(jniData->env, data->movieLabel));
}
break;
case LIST_ACTRESSES:
{
const struct ActorInList_s *data=entry;
r=(*(jniData->env))->CallIntMethod(jniData->env,
jniData->jparserobject,
jniData->actressListEntry_jcb,
data->lineNumber,
data->number,
(*(jniData->env))->NewStringUTF(jniData->env, data->name),
data->billing,
data->isNarrator,
(*(jniData->env))->NewStringUTF(jniData->env, data->characterName),
(*(jniData->env))->NewStringUTF(jniData->env, data->characterNameAka),
(*(jniData->env))->NewStringUTF(jniData->env, data->movieLabel));
}
break;
}
return(r);
}
imdbParser_t *
imdbParser_create(JNIEnv *env,
jobject jlogobject,
char *dbsDir)
{
imdbParser_t *parser;
JLog_t *jl;
struct jniData_s *jniData;
jniData=malloc(sizeof(struct jniData_s));
if ( jniData == NULL ) {
return(NULL);
}
jl=JLog_initialize(env, jlogobject);
if ( jl == NULL ) {
free(jniData);
return(NULL);
}
parser=imdbParser_open(JLog_jlog(jl), dbsDir, listentry_cb);
imdbParser_setUserHandle(JLog_jlog(jl), parser, jniData);
JLog_uninitialize(jl);
return(parser);
}
static imdbParser_t *
getParserFromObject(JLog_t *jl,
JNIEnv *env,
jobject jparserobject)
{
jmethodID jcb;
jlong r;
jclass class=(*env)->GetObjectClass(env, jparserobject);
if ( (jcb=(*env)->GetStaticMethodID(env, class,
"getCPtr",
"(Lorg/libimdb/swig/Parser;)J"))==0 ) {
PARE_JNI_INVALID_OBJECT_FAILURE(JLog_jlog(jl), "org/libimdb/swig/Parser",
"static method \"getCPtr\" missing",
imdbParser_t *, NULL);
}
if ( (r=(*env)->CallStaticLongMethod(env, class, jcb, jparserobject, 0)) == 0 ) {
PARE_JNI_INVALID_OBJECT_FAILURE(JLog_jlog(jl), "org/libimdb/swig/Parser",
"static method call to \"getCPtr\" returned NULL(0)",
imdbParser_t *, NULL);
}
if ( r == 0 ) {
PAR_FAILURE(JLog_jlog(jl), imdbParser_t *, NULL);
}
else {
PAR_SUCCESS(JLog_jlog(jl), imdbParser_t *, *(imdbParser_t **)&r);
}
}
static void
progressStarting_cb(jlogHandle_t *logh,
imdbParser_t *parser,
const char *shortDescription,
int itemEstimate)
{
struct jniData_s *jniData=imdbParser_getUserHandle(logh, parser);
(*(jniData->env))->CallVoidMethod(jniData->env,
jniData->jprogressobject,
jniData->progressStarting_jcb,
(*(jniData->env))->NewStringUTF(jniData->env, shortDescription),
itemEstimate);
}
/* returns number of next item progrssUpdate
needs to be called for */
static int
progressUpdate_cb(jlogHandle_t *logh,
imdbParser_t *parser,
int itemCount,
int itemEstimate)
{
struct jniData_s *jniData=imdbParser_getUserHandle(logh, parser);
return((*(jniData->env))->CallIntMethod(jniData->env,
jniData->jprogressobject,
jniData->progressUpdate_jcb,
itemCount, itemEstimate));
}
static void
progressFinished_cb(jlogHandle_t *logh,
imdbParser_t *parser,
int itemCount,
int abortCode)
{
struct jniData_s *jniData=imdbParser_getUserHandle(logh, parser);
(*(jniData->env))->CallVoidMethod(jniData->env,
jniData->jprogressobject,
jniData->progressFinished_jcb,
itemCount, abortCode);
}
static int
setupProgressListener(JNIEnv *env,
JLog_t *jl,
imdbParser_t *parser,
jobject jprogressobject)
{
jclass class;
struct jniData_s *jniData=imdbParser_getUserHandle(JLog_jlog(jl), parser);
if ( jprogressobject == NULL ) {
return(imdbParser_disableProgressCallbacks(JLog_jlog(jl), parser));
}
class=(*env)->GetObjectClass(env, jprogressobject);
if ( (jniData->progressStarting_jcb=(*env)->GetMethodID(env, class,
"progressStarting_cb",
"(Ljava/lang/String;I)V"))==0 ) {
PARE_JNI_INVALID_OBJECT_FAILURE(JLog_jlog(jl), "org/libimdb/swig/ProgressListener",
"static method \"progressStarting_cb\" missing",
int, -1);
}
if ( (jniData->progressUpdate_jcb=(*env)->GetMethodID(env, class,
"progressUpdate_cb",
"(II)I"))==0 ) {
PARE_JNI_INVALID_OBJECT_FAILURE(JLog_jlog(jl), "org/libimdb/swig/ProgressListener",
"static method \"progressUpdate_cb\" missing",
int, -1);
}
if ( (jniData->progressFinished_jcb=(*env)->GetMethodID(env, class,
"progressFinished_cb",
"(II)V"))==0 ) {
PARE_JNI_INVALID_OBJECT_FAILURE(JLog_jlog(jl), "org/libimdb/swig/ProgressListener",
"static method \"progressFinished_cb\" missing",
int, -1);
}
jniData->jprogressobject=jprogressobject;
return(imdbParser_setProgressCallbacks(JLog_jlog(jl), parser,
progressStarting_cb,
progressUpdate_cb,
progressFinished_cb));
}
int
imdbParser_destroy(JNIEnv *env,
jobject jlogobject,
jobject jparserobject)
{
int ret;
JLog_t *jl;
imdbParser_t *parser;
struct jniData_s *jniData;
jl=JLog_initialize(env, jlogobject);
if ( jl == NULL ) {
return(-1);
}
parser=getParserFromObject(jl, env, jparserobject);
if ( parser == NULL ) {
JLog_uninitialize(jl);
return(-2);
}
jniData=imdbParser_setUserHandle(JLog_jlog(jl), parser, NULL);
free(jniData);
ret=imdbParser_close(JLog_jlog(jl), parser);
JLog_uninitialize(jl);
return(ret);
}
int
imdbParser_dumpMovies(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject)
{
jclass class;
int ret;
JLog_t *jl;
imdbParser_t *parser;
struct jniData_s *jniData;
jl=JLog_initialize(env, jlogobject);
if ( jl == NULL ) {
return(-1);
}
parser=getParserFromObject(jl, env, jparserobject);
if ( parser == NULL ) {
JLog_uninitialize(jl);
return(-2);
}
jniData=imdbParser_getUserHandle(JLog_jlog(jl), parser);
jniData->env=env;
jniData->jparserobject=jparserobject;
if ( setupProgressListener(env, jl, parser, jprogressobject) != 0 ) {
JLog_uninitialize(jl);
return(-3);
}
class=(*env)->GetObjectClass(env, jparserobject);
/* javap -s -classpath bdir-LINUX org.libimdb.swig.Parser */
jniData->movieListEntry_jcb=(*env)->GetMethodID(env, class,
"movieListEntry_cb",
"(IIILjava/lang/String;I)I");
if ( jniData->movieListEntry_jcb == 0 ) {
JLog_uninitialize(jl);
return(-4);
}
ret=imdbParser_moviesParse(JLog_jlog(jl), parser);
JLog_uninitialize(jl);
return(ret);
}
int
imdbParser_dumpDirectors(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject)
{
jclass class;
int ret;
JLog_t *jl;
imdbParser_t *parser;
struct jniData_s *jniData;
jl=JLog_initialize(env, jlogobject);
if ( jl == NULL ) {
return(-1);
}
parser=getParserFromObject(jl, env, jparserobject);
if ( parser == NULL ) {
JLog_uninitialize(jl);
return(-2);
}
jniData=imdbParser_getUserHandle(JLog_jlog(jl), parser);
if ( setupProgressListener(env, jl, parser, jprogressobject) != 0 ) {
JLog_uninitialize(jl);
return(-3);
}
jniData->env=env;
jniData->jparserobject=jparserobject;
class=(*env)->GetObjectClass(env, jparserobject);
/* javap -s -classpath bdir-LINUX org.libimdb.swig.Parser */
jniData->directorListEntry_jcb=(*env)->GetMethodID(env, class,
"directorListEntry_cb",
"(IILjava/lang/String;Ljava/lang/String;)I");
if ( jniData->directorListEntry_jcb == 0 ) {
JLog_uninitialize(jl);
return(-4);
}
ret=imdbParser_directorsParse(JLog_jlog(jl), parser);
JLog_uninitialize(jl);
return(ret);
}
int
imdbParser_dumpActors(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject)
{
jclass class;
int ret;
JLog_t *jl;
imdbParser_t *parser;
struct jniData_s *jniData;
jl=JLog_initialize(env, jlogobject);
if ( jl == NULL ) {
return(-1);
}
parser=getParserFromObject(jl, env, jparserobject);
if ( parser == NULL ) {
JLog_uninitialize(jl);
return(-2);
}
jniData=imdbParser_getUserHandle(JLog_jlog(jl), parser);
if ( setupProgressListener(env, jl, parser, jprogressobject) != 0 ) {
JLog_uninitialize(jl);
return(-3);
}
jniData->env=env;
jniData->jparserobject=jparserobject;
class=(*env)->GetObjectClass(env, jparserobject);
/* javap -s -classpath bdir-LINUX org.libimdb.swig.Parser */
jniData->actorListEntry_jcb=(*env)->GetMethodID(env, class,
"actorListEntry_cb",
"(IILjava/lang/String;IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I");
if ( jniData->actorListEntry_jcb == 0 ) {
JLog_uninitialize(jl);
return(-4);
}
ret=imdbParser_actorsParse(JLog_jlog(jl), parser);
JLog_uninitialize(jl);
return(ret);
}
int
imdbParser_dumpActresses(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject)
{
jclass class;
int ret;
JLog_t *jl;
imdbParser_t *parser;
struct jniData_s *jniData;
jl=JLog_initialize(env, jlogobject);
if ( jl == NULL ) {
return(-1);
}
parser=getParserFromObject(jl, env, jparserobject);
if ( parser == NULL ) {
JLog_uninitialize(jl);
return(-2);
}
jniData=imdbParser_getUserHandle(JLog_jlog(jl), parser);
if ( setupProgressListener(env, jl, parser, jprogressobject) != 0 ) {
JLog_uninitialize(jl);
return(-3);
}
jniData->env=env;
jniData->jparserobject=jparserobject;
class=(*env)->GetObjectClass(env, jparserobject);
/* javap -s -classpath bdir-LINUX org.libimdb.swig.Parser */
jniData->actressListEntry_jcb=(*env)->GetMethodID(env, class,
"actressListEntry_cb",
"(IILjava/lang/String;IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I");
if ( jniData->actressListEntry_jcb == 0 ) {
JLog_uninitialize(jl);
return(-4);
}
ret=imdbParser_actressesParse(JLog_jlog(jl), parser);
JLog_uninitialize(jl);
return(ret);
}
--- NEW FILE: Parser_jni.h ---
/**
@file
Shared include with both Parser.swig and Parser_jni.c
(ensures consistancy)
@verbatim $Id: Parser_jni.h,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
#ifdef SWIGJAVA
%typemap(jni) (jobject jlog) "/*jni*/jobject"
%typemap(jtype) (jobject jlog) "/*jtype*/org.libimdb.swig.JLog"
%typemap(jstype) (jobject jlog) "/*jstype*/org.libimdb.swig.JLog"
%typemap(javain) (jobject jlog) %{/*javain*/$javainput%}
%typemap(in) (jobject jlog) %{ $1=jarg$argnum;%}
%typemap(freearg) (jobject jlog) %{%}
%apply (jobject jlog) {(jobject jlogobject)};
#endif /* SWIGJAVA */
imdbParser_t *
imdbParser_create(JNIEnv *env,
jobject jlogobject,
char *dbsDir);
int
imdbParser_destroy(JNIEnv *env,
jobject jlogobject,
jobject jparserobject);
#ifdef SWIGJAVA
%typemap(jni) (jobject jprog) "/*jni*/jobject"
%typemap(jtype) (jobject jprog) "/*jtype*/org.libimdb.swig.ProgressListener"
%typemap(jstype) (jobject jprog) "/*jstype*/org.libimdb.swig.ProgressListener"
%typemap(javain) (jobject jprog) %{/*javain*/$javainput%}
%typemap(in) (jobject jprog) %{ $1=jarg$argnum;%}
%typemap(freearg) (jobject jprog) %{%}
%apply (jobject jprog) {(jobject jprogressobject)};
#endif
#ifdef SWIGJAVA
%typemap(jni) (jobject jparser) "/*jni*/jobject"
%typemap(jtype) (jobject jparser) "/*jtype*/org.libimdb.swig.Parser"
%typemap(jstype) (jobject jparser) "/*jstype*/org.libimdb.swig.Parser"
%typemap(javain) (jobject jparser) %{/*javain*/$javainput%}
%typemap(in) (jobject jparser) %{ $1=jarg$argnum;%}
%typemap(freearg) (jobject jparser) %{%}
%apply (jobject jparser) {(jobject jparserobject)};
#endif
int
imdbParser_dumpMovies(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject);
int
imdbParser_dumpDirectors(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject);
int
imdbParser_dumpActors(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject);
int
imdbParser_dumpActresses(JNIEnv *env,
jobject jlogobject,
jobject jparserobject,
jobject jprogressobject);
--- NEW FILE: bytetypemaps.i ---
#ifdef SWIG
%typemap(jni) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN) "/*jni*/jbyteArray"
%typemap(jtype) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN) "/*jtype*/byte[]"
%typemap(jstype) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN) "/*jstype*/byte[]"
%typemap(javain) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN) %{/*javain*/$javainput%}
#if IF_JAVAOUT_DID_SOMETHING
%typemap(javaout) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN) %{/*javaout*/&$jnicall%}
#endif
%typemap(in) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN)(jboolean isCopy) {
$1=JCALL1(GetArrayLength, jenv, $input);
$2=JCALL2(GetByteArrayElements, jenv, $input, &isCopy);
}
%typemap(argout) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN) {
/*argout*/
JCALL3(ReleaseByteArrayElements, jenv, $input, $2, JNI_ABORT);
}
%typemap(freearg) (int LIST_SIZE, uint8_t *BYTE_ARRAY_IN) {/* freearg */}
#endif
--- NEW FILE: inttypemaps.i ---
/* int32_t *INTEGER_ARRAY_IN
- to use:
%apply (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) {(int size, int32_t *list)};
extern int printInts(int size, int32_t *list);
%clear (int size, int32_t *list);
*/
%typemap(jni) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) "/*jni*/jintArray"
%typemap(jtype) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) "/*jtype*/int[]"
%typemap(jstype) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) "/*jstype*/int[]"
%typemap(javain) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) %{/*javain*/$javainput%}
#if IF_JAVAOUT_DID_SOMETHING
%typemap(javaout) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) %{/*javaout*/&$jnicall%}
#endif
%typemap(in) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN)(jboolean isCopy) {
$1=JCALL1(GetArrayLength, jenv, $input);
$2=JCALL2(GetIntArrayElements, jenv, $input, &isCopy);
}
%typemap(argout) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) {
/*argout*/
JCALL3(ReleaseIntArrayElements, jenv, $input, $2, JNI_ABORT);
}
%typemap(freearg) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_IN) {/* freearg */}
/* int32_t *INTEGER_ARRAY_INOUT
- array must stay the same size :)
- to use:
%apply (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) {(int size, int32_t *list)};
extern int reverseInts(int size, int32_t *list);
%clear (int size, int32_t *list);
*/
%typemap(jni) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) "/*jni*/jintArray"
%typemap(jtype) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) "/*jtype*/int[]"
%typemap(jstype) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) "/*jstype*/int[]"
%typemap(javain) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) %{/*javain*/$javainput%}
#if IF_JAVAOUT_DID_SOMETHING
%typemap(javaout) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) %{/*javaout*/&$jnicall%}
#endif
%typemap(in) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT)(jboolean isCopy) {
$1=JCALL1(GetArrayLength, jenv, $input);
$2=JCALL2(GetIntArrayElements, jenv, $input, &isCopy);
}
%typemap(argout) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) {
JCALL3(ReleaseIntArrayElements, jenv, $input, $2, 0/*copy back and free prev arg*/);
$2=NULL;
}
%typemap(freearg) (int32_t LIST_SIZE, int32_t *INTEGER_ARRAY_INOUT) {/* freearg */}
--- NEW FILE: javahead.c ---
/* my copy of javahead.swg - jwv
*/
#if defined(__GNUC__)
typedef long long __int64; /*For gcc on Windows */
#endif
#include <jni.h>
#include <stdlib.h>
#include <string.h>
/* Support for throwing Java exceptions */
typedef enum {
SWIG_JavaOutOfMemoryError = 1,
SWIG_JavaIOException,
SWIG_JavaRuntimeException,
SWIG_JavaIndexOutOfBoundsException,
SWIG_JavaArithmeticException,
SWIG_JavaIllegalArgumentException,
SWIG_JavaNullPointerException,
SWIG_JavaUnknownError
} SWIG_JavaExceptionCodes;
typedef struct {
SWIG_JavaExceptionCodes code;
const char *java_exception;
} SWIG_JavaExceptions_t;
void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
jclass excep;
static const SWIG_JavaExceptions_t java_exceptions[] = {
{ SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
{ SWIG_JavaIOException, "java/io/IOException" },
{ SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
{ SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
{ SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
{ SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
{ SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
{ SWIG_JavaUnknownError, "java/lang/UnknownError" },
{ (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } };
const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
while (except_ptr->code != code && except_ptr->code)
except_ptr++;
(*jenv)->ExceptionClear(jenv);
excep = (*jenv)->FindClass(jenv, except_ptr->java_exception);
if (excep)
(*jenv)->ThrowNew(jenv, excep, msg);
}
--- NEW FILE: longtypemaps.i ---
/* int64_t *LONG_ARRAY_IN
- to use:
%apply (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) {(int size, int64_t *list)};
extern int printLongs(int size, int64_t *list);
%clear (int size, int64_t *list);
*/
%typemap(jni) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) "/*jni*/jlongArray"
%typemap(jtype) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) "/*jtype*/long[]"
%typemap(jstype) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) "/*jstype*/long[]"
%typemap(javain) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) %{/*javain*/$javainput%}
#if IF_JAVAOUT_DID_SOMETHING
%typemap(javaout) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) %{/*javaout*/&$jnicall%}
#endif
%typemap(in) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN)(jboolean isCopy) {
$1=JCALL1(GetArrayLength, jenv, $input);
$2=JCALL2(GetLongArrayElements, jenv, $input, &isCopy);
}
%typemap(argout) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) {
/*argout*/
JCALL3(ReleaseLongArrayElements, jenv, $input, $2, JNI_ABORT);
}
%typemap(freearg) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_IN) { /* freearg */ }
/* int64_t *LONG_ARRAY_INOUT
- array must stay the same size :)
- to use:
%apply (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) {(int size, int64_t *list)};
extern int reverseLongs(int size, int64_t *list);
%clear (int size, int64_t *list);
*/
%typemap(jni) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) "/*jni*/jlongArray"
%typemap(jtype) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) "/*jtype*/long[]"
%typemap(jstype) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) "/*jstype*/long[]"
%typemap(javain) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) %{/*javain*/$javainput%}
#if IF_JAVAOUT_DID_SOMETHING
%typemap(javaout) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) %{/*javaout*/&$jnicall%}
#endif
%typemap(in) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT)(jboolean isCopy) {
$1=JCALL1(GetArrayLength, jenv, $input);
$2=JCALL2(GetLongArrayElements, jenv, $input, &isCopy);
}
%typemap(argout) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) {
JCALL3(ReleaseLongArrayElements, jenv, $input, $2, 0/*copy back and free prev arg*/);
$2=NULL;
}
%typemap(freearg) (int32_t LIST_SIZE, int64_t *LONG_ARRAY_INOUT) { /* freearg */ }
--- NEW FILE: mytypemaps.i ---
/* char **MYSTATIC_STRING_OUT_ARG - result must be a null terminated string */
%typemap(jni) char **MYSTATIC_STRING_OUT_ARG "jobjectArray"
%typemap(jtype) char **MYSTATIC_STRING_OUT_ARG "String[]"
%typemap(jstype) char **MYSTATIC_STRING_OUT_ARG "String[]"
%typemap(in) char **MYSTATIC_STRING_OUT_ARG (char *s) %{ $1 = &s; %}
%typemap(argout) char **MYSTATIC_STRING_OUT_ARG {
if($1) {
JCALL3(SetObjectArrayElement, jenv, $input, 0, JCALL1(NewStringUTF, jenv, *$1));
}
}
%typemap(javain) char **MYSTATIC_STRING_OUT_ARG "$javainput"
%typemap(javaout) char **MYSTATIC_STRING_OUT_ARG "&$jnicall"
/* char **MYALLOCTED_STRING_OUT
*/
%typemap(jni) char **MYALLOCTED_STRING_OUT_ARG "jobjectArray"
%typemap(jtype) char **MYALLOCTED_STRING_OUT_ARG "String[]"
%typemap(jstype) char **MYALLOCTED_STRING_OUT_ARG "String[]"
%typemap(in) char **MYALLOCTED_STRING_OUT_ARG (char *s) %{ $1 = &s; %}
%typemap(argout) char **MYALLOCTED_STRING_OUT_ARG {
if($1) {
JCALL3(SetObjectArrayElement, jenv, $input, 0, JCALL1(NewStringUTF, jenv, *$1));
free($1); $1=NULL;
}
}
%typemap(javain) char **MYALLOCTED_STRING_OUT_ARG "$javainput"
%typemap(javaout) char **MYALLOCTED_STRING_OUT_ARG "&$jnicall"
/* char **MYSTATIC_STRING_ARRAY_RETURN
for use for functions that return a NULL terminated array
of strings (that the function does the memory management on) */
%typemap(jni) char **MYSTATIC_STRING_ARRAY_RET "jarray"
%typemap(jtype) char **MYSTATIC_STRING_ARRAY_RET "String[]"
%typemap(jstype) char **MYSTATIC_STRING_ARRAY_RET "String[]"
%typemap(out) char **MYSTATIC_STRING_ARRAY_RET {
if($1 != NULL) {
char **p = $1;
jsize size = 0;
int i = 0;
jclass strClass;
while (*p++) size++; /* determine size */
strClass = JCALL1(FindClass, jenv, "java/lang/String");
$result = JCALL3(NewObjectArray, jenv, size, strClass, NULL);
p = $1;
while (*p) {
jstring js = JCALL1(NewStringUTF, jenv, *p);
JCALL3(SetObjectArrayElement, jenv, $result, i++, js);
p++;
}
}
}
%typemap(javain) char **MYSTATIC_STRING_ARRAY_RET "$javainput"
%typemap(javaout) char **MYSTATIC_STRING_ARRAY_RET "{return($jnicall);}"
/* char **MYALLOCTED_STRING_ARRAY_RET
same as MYSTATIC_STRING_ARRAY_RET except returned array
is freed after its been returned (each element, then the
array itself */
%typemap(jni) char **MYALLOCTED_STRING_ARRAY_RET "jarray"
%typemap(jtype) char **MYALLOCTED_STRING_ARRAY_RET "String[]"
%typemap(jstype) char **MYALLOCTED_STRING_ARRAY_RET "String[]"
%typemap(out) char **MYALLOCTED_STRING_ARRAY_RET {
if($1 != NULL) {
char **p = $1;
jsize size = 0;
int i = 0;
jclass strClass;
while (*p++) size++; /* determine size */
strClass = JCALL1(FindClass, jenv, "java/lang/String");
$result = JCALL3(NewObjectArray, jenv, size, strClass, NULL);
p = $1;
while (*p) {
jstring js = JCALL1(NewStringUTF, jenv, *p);
JCALL3(SetObjectArrayElement, jenv, $result, i++, js);
free(*p);
*p=NULL;
p++;
}
free($1);
$1=NULL;
}
}
%typemap(javain) char **MYALLOCTED_STRING_ARRAY_RET "$javainput"
%typemap(javaout) char **MYALLOCTED_STRING_ARRAY_RET "{return($jnicall);}"
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb
In directory sc8-pr-cvs1:/tmp/cvs-serv11812
Added Files:
Makefile README constants.mk rules.mk
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
SUBPROJECTS := include libjlog parser java demo
include config.mk
ifneq "$(origin PROJECT_TOP)" "undefined"
include constants.mk
endif
build clean clobber depend: config.mk
@for sub in $(SUBPROJECTS); do \
[ -d $$sub ] || continue; \
$(ECHO) "`$(DATECMD)`: $@ing $$sub"; \
(cd $$sub; $(MAKE) $@) || exit 1; \
done;
distclean: clobber
rm -f config.mk
install:
@[ -d $(INSTALL_ROOT) ] || mkdir -p $(INSTALL_ROOT)
config\
config.mk: Makefile
@echo "creating config.mk..."
@(echo "PROJECT_TOP=`pwd`";\
echo "JAVA_COMPILER=SUNJava14" ;\
echo "JAVA_RUNTIME=SUNJava14" ;\
echo "JAVADOC_RUNTIME=SUNJava14" ;\
echo "RT_JAR=SUNJava14" ;\
) > config.mk
--- NEW FILE: README ---
Short list to get things out.
- build env
- roll out c library
- roll out beta java interface
- simple web page and setup of cvs, mailing lists etc.
- will want to use something like mpatrol to assess what
the memory requirements are for different parts of the
library.
- need to version things.
libimdb_getVersion();
libimdb_getListFileInfo(); ??
- is it easy to convert lfetch to a c program ?
libimdb_updateListFile();
- look at perl script to just get list files
- look at perl script to get and merge list diff files.
Things to be done
-----------------
Since movie lables are the key to the database, maybe a temperary
(option) on-disk db database to hold the movie info and rest of
them return references to entries via a movie key. The user does
a second set of lookups when the movie detail is needed. Making
it optional means not paying the disk price and instead paying
the memory price. (may also just be a runtime optional though,
since we may want to use an in-memory db still - this could be
substituted for a non-db solution later).
Guess that means we may need to lookup movies by key, but also
generate a list of movie label based results when searching by
title. This may require a second pass over the movie database.
Need to take a closer look at all the list file to assess if
this is the best strategy.
Simpler scan actor db one at a time - callbacks get a single actors
and multiple movie keys (and char info).
perl interface and callback using swig'd interface
- build simple example and look for help via
perl5 book and swig mailing list.
- support callback or first/next... processing ?
- first/next might be just simpler for perl
- probably pretty easy to support both.
libjlog
- main log_open should initialize default
logtracker and logtee from env variables
- do we want this to happen every log_open ?
- yes
- how do we define filters ?
- file/func filters
- in/out filters
- regexp ?
- config file
- can mklog.pl generate/manage the list of
modules supported ? Would require that
enum gets initialized though.
- one enum should alwyas be MOD_OKAY=0
- completely separate tree for jvlog ?
- can success/failure callback be combined
with current callback mechanism ?
- support success call from void function
- LOGerror_e should become LOGvalues_e
and include LOG_SUCCESS=0, enum values should be negative
for error
- how can we get gcc to check __attribute()__ stuff ?
nuke build environment and re-write.
- use simple gmake makefiles that need to be
massaged to work....
- could have basic configure at the top.
- swig generation should be separate target and
not part of normal build.
- change name of .javaswig file to not specify
packaging, explicit move command and rmdir
with warnings if files end up lying around
- cvs ci should include java generated c etc.
- can I or should I use sysinclude.h ?
- probably don't need it... would need to test port to
cygwin for compiling into a dll.
- can probably keep it if I get rid of Precise/Invidi
related bits (NATIVE_WINDOWS)
(switch if !defined(NATIVE_WINDOWS) to if defined(LINUX))
etc.
Utility for downloading/managing ftp list files
What is this thing for ?
------------------------
- look at what Scott did for mysql loading.
- look at xmltv2db on sf for a basic example of
putting data into jdbc database - now sure how useful this is.
- support gzip'd list files.
- www.gzip.org/zlib
- can probably just include it.
- need bigger picture plan... what is libimdb ?
- for use with tv_imdb ?
- maybe tv_imdb just uses a libimdb database
- libimdb's own database could just be a
series of text files in sorted key order.
then use look to locate things.
- perl interface kept simple, while libimdb
could use binary search algorithm.
- still doesn't require mysql and is platform
independent.
- what other db options are out there ? gdbm ?
- nothing to say we can't use dynamic libimdb.so
for searching, provide a generic interface
that includes what you want for tv_imdb
Then just have java and a perl interface.
- guess a perl script is the easies to load
things into mysql ?
- xml output of db entry (probably useful for
debugging as well).
- xmlrpc ? what is it, is it useful here ?
- linux and windows supported ?
- load imdb data into hsqldb / mysqldb
- how do we standardize on db tables ?
- how do you look flexible ?
- interface must support db clean, load
- way in the future what can we do about doing
minimal updates ? Can we only update the table
entries that changed since the last fresh build ?
Maybe the parse should support an update
operation ? How do we identify things that have
to be removed ? Can we ? Maybe intermediate db
(flat sorted index) and a compare or refresh mysql
utility.
- query data
- do all of this from java and perl
- can I build a java centric database loader (int hsqldb ?)
- what kind of progress bars are in java ?
- JFreeChart to plot things ?
- number of actors / movie
- years of movies ?
- present stats generated from loader ?
- actors to actresses totals
- movie ratings (user rated) against years
- what about a imdb server that has XML-RPC interfaces
for queries ?
perl use Soap::Lite package (www.soaplite.com)
--- NEW FILE: constants.mk ---
#
# $Id: constants.mk,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
#
# Required re-defined variables
# PROJECT_TOP
# JAVA_COMPILER (see comments below)
# JAVA_RUNTIME (see comments below)
# JAVADOC_RUNTIME (see comments below)
#
COMPILE_BIN=$(PROJECT_TOP)/bin
HOST_DETAILED_ARCH := $(shell uname -m)
HOST_DETAILED_OS := $(shell uname -sr | sed 's/ /-/')
HOST_NAME := $(shell uname -n)
__HOST_ARCH__ :=case "$(HOST_DETAILED_ARCH)" in \
sun4u) echo sun4;; \
586|i586) echo i586;; \
686|i686) echo i686;; \
*) echo "bad HOST_DETAILED_ARCH: $(HOST_DETAILED_ARCH)" >&2; exit 1;; \
esac
HOST_ARCH := $(shell $(__HOST_ARCH__))
__HOST_OS__ :=case "$(HOST_DETAILED_OS)" in \
Linux-2.*) echo LINUX;; \
CYGWIN_NT-5*) echo CYGWIN;; \
*) echo "bad HOST_DETAILED_OS: $(HOST_DETAILED_OS)" >&2; exit 1;; \
esac
HOST_OS := $(shell $(__HOST_OS__))
__HOST_OS_VERSION__ :=case "$(HOST_DETAILED_OS)" in \
Linux-2.*) echo 2;; \
Windows_NT-4) echo 4;; \
*) echo "bad HOST_OS: $(HOST_OS)" >&2; exit 1;; \
esac
HOST_OS_VERSION := $(shell $(__HOST_OS_VERSION__))
# backward compatibility
OS=$(HOST_OS)
#
# BUILD_ARCH / _OS and _PLATFORM
#
BUILD_ARCH =$(HOST_ARCH)
BUILD_OS =$(HOST_OS)
BUILD_OS_VERSION=$(HOST_OS)$(HOST_OS_VERSION)
BUILD_PLATFORM =$(HOST_ARCH)-$(HOST_OS)
#
# TARGET_ARCH / _OS and _PLATFORM
#
TARGET_ARCH =$(BUILD_ARCH)
TARGET_OS =$(BUILD_OS)
TARGET_OS_VERSION=$(BUILD_OS_VERSION)
TARGET_PLATFORM =$(TARGET_ARCH)-$(TARGET_OS)
#
# list of TARGET_PLATFORMS we currently support
#
ifneq "$(TARGET_PLATFORM)" "i686-LINUX"
ifneq "$(TARGET_PLATFORM)" "i686-CYGWIN"
ifneq "$(TARGET_PLATFORM)" "i686-MINGW"
$(error invalid TARGET_PLATFORM="$(TARGET_PLATFORM)")
endif
endif
endif
# WHOAMI_LINUX := /usr/bin/whoami
# WHOAMI_CYGWIN := /bin/whoami
# WHOAMI = $(WHOAMI_$(BUILD_OS))
#
# USER_NAME := $(shell $(WHOAMI))
CLASSPATH_SEP_CYGWIN :=;
CLASSPATH_SEP_LINUX :=:
CLASSPATH_SEP=$(CLASSPATH_SEP_$(BUILD_OS))
# used by among other things javadoc
SOURCEPATH_SEP_CYGWIN :=;
SOURCEPATH_SEP_LINUX :=:
SOURCEPATH_SEP=$(SOURCEPATH_SEP_$(BUILD_OS))
# these are used for commands like $(subst $(space),$(SEP),$(PATH))
empty:=
space:=$(empty) $(empty)
dot:=.
slash:=/
colon:=:
semicolon:=;
plus:=+
# create shell-ready classpath given an argument that is a space separated
# list of paths
# - we no longer use this function since make screws up the $$ expansion
# in $(call) function usage in make
#createClassPath=$(subst $(space),$(CLASSPATH_SEP),$(strip $(1)))
AR_CYGWIN := /bin/ar
AR_LINUX := /usr/bin/ar
AR = $(AR_$(BUILD_OS))
ARFLAGS = cr
AWK_CYGWIN := /bin/awk
AWK_LINUX := /bin/awk
AWK = $(AWK_$(BUILD_OS))
BISON_CYGWIN := /bin/bison
BISON_LINUX := /usr/bin/bison
BISON = $(BISON_$(BUILD_OS))
CHMOD_CYGWIN := /bin/chmod
CHMOD_LINUX := /bin/chmod
CHMOD = $(CHMOD_$(BUILD_OS))
CMP_CYGWIN := /bin/cmp
CMP_LINUX := /usr/bin/cmp
CMP = $(CMP_$(BUILD_OS))
CC_CYGWIN := /usr/bin/gcc
CC_LINUX := /usr/bin/gcc
CC = $(CC_$(BUILD_OS))
# define CC_COMPILER as being the basename of the compiler.
# this can be (is) used to switch between compiler-dependent flags etc
# (it replaces the previous CC_BASENAME, mostly we may have compilers
# whose basenames aren't legal gmake variables ie CFLAGS_g++)
#CC_BASENAME = $(notdir $(basename $(filter-out perl, $(CC_$(BUILD_OS)))))
CC_COMPILER = $(subst $(plus),x,$(notdir $(basename $(filter-out perl, $(CC_$(BUILD_OS))))))
CXX_CYGWIN := /usr/bin/g++
CXX_LINUX := /usr/bin/g++
CXX = $(CXX_$(BUILD_OS))
# define CXX_COMPILER as being the basename of the compiler.
# this can be (is) used to switch between compiler-dependent flags etc
# (it replaces the previous CXX_BASENAME, mostly we may have compilers
# whose basenames aren't legal gmake variables ie CFLAGS_g++)
#CXX_BASENAME = $(notdir $(basename $(filter-out perl, $(CCC_$(BUILD_OS)))))
CXX_COMPILER = $(subst $(plus),x,$(notdir $(basename $(CXX_$(BUILD_OS)))))
# extensions:
O_CYGWIN :=o
O_LINUX :=o
O:=$(O_$(BUILD_OS))
A_CYGWIN :=lib
A_LINUX :=a
A:=$(A_$(BUILD_OS))
SO_CYGWIN :=dll
SO_LINUX :=so
SO:=$(SO_$(BUILD_OS))
JAR:=jar
# placing a value in PROFILE causes compilation for coverage analysis:
# this includes:
# - stoping creation of dynamic libraries or installation of them.
# - object files to not be compiled with position independent code (-fpic).
# - adds -a to CFLAGS to turn on gcc basic block profiling.
# - binaries link with static (.a) libs instead of dynamic (.so).
# sideffects
# - for this to work, everyone has to compile both a dynamic and static lib
# - makefiles must use $(SO) for library extenions in LIBS definitions
#PROFILE := yes
ifdef PROFILE
BUILDING_DYNAMIC :=false
CFLAGS_FPIC:=
CFLAGS_PROFILE=-a
SO=$(A)
# for now, the same as CFLAGS_FPIC
CCFLAGS_FPIC :=$(CFLAGS_FPIC)
else
# BUILDING_DYNAMIC says whether we are building dynamic libraries for this
# release. The value can be overriden in a particular Makefile.
BUILDING_DYNAMIC_CYGWIN :=true
BUILDING_DYNAMIC_LINUX :=true
BUILDING_DYNAMIC =$(BUILDING_DYNAMIC_$(BUILD_OS))
CFLAGS_FPIC_CYGWIN_gcc :=
CFLAGS_FPIC_LINUX_gcc :=-fpic
CFLAGS_FPIC :=$(CFLAGS_FPIC_$(BUILD_OS)_$(CC_COMPILER))
# for now, the same as CFLAGS_FPIC
CCFLAGS_FPIC :=$(CFLAGS_FPIC)
CFLAGS_PROFILE=
endif
# it's important to build the dynamic objects first because:
# - OBJS_TYPE=DYNAMIC causes -fpic (or equivalent) to be added to CFLAGS
# - there is no distinction between dynamic and static object directories
# on Solaris, SunOS, Linux ..., so only the first make will build anything.
# So, we want that one build to have -fpic defined in order to make the
# dynamic libraries. If we were efficiency nuts we could make two object
# directories on all platforms.
ifdef DYNAMIC
OBJS_TYPE =DYNAMIC
else
OBJS_TYPE =STATIC
endif
#BUILD_BASE=bdir-$(BUILD_OS)-$(TARGET_OS)
BUILD_BASE=bdir-$(BUILD_OS)
BUILD_CFG=$(BUILD_BASE)
BUILD_DIR=$(BUILD_CFG)
# override should contain $(BUILD_CFG) eg. BUILD_DIR = ../$(BUILD_CFG)
# BUILD_CFG should never contain a slash
OBJS_CFG_CYGWIN =$(BUILD_CFG)
OBJS_CFG_LINUX =$(BUILD_CFG)
OBJS_CFG =$(OBJS_CFG_$(BUILD_OS))
OBJS_DIR =$(OBJS_CFG)
# CFLAGS, CCFLAGS and CPPFLAGS are not set by := so that project
# specific flags can be set like
# CFLAGS += ...
# in leaf Makefile
CFLAGS_gcc :=-O -g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Waggregate-return
# -fcheck-memory-usage
CFLAGS_gcc_LINUX :=
CFLAGS_gcc_TARGET_MINGW :=-mno-cygwin
# this doens't work if you have empty defines :)
#ifeq "$(CFLAGS_$(CC_COMPILER))" "undef"
# $(error CFLAGS_$(CC_COMPILER)) was left undefined, fix constants.mk)
#endif
CFLAGS_DYNAMIC := $(CFLAGS_FPIC)
CFLAGS_STATIC :=
CFLAGS=$(filter-out $(CFLAGS_DROP),$(CFLAGS_PROFILE) $(CFLAGS_$(CC_COMPILER)) $(CFLAGS_$(CC_COMPILER)_$(BUILD_OS)) $(CFLAGS_$(CC_COMPILER)_TARGET_$(BUILD_OS)) $(CFLAGS_$(OBJS_TYPE)))
# note: -mno-cygwin removed from CCFLAGS_cxx_CYGWIN so default is to build dependent on cygwin
CCFLAGS_gxx :=-g -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow
CCFLAGS_gxx_TARGET_MINGW :=-mno-cygwin
# this doens't work if you have empty defines :)
#ifeq "$(CCFLAGS_$(CXX_COMPILER))" ""
# $(error CCFLAGS_$(CXX_COMPILER)) was left undefined, fix constants.mk)
#endif
CCFLAGS_DYNAMIC := $(CCFLAGS_FPIC)
CCFLAGS_STATIC :=
CCFLAGS =$(filter-out $(CCFLAGS_DROP),$(CCFLAGS_$(CXX_COMPILER)) $(CCFLAGS_$(CXX_COMPILER)_BUILD_$(BUILD_OS)) $(CCFLAGS_$(CXX_COMPILER)_TARGET_$(TARGET_OS)) $(CCFLAGS_$(OBJS_TYPE)))
CPPFLAGS_gcc :=
# this doens't work if you have empty defines :)
#ifeq "$(CPPFLAGS_$(CC_COMPILER))" ""
# $(error CPPFLAGS_$(CC_COMPILER)) was left undefined, fix constants.mk)
#endif
CPPFLAGS =$(filter-out $(CPPFLAGS_DROP),$(CPPFLAGS_$(CC_COMPILER)) -D$(BUILD_OS) -D$(BUILD_OS_VERSION))
DATE_CYGWIN := /bin/date
DATE_LINUX := /bin/date
DATE = $(DATE_$(BUILD_OS))
DATECMD := $(DATE) '+%h %d %T'
DU_CYGWIN := /bin/du
DU_LINUX := /bin/du
DU = $(DU_$(BUILD_OS))
DUFLAGS = -sk
ETAGS_CYGWIN := /bin/etags
ETAGS_LINUX := /usr/bin/etags
ETAGS = $(ETAGS_$(BUILD_OS))
FIND_CYGWIN := /bin/find
FIND_LINUX := /usr/bin/find
FIND = $(FIND_$(BUILD_OS))
TAIL_CYGWIN := /bin/tail
TAIL_LINUX := /bin/tail
TAIL = $(TAIL_$(BUILD_OS))
LEX_CYGWIN := /bin/flex
LEX_LINUX := /usr/bin/flex
LEX = $(LEX_$(BUILD_OS))
LEXFLAGS = -t
# default MASSAGE is a no-op
MASSAGE := /bin/true
RM_CYGWIN := /bin/rm
RM_LINUX := /bin/rm
RM = $(RM_$(BUILD_OS))
MV_CYGWIN := /bin/mv
MV_LINUX := /bin/mv
MV = $(MV_$(BUILD_OS))
CP_CYGWIN := /bin/cp
CP_LINUX := /bin/cp
CP = $(CP_$(BUILD_OS))
CAT_CYGWIN := /bin/cat
CAT_LINUX := /bin/cat
CAT = $(CAT_$(BUILD_OS))
SH_CYGWIN := /bin/sh
SH_LINUX := /bin/sh
SH = $(SH_$(BUILD_OS))
TAR_CYGWIN := /bin/tar
TAR_LINUX := /bin/tar
TAR = $(TAR_$(BUILD_OS))
SLEEP_CYGWIN := /bin/sleep
SLEEP_LINUX := /bin/sleep
SLEEP = $(SLEEP_$(BUILD_OS))
ISPELL_CYGWIN := /usr/local/bin/ispell
ISPELL_LINUX := /usr/bin/ispell
ISPELL = $(ISPELL_$(BUILD_OS))
STRIP_CYGWIN := /bin/strip
STRIP_LINUX := /usr/bin/strip
STRIP = $(STRIP_$(BUILD_OS))
SED_CYGWIN := /bin/sed
SED_LINUX := /bin/sed
SED = $(SED_$(BUILD_OS))
TOUCH_CYGWIN := /bin/touch
TOUCH_LINUX := /bin/touch
TOUCH = $(TOUCH_$(BUILD_OS))
DIRNAME_CYGWIN := /bin/dirname
DIRNAME_LINUX := /bin/dirname
DIRNAME = $(DIRNAME_$(BUILD_OS))
RMDIR_CYGWIN := /bin/rmdir
RMDIR_LINUX := /bin/rmdir
RMDIR = $(RMDIR_$(BUILD_OS))
GZIP_CYGWIN := /bin/gzip
GZIP_LINUX := /bin/gzip
GZIP = $(GZIP_$(BUILD_OS))
ZIP_CYGWIN := /bin/zip
ZIP_LINUX := /bin/zip
ZIP = $(ZIP_$(BUILD_OS))
UNZIP_CYGWIN := /bin/unzip
UNZIP_LINUX := /usr/bin/unzip
UNZIP = $(UNZIP_$(BUILD_OS))
WC_CYGWIN := /bin/wc
WC_LINUX := /usr/bin/wc
WC = $(WC_$(BUILD_OS))
LD :=$(CC)
LDXX :=$(CXX)
LDD_CYGWIN := false
LDD_LINUX := /usr/bin/ldd
LDD := $(LDD_$(BUILD_OS))
# need the real ld to create dynamic libraries:
LD_DYNAMIC_CYGWIN :=/usr/bin/gcc
LD_DYNAMIC_LINUX :=/usr/bin/ld
LD_DYNAMIC =$(LD_DYNAMIC_$(BUILD_OS))
LD_DYNAMIC_BASENAME =$(subst $(plus),x,$(notdir $(basename $(LD_DYNAMIC))))
# need the real ld to create dynamic libraries containing c++ source:
LDXX_DYNAMIC_CYGWIN :=/usr/bin/g++
LDXX_DYNAMIC_LINUX :=/usr/bin/g++
LDXX_DYNAMIC =$(LDXX_DYNAMIC_$(BUILD_OS))
LDXX_DYNAMIC_BASENAME =$(subst $(plus),x,$(notdir $(basename $(LDXX_DYNAMIC))))
# note: -mno-cygwin removed from LD_DYNAMIC_FLAGS_CYGWIN so default is to build dependent on cygwin
LD_DYNAMIC_FLAGS_gcc_BUILD_CYGWIN =-shared -Wl,--add-stdcall-alias
LD_DYNAMIC_FLAGS_ld_BUILD_LINUX =-shared -h $(basename $(@F))
LD_DYNAMIC_FLAGS_gxx_TARGET_MINGW :=-mno-cygwin
LD_DYNAMIC_FLAGS=$(LD_DYNAMIC_FLAGS_$(LD_DYNAMIC_BASENAME)_BUILD_$(BUILD_OS)) \
$(LD_DYNAMIC_FLAGS_$(LD_DYNAMIC_BASENAME)_TARGET_$(TARGET_OS))
# note: -mno-cygwin removed from LDXX_DYNAMIC_FLAGS_CYGWIN so default is to build dependent on cygwin
LDXX_DYNAMIC_FLAGS_gxx_BUILD_CYGWIN =-shared -Wl,--add-stdcall-alias
LDXX_DYNAMIC_FLAGS_gxx_BUILD_LINUX =-shared -Wl,'-h $(basename $(@F))'
LDXX_DYNAMIC_FLAGS_gxx_TARGET_MINGW =-mno-cygwin
LDXX_DYNAMIC_FLAGS=$(LDXX_DYNAMIC_FLAGS_$(LDXX_DYNAMIC_BASENAME)_BUILD_$(BUILD_OS)) \
$(LDXX_DYNAMIC_FLAGS_$(LDXX_DYNAMIC_BASENAME)_TARGET_$(TARGET_OS))
# the distributed m4 doesn't handle -D command line arguments correctly,
# so we use the gnu one.
M4_CYGWIN := /bin/m4
M4_LINUX := /usr/bin/m4
M4 = $(M4_$(BUILD_OS))
RANLIB_CYGWIN := :
RANLIB_LINUX := :
RANLIB = $(RANLIB_$(BUILD_OS))
SORT_CYGWIN := /bin/sort
SORT_LINUX := /bin/sort
SORT = $(SORT_$(BUILD_OS))
MKDIR_CYGWIN := /bin/mkdir
MKDIR_LINUX := /bin/mkdir
MKDIR = $(MKDIR_$(BUILD_OS))
MKPATH = $(MKDIR) -p
ECHO_CYGWIN := /bin/echo
ECHO_LINUX := /bin/echo
ECHO = $(ECHO_$(BUILD_OS))
EXPR_CYGWIN := /bin/expr
EXPR_LINUX := /usr/bin/expr
EXPR = $(EXPR_$(BUILD_OS))
LS_CYGWIN := /bin/ls
LS_LINUX := /bin/ls
LS = $(LS_$(BUILD_OS))
TR_CYGWIN := /bin/tr
TR_LINUX := /usr/bin/tr
TR = $(TR_$(BUILD_OS))
LN_CYGWIN := /bin/ln
LN_LINUX := /bin/ln
LN = $(LN_$(BUILD_OS))
EGREP_CYGWIN := /bin/egrep
EGREP_LINUX := /bin/egrep
EGREP = $(EGREP_$(BUILD_OS))
HOSTNAME := $(HOST_NAME)
NM_CYGWIN := /bin/nm
NM_LINUX := /usr/bin/nm
NM = $(NM_$(BUILD_OS))
# since some of the perl packages we use fail
# to work under perl-5.6.0, on some linux boxes we
# install a later version that works in /usr/local/bin/perl.
# sigh...
PERL_CYGWIN := /usr/bin/perl
PERL_LINUX := /usr/bin/perl
PERL = $(PERL_$(BUILD_OS))
# PERL_INCLUDE is used for building swig projects providing perl interfaces
PERL_INCLUDE :=$(shell $(PERL) -e 'use Config; print "$$Config{archlib}/CORE";')
RSH_CYGWIN := /bin/rsh
RSH_LINUX := /bin/rsh
RSH = $(RSH_$(BUILD_OS))
# place for optionally installed software
# - no real criteria of what belongs here, since
# what is called optional is rarely is (optional)
# and optional may be included in the standard
# installation for a given system
SWIG_CYGWIN :=/usr/bin/swig
SWIG_LINUX :=/usr/local/bin/swig
SWIG = $(SWIG_$(BUILD_OS))
TEST_CYGWIN :=/usr/bin/test
TEST_LINUX :=/usr/bin/test
TEST = $(TEST_$(BUILD_OS))
DOXYGEN_CYGWIN :=
DOXYGEN_LINUX :=/usr/bin/doxygen
DOXYGEN = $(DOXYGEN_$(BUILD_OS))
#
# Java compilers and JVMs
#
# for convience we define the install path for sun javac
SUNJava14_HOME_CYGWIN :=c:/j2sdk1.4
SUNJava14_HOME_LINUX :=/usr/java/j2sdk1.4
SUNJava14_HOME :=$(SUNJava14_HOME_$(BUILD_OS))
# JAVAC
# - requires JAVA_COMPILER be one of:
# SUNJava14
# Do *not* use Jikes 1.13 -- it is broken.
#
ifeq "$(JAVA_COMPILER)" "SUNJava14"
JAVAC_CYGWIN :=$(SUNJava14_HOME)/bin/javac
JAVAC_LINUX :=$(SUNJava14_HOME)/bin/javac
JAVAC =$(JAVAC_$(BUILD_OS))
endif
ifeq "$(JAVAC)" ""
$(error JAVAC was left undefined, failed to find JAVA_COMPILER '$(JAVA_COMPILER)')
endif
# JAVA
# - requires JAVA_RUNTIME be one of:
# SUNJava14
#
ifeq "$(JAVA_RUNTIME)" "SUNJava14"
JAVA_CYGWIN :=$(SUNJava14_HOME)/bin/java
JAVA_LINUX :=$(SUNJava14_HOME)/bin/java
JAVA =$(JAVA_$(BUILD_OS))
endif
ifeq "$(JAVA)" ""
$(error JAVA was left undefined, failed to find JAVA_RUNTIME '$(JAVA_RUNTIME)')
endif
# JAVADOC
# - requires JAVADOC_RUNTIME be one of:
# SUNJava14
#
ifeq "$(JAVADOC_RUNTIME)" "SUNJava14"
JAVADOC_CYGWIN :=$(SUNJava14_HOME)/bin/javadoc
JAVADOC_LINUX :=$(SUNJava14_HOME)/bin/javadoc
JAVADOC =$(JAVADOC_$(BUILD_OS))
endif
ifeq "$(JAVADOC)" ""
$(error JAVADOC was left undefined, failed to find JAVADOC_RUNTIME '$(JAVADOC_RUNTIME)')
endif
# JAR
# - requires JAR_RUNTIME be one of:
# SUNJava14
#
ifeq "$(JAR_RUNTIME)" "SUNJava14"
JAR_CYGWIN :=$(SUNJava14_HOME)/bin/jar
JAR_LINUX :=$(SUNJava14_HOME)/bin/jar
JAR =$(JAR_$(BUILD_OS))
endif
ifeq "$(JAR)" ""
$(error JAR was left undefined, failed to find JAR_RUNTIME '$(JAR_RUNTIME)')
endif
# RT_JAR
# - requires RT_JAR be one of:
# SUNJava14
#
# JNI_INCLUDE
# - used for swig projects building jni interfaces
#
ifeq "$(RT_JAR)" "SUNJava14"
RT_JAR_HOME_CYGWIN :=$(SUNJava14_HOME)
RT_JAR_HOME_LINUX :=$(SUNJava14_HOME)
RT_JAR_HOME =$(RT_JAR_HOME_$(BUILD_OS))
JNI_INCLUDE_DIR :=$(SUNJava14_HOME)/include
endif
ifeq "$(RT_JAR_HOME)" ""
$(error RT_JAR_HOME was left undefined, failed to find RT_JAR '$(RT_JAR)')
endif
ifeq "$(JNI_INCLUDE_DIR)" ""
$(error JNI_INCLUDE_DIR was left undefined, check RT_JAR '$(RT_JAR)' defines)
endif
JNI_CPPFLAGS_CYGWIN :=-I$(JNI_INCLUDE_DIR)/win32
JNI_CPPFLAGS_LINUX :=-I$(JNI_INCLUDE_DIR)/linux
JNI_CPPFLAGS :=-I$(JNI_INCLUDE_DIR) $(JNI_CPPFLAGS_$(BUILD_OS))
# JAVAC compiler flags
#
# swap -O for -g for optimized
JAVAC_FLAGS_SUNJava14 :=-deprecation -encoding iso-8859-1 -source 1.4 -target 1.4 -g:none -g
JAVAC_FLAGS =$(JAVAC_FLAGS_$(JAVA_COMPILER))
JAVAC_CLASSPATH:=
JAVAC_SOURCEPATH=.
# define PROJECT_TOP in java runtime environment (mostly for testing utilites)
#JAVA_FLAGS =-DPROJECT_TOP=$(PROJECT_TOP) -DproxySet=true -DproxyHost=proxy -DproxyPort=3128
JAVA_FLAGS =-DPROJECT_TOP=$(PROJECT_TOP)
# Now add the remaining stuff
JAVA_CLASSPATH +=$(JAR_CLASSPATH)
# path to java sources
JAVA_SRCS_SOURCEPATH_CYGWIN :=$(RT_JAR_HOME)/src
JAVA_SRCS_SOURCEPATH_LINUX :=$(RT_JAR_HOME)/src
JAVA_SRCS_SOURCEPATH :=$(JAVA_SRCS_SOURCEPATH_$(BUILD_OS))
JAVADOC_FLAGS_13 := -link http://web.interdynamix.com/~release/java/jdk1.3/docs/api
JAVADOC_FLAGS_14 := -link http://web.interdynamix.com/~release/java/jdk1.4/docs/api -source 1.4
JAVADOC_FLAGS_SUNJava14 := $(JAVADOC_FLAGS_14)
JAVADOC_FLAGS_JIKES118 := $(JAVADOC_FLAGS_13)
JAVADOC_FLAGS = -use -private -splitIndex -version \
-windowtitle "Project libimdb API (`$(DATECMD)`)" \
-doctitle "Project libimdb API (build:`$(DATECMD)`)" \
-header 'Project libimdb API' \
-bottom 'Project libimdb API' \
$(JAVADOC_FLAGS_$(JAVA_COMPILER))
JAVADOC_SOURCEPATH =.
JAVADOC_CLASSPATH =
# binary extensions
EXE_CYGWIN :=
EXE_LINUX :=
EXE =$(EXE_$(BUILD_OS))
INSTALL :=$(PERL) $(COMPILE_BIN)/install.pl
INSTALLBIN :=$(INSTALL) -m755
INSTALLSCRIPT :=$(INSTALL) -m755
INSTALLFILE :=$(INSTALL) -m644
INSTALLDIR :=$(INSTALL) -d -m755
INSTALLBIN :=$(INSTALL)
INSTALLSCRIPT :=$(INSTALL)
INSTALLFILE :=$(INSTALL)
INSTALLDIR :=$(INSTALL) -d
ifeq "$(BUILDING_DYNAMIC)" "false"
INSTALLDYN :=@$(ECHO) "NOT installing"
else
INSTALLDYN :=@f() { \
dir=`$(DIRNAME) $$1`; \
base=`$(EXPR) $$1 : ".*/\([^.]*\)"`; \
ver=`$(EXPR) $$1 : ".*\.s[ao]\.\(.*\)"`; \
ver_M=`$(EXPR) $$ver : "\([^.]\)"`; \
ver_m=`$(EXPR) $$ver : ".*\([^.]\)"`; \
so=`$(EXPR) $$1 : ".*\.\(s[ao]\)\."`; \
$(ECHO) "$(INSTALLFILE) $$dir/$$base.$$so.$$ver $$2"; \
$(INSTALLFILE) $$dir/$$base.$$so.$$ver $$2 ; \
$(ECHO) "$(RM) -f $$2/$$base.$$so.$$ver_M" ; \
$(RM) -f $$2/$$base.$$so.$$ver_M; \
$(ECHO) "ln -s $$base.$$so.$$ver $$2/$$base.$$so.$$ver_M" ; \
ln -s $$base.$$so.$$ver $$2/$$base.$$so.$$ver_M; \
fi; }; f
endif
MYDYNAMIC_CYGWIN =$(BUILD_DIR)/$(LIB_BASE).$(SO)
MYDYNAMIC_LINUX =$(BUILD_DIR)/lib$(LIB_BASE).$(SO).$(LIB_VERSION)
MYDYNAMIC =$(MYDYNAMIC_$(BUILD_OS))
MYLIBRARY =$(BUILD_DIR)/lib$(LIB_BASE).$(A)
MYJAR =$(BUILD_DIR)/$(JAR_BASE).$(JAR)
#
# $(wildcard *.c *.cc) is empty if there are no files
# that match, as opposed to 'echo *.c *.cc'
# Also, we need to include GENERATED_SRCS for projects
# that have no other kind, otherwise, a program's dependencies
# will be empty.
#
SRCS.C =$(wildcard *.c)
SRCS.CC =$(wildcard *.cc *.cpp)
SRCS.L =$(wildcard *.l)
SRCS.Y =$(wildcard *.y)
SRCS.JAVA=$(wildcard *.java)
SRCS.PERLSWIG=$(wildcard *.perlswig)
SRCS.JAVASWIG=$(wildcard *.javaswig)
SRCS.JAVASWIGXX=$(wildcard *.javaswigxx)
GENERATED_SRCS =$(patsubst %.l, gen_$(BUILD_OS)/%.c, $(SRCS.L)) \
$(patsubst %.y, gen_$(BUILD_OS)/%.c, $(SRCS.Y)) \
$(patsubst %.perlswig, gen_$(BUILD_OS)/%_swig.c, $(SRCS.PERLSWIG)) \
$(patsubst %.javaswig, gen_$(BUILD_OS)/%_swig.c, $(SRCS.JAVASWIG)) \
$(patsubst %.javaswigxx, gen_$(BUILD_OS)/%_swig.cpp, $(SRCS.JAVASWIGXX))
GENERATED_HDRS =$(patsubst %.y, gen_$(BUILD_OS)/%.h, $(SRCS.Y))
GENERATED_JAVA_SRCS =
GENERATED_FILES = $(GENERATED_SRCS) $(GENERATED_HDRS)
# when all projects are using the guidelines for generated files
# (specifically, no generated files in the source directory), then
# we can remove the tr and sort -u.
#DEFAULT_SRCS = $(shell echo $(wildcard *.c *.cc) $(GENERATED_SRCS) | tr -s ' ' '\012' | $(SORT) -u)
DEFAULT_SRCS =$(wildcard *.c *.cc *.cpp) $(GENERATED_SRCS)
#
# get list of srcs we want
SRCS =$(DEFAULT_SRCS)
# we need the notdir to remove the gen_$(BUILD_OS) portion from the
# list of GENERATED_SRCS. The basename is used to remove
# all extensions.
OBJS =$(patsubst %, $(OBJS_DIR)/%.$(O), $(notdir $(basename $(SRCS))))
# default java sources to include in JAVAPACKAGE
JAVA_SRCS =$(wildcard *.java) $(GENERATED_JAVA_SRCS)
# create LIBS_LOCAL without the suffixes
LIBS_LOCAL =$(filter %.$(SO), $(LIBS)) $(filter %.$(A), $(LIBS))
__LIBS_LINK__ =\
set x $(LIBS); shift; \
for lib in $$*; do \
case $$lib in \
*.$(SO)) $(ECHO) "-l`$(EXPR) $$lib : '.*/lib\(.*\)\.$(SO)'`";; \
*) $(ECHO) $$lib;; \
esac; \
done
LDFLAGS_LINK =$(patsubst %/, -L%, $(dir $(filter %.$(SO), $(LIBS))))
# if compiler is NOT insure we remove the insure directived from the link line
ifeq "$(CC_COMPILER)" "insure"
LIBS_LINK =$(shell $(__LIBS_LINK__))
else
LIBS_LINK =$(filter-out -Z%, $(shell $(__LIBS_LINK__)))
endif
# placing a value in MPATROL enables the use of
# mpatrol to check memory allocation.
ifdef MPATROL
ifeq "$(BUILD_OS)" "LINUX"
CPPFLAGS+=-DMPATROL
LIBS_LINK+=/usr/local/lib/libmpatrol.$(SO) -lbfd -liberty -ldl
else
$(error "MPATROL usage under OS=$(BUILD_OS) not yet suppored")
endif
endif
# don't put the dependency file in $(BUILD_DIR), because some projects
# have multiple directories sharing $(BUILD_DIR)
DEPEND_FILE =$(BUILD_BASE)/.dependencies
DEPEND_CC_CYGWIN :=/usr/bin/gcc
DEPEND_CC_LINUX :=/usr/bin/gcc
DEPEND_CC=$(DEPEND_CC_$(BUILD_OS))
DEPEND_CC_BASENAME=$(subst $(plus),x,$(notdir $(basename $(DEPEND_CC))))
#
# WARNING:we re-use DEPEND_CC here
#
DEPEND_CXX=$(DEPEND_CC_$(BUILD_OS))
DEPEND_CXX_BASENAME=$(subst $(plus),x,$(notdir $(basename $(DEPEND_CXX))))
DEPEND_CPPFLAGS_CC_gcc :=-MM
DEPEND_CPPFLAGS_CC_BUILD_gcc :=
DEPEND_CPPFLAGS_CC_TARGET_gcc_MINGW :=-mno-cygwin
DEPEND_CPPFLAGS_CC =$(DEPEND_CPPFLAGS_CC_$(DEPEND_CC_BASENAME)) \
$(DEPEND_CPPFLAGS_CC_BUILD_$(DEPEND_CC_BASENAME)) \
$(DEPEND_CPPFLAGS_CC_TARGET_$(DEPEND_CC_BASENAME)) \
$(DEPEND_CPPFLAGS_CC_TARGET_$(DEPEND_CC_BASENAME)_$(TARGET_OS))
DEPEND_CPPFLAGS_CXX_gcc :=-MM
DEPEND_CPPFLAGS_CXX_BUILD_gxx :=
DEPEND_CPPFLAGS_CXX_TARGET_gcc_MINGW :=-mno-cygwin
DEPEND_CPPFLAGS_CXX =$(DEPEND_CPPFLAGS_CXX_$(DEPEND_CXX_BASENAME)) \
$(DEPEND_CPPFLAGS_CXX_BUILD_$(DEPEND_CXX_BASENAME)) \
$(DEPEND_CPPFLAGS_CXX_TARGET_$(DEPEND_CXX_BASENAME)) \
$(DEPEND_CPPFLAGS_CXX_TARGET_$(DEPEND_CXX_BASENAME)_$(TARGET_OS))
#
# These are used by 'make install' related operations
#
INSTALL_BINDIR = $(INSTALL_ROOT)/bin
INSTALL_ETCDIR = $(INSTALL_ROOT)/etc
INSTALL_LIBDIR = $(INSTALL_ROOT)/lib
# These adjust the default target when you define PROGRAM, LIBRARY or DYNAMIC
# so that you can do this:
# $(MAKE) PROGRAM=x
# instead of this:
# $(MAKE) $(PROGRAM) PROGRAM=x
ifdef PROGRAM
$(PROGRAM):
endif
ifdef LIBRARY
$(LIBRARY):
endif
ifdef DYNAMIC
$(DYNAMIC):
endif
#
# List of JARs available in the system
#
3RD_PARTY_JAR_PATH =$(PROJECT_TOP)/lib/java
ALL_3RD_PARTY_JARS =
--- NEW FILE: rules.mk ---
#
# $Id: rules.mk,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
.DELETE_ON_ERROR:
clean::
@if [ "$(OBJS)" != "" ] ; then \
echo "$(RM) -f $(OBJS)"; \
$(RM) -f $(OBJS) ;\
fi
@rm -f *~
clobber:: clean
ifneq "$(LIB_BASE)" ""
$(RM) -rf $(MYLIBRARY) $(MYDYNAMIC) $(basename $(MYDYNAMIC)) $(basename $(basename $(MYDYNAMIC)))
endif
$(RM) -rf $(BUILD_CFG) gen_$(BUILD_OS)
oldclobber:
depend::
$(RM) -f $(DEPEND_FILE) $(DEPEND_FILE)-*
install: build
playpen::
@true
ifeq "$(BUILDING_DYNAMIC)-$(OBJS_TYPE)" "false-DYNAMIC"
objs:; @$(ECHO) NOT building dynamic objs
else
objs: $(OBJS)
endif
$(DEPEND_FILE): $(GENERATED_FILES)
@[ -d $(@D) ] || $(MKPATH) $(@D)
@$(ECHO) "generating $@.."
ifeq ($(strip $(DEFAULT_SRCS)),)
$(TOUCH) $@
else
@for f in X $(DEFAULT_SRCS); do \
[ "$$f" = X ] && continue; \
case $$f in \
*.cc) $(DEPEND_CXX) $(CPPFLAGS) $(DEPEND_CPPFLAGS_CXX) $$f;; \
*.cpp) $(DEPEND_CXX) $(CPPFLAGS) $(DEPEND_CPPFLAGS_CXX) $$f;; \
*.c) $(DEPEND_CC) $(CPPFLAGS) $(DEPEND_CPPFLAGS_CC) $$f;; \
*) $(ECHO) "rules.mk: missing case statement for file type (example:$$f)" && exit 1;; \
esac; \
done | $(SED) -e 's/\.o:/\.$(O):/' -e '/^[^ ]/s,^,$$(OBJS_DIR)/,' > $@
endif
@[ "$(SRCS.SWIG)" = "" ] || $(PERL) $(COMPILE_BIN)/swigdepend.pl $(CPPFLAGS) $(SRCS.SWIG) >> $@
ifdef PROGRAM
INCLUDE_DEPENDENCIES = TRUE
ifeq "$(findstring .cpp,$(SRCS))$(findstring .cc,$(SRCS))" ""
MYLINKER_CMD=$(LD)
else
MYLINKER_CMD=$(LDXX)
endif
$(PROGRAM): $(OBJS) $(LIBS_LOCAL) Makefile
@[ -d $(@D) ] || $(MKPATH) $(@D)
LD_LIBRARY_PATH="" $(MYLINKER_CMD) $(LDFLAGS) $(LDFLAGS_LINK) -o $@ $(OBJS) $(LIBS_LINK)
endif
####################################f###################################
# define:
# LIB_BASE=mylibrary
# use:
# $(MAKE) $(MYLIBARY) LIBARY=$(MYLIBARY)
#
ifdef LIBRARY
INCLUDE_DEPENDENCIES = TRUE
$(LIBRARY): $(OBJS) Makefile
@[ -d $(@D) ] || $(MKPATH) $(@D)
$(RM) -f $(LIBRARY)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(RANLIB) $@
endif
####################################f###################################
# define:
# LIB_BASE=mylibrary
# LIB_VERSION=1.0
# use:
# $(MAKE) $(MYDYNAMIC) DYNAMIC=$(MYDYNAMIC)
#
ifdef DYNAMIC
ifeq "$(BUILDING_DYNAMIC)" "true"
INCLUDE_DEPENDENCIES = TRUE
ifeq "$(findstring .cpp,$(SRCS))$(findstring .cc,$(SRCS))" ""
MYLINKER_CMD=$(LD_DYNAMIC) $(LD_DYNAMIC_FLAGS)
else
MYLINKER_CMD=$(LDXX_DYNAMIC) $(LDXX_DYNAMIC_FLAGS)
endif
$(DYNAMIC): $(OBJS) Makefile $(OBJS_STA)
@[ -d $(@D) ] || $(MKPATH) $(@D);
LD_LIBRARY_PATH="" $(MYLINKER_CMD) $(LDFLAGS) $(LDFLAGS_LINK) -o $@ $(OBJS) $(LIBS_LINK) && \
if [ "$(BUILD_OS)" = "LINUX" ]; then \
$(RM) -f $(basename $(basename $@)) $(basename $@); \
$(LN) -s $(@F) $(basename $(basename $@)); \
$(LN) -s $(@F) $(basename $@); \
fi
else
$(DYNAMIC):; @$(ECHO) NOT building $@;
endif
endif
#
# generate wrapper for JAVA runtime for non-make usage
#
$(PROJECT_TOP)/gen/runjava: $(PROJECT_TOP)/constants.mk $(PROJECT_TOP)/config.mk $(PROJECT_TOP)/rules.mk
@$(ECHO) "generating $@.."
@[ -d $(@D) ] || $(MKPATH) $(@D)
@$(ECHO) '$(JAVA) $(JAVA_FLAGS) -classpath "$(subst $(space),$(CLASSPATH_SEP),$(strip $(JAVASRCS_CLASSES_DEST) $(JAVA_CLASSPATH)) $(ALL_3RD_PARTY_JARS) $$CLASSPATH)" "$$@"' > $@
@$(CHMOD) +x $@
#
# generate something useful for java classes like EtherProgram to parse
# and understand how to invoke a controlable (ha) jvm child process
#
#
$(PROJECT_TOP)/gen/jvm.config: $(PROJECT_TOP)/constants.mk $(PROJECT_TOP)/config.mk $(PROJECT_TOP)/rules.mk
@$(ECHO) "generating $@.."
@[ -d $(@D) ] || $(MKPATH) $(@D)
@($(ECHO) "# This file is provided for java classes who";\
$(ECHO) "# want to invoke a controlable (ha) jvm child process";\
$(ECHO) "# access to the JAVAC command line that otherwise only" ;\
$(ECHO) "# Warning:format is compatible with CmdLine class, not shell usage";\
$(ECHO) "JDB_PATHNAME $(JDB)";\
$(ECHO) "JDB_STANDARD_FLAGS $(JDB_FLAGS)";\
$(ECHO) "JVM_PATHNAME $(JAVA)";\
$(ECHO) "JVM_STANDARD_FLAGS $(JAVA_FLAGS)";\
$(ECHO) "JVM_STANDARD_CLASSPATH $(subst $(space),$(CLASSPATH_SEP),$(strip $(JAVASRCS_CLASSES_DEST) $(JAVA_CLASSPATH)) $$CLASSPATH)" )> $@
@$(CHMOD) +r $@
#
# generate wrapper for JAVAC runtime for non-make usage
# see comments for more details
#
$(PROJECT_TOP)/gen/runjavac: $(PROJECT_TOP)/constants.mk $(PROJECT_TOP)/config.mk $(PROJECT_TOP)/rules.mk
@$(ECHO) "generating $@.."
@[ -d $(@D) ] || $(MKPATH) $(@D)
@($(ECHO) "# This script is generated during a 'make' to provide" ;\
$(ECHO) "# access to the JAVAC command line that otherwise only" ;\
$(ECHO) "# make' would have acess to." ;\
$(ECHO) "# " ;\
$(ECHO) "# Typical usage include providing a '-d <dir>' and a" ;\
$(ECHO) "# list of classes to compile, but not required." ;\
$(ECHO) '$(JAVAC) $(JAVAC_FLAGS) -sourcepath . -classpath "$(subst $(space),$(CLASSPATH_SEP),$(strip $(JAVASRCS_CLASSES_DEST) $(JAVAC_CLASSPATH)) $$CLASSPATH)" "$$@"' ) > $@
@$(CHMOD) +x $@
#
# generate wrapper for PERL runtime for non-make usage
#
$(PROJECT_TOP)/gen/runperl: $(PROJECT_TOP)/constants.mk $(PROJECT_TOP)/config.mk $(PROJECT_TOP)/rules.mk
@$(ECHO) "generating $@.."
@[ -d $(@D) ] || $(MKPATH) $(@D)
@($(ECHO) "# This script is generated during a 'make' to provide" ;\
$(ECHO) "# an easy way to invoke the perl run-time as defined in constants.mk" ;\
$(ECHO) "# without all having to use make to get things done." ;\
$(ECHO) "# " ;\
$(ECHO) '$(PERL) -I$(PROJECT_TOP)/lib/perl "$$@"') > $@
@$(CHMOD) +x $@
$(OBJS_DIR)/%.$(O): gen_$(BUILD_OS)/%.c
@[ -d $(@D) ] || $(MKPATH) $(@D)
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(OBJS_DIR)/%.$(O): %.c
@[ -d $(@D) ] || $(MKPATH) $(@D)
$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
$(OBJS_DIR)/%.$(O): %.cc
@[ -d $(@D) ] || $(MKPATH) $(@D)
$(CXX) -c $(CCFLAGS) $(CPPFLAGS) -o $@ $<
$(OBJS_DIR)/%.$(O): %.cpp
@[ -d $(@D) ] || $(MKPATH) $(@D)
$(CXX) -c $(CCFLAGS) $(CPPFLAGS) -o $@ $<
#
# Generated sources:
#
gen_$(BUILD_OS)/%.c \
gen_$(BUILD_OS)/%.h: %.y
@[ -d $(@D) ] || $(MKDIR) $(@D)
$(BISON) -d -o gen_$(BUILD_OS)/$*.c $<
gen_$(BUILD_OS)/%.c: %.l
@[ -d $(@D) ] || $(MKDIR) $(@D)
$(LEX) $(LEXFLAGS) $< > $@
ifdef INCLUDE_DEPENDENCIES
include $(DEPEND_FILE)
endif
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/include/jlog
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/include/jlog
Added Files:
Makefile dic.errors jlog.h jlog2File.h jlogTracker.h mklog.pl
par.errors
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
include ../../config.mk
include ../../constants.mk
GENERATED_HDRS := $(patsubst %.errors, %err.h, $(wildcard *.errors))
TEMPFILE = .tmpf-$(OS)
# to make clean/clobber targets in rules.mk happy
OBJS = $(TEMPFILE)
build: $(GENERATED_HDRS)
%err.h: %.errors mklog.pl Makefile
$(PERL) mklog.pl $* $< > $(TEMPFILE)
$(CMP) -s $(TEMPFILE) $@ || $(MV) $(TEMPFILE) $@
clobber::
$(RM) -f $(GENERATED_HDRS)
include ../../rules.mk
--- NEW FILE: dic.errors ---
DICE_BAD_MEM "memory failed"
DICE_FILE_OPEN "open %s failed (%s)"
--- NEW FILE: jlog.h ---
/**
@file
The jlog library provides a consistant and reliable logging mechanism for
critical error, general error, warning and debugging messages.
It is designed to be easy to use, and to take advantage of compiler
options to minimize coding errors. For instance using ansi declarations
and the use of #defines to wrap var-arg entry points.
The jlog library supports the concept of modules so that levels and
details of logging are managed on a per-module basis.
Modules are defined statically in an enumeration (@see jlogmod_e) to
ensure uniquiness (and quicker execution within the jlog library).
Typically, but not neccessarily, each modules' messages to the jlog
library are generated by defining a message definition file.
This helps enumerate possible jlog messages (critical, error and
warnings) and promptes proper error tracking, further simplifies the
jlog interface and message re-use within a module. See jlog/jlog/mklog.pl
for details on how to use.
@todo can the return code of one jlogCallbackHandle effect if the rest
get called ?
@todo ENTER/SUCCESS/FAILURE macros should have compile time option for disabling
each individually.
@todo should have simple clone() function or somehow be able to temperarily
disable all error/warning reporting etc during clean-up code (see todo in swtable.c)
@verbatim $Id: jlog.h,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $ @endverbatim
*/
#ifndef JLOG_H
# define JLOG_H
/** @enum jlogmod_e
* one for each logical "module".
*/
typedef enum {
MOD_NONE=0, /**< must be first */
MOD_JLG=1, /**< libjlog */
MOD_PAR=2, /**< libimdb parser */
MOD_DIC=3, /**< libimdb dict */
MOD_ALL=4 /**< must be last */
} jlogModule_e;
/**
* @enum jlogReportLevel_e
* Four levels of logging.
*/
typedef enum {
JLOGT_DEBUG=2, /**< debug message */
JLOGT_ERROR=1, /**< error message */
JLOGT_CRITICAL=0, /**< critical error message */
} jlogReportLevel_e;
#ifndef SWIG
typedef struct jlog_s jlogHandle_t;
/* this should be jlog_Complex_callback_t */
typedef void (jlog_eventCallback_t)(jlogHandle_t *logh, const char *srcfile, const char *srcfunc,
int srcline, jlogModule_e module, jlogReportLevel_e jlogReportLevel,
int messageNumber, const char *messageText, void *cb_extra);
#endif
/**
* typedef for callbacks from the jlog library.
*/
jlogHandle_t *
jlog_openMain(jlogHandle_t *reuseh, const char *file, const char *function, int lineno);
#define jlog_open(reuseh) jlog_openMain(reuseh, __FILE__, __FUNC__, __LINE__)
#define jlog_openNew() jlog_openMain(NULL, __FILE__, __FUNC__, __LINE__)
int
jlog_close(jlogHandle_t *logh);
#ifdef SWIGJAVA
%apply char **MYSTATIC_STRING_ARRAY_RET {char **jlog_getModuleShortNames}
#endif
char **jlog_getModuleShortNames(const jlogHandle_t *logh);
#ifdef SWIGJAVA
%clear char **jlog_getModuleShortNames;
#endif
#ifndef SWIGJAVA
/** @todo we should support multiple of these
* and return code should determine if next one gets called etc
* should create a callback definition, define userdata, define callback
* level
*/
typedef struct jlogCallbackHandle_s jlogCallbackHandle_t;
jlogCallbackHandle_t *
jlogCallback_create(jlog_eventCallback_t *cb, void *userdata);
void
jlogCallback_destroy(jlogCallbackHandle_t *l);
int
jlogCallback_setNotificationLevel(jlogCallbackHandle_t *cbHandle,
jlogModule_e module,
jlogReportLevel_e level);
int
jlog_registerEventCallback(jlogHandle_t *logh,
jlogCallbackHandle_t *cb);
int
jlog_unregisterEventCallback(jlogHandle_t *logh,
jlogCallbackHandle_t *cb);
#endif /* SWIGJAVA */
jlogModule_e
jlog_messageModule(const jlogHandle_t *logh, jlogReportLevel_e level);
int
jlog_messageNumber(const jlogHandle_t *logh, jlogReportLevel_e level);
/** clear the message stack, set jlog_errmodule to MOD_NONE,
* and jlog_messageNumber to 0
*/
int
jlog_reset(jlogHandle_t *logh);
/**
* enable/disable enter exit calls for a given module
*/
int
jlog_setModuleDebugEnterExit(jlogHandle_t *logh, jlogModule_e module, int on);
/**
* enable/disable enter exit calls for all modules
*/
int
jlog_setAllModuleDebugEnterExit(jlogHandle_t *logh, int on);
#ifndef SWIG
/**
* @def MAXJLOGMSGLEN
* For performance reasons, we statically define maximum message length at compile time.
*/
#define MAXJLOGMSGLEN (4048)
#endif /* SWIG */
#ifndef __GNUC__
/**
* @def __attribute__
* undefine unless we're using a gnuc compiler
*/
#define __attribute__(def)
#endif
#if defined(_USE_STDARG)
int
jlog_fmt_arglist(jlogHandle_t *logh, jlogReportLevel_e jlogReportLevel, jlogModule_e module, int messageNumber,
const char *srcfile, const char *srcfunc, int srcline, const char *fmt, va_list ap);
/** @def JLOG_FMT_ARG
* convenience macro calling jlog_fmt_arglist with proper compile time location
* information.
*/
#define JLOG_FMT_ARG(jlogh, jlogReportLevel, module, messageNumber, fmt, ap) \
jlog_fmt_arglist(jlogh, jlogReportLevel, module, messageNumber, __FILE__, __FUNC__, __LINE__, fmt, ap)
#endif
#ifndef SWIG
int
jlog_fmt(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module, int messageNumber,
const char *srcfile, const char *srcfunc, int srcline, const char *fmt, ...);
/**
* @def jlog_msg
* wrapper for calling jlog_fmt_arglist with no args.
*/
#define jlog_msg(jlogh, jlogReportLevel, module, messageNumber, srcfile, srcfunc, srcline, fmt) \
(jlog_fmt(jlogh, jlogReportLevel, module, messageNumber, srcfile, srcfunc, srcline, fmt, NULL))
#endif /* SWIG */
int
jlog_fmtfile(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module, int messageNumber,
const char *srcfile, const char *srcfunc, int srcline, const char *file);
#ifndef SWIG
/** @def JLOG_FMT
* convenience macro calling jlog_fmtfile with proper compile time location information.
*/
#define JLOG_FMTFILE(jlogh, jlogReportLevel, module, messageNumber, file) \
jlog_fmtfile(jlogh, jlogReportLevel, module, messageNumber, __FILE__, __FUNC__, __LINE__, file)
/** @def JLOG_FMT
* convenience macro calling jlog_fmt with proper compile time location information.
*/
#define JLOG_FMT(jlogh, jlogReportLevel, module, mess) \
jlog_msg(jlogh, jlogReportLevel, module, -1, __FILE__, __FUNC__, __LINE__, mess)
/* Critical Macros ;) */
/** @def JLOG_CRITICAL
* jlog a critical message associated with the given module.
*/
#define JLOG_CRITICAL(jlogh, module, mess) \
jlog_msg(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_CRITICAL1
* jlog a critical message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_CRITICAL1(jlogh, module, fmt, a1) \
jlog_fmt(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_CRITICAL2
* jlog a critical message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_CRITICAL2(jlogh, module, fmt, a1, a2) \
jlog_fmt(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1, a2)
/** @def JLOG_CRITICAL3
* jlog a critical message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_CRITICAL3(jlogh, module, fmt, a1, a2, a3) \
jlog_fmt(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1, a2, a3)
/* ERR Macros */
/** @def JLOG_ERROR
* jlog an error message associated with the given module.
*/
#define JLOG_ERROR(jlogh, module, errn, mess) \
jlog_msg(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_ERROR1
* jlog an error message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_ERROR1(jlogh, module, errn, fmt, a1) \
jlog_fmt(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_ERROR2
* jlog an error message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_ERROR2(jlogh, module, errn, fmt, a1, a2) \
jlog_fmt(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, fmt, a1, a2)
/** @def JLOG_ERROR3
* jlog an error message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_ERROR3(jlogh, module, errn, fmt, a1, a2, a3) \
jlog_fmt(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, fmt, a1, a2, a3)
/** @def JLOG_WARNING
* jlog a warning message associated with the given module.
*/
#define JLOG_WARNING(jlogh, module, mess) \
jlog_msg(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_WARNING1
* jlog a warning message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_WARNING1(jlogh, module, fmt, a1) \
jlog_fmt(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_WARNING2
* jlog a warning message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_WARNING2(jlogh, module, fmt, a1, a2) \
jlog_fmt(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_WARNING3
* jlog a warning message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_WARNING3(jlogh, module, fmt, a1, a2, a3) \
jlog_fmt(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1, a2, a3)
/* DEBUG Macros */
/** @def JLOG_DBG_FILE
* jlog the contents of a file as debug message for a given module.
*/
#define JLOG_DBG_FILE(jlogh, module, file) \
JLOG_FMTFILE(jlogh, JLOGT_DEBUG, module, -1, file)
/** @def JLOG_DBG
* jlog a debug message associated with the given module.
*/
#define JLOG_DBG(H, mod, mess) \
jlog_msg(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_DBG0
* jlog a debug message associated with the given module.
*/
#define JLOG_DBG0(H, mod, mess) JLOG_DBG(H, mod, mess)
/** @def JLOG_DBG1
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG1(H, mod, f, a1) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1)
/** @def JLOG_DBG2
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG2(H, mod, f, a1, a2) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2)
/** @def JLOG_DBG3
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG3(H, mod, f, a1, a2, a3) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3)
/** @def JLOG_DBG4
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG4(H, mod, f, a1, a2, a3, a4) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4)
/** @def JLOG_DBG5
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG5(H, m, f, a1, a2, a3, a4, a5) \
jlog_fmt(H, JLOGT_DEBUG, m, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4,a5)
/** @def JLOG_DBG6
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG6(H, m, f, a1, a2, a3, a4, a5, a6) \
jlog_fmt(H, JLOGT_DEBUG, m, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4,a5,a6)
/** @def JLOG_DBG9
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG9(H, m, f, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
jlog_fmt(H, JLOGT_DEBUG, m, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
/**
* @def JLOG_DEBUG
* nice for development, module-independent debugging to default jlogging factilites.
* set environment variable JLOG_DEBUG_LEVEL to "-:+MOD_ALL"
*/
#define JLOG_DEBUG(H,M,f)\
JLOG_DBG0(H,M,f)
#define JLOG_DEBUG0(H,M,f)\
JLOG_DBG0(H,M,f)
#define JLOG_DEBUG1(H,M,f,a1)\
JLOG_DBG1(H,M,f,a1)
#define JLOG_DEBUG2(H,M,f,a1,a2)\
JLOG_DBG2(H,M,f,a1,a2)
#define JLOG_DEBUG3(H,M,f,a1,a2,a3)\
JLOG_DBG3(H,M,f,a1,a2,a3)
#define JLOG_DEBUG4(H,M,f,a1,a2,a3,a4)\
JLOG_DBG4(H,M,f,a1,a2,a3,a4)
#define JLOG_DEBUG5(H,M,f,a1,a2,a3,a4,a5)\
JLOG_DBG5(H,M,f,a1,a2,a3,a4,a5)
#define JLOG_DEBUG6(H,M,f,a1,a2,a3,a4,a5,a6)\
JLOG_DBG6(H,M,f,a1,a2,a3,a4,a5,a6)
#define JLOG_DEBUG7(H,M,f,a0,a1,a2,a3,a4,a5,a6)\
JLOG_DEBUG7(H,M,f,a0,a1,a2,a3,a4,a5,a6)
#define JLOG_DEBUG8(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7)\
JLOG_DEBUG8(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7)
#define JLOG_DEBUG9(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8)\
JLOG_DEBUG9(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8)
#define JLOG_DEBUG10(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
JLOG_DEBUG10(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)
#define JLOG_DEBUG11(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)\
JLOG_DEBUG11(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
#define JLOG_DEBUG12(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)\
JLOG_DEBUG12(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
/**
* @def JLOG_DEBUG_G
* these are here to ease use of the default jlog facilities for debugging
*/
#define JLOG_DEBUG_G(f) JLOG_DEBUG0(NULL, MOD_ALL, f)
#define JLOG_DEBUG0_G(f) JLOG_DEBUG0(NULL, MOD_ALL, f)
#define JLOG_DEBUG1_G(f,a1) JLOG_DEBUG1(NULL, MOD_ALL, f,a1)
#define JLOG_DEBUG2_G(f,a1,a2) JLOG_DEBUG2(NULL, MOD_ALL, f,a1,a2)
#define JLOG_DEBUG3_G(f,a1,a2,a3) JLOG_DEBUG3(NULL, MOD_ALL, f,a1,a2,a3)
#define JLOG_DEBUG4_G(f,a1,a2,a3,a4) JLOG_DEBUG4(NULL, MOD_ALL, f,a1,a2,a3,a4)
#define JLOG_DEBUG5_G(f,a1,a2,a3,a4,a5) JLOG_DEBUG5(NULL, MOD_ALL, f,a1,a2,a3,a4,a5)
#define JLOG_DEBUG6_G(f,a1,a2,a3,a4,a5,a6) JLOG_DEBUG6(NULL, MOD_ALL, f,a1,a2,a3,a4,a5,a6)
int
jlog_enter(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module,
const char *srcfile, int srcline, const char *srcfunc, ...);
int
jlog_success(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module,
const char *srcfile, int srcline, const char *srcfunc, ...);
int
jlog_failure(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module,
const char *srcfile, int srcline, const char *srcfunc, ...);
/** @def JLOG_ENTER
* @todo - JLOG_ENTER macros could use # special operator so the type arguments
* don't have to be strings.
*/
#define JLOG_ENTER(H, m) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
NULL)
#define JLOG_ENTER0(H, m) JLOG_ENTER(H, m)
#define JLOG_ENTER1(H, m, t1, v1) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, NULL)
#define JLOG_ENTER2(H, m, t1, v1, t2, v2) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, NULL)
#define JLOG_ENTER3(H, m, t1, v1, t2, v2, t3, v3) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, NULL)
#define JLOG_ENTER4(H, m, t1, v1, t2, v2, t3, v3, t4, v4) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, NULL)
#define JLOG_ENTER5(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, NULL)
#define JLOG_ENTER6(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, NULL)
#define JLOG_ENTER7(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, NULL)
#define JLOG_ENTER8(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, NULL)
#define JLOG_ENTER9(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9, NULL)
/** @todo note in programming guidelines about how to use JLOG_FAILURE and
* JLOG_SUCCESS along with CRTE_BAD_MEM_FAILURE macros
*/
#define JLOG_FAILURE(H, MODULE, TYPE, VALUE) \
{TYPE __jlog_failure_macro_ret=(VALUE); \
jlog_failure(H, JLOGT_DEBUG, MODULE, __FILE__, __LINE__, __FUNC__, #TYPE, __jlog_failure_macro_ret, NULL); \
return(__jlog_failure_macro_ret);}
#define JLOG_SUCCESS(H, MODULE, TYPE, VALUE) \
{TYPE __jlog_success_macro_ret=(VALUE); \
jlog_success(H, JLOGT_DEBUG, MODULE, __FILE__, __LINE__, __FUNC__, #TYPE, __jlog_success_macro_ret, NULL);\
return(__jlog_success_macro_ret);}
#endif /* SWIG */
#endif /* JLOG_H */
--- NEW FILE: jlog2File.h ---
/**
* @file
*
* simple logCallbackHandle enabled module that logs to a file.
*/
typedef struct jlog2File_s jlog2File_t;
jlog2File_t *
jlog2File_create(char *filename);
int
jlog2File_destroy(jlog2File_t *lt);
int
jlog2File_enable(jlog2File_t *lt);
int
jlog2File_disable(jlog2File_t *lt);
char *
jlog2File_getFilename(jlog2File_t *lt);
jlogCallbackHandle_t *
jlog2File_getJLogCallbackHandle(jlog2File_t *lt);
--- NEW FILE: jlogTracker.h ---
/**
* @file
*
* Simple log tracker class for logging to memory.
*
* @todo LOG_DEBUG env variable should support file/function regexp match.
*
*/
typedef struct jlogTracker_s jlogTracker_t;
jlogTracker_t *
jlogTracker_create(void);
jlogReportLevel_e
jlogTracker_setLevel(jlogTracker_t *lt, jlogReportLevel_e level);
void
jlogTracker_reset(jlogTracker_t *lt);
int
jlogTracker_getCount(jlogTracker_t *lt);
int
jlogTracker_getMessageDetails(jlogTracker_t *lt,
int messageIndex,
char **srcfile,
char **srcfunc,
int *srcline,
jlogModule_e *module,
jlogReportLevel_e *reportLevel,
int *messageNumber,
char **messageText);
jlogCallbackHandle_t *
jlogTracker_getJLogCallbackHandle(jlogTracker_t *lt);
--- NEW FILE: mklog.pl ---
#! /usr/local/bin/perl -w
#
# This script preprocesses the messages defined for a
# single module. The first argument is the name of module (ie sys).
# The second argument (or stdin by default) is the file that
# defines the errorTable for the specified module.
#
# An errorTable is a file with two columns, for example:
# SYSE_GENERAL_ERROR "general error: %s"
# SYSC_GENERAL_CRITICAL "critical message: %s"
# SYSD_GENERAL_DEBUG "general debug message: %s"
#
# For a given module, the module prefix (SYS in this example)
# must appear in log.h header enumeration logmod_e (MOD_SYS).
#
# The output consists of #defines macros that translate the table into
# appropriate calls to log_fmt() that includes the required arguments
# (ie accounts for %s, %d etc in second column strings).
#
# The E_, W_, C_, and D_ cause the second argument to jlog_fmt call
# to be JLOGT_ERROR, JLOGT_CRITICAL and JLOGT_DEBUG as
# appropriate.
#
# The names of the output macros are the first column entry followed
# by _F. So for example, the SYSE_GENERAL_ERROR entry above would appear
# as:
# #define SYSE_GENERAL_ERROR_F(H, a1) \
# jlog_fmt(H, JLOGT_ERROR, MOD_SYS, SYSE_GENERAL_ERROR, \
# __FILE__, __FUNCTION__, __LINE__, "general error: %s", a1);
#
# nice huh ? now you can get some compilers to check you specified a
# valid argument to the macro.
#
# Also as output, a single enumeration that includes all the column 1
# entries, along with a macro for calling jlog_errno() and casting the
# return value to the enumeration.
#
use strict;
my $usage = "usage: $0 moduleName [errorTable]\n";
# errorTable is a file with two columns, eg.
# PRVE_NO_ERROR "error message"
# PRVC_NO_ERROR "critical message"
# PRVD_NO_ERROR "debug message"
my $moduleName = shift || die($usage);
$moduleName = uc($moduleName);
print "#ifndef ${moduleName}_ERROR_H\n";
print "#define ${moduleName}_ERROR_H\n";
print "\n/* for convience */\n#include \"jlog/jlog.h\"\n\n";
my @errors;
my @criticals;
my @debugs;
print "/* convience, so code reads consistant with _FAIL macros */\n";
print "#define ${moduleName}_SUCCESS(H, TYPE, VALUE) JLOG_SUCCESS(H, MOD_$moduleName, TYPE, VALUE)\n\n";
print "#define ${moduleName}_FAILURE(H, TYPE, VALUE) JLOG_FAILURE(H, MOD_$moduleName, TYPE, VALUE)\n";
while (<>) {
chomp;
if ( !m/^$moduleName/o ) {
print "$_\n";
next;
}
my ($name, $msg) = split(' ', $_, 2);
# count % escapes, don't forget about %% though:
my $count = ($msg =~ s/(%.)/$1/g) - ($msg =~ s/(%%)/$1/g);
my $args = "";
for (my $i = 0; $i < $count; $i += 1) {
$args .= ", a$i";
}
my $type;
my $errno;
if ( $name=~m/^${moduleName}E_/o ) {
$type="JLOGT_ERROR";
$errno=$name;
push(@errors, $name);
} elsif ( $name=~m/^${moduleName}C_/o ) {
$type="JLOGT_CRITICAL";
$errno=$name;
push(@criticals, $name);
} elsif ( $name=~m/^${moduleName}D_/o ) {
$type="JLOGT_DEBUG";
$errno=$name;
push(@debugs, $name);
}
print "#define ${name}_F(H$args)\\\n";
print "\tjlog_fmt(H, $type, MOD_$moduleName, $errno, __FILE__, __FUNC__, __LINE__, ".$msg."$args)\n";
if ( $type eq "JLOGT_ERROR" ||
$type eq "JLOGT_CRITICAL" ) {
print "#define ${name}_FAILURE(H$args, TYPE, VALUE)\\\n";
print "\t{${name}_F(H$args); JLOG_FAILURE(H, MOD_$moduleName, TYPE, VALUE);}\n\n";
}
print "\n";
}
my $number=0;
if ( @criticals ) {
print "\ntypedef enum {\n";
for (@criticals) {
print " $_=$number,\n";
$number++;
}
print "} ${moduleName}critical_e;\n";
}
else {
print "\n/* no criticals, so enumeration becomes an int */\n";
print "typedef int ${moduleName}critical_e;\n";
}
if ( @errors ) {
print "\ntypedef enum {\n";
for (@errors) {
print " $_=$number,\n";
$number++;
}
print "} ${moduleName}error_e;\n";
}
else {
print "\n/* no errors, so enumeration becomes an int */\n";
print "typedef int ${moduleName}error_e;\n";
}
if ( @debugs ) {
print "\ntypedef enum {\n";
for (@debugs) {
print " $_=$number,\n";
$number++;
}
print "} ${moduleName}debug_e;\n";
}
else {
print "\n/* no debugs, so enumeration becomes an int */\n";
print "typedef int ${moduleName}debug_e;\n";
}
print "\n";
if ( @criticals && scalar(@criticals) == 1 ) {
print "#define is${moduleName}criticalNumber(N)\t(N==".$criticals[0].")\n";
}
elsif ( @criticals && scalar(@criticals) > 1 ) {
print "#define is${moduleName}criticalNumber(N)\t(N>=".$criticals[0].
" && N<=".$criticals[scalar(@criticals)-1].")\n";
}
else {
print "#define is${moduleName}criticalNumber(N)\t(0)\n";
}
if ( @errors && scalar(@errors) == 1 ) {
print "#define is${moduleName}errorNumber(N)\t(N==".$errors[0].")\n";
}
elsif ( @errors && scalar(@errors) > 1 ) {
print "#define is${moduleName}errorsNumber(N)\t(N>=".$errors[0].
" && N<=".$errors[scalar(@errors)-1].")\n";
}
else {
print "#define is${moduleName}errorNumber(N)\t(0)\n";
}
if ( @debugs && scalar(@debugs) == 1 ) {
print "#define is${moduleName}debugNumber(N)\t(N==".$debugs[0].")\n";
}
elsif ( @debugs && scalar(@debugs) > 1 ) {
print "#define is${moduleName}debugsNumber(N)\t(N>=".$debugs[0].
" && N<=".$debugs[scalar(@debugs)-1].")\n";
}
else {
print "#define is${moduleName}debugNumber(N)\t(0)\n";
}
print "\n";
print "#define ${moduleName}criticalNumber(LOGH) (${moduleName}critical_e)jlog_messageNumber(LOGH, JLOGT_CRITICAL)\n";
print "#define ${moduleName}errorNumber(LOGH) (${moduleName}error_e)jlog_messageNumber(LOGH, JLOGT_ERROR)\n";
print "#define ${moduleName}debugNumber(LOGH) (${moduleName}debug_e)jlog_messageNumber(LOGH, JLOGT_DEBUG)\n";
print "\n";
print "#define ${moduleName}_DEBUG(H,f)\\\n";
print "\tjlog_msg(H,JLOGT_DEBUG,MOD_${moduleName},-1,__FILE__,__FUNC__,__LINE__,f)\n";
for (my $i=0; $i<=12 ; $i++) {
my $args=",";
for (my $j=0; $j<$i; $j++) {
$args.="a$j,";
}
chop($args);
print "#define ${moduleName}_DEBUG$i(H,f$args)\\\n";
print "\tjlog_fmt(H,JLOGT_DEBUG,MOD_${moduleName},-1,__FILE__,__FUNC__,__LINE__,f$args)\n";
}
print "\n";
print "#define ${moduleName}_ENTER(H)\\\n\tJLOG_ENTER0(H,MOD_${moduleName})\n";
for (my $i=0; $i<=10 ; $i++) {
my $args=",";
for (my $j=0; $j<$i; $j++) {
$args.="t$j,v$j,";
}
chop($args);
print "#define ${moduleName}_ENTER$i(H$args)\\\n\tJLOG_ENTER$i(H,MOD_${moduleName}$args)\n";
}
print "\n#endif /*${moduleName}_ERROR_H*/\n";
exit(0);
--- NEW FILE: par.errors ---
PARE_INVALID_ARGUMENT "invalid argument '%s'"
PARE_DIRECTORY_READ_FAILED "directory %s: does not exist"
PARE_BAD_MEM "memory failed"
PARE_READ_FAILED "file %s: read failed"
PARE_LIST_FILE_MISSING_INITIAL_SEPARATOR "%s missing start separator (%s)"
PARE_LIST_FILE_MISSING_FINAL_SEPARATOR "%s missing end separator (%s)"
PARE_FORMAT_ERROR "%s:%d: %s"
PARE_JNI_INVALID_OBJECT "invalid object: %s:%s"
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/java/org/libimdb/swig
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/java/org/libimdb/swig
Added Files:
JLog.java Parser.java ProgressListener.java
Log Message:
initial checkin
--- NEW FILE: JLog.java ---
package org.libimdb.swig;
public class JLog
{
private long m_swigCPtr;
static {
try {
System.loadLibrary("imdbParser_java");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public JLog(long swigCPtr) throws IllegalArgumentException
{
if ( swigCPtr == 0 ) {
throw new IllegalArgumentException("create failed");
}
m_swigCPtr=swigCPtr;
}
public static long getCPtr(JLog obj)
{
return (obj == null) ? 0 : obj.m_swigCPtr;
}
public static JLog create()
{
return(org.libimdb.swig.gen.JLog.JLog_create());
}
public int destroy()
{
int ret=org.libimdb.swig.gen.JLog.JLog_destroy(this);
m_swigCPtr=-1;
return(ret);
}
public int JLogMessage_cb(String srcFile,
String srcFunc,
int srcLine,
int module,
int reportLevel,
int messageNumber,
String messageText)
{
String errstr;
if ( reportLevel == org.libimdb.swig.gen.JLog.JLOG_DEBUG ) {
errstr="DEBUG-"+messageNumber;
}
else if ( reportLevel == org.libimdb.swig.gen.JLog.JLOG_ERROR ) {
errstr="ERROR-"+messageNumber;
}
else if ( reportLevel == org.libimdb.swig.gen.JLog.JLOG_CRITICAL ) {
errstr="CRITICAL-"+messageNumber;
}
else {
errstr="UNDEFINED-"+messageNumber;
}
System.err.println(srcFile+" "+srcFunc+":"+srcLine+":"+module+": "+errstr+": "+messageText);
return(0);
}
/*
public int fmtfile(int logReportLevel,
int module,
int errorNumber,
String srcfile,
String srcfunc,
int srcline,
String file)
{
if ( m_swigCPtr == -1 ) {
System.err.println("attempt to use a closed JLog connection");
System.exit(1);
}
return(org.libimdb.swig.gen.JLog.jlog_fmtfile(this,
logReportLevel,
module,
errorNumber,
srcfile,
srcfunc,
srcline,
file));
}
*/
public int setMessageLevel()
{
if ( m_swigCPtr == -1 ) {
System.err.println("attempt to use a closed JLog connection");
System.exit(1);
}
/*
return(org.libimdb.swig.gen.JLog.jlog_setAppendLevel(this,
org.libimdb.swig.gen.JLog.JLOGT_DEBUG));
*/
return(-1);
}
public static void main(String args[])
{
JLog log;
log=create();
/*
System.out.println("messlevel:"+log.setMessageLevel());
System.out.println("fmtfile:"+log.fmtfile(org.libimdb.swig.gen.JLog.JLOGT_ERROR,
org.libimdb.swig.gen.JLog.MOD_JLG,
98,
"main", "Log.java", 31,
"/tmp/Makefile"));
System.out.println("dumped:"+log.dumpMessages());
*/
//System.out.println("Messages:"+l.messages());
//System.out.println("error number:"+l.errorNumber());
log.destroy();
log=null;
}
}
--- NEW FILE: Parser.java ---
package org.libimdb.swig;
public class Parser
{
private long m_swigCPtr;
private class MyProgress implements ProgressListener
{
private int m_itemEstimate=0;
MyProgress()
{
}
public void progressStarting_cb(String shortDescription, int itemEstimate)
{
m_itemEstimate=itemEstimate;
System.out.println("starting: "+shortDescription+" expect "+itemEstimate+" entries");
}
public int progressUpdate_cb(int itemCount, int itemEstimate)
{
if ( m_itemEstimate != itemEstimate ) {
/* new estimate */
m_itemEstimate=itemEstimate;
}
int perc=m_itemEstimate==0?0:(itemCount*100)/itemEstimate;
System.out.println("finished "+perc+"% done ("+itemCount+" of "+m_itemEstimate+")");
int next=((perc+5)*m_itemEstimate)/100;
if (next > itemEstimate ) {
return(itemEstimate);
}
else {
return(next);
}
}
public void progressFinished_cb(int itemCount, int abortCode)
{
if ( abortCode != 0 ) {
System.out.println("progress aborted after "+itemCount+" items with code="+abortCode);
}
else {
progressUpdate_cb(itemCount, itemCount);
System.out.println("progress done after "+itemCount+" items");
}
}
}
public Parser(long swigCPtr) throws IllegalArgumentException
{
if ( swigCPtr == 0 ) {
throw new IllegalArgumentException("create failed");
}
m_swigCPtr=swigCPtr;
}
public static long getCPtr(Parser obj)
{
return (obj == null) ? 0 : obj.m_swigCPtr;
}
public static Parser create(JLog logh, String dbsDir) throws IllegalArgumentException
{
Parser parser=org.libimdb.swig.gen.Parser.imdbParser_create(logh, dbsDir);
if ( parser == null ) {
throw new IllegalArgumentException("create failed");
}
return(parser);
}
public int destroy(JLog logh)
{
int ret=org.libimdb.swig.gen.Parser.imdbParser_destroy(logh, this);
m_swigCPtr=-1;
return(ret);
}
public int movieListEntry_cb(int lineNumber, int entryNumber,
int movieType, String movieTitle, int movieYear)
{
//System.out.println("ya: "+number+":"+movieTitle);
return(0);
}
public int directorListEntry_cb(int lineNumber, int entryNumber,
String directorName, String movieLabel)
{
System.out.println("ya: "+entryNumber+":"+directorName);
if ( entryNumber == 10 ) {
/* stop ! */
return(-1);
}
return(0);
}
public int actorListEntry_cb(int lineNumber, int entryNumber,
String actorName, int billing, int isNarrator,
String characterName,
String characterNameAka,
String movieLabel)
{
System.out.println("ya: "+entryNumber+":"+actorName);
if ( entryNumber == 10 ) {
/* stop ! */
return(-1);
}
return(0);
}
public int actressListEntry_cb(int lineNumber, int entryNumber,
String actressName, int billing, int isNarrator,
String characterName,
String characterNameAka,
String movieLabel)
{
System.out.println("ya: "+entryNumber+":"+actressName);
if ( entryNumber == 10 ) {
/* stop ! */
return(-1);
}
return(0);
}
void dumpThem(JLog logh)
{
/*org.libimdb.swig.gen.Parser.imdbParser_dumpMovies(logh, this, new MyProgress());*/
org.libimdb.swig.gen.Parser.imdbParser_dumpDirectors(logh, this, new MyProgress());
org.libimdb.swig.gen.Parser.imdbParser_dumpActors(logh, this, new MyProgress());
org.libimdb.swig.gen.Parser.imdbParser_dumpActresses(logh, this, new MyProgress());
}
public static void main(String args[])
{
JLog logh;
logh=JLog.create();
Parser parser=create(logh, "/home/jerry/imdb/moviedb-3.21/lists");
if ( parser != null ) {
parser.dumpThem(logh);
/*org.libimdb.swig.gen.Parser.imdbParser_dumpMovies(logh, new MyProgress(),
parser);*/
parser.destroy(logh);
parser=null;
}
logh.destroy();
logh=null;
}
}
--- NEW FILE: ProgressListener.java ---
package org.libimdb.swig;
public interface ProgressListener
{
/**
* progress starting callback.
* Includes short string describing operation about
* to start with an estimate of the number of items
* we expect to process
*/
void progressStarting_cb(String shortDescription, int itemEstimate);
/**
* progress update callback.
* Includes the current item being processed and a
* possibly updated number of items we estimate we will
* process.
* @returns item number you'd like to get another progressUpdate_cb
* callback for.
*/
int progressUpdate_cb(int itemCount, int itemEstimate);
/**
* progress finished callback.
* includes the total number of items processed and
* an abortCode which it non-zero if we stopped progress
* prematurly.
*/
void progressFinished_cb(int itemCount, int abortCode);
}
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/bin
Added Files:
swigdepend.pl swiggen.pl
Log Message:
initial checkin
--- NEW FILE: swigdepend.pl ---
#! /usr//bin/perl
sub findInclude
{
local($file) = @_;
local($path);
foreach $path (@INCPATH) {
return "$path/$file" if (-f "$path/$file");
}
return undef;
}
while ($ARGV[0] =~ m/^-/) {
if ($ARGV[0] =~ m/^-I(.*)/) {
push(@INCPATH, $1);
}
shift;
}
while (<>) {
if (m/^%include\s+"(.*)"/) {
($include = &findInclude($1)) ||
die "swigdepend: can't find include file: $1\n";
print "\$(BUILD_DIR)/$ARGV: $include\n";
}
}
--- NEW FILE: swiggen.pl ---
#!/usr/bin/perl
$|=1;
while (<>) {
if (m/^%mymagic/) {
my $incs="";
while (<>) {
if ( m/^%mymagic_end/ ) {
#printf STDERR ("echo \"$incs\" | $ENV{CMD}\n");
open(FD, "| $ENV{CMD}") || die "| $ENV{CMD}: $!";
printf FD "$incs\n";
close(FD);
last;
} elsif ( m/^%include\s+"(.*)"\n/) {
$incs.="#include <$1>\n";
} elsif ( m/^\s+$/) {
next;
} else {
die "don't understand line '$_'\n";
}
}
die "missing mymagic_end" if ( !m/^%mymagic_end/ );
next;
} else {
print;
}
}
exit 0;
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/parser
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/parser
Added Files:
Makefile imdbDict.c imdbParser.c private.h
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $
#
include ../config.mk
include ../constants.mk
CPPFLAGS += -I../include
LIB_BASE = imdbParser
LIB_VERSION = 1.0
build:
$(MAKE) $(MYLIBRARY) LIBRARY=$(MYLIBRARY)
$(MAKE) $(MYDYNAMIC) DYNAMIC=$(MYDYNAMIC)
install:; @true;
include ../rules.mk
--- NEW FILE: imdbDict.c ---
/**
* @file
* @verbatim $Id: imdbDict.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
static char rcs_id[] = "$Id: imdbDict.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_IO
#define _USE_ASSERT
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_TYPES
#define _USE_CTYPE
#define _USE_MALLOC
#define _USE_LIMITS
#define _USE_TIME
#include "sysincludes.h"
#include "jlog/dicerr.h"
#include "libimdb/parser.h"
#include "libimdb/dict.h"
/*#include "private.h"*/
struct imdbDict_s
{
int fd;
char dir[1024];
imdbParser_t *parser;
};
static inline void
writeIt(int fd, char *in)
{
char *i=in;
while(*i != '\0') {
if ( isalnum(*i) || *i == '_' || *i=='.' || *i=='-') {
write(fd, i, 1);
}
else {
char buf[100];
sprintf(buf, "%%%02x", (unsigned int)*i);
write(fd, buf, strlen(buf));
}
i++;
}
}
/**
* move ending ', The', articles to front of title name.
* articles include The,A,Une,Les,L\',Le,La,El,Das.
*/
static void
titleMoveArticlesToFront(const char *title, char *output)
{
int len=strlen(title);
const char *end=title+len;
if ( strncmp(end-5, ", The", 5)==0 ||
strncmp(end-5, ", Une", 5)==0 ||
strncmp(end-5, ", Les", 5)==0 ||
strncmp(end-5, ", Das", 5)==0 ) {
output[0]=*(end-3);
output[1]=*(end-2);
output[2]=*(end-1);
output[3]=' ';
strncpy(output+4, title, len-5);
output[len-1]='\0';
}
else if ( strncmp(end-3, ", A", 3)==0 ) {
output[0]='A';
output[1]=' ';
strncpy(output+2, title, len-3);
output[len-1]='\0';
}
else if ( strncmp(end-4, ", L\'", 4)==0 ||
strncmp(end-4, ", Le", 4)==0 ||
strncmp(end-4, ", La", 4)==0 ||
strncmp(end-4, ", El", 4)==0 ) {
output[0]=*(end-2);
output[1]=*(end-1);
output[2]=' ';
strncpy(output+3, title, len-4);
output[len-1]='\0';
}
else {
strcpy(output, title);
}
}
static int
listentry_cb(jlogHandle_t *logh,
imdbParser_t *imdbh,
const ListFile_e lf,
const void *entry)
{
imdbDict_t *dict=imdbParser_getUserHandle(logh, imdbh);
switch(lf) {
case LIST_MOVIES:
{
const struct MovieInList_s *data=entry;
write(dict->fd, data->title, strlen(data->title));
write(dict->fd, "\t", 1);
switch(data->type) {
case isMovie: write(dict->fd, "\t1", 2);
break;
case isTVSeries: write(dict->fd, "\t2", 2);
break;
case isTVMovie: write(dict->fd, "\t3", 2);
break;
case isVideoMovie: write(dict->fd, "\t4", 2);
break;
case isVideoGame: write(dict->fd, "\t5", 2);
break;
case isTVMiniSeries:write(dict->fd, "\t6", 2);
break;
}
write(dict->fd, "\n", 1);
if ( data->number > 1000 ) {
/* stop */
/*return(-1);*/
}
}
break;
case LIST_DIRECTORS:
{
const struct DirectorInList_s *data=entry;
}
break;
case LIST_ACTORS:
{
const struct ActorInList_s *data=entry;
}
break;
case LIST_ACTRESSES:
{
const struct ActorInList_s *data=entry;
}
break;
}
return(0);
}
imdbDict_t *
imdbDict_create(jlogHandle_t *logh,
const char *dbsDir,
const char *dictDir)
{
imdbDict_t *dict;
dict=malloc(sizeof(struct imdbDict_s));
if ( dict == NULL ) {
DICE_BAD_MEM_FAILURE(logh, imdbDict_t *, NULL);
}
dict->parser=imdbParser_open(logh, dbsDir, listentry_cb);
if ( dict->parser == NULL ) {
free(dict);
DIC_FAILURE(logh, imdbDict_t *, NULL);
}
imdbParser_setUserHandle(logh, dict->parser, dict);
dict->fd=-1;
strcpy(dict->dir, dictDir);
return(dict);
}
int
imdbDict_destroy(jlogHandle_t *logh,
imdbDict_t *dict)
{
imdbParser_close(logh, dict->parser);
free(dict);
DIC_SUCCESS(logh, int, 0);
}
int
imdbDict_indexMovies(jlogHandle_t *logh,
imdbDict_t *dict)
{
char file[1024];
sprintf(file, "%s/moviedb.idx", dict->dir);
dict->fd=open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if ( dict->fd == -1 ) {
DICE_FILE_OPEN_FAILURE(logh, file, strerror(errno), int, -1);
}
/* -1 means stop, -2 means abort */
if ( imdbParser_moviesParse(logh, dict->parser) < -1 ) {
close(dict->fd);
unlink(file);
DIC_FAILURE(logh, int, -1);
}
close(dict->fd);
return(0);
}
--- NEW FILE: imdbParser.c ---
/**
* @file
* @verbatim $Id: imdbParser.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
static char rcs_id[] = "$Id: imdbParser.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_IO
#define _USE_ASSERT
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_TYPES
#define _USE_CTYPE
#define _USE_MALLOC
#define _USE_LIMITS
#define _USE_TIME
[...1333 lines suppressed...]
LIST_DIRECTORS));
}
int
imdbParser_actorsParse(jlogHandle_t *logh,
imdbParser_t *parser)
{
return(imdbParser_castOrDirectorsParse(logh,
parser,
LIST_ACTORS));
}
int
imdbParser_actressesParse(jlogHandle_t *logh,
imdbParser_t *parser)
{
return(imdbParser_castOrDirectorsParse(logh,
parser,
LIST_ACTRESSES));
}
--- NEW FILE: private.h ---
/**
* @file
* @verbatim $Id: private.h,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
/*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
{
void *userHandle;
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;
} stats;
};
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/demo/indexMovies
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/demo/indexMovies
Added Files:
Makefile README db.c db.h dumpit-db.pl dumpit.pl main.c
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
include ../../config.mk
include ../../constants.mk
CPPFLAGS += -I../../include
LIBS= ../../parser/$(BUILD_DIR)/libimdbParser.a \
../../libjlog/$(BUILD_DIR)/libjlog.a \
-ldb \
-lpthread
MYPROGRAM=$(BUILD_DIR)/indexMovies
build:
$(MAKE) PROGRAM=$(MYPROGRAM)
install:; @true;
include ../../rules.mk
--- NEW FILE: README ---
indexMovies
-----------
This program builds the following files:
movies.idx
title<tab>movieID,movieID,...\n
- where title is the title string from the list file (articles not moved).
- movieID can be used to lookup more information in movies.dat file.
- contents are sorted by title.
movies.dat
movieID<tab>movieTypeID<tab>yearDescription<tab>DirectorID,DirectorID,...<tab>ActorID(billing),..\n
- where movieID is a front-zero padded 7 digit number.
- movieTypeID is one of:
isMovie=1,
isTVSeries=2,
isTVMovie=3,
isVideoMovie=4,
isVideoGame=5,
isTVMiniSeries=6
- yearDescription is one of: 4 digit year or 0000 for unknown and possibly followed by a '/' and
some roman numerals.
- where DirectorID is used to lookup the directors name in directors.dat
- the (billing) following the ActorID gives the billing number if known.
- ActorIDs are always sorted in billing order
- similar for ActorIDs in actors.dat
directors.dat
DirectorID<tab>name<tab>movieID,movieID...\n
actors.dat
ActorID<tab>genderID<tab>name<tab>movieID|billing|narrator|charName|charNameAka<tab>movieID...\n
- gender is of course 0 for male, and 1 for female ( I imagine some guesses as some of these)
- billing
- narrator is 0 or 1 depending if (s)he was the narrator
- charName - character name
- charNameAka - some characters have more than one name
--- NEW FILE: db.c ---
/**
* @file
* @verbatim $Id: db.c,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $ @endverbatim
*/
static char rcs_id[] = "$Id: db.c,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_IO
#define _USE_ASSERT
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_TYPES
#define _USE_CTYPE
#define _USE_MALLOC
#define _USE_LIMITS
#define _USE_TIME
#include "sysincludes.h"
#include "jlog/dicerr.h"
#include "libimdb/parser.h"
#include "db.h"
#include "/usr/include/db.h"
/*#include "/usr/local/BerkeleyDB.4.1/include/db.h"*/
struct imdbDB_s
{
DB *dbp;
char *dir;
imdbParser_t *parser;
};
#if 0
static inline void
writeIt(int fd, char *in)
{
char *i=in;
while(*i != '\0') {
if ( isalnum(*i) || *i == '_' || *i=='.' || *i=='-') {
write(fd, i, 1);
}
else {
char buf[100];
sprintf(buf, "%%%02x", (unsigned int)*i);
write(fd, buf, strlen(buf));
}
i++;
}
}
#endif
/**
* move ending ', The', articles to front of title name.
* articles include The,A,Une,Les,L\',Le,La,El,Das.
*/
static void
titleMoveArticlesToFront(const char *title, char *output)
{
int len=strlen(title);
const char *end=title+len;
if ( strncmp(end-5, ", The", 5)==0 ||
strncmp(end-5, ", Une", 5)==0 ||
strncmp(end-5, ", Les", 5)==0 ||
strncmp(end-5, ", Das", 5)==0 ) {
output[0]=*(end-3);
output[1]=*(end-2);
output[2]=*(end-1);
output[3]=' ';
strncpy(output+4, title, len-5);
output[len-1]='\0';
}
else if ( strncmp(end-3, ", A", 3)==0 ) {
output[0]='A';
output[1]=' ';
strncpy(output+2, title, len-3);
output[len-1]='\0';
}
else if ( strncmp(end-4, ", L\'", 4)==0 ||
strncmp(end-4, ", Le", 4)==0 ||
strncmp(end-4, ", La", 4)==0 ||
strncmp(end-4, ", El", 4)==0 ) {
output[0]=*(end-2);
output[1]=*(end-1);
output[2]=' ';
strncpy(output+3, title, len-4);
output[len-1]='\0';
}
else {
strcpy(output, title);
}
}
static int
listentry_cb(jlogHandle_t *logh,
imdbParser_t *imdbh,
const ListFile_e lf,
const void *entry)
{
imdbDB_t *dbh=imdbParser_getUserHandle(logh, imdbh);
switch(lf) {
case LIST_MOVIES:
{
const struct MovieInList_s *data=entry;
char buf[1024];
DBT key, keydata;
int ret;
memset(&key, 0, sizeof(key));
memset(&keydata, 0, sizeof(keydata));
key.data = data->label;
key.size = sizeof(char)*strlen(data->label);
switch(data->type) {
case isMovie: sprintf(buf, "1");
break;
case isTVSeries: sprintf(buf, "2");
break;
case isTVMovie: sprintf(buf, "3");
break;
case isVideoMovie: sprintf(buf, "4");
break;
case isVideoGame: sprintf(buf, "5");
break;
case isTVMiniSeries:sprintf(buf, "6");
break;
}
keydata.data = buf;
keydata.size = sizeof(char)*strlen(buf);
switch (ret=dbh->dbp->put(dbh->dbp, NULL, &key, &keydata, DB_NOOVERWRITE)) {
case 0:
/*fprintf(stderr, "db: %s: key stored.\n", (char *)key.data);*/
break;
case DB_KEYEXIST:
/*fprintf(stderr, "db: %s: key previously stored.\n",
(char *)key.data);*/
/*return(-1);*/
break;
default:
dbh->dbp->err(dbh->dbp, ret, "DB->put");
return(-1);
}
if ( data->number > 1000 ) {
/* stop */
return(-1);
}
}
break;
case LIST_DIRECTORS:
{
const struct DirectorInList_s *data=entry;
}
break;
case LIST_ACTORS:
{
const struct ActorInList_s *data=entry;
}
break;
case LIST_ACTRESSES:
{
const struct ActorInList_s *data=entry;
}
break;
}
return(0);
}
imdbDB_t *
imdbDB_create(jlogHandle_t *logh,
const char *dbsDir,
const char *dbDir)
{
imdbDB_t *dbh;
dbh=malloc(sizeof(struct imdbDB_s));
if ( dbh == NULL ) {
DICE_BAD_MEM_FAILURE(logh, imdbDB_t *, NULL);
}
dbh->dbp=NULL;
dbh->dir=strdup(dbDir);
dbh->parser=imdbParser_open(logh, dbsDir, listentry_cb);
if ( dbh->parser == NULL ) {
free(dbh->dir);
free(dbh);
DIC_FAILURE(logh, imdbDB_t *, NULL);
}
imdbParser_setUserHandle(logh, dbh->parser, dbh);
return(dbh);
}
int
imdbDB_destroy(jlogHandle_t *logh,
imdbDB_t *dbh)
{
imdbParser_close(logh, dbh->parser);
if ( dbh->dbp != NULL ) {
dbh->dbp->close(dbh->dbp, 0);
}
free(dbh->dir);
free(dbh);
DIC_SUCCESS(logh, int, 0);
}
int
imdbDB_indexMovies(jlogHandle_t *logh,
imdbDB_t *dbh)
{
char file[1024];
int ret;
sprintf(file, "%s/moviedb.idx", dbh->dir);
/*
if ((ret = db_create(&(dbh->dbp), NULL, 0)) != 0) {
DICE_FILE_OPEN_FAILURE(logh, "db_create", db_strerror(ret), int, -1);
}
if ((ret = dbh->dbp->open(dbh->dbp, NULL, file, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) {
dbh->dbp->close(dbh->dbp, 0);
dbh->dbp=NULL;
DICE_FILE_OPEN_FAILURE(logh, file, db_strerror(ret), int, -1);
}
*/
if ((ret = db_create(&(dbh->dbp), NULL, 0)) != 0) {
fprintf(stderr, "db_create: %s\n", db_strerror(ret));
exit (1);
}
if ((ret = dbh->dbp->open(dbh->dbp, "moviedb", NULL, DB_BTREE, DB_CREATE, 0664)) != 0) {
dbh->dbp->err(dbh->dbp, ret, "%s", file);
exit(1);
}
/* -1 means stop, -2 means abort */
if ( imdbParser_moviesParse(logh, dbh->parser) < -1 ) {
dbh->dbp->close(dbh->dbp, 0);
dbh->dbp=NULL;
unlink(file);
DIC_FAILURE(logh, int, -1);
}
dbh->dbp->close(dbh->dbp, 0);
dbh->dbp=NULL;
return(0);
}
--- NEW FILE: db.h ---
/**
* @file
* @verbatim $Id: db.h,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $ @endverbatim
*/
#ifndef IMDBDB_H
# define IMDBDB_H
typedef struct imdbDB_s imdbDB_t;
imdbDB_t *
imdbDB_create(jlogHandle_t *logh,
const char *dbsDir,
const char *dbDir);
int
imdbDB_destroy(jlogHandle_t *logh,
imdbDB_t *dbh);
int
imdbDB_indexMovies(jlogHandle_t *logh,
imdbDB_t *dbh);
#endif /* IMDBDICT_H */
--- NEW FILE: dumpit-db.pl ---
#!/usr/bin/perl -w
#use warnings;
use strict;
#use BerkeleyDB;
use DB_File;
my %hash;
my $db=tie %hash, 'BerkeleyDB::Btree', Filename => "moviedb", Flags => DB_RDONLY
or die "failed:$!";
# Install DBM Filters
#$db->filter_fetch_key ( sub { s/\0$// } ) ;
#$db->filter_store_key ( sub { $_ .= "\0" } ) ;
#$db->filter_fetch_value( sub { s/\0$// } ) ;
#$db->filter_store_value( sub { $_ .= "\0" } ) ;
print "size=".scalar(keys %hash)."\n";
$hash{key}="data";
for my $key ( keys %hash ) {
print "$key: ".$hash{$key}."\n";
}
undef($db);
untie %hash;
exit(0);
--- NEW FILE: dumpit.pl ---
#!/usr/bin/perl -w
#use warnings;
use strict;
use BerkeleyDB;
#use DB_File;
my %hash;
my $db=tie %hash, 'BerkeleyDB::Btree', Filename => "moviedb", Flags => DB_RDONLY
or die "failed:$!";
# Install DBM Filters
#$db->filter_fetch_key ( sub { s/\0$// } ) ;
#$db->filter_store_key ( sub { $_ .= "\0" } ) ;
#$db->filter_fetch_value( sub { s/\0$// } ) ;
#$db->filter_store_value( sub { $_ .= "\0" } ) ;
print "size=".scalar(keys %hash)."\n";
$hash{key}="data";
for my $key ( keys %hash ) {
print "$key: ".$hash{$key}."\n";
}
undef($db);
untie %hash;
exit(0);
--- NEW FILE: main.c ---
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "sysincludes.h"
#include "jlog/dicerr.h"
#include "jlog/jlog2File.h"
#include "db.h"
jlogHandle_t *logh;
imdbDB_t *dbh;
jlog2File_t *l2f;
int
main(int argc, char **argv)
{
l2f=jlog2File_create("-");
assert(jlogCallback_setNotificationLevel(jlog2File_getJLogCallbackHandle(l2f),
MOD_ALL,
JLOGT_DEBUG)==0);
logh=jlog_openNew();
jlog_registerEventCallback(logh, jlog2File_getJLogCallbackHandle(l2f));
//log_setAllModuleCallbackLevels(logh, LOGT_DEBUG);
//log_setAllModuleDebugEnterExit(logh, 1);
dbh=imdbDB_create(logh, "../dumpMovies/dbs", ".");
if ( dbh != NULL ) {
if ( 1 ) {
if (imdbDB_indexMovies(logh, dbh) == 0 ) {
}
}
/*if ( 0 ) {
if ( imdbParser_directorsParse(logh, parser) == 0 ) {
}
}
if ( 0 ) {
if ( imdbParser_actorsParse(logh, parser) == 0 ) {
}
}
if ( 0 ) {
if ( imdbParser_actressesParse(logh, parser) == 0 ) {
}
}*/
imdbDB_destroy(logh, dbh);
}
jlog_close(logh);
jlog2File_destroy(l2f);
exit(0);
}
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/libjlog
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/libjlog
Added Files:
Makefile jlog.c jlog2File.c jlogTracker.c
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $
#
include ../config.mk
include ../constants.mk
CPPFLAGS += -I../include
LIB_BASE = jlog
LIB_VERSION = 1.2
build:
$(MAKE) $(MYLIBRARY) LIBRARY=$(MYLIBRARY)
$(MAKE) $(MYDYNAMIC) DYNAMIC=$(MYDYNAMIC)
install:; @true;
include ../rules.mk
--- NEW FILE: jlog.c ---
/**
* @file
*
* @todo should create test code to validate snprintf, and friends usage
*/
static char rcs_id[] = "$Id: jlog.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_IO
#define _USE_ASSERT
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_TYPES
#define _USE_MALLOC
#define _USE_LIMITS
#define _USE_TIME
[...1033 lines suppressed...]
}
else {
mylogh=logh;
}
if ( mylogh->h_appendEnterExit[module] == 0 &&
mylogh->h_appendEnterExit[MOD_ALL] == 0 ) {
return(0);
}
else {
va_list args;
int ret;
va_start(args, srcfunc);
ret=jlog_enterReturn(mylogh, jlogReportLevel, module, IS_FAILURE, srcfile, srcline, srcfunc, args);
va_end(args);
return(ret);
}
}
--- NEW FILE: jlog2File.c ---
/**
* @file
*/
static char rcs_id[] = "$Id: jlog2File.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_IO
#define _USE_ASSERT
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_TYPES
#define _USE_MALLOC
#define _USE_LIMITS
#define _USE_TIME
#include "sysincludes.h"
#include "jlog/jlog.h"
#include "jlog/jlog2File.h"
struct jlog2File_s {
char filename[MAXPATHLEN];
/* for private use */
time_t tval_s;
char tim[100];
int detailLevel;
int fd;
jlogCallbackHandle_t *cb;
void *cb_userdata;
};
static void
jlog_eventCallback(jlogHandle_t *logh, const char *srcfile, const char *srcfunc,
int srcline, jlogModule_e module, jlogReportLevel_e jlogReportLevel,
int messageNumber, const char *messageText, void *cb_userdata)
{
jlog2File_t *lt=cb_userdata;
char buf[MAXJLOGMSGLEN+1];
int buflen;
char errstr[100];
/* is enabled ? */
if ( lt->fd == -1 ) {
return;
}
switch(jlogReportLevel) {
case JLOGT_CRITICAL:
sprintf(errstr, "CRITICAL-%03d", messageNumber);
break;
case JLOGT_ERROR:
sprintf(errstr, "ERROR-%03d", messageNumber);
break;
case JLOGT_DEBUG:
sprintf(errstr, "DEBUG-%03d", messageNumber);
break;
}
if ( lt->detailLevel == 0 ) {
if ( (buflen=snprintf(buf, MAXJLOGMSGLEN, "%03d-%s: %s\n", module, errstr, messageText)) < 0 ||
buflen == MAXJLOGMSGLEN ) {
buf[MAXJLOGMSGLEN-1]='\0';
buflen=MAXJLOGMSGLEN-1;
}
}
else {
time_t tval;
tval = time(NULL);
if ( tval != lt->tval_s ) {
struct tm *tms=localtime(&tval);
strftime(lt->tim, 100, "%Y%m%d %H%M%S", tms);
lt->tval_s=tval;
}
if ( srcfunc != NULL ) {
if ( (buflen=snprintf(buf, MAXJLOGMSGLEN, "%d %s %s:%s:%4d: %03d-%s: %s\n",
getpid(), lt->tim, srcfile, srcfunc, srcline, module, errstr, messageText)) < 0 ||
buflen == MAXJLOGMSGLEN ) {
buf[MAXJLOGMSGLEN-1]='\0';
buflen=MAXJLOGMSGLEN-1;
}
}
else {
if ( (buflen=snprintf(buf, MAXJLOGMSGLEN, "%d %s:%s:%4d: %03d-%s: %s\n",
getpid(), lt->tim, srcfile, srcline, module, errstr, messageText)) < 0 ||
buflen == MAXJLOGMSGLEN ) {
buf[MAXJLOGMSGLEN-1]='\0';
buflen=MAXJLOGMSGLEN-1;
}
}
}
/* one atomic write - not sure if this matters... really */
write(lt->fd, buf, buflen);
return;
}
jlog2File_t *
jlog2File_create(char *filename)
{
jlog2File_t *lt;
lt=malloc(sizeof(struct jlog2File_s));
if ( lt == NULL ) {
return(NULL);
}
assert(strlen(filename) < MAXPATHLEN);
strcpy(lt->filename, filename);
lt->tval_s=0;
lt->tim[0]='\0';
lt->cb=jlogCallback_create(jlog_eventCallback,lt);
lt->detailLevel=0;
lt->fd=-1;
if ( jlog2File_enable(lt) != 0 ) {
free(lt);
return(NULL);
}
return(lt);
}
int
jlog2File_destroy(jlog2File_t *lt)
{
jlog2File_disable(lt);
free(lt);
return(0);
}
int
jlog2File_enable(jlog2File_t *lt)
{
if ( lt->fd == -1 ) {
if ( strcmp(lt->filename, "-") == 0 ) {
lt->fd=1;
}
else {
lt->fd=open(lt->filename, O_CREAT|O_RDWR|O_APPEND, 0660);
if ( lt->fd == 0 ) {
lt->fd=-1;
return(-1);
}
}
}
return(0);
}
int
jlog2File_disable(jlog2File_t *lt)
{
if ( lt->fd != -1 ) {
if ( lt->fd == 0 ) {
lt->fd=-1;
return(0);
}
else if( close(lt->fd) != 0 ) {
lt->fd=-1;
return(-1);
}
lt->fd=-1;
}
return(0);
}
char *
jlog2File_getFilename(jlog2File_t *lt)
{
return(lt->filename);
}
jlogCallbackHandle_t *
jlog2File_getJLogCallbackHandle(jlog2File_t *lt)
{
return(lt->cb);
}
--- NEW FILE: jlogTracker.c ---
/**
* @file
*/
static char rcs_id[] = "$Id: jlogTracker.c,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $";
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_IO
#define _USE_ASSERT
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_TYPES
#define _USE_MALLOC
#define _USE_LIMITS
#define _USE_TIME
#include "sysincludes.h"
#include "jlog/jlog.h"
#include "jlog/jlogTracker.h"
struct jlogTracker_s {
struct messHead_s *head; /**< message stack */
jlogCallbackHandle_t *cb;
};
struct messNode_s {
char *srcfile;
char *srcfunc;
int srcline;
jlogModule_e module;
jlogReportLevel_e reportLevel;
int messageNumber;
char *messageText;
struct messNode_s *next;
};
struct messHead_s {
int count;
struct messNode_s *first;
};
static void
messbuf_destroyNode(struct messNode_s *node)
{
if ( node->srcfile != NULL ) free(node->srcfile);
if ( node->srcfunc != NULL ) free(node->srcfunc);
if ( node->messageText != NULL ) free(node->messageText);
free(node);
}
static struct messNode_s *
messbuf_createNode(const char *srcfile, const char *srcfunc,
int srcline, jlogModule_e module,
jlogReportLevel_e reportLevel,
int messageNumber,
const char *messageText)
{
struct messNode_s *node;
node=malloc(sizeof(struct messNode_s));
if ( node == NULL ) {
return(NULL);
}
node->srcfile=strdup(srcfile);
node->srcfunc=strdup(srcfunc);
node->srcline=srcline;
node->module=module;
node->reportLevel=reportLevel;
node->messageNumber=messageNumber;
node->messageText=strdup(messageText);
node->next=NULL;
if ( node->srcfile == NULL ||
node->srcfunc == NULL ||
node->messageText == NULL ) {
messbuf_destroyNode(node);
return(NULL);
}
return(node);
}
static int
messbuf_append(struct messHead_s *head, const char *srcfile, const char *srcfunc,
int srcline, jlogModule_e module, jlogReportLevel_e logReportLevel,
int messageNumber, const char *messageText)
{
struct messNode_s *node;
struct messNode_s *last;
node=messbuf_createNode(srcfile, srcfunc,
srcline, module, logReportLevel,
messageNumber,
messageText);
if ( node == NULL ) {
return(-1);
}
if ( head->first == NULL ) {
head->first=node;
head->count=1;
return(0);
}
for (last=head->first; last->next!=NULL ; last=last->next) {
/* empty, just find end */
}
last->next=node;
node->next=NULL;
head->count++;
return(0);
}
static struct messNode_s *
messbuf_getNode(const struct messHead_s *head, int messageIndex)
{
struct messNode_s *last;
int count=0;
if ( head->first == NULL ) {
return(NULL);
}
for (last=head->first; last->next!=NULL ; last=last->next) {
char str[300];
sprintf(str, "found %d, want %d", count, messageIndex);
if ( count++ == messageIndex ) {
return(last);
}
}
if ( count == messageIndex ) {
return(last);
}
return(NULL);
}
static void
jlog_eventCallback(jlogHandle_t *logh, const char *srcfile, const char *srcfunc,
int srcline, jlogModule_e module, jlogReportLevel_e jlogReportLevel,
int messageNumber, const char *messageText, void *cb_userdata)
{
jlogTracker_t *lt=cb_userdata;
messbuf_append(lt->head, srcfile, srcfunc, srcline, module, jlogReportLevel,
messageNumber, messageText);
}
jlogTracker_t *
jlogTracker_create(void)
{
jlogTracker_t *lt;
lt=malloc(sizeof(struct jlogTracker_s));
if ( lt == NULL ) {
return(NULL);
}
lt->head=malloc(sizeof(struct messHead_s));
lt->head->count=0;
lt->head->first=NULL;
lt->cb=jlogCallback_create(jlog_eventCallback, lt);
return(lt);
}
/**
* message buffer structure that helps manages a message stack
*/
void
jlogTracker_reset(jlogTracker_t *lt)
{
struct messNode_s *node, *nextNode;
for (node=lt->head->first ; node != NULL ; node=nextNode ) {
nextNode=node->next;
messbuf_destroyNode(node);
}
lt->head->first=NULL;
lt->head->count=0;
}
/** get the number of message buffered
*/
int
jlogTracker_getCount(jlogTracker_t *lt)
{
return(lt->head->count);
}
/** get message details of message.
* messageIndex must between 0 to (log_getMessagesCount()-1)
* @returns -1 upon error (out of range)
* @returns 0 upon success
*/
int
jlogTracker_getMessageDetails(jlogTracker_t *lt,
int messageIndex,
char **srcfile,
char **srcfunc,
int *srcline,
jlogModule_e *module,
jlogReportLevel_e *reportLevel,
int *messageNumber,
char **messageText)
{
struct messNode_s *node;
node=messbuf_getNode(lt->head, messageIndex);
if ( node == NULL ) {
*srcfile="";
*srcfunc="";
*srcline=0;
*module=0;
*reportLevel=0;
*messageNumber=0;
*messageText="";
return(-1);
}
*srcfile=node->srcfile;
*srcfunc=node->srcfunc;
*srcline=node->srcline;
*module=node->module;
*reportLevel=node->reportLevel;
*messageNumber=node->messageNumber;
*messageText=node->messageText;
return(0);
}
jlogCallbackHandle_t *
jlogTracker_getJLogCallbackHandle(jlogTracker_t *lt)
{
return(lt->cb);
}
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/demo/dumpMovies
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/demo/dumpMovies
Added Files:
Makefile main.c
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
include ../../config.mk
include ../../constants.mk
CPPFLAGS += -I../../include
LIBS= ../../parser/$(BUILD_DIR)/libimdbParser.a \
../../libjlog/$(BUILD_DIR)/libjlog.a
MYPROGRAM=$(BUILD_DIR)/dumpMovies
build:
$(MAKE) PROGRAM=$(MYPROGRAM)
install:; @true;
include ../../rules.mk
--- NEW FILE: main.c ---
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "sysincludes.h"
#include "jlog/parerr.h"
#include "jlog/jlog2File.h"
#include "libimdb/parser.h"
jlog2File_t *l2f;
static int
ListEntry_cb(jlogHandle_t *logh,
imdbParser_t *parser,
ListFile_e lf,
const void *entry)
{
switch(lf) {
case LIST_MOVIES: {
const struct MovieInList_s *data=entry;
/*fprintf(stderr, "%d:type=%d, %s (%04d)\n", data->number, data->type, data->title, data->year);
*/
break;
}
case LIST_DIRECTORS: {
const struct DirectorInList_s *data=entry;
/*fprintf(stdout, "%d:%s type=%d, title=%s (%04d)\n", data->number, data->name, data->movieType,
data->movieTitle, data->movieYear);*/
break;
}
case LIST_ACTORS: {
const struct ActorInList_s *data=entry;
/*fprintf(stdout, "%d:%s type=%d, title=%s (%04d)\n", data->number, data->name, data->movieType,
data->movieTitle, data->movieYear);*/
break;
}
case LIST_ACTRESSES: {
const struct ActressInList_s *data=entry;
/*fprintf(stdout, "%d:%s type=%d, title=%s (%04d)\n", data->number, data->name, data->movieType,
data->movieTitle, data->movieYear);*/
break;
}
}
return(0);
}
jlogHandle_t *logh;
imdbParser_t *parser;
int
main(int argc, char **argv)
{
l2f=jlog2File_create("-");
assert(jlogCallback_setNotificationLevel(jlog2File_getJLogCallbackHandle(l2f),
MOD_ALL,
JLOGT_ERROR)==0);
logh=jlog_openNew();
jlog_registerEventCallback(logh, jlog2File_getJLogCallbackHandle(l2f));
//log_setAllModuleCallbackLevels(logh, LOGT_DEBUG);
//log_setAllModuleDebugEnterExit(logh, 1);
parser=imdbParser_open(logh, "./dbs", ListEntry_cb);
if ( parser != NULL ) {
if ( 1 ) {
if (imdbParser_moviesParse(logh, parser) == 0 ) {
}
}
if ( 1 ) {
if ( imdbParser_directorsParse(logh, parser) == 0 ) {
}
}
if ( 1 ) {
if ( imdbParser_actorsParse(logh, parser) == 0 ) {
}
}
if ( 1 ) {
if ( imdbParser_actressesParse(logh, parser) == 0 ) {
}
}
imdbParser_close(logh, parser);
}
jlog_close(logh);
jlog2File_destroy(l2f);
exit(0);
}
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/demo In directory sc8-pr-cvs1:/tmp/cvs-serv11812/demo Added Files: Makefile Log Message: initial checkin --- NEW FILE: Makefile --- # # $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $ # include ../config.mk include ../constants.mk SUBPROJECTS = dumpMovies indexMovies build clean clobber depend install: @for sub in $(SUBPROJECTS); do \ [ -d $$sub ] || continue; \ echo "`$(DATECMD)`: $@ing $$sub"; \ (cd $$sub; $(MAKE) $@) || exit 1; \ done; \ |
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:47
|
Update of /cvsroot/libimdb/libimdb/include
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/include
Added Files:
Makefile sysincludes.h
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
include ../config.mk
include ../constants.mk
SUBPROJECTS = jlog
build clean clobber depend install:
@for sub in $(SUBPROJECTS); do \
[ -d $$sub ] || continue; \
echo "`$(DATECMD)`: $@ing $$sub"; \
(cd $$sub; $(MAKE) $@) || exit 1; \
done; \
--- NEW FILE: sysincludes.h ---
/**
@file
An attempt to hide some cross system and cross compiler issues like what
system includes are required.
Because we don't write testing code for all cases, support in each _USE_
definition is fixed/added on a needed basis, the framework here should
minimize code compatibily when new support is added.
History: we chose _USE_??? because this doesn't seem to colide with other
software projects and __USE_?? appears in system specific includes for things
like __USE_POSIX and __USE_XOPEN. We try to be similar but not conflict.
We should/could probably undef all _USE_ defines at the end of this file, but
this allows the use of these definitions after the include directive to do
code switching... not that this is neccessarily useful.
Supports the follow defined systems:
- SOLARIS5 (solaris 2.5.x)
- SOLARIS7 (solaris 2.7.x)
- NATIVE_WINDOWS (windows includes)
- LINUX (only tested with RH 7.[13])
@todo how can we enforce that we use INLINE and __FUNC__ and
__PRETTY_FUNC__ ?
@verbatim $Id: sysincludes.h,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $ @endverbatim
*/
#ifndef SYSINCLUDES_H
# define SYSINCLUDES_H
/******************************************************************************/
/** @def INSIGHT_SET_OPTION
This is parasoft software specific and is here only out of convienece
*/
#ifdef __INSIGHT__
#define INSIGHT_SET_OPTION(option, value) _Insight_set_option(option, value);
#else
#define INSIGHT_SET_OPTION(option, value)
#endif
/**
Here completely out out of convienece, disables __attribute_ defintions
for non-gnuc compilers.
*/
#ifndef __GNUC__
#define __attribute__(def)
#endif
/* from assert.h in RH's glibc-devel-2.2.4-31:
------------------------------------------
Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
which contains the name of the function currently being defined.
This is broken in G++ before version 2.6.
C9x has a similar variable called __func__, but prefer the GCC one since
it demangles C++ function names.
*/
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ == 199901L)
#define __FUNC__ __func__
#define __PRETY_FUNC__ __func__
#elif defined(__GNUC__)
#define __FUNC__ __FUNCTION__
#define __PRETY_FUNC__ __PRETTY_FUNCTION__
#else /* __STDC_VERSION__ && __GNUC__ */
#define __FUNC__ NULL
#define __PRETTY_FUNC__ NULL
#endif /* __STDC_VERSION__ && __GNUC__ */
/* define INLINE, I suspect the keyword is __inline for
M$'s cl and cxx, but I'm not sure - jwv */
#if defined(__GNUC__)
#define INLINE inline
#else /* __STDC__ && __cplusplus */
#error "INLINE is not defined for this compiler"
#endif /* __STDC__ && __cplusplus */
#if defined(MPATROL)
# include "/usr/local/include/mpatrol.h"
#endif
/**
@def _USE_STDIO
Standard io definitions.
NULL, FILE, fprintf, stderr, unlink, putenv etc
*/
#if defined(_USE_STDIO)
# include <stdio.h>
# ifdef NATIVE_WINDOWS
# define tempnam _tempnam
# define unlink _unlink
# endif
#endif
/******************************************************************************/
/**
@def _USE_STDLIB
Standard library definitions.
includes: exit, abort, ato*, abs, strtod, strtol, strtoul, system, rand,
getenv, putenv, getpagesize, getpid, sleep
*/
#if defined(_USE_STDLIB)
# include <stdlib.h>
# if !defined(NATIVE_WINDOWS)
# include <unistd.h>
# endif
# if defined(NATIVE_WINDOWS)
# include <process.h> /* for getpid */
# define getpid _getpid
# define sleep(sec) Sleep(sec*1000)
# define putenv _putenv
/*
* get option letter from argument vector
*/
extern int opterr, optind, optopt;
extern char *optarg;
int
getopt(int nargc, char** nargv, char* ostr);
# endif
# ifdef SOLARIS5
extern int getpagesize(void);
# endif
#endif
/**
@def _USE_ERRNO
Standard system errno functions and definitions.
includes: errno, sys_nerr...
*/
#if defined(_USE_ERRNO)
# include <errno.h>
# if defined(SOLARIS5)
extern int sys_nerr;
# endif
#endif
/**
@def _USE_STDARG
Standard argument parsing functions and defintions.
includes: va_list, va_start, va_arg, va_end..
*/
#if defined(_USE_STDARG)
# include <stdarg.h>
#endif
/**
@def _USE_STRINGS
Standard string allocation, manipulation functions and definitions.
includes: strlen, strncmp, strcspn, strdup, strtok, snprintf, vsnprintf
*/
#if defined(_USE_STRING)
/* common typo :) */
# error "you specied _USE_STRING, you probably want _USE_STRINGS"
#endif
#if defined(_USE_STRINGS)
# include <string.h>
# ifdef NATIVE_WINDOWS
# define strncasecmp _strnicmp
# define strcasecmp _stricmp
# define strdup _strdup
# endif
# if defined(SOLARIS5)
# define snprintf __snprintf
# define vsnprintf __snprintf
# if defined(_USE_STDARG)
extern int snprintf(char *s, int len, char *fmt, ...);
/*extern int snprintf(char *s, int len, char *fmt, va_list args);*/
# endif
# elif defined(NATIVE_WINDOWS)
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
#endif
/**
@def _USE_BYTEORDER
Standard byte order related functions and definitions.
includes htonl, nltoh, htons...
(use to be USE_ENDIAN)
*/
#if defined(_USE_BYTEORDER)
# if defined(NATIVE_WINDOWS)
# include <winsock2.h>
# endif
# if defined(LINUX)
# include <endian.h> /* definitions */
# include <netinet/in.h> /* htonl and the like */
# endif
# if defined(SOLARIS)
# include <sys/types.h> /* definitions */
# include <netinet/in.h>
# include <inttypes.h>
# include <sys/byteorder.h>
# endif
#endif
/**
@def _USE_TYPES
Standard useful type definitions.
includes: mode_t things typically in types.h
*/
#if defined(_USE_TYPE)
/* common typo :) */
# error "you specied _USE_TYPE, you probably want _USE_TYPES"
#endif
#if defined(_USE_TYPES)
# ifdef NATIVE_WINDOWS
# include <winsock2.h> /* u_char, u_short, u_int, u_long */
# include <native.h> /* int64_t etc */
typedef u_int mode_t;
typedef int pid_t;
# define umask _umask
# else
# include <sys/types.h> /* int64_t */
typedef u_int SOCKET;
# if defined(LINUX)
# include <linux/types.h>
# endif
# if defined(SOLARIS5) || defined (SOLARIS7) || defined(LINUX)
/*# define int64_t long long*/
# endif
# if defined(LINUX)
# include <stdint.h> /* works under linux for uint32_t etc */
# endif
# endif
#endif
/**
@def _USE_SOCKETS
Standard socket functions and definitions.
include: sockaddr_in struct and BSD sockets - select, connect ..
*/
#if defined(_USE_SOCKETS)
#ifndef _USE_TYPES
# error "_USE_SOCKETS requires that you also define _USE_TYPES"
#endif
#ifndef _USE_SELECT
# error "_USE_SOCKETS requires that you also define _USE_SELECT"
#endif
# if defined(NATIVE_WINDOWS)
# include <winsock2.h>
# else
# define SOCKET_ERROR -1 /**< cross platform failure check on return code from
socket() */
# define INVALID_SOCKET (SOCKET)(~0)
# define closesocket(s) close(s) /**< useful for crossplatform use */
# include <sys/socket.h>
# include <rpc/rpc.h>
# include <rpc/pmap_clnt.h> /* for pmap_unset */
# include <fcntl.h> /* for fcntl() */
# endif
#endif
/**
@def _USE_RPC
Sun RPC functions.
*/
#if defined(_USE_RPC)
# if defined(NATIVE_WINDOWS)
# else
# include <rpc/rpc.h>
# include <rpc/pmap_clnt.h> /* for pmap_unset */
# endif
#endif
/**
@def _USE_SELECT
File Descript select() function and declarations
*/
#if defined(_USE_SELECT)
# if !defined(NATIVE_WINDOWS)
# include <sys/select.h>
# endif
#endif
/**
@def _USE_CTYPE
Standard character macros/functions defines.
includes; isupper, islower, toupper, tolower...
*/
#if defined(_USE_CTYPE)
# include <ctype.h>
# ifdef NATIVE_WINDOWS
# define isascii __isascii
# endif
#endif
/**
@def _USE_STAT
Standard file/directory statistic and management defines,functions etc.
includes:stat, fstat, mkdir
*/
#if defined(_USE_STAT)
# include <sys/stat.h>
# ifdef NATIVE_WINDOWS
# include <direct.h> /* for mkdir */
#
/** @def STRUCT_STAT
Useful for crossplatform stat() support */
# define STRUCT_STAT struct _stat
# define STAT _stat
# define FSTAT _fstat
/** @def S_ISDIR - apparently missing from windows :) */
# define S_ISDIR(_m) (((_m) & _S_IFMT) == _S_IFDIR)
#else
/** @def STRUCT_STAT
Useful for crossplatform stat() support */
# define STRUCT_STAT struct stat
# define STAT stat
# define FSTAT fstat
# endif
#endif
/**
@def _USE_IO
Advanced (ha) io functions and definition
includes: open, read/write,close,fileno, fdopen...
*/
#if defined(_USE_IO)
# if !defined(NATIVE_WINDOWS)
# include <unistd.h>
# endif
# if defined(NATIVE_WINDOWS)
# define access _access
# define open _open
# define close _close
# define read _read
# define write _write
# define fileno _fileno
# define fdopen _fdopen
# define ftruncate _chsize
# define popen _popen
# define pclose _pclose
# define F_OK 00
# define W_OK 02
# define R_OK 04
# include <io.h>
# include <sys/locking.h>
# define O_RDONLY _O_RDONLY
# define O_WRONLY _O_WRONLY
# define O_RDWR _O_RDWR
# define O_APPEND _O_APPEND
# define O_CREAT _O_CREAT
# define O_TRUNC _O_TRUNC
# define O_EXCL _O_EXCL
# define O_BINARY _O_BINARY
# include <sys/stat.h> /* for S_IREAD and S_IWRITE */
# else
# define O_BINARY 0
# ifndef S_IREAD
# define S_IREAD S_IRUSR
# define S_IWRITE S_IWUSR
# endif
# endif
# include <fcntl.h>
/** @def OPEN
crossplatform OPEN is here to ease cross platform #ifdef head-aches
*/
# if defined(NATIVE_WINDOWS)
# define OPEN(file, flags, unixmode, winmode) open(file, flags, winmode)
# else
# define OPEN(file, flags, unixmode, winmode) open(file, flags, unixmode)
# endif
#endif
/**
@def _USE_SIGNAL
System V - signal functions.
include: signal...
*/
#if defined(_USE_SIGNAL)
# include <signal.h>
#endif
/**
@def _USE_WAIT
Wait and friends.
includes: wait, waitpid
*/
#if defined(_USE_WAIT)
# if !defined(NATIVE_WINDOWS)
# include <sys/wait.h>
# endif
#endif
/**
@def _USE_TERMIO
Tty control functions, defines etc.
includes: ioctl and tty...
*/
#if defined(_USE_TERMIO)
# if !defined(NATIVE_WINDOWS)
# include <sys/ioctl.h>
# endif
# if defined(SOLARIS5) || defined(SOLARIS7)
# include <termios.h>
# endif
#endif
/**
@def _USE_NETDB
Network database queries, hostname lookups etc.
include: gethostbyname...
*/
#if defined(_USE_NETDB)
# if defined(NATIVE_WINDOWS)
# include <winsock2.h> /* for struct hostent etc */
# else
# include <netdb.h>
# endif
#endif
/**
@def _USE_UNAME
get name and information about current kernel
includes: uname
*/
#if defined(_USE_UNAME)
# if !defined(NATIVE_WINDOWS)
# include <sys/utsname.h>
# endif
#endif
/**
@def _USE_SETJMP
Setjmp and friends.
*/
#if defined(_USE_SETJMP)
# include <setjmp.h>
#endif
/**
@def _USE_TIME
Time functions and defines
*/
#if defined(_USE_TIME)
# if defined(NATIVE_WINDOWS)
# include <time.h>
# include <sys/timeb.h>
# define STRUCT_TIMEB struct _timeb
# define ftime _ftime
# else
# include <time.h>
# include <sys/time.h>
# include <sys/timeb.h>
# define STRUCT_TIMEB struct timeb
# endif
#endif
/**
@def _USE_MALLOC
Memory managment functions/defines.
includes: malloc, free, realloc, heap/mallocinfo
*/
#if defined(_USE_MALLOC)
# if defined(NATIVE_WINDOWS)
# define alloca _alloca
# endif
# if !defined(MPATROL)
# include <malloc.h>
# endif
#endif
/**
@def _USE_MMAP
Mmap and friends.
*/
#if defined(_USE_MMAP)
# if !defined(NATIVE_WINDOWS)
# include <sys/mman.h>
# endif
#endif
/**
@def _USE_ASSERT
lovely assert() function :)
*/
#if defined(_USE_ASSERT)
# include <assert.h>
#endif
/**
@def _USE_MEMORY
Memory modification functions.
include: memset, memcpy, memcmp...
*/
#if defined(_USE_MEMORY)
# include <memory.h>
#endif
/**
@def _USE_DYNAMIC_LIBS
Dynamic library management.
include: dlopen, dlclose, dlsym, dlerror...
*/
#if defined(_USE_DYNAMIC_LIBS)
# if !defined(NATIVE_WINDOWS)
# include <dlfcn.h>
# endif
#endif
/**
@def _USE_READDIR
Diretory information services.
include:opendir, closedir, readdir...
*/
#if defined(_USE_READDIR)
# if !defined(NATIVE_WINDOWS)
# include <dirent.h>
# endif
#endif
/**
@def _USE_SYSLOG
Syslog routines.
*/
#if defined(_USE_SYSLOG)
#ifndef _USE_TYPES
# error "_USE_SYSLOG requires that you also define _USE_TYPES"
#endif
# if !defined(NATIVE_WINDOWS)
# include <syslog.h>
# endif
#endif
/**
@def _USE_PWD
password entry information.
includes: getpwnam, getpwuid...
*/
#if defined(_USE_PWD)
# if defined(NATIVE_WINDOWS)
# include <windows.h>
# else
# include <pwd.h>
# endif
#endif
/**
@def _USE_GROUP
User group entry information.
includes:getgrgid, getgrnam, getgroups...
*/
#if defined(_USE_GROUP)
# if !defined(NATIVE_WINDOWS)
# include <unistd.h> /* for getgroups */
# include <grp.h>
# endif
#endif
/**
@def _USE_LIMITS
Catchall for Size limitations.
includes MAXPATHLEN, HOSTNAME_LEN, LOGINNAME_LEN, INT_MIN, INT_MAX,
UINT_MAX, INT8_MAX, UINT8_MAX, INT32_MAX, UINT32_MAX, INT64_MAX,
UINT64_MAX...
*/
#if defined(_USE_LIMITS)
# include <limits.h>
# if defined(NATIVE_WINDOWS)
# define MAXPATHLEN _MAX_PATH
#
# include <windows.h>
# include <winbase.h> /* for MAX_COMPUTERNAME_LENGTH */
# include <lmcons.h> /* for UNLEN */
# define HOSTNAME_LEN MAX_COMPUTERNAME_LENGTH + 1
# define GROUPNAME_LEN 256 /* should be fixed later */
# define LOGINNAME_LEN UNLEN+1 /* defined size for GetUserName */
# else
# if defined(SOLARIS7)
# include <netdb.h> /* for MAXHOSTNAMELEN */
# endif
# include <sys/param.h>
# define MAXINT INT_MAX
# define HOSTNAME_LEN MAXHOSTNAMELEN+1
# define GROUPNAME_LEN 256
# define LOGINNAME_LEN 256 /**< L_cuserid is only defined length for usernames on unix
but this (usually 9) seems too small, so we defined ours
to be bigger */
# endif
/*
# ifdef LINUX
# define INT8_MAX 127
# define UINT8_MAX 255U
# define INT32_MAX 2147483647
# define UINT32_MAX 4294967295U
# define INT64_MAX (9223372036854775807L)
# define UINT64_MAX (18446744073709551615UL)
# endif
*/
#endif
/* functions from misc library */
#if defined(_USE_STRINGS) && defined(_USE_TYPES)
char *
lltostr(int64_t x, char *ptr);
int64_t
strtoll(const char *s, char **ptr, int base);
#endif /* _USE_STRINGS && _USE_TYPES */
/**
@def _USE_MISC
Enable misc library functions that are missing from os to os
These appear here out of convienence.
*/
#if defined(_USE_MISC)
char *basename(char *pathname, char *buf);
# ifdef _USE_STRINGS
int strprefix(char *s, char *prefix, char **after);
# endif
# ifdef _USE_STDARG
int vsnprintf (char *str, size_t count, const char *fmt, va_list args);
int vasprintf(char **ptr, const char *format, va_list ap);
int asprintf(char **ptr, const char *format, ...);
# endif
int snprintf(char *str,size_t count,const char *fmt,...);
#endif
#ifdef DOXYGEN
/* these defines are only here to trigger doxygen documenation
generatation, because if they're not defined, doxygen complains
(Warning: documentation for unknown define _USE_TERMIO found)
We of course don't define these in this include, but we want
to docuemnt them here :)
*/
#define _USE_STDIO
#define _USE_STDLIB
#define _USE_ERRNO
#define _USE_STDARG
#define _USE_STRINGS
#define _USE_BYTEORDER
#define _USE_TYPES
#define _USE_SOCKETS
#define _USE_RPC
#define _USE_SELECT
#define _USE_CTYPE
#define _USE_STAT
#define _USE_IO
#define _USE_SIGNAL
#define _USE_WAIT
#define _USE_TERMIO
#define _USE_NETDB
#define _USE_UNAME
#define _USE_SETJMP
#define _USE_TIME
#define _USE_MALLOC
#define _USE_MMAP
#define _USE_ASSERT
#define _USE_MEMORY
#define _USE_DYNAMIC_LIBS
#define _USE_READDIR
#define _USE_SYSLOG
#define _USE_PWD
#define _USE_GROUP
#define _USE_LIMITS
#define _USE_MISC
#endif /* DOXYGEN */
#endif /* SYSINCLUDES_H */
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:47
|
Update of /cvsroot/libimdb/libimdb/include/libimdb
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/include/libimdb
Added Files:
dict.h parser.h
Log Message:
initial checkin
--- NEW FILE: dict.h ---
/**
* @file
* @verbatim $Id: dict.h,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
#ifndef IMDBDICT_H
# define IMDBDICT_H
typedef struct imdbDict_s imdbDict_t;
imdbDict_t *
imdbDict_create(jlogHandle_t *logh,
const char *dbsDir,
const char *dictDir);
int
imdbDict_destroy(jlogHandle_t *logh,
imdbDict_t *dict);
int
imdbDict_indexMovies(jlogHandle_t *logh,
imdbDict_t *dict);
#endif /* IMDBDICT_H */
--- NEW FILE: parser.h ---
/**
* @file
* @verbatim $Id: parser.h,v 1.1 2003/06/16 04:18:38 jveldhuis Exp $ @endverbatim
*/
#ifndef IMDBPARSER_H
# define IMDBPARSER_H
#ifndef SWIG
typedef struct imdbParser_s imdbParser_t;
typedef enum {
isMovie=1,
isTVSeries=2,
isTVMovie=3,
isVideoMovie=4, /* made for video movie */
isVideoGame=5,
isTVMiniSeries=6,
} MovieType_e;
typedef void (progressStarting_cb_t)(jlogHandle_t *logh,
imdbParser_t *imdbh,
const char *shortDescription,
int itemEstimate);
/* returns number of next item progrssUpdate
needs to be called for */
typedef int (progressUpdate_cb_t)(jlogHandle_t *logh,
imdbParser_t *imdbh,
int itemCount,
int itemEstimate);
typedef void (progressFinished_cb_t)(jlogHandle_t *logh,
imdbParser_t *imdbh,
int itemCount,
int abortCode/*non-zero if aborted*/);
#endif
typedef enum {
LIST_MOVIES,
LIST_DIRECTORS,
LIST_ACTORS,
LIST_ACTRESSES,
} ListFile_e;
#ifndef SWIG
#define MAX_ALLOWED_TITLE_LENGTH 1024
#define MAX_ALLOWED_ROMANNUMERALS_LENGTH 20
struct MovieLabel_s {
char title[MAX_ALLOWED_TITLE_LENGTH];
MovieType_e type;
char romanNumberalsInYear[MAX_ALLOWED_ROMANNUMERALS_LENGTH];
int yearNumber;
};
struct MovieInList_s {
int lineNumber;
int number;
char *label;
MovieType_e type;
char *title;
int year;
char *yearRomanNumberals; /* NULL if non appeared */
};
struct DirectorInList_s {
int lineNumber;
int number;
char *name;
char *movieLabel;
};
struct ActorInList_s {
int lineNumber;
int number;
char *name;
int billing;
int isNarrator; /*0 or 1*/
char *characterName;
char *characterNameAka;
char *movieLabel;
};
typedef int (ListEntry_cb_t)(jlogHandle_t *logh,
imdbParser_t *imdbh,
ListFile_e lf,
const void *entry);
#endif
imdbParser_t *
imdbParser_open(jlogHandle_t *logh,
const char *dbsDir,
ListEntry_cb_t listentry_cb);
/* associate some handle to user data */
void *
imdbParser_setUserHandle(jlogHandle_t *logh,
imdbParser_t *parser,
void *userHandle);
void *
imdbParser_getUserHandle(jlogHandle_t *logh,
imdbParser_t *parser);
int
imdbParser_close(jlogHandle_t *logh,
imdbParser_t *imdbh);
int
imdbParser_setProgressCallbacks(jlogHandle_t *logh,
imdbParser_t *parser,
progressStarting_cb_t *starting_cb,
progressUpdate_cb_t *update_cb,
progressFinished_cb_t *finished_cb);
int
imdbParser_disableProgressCallbacks(jlogHandle_t *logh,
imdbParser_t *parser);
int
imdbParser_decodeMovieLabel(jlogHandle_t *logh,
const char *pathname,
int lineNumber,
const char *label,
struct MovieLabel_s *results);
int
imdbParser_moviesParse(jlogHandle_t *logh,
imdbParser_t *imdbh);
int
imdbParser_directorsParse(jlogHandle_t *logh,
imdbParser_t *parser);
int
imdbParser_actorsParse(jlogHandle_t *logh,
imdbParser_t *parser);
int
imdbParser_actressesParse(jlogHandle_t *logh,
imdbParser_t *parser);
#endif /* IMDBPARSER_H */
|
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:17:06
|
Update of /cvsroot/libimdb/libimdb/demo/indexMovies In directory sc8-pr-cvs1:/tmp/cvs-serv11532/indexMovies Log Message: Directory /cvsroot/libimdb/libimdb/demo/indexMovies added to the repository |