├── CHANGES ├── CONTRIBUTIONS ├── ChangeLog ├── KNOWN_BUGS ├── LICENSE ├── Makefile.NeXT ├── Makefile.alpha ├── Makefile.hp ├── Makefile.in ├── Makefile.linux ├── Makefile.org ├── Makefile.rs6000 ├── Makefile.sgi ├── Makefile.solaris ├── Makefile.sunos ├── README ├── README.install ├── README.md ├── agrep ├── Makefile.NeXT ├── Makefile.alpha ├── Makefile.hp ├── Makefile.in ├── Makefile.linux ├── Makefile.rs6000 ├── Makefile.sgi ├── Makefile.solaris ├── Makefile.sunos ├── README ├── agrep.1 ├── agrep.algorithms ├── agrep.c ├── agrep.chronicle ├── agrep.h ├── asearch.c ├── asearch1.c ├── asplit.c ├── bitap.c ├── bitap.c.orig ├── checkfile.c ├── checkfile.h ├── checksg.c ├── compat.c ├── config.h ├── contribution.list ├── defs.h ├── delim.c ├── dummyfilters.c ├── dummysyscalls.c ├── follow.c ├── io.c ├── io.c.orig ├── main.c ├── maskgen.c ├── newmgrep.c ├── parse.c ├── preprocess.c ├── putils.c ├── re.h ├── recursive.c ├── sgrep.c └── utilities.c ├── communicate.c ├── compress ├── Makefile.NeXT ├── Makefile.alpha ├── Makefile.hp ├── Makefile.in ├── Makefile.linux ├── Makefile.rs6000 ├── Makefile.sgi ├── Makefile.solaris ├── Makefile.sunos ├── README ├── cast.c ├── compress.chronicle ├── defs.h ├── hash.c ├── main_cast.c ├── main_tbuild.c ├── main_uncast.c ├── misc.c ├── quick.c ├── string.c ├── tbuild.c ├── test.c ├── tmemlook.c ├── trecursive.c ├── tsimpletest.c └── uncast.c ├── configure ├── configure.in ├── defs.h ├── dynfilters ├── Makefile.in ├── Makefile.linux ├── README ├── htuml2txt.lex └── sotest.c ├── genpatch ├── gentar ├── get_filename.c ├── get_index.c ├── glimpse.1 ├── glimpse.chronicle ├── glimpse ├── CHANGES ├── CONTRIBUTIONS ├── ChangeLog ├── KNOWN_BUGS ├── Makefile.NeXT ├── Makefile.alpha ├── Makefile.hp ├── Makefile.in ├── Makefile.linux ├── Makefile.org ├── Makefile.rs6000 ├── Makefile.sgi ├── Makefile.solaris ├── Makefile.sunos ├── README ├── README.install ├── communicate.c ├── configure ├── configure.in ├── defs.h ├── genpatch ├── gentar ├── get_filename.c ├── get_index.c ├── glimpse.1 ├── glimpse.chronicle ├── glimpseindex.1 ├── glimpseserver.1 ├── install-sh ├── main.c ├── mkinstalldirs └── split.c ├── glimpseindex.1 ├── glimpseserver.1 ├── index ├── Makefile.NeXT ├── Makefile.alpha ├── Makefile.hp ├── Makefile.in ├── Makefile.linux ├── Makefile.rs6000 ├── Makefile.sgi ├── Makefile.solaris ├── Makefile.sunos ├── README ├── build_in.c ├── convert.c ├── dir.c ├── filetype.c ├── fixname.c ├── getword.c ├── glimpse.c ├── glimpse.h ├── index.chronicle ├── io.c ├── lib.c ├── memlook.c ├── partition.c ├── region.c ├── region.h ├── simpletest.c └── utils.c ├── install-sh ├── libtemplate ├── Makefile.NeXT ├── Makefile.alpha ├── Makefile.hp ├── Makefile.in ├── Makefile.linux ├── Makefile.rs6000 ├── Makefile.sgi ├── Makefile.solaris ├── Makefile.sunos ├── README ├── include │ ├── autoconf.h │ ├── autoconf.h.in │ ├── ccache.h │ ├── ccache_list.h │ ├── ccache_queue.h │ ├── config.h │ ├── gdbm.h │ ├── paths.h │ ├── paths.h.in │ ├── template.h │ ├── time_it.h │ ├── url.h │ └── util.h ├── lib │ ├── Makefile.in │ └── Makefile.sunos ├── template │ ├── Attributes.html │ ├── Makefile.NeXT │ ├── Makefile.alpha │ ├── Makefile.hp │ ├── Makefile.in │ ├── Makefile.linux │ ├── Makefile.rs6000 │ ├── Makefile.sgi │ ├── Makefile.solaris │ ├── Makefile.sunos │ ├── README │ ├── cksoif.c │ ├── iafa2soif.c │ ├── lsm2soif.c │ ├── netfind2soif.pl │ ├── pcindex2soif.c │ ├── print-attr.c │ ├── print-template.c │ ├── print-urlrefs.c │ ├── soif.pl │ ├── template.c │ └── translate-urls.c └── util │ ├── Makefile.NeXT │ ├── Makefile.alpha │ ├── Makefile.hp │ ├── Makefile.in │ ├── Makefile.linux │ ├── Makefile.rs6000 │ ├── Makefile.sgi │ ├── Makefile.solaris │ ├── Makefile.sunos │ ├── README │ ├── buffer.c │ ├── harvest.c │ ├── host.c │ ├── log.c │ ├── strdup.c │ ├── strerror.c │ ├── string.c │ ├── system.c │ └── xmalloc.c ├── main.c ├── mkinstalldirs ├── split.c └── test ├── check.sh └── test.txt /KNOWN_BUGS: -------------------------------------------------------------------------------- 1 | * Thu Aug 20 14:56:44 1998 2 | 3 | agrep -v fails to write anything unless at least one line (possibly, a 4 | particular line) of the input matches the pattern that we're trying to 5 | mismatch. The non-glimpse agrep does not have this problem. E.g.: 6 | 7 | thalia[189]$ for p in O e n w o r ; do echo "Pattern '${p}':" ; echo "One@Two@Three" | tr '@' '\012' | agrep -v ${p} ; done 8 | Pattern 'O': 9 | Pattern 'e': 10 | Two 11 | Pattern 'n': 12 | Pattern 'w': 13 | One 14 | Pattern 'o': 15 | One 16 | Pattern 'r': 17 | One 18 | Two 19 | 20 | thalia[190]$ for p in O e n w o r ; do echo "Pattern '${p}':" ; echo "One@Two@Three" | tr '@' '\012' | agrep-2.04 -v ${p} ; done 21 | Pattern 'O': 22 | Two 23 | Three 24 | Pattern 'e': 25 | Two 26 | Pattern 'n': 27 | Two 28 | Three 29 | Pattern 'w': 30 | One 31 | Three 32 | Pattern 'o': 33 | One 34 | Three 35 | Pattern 'r': 36 | One 37 | Two 38 | 39 | The non-glimpse agrep uses bitap to do the search; the glimpse one uses bm. 40 | Some pre-condition is unsatisfied in the call to bm, because it overruns the 41 | input text buffer by a huge amount in attempting to find a pattern match. 42 | 43 | It isn't obvious to me where this bug is arising, or how to fix it. 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Anyone distributing the Glimpse code should include the following license: 2 | 3 | Copyright 1996, Arizona Board of Regents on behalf of The University of Arizona. 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 8 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | GLIMPSE 4.18: searching entire file systems 2 | (http://webglimpse.org/) 3 | (http://glimpse.cs.arizona.edu/) 4 | 5 | For installation instructions, see README.install 6 | 7 | Glimpse is a very powerful indexing and query system that allows you to 8 | search through all your files very quickly. It can be used by 9 | individuals for their personal file systems as well as by organizations 10 | for large data collections. Glimpse is also the basis of WebGlimpse, 11 | which provides search for web sites, and it is the default search engine 12 | in Harvest (see below). 13 | 14 | Glimpseindex, which you run by saying "glimpseindex DIR" builds an 15 | index of all text files in the tree rooted at DIR. 16 | (e.g., glimpseindex ~ indexes all your files.) With it, glimpse can 17 | search through all files much the same way as agrep (or any other 18 | grep), except that you don't have to specify file names and the search 19 | is fast. For example, 20 | 21 | glimpse -1 unbelievable 22 | 23 | will find all occurrences (in all your files!) of "unbelievable" 24 | allowing one spelling error; 25 | 26 | glimpse -F mail arizona 27 | 28 | will find all occurrences of "arizona" in all files with "mail" somewhere 29 | in their name; 30 | 31 | glimpse 'Arizona desert;windsurfing' 32 | 33 | will find all lines that contain both "Arizona desert" and "windsurfing". 34 | 35 | Glimpse supports three types of indexes: a tiny one (2-3% of the 36 | size of all files), a small one (7-9%), and a medium one (20-30%). 37 | The larger the index the faster the search. 38 | Glimpse supports most of agrep's options (agrep is our powerful version 39 | of grep, and it is part of glimpse) including approximate matching 40 | (e.g., finding misspelled words), Boolean queries, and even some 41 | limited forms of regular expressions. 42 | 43 | The WWW home page for glimpse is in 44 | http://glimpse.cs.arizona.edu/ 45 | It includes links to the source, binaries for most UNIX systems, 46 | documentations, articles, and more. 47 | 48 | The WebGlimpse home page is in 49 | http://glimpse.cs.arizona.edu/webglimpse/ 50 | 51 | Harvest's WWW home page is 52 | http://harvest.cs.colorado.edu/ 53 | (Harvest is an integrated set of tools to gather, extract, 54 | organize, search, cache, and replicate relevant information 55 | across the Internet.) 56 | 57 | Mail glimpse-request@cs.arizona.edu to be added to the glimpse mailing list. 58 | Mail glimpse@cs.arizona.edu to report bugs, ask questions, discuss 59 | tricks for using glimpse, etc. (This is a moderated mailing list.) 60 | 61 | Udi Manber, Burra Gopal, and Sun Wu. 62 | 63 | Please report bugs online at http://webglimpse.net/contact.php 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### Glimpse 2 | 3 | 4 | This is the official repository for Glimpse. 5 | 6 | (further text to be added here) 7 | 8 | 9 | #### Agrep 10 | 11 | 12 | An essential part of Glimpse is Agrep, - the approximate GREP for fast fuzzy string searching. Files are searched for a string or regular expression, with approximate matching capabilities and user-definable records. Developed 1989-1991 by Udi Manber, Sun Wu et al. at the University of Arizona. 13 | 14 | The official Agrep repository can be found on https://github.com/Wikinaut/agrep . 15 | -------------------------------------------------------------------------------- /agrep/Makefile.in: -------------------------------------------------------------------------------- 1 | # Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. 2 | 3 | srcdir = @srcdir@ 4 | VPATH = @srcdir@ 5 | SHELL = /bin/sh 6 | CC = @CC@ 7 | AR = @AR@ 8 | RANLIB = @RANLIB@ 9 | CP = @CP@ 10 | STRIP = @STRIP@ 11 | INSTALL = @INSTALL@ 12 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 13 | INSTALL_DATA = @INSTALL_DATA@ 14 | INSTALL_MAN = ${INSTALL} -m 444 15 | DEFS = 16 | 17 | prefix = @prefix@ 18 | exec_prefix = @exec_prefix@ 19 | binprefix = 20 | manprefix = 21 | 22 | bindir = $(exec_prefix)/bin 23 | libdir = $(exec_prefix)/lib 24 | mandir = $(prefix)/man/man1 25 | manext = 1 26 | 27 | MAN1 = agrep.1 28 | 29 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 30 | 31 | # The binaries will be made in ../bin/. and the agrep library in ../lib 32 | # You normally don't have to change them. 33 | BINDIR = ../bin 34 | LIBDIR = ../lib 35 | TCOMP = cast 36 | TCOMPDIR = ../compress 37 | AGREPDIR = ../agrep 38 | TEMPLATEDIR = ../libtemplate 39 | 40 | # You can change the target to use the "cast" (compression) library by changing: 41 | # all: $(NOTCPROG) 42 | # to: 43 | # all: $(PROG) 44 | # You must also define DOTCOMPRESSED below to be 1 instead of 0. 45 | 46 | DOTCOMPRESSED = 0 47 | 48 | OPTIMIZEFLAGS = -O2 49 | INCLUDEFLAGS = -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 50 | 51 | # AGREP_POINTER is defined in autoconf.h 52 | MYDEFINEFLAGS = -DMEASURE_TIMES=0 -DDOTCOMPRESSED=$(DOTCOMPRESSED) 53 | CFLAGS = $(MYDEFINEFLAGS) $(INCLUDEFLAGS) $(DEFS) 54 | LDFLAGS = 55 | OTHERLIBS = 56 | 57 | PROG = agrep 58 | NOTCPROG = notc$(PROG) 59 | LIB = $(LIBDIR)/lib$(PROG).a 60 | 61 | all: $(LIB) $(NOTCPROG) 62 | 63 | install: all install-man 64 | $(INSTALL) $(PROG) $(bindir) 65 | 66 | install-man: $(MAN1) 67 | $(INSTALL_MAN) $(MAN1) $(mandir) 68 | 69 | clean: 70 | rm -f $(LIB) $(OBJS) dummyfilters.o main.o core a.out $(PROG) 71 | 72 | distclean: clean 73 | rm -f Makefile 74 | 75 | HDRS = agrep.h checkfile.h re.h defs.h config.h 76 | TCOMPLIBOBJ = \ 77 | $(TCOMPDIR)/hash.o \ 78 | $(TCOMPDIR)/string.o \ 79 | $(TCOMPDIR)/misc.o \ 80 | $(TCOMPDIR)/quick.o \ 81 | $(TCOMPDIR)/cast.o \ 82 | $(TCOMPDIR)/uncast.o \ 83 | $(TCOMPDIR)/tsimpletest.o \ 84 | $(TCOMPDIR)/tbuild.o\ 85 | $(TCOMPDIR)/tmemlook.o 86 | OBJS = \ 87 | follow.o \ 88 | asearch.o \ 89 | asearch1.o \ 90 | agrep.o \ 91 | bitap.o \ 92 | checkfile.o \ 93 | compat.o \ 94 | maskgen.o \ 95 | parse.o \ 96 | checksg.o \ 97 | preprocess.o \ 98 | delim.o \ 99 | asplit.o \ 100 | recursive.o \ 101 | sgrep.o \ 102 | newmgrep.o \ 103 | utilities.o 104 | 105 | $(PROG): $(OBJS) main.o $(LIBDIR)/lib$(TCOMP).a 106 | $(CC) -L$(LIBDIR) $(LDFLAGS) -o $@ $(OBJS) main.o -l$(TCOMP) $(OTHERLIBS) 107 | $(AR) rcv $(LIB) $(OBJS) $(TCOMPLIBOBJ) 108 | $(RANLIB) $(LIB) 109 | 110 | $(LIBDIR)/lib$(TCOMP).a: 111 | cd $(TCOMPDIR) ; $(MAKE) 112 | 113 | $(LIB): $(OBJS) dummyfilters.o 114 | $(AR) rcv $(LIB) $(OBJS) dummyfilters.o 115 | $(RANLIB) $(LIB) 116 | 117 | $(NOTCPROG): $(OBJS) dummyfilters.o main.o 118 | $(CC) $(LDFLAGS) -o $(PROG) $(OBJS) dummyfilters.o main.o $(OTHERLIBS) 119 | 120 | compat.o: agrep.h defs.h config.h 121 | asearch.o: agrep.h defs.h config.h 122 | asearch1.o: agrep.h defs.h config.h 123 | bitap.o: agrep.h defs.h config.h 124 | checkfile.o: agrep.h checkfile.h defs.h config.h 125 | follow.o: re.h agrep.h defs.h config.h 126 | main.o: agrep.h checkfile.h defs.h config.h dummysyscalls.c 127 | agrep.o: agrep.h checkfile.h defs.h config.h 128 | newmgrep.o: agrep.h defs.h config.h 129 | maskgen.o: agrep.h defs.h config.h 130 | next.o: agrep.h defs.h config.h 131 | parse.o: re.h agrep.h defs.h config.h 132 | preprocess.o: agrep.h defs.h config.h 133 | checksg.o: agrep.h checkfile.h defs.h config.h 134 | delim.o: agrep.h defs.h config.h 135 | asplit.o: agrep.h defs.h config.h 136 | sgrep.o: agrep.h defs.h config.h 137 | abm.o: agrep.h defs.h config.h 138 | utilities.o: re.h agrep.h defs.h config.h 139 | dummyfilters.o: dummyfilters.c 140 | -------------------------------------------------------------------------------- /agrep/agrep.algorithms: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | The implementation of agrep includes the following algorithms. 3 | Except for exact matching of simple patterns, for which we use 4 | a simple variation of the Boyer-Moore algorithm, 5 | all the algorithms (listed below) were designed by Sun Wu and Udi Manber. 6 | 7 | 1. bitap: The most general algorithm inside agrep. 8 | It supports many extensions such as approximate regular expression 9 | pattern matching, non-uniform costs, simultaneous matching of 10 | multiple patterns, mixed exact/approximate matching, etc. 11 | The algorithm is described in agrep.ps.1. 12 | 13 | 2. mgrep: A sub-linear expect-time algorithm for matching a set of patterns. 14 | It assumes that the set of patterns contains k patterns, and that 15 | the shortest pattern is of size m. 16 | See agrep.ps.2 for a brief description of the algorithm. 17 | 18 | 3. amonkey: a Boyer-Moore style algorithm for approximate pattern matching. 19 | let b = log_c (2*m), where c is the size of alphabet set. 20 | In the preprocessing, a table is built to determine whether 21 | a given substring of size b is in the pattern. 22 | Suppose we are looking for matches with at most k errors. 23 | The search is done in two passes. 24 | In the first pass (the filtering pass), the areas in the text 25 | that have a possibility to contain the matches are marked. 26 | The second pass finds the matches in those marked areas. 27 | The search in the first pass is done in the following way. 28 | Suppose the end position of the pattern is currently aligned with 29 | position tx in the text. 30 | The algorithm scans backward from tx until either (k+1) blocks 31 | that do not occur in the pattern have been scanned, or 32 | the scan has passed position (tx-m+k). 33 | In the former case, pattern is shifted forward to align 34 | the beginning position of the pattern with one character after 35 | the position in the text where the scan was stopped. 36 | In the latter case, we marked tx-m to tx+m as a candidate area. 37 | 38 | 4. mmonkey: Combining the mgrep algorithm with a partition technique, we 39 | have an algorithm with the same time complexity as amonkey. 40 | For ASCII text and pattern, this algorithm is faster than amonkey. 41 | The principle of the partition technique is as follows. 42 | Let A and B be two strings of size m. 43 | If we partition A into (k+1) blocks, then the distance between 44 | A and B is > k if none of the blocks of A occur in B. 45 | This implies that to match A with no more than k errors, 46 | B has to contain a substring that matches exactly one block of A. 47 | A brief description can be found in agrep.ps.2. 48 | 49 | -------------------------------------------------------------------------------- /agrep/checkfile.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* 3 | * checkfile.c 4 | * takes a file name and checks to see if a file is a regular ascii file 5 | * 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "checkfile.h" 15 | 16 | #ifndef S_ISREG 17 | #define S_ISREG(mode) (0100000&(mode)) 18 | #endif 19 | 20 | #ifndef S_ISDIR 21 | #define S_ISDIR(mode) (0040000&(mode)) 22 | #endif 23 | 24 | #define MAXLINE 512 25 | 26 | extern char Progname[]; 27 | extern int errno; 28 | 29 | unsigned char ibuf[MAXLINE]; 30 | 31 | /************************************************************************** 32 | * 33 | * check_file 34 | * input: filename or path (null-terminated character string) 35 | * returns: int (0 if file is a regular file, non-0 if not) 36 | * 37 | * uses stat(2) to see if a file is a regular file. 38 | * 39 | ***************************************************************************/ 40 | 41 | int check_file(fname) 42 | char *fname; 43 | 44 | { 45 | struct stat buf; 46 | 47 | if (my_stat(fname, &buf) != 0) { 48 | if (errno == ENOENT) 49 | return NOSUCHFILE; 50 | else 51 | return STATFAILED; 52 | } 53 | else { 54 | /* 55 | int ftype; 56 | if (S_ISREG(buf.st_mode)) { 57 | if ((ftype = samplefile(fname)) == ISASCIIFILE) { 58 | return ISASCIIFILE; 59 | } else if (ftype == ISBINARYFILE) { 60 | return ISBINARYFILE; 61 | } else if (ftype == OPENFAILED) { 62 | return OPENFAILED; 63 | } 64 | } 65 | if (S_ISDIR(buf.st_mode)) { 66 | return ISDIRECTORY; 67 | } 68 | if (S_ISBLK(buf.st_mode)) { 69 | return ISBLOCKFILE; 70 | } 71 | if (S_ISSOCK(buf.st_mode)) { 72 | return ISSOCKET; 73 | } 74 | */ 75 | return 0; 76 | } 77 | } 78 | 79 | /*************************************************************************** 80 | * 81 | * samplefile 82 | * reads in the first part of a file, and checks to see that it is 83 | * all ascii. 84 | * 85 | ***************************************************************************/ 86 | /* 87 | int samplefile(fname) 88 | char *fname; 89 | { 90 | char *p; 91 | int numread; 92 | int fd; 93 | 94 | if ((fd = open(fname, O_RDONLY)) == -1) { 95 | fprintf(stderr, "open failed on filename %s\n", fname); 96 | return OPENFAILED; 97 | } 98 | 99 | -comment- No need to use alloc_buf and free_buf here since always read from non-ve fd -tnemmoc- 100 | if (numread = fill_buf(fd, ibuf, MAXLINE)) { 101 | close(fd); 102 | p = ibuf; 103 | while (ISASCII(*p++) && --numread); 104 | if (!numread) { 105 | return(ISASCIIFILE); 106 | } else { 107 | return(ISBINARYFILE); 108 | } 109 | } else { 110 | close(fd); 111 | return(ISASCIIFILE); 112 | } 113 | } 114 | */ 115 | -------------------------------------------------------------------------------- /agrep/checkfile.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | #define NOSUCHFILE -3 3 | #define OPENFAILED -2 4 | #define STATFAILED -1 5 | #define ISASCIIFILE 0 6 | #define ISDIRECTORY 1 7 | #define ISBLOCKFILE 2 8 | #define ISSOCKET 3 9 | #define ISBINARYFILE 4 10 | -------------------------------------------------------------------------------- /agrep/compat.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* test the conflicts between options */ 3 | #include 4 | #include "agrep.h" 5 | #include 6 | 7 | extern int D; 8 | extern int FILENAMEONLY, APPROX, PAT_FILE, PAT_BUFFER, MULTI_OUTPUT, COUNT, INVERSE, BESTMATCH; 9 | extern FILEOUT; 10 | extern REGEX; 11 | extern DELIMITER; 12 | extern WHOLELINE; 13 | extern LINENUM; 14 | extern I, S, DD; 15 | extern JUMP; 16 | extern char Progname[MAXNAME]; 17 | extern int agrep_initialfd; 18 | extern int EXITONERROR; 19 | extern int errno; 20 | 21 | int 22 | compat() 23 | { 24 | if(BESTMATCH) { 25 | 26 | if(COUNT || FILENAMEONLY || APPROX || PAT_FILE) { 27 | BESTMATCH = 0; 28 | fprintf(stderr, "%s: -B option ignored when -c, -l, -f, or -# is on\n", Progname); 29 | } 30 | /* if (LINENUM) { 31 | BESTMATCH = 0; 32 | fprintf(stderr, "%s: -B option ignored when -n is on", Progname); 33 | *//* Currently, the BESTMATCH option disables -n but there 34 | * doesn't seem to be a reason for it. 35 | * compat.c modified while testing continues 10-26-2002 KAM 36 | *//* 37 | } 38 | */ 39 | } 40 | if (COUNT && LINENUM) { 41 | LINENUM = 0; 42 | fprintf(stderr, "%s: -n option ignored with -c\n", Progname); 43 | } 44 | if(PAT_FILE || PAT_BUFFER) { 45 | if(APPROX && (D > 0)) { 46 | fprintf(stderr, "%s: approximate matching is not supported with -f option\n", Progname); 47 | } 48 | /* 49 | if(INVERSE) { 50 | fprintf(stderr, "%s: -f and -v are not compatible\n", Progname); 51 | if (!EXITONERROR) { 52 | errno = AGREP_ERROR; 53 | return -1; 54 | } 55 | else exit(2); 56 | } 57 | */ 58 | if(LINENUM) { 59 | fprintf(stderr, "%s: -f and -n are not compatible\n", Progname); 60 | if (!EXITONERROR) { 61 | errno = AGREP_ERROR; 62 | return -1; 63 | } 64 | else exit(2); 65 | } 66 | /* 67 | if(DELIMITER) { 68 | fprintf(stderr, "%s: -f and -d are not compatible\n", Progname); 69 | if (!EXITONERROR) { 70 | errno = AGREP_ERROR; 71 | return -1; 72 | } 73 | else exit(2); 74 | } 75 | */ 76 | } 77 | if (MULTI_OUTPUT && LINENUM) { 78 | fprintf(stderr, "%s: -M and -n are not compatible\n", Progname); 79 | if (!EXITONERROR) { 80 | errno = AGREP_ERROR; 81 | return -1; 82 | } 83 | else exit(2); 84 | } 85 | if(JUMP) { 86 | if(REGEX) { 87 | fprintf(stderr, "%s: -D#, -I#, or -S# option is ignored for regular expression pattern\n", Progname); 88 | JUMP = 0; 89 | } 90 | if(I == 0 || S == 0 || DD == 0) { 91 | fprintf(stderr, "%s: the error cost cannot be 0\n", Progname); 92 | if (!EXITONERROR) { 93 | errno = AGREP_ERROR; 94 | return -1; 95 | } 96 | else exit(2); 97 | } 98 | } 99 | if(DELIMITER) { 100 | if(WHOLELINE) { 101 | fprintf(stderr, "%s: -d and -x are not compatible\n", Progname); 102 | if (!EXITONERROR) { 103 | errno = AGREP_ERROR; 104 | return -1; 105 | } 106 | else exit(2); 107 | } 108 | } 109 | if (INVERSE && (PAT_FILE || PAT_BUFFER) && MULTI_OUTPUT) { 110 | fprintf(stderr, "%s: -v and -M are not compatible\n", Progname); 111 | if (!EXITONERROR) { 112 | errno = AGREP_ERROR; 113 | return -1; 114 | } 115 | else exit(2); 116 | } 117 | 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /agrep/config.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | 3 | /* 4 | * Definitions in this file will be visible throughout glimpse source code. 5 | * Any global flags or macros can should be defined here. 6 | */ 7 | 8 | #if defined(__NeXT__) 9 | #define getcwd(buf,size) getwd(buf) /* NB: unchecked target size--could overflow; BG: Ok since buffers are usually >= 256B */ 10 | #define S_ISREG(mode) (((mode) & (_S_IFMT)) == (_S_IFREG)) 11 | #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) 12 | #endif 13 | -------------------------------------------------------------------------------- /agrep/contribution.list: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | List of people (other than authors) who have contributed to agrep: 3 | 4 | Chunghwa H. Rao 5 | Gene Myers 6 | Ricardo Baeza-Yates 7 | Cliff Hathaway 8 | Ric Anderson 9 | Su-Ing Tsuei 10 | Raphael Finkel 11 | Andrew Hume 12 | David W. Sanderson 13 | William I. Chang 14 | Jack Kirman 15 | Dave Lutz 16 | Tony Plate 17 | Ken Lalonde 18 | Mark Christopher 19 | Dieter Becker 20 | Ian Young 21 | James M. Winget 22 | John F. Stoffel 23 | -------------------------------------------------------------------------------- /agrep/defs.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* Must be the same as those defined in compress/defs.h */ 3 | #define SIGNATURE_LEN 16 4 | #define TC_LITTLE_ENDIAN 1 5 | #define TC_BIG_ENDIAN 0 6 | #define TC_EASYSEARCH 0x1 7 | #define TC_UNTILNEWLINE 0x2 8 | #define TC_REMOVE 0x4 9 | #define TC_OVERWRITE 0x8 10 | #define TC_RECURSIVE 0x10 11 | #define TC_ERRORMSGS 0x20 12 | #define TC_SILENT 0x40 13 | #define TC_NOPROMPT 0x80 14 | #define TC_FILENAMESONSTDIN 0x100 15 | #define COMP_SUFFIX ".CZ" 16 | #define DEF_FREQ_FILE ".glimpse_quick" 17 | #define DEF_HASH_FILE ".glimpse_compress" 18 | #define DEF_STRING_FILE ".glimpse_uncompress" 19 | -------------------------------------------------------------------------------- /agrep/delim.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | 3 | #include "agrep.h" 4 | extern int EASYSEARCH, TCOMPRESSED; 5 | 6 | /* Accesses src completely before dest, so that dest can be = src */ 7 | void 8 | preprocess_delimiter(src, srclen, dest, pdestlen) 9 | unsigned char *src, *dest; 10 | int srclen, *pdestlen; 11 | { 12 | CHAR temp[Maxline]; 13 | int i, j; 14 | 15 | strcpy(temp, src); 16 | temp[srclen] = '\0'; 17 | for (i=0, j=0; i end) return -1; 39 | if (TCOMPRESSED == ON) return (exists_tcompressed_word(delim, len, begin, end - begin, EASYSEARCH)); 40 | for (curbegin = begin; curbegin + len <= end; curbegin ++) { 41 | for (curbuf = curbegin, curdelim = delim; curbuf < curbegin + len; curbuf ++, curdelim++) 42 | if (*curbuf != *curdelim) break; 43 | if (curbuf >= curbegin + len) return (curbegin - begin); 44 | } 45 | return -1; 46 | } 47 | 48 | /* return where delimiter begins or ends (=outtail): range = [begin, end) */ 49 | unsigned char * 50 | forward_delimiter(begin, end, delim, len, outtail) 51 | unsigned char *begin, *end, *delim; 52 | int len, outtail; 53 | { 54 | register unsigned char *curbegin, *curbuf, *curdelim; 55 | unsigned char *oldbegin = begin, *retval = begin; 56 | 57 | if (begin + len > end) { 58 | retval = end + 1; 59 | goto _ret; 60 | } 61 | if ((len == 1) && (*delim == '\n')) { 62 | begin ++; 63 | while ((begin < end) && (*begin != '\n')) begin ++; 64 | if (outtail && (*begin == '\n')) begin++; 65 | retval = begin; 66 | goto _ret; 67 | } 68 | if (TCOMPRESSED == ON) return forward_tcompressed_word(begin, end, delim, len, outtail, EASYSEARCH); 69 | for (curbegin = begin; curbegin + len <= end; curbegin ++) { 70 | for (curbuf = curbegin, curdelim = delim; curbuf < curbegin + len; curbuf ++, curdelim++) 71 | if (*curbuf != *curdelim) break; 72 | if (curbuf >= curbegin + len) break; 73 | } 74 | if (!outtail) retval = (curbegin <= end - len ? curbegin: end + 1); 75 | else retval = (curbegin <= end - len ? curbegin + len : end + 1); 76 | 77 | _ret: 78 | /* Gurantee that this skips at least one character */ 79 | if (retval <= oldbegin) return oldbegin + 1; 80 | else return retval; 81 | } 82 | 83 | /* return where the delimiter begins or ends (=outtail): range = [begin, end) */ 84 | unsigned char * 85 | backward_delimiter(end, begin, delim, len, outtail) 86 | unsigned char *end, *begin, *delim; 87 | int len, outtail; 88 | { 89 | register unsigned char *curbegin, *curbuf, *curdelim; 90 | 91 | if (end - len < begin) return begin; 92 | if ((len == 1) && (*delim == '\n')) { 93 | end --; 94 | while ((end > begin) && (*end != '\n')) end --; 95 | if (outtail && (*end == '\n')) end++; 96 | return end; 97 | } 98 | if (TCOMPRESSED == ON) return backward_tcompressed_word(end, begin, delim, len, outtail, EASYSEARCH); 99 | for (curbegin = end-len; curbegin >= begin; curbegin --) { 100 | for (curbuf = curbegin, curdelim = delim; curbuf < curbegin + len; curbuf ++, curdelim++) 101 | if (*curbuf != *curdelim) break; 102 | if (curbuf >= curbegin + len) break; 103 | } 104 | if (!outtail) return (curbegin >= begin ? curbegin : begin); 105 | else return (curbegin >= begin ? curbegin + len : begin); 106 | } 107 | -------------------------------------------------------------------------------- /agrep/dummyfilters.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | 3 | /* bgopal: used if search in compressed text files is not being performed */ 4 | /* Always say could not be compressed */ 5 | int 6 | quick_tcompress() 7 | { 8 | return 0; 9 | } 10 | 11 | /* Always say could not be uncompressed */ 12 | int 13 | quick_tuncompress() 14 | { 15 | return 0; 16 | } 17 | 18 | /* Always return uncompressible */ 19 | int 20 | tuncompressible() 21 | { 22 | return 0; 23 | } 24 | 25 | /* Always return uncompressible */ 26 | int 27 | tuncompressible_filename() 28 | { 29 | return 0; 30 | } 31 | 32 | /* Always return uncompressible */ 33 | int 34 | tuncompressible_file() 35 | { 36 | return 0; 37 | } 38 | 39 | /* Always return uncompressible */ 40 | int 41 | tuncompressible_fp() 42 | { 43 | return 0; 44 | } 45 | 46 | int 47 | exists_tcompressed_word() 48 | { 49 | return -1; 50 | } 51 | 52 | unsigned char * 53 | forward_tcompressed_word(begin, end, delim, len, outtail, flags) 54 | unsigned char *begin, *end, *delim; 55 | int len, outtail, flags; 56 | { 57 | return begin; 58 | } 59 | 60 | unsigned char * 61 | backward_tcompressed_word(end, begin, delim, len, outtail, flags) 62 | unsigned char *begin, *end, *delim; 63 | int len, outtail, flags; 64 | { 65 | return end; 66 | } 67 | 68 | int 69 | tcompress_file() 70 | { 71 | return 0; 72 | } 73 | 74 | int 75 | tuncompress_file() 76 | { 77 | return 0; 78 | } 79 | 80 | int 81 | initialize_tcompress() 82 | { 83 | return 0; 84 | } 85 | 86 | int 87 | initialize_tuncompress() 88 | { 89 | return 0; 90 | } 91 | 92 | int 93 | initialize_common() 94 | { 95 | return 0; 96 | } 97 | 98 | int 99 | uninitialize_tuncompress() 100 | { 101 | return 0; 102 | } 103 | 104 | int 105 | compute_dictionary() 106 | { 107 | return 0; 108 | } 109 | 110 | int 111 | uninitialize_common() 112 | { 113 | return 0; 114 | } 115 | 116 | int 117 | uninitialize_tcompress() 118 | { 119 | return 0; 120 | } 121 | 122 | int usemalloc = 0; 123 | 124 | int 125 | set_usemalloc() 126 | { 127 | return 0; 128 | } 129 | 130 | int 131 | unset_usemalloc() 132 | { 133 | return 0; 134 | } 135 | -------------------------------------------------------------------------------- /agrep/dummysyscalls.c: -------------------------------------------------------------------------------- 1 | 2 | /* These functions have been added here so that agrep/cast binaries will work independent of glimpse */ 3 | 4 | int 5 | my_open(name, flags, mode) 6 | char *name; 7 | int flags, mode; 8 | { 9 | return open(name, flags, mode); 10 | } 11 | 12 | FILE * 13 | my_fopen(name, flags) 14 | char *name; 15 | char *flags; 16 | { 17 | return fopen(name, flags); 18 | } 19 | 20 | int 21 | my_lstat(name, buf) 22 | char *name; 23 | struct stat *buf; 24 | { 25 | return lstat(name, buf); 26 | } 27 | 28 | int 29 | my_stat(name, buf) 30 | char *name; 31 | struct stat *buf; 32 | { 33 | return stat(name, buf); 34 | } 35 | 36 | int 37 | special_get_name(name, len, temp) 38 | char *name; 39 | int len; 40 | char *temp; 41 | { 42 | strcpy(temp, name); 43 | return 0; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /agrep/io.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | #include "agrep.h" 3 | 4 | /* AGREP_POINTER must be defined to be 1 always */ 5 | /* #define AGREP_POINTER 1 */ 6 | /* Removed since we now have a -DAGREP_POINTER=1 option in the Makefile */ 7 | 8 | fill_buf(fd, buf, record_size) 9 | int fd, record_size; 10 | unsigned char *buf; 11 | { 12 | int num_read=1; 13 | int total_read=0; 14 | 15 | if (fd >= 0) { 16 | --record_size; 17 | while(total_read < record_size && num_read > 0) { 18 | num_read = read(fd, buf+total_read, record_size - total_read); 19 | total_read = total_read + num_read; 20 | } 21 | if ((0 == num_read) && (0 < total_read)) { 22 | /* Add newline terminator */ 23 | buf [total_read] = '\n'; 24 | ++total_read; 25 | } 26 | } 27 | #if AGREP_POINTER 28 | else return 0; /* should not call this function if buf is a pointer to a user-specified region! */ 29 | #else /*AGREP_POINTER*/ 30 | else { /* simulate a file */ 31 | total_read = (record_size > (agrep_inlen - agrep_inpointer)) ? (agrep_inlen - agrep_inpointer) : record_size; 32 | memcpy(buf, agrep_inbuffer + agrep_inpointer, total_read); 33 | agrep_inpointer += total_read; 34 | } 35 | #endif /*AGREP_POINTER*/ 36 | return(total_read); 37 | } 38 | 39 | /* 40 | * In these functions no allocs/copying is done when 41 | * fd == -1, i.e., agrep is called to search within memory. 42 | */ 43 | 44 | alloc_buf(fd, buf, size) 45 | int fd; 46 | char **buf; 47 | int size; 48 | { 49 | #if AGREP_POINTER 50 | if (fd != -1) 51 | #endif /*AGREP_POINTER*/ 52 | *buf = (char *)malloc(size); 53 | } 54 | 55 | free_buf(fd, buf) 56 | int fd; 57 | char *buf; 58 | { 59 | #if AGREP_POINTER 60 | if (fd != -1) 61 | #endif /*AGREP_POINTER*/ 62 | free(buf); 63 | } 64 | -------------------------------------------------------------------------------- /agrep/io.c.orig: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | #include "agrep.h" 3 | 4 | /* AGREP_POINTER must be defined to be 1 always */ 5 | /* #define AGREP_POINTER 1 */ 6 | /* Removed since we now have a -DAGREP_POINTER=1 option in the Makefile */ 7 | 8 | fill_buf(fd, buf, record_size) 9 | int fd, record_size; 10 | unsigned char *buf; 11 | { 12 | int num_read=1; 13 | int total_read=0; 14 | 15 | if (fd >= 0) { 16 | while(total_read < record_size && num_read > 0) { 17 | num_read = read(fd, buf+total_read, record_size - total_read); 18 | total_read = total_read + num_read; 19 | } 20 | } 21 | #if AGREP_POINTER 22 | else return 0; /* should not call this function if buf is a pointer to a user-specified region! */ 23 | #else /*AGREP_POINTER*/ 24 | else { /* simulate a file */ 25 | total_read = (record_size > (agrep_inlen - agrep_inpointer)) ? (agrep_len - agrep_inpointer) : record_size; 26 | memcpy(buf, agrep_inbuffer + agrep_inpointer, total_read); 27 | agrep_inpointer += total_read; 28 | } 29 | #endif /*AGREP_POINTER*/ 30 | return(total_read); 31 | } 32 | 33 | /* 34 | * In these functions no allocs/copying is done when 35 | * fd == -1, i.e., agrep is called to search within memory. 36 | */ 37 | 38 | alloc_buf(fd, buf, size) 39 | int fd; 40 | char **buf; 41 | int size; 42 | { 43 | #if AGREP_POINTER 44 | if (fd != -1) 45 | #endif /*AGREP_POINTER*/ 46 | *buf = (char *)malloc(size); 47 | } 48 | 49 | free_buf(fd, buf) 50 | int fd; 51 | char *buf; 52 | { 53 | #if AGREP_POINTER 54 | if (fd != -1) 55 | #endif /*AGREP_POINTER*/ 56 | free(buf); 57 | } 58 | -------------------------------------------------------------------------------- /agrep/main.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | #include 3 | #include "agrep.h" 4 | #if ISO_CHAR_SET 5 | #include /* support for 8bit character set: ew@senate.be */ 6 | #endif 7 | 8 | #if MEASURE_TIMES 9 | extern int INFILTER_ms, OUTFILTER_ms, FILTERALGO_ms; 10 | #endif /*MEASURE_TIMES*/ 11 | 12 | extern char Pattern[MAXPAT]; 13 | extern int EXITONERROR; 14 | 15 | #include "dummysyscalls.c" 16 | 17 | int 18 | main(argc, argv) 19 | int argc; 20 | char *argv[]; 21 | { 22 | int ret; 23 | 24 | #if ISO_CHAR_SET 25 | setlocale(LC_ALL,""); /* support for 8bit character set: ew@senate.be, Henrik.Martin@eua.ericsson.se, "O.Bartunov" , S.Nazin (leng@sai.msu.su) */ 26 | #endif 27 | 28 | EXITONERROR = 1; /* the only place where it is set to 1 */ 29 | ret = fileagrep(argc, argv, 0, stdout); 30 | 31 | #if MEASURE_TIMES 32 | fprintf(stderr, "ret = %d infilter = %d ms\toutfilter = %d ms\tfilteralgo = %d ms\n", ret, INFILTER_ms, OUTFILTER_ms, FILTERALGO_ms); 33 | #endif /*MEASURE_TIMES*/ 34 | if(ret<0) exit(2); 35 | if(ret==0) exit(1); 36 | exit(0); 37 | } 38 | -------------------------------------------------------------------------------- /agrep/putils.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | 3 | #include "agrep.h" 4 | 5 | int 6 | is_complex_boolean(buffer, len) 7 | CHAR *buffer; 8 | int len; 9 | { 10 | int i = 0; 11 | CHAR cur = '\0'; 12 | 13 | while (i < len) { 14 | if (buffer[i] == '\\') i+=2; 15 | else if (buffer[i] == ',') { 16 | if ((cur == ';') || (cur == '~')) return 1; 17 | else cur = ','; 18 | i++; 19 | } 20 | else if (buffer[i] == ';') { 21 | if ((cur == ',') || (cur == '~')) return 1; 22 | else cur = ';'; 23 | i++; 24 | } 25 | /* else if ((buffer[i] == '~') || (buffer[i] == '{') || (buffer[i] == '}')) { */ 26 | else if (buffer[i] == '~') { 27 | /* even if pattern has just ~s... user must use -v option for single NOT */ 28 | return 1; 29 | } 30 | else i++; 31 | } 32 | return 0; 33 | } 34 | 35 | /* The possible tokens are: ; , a e ~ { } */ 36 | int 37 | get_token_bool(buffer, len, ptr, tokenbuf, tokenlen) 38 | CHAR *buffer, *tokenbuf; 39 | int len, *ptr, *tokenlen; 40 | { 41 | if ((*ptr>=len) || (buffer[*ptr] == '\n') || (buffer[*ptr] == '\0')) return 'e'; 42 | while ((*ptr=len) || (buffer[*ptr] == '\n') || (buffer[*ptr] == '\0')) return 'e'; 44 | if ((buffer[*ptr] == ',') || (buffer[*ptr] == ';') || (buffer[*ptr] == '~') || (buffer[*ptr] == '{') || (buffer[*ptr] == '}')) { 45 | tokenbuf[0] = buffer[*ptr]; 46 | *tokenlen = 1; 47 | return buffer[(*ptr)++]; 48 | } 49 | *tokenlen = 0; 50 | if (buffer[*ptr] == '\\') { 51 | tokenbuf[(*tokenlen)++] = buffer[(*ptr)++]; 52 | tokenbuf[(*tokenlen)++] = buffer[(*ptr)++]; 53 | } 54 | else tokenbuf[(*tokenlen)++] = buffer[(*ptr)++]; 55 | while ( (*ptr= len) */ 66 | } 67 | 68 | void 69 | print_tree(t, level) 70 | ParseTree *t; 71 | { 72 | int i; 73 | 74 | if (t == NULL) printf("NULL"); 75 | else if (t->type == LEAF) { 76 | for (i=0; iop, t->terminalindex, t->data.leaf.value); 78 | } 79 | else if (t->type == INTERNAL) { 80 | if (t->data.internal.left != NULL) print_tree(t->data.internal.left, level + 1); 81 | for (i=0; iop); 83 | if (t->data.internal.right != NULL) print_tree(t->data.internal.right, level + 1); 84 | } 85 | } 86 | 87 | void 88 | destroy_tree(t) 89 | ParseTree *t; 90 | { 91 | if (t == NULL) return; 92 | if (t->type == LEAF) { 93 | free(t->data.leaf.value); /* t itself should not be freed: static allocation */ 94 | } 95 | else if (t->type == INTERNAL) { 96 | if (t->data.internal.left != NULL) destroy_tree(t->data.internal.left); 97 | if (t->data.internal.right != NULL) destroy_tree(t->data.internal.right); 98 | free(t); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /agrep/recursive.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* The function of the program is to traverse the 3 | direcctory tree and collect paath names. 4 | This program is derived from the C-programming language book 5 | Originally, the program open a directory file as a regular file. But 6 | it won't work. We have to open a directory file using 7 | opendir system call, and use readdir() to read each entry of the 8 | directory. 9 | */ 10 | 11 | #include "autoconf.h" /* ../libtemplate/include */ 12 | #include 13 | #include 14 | #if ISO_CHAR_SET 15 | #include 16 | #endif 17 | 18 | #if HAVE_DIRENT_H 19 | # include 20 | # define NAMLEN(dirent) strlen((dirent)->d_name) 21 | #else 22 | # define dirent direct 23 | # define NAMLEN(dirent) (dirent)->d_namlen 24 | # if HAVE_SYS_NDIR_H 25 | # include 26 | # endif 27 | # if HAVE_SYS_DIR_H 28 | # include 29 | # endif 30 | # if HAVE_NDIR_H 31 | # include 32 | # endif 33 | #endif 34 | 35 | #include 36 | #include 37 | #define BUFSIZE 256 38 | #define DIRSIZE 14 39 | #define max_list 10 40 | 41 | #ifndef S_ISREG 42 | #define S_ISREG(mode) (0100000&(mode)) 43 | #endif 44 | 45 | #ifndef S_ISDIR 46 | #define S_ISDIR(mode) (0040000&(mode)) 47 | #endif 48 | 49 | char *file_list[max_list*2]; 50 | int fdx=0; /* index of file_List */ 51 | extern int Numfiles; 52 | char name_buf[BUFSIZE]; 53 | 54 | void directory(); 55 | static void treewalk(); 56 | 57 | /* returns -1 if error, num of matches >= 0 otherwise */ 58 | int 59 | recursive(argc, argv) 60 | int argc; 61 | char **argv; 62 | { 63 | int i,j; 64 | int num = 0, ret; 65 | 66 | for(i=0; i< argc; i++) { 67 | strcpy(name_buf, argv[i]); 68 | treewalk(name_buf); 69 | if(fdx > 0) { 70 | Numfiles = fdx; 71 | if ((ret = exec(3, file_list)) == -1) return -1; 72 | num += ret; 73 | for(j=0; j 0) { 99 | strcpy(buf, *++argv); 100 | treewalk(buf); 101 | } 102 | } 103 | */ 104 | 105 | static void 106 | treewalk(name) 107 | char *name; 108 | { 109 | struct stat stbuf; 110 | int i; 111 | extern void *malloc(); 112 | 113 | /* printf(" In treewalk\n"); */ 114 | if(my_lstat(name, &stbuf) == -1) { 115 | fprintf(stderr, "permission denied or non-existent: %s\n", name); 116 | return; 117 | } 118 | if ((stbuf.st_mode & S_IFMT) == S_IFLNK) { 119 | return; 120 | } 121 | if (( stbuf.st_mode & S_IFMT) == S_IFDIR) 122 | directory(name); 123 | else { 124 | file_list[fdx] = (char *)malloc(BUFSIZE); 125 | strcpy(file_list[fdx++], name); 126 | /* printf(" %s\n", name); */ 127 | if(fdx >= max_list) { 128 | Numfiles = fdx; 129 | exec(3, file_list); 130 | for(i=0; i= name+BUFSIZE ) /* name too long */ 149 | { 150 | fprintf(stderr, "name too long: %.32s...\n", name); 151 | return; 152 | } 153 | if((dirp = opendir(name)) == NULL) { 154 | fprintf(stderr, "permission denied: %s\n", name); 155 | return; 156 | } 157 | *nbp++ = '/'; 158 | *nbp = '\0'; 159 | for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { 160 | if (dp->d_name[0] == '\0' || strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..")==0) 161 | goto CONT; 162 | /* 163 | printf("dp->d_name = %s\n", dp->d_name); 164 | */ 165 | strcpy(nbp, dp->d_name); 166 | treewalk(name); 167 | CONT: 168 | ; 169 | } 170 | closedir (dirp); 171 | *--nbp = '\0'; /* restore name */ 172 | } 173 | -------------------------------------------------------------------------------- /compress/Makefile.NeXT: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On IRIX, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = gcc 9 | AR = /bin/ar 10 | RANLIB = /bin/ranlib 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 0 16 | HAVE_SYS_DIR_H = 0 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include -I/usr/include/bsd/sys 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/Makefile.alpha: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On Solaris, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = cc 9 | AR = ar #/usr/ccs/bin/ar #for Solaris 10 | RANLIB = ranlib #true #for Solaris 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 1 16 | HAVE_SYS_DIR_H = 0 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O -Olimit 3000 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/Makefile.hp: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On Solaris, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = cc 9 | AR = ar #/usr/ccs/bin/ar #for Solaris 10 | RANLIB = : 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 0 16 | HAVE_SYS_DIR_H = 1 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/Makefile.in: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 6 | 7 | srcdir = @srcdir@ 8 | VPATH = @srcdir@ 9 | SHELL = /bin/sh 10 | CC = @CC@ 11 | AR = @AR@ 12 | RANLIB = @RANLIB@ 13 | CP = @CP@ 14 | STRIP = @STRIP@ 15 | INSTALL = @INSTALL@ 16 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 17 | INSTALL_DATA = @INSTALL_DATA@ 18 | DEFS = 19 | 20 | prefix = @prefix@ 21 | exec_prefix = @exec_prefix@ 22 | binprefix = 23 | manprefix = 24 | 25 | bindir = $(exec_prefix)/bin 26 | libdir = $(exec_prefix)/lib 27 | mandir = $(prefix)/man/man1 28 | manext = 1 29 | 30 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 31 | 32 | INDEXDIR = ../index 33 | AGREPDIR = ../agrep 34 | LIBDIR = ../lib 35 | BIN = ../bin 36 | TEMPLATEDIR = ../libtemplate 37 | 38 | OPTIMIZEFLAGS = -O2 39 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 40 | CFLAGS = $(INCLUDEFLAGS) $(OPTIMIZEFLAGS) 41 | LDFLAGS = 42 | OTHERLIBS = 43 | 44 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 45 | LIB = $(LIBDIR)/libcast.a 46 | 47 | all: $(LIB) tbuild cast uncast 48 | 49 | install: all 50 | for i in tbuild cast uncast ; do \ 51 | $(INSTALL) $$i $(bindir) ; \ 52 | done 53 | 54 | install-man: 55 | 56 | clean: 57 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 58 | 59 | distclean: clean 60 | rm -f Makefile 61 | 62 | $(LIB): $(LIBOBJ) 63 | $(AR) rcv $(LIB) $(LIBOBJ) 64 | $(RANLIB) $(LIB) 65 | 66 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 67 | $(CC) $(LDFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 68 | 69 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 70 | $(CC) $(LDFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 71 | 72 | cast: main_cast.o $(LIB) 73 | $(CC) $(LDFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 74 | 75 | uncast: main_uncast.o $(LIB) 76 | $(CC) $(LDFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 77 | 78 | hash.o: defs.h $(INDEXDIR)/glimpse.h 79 | string.o: defs.h $(INDEXDIR)/glimpse.h 80 | misc.o: defs.h $(INDEXDIR)/glimpse.h 81 | quick.o: defs.h $(INDEXDIR)/glimpse.h 82 | cast.o: defs.h $(INDEXDIR)/glimpse.h 83 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 84 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 85 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 86 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 87 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 88 | test.o : test.c 89 | 90 | -------------------------------------------------------------------------------- /compress/Makefile.linux: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On Solaris, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = gcc -m486 9 | AR = ar #/usr/ccs/bin/ar #for Solaris 10 | RANLIB = ranlib #true #for Solaris 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 1 16 | HAVE_SYS_DIR_H = 0 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O2 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/Makefile.rs6000: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On IRIX, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = cc 9 | AR = /usr/bin/ar 10 | RANLIB = true #for IRIX 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 1 16 | HAVE_SYS_DIR_H = 0 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/Makefile.sgi: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On IRIX, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = cc 9 | AR = /usr/bin/ar 10 | RANLIB = true #for IRIX 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 1 16 | HAVE_SYS_DIR_H = 0 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/Makefile.solaris: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On Solaris, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = gcc -traditional #cc 9 | AR = /usr/ccs/bin/ar #for Solaris 10 | RANLIB = true #for Solaris 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 1 16 | HAVE_SYS_DIR_H = 0 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/Makefile.sunos: -------------------------------------------------------------------------------- 1 | #/* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | # Makefile for the compress library -- agrep should be linked with it in case 3 | # it wants to search for patterns in a compressed file. 4 | 5 | # You might have to change these depending on your machine configuration. 6 | # AR and RANLIB are the library-archive programs. On Solaris, RANLIB is not 7 | # required (define it to true) and AR is in /usr/ccs/bin/ar (on our machine!). 8 | CC = gcc 9 | AR = ar #/usr/ccs/bin/ar #for Solaris 10 | RANLIB = ranlib #true #for Solaris 11 | 12 | SHELL = /bin/sh 13 | 14 | # Define HAVE_DIRENT_H to be 1 when you don't have else define it to be 0 (in this case, one of the other 3 flags may need to be defined to be 1). 15 | HAVE_DIRENT_H = 1 16 | HAVE_SYS_DIR_H = 0 17 | HAVE_SYS_NDIR_H = 0 18 | HAVE_NDIR_H = 0 19 | 20 | # Define UTIME to be 1 if you have the utime() routine on your system. Else define it to be 0. 21 | UTIME = 1 22 | 23 | # Define ISO_CHAR_SET to be 1 if you want to use the international 8bit character set. Else define it to be 0. 24 | ISO_CHAR_SET = 0 25 | 26 | # YOU DON'T HAVE TO CHANGE ANYTHING BELOW THIS LINE 27 | 28 | INDEXDIR = ../index 29 | AGREPDIR = ../agrep 30 | LIBDIR = ../lib 31 | BIN = ../bin 32 | TEMPLATEDIR = ../libtemplate 33 | 34 | all: lib tbuild cast uncast test 35 | cp tbuild $(BIN)/. 36 | cp cast $(BIN)/. 37 | cp uncast $(BIN)/. 38 | 39 | # Include flags is not a part of CLFAGS and LINKFLAGS since path names from subdirs can be different 40 | OPTIMIZEFLAGS = -O 41 | #PROFILEFLAGS = -p 42 | #DEBUGFLAGS = -g -DBG_DEBUG=1 -DDEBUG=1 43 | INCLUDEFLAGS = -I$(INDEXDIR) -I$(AGREPDIR) -I$(TEMPLATEDIR)/include 44 | DEFINEFLAGS = -DSTRUCTURED_QUERIES=$(STRUCTURED_QUERIES) -DHAVE_DIRENT_H=$(HAVE_DIRENT_H) -DUTIME=$(UTIME) -DISO_CHAR_SET=$(ISO_CHAR_SET) 45 | SUBDIRCFLAGS = -c $(DEFINEFLAGS) $(OPTIMIZEFLAGS) $(PROFILEFLAGS) $(DEBUGFLAGS) 46 | CFLAGS = $(INCLUDEFLAGS) $(SUBDIRCFLAGS) 47 | SUBDIRLINKFLAGS = $(PROFILEFLAGS) 48 | LINKFLAGS = $(INCLUDES) $(SUBDIRLINKFLAGS) 49 | OTHERLIBS = 50 | 51 | LIBOBJ = hash.o string.o misc.o quick.o cast.o uncast.o tsimpletest.o tmemlook.o tbuild.o 52 | LIB = $(LIBDIR)/libcast.a 53 | 54 | lib: $(LIBOBJ) 55 | $(AR) rcv $(LIB) $(LIBOBJ) 56 | $(RANLIB) $(LIB) 57 | 58 | test: hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o 59 | $(CC) $(LINKFLAGS) -o test hash.o string.o misc.o test.o quick.o tsimpletest.o tmemlook.o cast.o uncast.o $(OTHERLIBS) 60 | 61 | tbuild: hash.o string.o misc.o tbuild.o main_tbuild.o defs.h 62 | $(CC) $(LINKFLAGS) -o tbuild hash.o string.o misc.o tbuild.o main_tbuild.o $(OTHERLIBS) 63 | 64 | cast: main_cast.o $(LIB) 65 | $(CC) $(LINKFLAGS) -o cast main_cast.o $(LIBOBJ) $(OTHERLIBS) 66 | 67 | uncast: main_uncast.o $(LIB) 68 | $(CC) $(LINKFLAGS) -o uncast main_uncast.o $(LIBOBJ) $(OTHERLIBS) 69 | 70 | hash.o: defs.h $(INDEXDIR)/glimpse.h 71 | string.o: defs.h $(INDEXDIR)/glimpse.h 72 | misc.o: defs.h $(INDEXDIR)/glimpse.h 73 | quick.o: defs.h $(INDEXDIR)/glimpse.h 74 | cast.o: defs.h $(INDEXDIR)/glimpse.h 75 | uncast.o: defs.h $(INDEXDIR)/glimpse.h 76 | main_cast.o: defs.h $(INDEXDIR)/glimpse.h 77 | main_uncast.o: defs.h $(INDEXDIR)/glimpse.h 78 | tsimpletest.o: defs.h $(INDEXDIR)/glimpse.h 79 | tmemlook.o: defs.h $(INDEXDIR)/glimpse.h 80 | test.o : test.c 81 | 82 | clean: 83 | rm -f *.o $(LIB) core test cast uncast tbuild a.out 84 | -------------------------------------------------------------------------------- /compress/README: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | 3 | This directory contains the source code for the new text-compression 4 | algorithm. The source is divided as follows: 5 | 6 | 1. main_comp.c, tcomp.c: source code for tcomp (compress algorithm). 7 | This also uses simpletest.c and memlook.c from ../index. 8 | 9 | 2. main_uncomp.c, tuncomp.c: source code for tuncomp (uncompress algorithm). 10 | 11 | 3. read_in.c: generates build, the procedure which builds the dictionary 12 | to be used by tuncomp and the hash_table used by tcomp. It uses 13 | and interprets the output of the indexing-algorithm present 14 | in ../index, the software is glimpseindex (a part of glimpse). 15 | 16 | 4. hash.c: common routines used by tcomp and build. 17 | 18 | 5. string.c: common routines used by tuncomp and build. 19 | 20 | 6. misc.c, defs.h: common to all above. 21 | -------------------------------------------------------------------------------- /compress/compress.chronicle: -------------------------------------------------------------------------------- 1 | Started on 1st Sep 1994. 2 | 0. Completely integrated compression (cast, uncast) into glimpse/glimpseindex 3 | and agrep during Aug 1994. 4 | -------------------------------------------------------------------------------- /compress/main_tbuild.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | 3 | /* 4 | * main_tbuild.c: calls tbuild.c/compute_dictionary() after reading options. 5 | */ 6 | 7 | #include "defs.h" 8 | #if ISO_CHAR_SET 9 | #include 10 | #endif 11 | 12 | extern int compute_dictionary(); 13 | extern char **environ; 14 | 15 | #include "dummysyscalls.c" 16 | 17 | usage(progname) 18 | char *progname; 19 | { 20 | fprintf(stderr, "usage: %s [-H directory] [-t threshold] [-l stop-list-size]\n", progname); 21 | fprintf(stderr, "defaults: %d %d %d ~\n", DEF_SPECIAL_WORDS, DEF_THRESHOLD, DEF_BLOCKSIZE); 22 | exit(1); 23 | } 24 | 25 | int 26 | main(argc, argv) 27 | int argc; 28 | unsigned char *argv[]; 29 | { 30 | char comp_dir[MAX_LINE_LEN]; 31 | int threshold, specialwords; 32 | int i = 1; 33 | char *home; 34 | 35 | #if ISO_CHAR_SET 36 | setlocale(LC_ALL, ""); 37 | #endif 38 | /* fill in default options */ 39 | comp_dir[0] = '\0'; 40 | threshold = DEF_THRESHOLD; 41 | specialwords = DEF_SPECIAL_WORDS; 42 | 43 | while(i < argc) { 44 | if (argv[i][0] != '-') return usage(argv[0]); 45 | else if (argv[i][1] == 'H') strcpy(comp_dir, argv[++i]); 46 | else if (argv[i][1] == 't') threshold = atoi(argv[++i]); 47 | else if (argv[i][1] == 'l') specialwords = atoi(argv[++i]); 48 | else if (argv[i][1] == 'V') { 49 | printf("\nThis is tbuild version %s. Copyright (c) %s, University of Arizona.\n\n", CAST_VERSION, CAST_DATE); 50 | } 51 | else return usage(argv[0]); 52 | i++; 53 | } 54 | if (comp_dir[0] == '\0') { 55 | if ((home = (char *)getenv("HOME")) == NULL) { 56 | getcwd(comp_dir, MAX_LINE_LEN-1); 57 | fprintf(stderr, "using working-directory '%s' to locate index\n", comp_dir); 58 | } 59 | else strncpy(comp_dir, home, MAX_LINE_LEN); 60 | } 61 | 62 | compute_dictionary(threshold, DISKBLOCKSIZE, specialwords, comp_dir); 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /compress/test.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | #include 3 | #include 4 | 5 | #include /* configured defines */ 6 | 7 | #if ISO_CHAR_SET 8 | #include 9 | #endif 10 | 11 | char src[256] = " industrial production because of energy and input shortages and labor\n"; 12 | 13 | char dest[256]; 14 | char srcsrc[256]; 15 | 16 | #include "dummysyscalls.c" 17 | 18 | main() 19 | { 20 | int i; 21 | int srclen = strlen(src); 22 | int destlen; 23 | int srcsrclen; 24 | 25 | #if ISO_CHAR_SET 26 | setlocale(LC_ALL, ""); 27 | #endif 28 | printf("going...\n"); 29 | destlen = quick_tcompress(".quick_lookup", ".compress_dictionary", src, srclen, dest, get_endian()); 30 | dest[63] = 0; 31 | printf("len=%d\n", destlen); 32 | for (i=0; i 10 | #include 11 | 12 | int tmemlook(pattern, text, length) 13 | unsigned char *pattern; 14 | unsigned char *text; 15 | int length; 16 | { 17 | unsigned char *text_end = text+length; 18 | unsigned char *text_begin = text; 19 | register unsigned char pat_0=pattern[0]; 20 | register unsigned char *px, *tx; 21 | 22 | if(pat_0 == '\n') { 23 | if(strncmp((char *)pattern+1, text, strlen((char *)pattern) -1) == 0) { 24 | return(0); 25 | } 26 | } 27 | /* this is a special case when the pattern is to begin of a line 28 | while the text match the pattern right at the beginning, in 29 | which case, '\n' won't be matched. 30 | */ 31 | pattern++; 32 | *text_end = pat_0 ; 33 | while(text < text_end) { 34 | while(*text++ != pat_0); 35 | if(text < text_end) { 36 | px = pattern; 37 | tx = text; 38 | while(*px == *tx) { 39 | px++; tx++; 40 | }; 41 | if(*px == '\0') { 42 | /* 43 | printf("begin matched\n"); 44 | */ 45 | return(text - text_begin); 46 | } 47 | } 48 | } 49 | return(-2); 50 | } 51 | 52 | -------------------------------------------------------------------------------- /compress/trecursive.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Burra Gopal, Udi Manber. All Rights Reserved. */ 2 | 3 | #include "autoconf.h" /* ../libtemplate/include */ 4 | #include 5 | #include 6 | #if ISO_CHAR_SET 7 | #include 8 | #endif 9 | 10 | #if HAVE_DIRENT_H 11 | # include 12 | # define NAMLEN(dirent) strlen((dirent)->d_name) 13 | #else 14 | # define dirent direct 15 | # define NAMLEN(dirent) (dirent)->d_namlen 16 | # if HAVE_SYS_NDIR_H 17 | # include 18 | # endif 19 | # if HAVE_SYS_DIR_H 20 | # include 21 | # endif 22 | # if HAVE_NDIR_H 23 | # include 24 | # endif 25 | #endif 26 | 27 | #include 28 | #include 29 | #define DIRSIZE 14 30 | 31 | #ifndef S_ISREG 32 | #define S_ISREG(mode) (0100000&(mode)) 33 | #endif 34 | 35 | #ifndef S_ISDIR 36 | #define S_ISDIR(mode) (0040000&(mode)) 37 | #endif 38 | 39 | #if 0 40 | #define FUNCTION(x, y, z) treewalk(x, y, z) 41 | #define MAX_LINE_LEN 1024 42 | 43 | main(argc, argv) 44 | int argc; char **argv; 45 | { 46 | char buf[MAX_LINE_LEN]; 47 | char outbuf[MAX_LINE_LEN]; 48 | int flags=0; 49 | 50 | #if ISO_CHAR_SET 51 | setlocale(LC_ALL, ""); 52 | #endif 53 | if (argc == 1) { 54 | strcpy(buf, "."); 55 | return treewalk(buf, outbuf, flags); 56 | } 57 | else while(--argc > 0) { 58 | strcpy(buf, *++argv); 59 | return treewalk(buf, outbuf, flags); 60 | } 61 | } 62 | 63 | int 64 | treewalk(name, outname, flags) 65 | char *name; 66 | char *outname; 67 | int flags; 68 | { 69 | struct stat stbuf; 70 | extern int puts(); 71 | 72 | if(my_lstat(name, &stbuf) == -1) { 73 | fprintf(stderr, "permission denied or non-existent: %s\n", name); 74 | return -1; 75 | } 76 | if ((stbuf.st_mode & S_IFMT) == S_IFLNK) 77 | return -1; 78 | if ((stbuf.st_mode & S_IFMT) == S_IFDIR) 79 | return DIRECTORY(name, outname, flags); 80 | if ((stbuf.st_mode & S_IFMT) == S_IFREG) 81 | return puts(name); 82 | } 83 | #endif /*0*/ 84 | 85 | int 86 | DIRECTORY(name, outname, flags) 87 | char *name, *outname; 88 | int flags; 89 | { 90 | struct dirent *dp; 91 | char *nbp; 92 | DIR *dirp; 93 | 94 | nbp = name + strlen(name); 95 | if( nbp+DIRSIZE+2 >= name+MAX_LINE_LEN ) { /* name too long */ 96 | fprintf(stderr, "name too long: %.32s...\n", name); 97 | return -1; 98 | } 99 | if((dirp = opendir(name)) == NULL) { 100 | fprintf(stderr, "permission denied: %s\n", name); 101 | return -1; 102 | } 103 | *nbp++ = '/'; 104 | for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { 105 | if (dp->d_name[0] == '\0' || strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..")==0) { 106 | continue; 107 | } 108 | strcpy(nbp, dp->d_name); 109 | FUNCTION(name, outname, flags); 110 | } 111 | closedir (dirp); 112 | *--nbp = '\0'; /* restore name */ 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /compress/tsimpletest.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* simple tests which don't need to access indexing data structures */ 3 | #include 4 | #include 5 | #define b_sample_size 2048 /* the number of bytes sampled to determine 6 | whether a file is binary */ 7 | #define u_sample_size 1024 /* the number of bytes sampled to determine 8 | whether a file is uuencoded */ 9 | 10 | 11 | #if 0 12 | /* --------------------------------------------------------------------- 13 | check for binary stream 14 | --------------------------------------------------------------------- */ 15 | ttest_binary(buffer, length) 16 | unsigned char *buffer; 17 | int length; 18 | { 19 | int i=0; 20 | int b_count=0; 21 | 22 | if(length > b_sample_size) length = b_sample_size; 23 | 24 | for(i=0; i 127) b_count++; 26 | } 27 | if(b_count*10 >= length) return(1); 28 | return(0); 29 | } 30 | #else /*0*/ 31 | /* Lets try this one instead: Chris Dalton */ 32 | ttest_binary(buffer, length) 33 | unsigned char *buffer; 34 | int length; 35 | { 36 | int permitted_errors; 37 | 38 | if (length > b_sample_size) { length= b_sample_size; } 39 | permitted_errors= length/10; 40 | 41 | while (permitted_errors && length--) { 42 | if (!(isgraph(*buffer) || isspace(*buffer))) --permitted_errors; 43 | } 44 | return (permitted_errors == 0); 45 | } 46 | #endif /*0*/ 47 | 48 | /* --------------------------------------------------------------------- 49 | check for uuencoded stream 50 | --------------------------------------------------------------------- */ 51 | ttest_uuencode(buffer, length) 52 | unsigned char *buffer; 53 | int length; 54 | { 55 | int i=0; 56 | int j; 57 | 58 | if(length > u_sample_size) length = u_sample_size; 59 | 60 | if(strncmp((char *)buffer, "begin", 5) == 0) { 61 | i=5; 62 | goto CONT; 63 | } 64 | i = tmemlook("\nbegin", buffer, length); 65 | if(i < 0) return(0); 66 | CONT: 67 | while(buffer[i] != '\n' && i=length) return 0; 88 | buffer[i] = '\0'; 89 | if ((first = (char *)strstr((char *)buffer, "PS-Adobe")) == NULL) { 90 | buffer[i] = '\n'; 91 | return 0; 92 | } 93 | buffer[i] = '\n'; 94 | return 1; 95 | } 96 | -------------------------------------------------------------------------------- /defs.h: -------------------------------------------------------------------------------- 1 | #ifndef _GIMPSE_DEFS_H_ 2 | #define _GIMPSE_DEFS_H_ 3 | 4 | #include /* autoconf defines */ 5 | 6 | #define MAX_ARGS 80 /* English alphabets + numbers + pattern + progname + arguments + extras */ 7 | #define MAXFILEOPT 1024 /* includes length of args too: #args is <= MAX_ARGS */ 8 | #define BLOCKSIZE 8192 /* For compression: what is the optimal unit of disk i/o = n * pagesize */ 9 | 10 | /* 11 | * These are some parameters that allow us to switch between offset computation 12 | * and just index computation when the index is built at a byte-level: since 13 | * offset computation is a waste if we can't narrow down search enough (since 14 | * we must look all over and the lists become too long => bottleneck). This may 15 | * not be needed if we used trees to store intervals --- we'll do it later :-). 16 | */ 17 | 18 | #define MAX_DISPARITY 100 /* if least frequent word occurrs in < 1/100 times most frequent word, resort to agrep: don't intersect lists (byte-level) */ 19 | #define MIN_OCCURRENCES 20 /* Min no. of occurrences before we check for highly frequent words using MAX_UNION */ 20 | #define MAX_UNION 500 /* Don't even perform the Union of offsets if least < 1/500 times most freq word (we are on track of stop list kinda words) */ 21 | #define MAX_ABSOLUTE MAX_SORTLINE_LEN /* Don't even perform the Union of offsets if a word occurs more than 16K times (independent of #of files) */ 22 | #endif 23 | -------------------------------------------------------------------------------- /dynfilters/Makefile.in: -------------------------------------------------------------------------------- 1 | # Set this variable to the name of your C compiler 2 | CC=gcc 3 | 4 | # Provide optimization flages here. These settings are fine for egcs and 5 | # gcc >= 2.95. If you use an older gcc version, change -O3 to -O2. If you 6 | # use a non-gcc compiler, change this line to 7 | # CFLAGS=-O 8 | CFLAGS=-O3 -fomit-frame-pointer 9 | 10 | # Additional definitions you would like to pass to the compiler. You usually 11 | # can leave this line alone. 12 | DEFS= 13 | 14 | # The name of the linker. Usually, specifying the same name as the C compiler 15 | # is fine. Change this to "ld" if in doubt. 16 | LD=$(CC) 17 | 18 | # Additional flags you would like to pass to the linker. You usually can leave 19 | # this line alone. 20 | LDFLAGS= 21 | 22 | # Specify the name of your lex program here. If you have flex installed, it is 23 | # highly recommended that you leave this line alone. If you use AT&T lex, 24 | # change this line to "lex". You then also need to change the next variable, 25 | # see below. 26 | LEX=flex 27 | 28 | # Flags you pass to the lexer. These are flex-specific. If you use AT&T lex, 29 | # change this line to "LEXFLAGS=" 30 | LEXFLAGS=-F -8 31 | 32 | # lex and flex require that you link against an additional library. If you use 33 | # AT&T lex, change this to "-ll". 34 | LEXLIB=-lfl 35 | 36 | 37 | # You can ignore the next lines if you do not want to build the filter 38 | # in a shared library. Unless you take part in the experimental glimpse 39 | # project that allows filters to be specified in shared libraries, you 40 | # can leave the rest of the makefile safely alone. 41 | 42 | #------------------------------------------------------------------------ 43 | 44 | # If you build a shared library, some compilers, such as gcc, require you 45 | # to build "position-independent" (i.e. relocatable) code. Some other 46 | # compilers do not require anything. Check your compiler manual on how to 47 | # build shared libraries and clear this line if necessary. 48 | SHAREDCFLAGS=-fPIC 49 | 50 | # This line is passed to the linker, to indicate that it should build a 51 | # shared library. Consult your compiler manual on how to build shared 52 | # libraries, and change this line if necessary. 53 | SHAREDLDFLAGS=-shared 54 | 55 | # This line specifies the library, in which the functions for loading 56 | # a shared library at runtime reside. More specifically, look for the 57 | # library that defines dlopen, dlsym, and dlclose. 58 | DLLIB=-ldl 59 | 60 | # Do not change this line 61 | SHAREDDEFS=-DSHARED_OBJECT 62 | 63 | 64 | htuml2txt: lex.yy.c 65 | $(CC) $(CFLAGS) $(DEFS) -c lex.yy.c 66 | $(LD) $(LDFLAGS) -o htuml2txt lex.yy.o $(LEXLIB) 67 | 68 | htuml2txt.so: lex.yy.c 69 | $(CC) $(CFLAGS) $(DEFS) $(SHAREDCFLAGS) $(SHAREDDEFS) -c lex.yy.c 70 | $(LD) $(LDFLAGS) $(SHAREDLDFLAGS) -o htuml2txt.so lex.yy.o $(LEXLIB) 71 | 72 | sotest: sotest.c 73 | $(CC) $(CFLAGS) $(DEFS) -c sotest.c 74 | $(LD) $(LDFLAGS) -o sotest sotest.o $(DLLIB) 75 | 76 | lex.yy.c: htuml2txt.lex 77 | $(LEX) $(LEXFLAGS) htuml2txt.lex 78 | 79 | all: htuml2txt htuml2txt.so 80 | 81 | clean: 82 | rm -f *.o lex.yy.c core 83 | 84 | distclean: clean 85 | rm -f htuml2txt htuml2txt.so Makefile 86 | 87 | install: all 88 | 89 | test: all 90 | echo "Doing regression test ..." 91 | 92 | 93 | alltest: test sotest 94 | echo "Doing extended regression test ... " 95 | -------------------------------------------------------------------------------- /dynfilters/Makefile.linux: -------------------------------------------------------------------------------- 1 | # Set this variable to the name of your C compiler 2 | CC=gcc 3 | 4 | # Provide optimization flages here. These settings are fine for egcs and 5 | # gcc >= 2.95. If you use an older gcc version, change -O3 to -O2. If you 6 | # use a non-gcc compiler, change this line to 7 | # CFLAGS=-O 8 | CFLAGS=-O3 -fomit-frame-pointer 9 | 10 | # Additional definitions you would like to pass to the compiler. You usually 11 | # can leave this line alone. 12 | DEFS= 13 | 14 | # The name of the linker. Usually, specifying the same name as the C compiler 15 | # is fine. Change this to "ld" if in doubt. 16 | LD=$(CC) 17 | 18 | # Additional flags you would like to pass to the linker. You usually can leave 19 | # this line alone. 20 | LDFLAGS= 21 | 22 | # Specify the name of your lex program here. If you have flex installed, it is 23 | # highly recommended that you leave this line alone. If you use AT&T lex, 24 | # change this line to "lex". You then also need to change the next variable, 25 | # see below. 26 | LEX=flex 27 | 28 | # Flags you pass to the lexer. These are flex-specific. If you use AT&T lex, 29 | # change this line to "LEXFLAGS=" 30 | LEXFLAGS=-F -8 31 | 32 | # lex and flex require that you link against an additional library. If you use 33 | # AT&T lex, change this to "-ll". 34 | LEXLIB=-lfl 35 | 36 | 37 | # You can ignore the next lines if you do not want to build the filter 38 | # in a shared library. Unless you take part in the experimental glimpse 39 | # project that allows filters to be specified in shared libraries, you 40 | # can leave the rest of the makefile safely alone. 41 | 42 | #------------------------------------------------------------------------ 43 | 44 | # If you build a shared library, some compilers, such as gcc, require you 45 | # to build "position-independent" (i.e. relocatable) code. Some other 46 | # compilers do not require anything. Check your compiler manual on how to 47 | # build shared libraries and clear this line if necessary. 48 | SHAREDCFLAGS=-fPIC 49 | 50 | # This line is passed to the linker, to indicate that it should build a 51 | # shared library. Consult your compiler manual on how to build shared 52 | # libraries, and change this line if necessary. 53 | SHAREDLDFLAGS=-shared 54 | 55 | # This line specifies the library, in which the functions for loading 56 | # a shared library at runtime reside. More specifically, look for the 57 | # library that defines dlopen, dlsym, and dlclose. 58 | DLLIB=-ldl 59 | 60 | # Do not change this line 61 | SHAREDDEFS=-DSHARED_OBJECT 62 | 63 | 64 | htuml2txt: lex.yy.c 65 | $(CC) $(CFLAGS) $(DEFS) -c lex.yy.c 66 | $(LD) $(LDFLAGS) -o htuml2txt lex.yy.o $(LEXLIB) 67 | 68 | htuml2txt.so: lex.yy.c 69 | $(CC) $(CFLAGS) $(DEFS) $(SHAREDCFLAGS) $(SHAREDDEFS) -c lex.yy.c 70 | $(LD) $(LDFLAGS) $(SHAREDLDFLAGS) -o htuml2txt.so lex.yy.o $(LEXLIB) 71 | 72 | sotest: sotest.c 73 | $(CC) $(CFLAGS) $(DEFS) -c sotest.c 74 | $(LD) $(LDFLAGS) -o sotest sotest.o $(DLLIB) 75 | 76 | lex.yy.c: htuml2txt.lex 77 | $(LEX) $(LEXFLAGS) htuml2txt.lex 78 | 79 | all: htuml2txt htuml2txt.so 80 | 81 | clean: 82 | rm -f *.o lex.yy.c core 83 | 84 | test: all 85 | echo "Doing regression test ..." 86 | 87 | 88 | alltest: test sotest 89 | echo "Doing extended regression test ... " 90 | -------------------------------------------------------------------------------- /dynfilters/README: -------------------------------------------------------------------------------- 1 | These files constitute fixes and enhancements for Webglimpse 2 | 1.7.1. Feel free to contact me at cvogler@gradient.cis.upenn.edu with 3 | any questions or concerns. 4 | 5 | 6 | Overview: 7 | ========= 8 | 9 | htuml2txt.lex - a set of lex rules intended to replace the functionality 10 | htuml2txt.pl. Can be built with either flex or an 11 | 8bit-clean AT&T lex. 12 | 13 | Makefile.linux - Makefile for building an optimized htuml2txt on Linux. 14 | Adapting it to other systems should be trivial. 15 | 16 | Makefile.flex - A generic makefile for flex 17 | 18 | Makefile.att - A generic makefile for AT&T lex variants 19 | 20 | makecron.patch - A small patch that makes sure that the indexing phase 21 | of Webglimpse also uses an HTML filter (html2txt, 22 | htuml2txt, or htuml2txt.pl). It does so by adding the -z 23 | switch to the argument list of glimpseindex. 24 | 25 | 26 | htuml2txt.lex 27 | ============= 28 | 29 | Description: A faster HTML filter for WebGlimpse than htuml2txt.pl. I 30 | found that the spawning of all the perl processes by glimpse was way 31 | too expensive to be practical. In particular, searching 2000 files for 32 | a frequently occuring term took more than 30 seconds on a 33 | PII-400/Linux 2.2.5 machine. Rewriting the filter as a set of lex 34 | rules sped up the search by a factor of 6, which is about on par with 35 | the plain html2txt filter. 36 | 37 | You need either flex(1) from the Free Software Foundation 38 | (http://www.fsf.org), or an 8bit-clean version of AT&T lex(1) to build 39 | the filter correctly. Systems that have a C compiler installed usually 40 | also have at least one of these tools installed. I tested the filter 41 | successfully on Linux 2.2 (using flex), SGI IRIX 6.4 (using both flex 42 | and AT&T lex), and Solaris 2.6 (using both flex and AT&T lex). 43 | 44 | When in doubt, I recommend using flex. It is freely available, and it 45 | is much faster and more robust than the AT&T variants of lex. 46 | 47 | If you are using Linux and have egcs installed, you can build an 48 | optimized version of html2txt with this command: 49 | 50 | make -f Makefile.linux 51 | 52 | Otherwise, if you are using flex on any system, you can build the 53 | filter with this command: 54 | 55 | make -f Makefile.flex 56 | 57 | Finally, if you prefer using AT&T lex, you can build the filter with 58 | this command: 59 | 60 | make -f Makefile.att 61 | 62 | 63 | Any of these commands should build the file "htuml2txt". To install and 64 | use the filter, copy this file to the lib directory in your Webglimpse 65 | home directory. Also, edit the file ".glimpse_filters" in your 66 | database directory and replace all occurrences of "htuml2txt.pl" with 67 | "htuml2txt". 68 | 69 | 70 | makecron.patch 71 | ============== 72 | 73 | This is a small patch that ensures that Webglimpse uses the HTML 74 | filters during index creation. This can greatly reduce the number of 75 | files that webglimpse has to search. For some search terms, I observed 76 | a speedup of a factor of 2 with this change. 77 | 78 | To apply the patch, change to the webglimpse home directory and run 79 | this command: 80 | 81 | patch -p1 < /makecron.patch 82 | 83 | Afterwards, run makecron and reconfigure the archives to make sure 84 | that the changes propagate to all archives. 85 | 86 | 87 | -------------------------------------------------------------------------------- /dynfilters/htuml2txt.lex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gvelez17/glimpse/49457116bb0796636fd1bc84f39006fb102bfafc/dynfilters/htuml2txt.lex -------------------------------------------------------------------------------- /dynfilters/sotest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | 6 | int main(void) 7 | { 8 | int (*filter)(FILE *in, FILE *out); 9 | void *handle; 10 | char *error; 11 | 12 | if ((handle = dlopen("./htuml2txt.so", 13 | RTLD_NOW)) == NULL) { 14 | fprintf(stderr, "sotest: %s\n", dlerror()); 15 | return 1; 16 | } 17 | 18 | filter = dlsym(handle, "filter_func"); 19 | if ((error = dlerror()) != NULL) { 20 | fprintf(stderr, "sotest: %s\n", error); 21 | return 1; 22 | } 23 | 24 | (*filter)(stdin, stdout); 25 | 26 | dlclose(handle); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /genpatch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: genpatch,v 1.1 1999/11/03 20:36:24 golda Exp $ 3 | 4 | PATH=/bin:/usr/bin:/usr/local/bin ; export PATH 5 | ROOT=${1-.} 6 | RLOGFLAGS="-L -R" 7 | 8 | tmpfile="/tmp/findco$$" 9 | 10 | for rcsdir in `find ${ROOT} -name RCS -type d -print` ; do 11 | rlog ${RLOGFLAGS} ${rcsdir}/* > ${tmpfile} 12 | if [ -s "${tmpfile}" ] ; then 13 | echo "# Files in ${rcsdir}:" 14 | for f in `cat ${tmpfile}` ; do 15 | f2=`echo $f | sed -e 's@RCS/@@' -e 's@,v$@@'` 16 | rcsdiff -c ${f2} 17 | done 18 | fi 19 | done 20 | rm -f ${tmpfile} 21 | -------------------------------------------------------------------------------- /gentar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: gentar,v 1.1 1998/04/27 16:11:23 pab Exp $ 3 | # 4 | # Build a tar file image of this directory, checking out files from RCS. 5 | 6 | # What version to build? 7 | RELVER=${1-DEV} 8 | srcdir="./glimpse-${RELVER}-src" 9 | 10 | # Safety check---don't overwrite existing directory 11 | if [ -d "${srcdir}" ] ; then 12 | echo "$0: Please remove existing source archive ${srcdir}" 13 | exit 1 14 | fi 15 | 16 | # Get the hierarchy first 17 | dirs=`find . -type d` 18 | # Now create the duplication area 19 | mkdir ${srcdir} 20 | cdir=`pwd` 21 | # Duplicate the directory hierarchy; if the directory has an RCS area, 22 | # check out its files, then remove the RCS link. 23 | for d in ${dirs} ; do 24 | mkdir -p ${srcdir}/${d} 25 | if [ -e ${d}/RCS ] ; then 26 | (cd ${srcdir}/${d} ; ln -s ${cdir}/${d}/RCS ; co -f RCS/* ; rm RCS) 27 | fi 28 | done 29 | 30 | # Put all that into a tar file 31 | tar cf glimpse-${RELVER}-src.tar ${srcdir} 32 | -------------------------------------------------------------------------------- /glimpse.chronicle: -------------------------------------------------------------------------------- 1 | 0. Created file on 2/May/94 2 | 1. Added patches to main.c to use sizeof(char*) instead of 4 in relevant 3 | places. Same for other pointer mallocs. 4 | -- bg 2 May 1994 5 | 2. Successfully ported to DEC-ALPHA: changes to routines in agrep/agrep.c 6 | -- bg 10 May 1994 7 | 3. Added the new mgrep routine. Removed bugs (pattern too long) related to 8 | using shift-or/and algorithm to search for booleans: now it uses mgrep. 9 | -- bg 26-30 May 1994 10 | 4. Added delimiter processing even with -f and -m. 11 | -- bg 31 May - 2 June 1994 12 | 5. Added structured queries support in June 1994 13 | -- Syntax of glimpse: 14 | glimpse 'a1=v1,a2=v2...' (series of ORs) 15 | glimpse 'a1=v1;a2=v2...' (series of ANDs) 16 | -- Syntax of glimpseindex: 17 | glimpseindex -s 18 | -- NOTES: 19 | v1, v2 etc. must lie within the range of a1, a2, etc., i.e., if 20 | a1 is in the region [offset, offset+len] in a file, v1 must lie 21 | compleletely within that range. 22 | A new glimpse-file called .glimpse_attributes is created to hold 23 | the attributes discovered while indexing with -s. A-V searches 24 | may not give out an error message if the index is not built with -s. 25 | 6. Added glimpseserver to speed up queries by reading in the index ahead of 26 | time, during July 1994. 27 | 7. Integrated compression into glimpse during July 1994. The new option to 28 | glimpseindex can now index compressed files (those compressed with tcomp). 29 | 8. Added multipattern search for simple patterns with -w in compressed files 30 | during August 1994. 31 | 9. Ability to take input files from command line (-F) (Sep 10/94) 32 | 10. Added byte level index support (Sep 23/94) 33 | 11. Added support for arbitrary boolean expressions (Oct 10/94) 34 | 12. Added support for arbitary filtering with -z option (Oct 94) 35 | 13. Completely integrated glimpseserver into Harvest (Jan 95) 36 | 14. Speeded up structured queries and -W option (filtering) (Feb 95) 37 | 15. Added -W -z support (June 1995) 38 | 16. Added undocumented options for index-search/analysis (SFS_COMPAT, Jun 1995) 39 | 17. Removed bugs related to structured queries and booleans w/ -b (Jul 1995) 40 | 18. Added -z and structured queries support (Aug 1995) 41 | 19. Changed maximum pattern and indexable word sizes (Sep 1995) 42 | 20. Made it portable to various architectures (see README.install, Oct 1995) 43 | 21. Added "-f filename" option to glimpse: it allows you to restrict the 44 | search to only those files whose names appear in "filename" (Jan 1996). 45 | 22. Fixed the agrep bug where -n was not working with ISO chars (Jan 1996). 46 | 23. Added -t to glimpseindex that sorts .glimpse_filenames by decreasing order 47 | of modify time (st_mtime in stat structure); 48 | Added -@ option to glimpse to print time of file along with its name; 49 | (Feb 1996) 50 | 24. Added "-Y days" option to print files that were modified "days" before 51 | the index was created (Mar 1996). 52 | 25. Added support for handling filenames/directorynames with special characters: 53 | they can now have ' " & > < ! etc., whatever and glimpse works just fine. 54 | 26. Added conversion program for neighborhood manipulation in webglimpse (9/96). 55 | 27. Added limited support for NOT in glimpse (index search or -W only) (11/96). 56 | 28. Added support to search for patterns with repeating strings (11/96): 57 | "{computer;science},{computer;chronicles}" 58 | This now works in agrep as well as glimpse. However, its for simple 59 | patterns only (i.e., no regexp or spelling-errors). 60 | 29. Fixed some nagging memory leaks and segfaults on Solaris (10/96). 61 | 30. Fixed multiple matches / missed matches problems with -W (11/96). 62 | 31. Release of version 4.1 (10/97) 63 | -------------------------------------------------------------------------------- /glimpse/KNOWN_BUGS: -------------------------------------------------------------------------------- 1 | * Thu Aug 20 14:56:44 1998 2 | 3 | agrep -v fails to write anything unless at least one line (possibly, a 4 | particular line) of the input matches the pattern that we're trying to 5 | mismatch. The non-glimpse agrep does not have this problem. E.g.: 6 | 7 | thalia[189]$ for p in O e n w o r ; do echo "Pattern '${p}':" ; echo "One@Two@Three" | tr '@' '\012' | agrep -v ${p} ; done 8 | Pattern 'O': 9 | Pattern 'e': 10 | Two 11 | Pattern 'n': 12 | Pattern 'w': 13 | One 14 | Pattern 'o': 15 | One 16 | Pattern 'r': 17 | One 18 | Two 19 | 20 | thalia[190]$ for p in O e n w o r ; do echo "Pattern '${p}':" ; echo "One@Two@Three" | tr '@' '\012' | agrep-2.04 -v ${p} ; done 21 | Pattern 'O': 22 | Two 23 | Three 24 | Pattern 'e': 25 | Two 26 | Pattern 'n': 27 | Two 28 | Three 29 | Pattern 'w': 30 | One 31 | Three 32 | Pattern 'o': 33 | One 34 | Three 35 | Pattern 'r': 36 | One 37 | Two 38 | 39 | The non-glimpse agrep uses bitap to do the search; the glimpse one uses bm. 40 | Some pre-condition is unsatisfied in the call to bm, because it overruns the 41 | input text buffer by a huge amount in attempting to find a pattern match. 42 | 43 | It isn't obvious to me where this bug is arising, or how to fix it. 44 | -------------------------------------------------------------------------------- /glimpse/README: -------------------------------------------------------------------------------- 1 | GLIMPSE 4.18: searching entire file systems 2 | (http://webglimpse.net/) 3 | (http://glimpse.cs.arizona.edu/) 4 | 5 | For installation instructions, see README.install 6 | 7 | Glimpse is a very powerful indexing and query system that allows you to 8 | search through all your files very quickly. It can be used by 9 | individuals for their personal file systems as well as by organizations 10 | for large data collections. Glimpse is also the basis of WebGlimpse, 11 | which provides search for web sites, and it is the default search engine 12 | in Harvest (see below). 13 | 14 | Glimpseindex, which you run by saying "glimpseindex DIR" builds an 15 | index of all text files in the tree rooted at DIR. 16 | (e.g., glimpseindex ~ indexes all your files.) With it, glimpse can 17 | search through all files much the same way as agrep (or any other 18 | grep), except that you don't have to specify file names and the search 19 | is fast. For example, 20 | 21 | glimpse -1 unbelievable 22 | 23 | will find all occurrences (in all your files!) of "unbelievable" 24 | allowing one spelling error; 25 | 26 | glimpse -F mail arizona 27 | 28 | will find all occurrences of "arizona" in all files with "mail" somewhere 29 | in their name; 30 | 31 | glimpse 'Arizona desert;windsurfing' 32 | 33 | will find all lines that contain both "Arizona desert" and "windsurfing". 34 | 35 | Glimpse supports three types of indexes: a tiny one (2-3% of the 36 | size of all files), a small one (7-9%), and a medium one (20-30%). 37 | The larger the index the faster the search. 38 | Glimpse supports most of agrep's options (agrep is our powerful version 39 | of grep, and it is part of glimpse) including approximate matching 40 | (e.g., finding misspelled words), Boolean queries, and even some 41 | limited forms of regular expressions. 42 | 43 | The WWW home page for glimpse is in 44 | http://glimpse.cs.arizona.edu/ 45 | It includes links to the source, binaries for most UNIX systems, 46 | documentations, articles, and more. 47 | 48 | The WebGlimpse home page is in 49 | http://glimpse.cs.arizona.edu/webglimpse/ 50 | 51 | Harvest's WWW home page is 52 | http://harvest.cs.colorado.edu/ 53 | (Harvest is an integrated set of tools to gather, extract, 54 | organize, search, cache, and replicate relevant information 55 | across the Internet.) 56 | 57 | Mail glimpse-request@cs.arizona.edu to be added to the glimpse mailing list. 58 | Mail glimpse@cs.arizona.edu to report bugs, ask questions, discuss 59 | tricks for using glimpse, etc. (This is a moderated mailing list.) 60 | 61 | Udi Manber, Burra Gopal, and Sun Wu. 62 | 63 | Please report bugs online at http://webglimpse.net/contact.php 64 | -------------------------------------------------------------------------------- /glimpse/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef _GIMPSE_DEFS_H_ 2 | #define _GIMPSE_DEFS_H_ 3 | 4 | #include /* autoconf defines */ 5 | 6 | #define MAX_ARGS 80 /* English alphabets + numbers + pattern + progname + arguments + extras */ 7 | #define MAXFILEOPT 1024 /* includes length of args too: #args is <= MAX_ARGS */ 8 | #define BLOCKSIZE 8192 /* For compression: what is the optimal unit of disk i/o = n * pagesize */ 9 | 10 | /* 11 | * These are some parameters that allow us to switch between offset computation 12 | * and just index computation when the index is built at a byte-level: since 13 | * offset computation is a waste if we can't narrow down search enough (since 14 | * we must look all over and the lists become too long => bottleneck). This may 15 | * not be needed if we used trees to store intervals --- we'll do it later :-). 16 | */ 17 | 18 | #define MAX_DISPARITY 100 /* if least frequent word occurrs in < 1/100 times most frequent word, resort to agrep: don't intersect lists (byte-level) */ 19 | #define MIN_OCCURRENCES 20 /* Min no. of occurrences before we check for highly frequent words using MAX_UNION */ 20 | #define MAX_UNION 500 /* Don't even perform the Union of offsets if least < 1/500 times most freq word (we are on track of stop list kinda words) */ 21 | #define MAX_ABSOLUTE MAX_SORTLINE_LEN /* Don't even perform the Union of offsets if a word occurs more than 16K times (independent of #of files) */ 22 | #endif 23 | -------------------------------------------------------------------------------- /glimpse/genpatch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: genpatch,v 1.1 1999/11/03 20:36:24 golda Exp $ 3 | 4 | PATH=/bin:/usr/bin:/usr/local/bin ; export PATH 5 | ROOT=${1-.} 6 | RLOGFLAGS="-L -R" 7 | 8 | tmpfile="/tmp/findco$$" 9 | 10 | for rcsdir in `find ${ROOT} -name RCS -type d -print` ; do 11 | rlog ${RLOGFLAGS} ${rcsdir}/* > ${tmpfile} 12 | if [ -s "${tmpfile}" ] ; then 13 | echo "# Files in ${rcsdir}:" 14 | for f in `cat ${tmpfile}` ; do 15 | f2=`echo $f | sed -e 's@RCS/@@' -e 's@,v$@@'` 16 | rcsdiff -c ${f2} 17 | done 18 | fi 19 | done 20 | rm -f ${tmpfile} 21 | -------------------------------------------------------------------------------- /glimpse/gentar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # $Id: gentar,v 1.1 1998/04/27 16:11:23 pab Exp $ 3 | # 4 | # Build a tar file image of this directory, checking out files from RCS. 5 | 6 | # What version to build? 7 | RELVER=${1-DEV} 8 | srcdir="./glimpse-${RELVER}-src" 9 | 10 | # Safety check---don't overwrite existing directory 11 | if [ -d "${srcdir}" ] ; then 12 | echo "$0: Please remove existing source archive ${srcdir}" 13 | exit 1 14 | fi 15 | 16 | # Get the hierarchy first 17 | dirs=`find . -type d` 18 | # Now create the duplication area 19 | mkdir ${srcdir} 20 | cdir=`pwd` 21 | # Duplicate the directory hierarchy; if the directory has an RCS area, 22 | # check out its files, then remove the RCS link. 23 | for d in ${dirs} ; do 24 | mkdir -p ${srcdir}/${d} 25 | if [ -e ${d}/RCS ] ; then 26 | (cd ${srcdir}/${d} ; ln -s ${cdir}/${d}/RCS ; co -f RCS/* ; rm RCS) 27 | fi 28 | done 29 | 30 | # Put all that into a tar file 31 | tar cf glimpse-${RELVER}-src.tar ${srcdir} 32 | -------------------------------------------------------------------------------- /glimpse/glimpse.chronicle: -------------------------------------------------------------------------------- 1 | 0. Created file on 2/May/94 2 | 1. Added patches to main.c to use sizeof(char*) instead of 4 in relevant 3 | places. Same for other pointer mallocs. 4 | -- bg 2 May 1994 5 | 2. Successfully ported to DEC-ALPHA: changes to routines in agrep/agrep.c 6 | -- bg 10 May 1994 7 | 3. Added the new mgrep routine. Removed bugs (pattern too long) related to 8 | using shift-or/and algorithm to search for booleans: now it uses mgrep. 9 | -- bg 26-30 May 1994 10 | 4. Added delimiter processing even with -f and -m. 11 | -- bg 31 May - 2 June 1994 12 | 5. Added structured queries support in June 1994 13 | -- Syntax of glimpse: 14 | glimpse 'a1=v1,a2=v2...' (series of ORs) 15 | glimpse 'a1=v1;a2=v2...' (series of ANDs) 16 | -- Syntax of glimpseindex: 17 | glimpseindex -s 18 | -- NOTES: 19 | v1, v2 etc. must lie within the range of a1, a2, etc., i.e., if 20 | a1 is in the region [offset, offset+len] in a file, v1 must lie 21 | compleletely within that range. 22 | A new glimpse-file called .glimpse_attributes is created to hold 23 | the attributes discovered while indexing with -s. A-V searches 24 | may not give out an error message if the index is not built with -s. 25 | 6. Added glimpseserver to speed up queries by reading in the index ahead of 26 | time, during July 1994. 27 | 7. Integrated compression into glimpse during July 1994. The new option to 28 | glimpseindex can now index compressed files (those compressed with tcomp). 29 | 8. Added multipattern search for simple patterns with -w in compressed files 30 | during August 1994. 31 | 9. Ability to take input files from command line (-F) (Sep 10/94) 32 | 10. Added byte level index support (Sep 23/94) 33 | 11. Added support for arbitrary boolean expressions (Oct 10/94) 34 | 12. Added support for arbitary filtering with -z option (Oct 94) 35 | 13. Completely integrated glimpseserver into Harvest (Jan 95) 36 | 14. Speeded up structured queries and -W option (filtering) (Feb 95) 37 | 15. Added -W -z support (June 1995) 38 | 16. Added undocumented options for index-search/analysis (SFS_COMPAT, Jun 1995) 39 | 17. Removed bugs related to structured queries and booleans w/ -b (Jul 1995) 40 | 18. Added -z and structured queries support (Aug 1995) 41 | 19. Changed maximum pattern and indexable word sizes (Sep 1995) 42 | 20. Made it portable to various architectures (see README.install, Oct 1995) 43 | 21. Added "-f filename" option to glimpse: it allows you to restrict the 44 | search to only those files whose names appear in "filename" (Jan 1996). 45 | 22. Fixed the agrep bug where -n was not working with ISO chars (Jan 1996). 46 | 23. Added -t to glimpseindex that sorts .glimpse_filenames by decreasing order 47 | of modify time (st_mtime in stat structure); 48 | Added -@ option to glimpse to print time of file along with its name; 49 | (Feb 1996) 50 | 24. Added "-Y days" option to print files that were modified "days" before 51 | the index was created (Mar 1996). 52 | 25. Added support for handling filenames/directorynames with special characters: 53 | they can now have ' " & > < ! etc., whatever and glimpse works just fine. 54 | 26. Added conversion program for neighborhood manipulation in webglimpse (9/96). 55 | 27. Added limited support for NOT in glimpse (index search or -W only) (11/96). 56 | 28. Added support to search for patterns with repeating strings (11/96): 57 | "{computer;science},{computer;chronicles}" 58 | This now works in agrep as well as glimpse. However, its for simple 59 | patterns only (i.e., no regexp or spelling-errors). 60 | 29. Fixed some nagging memory leaks and segfaults on Solaris (10/96). 61 | 30. Fixed multiple matches / missed matches problems with -W (11/96). 62 | 31. Release of version 4.1 (10/97) 63 | -------------------------------------------------------------------------------- /glimpse/glimpseserver.1: -------------------------------------------------------------------------------- 1 | .TH GLIMPSESERVER l "October 13, 1997" 2 | .SH NAME 3 | \fIglimpseserver 4.1\fP - a server version of the glimpse searching package. 4 | .SH OVERVIEW 5 | \fIGlimpse\fP 6 | is an indexing and query system that allows you to search through 7 | all your files very quickly. 8 | The use of glimpse in servers that handle frequent queries 9 | is growing, which is why we wrote glimpseserver to 10 | make searches more efficient. 11 | Glimpseserver starts a process that listens to queries, runs glimpse, 12 | and sends the answers back. 13 | The main advantage is that the index is read only once into memory 14 | saving a lot of IO. 15 | Glimpse communicates with glimpseserver through a given port number. 16 | See the warning about security below. 17 | .LP 18 | .SH SYNOPSIS 19 | .B glimpseserver 20 | [ 21 | \fB\-H \fIdir\fP \-K \fIport\fP \-J \fIhost\fP. 22 | ] 23 | .SH "DESCRIPTION" 24 | .LP 25 | .TP 26 | .B \-H \fIdir\fP 27 | specifies the directory of the index. Similar to the \-H option 28 | of glimpse. 29 | The default directory is the value of the environment variable $HOME 30 | if that is set, otherwise it is the current directory. 31 | .TP 32 | .B \-K \fIport\fP 33 | this is the TCP port for communication: glimpseserver waits for requests 34 | on this port and clients that want to search using the index in 35 | specified by the \-H option must use this port (by calling 36 | glimpse -K). 37 | The defaults port number is 2001. 38 | .TP 39 | .B \-J \fIhost\fP 40 | the name of the host. The default is the host where glimpseserver 41 | is running, which is probably the only possibility anyway. 42 | .SH "RESTARTING" 43 | .LP 44 | If a new index is created by running glimpseindex every night, 45 | restarting a new glimpseserver is now easier: 46 | simply send a SIGUSR2 (signal #31 - i.e., "kill -31 pid") to 47 | glimpseserver; it then re-reads the NEW index and is ready to serve 48 | requests again. 49 | (A SIGHUP, i.e., signal #1, can also be sent instead of SIGUSR2 50 | to make the glimpseserver re-read the new index.) 51 | The recommended way to do a fresh indexing while the 52 | server is still running is: 53 | .br 54 | send SIGSTOP to glimpseserver 55 | .br 56 | do the indexing 57 | .br 58 | send SIGUSR2 to glimpseserver 59 | .br 60 | send SIGCONT to glimpseserver (to ask it to continue after stop) 61 | .br 62 | The SIGSTOP is required so that glimpseserver doesn't answer any queries 63 | while the indexing is going on. 64 | .SH "WARNING" 65 | .LP 66 | Glimpseserver should be used only for public servers. 67 | Any client that knows the port number can get any information 68 | available in the index (and port numbers are not that secret). 69 | When glimpse is run as a standalone application it requires read 70 | permission of the index and all the files. 71 | When glimpse uses the \-C option to communicate with glimpseserver, 72 | glimpse (the client) does not require any permission, because glimpseserver 73 | does all the searching. 74 | So, we recommend not to run glimpseserver on any data that 75 | should be protected. 76 | Glimpseserver is meant to be used for public data. 77 | .SH "SEE ALSO" 78 | .BR glimpse (1), 79 | .BR glimpseindex (1), 80 | .SH BUGS 81 | .LP 82 | Please submit bug reports or comments at http://webglimpse.net/bugzilla/ 83 | .SH AUTHORS 84 | Udi Manber and Burra Gopal, Department of Computer Science, 85 | University of Arizona, and Sun Wu, the National Chung-Cheng University, 86 | Taiwan. Now maintained by Golda Velez at Internet WorkShop 87 | (Email: gvelez@webglimpse.net) 88 | -------------------------------------------------------------------------------- /glimpse/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Last modified: 1994-03-25 6 | # Public domain 7 | 8 | errstatus=0 9 | 10 | for file in ${1+"$@"} ; do 11 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 12 | shift 13 | 14 | pathcomp= 15 | for d in ${1+"$@"} ; do 16 | pathcomp="$pathcomp$d" 17 | case "$pathcomp" in 18 | -* ) pathcomp=./$pathcomp ;; 19 | esac 20 | 21 | if test ! -d "$pathcomp"; then 22 | echo "mkdir $pathcomp" 1>&2 23 | mkdir "$pathcomp" || errstatus=$? 24 | fi 25 | 26 | pathcomp="$pathcomp/" 27 | done 28 | done 29 | 30 | exit $errstatus 31 | 32 | # mkinstalldirs ends here 33 | 34 | -------------------------------------------------------------------------------- /glimpseserver.1: -------------------------------------------------------------------------------- 1 | .TH GLIMPSESERVER l "October 13, 1997" 2 | .SH NAME 3 | \fIglimpseserver 4.1\fP - a server version of the glimpse searching package. 4 | .SH OVERVIEW 5 | \fIGlimpse\fP 6 | is an indexing and query system that allows you to search through 7 | all your files very quickly. 8 | The use of glimpse in servers that handle frequent queries 9 | is growing, which is why we wrote glimpseserver to 10 | make searches more efficient. 11 | Glimpseserver starts a process that listens to queries, runs glimpse, 12 | and sends the answers back. 13 | The main advantage is that the index is read only once into memory 14 | saving a lot of IO. 15 | Glimpse communicates with glimpseserver through a given port number. 16 | See the warning about security below. 17 | .LP 18 | .SH SYNOPSIS 19 | .B glimpseserver 20 | [ 21 | \fB\-H \fIdir\fP \-K \fIport\fP \-J \fIhost\fP. 22 | ] 23 | .SH "DESCRIPTION" 24 | .LP 25 | .TP 26 | .B \-H \fIdir\fP 27 | specifies the directory of the index. Similar to the \-H option 28 | of glimpse. 29 | The default directory is the value of the environment variable $HOME 30 | if that is set, otherwise it is the current directory. 31 | .TP 32 | .B \-K \fIport\fP 33 | this is the TCP port for communication: glimpseserver waits for requests 34 | on this port and clients that want to search using the index in 35 | specified by the \-H option must use this port (by calling 36 | glimpse -K). 37 | The defaults port number is 2001. 38 | .TP 39 | .B \-J \fIhost\fP 40 | the name of the host. The default is the host where glimpseserver 41 | is running, which is probably the only possibility anyway. 42 | .SH "RESTARTING" 43 | .LP 44 | If a new index is created by running glimpseindex every night, 45 | restarting a new glimpseserver is now easier: 46 | simply send a SIGUSR2 (signal #31 - i.e., "kill -31 pid") to 47 | glimpseserver; it then re-reads the NEW index and is ready to serve 48 | requests again. 49 | (A SIGHUP, i.e., signal #1, can also be sent instead of SIGUSR2 50 | to make the glimpseserver re-read the new index.) 51 | The recommended way to do a fresh indexing while the 52 | server is still running is: 53 | .br 54 | send SIGSTOP to glimpseserver 55 | .br 56 | do the indexing 57 | .br 58 | send SIGUSR2 to glimpseserver 59 | .br 60 | send SIGCONT to glimpseserver (to ask it to continue after stop) 61 | .br 62 | The SIGSTOP is required so that glimpseserver doesn't answer any queries 63 | while the indexing is going on. 64 | .SH "WARNING" 65 | .LP 66 | Glimpseserver should be used only for public servers. 67 | Any client that knows the port number can get any information 68 | available in the index (and port numbers are not that secret). 69 | When glimpse is run as a standalone application it requires read 70 | permission of the index and all the files. 71 | When glimpse uses the \-C option to communicate with glimpseserver, 72 | glimpse (the client) does not require any permission, because glimpseserver 73 | does all the searching. 74 | So, we recommend not to run glimpseserver on any data that 75 | should be protected. 76 | Glimpseserver is meant to be used for public data. 77 | .SH "SEE ALSO" 78 | .BR glimpse (1), 79 | .BR glimpseindex (1), 80 | .SH BUGS 81 | .LP 82 | Please submit bug reports or comments at http://webglimpse.net/bugzilla/ 83 | .SH AUTHORS 84 | Udi Manber and Burra Gopal, Department of Computer Science, 85 | University of Arizona, and Sun Wu, the National Chung-Cheng University, 86 | Taiwan. Now maintained by Golda Velez at Internet WorkShop 87 | (Email: gvelez@webglimpse.net) 88 | -------------------------------------------------------------------------------- /index/README: -------------------------------------------------------------------------------- 1 | This contains the source for the program "glimpseindex". 2 | -------------------------------------------------------------------------------- /index/fixname.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | main() 4 | { 5 | int offset = 0; 6 | char buffer[1024]; 7 | 8 | fgets(buffer, 1024, stdin); /* skip over num. of file names */ 9 | offset += strlen(buffer); 10 | while (fgets(buffer, 1024, stdin) != NULL) { 11 | putc((offset & 0xff000000) >> 24, stdout); 12 | putc((offset & 0xff0000) >> 16, stdout); 13 | putc((offset & 0xff00) >> 8, stdout); 14 | putc((offset & 0xff), stdout); 15 | offset += strlen(buffer); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /index/lib.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* ./glimpse/index/lib.c */ 3 | #include 4 | 5 | unsigned char *strdup(str) 6 | unsigned char *str; 7 | { 8 | int len; 9 | unsigned char *str1, *str1_bak; 10 | extern char *my_malloc(); 11 | 12 | len = strlen(str); 13 | str1 = (unsigned char *) my_malloc(len + 2); 14 | if(str1 == NULL) { 15 | fprintf(stderr, "malloc failure\n"); 16 | exit(2); 17 | } 18 | str1_bak = str1; 19 | while(*str1++ = *str++); 20 | return(str1_bak); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /index/memlook.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* ./glimpse/index/newmemlook.c */ 3 | 4 | /* by Christian Vogler, Jan 9, 2000 */ 5 | 6 | /* I completely rewrote memlook, because in its original form the function 7 | has too many problems. It is prone to several buffer overruns. In addition, 8 | it puts a sentinel value past the end of the buffer, which may corrupt 9 | other data structures. 10 | 11 | The purpose of this function is to match a string in an area of text. 12 | If the string starts with a newline, it is matched as well, *except* 13 | at the very beginning of the text area. In this latter case, the newline 14 | is ignored. 15 | 16 | Returns the index of the first character of the matching string in 17 | the text area (excluding beginning newline), or -2 if it cannot be found. 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | int memlook(const unsigned char *pattern, const unsigned char *text, 24 | int length) 25 | { 26 | int pattern_length; 27 | const unsigned char *text_end = text + length; 28 | const unsigned char *pat_compare = pattern; /* next pattern character to be 29 | compared */ 30 | const unsigned char *text_ptr = text; /* next text location to be searched 31 | for pattern */ 32 | const unsigned char *text_compare; /* next text character to be compared 33 | in a pattern comparision */ 34 | int found = 0; 35 | 36 | pattern_length = strlen((char *) pattern); 37 | 38 | /* First check if pattern starts with a newline. If yes, ignore 39 | newline and try to match rest of pattern at beginning of text. */ 40 | if (pattern[0] == '\n') 41 | pat_compare++; 42 | 43 | while (text_ptr + pattern_length <= text_end) { 44 | text_compare = text_ptr; 45 | while (pat_compare < pattern + pattern_length) { 46 | if (*pat_compare != *text_compare) 47 | break; 48 | pat_compare++; 49 | text_compare++; 50 | } 51 | 52 | found = (pat_compare == pattern + pattern_length); 53 | if (found) 54 | break; /* pattern has been found */ 55 | 56 | /* not found? then reset pattern comparison character pointer 57 | and try next text character */ 58 | pat_compare = pattern; 59 | text_ptr++; 60 | } 61 | 62 | if (found) { 63 | /* ignore beginning newline in pattern when returning position */ 64 | if (pattern[0] 65 | == '\n' && *text_ptr == '\n') 66 | text_ptr++; 67 | return text_ptr - text; 68 | } 69 | else 70 | return (-2); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /index/region.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* Constructed from the mail messages received from Bill Camargo in June 1994 */ 3 | #ifndef _REGION_H_ 4 | #define _REGION_H_ 5 | #include 6 | #include /* autoconf defines STRUCTURED_SQURIES */ 7 | 8 | #if STRUCTURED_QUERIES 9 | /* These are imports from Bill's stuff */ 10 | #include "util.h" 11 | #include "template.h" 12 | #endif /*STRUCTURED_QUERIES*/ 13 | 14 | /* These are mine */ 15 | typedef struct REGION { 16 | int length; 17 | int offset; 18 | int attributeid; 19 | struct REGION *next, *prev; 20 | } region_t; 21 | 22 | /* Assuming there are no more than 2^(8*sizeof(int)) attributes */ 23 | typedef struct ATTR_ELEMENT { 24 | struct ATTR_ELEMENT *next; 25 | int attributeid; 26 | char *attribute; /* pointer to the one in the hash entry */ 27 | } attr_element_t; 28 | 29 | extern FILE *my_fopen(); 30 | extern char *my_malloc(); 31 | extern int my_free(); 32 | #endif /*_REGION_H_*/ 33 | -------------------------------------------------------------------------------- /index/simpletest.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal. All Rights Reserved. */ 2 | /* simple tests which don't need to access indexing data structures */ 3 | #include 4 | #include "glimpse.h" 5 | #define b_sample_size 2048 /* the number of bytes sampled to determine 6 | whether a file is binary */ 7 | #define u_sample_size 1024 /* the number of bytes sampled to determine 8 | whether a file is uuencoded */ 9 | 10 | extern UseFilters; 11 | 12 | #if 0 13 | /* --------------------------------------------------------------------- 14 | check for binary stream 15 | --------------------------------------------------------------------- */ 16 | test_binary(buffer, length) 17 | unsigned char *buffer; 18 | int length; 19 | { 20 | int i=0; 21 | int b_count=0; 22 | 23 | if(length > b_sample_size) length = b_sample_size; 24 | 25 | for(i=0; i 127) b_count++; 27 | } 28 | if(b_count*10 >= length) return(1); 29 | return(0); 30 | } 31 | #else /*0*/ 32 | /* Lets try this one instead: Chris Dalton */ 33 | test_binary(buffer, length) 34 | unsigned char *buffer; 35 | int length; 36 | { 37 | int permitted_errors; 38 | 39 | if (length > b_sample_size) { length= b_sample_size; } 40 | permitted_errors= length/10; 41 | 42 | while (permitted_errors && length--) { 43 | if (!(isgraph(*buffer) || isspace(*buffer))) --permitted_errors; 44 | buffer ++; 45 | } 46 | /* printf("\t\t\tpermerr=%d in %d\n", permitted_errors, length); */ 47 | return (permitted_errors == 0); 48 | } 49 | #endif /*0*/ 50 | 51 | /* --------------------------------------------------------------------- 52 | check for uuencoded stream 53 | --------------------------------------------------------------------- */ 54 | test_uuencode(buffer, length) 55 | unsigned char *buffer; 56 | int length; 57 | { 58 | int i=0; 59 | int j; 60 | 61 | if(length > u_sample_size) length = u_sample_size; 62 | 63 | if(strncmp((char *)buffer, "begin", 5) == 0) { 64 | i=5; 65 | goto CONT; 66 | } 67 | i = memlook("\nbegin", buffer, length); 68 | if(i < 0) return(0); 69 | CONT: 70 | while(buffer[i] != '\n' && i=length) return 0; 91 | buffer[i] = '\0'; 92 | if ((first = (char *)strstr((char *)buffer, "PS-Adobe")) == NULL) { 93 | buffer[i] = '\n'; 94 | return 0; 95 | } 96 | buffer[i] = '\n'; 97 | return 1; 98 | } 99 | 100 | char *suffixlist[NUM_SUFFIXES] = IGNORED_SUFFIXES; 101 | 102 | int 103 | test_special_suffix(name) 104 | char *name; 105 | { 106 | int len = strlen(name); 107 | int j, i = len-1; 108 | char *suffix; 109 | 110 | #if SFS_COMPAT 111 | while(i>=0) if (name[i] == '/') break; else i--; 112 | if (i<0) return 0; /* no suffix: can be directory... */ 113 | else suffix = &name[i+1]; 114 | 115 | for (j=0; j= NUM_SUFFIXES) return 0; 118 | return 1; 119 | #else 120 | while(i>=0) if (name[i] == '.') break; else i--; 121 | if (i<0) return 0; /* no suffix: can be directory... */ 122 | else suffix = &name[i+1]; 123 | 124 | for (j=0; j= NUM_SUFFIXES) return 0; 127 | return 1; 128 | #endif 129 | } 130 | -------------------------------------------------------------------------------- /libtemplate/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the common source directory 3 | # 4 | # $Id: Makefile.in,v 1.2 2001/05/21 04:48:55 golda Exp $ 5 | # 6 | SUBDIRS = util template lib 7 | DEBUG_TOP = #-O #-g #-DDEBUG 8 | 9 | srcdir = @srcdir@ 10 | VPATH = @srcdir@ 11 | prefix = /usr/local/harvest 12 | INSTALL_BINDIR = $(prefix)/bin 13 | INSTALL_LIBDIR = $(prefix)/lib 14 | INSTALL_MANDIR = $(prefix)/man 15 | 16 | SHELL = /bin/sh 17 | CC = @CC@ 18 | INSTALL = @INSTALL@ 19 | INSTALL_BIN = @INSTALL_PROGRAM@ 20 | INSTALL_FILE = @INSTALL_DATA@ 21 | RANLIB = @RANLIB@ 22 | LN_S = @LN_S@ 23 | XTRA_LIBS = @XTRA_LIBS@ 24 | 25 | # old variables for backward compatability 26 | INSTALLDIR = $(INSTALL_BINDIR) 27 | INSTALL_SCRIPT = $(INSTALL_BIN) 28 | 29 | INSTALL_DIRS = $(prefix) $(INSTALL_BINDIR) $(INSTALL_LIBDIR) \ 30 | $(INSTALL_MANDIR) 31 | 32 | default: all 33 | 34 | all install clean: 35 | @for dir in $(SUBDIRS); do \ 36 | echo Making $@ in $$dir; \ 37 | ( cd $$dir; $(MAKE) $@ ); \ 38 | done 39 | 40 | distclean realclean: 41 | @for dir in $(SUBDIRS); do \ 42 | echo Making $@ in $$dir; \ 43 | ( cd $$dir; $(MAKE) $@ ); \ 44 | done 45 | rm -f Makefile 46 | 47 | install-man: 48 | -------------------------------------------------------------------------------- /libtemplate/README: -------------------------------------------------------------------------------- 1 | This is source code that is used by various components of the Harvest system. 2 | 3 | Notes for distribution along with glimpse: 4 | ------------------------------------------ 5 | Glimpse uses the SOIF parser distributed with Harvest to support 6 | structured queries. To include the parser in glimpse, we made the 7 | following changes so that glimpse could be a stand-alone system (these 8 | changes are NOT present in the Glimpse source code present in Harvest): 9 | 10 | 1. Obtained Harvest source distribution from "harvest.cs.colorado.edu". 11 | 12 | 2. Made Harvest on our machine by running make from "harvest" directory. 13 | 14 | 3. Picked up the code in "harvest/src/common/", except for the code in 15 | "harvest/src/common/{gdbm,md5,url}", and put it in "glimpse/libtemplate". 16 | Commented out the HAVE_FLOCK and DIRENT definitions in include/autoconf.h. 17 | Made HAVE_GETCWD 0 with NeXT systems: 1 is the default. 18 | 19 | 4. Replaced Harvest's Makefiles for "src/common" with our own Makefiles. 20 | These Makefiles were INITIALLY derived by following steps 5..7 21 | (we DON'T have to make these changes for each new version of Harvest). 22 | 23 | 5. Changed the "Makefile"s generated by Harvest's configuration script 24 | to skip over the rules that made anything in "harvest/src/common" that 25 | needed the 3 directories mentioned above. We also changed the absolute 26 | pathnames of Unix commands generated by harvest to simple command names 27 | --- the user should add the relevant pathnames to his/her "$PATH". We 28 | also commented out rules to make "realclean" in ALL make files. But we 29 | DID NOT CHANGE "Makefile.in" in any directory, since we don't use it. 30 | 31 | 6. Added new makefiles in each of the directories "glimpse/libtemplate", 32 | "glimpse/libtemplate/util" and "glimpse/libtemplate/template" to handle the 33 | most common architectures, so that we did not need Harvest's autoconf to 34 | generate Makefiles. We hope to distribute our own autoconf later. 35 | 36 | 7. Changed INSTALL macros in all makefiles to simple "cp" since no one 37 | else needs to use the libtemplate library distributed along with glimpse. 38 | 39 | 8. Passed glimpse make-variables down to Makefiles within template and util 40 | directories in Makefile and the other makefiles specific to each platform. 41 | 42 | 9. On BSD, include/autoconf.h must have #define HAVE_STRERROR 1 (not #undef). 43 | 44 | -- Udi Manber, Burra Gopal 45 | -------------------------------------------------------------------------------- /libtemplate/include/ccache_list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ccache_list.h -- definitions for CS 2270 linked list package 3 | * 4 | * Mark Peterson 9/91 5 | * 6 | * $Id: ccache_list.h,v 1.1 1999/11/03 21:40:57 golda Exp $ 7 | * 8 | * ---------------------------------------------------------------------- 9 | * Copyright (c) 1994, 1995. All rights reserved. 10 | * 11 | * Mic Bowman of Transarc Corporation. 12 | * Peter Danzig of the University of Southern California. 13 | * Darren R. Hardy of the University of Colorado at Boulder. 14 | * Udi Manber of the University of Arizona. 15 | * Michael F. Schwartz of the University of Colorado at Boulder. 16 | * 17 | */ 18 | #ifndef _CCACHE_LIST_H_ 19 | #define _CCACHE_LIST_H_ 20 | 21 | typedef struct list_node { /*list node type */ 22 | struct list_node *next; /*points to the following node */ 23 | struct list_node *previous; /*points to the previous node */ 24 | Datum *data; /*stores data record in list */ 25 | } List_Node; 26 | 27 | 28 | typedef struct { /*list header node */ 29 | List_Node *first; /*points to the first node */ 30 | List_Node *last; /*points to the last node */ 31 | unsigned int count; 32 | /*keeps count of the number of nodes in list */ 33 | int (*compare) (); /*A compare function */ 34 | } Linked_List; 35 | 36 | 37 | /* 38 | **The list toolkit functions: 39 | */ 40 | 41 | Linked_List *list_create(); /*initialize list header block */ 42 | void list_destroy(); /*destroy list header block */ 43 | List_Node *list_insert(); /*insert a new node in the list */ 44 | Datum *list_delete(); /*delete a node from the list */ 45 | List_Node *list_find(); /*find a node in the list */ 46 | Boolean list_apply(); /*apply a function to each node in the list */ 47 | 48 | /*Built in Macros */ 49 | #define list_first(head) ((head)->first) /*find the first node in the list */ 50 | #define list_next(node) ((node)->next) /*find the next node in the list */ 51 | #define list_last(head) ((head)->last) /*find the last node in the list */ 52 | #define list_previous(node) ((node)->previous) 53 | /*find the previous node in the list */ 54 | 55 | #define list_getdata(node) ((node)->data) /*get the data from the list */ 56 | void list_putdata(); /*modify the data in the node in the list */ 57 | #define list_length(head) ((head)->count) /*find the length of the list */ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /libtemplate/include/ccache_queue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ccache_queue.h - 3 | * 4 | * Mark Peterson 9/91 5 | * 6 | * $Id: ccache_queue.h,v 1.1 1999/11/03 21:40:57 golda Exp $ 7 | * 8 | * ---------------------------------------------------------------------- 9 | * Copyright (c) 1994, 1995. All rights reserved. 10 | * 11 | * Mic Bowman of Transarc Corporation. 12 | * Peter Danzig of the University of Southern California. 13 | * Darren R. Hardy of the University of Colorado at Boulder. 14 | * Udi Manber of the University of Arizona. 15 | * Michael F. Schwartz of the University of Colorado at Boulder. 16 | * 17 | */ 18 | #ifndef _CCACHE_QUEUE_H_ 19 | #define _CCACHE_QUEUE_H_ 20 | 21 | #include "ccache_list.h" 22 | 23 | typedef List_Node Queue_Node; /*Define a Queue node same as a List node. */ 24 | typedef Linked_List Queue; /*Define a Queue header same as a List header.*/ 25 | 26 | /* **The queue toolkit contains: */ 27 | 28 | Queue *queue_create(); /*initialize queue header block */ 29 | void queue_destroy(); /*destory queue header block */ 30 | Boolean enqueue(); /*insert a new node at the end of the queue */ 31 | Datum *dequeue(); /*delete a node from the head of the queue */ 32 | Boolean queue_apply(); /*apply a function to each node in the queue */ 33 | Boolean queue_empty(); /*is the queue empty? */ 34 | 35 | /*Special functions designed for use in a priority timer queue. */ 36 | /*For use specifically with the time_it.h package. */ 37 | Boolean tenqueue(); /*Enqueue's a timer value. */ 38 | int tdequeue(); /*Dequeue's a timer value. */ 39 | Datum *head(); 40 | 41 | #define queue_length(q_head) ((q_head)->count) 42 | /*Return the number of items in the queue. */ 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /libtemplate/include/paths.h: -------------------------------------------------------------------------------- 1 | /* Generated automatically from paths.h.in by configure. */ 2 | #ifndef _PATHS_H_ 3 | #define _PATHS_H_ 4 | 5 | #ifndef CMD_PERL 6 | #define CMD_PERL "/usr/local/perl" 7 | #endif 8 | 9 | #ifndef CMD_GZIP 10 | #define CMD_GZIP "/usr/local/gzip" 11 | #endif 12 | 13 | #ifndef CMD_GUNZIP 14 | #define CMD_GUNZIP "/usr/local/gunzip" 15 | #endif 16 | 17 | #ifndef CMD_UNZIP 18 | #define CMD_UNZIP "/usr/local/unzip" 19 | #endif 20 | 21 | #ifndef CMD_UNCOMPRESS 22 | #define CMD_UNCOMPRESS "/usr/ucb/uncompress" 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /libtemplate/include/paths.h.in: -------------------------------------------------------------------------------- 1 | #ifndef _PATHS_H_ 2 | #define _PATHS_H_ 3 | 4 | #ifndef CMD_PERL 5 | #define CMD_PERL "@CMD_PERL@" 6 | #endif 7 | 8 | #ifndef CMD_GZIP 9 | #define CMD_GZIP "@CMD_GZIP@" 10 | #endif 11 | 12 | #ifndef CMD_GUNZIP 13 | #define CMD_GUNZIP "@CMD_GUNZIP@" 14 | #endif 15 | 16 | #ifndef CMD_UNZIP 17 | #define CMD_UNZIP "@CMD_UNZIP@" 18 | #endif 19 | 20 | #ifndef CMD_UNCOMPRESS 21 | #define CMD_UNCOMPRESS "@CMD_UNCOMPRESS@" 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libtemplate/include/time_it.h: -------------------------------------------------------------------------------- 1 | /* 2 | * time_it.h 3 | * 4 | * $Id: time_it.h,v 1.1 1999/11/03 21:40:57 golda Exp $ 5 | * 6 | * ---------------------------------------------------------------------- 7 | * Copyright (c) 1994, 1995. All rights reserved. 8 | * 9 | * Mic Bowman of Transarc Corporation. 10 | * Peter Danzig of the University of Southern California. 11 | * Darren R. Hardy of the University of Colorado at Boulder. 12 | * Udi Manber of the University of Arizona. 13 | * Michael F. Schwartz of the University of Colorado at Boulder. 14 | * 15 | */ 16 | #ifndef _TIME_IT_H_ 17 | #define _TIME_IT_H_ 18 | 19 | /*Automatically include timer.h only if not previously included. */ 20 | 21 | 22 | /*Simple structure to track blocked processes in an OS. */ 23 | typedef struct timer_record { 24 | int eventnum; /*Tracks the order of items enqueued. */ 25 | int time_in_secs; /*Non-cumulative time in seconds for process to 26 | remain blocked in queue. */ 27 | int (*ProctoCall) (); /*A pointer to the blocked procedure. */ 28 | } Time_Node; 29 | 30 | void InitTimer(); 31 | int SetTimer(); 32 | Boolean CancelTimer(); 33 | void HandleTimerSignal(); 34 | void Freeze(); 35 | void Thaw(); 36 | void DisplayQueue(); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libtemplate/include/url.h: -------------------------------------------------------------------------------- 1 | /* 2 | * url.h - URL Processing (parsing & retrieval) 3 | * 4 | * Darren Hardy, hardy@cs.colorado.edu, April 1994 5 | * 6 | * $Id: url.h,v 1.2 2006/02/03 16:59:14 golda Exp $ 7 | * 8 | * ---------------------------------------------------------------------- 9 | * Copyright (c) 1994, 1995. All rights reserved. 10 | * 11 | * Mic Bowman of Transarc Corporation. 12 | * Peter Danzig of the University of Southern California. 13 | * Darren R. Hardy of the University of Colorado at Boulder. 14 | * Udi Manber of the University of Arizona. 15 | * Michael F. Schwartz of the University of Colorado at Boulder. 16 | * 17 | */ 18 | #ifndef _URL_H_ 19 | #define _URL_H_ 20 | 21 | #include "config.h" 22 | #include 23 | 24 | /* 25 | * The supported URLs look like: 26 | * 27 | * file://host/pathname 28 | * gopher://host[:port][/TypeDigitGopherRequest] 29 | * http://host[:port][/[pathname][#name][?search]] 30 | * ftp://[user[:password]@]host[:port][/pathname] 31 | * 32 | * where host is either a fully qualified hostname, an IP number, or 33 | * a relative hostname. 34 | * 35 | * For http, any '#name' or '?search' directives are ignored. 36 | * For ftp, any user, password, or port directives are unsupported. 37 | */ 38 | 39 | struct url { 40 | char *url; /* Complete, normalized URL */ 41 | int type; /* file, ftp, http, gopher, etc. */ 42 | char *raw_pathname; /* pathname portion of the URL, w/ escapes */ 43 | char *pathname; /* pathname portion of the URL, w/o escapes */ 44 | char *host; /* fully qualified hostname */ 45 | int port; /* TCP/IP port */ 46 | 47 | 48 | /* Information for FTP processing */ 49 | char *user; /* Login name for ftp */ 50 | char *password; /* password for ftp */ 51 | 52 | /* Information for Gopher processing */ 53 | int gophertype; /* Numeric type for gopher request */ 54 | 55 | /* Information for HTTP processing */ 56 | char *http_version; /* HTTP/1.0 Version */ 57 | int http_status_code; /* HTTP/1.0 Status Code */ 58 | char *http_reason_line; /* HTTP/1.0 Reason Line */ 59 | char *http_mime_hdr; /* HTTP/1.0 MIME Response Header */ 60 | 61 | /* Information for local copy processing */ 62 | char *filename; /* local filename */ 63 | FILE *fp; /* ptr to local filename */ 64 | time_t lmt; /* Last-Modification-Time */ 65 | 66 | #ifdef USE_MD5 67 | char *md5; /* MD5 value of URL */ 68 | #endif 69 | }; 70 | typedef struct url URL; 71 | 72 | enum url_types { /* Constants for URL types */ 73 | URL_UNKNOWN, 74 | URL_FILE, 75 | URL_FTP, 76 | URL_GOPHER, 77 | URL_HTTP, 78 | URL_NEWS, 79 | URL_NOP, 80 | URL_TELNET, 81 | URL_WAIS 82 | }; 83 | 84 | #ifndef _PARAMS 85 | #define _PARAMS(ARGS) ARGS 86 | #endif /* _PARAMS */ 87 | 88 | URL *url_open _PARAMS((char *)); 89 | int url_read _PARAMS((char *, int, int, URL *)); 90 | int url_retrieve _PARAMS((URL *)); 91 | void url_close _PARAMS((URL *)); 92 | 93 | void init_url _PARAMS(()); 94 | void finish_url _PARAMS(()); 95 | 96 | void url_purge _PARAMS(()); 97 | 98 | URL *dup_url _PARAMS((URL *)); 99 | void print_url _PARAMS((URL *)); 100 | 101 | int http_get _PARAMS((URL *)); 102 | int ftp_get _PARAMS((URL *)); 103 | int gopher_get _PARAMS((URL *)); 104 | 105 | 106 | #ifdef USE_LOCAL_CACHE 107 | void init_cache _PARAMS(()); 108 | char *lookup_cache _PARAMS((char *)); 109 | time_t lmt_cache _PARAMS((char *)); 110 | void add_cache _PARAMS((char *, char *)); 111 | void finish_cache _PARAMS(()); 112 | void expire_cache _PARAMS(()); 113 | #endif 114 | 115 | #ifdef USE_CCACHE 116 | void url_initCache _PARAMS((int, long)); 117 | void url_shutdowncache _PARAMS(()); 118 | #endif 119 | 120 | #endif /* _URL_H_ */ 121 | 122 | -------------------------------------------------------------------------------- /libtemplate/include/util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * util.h - Common utilities for the Essence system 3 | * 4 | * Darren Hardy, hardy@cs.colorado.edu, April 1994 5 | * 6 | * $Id: util.h,v 1.3 2006/02/03 16:56:35 golda Exp $ 7 | * 8 | * ---------------------------------------------------------------------- 9 | * Copyright (c) 1994, 1995. All rights reserved. 10 | * 11 | * Mic Bowman of Transarc Corporation. 12 | * Peter Danzig of the University of Southern California. 13 | * Darren R. Hardy of the University of Colorado at Boulder. 14 | * Udi Manber of the University of Arizona. 15 | * Michael F. Schwartz of the University of Colorado at Boulder. 16 | */ 17 | #ifndef _UTIL_H_ 18 | #define _UTIL_H_ 19 | 20 | #include 21 | #include "config.h" 22 | 23 | /* Buffer structure for buffer management routines */ 24 | struct gbuf { /* Growing and shrinking buffer */ 25 | char *data; /* Data buffer */ 26 | int length; /* Current length of data buffer */ 27 | int size; /* Size allocated in the Data buffer */ 28 | int default_size; /* Default size of the Data buffer */ 29 | }; 30 | typedef struct gbuf Buffer; /* Growing buffer */ 31 | 32 | #define stradd_buffer(b,s) add_buffer((b), (s), strlen(s)) 33 | 34 | #ifndef _PARAMS 35 | #define _PARAMS(ARGS) ARGS 36 | #endif /* _PARAMS */ 37 | 38 | /* from buffer.c Buffer manipulation routines */ 39 | Buffer *create_buffer _PARAMS((int)); /* New buffer */ 40 | void grow_buffer _PARAMS((Buffer *)); /* Increase buffer size */ 41 | void increase_buffer _PARAMS((Buffer *, int)); /* Increase buffer size */ 42 | void shrink_buffer _PARAMS((Buffer *)); /* Reduce buffer size */ 43 | void add_buffer _PARAMS((Buffer *, char *, int));/* Add data to a buffer */ 44 | void free_buffer _PARAMS((Buffer *)); /* Clean up a buffer */ 45 | 46 | /* from host.c */ 47 | char *getfullhostname _PARAMS(()); /* Fully qualified hostname */ 48 | char *getmylogin _PARAMS(()); /* getlogin(3) clone */ 49 | char *getrealhost _PARAMS((char *)); /* Real DNS hostname */ 50 | 51 | /* from log.c */ 52 | void init_log _PARAMS((FILE *, FILE *)); /* Initialize log routines */ 53 | void init_log3 _PARAMS((char *,FILE *,FILE *)); /* Initialize log routines */ 54 | void log_errno _PARAMS((char *)); /* Same as perror(3) */ 55 | void fatal_errno _PARAMS((char *)); /* Same as perror(3) & exit */ 56 | #include 57 | void glimpselog _PARAMS((char *, ...)); /* Log a message */ 58 | void errorlog _PARAMS((char *, ...)); /* Log an error message */ 59 | void fatal _PARAMS((char *, ...)); /* Log error msg and exit */ 60 | 61 | #ifdef NO_STRDUP 62 | /* from strdup.c */ 63 | char *strdup _PARAMS((const char *)); /* Duplicate a string */ 64 | #endif 65 | 66 | /* from string.c */ 67 | void parse_argv _PARAMS((char **, char *)); /* Parse a command string */ 68 | 69 | /* from system.c */ 70 | int do_system _PARAMS((char *)); /* Wrapper for system(3) */ 71 | int run_cmd _PARAMS((char *)); /* Simple system(3) */ 72 | void do_system_lifetime _PARAMS((char *, int)); /* Limited system(3) */ 73 | void close_all_fds _PARAMS((int)); /* Closes all fd's */ 74 | 75 | /* from xmalloc.c */ 76 | void *xmalloc _PARAMS((size_t)); /* Wrapper for malloc(3) */ 77 | void *xrealloc _PARAMS((void *, size_t)); /* Wrapper for realloc(3) */ 78 | void xfree _PARAMS((void *)); /* Wrapper for free(3) */ 79 | 80 | /* from harvest.c */ 81 | char *harvest_bindir _PARAMS((void)); 82 | char *harvest_libdir _PARAMS((void)); 83 | char *harvest_topdir _PARAMS((void)); 84 | void harvest_add_path _PARAMS((char *)); 85 | #define harvest_add_gatherer_path() harvest_add_path("gatherer:") 86 | #define harvest_add_broker_path() harvest_add_path("broker:") 87 | #define harvest_add_cache_path() harvest_add_path("cache:") 88 | #define harvest_add_replicator_path() harvest_add_path("replicator:") 89 | 90 | #endif /* _UTIL_H_ */ 91 | -------------------------------------------------------------------------------- /libtemplate/lib/Makefile.in: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | install: 4 | 5 | clean: 6 | rm -f *.a core 7 | 8 | distclean realclean: clean 9 | rm -f Makefile 10 | -------------------------------------------------------------------------------- /libtemplate/lib/Makefile.sunos: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | install: 4 | 5 | clean: 6 | -rm -f *.a core 7 | -------------------------------------------------------------------------------- /libtemplate/template/Attributes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Attributes supported by the Gatherer 4 | 5 |

Attributes supported by the Gatherer

6 |
7 | 8 |
Abstract 9 |
Brief abstract about the object. 10 | 11 |
Author 12 |
Author(s) of the object. 13 | 14 |
Description 15 |
Brief description about the object. 16 | 17 |
File-Size 18 |
Number of bytes in the object. 19 | 20 |
Text-Text 21 |
Entire contents of the object. 22 | 23 |
Gatherer-Host 24 |
Host on which the Gatherer ran to extract information from 25 | the object. 26 | 27 |
Gatherer-Name 28 |
Name of the Gatherer that extracted information from the 29 | object. (eg. Full-Text, Selected-Text, or Terse). 30 | 31 |
Gatherer-Port 32 |
Port number on the Gatherer-Host that serves the Gatherer's 33 | information. 34 | 35 |
Gatherer-Version 36 |
Version number of the Gatherer. 37 | 38 |
Update-Time 39 |
The time that Gatherer updated the content summary for the object. 40 | 41 |
Keywords 42 |
Searchable keywords extracted from the object. 43 | 44 |
Last-Modification-Time 45 |
The time that the object was last modified. 46 | 47 |
MD5 48 |
MD5 16-byte checksum of the object. 49 | 50 |
Refresh-Rate 51 |
How often the Broker attempts to update the content summary. 52 | 53 |
Time-to-Live 54 |
The time at which the content summary is no longer valid. 55 | 56 |
Type 57 |
The object's type. Some example types are: 58 |

59 |

 60 | 	Archive
 61 | 	Audio
 62 | 	Awk
 63 | 	Backup
 64 | 	Binary
 65 | 	C
 66 | 	CHeader
 67 | 	Command
 68 | 	Compressed
 69 | 	CompressedTar
 70 | 	Configuration
 71 | 	Data
 72 | 	Directory
 73 | 	DotFile
 74 | 	Dvi
 75 | 	FAQ
 76 | 	FYI
 77 | 	Font
 78 | 	FormattedText
 79 | 	GDBM
 80 | 	GNUCompressed
 81 | 	GNUCompressedTar
 82 | 	HTML
 83 | 	Image
 84 | 	Internet-Draft
 85 | 	MacCompressed
 86 | 	Mail
 87 | 	Makefile
 88 | 	ManPage
 89 | 	Object
 90 | 	OtherCode
 91 | 	PCCompressed
 92 | 	Patch
 93 | 	Perl
 94 | 	PostScript
 95 | 	RCS
 96 | 	README
 97 | 	RFC
 98 | 	SCCS
 99 | 	ShellArchive
100 | 	Tar
101 | 	Tcl
102 | 	Tex
103 | 	Text
104 | 	Troff
105 | 	Uuencoded
106 | 	WaisSource
107 | 
108 | 109 |
Update-Time 110 |
The time that Gatherer updated (generated) the content summary 111 | from the object. 112 | 113 | 114 |
URL-References 115 |
Any URL references present within HTML objects. 116 | 117 | 118 |
119 | 120 | 121 |

122 |


123 |
124 | 125 | Darren R. Hardy, hardy@cs.colorado.edu
126 | 127 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.NeXT: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.NeXT,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = gcc 15 | INSTALL = cp #install -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = /bin/ranlib 19 | XTRA_LIBS = -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.alpha: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.alpha,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = cc 15 | INSTALL = cp #installbsd -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = ranlib 19 | XTRA_LIBS = -lresolv -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.hp: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.hp,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = cc 15 | INSTALL = cp #install -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = : 19 | XTRA_LIBS = -lresolv -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.in,v 1.2 2001/05/21 04:48:59 golda Exp $ 7 | # 8 | 9 | srcdir = @srcdir@ 10 | VPATH = @srcdir@ 11 | prefix = /usr/local/harvest 12 | INSTALL_BINDIR = $(prefix)/bin 13 | INSTALL_LIBDIR = $(prefix)/lib 14 | INSTALL_MANDIR = $(prefix)/man 15 | 16 | SHELL = /bin/sh 17 | CC = @CC@ 18 | INSTALL = @INSTALL@ 19 | INSTALL_BIN = ${INSTALL} 20 | INSTALL_FILE = ${INSTALL} 21 | RANLIB = @RANLIB@ 22 | XTRA_LIBS = -lresolv -lm 23 | LN_S = @LN_S@ 24 | 25 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 26 | DEBUG_LIBS = 27 | 28 | CFLAGS = $(DEBUG) -I../include 29 | OBJS = template.o 30 | LIBDIR = ../lib 31 | LDFLAGS = -L$(LIBDIR) 32 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 33 | LIBFILE = libtemplate.a 34 | BINS = cksoif print-template print-attr \ 35 | lsm2soif iafa2soif pcindex2soif translate-urls 36 | 37 | all: $(LIBFILE) install-lib 38 | 39 | install: all 40 | 41 | install-man: 42 | 43 | clean: 44 | rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 45 | 46 | distclean realclean: clean 47 | rm -f Makefile mktemplate 48 | 49 | install-bin: all 50 | @for f in $(BINS) mktemplate; do \ 51 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 52 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 53 | done 54 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 55 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 56 | 57 | install-lib: $(LIBDIR)/$(LIBFILE) 58 | 59 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 60 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 61 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 62 | 63 | $(LIBFILE): $(OBJS) 64 | ar r $@ $(OBJS) 65 | $(RANLIB) $@ 66 | 67 | cksoif: cksoif.o 68 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 69 | 70 | print-template: print-template.o 71 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 72 | 73 | print-attr: print-attr.o 74 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 75 | 76 | template2html: template2html.o 77 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 78 | 79 | translate-urls: translate-urls.o 80 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 81 | 82 | lsm2soif: lsm2soif.o 83 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 84 | 85 | iafa2soif: iafa2soif.o 86 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 87 | 88 | print-urlrefs: print-urlrefs.o 89 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 90 | 91 | pcindex2soif: pcindex2soif.o 92 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 93 | 94 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.linux: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.linux,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = gcc -m486 15 | INSTALL = cp #install -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = ranlib 19 | XTRA_LIBS = -lresolv -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.rs6000: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.rs6000,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = cc 15 | INSTALL = cp #install -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = true 19 | XTRA_LIBS = -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.sgi: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.sgi,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = cc 15 | INSTALL = cp #install -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = true 19 | XTRA_LIBS = -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.solaris: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.solaris,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = gcc 15 | INSTALL = cp #install -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = true 19 | XTRA_LIBS = -lresolv -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/Makefile.sunos: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the SOIF template processing code 3 | # 4 | # Darren Hardy, hardy@cs.colorado.edu, May 1994 5 | # 6 | # $Id: Makefile.sunos,v 1.1 1999/11/03 21:41:04 golda Exp $ 7 | # 8 | prefix = /usr/local/harvest 9 | INSTALL_BINDIR = $(prefix)/bin 10 | INSTALL_LIBDIR = $(prefix)/lib 11 | INSTALL_MANDIR = $(prefix)/man 12 | 13 | SHELL = /bin/sh 14 | CC = gcc 15 | INSTALL = cp #install -c 16 | INSTALL_BIN = ${INSTALL} 17 | INSTALL_FILE = ${INSTALL} #-m 644 18 | RANLIB = ranlib 19 | XTRA_LIBS = -lresolv -lm 20 | LN_S = ln -s 21 | 22 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 23 | DEBUG_LIBS = 24 | 25 | CFLAGS = $(DEBUG) -I../include 26 | OBJS = template.o 27 | LIBDIR = ../lib 28 | LDFLAGS = -L$(LIBDIR) 29 | LIBS = -ltemplate -lutil $(DEBUG_LIBS) $(XTRA_LIBS) 30 | LIBFILE = libtemplate.a 31 | BINS = cksoif print-template print-attr \ 32 | lsm2soif iafa2soif pcindex2soif translate-urls 33 | 34 | all: $(LIBFILE) install-lib #$(BINS) mktemplate 35 | 36 | $(LIBFILE): $(OBJS) 37 | ar r $@ $(OBJS) 38 | $(RANLIB) $@ 39 | 40 | clean: 41 | -rm -f core $(OBJS) $(LIBFILE) $(BINS) *.o 42 | 43 | #realclean: 44 | # -rm -f Makefile mktemplate 45 | 46 | install: install-lib 47 | @for f in $(BINS) mktemplate; do \ 48 | echo $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 49 | $(INSTALL_BIN) $$f $(INSTALL_BINDIR); \ 50 | done 51 | -rm -f $(INSTALL_BINDIR)/LSM.unnest 52 | $(LN_S) $(INSTALL_BINDIR)/lsm2soif $(INSTALL_BINDIR)/LSM.unnest 53 | 54 | install-lib: $(LIBDIR)/$(LIBFILE) 55 | 56 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 57 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 58 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 59 | 60 | cksoif: cksoif.o 61 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 62 | 63 | print-template: print-template.o 64 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 65 | 66 | print-attr: print-attr.o 67 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 68 | 69 | template2html: template2html.o 70 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 71 | 72 | translate-urls: translate-urls.o 73 | $(CC) -o $@ $@.o $(LDFLAGS) $(LIBS) 74 | 75 | lsm2soif: lsm2soif.o 76 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 77 | 78 | iafa2soif: iafa2soif.o 79 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 80 | 81 | print-urlrefs: print-urlrefs.o 82 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 83 | 84 | pcindex2soif: pcindex2soif.o 85 | $(CC) -o $@ $@.o $(LDFLAGS) -lurl $(LIBS) -lgdbm -lmd5 $(XTRA_LIBS) 86 | 87 | -------------------------------------------------------------------------------- /libtemplate/template/README: -------------------------------------------------------------------------------- 1 | This directory holds the SOIF template processing library as well as some 2 | other utilities for manipulating SOIF templates. 3 | 4 | template.c is the SOIF template library; everything else is related. 5 | 6 | -Darren Hardy, June 1994 7 | -------------------------------------------------------------------------------- /libtemplate/template/cksoif.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: cksoif.c,v 1.1 1999/11/03 21:41:04 golda Exp $"; 2 | /* 3 | * cksoif - Reads in templates from stdin and prints whether or not 4 | * it's a legal SOIF template. 5 | * 6 | * Darren Hardy, hardy@cs.colorado.edu, November 1994 7 | * 8 | * ---------------------------------------------------------------------- 9 | * Copyright (c) 1994, 1995. All rights reserved. 10 | * 11 | * Mic Bowman of Transarc Corporation. 12 | * Peter Danzig of the University of Southern California. 13 | * Darren R. Hardy of the University of Colorado at Boulder. 14 | * Udi Manber of the University of Arizona. 15 | * Michael F. Schwartz of the University of Colorado at Boulder. 16 | * 17 | */ 18 | #include 19 | #include 20 | #include 21 | #include "util.h" 22 | #include "template.h" 23 | 24 | int main(argc, argv) 25 | int argc; 26 | char *argv[]; 27 | { 28 | int n = 0, nok = 0; 29 | Template *t; 30 | 31 | init_parse_template_file(stdin); 32 | while (1) { 33 | n++; 34 | t = parse_template(); 35 | if (t == NULL && is_parse_end_of_input()) 36 | break; 37 | if (t == NULL) { 38 | printf("Attempt %d: Invalid SOIF\n", n); 39 | continue; 40 | } 41 | free_template(t); 42 | printf("Attempt %d: Valid SOIF\n", n); 43 | nok++; 44 | } 45 | finish_parse_template(); 46 | printf("Successfully parsed %d SOIF objects, in %d attempts\n", 47 | nok, n - 1); 48 | exit(0); 49 | } 50 | -------------------------------------------------------------------------------- /libtemplate/template/iafa2soif.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: iafa2soif.c,v 1.1 1999/11/03 21:41:04 golda Exp $"; 2 | /* 3 | * iafa2soif - Converts IAFA templates to SOIF. 4 | * 5 | * Usage: iafa2soif url local-file 6 | * 7 | * Darren Hardy, hardy@cs.colorado.edu, June 1994 8 | * 9 | * ---------------------------------------------------------------------- 10 | * Copyright (c) 1994, 1995. All rights reserved. 11 | * 12 | * Mic Bowman of Transarc Corporation. 13 | * Peter Danzig of the University of Southern California. 14 | * Darren R. Hardy of the University of Colorado at Boulder. 15 | * Udi Manber of the University of Arizona. 16 | * Michael F. Schwartz of the University of Colorado at Boulder. 17 | */ 18 | #include 19 | #include 20 | #include "util.h" 21 | #include "url.h" 22 | #include "template.h" 23 | 24 | static void usage() 25 | { 26 | fprintf(stderr, "Usage: iafa2soif url local-file\n"); 27 | exit(1); 28 | } 29 | 30 | #define isiafa(c) (isalnum(c) || ((c) == '-') || ((c) == '#')) 31 | 32 | static void do_iafatosoif(url, filename) 33 | char *url; 34 | char *filename; 35 | { 36 | char buf[BUFSIZ], *s, *p; 37 | char attr[BUFSIZ]; 38 | char value[BUFSIZ]; 39 | int i; 40 | Template *t; 41 | FILE *fp; 42 | URL *up; 43 | 44 | if ((up = url_open(url)) == NULL) { 45 | errorlog("Cannot open URL: %s\n", url); 46 | return; 47 | } 48 | 49 | /* Build the template */ 50 | t = create_template(NULL, up->url); 51 | 52 | /* Read the file and build a SOIF template from it */ 53 | if ((fp = fopen(filename, "r")) == NULL) { 54 | log_errno(filename); 55 | url_close(up); 56 | return; 57 | } 58 | attr[0] = '\0'; 59 | while (fgets(buf, BUFSIZ, fp)) { 60 | if ((s = strrchr(buf, '\n')) != NULL) 61 | *s = '\0'; 62 | if (strlen(buf) < 1) 63 | continue; 64 | if ((s = strchr(buf, ':')) == NULL) { 65 | append_AVList(t->list, attr, buf, strlen(buf)); 66 | continue; 67 | } 68 | for (p = buf, i = 0; p < s && isiafa(*p); p++, i++) 69 | attr[i] = *p; 70 | attr[i] = '\0'; 71 | if (i < 1) 72 | continue; /* null attribute */ 73 | while (*s != '\0' && (*s == ':' || isspace(*s))) 74 | s++; 75 | if (strlen(s) < 1) /* empty line */ 76 | continue; 77 | strcpy(value, s); 78 | if (t->list) 79 | append_AVList(t->list, attr, value, strlen(value)); 80 | else 81 | t->list = create_AVList(attr, value, strlen(value)); 82 | 83 | } 84 | fclose(fp); 85 | 86 | /* Print out the template */ 87 | (void) init_print_template(stdout); 88 | print_template(t); 89 | finish_print_template(); 90 | free_template(t); 91 | url_close(up); 92 | return; 93 | } 94 | 95 | int main(argc, argv) 96 | int argc; 97 | char *argv[]; 98 | { 99 | char *url, *filename; 100 | 101 | if (argc != 3) 102 | usage(); 103 | url = strdup(argv[1]); 104 | filename = strdup(argv[2]); 105 | 106 | init_log(stderr, stderr); 107 | init_url(); 108 | do_iafatosoif(url, filename); 109 | finish_url(); 110 | exit(0); 111 | } 112 | -------------------------------------------------------------------------------- /libtemplate/template/netfind2soif.pl: -------------------------------------------------------------------------------- 1 | : # *-*-perl-*-* 2 | eval 'exec perl -S $0 "$@"' 3 | if $running_under_some_shell; 4 | # 5 | # netfind2soif.pl - Converts the Netfind seed database into a SOIF stream. 6 | # Groups the SOIF templates by second-level domains. 7 | # 8 | # Darren Hardy, hardy@cs.colorado.edu, January 1995 9 | # 10 | # $Id: netfind2soif.pl,v 1.1 1999/11/03 21:41:04 golda Exp $ 11 | # 12 | # The netfind seed database has records that look like this: 13 | # 14 | # %D domain-name 15 | # %O organization-name 16 | # %H hostnames 17 | # 18 | # Generates SOIF that looks like this: 19 | # 20 | # @DOMAIN { nop:domain-name 21 | # Embed-Domain{x}: foo.domain-name 22 | # Embed-Organization{x}: organization-name 23 | # Embed-Hosts{x}: hosts 24 | # Embed-Domain{x}: bar.domain-name 25 | # Embed-Organization{x}: organization-name 26 | # Embed-Hosts{x}: hosts 27 | # } 28 | # or 29 | # @DOMAIN { nop:domain-name 30 | # Domain{x}: domain-name 31 | # Organization{x}: organization-name 32 | # Hosts{x}: hosts 33 | # } 34 | # 35 | $ENV{'HARVEST_HOME'} = "/usr/local/harvest" if (!defined($ENV{'HARVEST_HOME'})); 36 | unshift(@INC, "$ENV{'HARVEST_HOME'}/lib"); # use local files 37 | $ENV{'TMPDIR'} = "/tmp" if (!defined($ENV{'TMPDIR'})); 38 | 39 | require 'soif.pl'; 40 | 41 | $sld_file = "$ENV{'TMPDIR'}/nfdomains.$$"; 42 | $slo_file = "$ENV{'TMPDIR'}/nforgs.$$"; 43 | $slh_file = "$ENV{'TMPDIR'}/nfhosts.$$"; 44 | 45 | 46 | &do_reset(); 47 | while (<>) { 48 | chop; 49 | $d = $1, next if (/^%D\s*(.*)$/io); 50 | $o = $1, next if (/^%O\s*(.*)$/io); 51 | $h = $1, next if (/^%H\s*(.*)$/io); 52 | if (defined($d) && defined($o) && defined($h)) { 53 | if ($d =~ /^(\d+)\.(\d+)\.(\d+)$/o) { 54 | $sld = "$1.$2"; 55 | } elsif ($d =~ /^([+\-\w]+\.[+\-\w]+)$/o) { 56 | $sld = $1; 57 | } elsif ($d =~ /^.*\.([+\-\w]+\.[+\-\w]+)$/o) { 58 | $sld = $1; 59 | } else { 60 | next; 61 | } 62 | $sl_domain{$sld} .= "$d\n"; 63 | if ($o eq "") { 64 | $sl_org{$sld} .= "unspecified\n"; 65 | } else { 66 | $sl_org{$sld} .= "$o\n"; 67 | } 68 | if ($h eq "") { 69 | $sl_host{$sld} .= "unspecified\n"; 70 | } else { 71 | $sl_host{$sld} .= "$h\n"; 72 | } 73 | &do_reset(); 74 | } 75 | } 76 | 77 | while (($key, $value) = each %sl_domain) { 78 | @domains = split(/\n/, $sl_domain{$key}); 79 | @orgs = split(/\n/, $sl_org{$key}); 80 | @hosts = split(/\n/, $sl_host{$key}); 81 | 82 | undef %record; 83 | delete $sl_domain{$key}; 84 | delete $sl_org{$key}; 85 | delete $sl_host{$key}; 86 | 87 | if ($#domains < 0 || $#orgs < 0 || $#hosts < 0) { 88 | print STDERR "Empty Record!\n"; 89 | next; 90 | } 91 | $n = $#domains + 1; 92 | if ($n == 1) { 93 | $record{"Domain"} = $domains[0]; 94 | $record{"Organization"} = $orgs[0] 95 | if ($orgs[0] ne "unspecified"); 96 | $record{"Hosts"} = $hosts[0] 97 | if ($hosts[0] ne "unspecified"); 98 | } else { 99 | for ($i = 1; $i <= $n; $i++) { 100 | $record{"Embed<$i>-Domain"} = $domains[$i-1]; 101 | $record{"Embed<$i>-Organization"} = $orgs[$i-1] 102 | if ($orgs[$i-1] ne "unspecified"); 103 | $record{"Embed<$i>-Hosts"} = $hosts[$i-1] 104 | if ($hosts[$i-1] ne "unspecified"); 105 | } 106 | } 107 | &soif'print("DOMAIN", "nop:$key", %record); 108 | } 109 | 110 | 111 | exit(0); 112 | 113 | sub do_reset { 114 | undef $d; 115 | undef $o; 116 | undef $h; 117 | undef $sld; 118 | } 119 | -------------------------------------------------------------------------------- /libtemplate/template/print-attr.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: print-attr.c,v 1.1 1999/11/03 21:41:04 golda Exp $"; 2 | /* 3 | * print-attr - Reads in a template from stdin and prints the data 4 | * associated with the given attributed to stdout. 5 | * 6 | * Darren Hardy, hardy@cs.colorado.edu, April 1994 7 | * 8 | * ---------------------------------------------------------------------- 9 | * Copyright (c) 1994, 1995. All rights reserved. 10 | * 11 | * Mic Bowman of Transarc Corporation. 12 | * Peter Danzig of the University of Southern California. 13 | * Darren R. Hardy of the University of Colorado at Boulder. 14 | * Udi Manber of the University of Arizona. 15 | * Michael F. Schwartz of the University of Colorado at Boulder. 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include "util.h" 21 | #include "template.h" 22 | 23 | static void usage() 24 | { 25 | fprintf(stderr, "Usage: print-attr Attribute\n"); 26 | exit(1); 27 | } 28 | 29 | int main(argc, argv) 30 | int argc; 31 | char *argv[]; 32 | { 33 | Template *template; 34 | AVPair *avp; 35 | char *attr; 36 | 37 | if (argc != 2) 38 | usage(); 39 | 40 | attr = strdup(argv[1]); 41 | 42 | init_parse_template_file(stdin); 43 | while ((template = parse_template()) != NULL) { 44 | avp = extract_AVPair(template->list, attr); 45 | if (avp) { 46 | fwrite(avp->value, 1, avp->vsize, stdout); 47 | putchar('\n'); 48 | } 49 | free_template(template); 50 | } 51 | finish_parse_template(); 52 | exit(0); 53 | } 54 | -------------------------------------------------------------------------------- /libtemplate/template/print-template.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: print-template.c,v 1.1 1999/11/03 21:41:04 golda Exp $"; 2 | /* 3 | * print-template - Reads in a template from stdin and prints it to stdout. 4 | * Used to test template parsing and printing. 5 | * 6 | * Darren Hardy, hardy@cs.colorado.edu, February 1994 7 | * 8 | * ---------------------------------------------------------------------- 9 | * Copyright (c) 1994, 1995. All rights reserved. 10 | * 11 | * Mic Bowman of Transarc Corporation. 12 | * Peter Danzig of the University of Southern California. 13 | * Darren R. Hardy of the University of Colorado at Boulder. 14 | * Udi Manber of the University of Arizona. 15 | * Michael F. Schwartz of the University of Colorado at Boulder. 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include "util.h" 21 | #include "template.h" 22 | 23 | static void add_print_time(t) 24 | Template *t; 25 | { 26 | char buf[BUFSIZ]; 27 | 28 | sprintf(buf, "%u", (unsigned int) time(NULL)); 29 | add_AVList(t->list, "Print-Time", buf, strlen(buf)); 30 | } 31 | 32 | int main(argc, argv) 33 | int argc; 34 | char *argv[]; 35 | { 36 | Template *template; 37 | Buffer *b; 38 | 39 | init_parse_template_file(stdin); /* Read Template from stdin */ 40 | while ((template = parse_template()) != NULL) { 41 | add_print_time(template); /* Add new Attribute-Value */ 42 | b = init_print_template(NULL); /* Print Template to Buffer */ 43 | print_template(template); 44 | fwrite(b->data, 1, b->length, stdout); /* Buffer to stdout */ 45 | finish_print_template(); /* Clean up */ 46 | free_template(template); 47 | } 48 | finish_parse_template(); 49 | exit(0); 50 | } 51 | -------------------------------------------------------------------------------- /libtemplate/template/print-urlrefs.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: print-urlrefs.c,v 1.1 1999/11/03 21:41:04 golda Exp $"; 2 | /* 3 | * print-urlrefs - Reads SOIF and prints normalized URLs from the 4 | * URL-References attribute. Used to extract URLs from HTML object sums. 5 | * 6 | * Usage: print-urlrefs 7 | * 8 | * Darren Hardy, hardy@cs.colorado.edu, July 1994 9 | * 10 | * ---------------------------------------------------------------------- 11 | * Copyright (c) 1994, 1995. All rights reserved. 12 | * 13 | * Mic Bowman of Transarc Corporation. 14 | * Peter Danzig of the University of Southern California. 15 | * Darren R. Hardy of the University of Colorado at Boulder. 16 | * Udi Manber of the University of Arizona. 17 | * Michael F. Schwartz of the University of Colorado at Boulder. 18 | * 19 | */ 20 | #include 21 | #include 22 | #include 23 | #include "util.h" 24 | #include "url.h" 25 | #include "template.h" 26 | 27 | static void print_urlrefs(t) 28 | Template *t; 29 | { 30 | AVPair *avp; 31 | char *s, url[BUFSIZ]; 32 | URL *up; 33 | 34 | if ((avp = extract_AVPair(t->list, "URL-References")) == NULL) 35 | return; 36 | 37 | /* For each line in the data, grab the URL */ 38 | for (s = strtok(avp->value, "\n"); s != NULL; s = strtok(NULL, "\n")) { 39 | url[0] = '\0'; 40 | 41 | /* Remove poorly formated lines */ 42 | if (strchr(s, '=') || strchr(s, ' ') || strchr(s, '<')) 43 | continue; 44 | if (strncmp(s, "mailto:", 6) == 0) 45 | continue; 46 | if (strncmp(s, "http:", 5) == 0 && !strstr(s, "://")) 47 | continue; 48 | 49 | if (strstr(s, "://") != NULL) { 50 | /* Is this URL ok as-is? If so, save it */ 51 | strcpy(url, s); 52 | } else if (s[0] == '/') { 53 | /* This URL is relative to the top of t->url */ 54 | char *thishost = t->url + strlen("http://"), *z; 55 | 56 | z = strchr(thishost, '/'); 57 | if (z != NULL) *z = '\0'; 58 | sprintf(url, "http:/%s%s", thishost, s); 59 | if (z != NULL) *z = '/'; 60 | } else { 61 | /* This URL is relative to t->url */ 62 | char *z = strdup(t->url), *p; 63 | 64 | if ((p = strrchr(z, '/')) != NULL) *p = '\0'; 65 | sprintf(url, "%s/%s", z, s); 66 | xfree(z); 67 | } 68 | /* If the URL is set, then parse it and print if ok */ 69 | if (url[0]) { 70 | if ((up = url_open(url)) != NULL) { 71 | printf("%s\n", up->url); 72 | url_close(up); 73 | } 74 | } 75 | } 76 | } 77 | 78 | 79 | int main(argc, argv) 80 | int argc; 81 | char *argv[]; 82 | { 83 | Template *template; 84 | Buffer *b; 85 | 86 | init_parse_template_file(stdin); 87 | while ((template = parse_template()) != NULL) { 88 | print_urlrefs(template); 89 | printf("%s\n", template->url); 90 | free_template(template); 91 | } 92 | finish_parse_template(); 93 | exit(0); 94 | } 95 | -------------------------------------------------------------------------------- /libtemplate/template/soif.pl: -------------------------------------------------------------------------------- 1 | #-*-perl-*- 2 | # 3 | # soif.pl - Processing for the SOIF format. 4 | # 5 | # Darren Hardy, hardy@cs.colorado.edu, January 1995 6 | # 7 | # $Id: soif.pl,v 1.1 1999/11/03 21:41:04 golda Exp $ 8 | # 9 | ####################################################################### 10 | # Usage: 11 | # 12 | # require 'soif.pl'; 13 | # 14 | # $soif'input = 'WHATEVER'; # defaults to STDIN 15 | # ($ttype, $url, %SOIF) = &soif'parse(); 16 | # foreach $k (sort keys %SOIF) { 17 | # print "KEY: $k\n"; 18 | # print "DATA: $SOIF{$k}\n"; 19 | # } 20 | # exit(0); 21 | # 22 | ####################################################################### 23 | # Copyright (c) 1994, 1995. All rights reserved. 24 | # 25 | # Mic Bowman of Transarc Corporation. 26 | # Peter Danzig of the University of Southern California. 27 | # Darren R. Hardy of the University of Colorado at Boulder. 28 | # Udi Manber of the University of Arizona. 29 | # Michael F. Schwartz of the University of Colorado at Boulder. 30 | # 31 | package soif; 32 | 33 | $soif'debug = 0; 34 | $soif'input = 'STDIN'; 35 | $soif'output = 'STDOUT'; 36 | $soif'sort_on_output = 1; 37 | 38 | # 39 | # soif'parse - $soif'input is the file descriptor from which to read SOIF. 40 | # Returns an associative array containing the SOIF, 41 | # the template type, and the URL. 42 | # 43 | sub soif'parse { 44 | print "Inside soif'parse.\n" if ($soif'debug); 45 | 46 | return () if (eof($soif'input)); # DW 47 | local($template_type) = "UNKNOWN"; 48 | local($url) = "UNKNOWN"; 49 | local(%SOIF); 50 | undef %SOIF; 51 | 52 | while (<$soif'input>) { 53 | print "READING input line: $_\n" if ($soif'debug); 54 | last if (/^\@\S+\s*{\s*\S+\s*$/o); 55 | } 56 | if (/^\@(\S+)\s*{\s*(\S+)\s*$/o) { 57 | $template_type = $1, $url = $2 58 | } else { 59 | return ($template_type, $url, %SOIF); # done 60 | } 61 | 62 | while (<$soif'input>) { 63 | if (/^\s*([^{]+){(\d+)}:\t(.*\n)/o) { 64 | $attr = $1; 65 | $vsize = $2; 66 | $value = $3; 67 | if (length($value) < $vsize) { 68 | $nleft = $vsize - length($value); 69 | $end_value = ""; 70 | $x = read($soif'input, $end_value, $nleft); 71 | die "Cannot read $nleft bytes: $!" 72 | if ($x != $nleft); 73 | $value .= $end_value; 74 | undef $end_value; 75 | } 76 | chop($SOIF{$attr} = $value); 77 | next; 78 | } 79 | last if (/^}/o); 80 | } 81 | 82 | return ($template_type, $url, %SOIF); 83 | } 84 | 85 | # 86 | # soif'print - $soif'output is the file descriptor to write SOIF. 87 | # 88 | sub soif'print { 89 | print "Inside soif'print.\n" if ($soif'debug); 90 | local($template_type, $url, %SOIF) = @_; 91 | 92 | # Write SOIF header, body, and trailer 93 | print $soif'output "\@$template_type { $url\n"; 94 | if ($soif'sort_on_output) { 95 | foreach $k (sort keys %SOIF) { 96 | next if (length($SOIF{$k}) < 1); 97 | &soif'print_item($k, $SOIF{$k}); 98 | } 99 | } else { 100 | foreach $k (keys %SOIF) { 101 | next if (length($SOIF{$k}) < 1); 102 | &soif'print_item($k, $SOIF{$k}); 103 | } 104 | } 105 | print $soif'output "}\n"; 106 | } 107 | 108 | sub soif'print_item { 109 | local($k, $v) = @_; 110 | print $soif'output "$k" , "{", length($v), "}:\t"; 111 | print $soif'output $v, "\n"; 112 | } 113 | 1; 114 | -------------------------------------------------------------------------------- /libtemplate/template/translate-urls.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: translate-urls.c,v 1.1 1999/11/03 21:41:04 golda Exp $"; 2 | /* 3 | * translate-urls - Reads SOIF and prints the new SOIF's with the 4 | * translated URLs from the 5 | * 6 | * Usage: translate-urls [(-access | -host | -path) old new] 7 | * 8 | * Darren Hardy, hardy@cs.colorado.edu, July 1994 9 | * 10 | * ---------------------------------------------------------------------- 11 | * Copyright (c) 1994, 1995. All rights reserved. 12 | * 13 | * Mic Bowman of Transarc Corporation. 14 | * Peter Danzig of the University of Southern California. 15 | * Darren R. Hardy of the University of Colorado at Boulder. 16 | * Udi Manber of the University of Arizona. 17 | * Michael F. Schwartz of the University of Colorado at Boulder. 18 | */ 19 | #include 20 | #include 21 | #include 22 | #include "util.h" 23 | #include "url.h" 24 | #include "template.h" 25 | 26 | static void translate_url(t) 27 | Template *t; 28 | { 29 | } 30 | 31 | int main(argc, argv) 32 | int argc; 33 | char *argv[]; 34 | { 35 | Template *template; 36 | Buffer *b; 37 | 38 | init_parse_template_file(stdin); /* Read Template from stdin */ 39 | while (1) { 40 | template = parse_template(); 41 | if (template == NULL && is_parse_end_of_input()) 42 | break; 43 | if (template == NULL) 44 | continue; 45 | 46 | translate_url(template); 47 | 48 | b = init_print_template(NULL); 49 | print_template(template); 50 | fwrite(b->data, 1, b->length, stdout); 51 | finish_print_template(); 52 | free_template(template); 53 | } 54 | finish_parse_template(); 55 | exit(0); 56 | } 57 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.NeXT: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.NeXT,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = gcc 13 | INSTALL = cp #install -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = /bin/ranlib 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | # Delete strerror.o, because it conflicts with definition in 25 | # /lib/libsys_s.a on NeXT systems 26 | OBJS = buffer.o host.o log.o strdup.o system.o \ 27 | string.o xmalloc.o 28 | 29 | all: $(LIBFILE) install-lib 30 | 31 | ctags: 32 | @ctags -w *.c 33 | 34 | clean: 35 | -rm -f core *.o $(LIBFILE) tags 36 | 37 | #realclean: clean 38 | # -rm -rf Makefile 39 | 40 | install: install-lib 41 | 42 | install-lib: $(LIBDIR)/$(LIBFILE) 43 | 44 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 45 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 46 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 47 | 48 | $(LIBFILE): $(OBJS) 49 | ar r $(LIBFILE) $(OBJS) 50 | $(RANLIB) $(LIBFILE) 51 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.alpha: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.alpha,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = cc 13 | INSTALL = cp #installbsd -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = ranlib 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 25 | string.o xmalloc.o 26 | 27 | all: $(LIBFILE) install-lib 28 | 29 | ctags: 30 | @ctags -w *.c 31 | 32 | clean: 33 | -rm -f core *.o $(LIBFILE) tags 34 | 35 | #realclean: clean 36 | # -rm -rf Makefile 37 | 38 | install: install-lib 39 | 40 | install-lib: $(LIBDIR)/$(LIBFILE) 41 | 42 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 43 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 44 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 45 | 46 | $(LIBFILE): $(OBJS) 47 | ar r $(LIBFILE) $(OBJS) 48 | $(RANLIB) $(LIBFILE) 49 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.hp: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.hp,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = cc 13 | INSTALL = cp #install -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = : 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 25 | string.o xmalloc.o 26 | 27 | all: $(LIBFILE) install-lib 28 | 29 | ctags: 30 | @ctags -w *.c 31 | 32 | clean: 33 | -rm -f core *.o $(LIBFILE) tags 34 | 35 | #realclean: clean 36 | # -rm -rf Makefile 37 | 38 | install: install-lib 39 | 40 | install-lib: $(LIBDIR)/$(LIBFILE) 41 | 42 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 43 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 44 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 45 | 46 | $(LIBFILE): $(OBJS) 47 | ar r $(LIBFILE) $(OBJS) 48 | $(RANLIB) $(LIBFILE) 49 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.in,v 1.2 2001/05/21 04:49:00 golda Exp $ 5 | # 6 | 7 | srcdir = @srcdir@ 8 | VPATH = @srcdir@ 9 | prefix = @prefix@ 10 | INSTALL_BINDIR = $(prefix)/bin 11 | INSTALL_LIBDIR = $(prefix)/lib 12 | INSTALL_MANDIR = $(prefix)/man 13 | 14 | SHELL = /bin/sh 15 | CC = @CC@ 16 | INSTALL = @INSTALL@ 17 | INSTALL_BIN = @INSTALL_PROGRAM@ 18 | INSTALL_FILE = @INSTALL_DATA@ 19 | RANLIB = @RANLIB@ 20 | DEFS = 21 | 22 | DEBUG = 23 | INCLUDE = -I../include 24 | CFLAGS = $(DEFS) $(INCLUDE) 25 | 26 | LIBFILE = libutil.a 27 | LIBDIR = ../lib 28 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 29 | string.o xmalloc.o 30 | 31 | all: $(LIBFILE) install-lib 32 | 33 | install: all 34 | 35 | install-man: 36 | 37 | ctags: 38 | @ctags -w *.c 39 | 40 | clean: 41 | rm -f core *.o $(LIBFILE) tags 42 | 43 | distclean realclean: clean 44 | rm -f Makefile 45 | 46 | install-lib: $(LIBDIR)/$(LIBFILE) 47 | 48 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 49 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 50 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 51 | 52 | $(LIBFILE): $(OBJS) 53 | ar r $(LIBFILE) $(OBJS) 54 | $(RANLIB) $(LIBFILE) 55 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.linux: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.linux,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = gcc -m486 13 | INSTALL = cp #install -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = ranlib 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 25 | string.o xmalloc.o 26 | 27 | all: $(LIBFILE) install-lib 28 | 29 | ctags: 30 | @ctags -w *.c 31 | 32 | clean: 33 | -rm -f core *.o $(LIBFILE) tags 34 | 35 | #realclean: clean 36 | # -rm -rf Makefile 37 | 38 | install: install-lib 39 | 40 | install-lib: $(LIBDIR)/$(LIBFILE) 41 | 42 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 43 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 44 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 45 | 46 | $(LIBFILE): $(OBJS) 47 | ar r $(LIBFILE) $(OBJS) 48 | $(RANLIB) $(LIBFILE) 49 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.rs6000: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.rs6000,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = cc 13 | INSTALL = cp #install -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = true 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 25 | string.o xmalloc.o 26 | 27 | all: $(LIBFILE) install-lib 28 | 29 | ctags: 30 | @ctags -w *.c 31 | 32 | clean: 33 | -rm -f core *.o $(LIBFILE) tags 34 | 35 | #realclean: clean 36 | # -rm -rf Makefile 37 | 38 | install: install-lib 39 | 40 | install-lib: $(LIBDIR)/$(LIBFILE) 41 | 42 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 43 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 44 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 45 | 46 | $(LIBFILE): $(OBJS) 47 | ar r $(LIBFILE) $(OBJS) 48 | $(RANLIB) $(LIBFILE) 49 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.sgi: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.sgi,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = cc 13 | INSTALL = cp #install -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = true 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 25 | string.o xmalloc.o 26 | 27 | all: $(LIBFILE) install-lib 28 | 29 | ctags: 30 | @ctags -w *.c 31 | 32 | clean: 33 | -rm -f core *.o $(LIBFILE) tags 34 | 35 | #realclean: clean 36 | # -rm -rf Makefile 37 | 38 | install: install-lib 39 | 40 | install-lib: $(LIBDIR)/$(LIBFILE) 41 | 42 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 43 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 44 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 45 | 46 | $(LIBFILE): $(OBJS) 47 | ar r $(LIBFILE) $(OBJS) 48 | $(RANLIB) $(LIBFILE) 49 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.solaris: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.solaris,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = gcc 13 | INSTALL = cp #install -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = true 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 25 | string.o xmalloc.o 26 | 27 | all: $(LIBFILE) install-lib 28 | 29 | ctags: 30 | @ctags -w *.c 31 | 32 | clean: 33 | -rm -f core *.o $(LIBFILE) tags 34 | 35 | #realclean: clean 36 | # -rm -rf Makefile 37 | 38 | install: install-lib 39 | 40 | install-lib: $(LIBDIR)/$(LIBFILE) 41 | 42 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 43 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 44 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 45 | 46 | $(LIBFILE): $(OBJS) 47 | ar r $(LIBFILE) $(OBJS) 48 | $(RANLIB) $(LIBFILE) 49 | -------------------------------------------------------------------------------- /libtemplate/util/Makefile.sunos: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the utilities source directory 3 | # 4 | # $Id: Makefile.sunos,v 1.1 1999/11/03 20:42:14 golda Exp $ 5 | # 6 | prefix = /usr/local/harvest 7 | INSTALL_BINDIR = $(prefix)/bin 8 | INSTALL_LIBDIR = $(prefix)/lib 9 | INSTALL_MANDIR = $(prefix)/man 10 | 11 | SHELL = /bin/sh 12 | CC = gcc 13 | INSTALL = cp #install -c 14 | INSTALL_BIN = ${INSTALL} 15 | INSTALL_FILE = ${INSTALL} #-m 644 16 | RANLIB = ranlib 17 | 18 | DEBUG = $(DEBUG_TOP) #-O #-g #-DDEBUG 19 | INCLUDE = -I../include 20 | CFLAGS = $(DEBUG) $(INCLUDE) 21 | 22 | LIBFILE = libutil.a 23 | LIBDIR = ../lib 24 | OBJS = buffer.o host.o log.o strdup.o system.o strerror.o \ 25 | string.o xmalloc.o 26 | 27 | all: $(LIBFILE) install-lib 28 | 29 | ctags: 30 | @ctags -w *.c 31 | 32 | clean: 33 | -rm -f core *.o $(LIBFILE) tags 34 | 35 | #realclean: clean 36 | # -rm -rf Makefile 37 | 38 | install: install-lib 39 | 40 | install-lib: $(LIBDIR)/$(LIBFILE) 41 | 42 | $(LIBDIR)/$(LIBFILE): $(LIBFILE) 43 | $(INSTALL_FILE) $(LIBFILE) $(LIBDIR)/$(LIBFILE) 44 | $(RANLIB) $(LIBDIR)/$(LIBFILE) 45 | 46 | $(LIBFILE): $(OBJS) 47 | ar r $(LIBFILE) $(OBJS) 48 | $(RANLIB) $(LIBFILE) 49 | -------------------------------------------------------------------------------- /libtemplate/util/README: -------------------------------------------------------------------------------- 1 | This directory has some generally useful functions. 2 | 3 | buffer.c Buffer management 4 | host.c DNS and host-specific routines 5 | log.c Simple, uniform logging 6 | strdup.c strdup(3) implementation 7 | strerror.c strerror(3) implementation 8 | string.c string processing 9 | system.c routines for running system(3) 10 | xmalloc.c wrappers for memory management 11 | 12 | -Darren Hardy, July 1994 13 | -------------------------------------------------------------------------------- /libtemplate/util/buffer.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: buffer.c,v 1.2 2003/11/13 05:17:39 golda Exp $"; 2 | /* 3 | * buffer.c - Simple dynamic buffer management. 4 | * 5 | * Darren Hardy, hardy@cs.colorado.edu, February 1994 6 | * 7 | * ---------------------------------------------------------------------- 8 | * Copyright (c) 1994, 1995. All rights reserved. 9 | * 10 | * Mic Bowman of Transarc Corporation. 11 | * Peter Danzig of the University of Southern California. 12 | * Darren R. Hardy of the University of Colorado at Boulder. 13 | * Udi Manber of the University of Arizona. 14 | * Michael F. Schwartz of the University of Colorado at Boulder. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include "util.h" 20 | 21 | /* 22 | * create_buffer() - Creates a buffer of default_size bytes allocated. 23 | */ 24 | Buffer *create_buffer(default_size) 25 | int default_size; 26 | { 27 | static Buffer *b = NULL; 28 | 29 | b = xmalloc(sizeof(Buffer)); 30 | b->size = b->default_size = default_size; 31 | b->data = xmalloc(b->size); 32 | b->length = 0; 33 | #ifdef DEBUG 34 | glimpselog("Creating buffer of %d bytes\n", b->size); 35 | #endif 36 | return (b); 37 | } 38 | 39 | /* 40 | * increase_buffer() - Increase the buffer so that it holds sz more bytes. 41 | */ 42 | void increase_buffer(b, sz) 43 | Buffer *b; 44 | int sz; 45 | { 46 | b->size += sz; 47 | b->data = xrealloc(b->data, b->size); 48 | #ifdef DEBUG 49 | glimpselog("Growing buffer by %d bytes to %d bytes\n", sz, b->size); 50 | #endif 51 | } 52 | 53 | /* 54 | * grow_buffer() - increases the buffer size by the default size 55 | */ 56 | void grow_buffer(b) 57 | Buffer *b; 58 | { 59 | increase_buffer(b, b->default_size); 60 | } 61 | 62 | /* 63 | * shrink_buffer() - restores a buffer back to its original size. 64 | * all data is lost. 65 | */ 66 | void shrink_buffer(b) 67 | Buffer *b; 68 | { 69 | b->length = 0; 70 | if (b->size == b->default_size) /* nothing to do */ 71 | return; 72 | 73 | if (b->data) 74 | xfree(b->data); 75 | b->size = b->default_size; 76 | b->data = xmalloc(b->size); 77 | #ifdef DEBUG 78 | glimpselog("Shrinking buffer to %d bytes\n", b->size); 79 | #endif 80 | } 81 | 82 | /* 83 | * free_buffer() - Cleans up after a buffer. 84 | */ 85 | void free_buffer(b) 86 | Buffer *b; 87 | { 88 | if (b == NULL) 89 | return; 90 | #ifdef DEBUG 91 | glimpselog("Freeing buffer of %d bytes\n", b->size); 92 | #endif 93 | if (b->data) 94 | xfree(b->data); 95 | xfree(b); 96 | } 97 | 98 | 99 | /* 100 | * add_buffer() - Adds the sz bytes of s to the Buffer b. 101 | */ 102 | void add_buffer(b, s, sz) 103 | Buffer *b; 104 | char *s; 105 | int sz; 106 | { 107 | if (sz < 1) 108 | return; 109 | if (b->length + sz + 1 > b->size) 110 | increase_buffer(b, sz); 111 | if (sz > 1) 112 | memcpy(&b->data[b->length], s, sz); 113 | else 114 | b->data[b->length] = *s; 115 | b->length += sz; 116 | b->data[b->length] = '\0'; /* add NULL to current position */ 117 | } 118 | -------------------------------------------------------------------------------- /libtemplate/util/harvest.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: harvest.c,v 1.2 2003/11/13 05:17:39 golda Exp $"; 2 | /* 3 | * harvest.c - Routines specific to the Harvest installation 4 | * 5 | * Darren Hardy, hardy@cs.colorado.edu, December 1994 6 | * 7 | * ---------------------------------------------------------------------- 8 | * Copyright (c) 1994, 1995. All rights reserved. 9 | * 10 | * Mic Bowman of Transarc Corporation. 11 | * Peter Danzig of the University of Southern California. 12 | * Darren R. Hardy of the University of Colorado at Boulder. 13 | * Udi Manber of the University of Arizona. 14 | * Michael F. Schwartz of the University of Colorado at Boulder. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "util.h" 22 | 23 | #define DEFAULT_HARVEST_HOME "/usr/local/harvest" 24 | 25 | /* 26 | * harvest_bindir() - Returns a static buffer that contains the 27 | * pathname that contains the binaries for Harvest. 28 | */ 29 | char *harvest_bindir() 30 | { 31 | static char bindir[MAXPATHLEN + 1]; 32 | char *s; 33 | 34 | if ((s = getenv("HARVEST_HOME")) != NULL) 35 | sprintf(bindir, "%s/bin", s); 36 | else 37 | sprintf(bindir, "%s/bin", DEFAULT_HARVEST_HOME); 38 | return (bindir); 39 | } 40 | 41 | /* 42 | * harvest_libdir() - Returns a static buffer that contains the 43 | * pathname that contains the libraries for Harvest. 44 | */ 45 | char *harvest_libdir() 46 | { 47 | static char libdir[MAXPATHLEN + 1]; 48 | char *s; 49 | 50 | if ((s = getenv("HARVEST_HOME")) != NULL) 51 | sprintf(libdir, "%s/lib", s); 52 | else 53 | sprintf(libdir, "%s/lib", DEFAULT_HARVEST_HOME); 54 | return (libdir); 55 | } 56 | 57 | /* 58 | * harvest_topdir() - Returns a static buffer that contains the 59 | * pathname that contains the libraries for Harvest. 60 | */ 61 | char *harvest_topdir() 62 | { 63 | static char topdir[MAXPATHLEN + 1]; 64 | char *s; 65 | 66 | if ((s = getenv("HARVEST_HOME")) != NULL) 67 | sprintf(topdir, "%s", s); 68 | else 69 | sprintf(topdir, "%s", DEFAULT_HARVEST_HOME); 70 | return (topdir); 71 | } 72 | 73 | /* 74 | * add_harvest_to_path() - If xtra is not-NULL, then it will 75 | * add harvest_libdir() + xtra to the path as well. For example, 76 | * a Gatherer process would call: 77 | * add_harvest_to_path("gatherer:") 78 | * to add $harvest_libdir/ and $harvest_libdir/gatherer 79 | */ 80 | void harvest_add_path(xtra) 81 | char *xtra; 82 | { 83 | char *s = getenv("PATH"), *newpath, *oldpath, *q; 84 | char *tmpxtra; 85 | 86 | if (s == NULL) 87 | fatal("This process does not have a PATH environment variable"); 88 | newpath = xmalloc(strlen(s) + BUFSIZ); 89 | sprintf(newpath, "PATH=%s", s); 90 | sprintf(newpath + strlen(newpath), ":%s", harvest_bindir()); 91 | if (xtra != NULL) { 92 | tmpxtra = strdup(xtra); 93 | q = strtok(tmpxtra, ":"); 94 | while (q != NULL) { 95 | sprintf(newpath + strlen(newpath), ":%s/%s", 96 | harvest_libdir(), q); 97 | q = strtok(NULL, ":"); 98 | } 99 | xfree(tmpxtra); 100 | } 101 | #ifdef DEBUG 102 | glimpselog("Adding new PATH to environment: %s\n", newpath); 103 | #endif 104 | (void) putenv(newpath); 105 | } 106 | -------------------------------------------------------------------------------- /libtemplate/util/host.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: host.c,v 1.2 2006/03/25 02:13:55 root Exp $"; 2 | /* 3 | * host.c - Retrieves full DNS name of the current host 4 | * 5 | * Darren Hardy, hardy@cs.colorado.edu, April 1994 6 | * 7 | * ---------------------------------------------------------------------- 8 | * Copyright (c) 1994, 1995. All rights reserved. 9 | * 10 | * Mic Bowman of Transarc Corporation. 11 | * Peter Danzig of the University of Southern California. 12 | * Darren R. Hardy of the University of Colorado at Boulder. 13 | * Udi Manber of the University of Arizona. 14 | * Michael F. Schwartz of the University of Colorado at Boulder. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "util.h" 30 | 31 | #ifndef MAXHOSTNAMELEN 32 | #define MAXHOSTNAMELEN 256 33 | #endif 34 | 35 | /* 36 | * getfullhostname() - Returns the fully qualified name of the current 37 | * host, or NULL on error. Pointer is only valid until the next call 38 | * to the gethost*() functions. 39 | */ 40 | char *getfullhostname() 41 | { 42 | struct hostent *hp; 43 | char buf[MAXHOSTNAMELEN + 1]; 44 | extern int gethostname(); /* UNIX system call */ 45 | 46 | if (gethostname(buf, MAXHOSTNAMELEN) < 0) 47 | return (NULL); 48 | if ((hp = gethostbyname(buf)) == NULL) 49 | return (NULL); 50 | return (hp->h_name); 51 | } 52 | 53 | /* 54 | * getmylogin() - Returns the login for the pid of the current process, 55 | * or "nobody" if there is not login associated with the pid of the 56 | * current process. Intended to be a replacement for braindead getlogin(3). 57 | */ 58 | char *getmylogin() 59 | { 60 | static char *nobody_str = "nobody"; 61 | uid_t myuid = getuid(); 62 | struct passwd *pwp; 63 | 64 | pwp = getpwuid(myuid); 65 | if (pwp == NULL || pwp->pw_name == NULL) 66 | return (nobody_str); 67 | return (pwp->pw_name); 68 | } 69 | 70 | /* 71 | * getrealhost() - Returns the real fully qualified name of the given 72 | * host or IP number, or NULL on error. 73 | */ 74 | char *getrealhost(s) 75 | char *s; 76 | { 77 | char *q; 78 | struct hostent *hp; 79 | int is_octet = 1, ndots = 0; 80 | unsigned int addr = 0; 81 | 82 | if (s == NULL || *s == '\0') 83 | return (NULL); 84 | 85 | for (q = s; *q; q++) { 86 | if (*q == '.') { 87 | ndots++; 88 | continue; 89 | } else if (!isdigit(*q)) { /* [^0-9] is a name */ 90 | is_octet = 0; 91 | break; 92 | } 93 | } 94 | 95 | if (ndots != 3) 96 | is_octet = 0; 97 | 98 | if (is_octet) { 99 | addr = inet_addr(s); 100 | hp = gethostbyaddr((char *) &addr, sizeof(unsigned int), AF_INET); 101 | } else { 102 | hp = gethostbyname(s); 103 | } 104 | return ((char *)(hp != NULL ? strdup(hp->h_name) : NULL)); 105 | } 106 | -------------------------------------------------------------------------------- /libtemplate/util/strdup.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: strdup.c,v 1.2 1999/11/19 08:11:49 golda Exp $"; 2 | /* 3 | * strdup.c - string duplication 4 | * 5 | * Darren Hardy, hardy@cs.colorado.edu, February 1994 6 | * 7 | * ---------------------------------------------------------------------- 8 | * Copyright (c) 1994, 1995. All rights reserved. 9 | * 10 | * Mic Bowman of Transarc Corporation. 11 | * Peter Danzig of the University of Southern California. 12 | * Darren R. Hardy of the University of Colorado at Boulder. 13 | * Udi Manber of the University of Arizona. 14 | * Michael F. Schwartz of the University of Colorado at Boulder. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include "util.h" 20 | 21 | #ifdef NO_STRDUP 22 | /* 23 | * strdup() - same as strdup(3) 24 | */ 25 | char *strdup(s) 26 | const char *s; 27 | { 28 | static char *p = NULL; 29 | int sz; 30 | 31 | if (s == NULL) 32 | return (NULL); 33 | 34 | sz = strlen(s); 35 | p = xmalloc((size_t) sz + 1); /* allocate memory for string */ 36 | memcpy(p, s, sz); /* copy string */ 37 | p[sz] = '\0'; /* terminate string */ 38 | return (p); 39 | } 40 | #endif 41 | -------------------------------------------------------------------------------- /libtemplate/util/strerror.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: strerror.c,v 1.2 1999/11/19 08:11:49 golda Exp $"; 2 | /* 3 | * strerror.c - print message associated with errno 4 | * 5 | * Darren Hardy, hardy@cs.colorado.edu, April 1994 6 | * 7 | * ---------------------------------------------------------------------- 8 | * Copyright (c) 1994, 1995. All rights reserved. 9 | * 10 | * Mic Bowman of Transarc Corporation. 11 | * Peter Danzig of the University of Southern California. 12 | * Darren R. Hardy of the University of Colorado at Boulder. 13 | * Udi Manber of the University of Arizona. 14 | * Michael F. Schwartz of the University of Colorado at Boulder. 15 | * 16 | */ 17 | #include 18 | #include "util.h" 19 | 20 | #ifdef NO_STRERROR 21 | /* 22 | * strerror() - same as strerror(3) 23 | */ 24 | char *strerror(n) 25 | int n; 26 | { 27 | if (n < 0 || n >= sys_nerr) 28 | return (NULL); 29 | return (sys_errlist[n]); 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /libtemplate/util/string.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: string.c,v 1.1 1999/11/03 20:42:14 golda Exp $"; 2 | /* 3 | * string.c - Simple string manipulation 4 | * 5 | * Darren Hardy, hardy@cs.colorado.edu, June 1994 6 | * 7 | * ---------------------------------------------------------------------- 8 | * Copyright (c) 1994, 1995. All rights reserved. 9 | * 10 | * Mic Bowman of Transarc Corporation. 11 | * Peter Danzig of the University of Southern California. 12 | * Darren R. Hardy of the University of Colorado at Boulder. 13 | * Udi Manber of the University of Arizona. 14 | * Michael F. Schwartz of the University of Colorado at Boulder. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include "util.h" 21 | 22 | #ifndef isquote 23 | #define isquote(c) (((c) == '\"') || ((c) == '\'')) 24 | #endif 25 | 26 | /* 27 | * parse_argv() - Parses the command string to build an argv list. 28 | * Supports simple quoting. argv is large enough to support the 29 | * command string. 30 | */ 31 | void parse_argv(argv, cmd) 32 | char *argv[]; 33 | char *cmd; 34 | { 35 | char *tmp, *p, *q; 36 | int i = 0; 37 | 38 | p = q = tmp = strdup(cmd); 39 | while (1) { 40 | if (isquote(*q)) { 41 | p++; 42 | q++; 43 | while (*q && !isquote(*q)) 44 | q++; 45 | if (isquote(*q)) 46 | *q++ = '\0'; 47 | else if (*q == '\0') 48 | break; 49 | } else { 50 | while (*q && !isspace(*q)) 51 | q++; 52 | } 53 | while (isspace(*q) && !isquote(*q)) 54 | *q++ = '\0'; 55 | if (*q == '\0') { 56 | argv[i++] = strdup(p); 57 | break; 58 | } 59 | if (*p) 60 | argv[i++] = strdup(p); 61 | p = q; 62 | } 63 | argv[i] = NULL; 64 | xfree(tmp); 65 | } 66 | -------------------------------------------------------------------------------- /libtemplate/util/xmalloc.c: -------------------------------------------------------------------------------- 1 | static char rcsid[] = "$Id: xmalloc.c,v 1.1 1999/11/03 20:42:14 golda Exp $"; 2 | /* 3 | * xmalloc.c - Memory allocation for Essence system. 4 | * 5 | * Darren Hardy, hardy@cs.colorado.edu, February 1994 6 | * 7 | * ---------------------------------------------------------------------- 8 | * Copyright (c) 1994, 1995. All rights reserved. 9 | * 10 | * Mic Bowman of Transarc Corporation. 11 | * Peter Danzig of the University of Southern California. 12 | * Darren R. Hardy of the University of Colorado at Boulder. 13 | * Udi Manber of the University of Arizona. 14 | * Michael F. Schwartz of the University of Colorado at Boulder. 15 | * 16 | */ 17 | #include 18 | #include 19 | #include 20 | #include "util.h" 21 | #ifdef MEMORY_LEAKS 22 | #include "leak.h" 23 | #endif 24 | 25 | /* 26 | * xmalloc() - same as malloc(3) except if malloc() returns NULL, then 27 | * xmalloc() prints an error message and calls exit(3). So xmalloc() 28 | * always returns non-NULL values. 29 | */ 30 | void *xmalloc(sz) 31 | size_t sz; 32 | { 33 | static void *p; 34 | 35 | #ifdef MEMORY_LEAKS 36 | leak_logging = 1; 37 | #endif 38 | if ((p = malloc(sz)) == NULL) { 39 | errorlog("malloc: Out of memory! Exiting...\n"); 40 | exit(1); 41 | } 42 | memset(p, '\0', sz); /* NULL out the memory */ 43 | return (p); 44 | } 45 | 46 | /* 47 | * xfree() - same as free(3). 48 | */ 49 | void xfree(s) 50 | void *s; 51 | { 52 | #ifdef MEMORY_LEAKS 53 | leak_logging = 1; 54 | #endif 55 | if (s != NULL) { 56 | free(s); 57 | } 58 | } 59 | 60 | /* 61 | * xrealloc() - same as realloc(3). Exits on error, so always returns 62 | * non-NULL values. 63 | */ 64 | void *xrealloc(s, sz) 65 | void *s; 66 | size_t sz; 67 | { 68 | static void *p; 69 | 70 | #ifdef MEMORY_LEAKS 71 | leak_logging = 1; 72 | #endif 73 | if ((p = realloc(s, sz)) == NULL) { 74 | errorlog("realloc: Out of memory! Exiting...\n"); 75 | exit(1); 76 | } 77 | return (p); 78 | } 79 | -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Last modified: 1994-03-25 6 | # Public domain 7 | 8 | errstatus=0 9 | 10 | for file in ${1+"$@"} ; do 11 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 12 | shift 13 | 14 | pathcomp= 15 | for d in ${1+"$@"} ; do 16 | pathcomp="$pathcomp$d" 17 | case "$pathcomp" in 18 | -* ) pathcomp=./$pathcomp ;; 19 | esac 20 | 21 | if test ! -d "$pathcomp"; then 22 | echo "mkdir $pathcomp" 1>&2 23 | mkdir "$pathcomp" || errstatus=$? 24 | fi 25 | 26 | pathcomp="$pathcomp/" 27 | done 28 | done 29 | 30 | exit $errstatus 31 | 32 | # mkinstalldirs ends here 33 | 34 | -------------------------------------------------------------------------------- /test/check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #---------------------------------------------- 4 | # Check target suite 5 | #---------------------------------------------- 6 | ERROR_LOG="../make_check.errors" 7 | 8 | echo "Start check suite" 9 | cd test 10 | rm -f $ERROR_LOG 11 | 12 | #---------------------------------------------- 13 | # Make simple index database for test.txt file 14 | #---------------------------------------------- 15 | echo "" 16 | echo "run test 1 [1 of 2]" 17 | echo -en "index test... " 18 | GLIMPSEINDEX_OUTPUT=`../bin/glimpseindex -b -H . test.txt` 19 | GLIMPSEINDEX_EXIT_CODE="$?" 20 | 21 | if [ "$GLIMPSEINDEX_EXIT_CODE" -ne "0" ]; then 22 | echo "Error occured when running command: ../bin/glimpseindex -b -H . test.txt" >>"$ERROR_LOG" 23 | echo "Exit code: ${GLIMPSEINDEX_EXIT_CODE}" >>"$ERROR_LOG" 24 | echo "Eror output: ${GLIMPSEINDEX_OUTPUT}" >>"$ERROR_LOG" 25 | echo "" >>"$ERROR_LOG" 26 | fi 27 | 28 | #---------------------------------------------- 29 | # Analyse indexing results 30 | #---------------------------------------------- 31 | GREP_INDEX=`grep "glimpse" .glimpse_index` 32 | if [ -f ".glimpse_index" -a -n "$GREP_INDEX" ]; then 33 | echo "ok" 34 | else 35 | echo "fail" 36 | fi 37 | 38 | #---------------------------------------------- 39 | # Perform boolean search using generated db 40 | #---------------------------------------------- 41 | echo "" 42 | echo "run test 2 [2 of 2]" 43 | echo -en "search test... " 44 | GLIMPSE_OUTPUT=`../bin/glimpse -c -h -i -y -H . 'test;suite'` 45 | GLIMPSE_EXIT_CODE="$?" 46 | 47 | if [ "$GLIMPSE_EXIT_CODE" -ne "0" ]; then 48 | echo "Error occured when running command: ../bin/glimpse -c -h -i -y -H . 'test;suite'" >>"$ERROR_LOG" 49 | echo "Exit code: ${GLIMPSE_EXIT_CODE}" >>"$ERROR_LOG" 50 | echo "Eror output: ${GLIMPSE_OUTPUT}" >>"$ERROR_LOG" 51 | echo "" >>"$ERROR_LOG" 52 | fi 53 | 54 | #---------------------------------------------- 55 | # Analyse search results 56 | #---------------------------------------------- 57 | if [ "$GLIMPSE_OUTPUT" = "1" ]; then 58 | echo "ok" 59 | else 60 | echo "fail" 61 | fi 62 | 63 | 64 | #---------------------------------------------- 65 | # Clean up 66 | #---------------------------------------------- 67 | rm -f .glimpse_* 68 | 69 | cd .. 70 | echo "" 71 | echo "Done" -------------------------------------------------------------------------------- /test/test.txt: -------------------------------------------------------------------------------- 1 | Basic glimpse test suite. --------------------------------------------------------------------------------