Glimpse under NT Glimpse 4.0 can be built using version 18 of the Cygnwin toolkit. The Cygwin toolkit is available from [3]http://www.cygnus.com Building After running configure, make the changes below. These changes can be wrapped in #ifdef _WIN32 or #ifdef __CYGWIN32__ main.c Comment out or ifdef out the lines that mention SIGURG. communicate.c, agrep/agrep.h Added the line #include to the top. communicate.c Ifdef out #include "sys/un.h" index/io.c Open all files in binary mode by oring O_BINARY to the open() call in my_fopen(). return open(temp, flag|O_BINARY, mode); This fixes runtime glimpseindexerrors about: read error on file xxx at offset xxx Substitute "rb" for "r" and "wb" for "w" The following shell script will do the trick: #! /bin/sh SRC=/src/glimpse-4.0.src cd $SRC files="get_filename.c get_index.c main.c main_server.c index/region.c \ index/partition.c index/io.c index/glimpse.c index/convert.c \ index/build_in.c compress/string.c compress/tbuild.c \ compress/uncast.c compress/cast.c compress/hash.c compress/misc.c \ compress/quick.c" for file in $files do echo $file sed 's/"r"/"rb"/' $file | sed 's/"w"/"wb"/' > t.c mv t.c $file done index/glimpse.h Set SYSTEM_SORT to #define SYSTEM_SORT "/gnuwin32/b18/H-i386-cygwin32/bin/sort" This fixes runtime glimpseindex errors about: SORT: invalid switch, as the MSDOS sort binary does not understand the -T flag. The alternative is to adjust your path so that the MSDOS sort is not first in your path. index/build_in.c The Cygwin b18 sort binary will truncate a file at the first Control-Z character. The workaround is to modify traverse1() so that just after the traverse() call, skip the call to sort traverse(); /* will produce .i2 and my_free allocated memory */ #ifdef _WIN32 #else [...] sprintf(s, "%s -10 '%s/%s'\n", SYSTEM_HEAD, escapesinglequote(INDEX_DIR, es 1), I2); system(s); #endif /*0*/ #endif /*_WIN32*/ index/build_in.c In traverse1(), we need to append the contents of .glimpse_tmpI2 onto .glimpse_index because under Cygwin b18, the cat command will only cop until the first Control-Z character. #ifdef _WIN32 /* Cygwin cat can't deal with files that contain control-Z chars. */ { FILE *fin, *fout; char tmpptr[BUFSIZ]; sprintf(s, "%s/%s",escapesinglequote(INDEX_DIR, es1), I2); if ((fin = fopen(s, "rb")) == (FILE *)NULL) { fprintf(stderr, "Failed to open %s:",s); perror(""); } sprintf(s, "%s/%s",escapesinglequote(INDEX_DIR, es2), INDEX_FILE); if ((fout = fopen(s, "ab")) == (FILE *)NULL) { fprintf(stderr, "Failed to open %s:",s); perror(""); } while(fgets(tmpptr,BUFSIZ,fin)) fputs(tmpptr, fout); fclose(fin); fclose(fout); } #else sprintf(s, "%s '%s/%s' >> '%s/%s'\n", SYSTEM_CAT, escapesinglequote(IND EX_DIR, es1), I2, escapesinglequote(INDEX_DIR, es2), INDEX_FILE); system(s); #endif _WIN32 index/glimpse.c Add fflush(TIMEFILE) fclose(TIMEFILE) above the fflush(MESSAGEFILE) linein main(). This gets rid of glimpseindex messages about ls: .glimpse_filetimes: Permission denied index/glimpse.c determine_sync(): Add the following block and place the rest of the body inside the #else statement. #ifdef _WIN32 strcpy(sync_path, "sync"); return 0; #else Note that under cygwin b18, sync will produce messages like sync(() called, but it is not done yet.. The next step obviates the need for calls to sync. For some reason, glimpse makes lots of calls to system() where it then execs a shell command (i.e. system("exec cp foo bar");. The problem here is that we don't have a reliable sync, so there is no way to ensure that the exec has finished and the files have been written out. The workaround is to remove all instances of exec that starts a double quoted string. The real fix here would be to parameterize the exec so that configure could set a #define properly and the lines that create the system() calls could use the #define (i.e. sprintf(s,"%s cp foo bar",SYSTEM_EXEC);. Below is a shell script that does the proper substitutions. #! /bin/sh SRC=/src/glimpse-4.0.src cd $SRC files="files="main.c compress/hash.c compress/string.c \ compress/tbuild.c index/glimpse.c index/build_in.c \ index/partition.c"index/io.c" for file in $files do echo $file sed 's/"exec /" /' $file > t.c mv t.c $file done Makefile In the install rules, add .exe to the end of glimpse etc. Glimpse under NT bugs glimpseindex produces messages about whereis and sync.