📄 swish.h
字号:
/*** Copyright (C) 1995, Enterprise Integration Technologies Corp. ** All Rights Reserved.** Kevin Hughes, kevinh@eit.com ** 3/11/94***/#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.1"#define INDEXFILE "index.swish"#define INDEXHEADER "# SWISH format 1.1 - SOIF"#define MAXFILELEN 1000#define MAXSTRLEN 100#define MAXWORDLEN 40#define MAXTITLELEN 10#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 "swish_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; struct result *next;};struct file { char *filename; int size; struct file *next;};struct filenum { int fileshort; long filelong; struct filenum *next;};struct location { int filenum; int frequency; int attribute; struct location *next;};struct entry { char *word; int tfrequency; struct location *locationlist; struct entry *left; struct entry *right;};struct fileentry { char *filename; struct fileentry *next;};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#endifVAR 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_FILEchar *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 };#elseextern char *indexchars;extern char *defaultstopwords[];extern char *entities[];#endifint main();void usage();void printversion();void printrunning();long getthetime();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -