--- Sjeng-Free-11.0/book.c.orig Thu Sep 27 21:13:00 2001 +++ Sjeng-Free-11.0/book.c Thu Sep 27 22:22:17 2001 @@ -38,6 +38,10 @@ #define book_solid 4 /* = */ #define book_murky 5 /* ?! */ +#undef fopen +#define fopen book_fopen +FILE * book_fopen(const char * name, const char * mode); + int init_book (void) { /* simply read all the book moves into a book array. The book will be --- Sjeng-Free-11.0/newbook.c.orig Thu Sep 27 21:25:03 2001 +++ Sjeng-Free-11.0/newbook.c Thu Sep 27 22:29:06 2001 14 if (Variant == Normal) - binbook = gdbm_open("nbook.bin", 16384, GDBM_READER, 0, NULL); + binbook = gdbm_open(SJENG_LIB_PATH "/nbook.bin", 16384, GDBM_READER, 0, NULL); else if (Variant == Suicide) - binbook = gdbm_open("sbook.bin", 16384, GDBM_READER, 0, NULL); + binbook = gdbm_open(SJENG_LIB_PATH "/sbook.bin", 16384, GDBM_READER, 0, NULL); else if (Variant == Losers) - binbook = gdbm_open("lbook.bin", 16384, GDBM_READER, 0, NULL); + binbook = gdbm_open(SJENG_LIB_PATH "/lbook.bin", 16384, GDBM_READER, 0, NULL); else - binbook = gdbm_open("zbook.bin", 16384, GDBM_READER, 0, NULL); + binbook = gdbm_open(SJENG_LIB_PATH "/zbook.bin", 16384, GDBM_READER, 0, NULL); if (binbook == NULL) --- Sjeng-Free-11.0/rcfile.c.orig Thu Sep 27 21:36:59 2001 +++ Sjeng-Free-11.0/rcfile.c Thu Sep 27 21:39:42 2001 @@ -47,6 +47,10 @@ int cfg_attackeval; float cfg_scalefac; +#undef fopen +#define fopen book_fopen +FILE * book_fopen(const char * name, const char * mode); + void read_rcfile (void) { int i; --- Sjeng-Free-11.0/sjeng.c.orig Thu Sep 27 22:21:25 2001 +++ Sjeng-Free-11.0/sjeng.c Thu Sep 27 22:39:44 2001 @@ -971,3 +971,26 @@ return 0; } + +#define MAXBOOKPATH 1000 + +FILE * book_fopen(const char * name, const char * mode) +{ + /* We search a couple of different directories */ + char path[MAXBOOKPATH]; + FILE * f; + const char * home; + + if (f = fopen(name, mode)) /* Current directory */ + return f; + if (home = getenv("HOME")) + if (snprintf(path, MAXBOOKPATH, "%s/lib/sjeng/%s", home, name) + < MAXBOOKPATH + ) + if (f = fopen(path, mode)) /* ~/lib/sjeng */ + return f; + if (snprintf(path, MAXBOOKPATH, "%s/%s", SJENG_LIB_PATH, name) < MAXBOOKPATH) + if (f = fopen(path, mode)) /* $(SJENG_LIB_PATH)/sjeng */ + return f; + return NULL; +} --- Sjeng-Free-11.0/sjeng.h.orig Thu Aug 30 07:59:35 2001 +++ Sjeng-Free-11.0/sjeng.h Thu Sep 27 22:38:07 2001 @@ -39,6 +39,8 @@ #define NDEBUG #include +#define SJENG_LIB_PATH "/usr/local/lib/sjeng" + #define DIE (*(int *)(NULL) = 0) /* GCP : my code uses WHITE=0 and BLACK=1 so reverse this */