1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
/*
** Copyright (C) 1995, Enterprise Integration Technologies Corp.
** All Rights Reserved.
** Kevin Hughes, kevinh@eit.com
** 3/11/94
**
** Added support for METADATA
** G. Hill ghill@library.berkeley.edu 3/18/97
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef NEXTSTEP
#include <sys/dir.h>
#else
#include <dirent.h>
#endif
#include <ctype.h>
#include <stdlib.h>
#include <time.h>
#include <setjmp.h>
#define VERSION "1.1"
#define INDEXFILE "index.swish"
#define INDEXHEADER "# SWISH-E format 1.1"
#define MAXFILELEN 1000
#define MAXSTRLEN 1000
#define MAXWORDLEN 1000
#define MAXTITLELEN 200
#define MAXSUFFIXLEN 10
#define MAXENTLEN 10
#define HASHSIZE 101
#define BIGHASHSIZE 1009
#define TI_OPEN 1
#define TI_CLOSE 2
#define TI_FOUND 4
#define NOWORD "thisisnotaword"
#define SECSPERMIN 60
#define NO_RULE 0
#define AND_RULE 1
#define OR_RULE 2
#define NOT_RULE 3
#define IN_FILE 1
#define IN_TITLE 2
#define IN_HEAD 4
#define IN_BODY 8
#define IN_COMMENTS 16
#define IN_HEADER 32
#define IN_EMPHASIZED 64
#define IN_ALL 127
#define MAXLONGLEN 16
#define MAXCHARS 69
#define MAXHEADCHARS MAXLONGLEN * MAXCHARS
#define METANAMEPOS MAXCHARS - 4
#define STOPWORDPOS MAXCHARS - 3
#define FILELISTPOS MAXCHARS - 2
#define FILEOFFSETPOS MAXCHARS - 1
#include "config.h"
struct metaEntry {
char* metaName;
int index;
struct metaEntry* next;
};
struct sortresult {
char *fileinfo;
int rank;
struct sortresult *left;
struct sortresult *right;
};
struct result {
int filenum;
int rank;
int structure;
struct result *next;
};
struct file {
char *filename;
char *title;
int size;
struct file *next;
};
struct filenum {
int fileshort;
long filelong;
struct filenum *next;
};
struct location {
int filenum;
int frequency;
int emphasized;
int structure;
int metaName;
struct location *next;
};
struct entry {
char *word;
int tfrequency;
struct location *locationlist;
struct entry *left;
struct entry *right;
};
struct sortentry {
char *filename;
char *title;
struct sortentry *left;
struct sortentry *right;
};
struct swline {
char *line;
struct swline *next;
};
struct fwordtotal {
int filenum;
int totalwords;
struct fwordtotal *next;
};
#ifndef MAIN_FILE
#define VAR extern
#else
#define VAR
#endif
VAR struct file *filelist;
VAR struct entry *entrylist;
VAR struct swline *pathconlist;
VAR struct swline *dirconlist;
VAR struct swline *fileconlist;
VAR struct swline *titconlist;
VAR struct swline *fileislist;
VAR struct swline *suffixlist;
VAR struct swline *nocontentslist;
VAR struct swline *replacelist;
VAR struct swline *searchwordlist;
VAR struct swline *dirlist;
VAR struct swline *indexlist;
VAR struct swline *hashstoplist[HASHSIZE];
VAR char *stopList[HASHSIZE];
VAR struct result *resulthashlist[HASHSIZE];
VAR struct fwordtotal *fwordtotals[BIGHASHSIZE];
VAR struct filenum *filehashlist[BIGHASHSIZE];
VAR struct metaEntry* metaEntryList;
VAR long offsets[MAXCHARS];
VAR int verbose;
VAR int bigrank;
VAR int maxhits;
VAR int totalwords;
VAR int followsymlinks;
VAR int commonerror;
VAR int stopPos;
VAR char indexn[MAXSTRLEN];
VAR char indexd[MAXSTRLEN];
VAR char indexp[MAXSTRLEN];
VAR char indexa[MAXSTRLEN];
VAR char errorstr[MAXSTRLEN];
#ifdef MAIN_FILE
char *indexchars = "abcdefghijklmnopqrstuvwxyz&#;0123456789_\\|/-+=?!@$%^'\"`~,.<>[]{}";
char *defaultstopwords[] = {
"a", "above", "according", "across", "actually", "adj", "after",
"afterwards", "again", "against", "all", "almost", "alone", "along",
"already", "also", "although", "always", "among", "amongst", "an", "and",
"another", "any", "anyhow", "anyone", "anything", "anywhere", "are", "aren",
"aren't", "around", "as", "at", "be", "became", "because", "become", "becomes",
"becoming", "been", "before", "beforehand", "begin", "beginning", "behind",
"being", "below", "beside", "besides", "between", "beyond", "billion", "both",
"but", "by", "can", "can't", "cannot", "caption", "co", "could", "couldn",
"couldn't", "did", "didn", "didn't", "do", "does", "doesn", "doesn't", "don",
"don't", "down", "during", "each", "eg", "eight", "eighty", "either", "else",
"elsewhere", "end", "ending", "enough", "etc", "even", "ever", "every",
"everyone", "everything", "everywhere", "except", "few", "fifty", "first",
"five", "for", "former", "formerly", "forty", "found", "four", "from",
"further", "had", "has", "hasn", "hasn't", "have", "haven", "haven't",
"he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon",
"hers", "herself", "him", "himself", "his", "how", "however", "hundred",
"ie", "i.e.", "if", "in", "inc", "inc.", "indeed", "instead", "into", "is",
"isn", "isn't", "it", "its", "itself", "last", "later", "latter", "latterly",
"least", "less", "let", "like", "likely", "ll", "ltd", "made", "make",
"makes", "many", "maybe", "me", "meantime", "meanwhile", "might", "million",
"miss", "more", "moreover", "most", "mostly", "mr", "mrs", "much", "must",
"my", "myself", "namely", "neither", "never", "nevertheless", "next", "nine",
"ninety", "no", "nobody", "none", "nonetheless", "noone", "nor", "not",
"nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one",
"only", "onto", "or", "others", "otherwise", "our", "ours",
"ourselves", "out", "over", "overall", "own", "per", "perhaps", "rather",
"re", "recent", "recently", "same", "seem", "seemed", "seeming", "seems",
"seven", "seventy", "several", "she", "should", "shouldn", "shouldn't",
"since", "six", "sixty", "so", "some", "somehow", "someone", "something",
"sometime", "sometimes", "somewhere", "still", "stop", "such", "taking",
"ten", "than", "that", "the", "their", "them", "themselves", "then",
"thence", "there", "thereafter", "thereby", "therefore", "therein",
"thereupon", "these", "they", "thirty", "this", "those", "though",
"thousand", "three", "through", "throughout", "thru", "thus", "to",
"together", "too", "toward", "towards", "trillion", "twenty", "two", "under",
"unless", "unlike", "unlikely", "until", "up", "upon", "us", "used", "using",
"ve", "very", "via", "was", "wasn", "we", "we", "well", "were", "weren",
"weren't", "what", "whatever", "when", "whence", "whenever", "where",
"whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever",
"whether", "which", "while", "whither", "who", "whoever", "whole", "whom",
"whomever", "whose", "why", "will", "with", "within", "without", "won",
"would", "wouldn", "wouldn't", "yes", "yet", "you", "your", "yours",
"yourself", "yourselves", NULL };
char *entities[] = {
"", " ", " ", "", "!", "!", """, """, "\"", "", "#", "#",
"", "$", "$", "", "%", "%", "&", "&", "&", "", "'", "'",
"", "+", "+", "", ",", ",", "", "-", "-", "", ".", ".",
"", "/", "/", "", "0", "0", "", "1", "1", "", "2", "2",
"", "3", "3", "", "4", "4", "", "5", "5", "", "6", "6",
"", "7", "7", "", "8", "8", "", "9", "9", "", ":", "",
"", ";", ";", "<", "<", "<", "", "=", "=", ">", ">", ">",
"", "?", "?", "", "@", "@", "", "A", "A", "", "B", "B",
"", "C", "C", "", "D", "D", "", "E", "E", "", "F", "F",
"", "G", "G", "", "H", "H", "", "I", "I", "", "J", "J",
"", "K", "K", "", "L", "L", "", "M", "M", "", "N", "N",
"", "O", "O", "", "P", "P", "", "Q", "Q", "", "R", "R",
"", "S", "S", "", "T", "T", "", "U", "U", "", "V", "V",
"", "W", "W", "", "X", "X", "", "Y", "Y", "", "Z", "Z",
"", "[", "[", "", "\", "\\", "", "]", "]", "", "^", "^",
"", "_", "-", "", "`", "`", "", "a", "a", "", "b", "b",
"", "c", "c", "", "d", "d", "", "e", "e", "", "f", "f",
"", "g", "g", "", "h", "h", "", "i", "i", "", "j", "j",
"", "k", "k", "", "l", "l", "", "m", "m", "", "n", "n",
"", "o", "o", "", "p", "p", "", "q", "q", "", "r", "r",
"", "s", "s", "", "t", "t", "", "u", "u", "", "v", "v",
"", "w", "w", "", "x", "x", "", "y", "y", "", "z", "z",
"", "{", "{", "", "|", "|", "", "}", "}", "", "~", "~",
" ", " ", " ", "¡", "¡", "", "¢", "¢", "",
"£", "£", "", "¤", "¤", "", "¥", "¥", "",
"¦", "¦", "", "§", "§", "", "&die", "¨", "",
"©", "©", "", "ª", "ª", "", "«", "«", "",
"¬", "¬", "", "­", "­", "", "®", "®", "",
"¯on", "¯", "", "°ree", "°", "", "±", "±", "",
"²", "²", "", "³", "³", "", "´", "´", "",
"µ", "µ", "", "&mu", "¶", "", "·", "·", "",
"&Cedilla", "¸", "", "¹", "¹", "", "º", "º", "",
"»", "»", "", "¼", "¼", "", "½", "½", "",
"¾", "¾", "", "¿", "¿", "", "À", "À", "A",
"Á", "Á", "A", "Â", "Â", "A", "Ã", "Ã", "A",
"Ä", "Ä", "A", "Å", "Å", "A", "Æ", "Æ", "A",
"Ç", "Ç", "C", "È", "È", "E", "É", "É", "E",
"Ê", "Ê", "E", "Ë", "Ë", "E", "Ì", "Ì", "E",
"Í", "Í", "I", "Î", "Î", "I", "Ï", "Ï", "I",
"Ð", "Ð", "", "Ñ", "Ñ", "N", "Ò", "Ò", "O",
"Ó", "Ó", "O", "Ô", "Ô", "O", "Õ", "Õ", "O",
"Ö", "Ö", "O", "×", "×", "", "Ø", "Ø", "O",
"Ù", "Ù", "U", "Ú", "Ú", "U", "Û", "Û", "U",
"Ü", "Ü", "U", "Ý", "Ý", "Y", "Þ", "Þ", "",
"ß", "ß", "", "à", "à", "a", "á", "á", "a",
"â", "â", "a", "ã", "ã", "a", "ä", "ä", "a",
"å", "å", "a", "æ", "æ", "a", "ç", "ç", "c",
"è", "è", "e", "é", "é", "e", "ê", "ê", "e",
"ë", "ë", "e", "ì", "ì", "i", "í", "í", "i",
"î", "î", "i", "ï", "ï", "i", "ð", "ð", "",
"ñ", "ñ", "n", "ò", "ò", "o", "ó", "ó", "o",
"ô", "ô", "o", "õ", "õ", "o", "ö", "ö", "o",
"÷", "÷", "", "ø", "ø", "o", "ù", "ù", "u",
"ú", "ú", "u", "û", "û", "u", "ü", "ü", "u",
"ý", "ý", "y", "þ", "þ", "", "ÿ", "ÿ", "y",
NULL };
#else
extern char *indexchars;
extern char *defaultstopwords[];
extern char *entities[];
#endif
#ifdef MAIN_FILE
int main();
void usage();
void printversion();
void printrunning();
long getthetime();
#endif
|