Algorithm 版 (精华区)
发信人: Lerry (想不开·撞树), 信区: Algorithm
标 题: parker.h
发信站: 哈工大紫丁香 (2002年06月09日21:27:33 星期天), 站内信件
/*
* NoseyParker, the search engine for FTP archives
* Copyright (C) 1993-96 by Jiri A. Randus
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* The author can be reached as follows:
* Internet: <Jiri.Randus@vslib.cz>
* Phone: ++42 48 5227374
* SnailMail: Jiri Randus
* KIN HF TU v Liberci
* Halkova 6
* 46117 Liberec
* Czech Republic
*/
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <netdb.h>
#include <dirent.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "conf.h"
/*
#define DEBUG
*/
#ifndef DEBUG
#define VERSION "V1.0D Btree"
#define DEB(xxx) {}
#define MAXAGENTS 20
#else
#define VERSION "V1.0D Btree DEBUGGED"
#define DEB(xxx) {printf("--- %s\n",xxx);fflush(stdout);}
#define MAXAGENTS 1
#endif
#define ECHO(xxx) {Echo(files[xxx][language]);}
/* #define ECHO(xxx) {Echo(files[xxx][1]);} /* English only */
#define HOSTLIST "/etc/Parker_Hosts"
#define SEEDDB "ServerData/"
#define DATADB "Data/"
#define SEEDPATHDB "DB.paths"
#define SEEDFILEDB "DB.hosts"
#define SEEDBTREE "DB.btreehosts"
#define SEEDBTREEFILES "DB.btreefiles"
#define EXCLUDEFILES "DB."
#define CORE "core"
/* if this begins with a slash, it means an absolute path;
otherwise, it is relative to ~parker */
#define MMAPTMPFILE "tmp/mmaped_file"
#define MAILHLPTXT "txts/mailhelp.txt"
#define STATUSTXT "txts/status.txt"
#define HELLOTXT "txts/welcome.txt"
#define HELPTXT "txts/help.txt"
#define SOLONGTXT "txts/solong.txt"
#define TOOBIGTXT "txts/toobig.txt"
#define TYPETXT "txts/type.txt"
#define LOOKFORTXT "txts/lookfor.txt"
#define SEEKINGTXT "txts/seeking.txt"
#define CHOICETXT "txts/choice.txt"
#define MAILRESTXT "txts/mailres.txt"
#define YNTXT "txts/yn.txt"
#define ADDRESSTXT "txts/address.txt"
#define EHADDRTXT "txts/ehaddr.txt"
#define CANTRESTXT "txts/cantres.txt"
#define MAILINGTXT "txts/mailing.txt"
#define SUBJECTTXT "txts/subject.txt"
#define RESULTTXT "txts/result.txt"
#define INACTIVITYTXT "txts/inactivity.txt"
#define HANGUPTXT "txts/hangup.txt"
#define MENUTXT "txts/menu.txt"
#define CZHELLOTXT "txts/czwelcome.txt"
#define CZHELPTXT "txts/czhelp.txt"
#define CZSOLONGTXT "txts/czsolong.txt"
#define CZTOOBIGTXT "txts/cztoobig.txt"
#define CZSTATUSTXT "txts/czstatus.txt"
#define CZTYPETXT "txts/cztype.txt"
#define CZLOOKFORTXT "txts/czlookfor.txt"
#define CZSEEKINGTXT "txts/czseeking.txt"
#define CZCHOICETXT "txts/czchoice.txt"
#define CZMAILRESTXT "txts/czmailres.txt"
#define CZYNTXT "txts/czyn.txt"
#define CZADDRESSTXT "txts/czaddress.txt"
#define CZEHADDRTXT "txts/czehaddr.txt"
#define CZCANTRESTXT "txts/czcantres.txt"
#define CZMAILINGTXT "txts/czmailing.txt"
#define CZSUBJECTTXT "txts/czsubject.txt"
#define CZRESULTTXT "txts/czresult.txt"
#define CZINACTIVITYTXT "txts/czinactivity.txt"
#define CZHANGUPTXT "txts/czhangup.txt"
#define CZMENUTXT "txts/czmenu.txt"
#define EMAILINFO "guest@my.net"
#define SERVER "127.0.0.1"
#define GO4GW_FTP "127.0.0.1"
#define GO4GW_FTP_PORT "70"
#define FROM_LINE "From: \"NoseyParker\" <parker@Larry>"
#define SUBJ "Subject:"
#define PREPOSITIVE '1'
#define POSITIVE '2'
#define PROCEED '3'
#define PRENEGATIVE '4'
#define NEGATIVE '5'
#define SUCCESS "226 "
#define PWD "257 "
#define SPECIALREGCHAR "?+()|.*^$[]"
#define SPECIALWILDCHAR "*?"
#define QUERYSTRING "QUERY_STRING"
#define HTTPUSERAGENT "HTTP_USER_AGENT"
#define HTTPPATHINFO "PATH_INFO"
#define MOZILLA "Mozilla"
#define PARKERSERVER "127.0.0.1"
#define PARKERPORT 1995
#define SIZEOFINETADDR 4
#define MINLENGTHOFSEARCH 3
#define S_PREOK 1
#define S_OK 0
#define S_ERROR -1
#define S_CLOSED -2
#define S_ERROR_INFIMA -3 /* A fix to the Major BBS's RFC 959 LIST violation
*/
#define PARKER_NICE 20
#define PSH_NICE 1
#define PMAIL_NICE 20
#define CGIALARM 600
#define FTPPORT 21
#define MODE 0644
#define TIMEOUT 1200
#define MAXWORDS 20
#define MAXLINES 23
#define MAX 1024
#define ALTIME 1200
#define MAXMAIL 50000
#define MAXPMAIL 50000
#define MAXPMAILTOTAL 100000
#define MAXCLLINES 300
#define PRFX "parkr"
#define CR 13
#define LF 10
#define ESC 27
#define TOP256 256
/******************** B-tree stuff ********************/
#define KEYSIZE 3 /* Size of a key for the Btree */
#define B 10 /* Btree: A=5, B=10 */
#define BTREEENDMARK (BTcnts)(-1)
typedef unsigned short BTcnts;
/*
* union DiskTripleDef is platform dependant !!!! It matters whether
* the machine is little or big endian, for which we make a tiny
* test in autoconf.c. The result should be one of the defines below.
*
*/
#ifdef MACHINE_BIG_ENDIAN
/* Big endian machines (RISCs and other big boxes) */
union DiskTripleRef { struct {BTcnts mark; BTcnts fileno;} file;
long offset;
};
#endif
#ifdef MACHINE_LITTLE_ENDIAN
/* Little endian machines (like Intel based machines) */
union DiskTripleRef {
long offset;
struct {BTcnts mark; BTcnts fileno;} file;
};
#endif
struct DiskBTreeRef { char top[KEYSIZE]; long offset;};
struct DiskBTreeHead { char key[KEYSIZE];
struct DiskBTreeRef treerefs[B];
long numrefs;
};
#define BTREENUMINFO 64
/* BTree info - refs to the database */
struct BTreeInfo { short cnt;
union DiskTripleRef refs[BTREENUMINFO];
struct BTreeInfo *next;
};
/* BTree item */
struct BTreeItem { char *key;
struct BTreeInfo *info;
char *tops[B];
struct BTreeItem *refs[B];
BTcnts lastfileno;
long lastoffset;
long diskoffset;
};
struct TripleList {char *key; struct TripleList *next;};
/* Externs */
extern void Log(char *, char *, char *);
void PStatus(char *, int);
int PQuery(char *, char *, int, char *, char *, char *);
int PSkip(char *);
/* externs for btree/btreehosts/btreefiles */
extern struct TripleList **TriIndex;
extern char *BTreeMax;
extern struct BTreeItem *Bhead;
extern struct TripleList *Thead, *Tptr, *Tptr2;
extern long triplecount;
extern long nodecount;
extern long diskoffset;
void addB(struct TripleList *, struct BTreeItem *, struct BTreeItem **, char
**);
void LoadTriples(void);
struct BTreeItem *LocateBItem(char *, struct BTreeItem *);
void AddRef(struct BTreeItem *, union DiskTripleRef *);
void IndexOffset(struct BTreeItem *, long *);
void SaveIndex(char *);
void CreateBtree(long, long);
void AnnounceMethod(void);
--
当一个女孩儿觉得她不太容易了解那个男人的时候,她会爱他。
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 天外飞仙]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:204.142毫秒