From: composer@Beyond.Dreams.ORG (Jeff Kellem) Newsgroups: comp.infosystems.wais Subject: Re: freeWAIS on BSD/386 Date: 19 Jul 93 01:11:49 Organization: Beyond Dreams Reply-To: composer@Beyond.Dreams.ORG NNTP-Posting-Host: toy.dreams.org In-reply-to: ejohnson@enuxha.eas.asu.edu's message of Wed, 14 Jul 1993 18:47:14 GMT [ Note: this also has a bug fix, in addition to the porting effort -- the strcmp() in ir/sersrch.c below. ] Patch file for freeWAIS 0.1 to run on BSDI's BSD/386 OS [ for BSD/386 version 1.0 March 1993 ] This patch should enable freeWAIS version 0.1 to run on BSDI's BSD/386 operating system. freeWAIS is available via anonymous ftp from ftp.cnidr.org as: /pub/NIDR.tools/freeWAIS-0.1.tar.Z This patch has NOT been THOROUGHLY tested, but simple and quick tests indicate that it works. It should at least be a start to get you going. The main problems were: o that freeWAIS was using code based on BIG_ENDIAN being #defined. Under 4.4BSD (and BSD/386), both BIG_ENDIAN and LITTLE_ENDIAN are defined and tested against BYTE_ORDER; so, code for a big endian machine was being used instead of the correct code for a little endian (i386) machine. o mixture of stdio(3) and low-level read/lseek(2) calls o no getdomainname(2) call in 4.4BSD (and BSD/386) NOTE: I have not taken the time to make sure the X client in the x subdirectory works. It tickles a bug in the 4.4BSD make, which I haven't taken the time to track down, yet. But, it is possible to start compilation by cd-ing into the x subdirectory first -- this misses the defaults you set in the top-level Makefile -- OR by using GNU make, assuming GNU make is called gmake via (at the top-level directory): gmake MAKE=gmake x There will still be some code changes to be made before the X clients will fully work. I might make another patch later, time permitting. The changes were made to get freeWAIS working on BSD/386. No effort was made to make it any more portable; that would require more thought throughout the entire source tree. Enjoy... -jeff Jeff Kellem Internet: composer@Beyond.Dreams.ORG ===CUT HERE===freeWAIS-0.1-bsdi.patch=== diff -c -r freeWAIS-0.1-DIST/config.c freeWAIS-0.1/config.c *** freeWAIS-0.1-DIST/config.c Wed Apr 7 15:14:04 1993 --- freeWAIS-0.1/config.c Sun Jul 18 12:50:26 1993 *************** *** 103,112 **** cp=(unsigned char*)&l; if(*cp == 0xde) { ! printf("#define BIG_ENDIAN\n"); } else { if(*cp == 0xef) { ! printf("#define LITTLE_ENDIAN\n"); } else { fprintf(stderr,"Error: can't find out byte order\n"); exit(1); --- 103,112 ---- cp=(unsigned char*)&l; if(*cp == 0xde) { ! printf("#define WAIS_BIG_ENDIAN\n"); } else { if(*cp == 0xef) { ! printf("#define WAIS_LITTLE_ENDIAN\n"); } else { fprintf(stderr,"Error: can't find out byte order\n"); exit(1); diff -c -r freeWAIS-0.1-DIST/ir/byte_order.h freeWAIS-0.1/ir/byte_order.h *** freeWAIS-0.1-DIST/ir/byte_order.h Wed Apr 7 14:48:08 1993 --- freeWAIS-0.1/ir/byte_order.h Sun Jul 18 12:49:48 1993 *************** *** 22,28 **** This macro turns a pointer to long into a pointer to a {1,2,3} byte value */ ! #ifdef BIG_ENDIAN #define ASSIGN_HELPER(var,size) (FOUR_BYTE*)((ONE_BYTE*) &var+(sizeof(FOUR_BYTE)-size)) #else #define ASSIGN_HELPER(var,size) (FOUR_BYTE *)&var --- 19,25 ---- This macro turns a pointer to long into a pointer to a {1,2,3} byte value */ ! #ifdef WAIS_BIG_ENDIAN #define ASSIGN_HELPER(var,size) (FOUR_BYTE*)((ONE_BYTE*) &var+(sizeof(FOUR_BYTE)-size)) #else #define ASSIGN_HELPER(var,size) (FOUR_BYTE *)&var *************** *** 44,50 **** ASSIGN_CANON uses canonical (big_endian) byte ordering */ ! #if defined(NATIVE_ORDER) || defined(BIG_ENDIAN) #define ASSIGN ASSIGN_NATIVE #else #define ASSIGN ASSIGN_CANON --- 41,47 ---- ASSIGN_CANON uses canonical (big_endian) byte ordering */ ! #if defined(NATIVE_ORDER) || defined(WAIS_BIG_ENDIAN) #define ASSIGN ASSIGN_NATIVE #else #define ASSIGN ASSIGN_CANON diff -c -r freeWAIS-0.1-DIST/ir/ir.c freeWAIS-0.1/ir/ir.c *** freeWAIS-0.1-DIST/ir/ir.c Fri Apr 9 16:01:49 1993 --- freeWAIS-0.1/ir/ir.c Sun Jul 18 14:45:49 1993 *************** *** 1234,1239 **** --- 1237,1244 ---- freeWAISSearchResponse(wais_response); /* free headers & seed_words_used */ } + /* should really be HAVE_ALPHASORT or something else -- and be elsewhere! */ + #ifndef __bsdi__ static int alphasort(d1, d2) struct dirent **d1; *************** *** 1241,1246 **** --- 1246,1252 ---- { return strcmp((*d1)->d_name, (*d2)->d_name); } + #endif /* !__bsdi__ */ static int filesonly(e) diff -c -r freeWAIS-0.1-DIST/ir/sersrch.c freeWAIS-0.1/ir/sersrch.c *** freeWAIS-0.1-DIST/ir/sersrch.c Fri Apr 9 11:02:21 1993 --- freeWAIS-0.1/ir/sersrch.c Sun Jul 18 14:53:16 1993 *************** *** 636,642 **** return(-1); } ! read(fileno(stream),index_buffer,INDEX_BLOCK_HEADER_SIZE); ASSIGN(not_full_flag, INDEX_BLOCK_FLAG_SIZE, --- 636,642 ---- return(-1); } ! fread(index_buffer, 1L, INDEX_BLOCK_HEADER_SIZE, stream); ASSIGN(not_full_flag, INDEX_BLOCK_FLAG_SIZE, *************** *** 707,714 **** int wgt; int did; if(count%1024 == 0) { ! read(fileno(stream),index_buffer,INDEX_ELEMENT_SIZE* ! MIN(1024,number_of_valid_entries-count)); i=index_buffer; } ASSIGN(wgt,WEIGHT_SIZE, --- 707,715 ---- int wgt; int did; if(count%1024 == 0) { ! fread(index_buffer, 1L, ! INDEX_ELEMENT_SIZE*MIN(1024,number_of_valid_entries-count), ! stream); i=index_buffer; } ASSIGN(wgt,WEIGHT_SIZE, *************** *** 760,766 **** txt_stream = s_fopen(txt_filename, "rb"); strcpy(prev_txt_filename, txt_filename); } ! else if (0 != strcmp(txt_stream, prev_txt_filename)) { s_fclose(txt_stream); txt_stream = s_fopen(txt_filename, "rb"); strcpy(prev_txt_filename, txt_filename); /* 2/92 GS TLG */ --- 761,767 ---- txt_stream = s_fopen(txt_filename, "rb"); strcpy(prev_txt_filename, txt_filename); } ! else if (0 != strcmp(txt_filename, prev_txt_filename)) { s_fclose(txt_stream); txt_stream = s_fopen(txt_filename, "rb"); strcpy(prev_txt_filename, txt_filename); /* 2/92 GS TLG */ diff -c -r freeWAIS-0.1-DIST/lib/Makefile freeWAIS-0.1/lib/Makefile *** freeWAIS-0.1-DIST/lib/Makefile Tue Feb 16 10:09:00 1993 --- freeWAIS-0.1/lib/Makefile Tue Apr 20 00:43:03 1993 *************** *** 42,56 **** LIBRARY = $(DEST)/libftw.a ! OBJS = alphasort.o \ ! freedir.o \ ! ftw.o \ ! scandir.o ! ! SRCS = alphasort.c \ ! freedir.c \ ! ftw.c \ ! scandir.c TESTOBJS = ftwtest.o ftwtest scantest.o scantest --- 45,59 ---- LIBRARY = $(DEST)/libftw.a ! OBJS = freedir.o \ ! ftw.o ! # alphasort.o \ ! # scandir.o ! ! SRCS = freedir.c \ ! ftw.c ! # alphasort.c \ ! # scandir.c TESTOBJS = ftwtest.o ftwtest scantest.o scantest diff -c -r freeWAIS-0.1-DIST/ui/screen-ui.c freeWAIS-0.1/ui/screen-ui.c *** freeWAIS-0.1-DIST/ui/screen-ui.c Wed Apr 7 15:09:37 1993 --- freeWAIS-0.1/ui/screen-ui.c Tue Apr 20 01:15:04 1993 *************** *** 61,67 **** --- 61,69 ---- #include #include #include + #ifdef __bsdi__ /* netinet/in.h needs #define IN_H in it !!! on BSD/386 */ #include + #endif /* __bsdi__ */ #if (defined(ULTRIX) || defined(ultrix)) /* diff -c -r freeWAIS-0.1-DIST/ui/shell-ui.c freeWAIS-0.1/ui/shell-ui.c *** freeWAIS-0.1-DIST/ui/shell-ui.c Wed Apr 7 15:09:47 1993 --- freeWAIS-0.1/ui/shell-ui.c Sun Jul 18 15:43:01 1993 *************** *** 306,314 **** --- 306,317 ---- { char hostname[80]; + #ifndef __bsdi__ char domainname[80]; + #endif /* __bsdi__ */ gethostname(hostname, 80); + #ifndef __bsdi__ getdomainname(domainname, 80); #ifdef TELL_USER sprintf(userInfo, "waissearch %s, from host: %s.%s, user: %s", *************** *** 317,322 **** --- 320,334 ---- sprintf(userInfo, "waissearch %s, from host: %s.%s", VERSION, hostname, domainname); #endif + #else /* __bsdi__ */ + #ifdef TELL_USER + sprintf(userInfo, "waissearch %s, from host: %s, user: %s", + VERSION, hostname, getenv("USER")); + #else + sprintf(userInfo, "waissearch %s, from host: %s", + VERSION, hostname); + #endif + #endif /* !__bsdi__ */ if((message_length = init_connection(request_message, response_message, diff -c -r freeWAIS-0.1-DIST/ui/source.c freeWAIS-0.1/ui/source.c *** freeWAIS-0.1-DIST/ui/source.c Wed Apr 7 15:09:55 1993 --- freeWAIS-0.1/ui/source.c Sun Jul 18 15:42:30 1993 *************** *** 762,770 **** --- 762,773 ---- char userInfo[500]; char message[500]; char hostname[80]; + #ifndef __bsdi__ char domain[80]; + #endif /* __bsdi__ */ gethostname(hostname, 80); + #ifndef __bsdi__ getdomainname(domain, 80); #ifdef TELL_USER sprintf(userInfo, "%s %s, from host: %s.%s, user: %s", *************** *** 773,778 **** --- 776,790 ---- sprintf(userInfo, "%s %s, from host: %s.%s", command_name, VERSION, hostname, domain); #endif + #else /* __bsdi__ */ + #ifdef TELL_USER + sprintf(userInfo, "%s %s, from host: %s, user: %s", + command_name, VERSION, hostname, getenv("USER")); + #else + sprintf(userInfo, "%s %s, from host: %s", + command_name, VERSION, hostname); + #endif + #endif /* !__bsdi__ */ if(source->initp == FALSE) { if(source->server[0] == 0)