Skip to content

Commit

Permalink
support passing book and coeffs path with enviroment variable (this i…
Browse files Browse the repository at this point in the history
…s useful for tests)
  • Loading branch information
panstromek committed Feb 20, 2022
1 parent 9a70624 commit a2e4fef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion getcoeff.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,9 @@ init_coeffs( void ) {
getcwd(sPatternFile, sizeof(sPatternFile));
strcat(sPatternFile, "/" PATTERN_FILE);
#endif
char* env_coeffs = getenv("COEFFS_PATH");

coeff_stream = gzopen( sPatternFile, "rb" );
coeff_stream = gzopen(env_coeffs ? env_coeffs : sPatternFile, "rb" );
if ( coeff_stream == NULL )
fatal_error( "%s '%s'\n", FILE_ERROR, sPatternFile );

Expand Down
9 changes: 7 additions & 2 deletions zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,13 @@ main( int argc, char *argv[] ) {
global_setup( use_random, hash_bits );
init_thor_database();

if ( use_book )
init_learn( "book.bin", TRUE );
if ( use_book ) {
char *book_filename = getenv("BOOK_PATH");
if (book_filename == NULL) {
book_filename = "book.bin";
}
init_learn(book_filename, TRUE );
}
if ( use_random && !SCRIPT_ONLY ) {
time( &timer );
my_srandom( timer );
Expand Down

0 comments on commit a2e4fef

Please sign in to comment.