diff -ru Sjeng-Free-11.2-orig/book.c Sjeng-Free-11.2/book.c --- Sjeng-Free-11.2-orig/book.c 2011-07-23 23:26:30.000000000 +0200 +++ Sjeng-Free-11.2/book.c 2011-07-23 23:40:26.000000000 +0200 @@ -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 diff -ru Sjeng-Free-11.2-orig/newbook.c Sjeng-Free-11.2/newbook.c --- Sjeng-Free-11.2-orig/newbook.c 2011-07-23 23:26:30.000000000 +0200 +++ Sjeng-Free-11.2/newbook.c 2011-07-23 23:40:26.000000000 +0200 @@ -466,13 +466,13 @@ srand(time(0)); 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) Only in Sjeng-Free-11.2: newbook.c.orig diff -ru Sjeng-Free-11.2-orig/rcfile.c Sjeng-Free-11.2/rcfile.c --- Sjeng-Free-11.2-orig/rcfile.c 2011-07-23 23:26:30.000000000 +0200 +++ Sjeng-Free-11.2/rcfile.c 2011-07-23 23:40:26.000000000 +0200 @@ -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; diff -ru Sjeng-Free-11.2-orig/sjeng.c Sjeng-Free-11.2/sjeng.c --- Sjeng-Free-11.2-orig/sjeng.c 2011-07-23 23:26:30.000000000 +0200 +++ Sjeng-Free-11.2/sjeng.c 2011-07-23 23:40:26.000000000 +0200 @@ -975,3 +975,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; +} Only in Sjeng-Free-11.2: sjeng.c.orig diff -ru Sjeng-Free-11.2-orig/sjeng.h Sjeng-Free-11.2/sjeng.h --- Sjeng-Free-11.2-orig/sjeng.h 2011-07-23 23:26:30.000000000 +0200 +++ Sjeng-Free-11.2/sjeng.h 2011-07-23 23:40:26.000000000 +0200 @@ -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 */