亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? htcache.c

?? www工具包. 這是W3C官方支持的www支撐庫. 其中提供通用目的的客戶端的WebAPI: complete HTTP/1.1 (with caching, pipelining, PUT, POS
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*							       	    HTCache.c**	CACHE WRITER****	(c) COPYRIGHT MIT 1995.**	Please first read the full copyright statement in the file COPYRIGH.**	@(#) $Id: HTCache.c,v 2.76 2001/08/30 13:49:24 kahan Exp $****	This modules manages the cache****      History:**         HFN: spawned from HTFwrite**         HWL: converted the caching scheme to be hierachical by taking**              AL code from Deamon***//* Library include files */#include "wwwsys.h"#include "WWWUtil.h"#include "WWWCore.h"#include "WWWTrans.h"#include "WWWApp.h"#include "HTCache.h"					 /* Implemented here *//* This is the default cache directory: */#define HT_CACHE_LOC	"/tmp/"#define HT_CACHE_ROOT	"w3c-cache/"#define HT_CACHE_INDEX	".index"#define HT_CACHE_LOCK	".lock"#define HT_CACHE_META	".meta"#define HT_CACHE_EMPTY_ETAG	"@w3c@"/* Default heuristics cache expirations - thanks to Jeff Mogul for good comments! */#define NO_LM_EXPIRATION	24*3600		/* 24 hours */#define MAX_LM_EXPIRATION	48*3600		/* Max expiration from LM *//***  If using LM to find the expiration then take 10% and no more than**  MAX_LM_EXPIRATION.*/#ifndef LM_EXPIRATION#define LM_EXPIRATION(t)	(HTMIN((MAX_LM_EXPIRATION), (t) / 10))#endif#define WARN_HEURISTICS		24*3600		  /* When to issue a warning */#define DUMP_FREQUENCY	10			 /* Dump index every x loads */#define MEGA			0x100000L#define HT_CACHE_TOTAL_SIZE	20		/* Default cache size is 20M */#define HT_CACHE_FOLDER_PCT	10    /* 10% of cache size for metainfo etc. */#define HT_CACHE_GC_PCT		10        /* 10% of cache size free after GC */#define HT_MIN_CACHE_TOTAL_SIZE	 5			/* 5M Min cache size */#define HT_MAX_CACHE_ENTRY_SIZE	 3     /* 3M Max sixe of single cached entry *//* Final states have negative value */typedef enum _CacheState {    CL_ERROR		= -3,    CL_NO_DATA		= -2,    CL_GOT_DATA		= -1,    CL_BEGIN		= 0,    CL_NEED_BODY,    CL_NEED_OPEN_FILE,    CL_NEED_CONTENT} CacheState;/* This is the context structure for the this module */typedef struct _cache_info {    CacheState		state;		  /* Current state of the connection */    char *		local;		/* Local representation of file name */    struct stat		stat_info;	      /* Contains actual file chosen */    HTNet *		net;    HTTimer *		timer;} cache_info;struct _HTCache {    /* Location */    int 		hash;    char *		url;    char *		cachename;    /* GC parameters */    char *		etag;    BOOL		range;	      /* Is this the full part or a subpart? */    BOOL		must_revalidate;    int			hits;				       /* Hit counts */    long		size;		       /* Size of cached entity body */    time_t		lm;				    /* Last modified */    time_t		expires;    time_t		freshness_lifetime;    time_t		response_time;    time_t		corrected_initial_age;    HTRequest *		lock;};struct _HTStream {    const HTStreamClass *	isa;    FILE *			fp;    long			bytes_written;	  /* Number of bytes written */    HTCache *			cache;    HTRequest *			request;    HTResponse *		response;    HTChunk *			buffer;			/* For index reading */    HTEOLState			EOLstate;    BOOL			append;		   /* Creating or appending? */};struct _HTInputStream {    const HTInputStreamClass *	isa;};/* Cache parameters */ PRIVATE BOOL		HTCacheEnable = NO;	      /* Disabled by default */PRIVATE BOOL		HTCacheInitialized = NO;PRIVATE BOOL		HTCacheProtected = YES;PRIVATE char *		HTCacheRoot = NULL;   /* Local Destination for cache */PRIVATE HTExpiresMode	HTExpMode = HT_EXPIRES_IGNORE;PRIVATE HTDisconnectedMode DisconnectedMode = HT_DISCONNECT_NONE;/* Heuristic expiration parameters */PRIVATE int DefaultExpiration = NO_LM_EXPIRATION;/* List of cache entries */PRIVATE HTList ** 	CacheTable = NULL;/* Cache size variables */PRIVATE long		HTCacheTotalSize = HT_CACHE_TOTAL_SIZE*MEGA;PRIVATE long		HTCacheFolderSize = (HT_CACHE_TOTAL_SIZE*MEGA)/HT_CACHE_FOLDER_PCT;PRIVATE long		HTCacheGCBuffer = (HT_CACHE_TOTAL_SIZE*MEGA)/HT_CACHE_GC_PCT;PRIVATE long		HTCacheContentSize = 0L;PRIVATE long		HTCacheMaxEntrySize = HT_MAX_CACHE_ENTRY_SIZE*MEGA;PRIVATE int		new_entries = 0;	   /* Number of new entries */PRIVATE HTNetBefore	HTCacheFilter;PRIVATE HTNetAfter	HTCacheUpdateFilter;PRIVATE HTNetAfter	HTCacheCheckFilter;/* ------------------------------------------------------------------------- *//*  			     CACHE GARBAGE COLLECTOR			     *//* ------------------------------------------------------------------------- */PRIVATE BOOL stopGC (void){    return (HTCacheContentSize + HTCacheFolderSize < HTCacheTotalSize - HTCacheGCBuffer);}PRIVATE BOOL startGC (void){    return (HTCacheContentSize + HTCacheFolderSize > HTCacheTotalSize);}PRIVATE BOOL HTCacheGarbage (void){    long old_size = HTCacheContentSize;    HTTRACE(CACHE_TRACE, "Cache....... Garbage collecting\n");    if (CacheTable) {	time_t cur_time = time(NULL);	HTList * cur;	int cnt;	int hits;	/*	**  Tell the user that we're gc'ing.	*/	{	    HTAlertCallback * cbf = HTAlert_find(HT_PROG_OTHER);	    if (cbf) (*cbf)(NULL, HT_PROG_OTHER, HT_MSG_NULL,NULL, NULL, NULL);	}	/*	**  Walk through and delete all the expired entries. If this is not	**  sufficient then take the fresh ones which have the lowest cache	**  hit count. This algorithm could be made a lot fancier by including	**  the size and also the pain it took to get the document in the first	**  case. It could also include max_stale.	*/	HTTRACE(CACHE_TRACE, "Cache....... Collecting Stale entries\n");	for (cnt=0; cnt<HT_XL_HASH_SIZE; cnt++) {	    if ((cur = CacheTable[cnt])) { 		HTList * old_cur = cur;		HTCache * pres;		while ((pres = (HTCache *) HTList_nextObject(cur)) != NULL) {		    time_t resident_time = cur_time - pres->response_time;		    time_t current_age = pres->corrected_initial_age +			resident_time;		    /* 2000-08-08 Jens Meggers: HTCache_remove doesn't		       remove a cache entry if it's locked. To avoid		       an endless loop, we check the return value of 		       HTCache_remove before skipping the entry. */		    if ((pres->freshness_lifetime < current_age)			&& HTCache_remove(pres)) {			cur = old_cur;		    } else {			old_cur = cur;		    }		    if (stopGC()) break;		}	    }	}	/*	**  We must at least free the min buffer size so that we don't	**  dead lock ourselves. We start from the bottom up by taking	**  all the documents with 0 hits, 1 hits, 2 hits, etc.	*/	HTTRACE(CACHE_TRACE, "Cache....... Collecting least used entries\n");	hits = 0;	while (startGC()) {	    BOOL removed = NO;	    HTTRACE(CACHE_TRACE, "Cache....... Collecting entries with %d hits\n" _ hits);	    for (cnt=0; cnt<HT_XL_HASH_SIZE; cnt++) {		if ((cur = CacheTable[cnt])) { 		    HTList * old_cur = cur;		    HTCache * pres;		    while ((pres = (HTCache *) HTList_nextObject(cur))) {			/* 2000-08-08 Jens Meggers: HTCache_remove doesn't			   remove a cache entry if it's locked. To avoid			   going into an endless loop, we check the return			   value of  HTCache_remove before marking the			   object as removed. */			if ((pres->size > HTCacheMaxEntrySize 			     || pres->hits <= hits) 			    && HTCache_remove(pres)) {			    cur = old_cur;			    removed = YES;			} else {			    old_cur = cur;			}			if (stopGC()) break;		    }		}	    }	    if (!removed) break;	    hits++;	}	HTTRACE(CACHE_TRACE, "Cache....... Size reduced from %ld to %ld\n" _ 		    old_size _ HTCacheContentSize);	/*	**  Dump the new content to the index file	*/	HTCacheIndex_write(HTCacheRoot);	new_entries = 0;	return YES;    }    return NO;}/* ------------------------------------------------------------------------- *//*  			      CACHE INDEX				     *//* ------------------------------------------------------------------------- */PRIVATE char * cache_index_name (const char * cache_root){    if (cache_root) {	char * location = NULL;	if ((location = (char *)	     HT_MALLOC(strlen(cache_root) + strlen(HT_CACHE_INDEX) + 1)) == NULL)	    HT_OUTOFMEM("cache_index_name");	strcpy(location, cache_root);	strcat(location, HT_CACHE_INDEX);	return location;    }    return NULL;}/***  Remove the cache index file*/PUBLIC BOOL HTCacheIndex_delete (const char * cache_root){    if (cache_root) {	char * index = cache_index_name(cache_root);	REMOVE(index);	HT_FREE(index);	return YES;    }    return NO;}/***	Walk through the list of cached objects and save them to disk.**	We override any existing version but that is normally OK as we have**	already read its contents.*/PUBLIC BOOL HTCacheIndex_write (const char * cache_root){    if (cache_root && CacheTable) {	char * index = cache_index_name(cache_root);	FILE * fp = NULL;	HTTRACE(CACHE_TRACE, "Cache Index. Writing index `%s\'\n" _ index);	/*	**  Open the file for writing. Note - we don't take a backup!	**  This should probably be fixed!	*/	if (!index) return NO;	if ((fp = fopen(index, "wb")) == NULL) {	    HTTRACE(CACHE_TRACE, "Cache Index. Can't open `%s\' for writing\n" _ index);	    HT_FREE(index);	    return NO;	}	/*	**  Walk through the list and write it out. The format is really	**  simple as we keep it all in ASCII.	*/	{	    HTList * cur;	    int cnt;	    for (cnt=0; cnt<HT_XL_HASH_SIZE; cnt++) {		if ((cur = CacheTable[cnt])) { 		    HTCache * pres;		    while ((pres = (HTCache *) HTList_nextObject(cur))) {			if (fprintf(fp, "%s %s %s %ld %ld %ld %c %d %d %ld %ld %ld %c\r\n",				    pres->url,				    pres->cachename,				    pres->etag ? pres->etag : HT_CACHE_EMPTY_ETAG,				    (long) (pres->lm),				    (long) (pres->expires),				    pres->size,				    pres->range+0x30,				    pres->hash,				    pres->hits,				    (long) (pres->freshness_lifetime),				    (long) (pres->response_time),				    (long) (pres->corrected_initial_age),				    pres->must_revalidate+0x30) < 0) {			    HTTRACE(CACHE_TRACE, "Cache Index. Error writing cache index\n");			    return NO;			}		    }		}	    }	}	/* Done writing */	fclose(fp);	HT_FREE(index);    }    return NO;}/***	Load one line of index file**	Returns YES if line OK, else NO*/PRIVATE BOOL HTCacheIndex_parseLine (char * line){    HTCache * cache = NULL;    if (line) {	char validate;	char range;	if ((cache = (HTCache *) HT_CALLOC(1, sizeof(HTCache))) == NULL)	    HT_OUTOFMEM("HTCacheIndex_parseLine");	/*	**  Read the line and create the cache object	*/	{	    char * url = HTNextField(&line);	    char * cachename = HTNextField(&line);	    char * etag = HTNextField(&line);	    StrAllocCopy(cache->url, url);	    StrAllocCopy(cache->cachename, cachename);	    if (strcmp(etag, HT_CACHE_EMPTY_ETAG)) StrAllocCopy(cache->etag, etag);	}#ifdef HAVE_LONG_TIME_T	/*	**  On some 64 bit machines (alpha) time_t is of type int and not long.	**  This means that we have to adjust sscanf accordingly so that we	**  know what we are looking for. Otherwise er may get unalignment	**  problems.	*/	if (sscanf(line, "%ld %ld %ld %c %d %d %ld %ld %ld %c",#else	if (sscanf(line, "%d %d %ld %c %d %d %d %d %d %c",#endif		   &cache->lm,		   &cache->expires,		   &cache->size,		   &range,		   &cache->hash,		   &cache->hits,		   &cache->freshness_lifetime,		   &cache->response_time,		   &cache->corrected_initial_age,		   &validate) < 0) {	    HTTRACE(CACHE_TRACE, "Cache Index. Error reading cache index\n");	    return NO;	}	cache->range = range-0x30;	cache->must_revalidate = validate-0x30;	/*	**  Create the new anchor and fill in the expire information we have read	**  in the index.	*/	if (cache) {	    HTAnchor * anchor = HTAnchor_findAddress(cache->url);	    HTParentAnchor * parent = HTAnchor_parent(anchor);	    HTAnchor_setExpires(parent, cache->expires);	    	    HTAnchor_setLastModified(parent, cache->lm);	    if (cache->etag) HTAnchor_setEtag(parent, cache->etag);	}	/*	**  Create the cache table if not already existent and add the new	**  entry. Also check that the hash is still within bounds	*/	if (!CacheTable) {	    if ((CacheTable = (HTList **) HT_CALLOC(HT_XL_HASH_SIZE,						    sizeof(HTList *))) == NULL)		HT_OUTOFMEM("HTCache_parseLine");	}	if (cache->hash >= 0 && cache->hash < HT_XL_HASH_SIZE) {	    int hash = cache->hash;	    if (!CacheTable[hash]) CacheTable[hash] = HTList_new();	    HTList_addObject(CacheTable[hash], (void *) cache);	}	/* Update the total cache size */	HTCacheContentSize += cache->size;	return YES;    }    return NO;}/***	Folding is either of CF LWS, LF LWS, CRLF LWS*/PRIVATE int HTCacheIndex_put_block (HTStream * me, const char * b, int l){    while (l > 0) {	if (me->EOLstate == EOL_FCR) {	    if (*b == LF)				   	     /* CRLF */		me->EOLstate = EOL_FLF;	    else if (isspace((int) *b))				   /* Folding: CR SP */		me->EOLstate = EOL_DOT;	    else {						 /* New line */		HTCacheIndex_parseLine(HTChunk_data(me->buffer));		me->EOLstate = EOL_BEGIN;		HTChunk_clear(me->buffer);		continue;	    }	} else if (me->EOLstate == EOL_FLF) {	    if (isspace((int) *b))		       /* Folding: LF SP or CR LF SP */		me->EOLstate = EOL_DOT;	    else {						/* New line */		HTCacheIndex_parseLine(HTChunk_data(me->buffer));		me->EOLstate = EOL_BEGIN;		HTChunk_clear(me->buffer);		continue;	    }	} else if (me->EOLstate == EOL_DOT) {	    if (isspace((int) *b)) {		me->EOLstate = EOL_BEGIN;		HTChunk_putc(me->buffer, ' ');	    } else {		HTCacheIndex_parseLine(HTChunk_data(me->buffer));		me->EOLstate = EOL_BEGIN;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
丁香六月综合激情| 韩国精品在线观看| 91黄色免费网站| 亚洲午夜免费电影| 91精品麻豆日日躁夜夜躁| 日本成人在线视频网站| 精品国产一区a| 成人一级片网址| 亚洲一区二区三区影院| 日韩一区二区三| 国产乱色国产精品免费视频| 欧美国产视频在线| 一本大道久久a久久精品综合| 亚洲一级电影视频| 日韩欧美的一区| 丁香婷婷综合色啪| 亚洲精品国久久99热| 91精品国产综合久久蜜臀 | 91精品国产一区二区| 久久精品国产秦先生| 国产精品视频你懂的| 欧美三级日韩三级国产三级| 美女视频网站久久| 欧美激情一区三区| 欧美视频在线播放| 国产精品99久久久久久似苏梦涵| 亚洲精品国久久99热| 精品美女在线播放| 色香色香欲天天天影视综合网| 日韩成人一级片| **欧美大码日韩| 欧美成人猛片aaaaaaa| 91亚洲精品久久久蜜桃| 美女在线观看视频一区二区| 综合自拍亚洲综合图不卡区| 日韩一级二级三级精品视频| a级高清视频欧美日韩| 美女免费视频一区二区| 亚洲人吸女人奶水| 精品国产精品网麻豆系列| 在线日韩av片| 菠萝蜜视频在线观看一区| 久久精品国产精品亚洲红杏| 亚洲黄色小说网站| 美女久久久精品| 亚洲人一二三区| 亚洲国产精品成人综合| 日韩欧美高清在线| 欧美区一区二区三区| 99视频热这里只有精品免费| 韩国一区二区三区| 美女视频黄久久| 水蜜桃久久夜色精品一区的特点| 国产精品进线69影院| 久久久久久9999| 日韩精品一区二区三区在线| 欧美在线短视频| 99精品偷自拍| 成a人片国产精品| 成人久久18免费网站麻豆 | 国产精品成人网| 久久久精品免费观看| 精品美女在线播放| 日韩欧美在线123| 日韩三级免费观看| 9191成人精品久久| 69成人精品免费视频| 欧美日韩免费观看一区二区三区| 91免费国产在线观看| 99久久婷婷国产| 99re成人在线| 99视频国产精品| 91在线视频免费91| 99久久精品免费看| 91视频一区二区| 91麻豆123| 91传媒视频在线播放| 欧美中文字幕亚洲一区二区va在线| 色综合久久久久综合99| 91免费看片在线观看| 欧美亚洲免费在线一区| 欧美日韩一卡二卡| 日韩一区二区在线免费观看| 欧美电影免费提供在线观看| 亚洲精品一区二区三区精华液 | av在线不卡网| 日本高清成人免费播放| 欧美综合在线视频| 91精品国产综合久久久蜜臀图片 | 国产亚洲综合性久久久影院| 久久一区二区三区国产精品| 国产欧美一区二区三区鸳鸯浴| 中文字幕第一区| 亚洲黄色av一区| 奇米四色…亚洲| 国产91丝袜在线播放0| 成人av电影在线| 欧美美女一区二区在线观看| 日韩视频在线观看一区二区| 久久众筹精品私拍模特| 国产精品天干天干在观线| 亚洲老妇xxxxxx| 日韩高清一级片| 国产成人精品一区二区三区四区| 97精品电影院| 日韩一级欧美一级| 国产日韩v精品一区二区| 亚洲免费在线视频| 免费观看在线综合色| 高清在线成人网| 欧美日韩国产成人在线免费| 久久综合狠狠综合久久综合88 | 欧洲国内综合视频| 欧美成人在线直播| 1000部国产精品成人观看| 午夜精品一区二区三区电影天堂| 精品伊人久久久久7777人| 99久久99久久免费精品蜜臀| 91精品国产综合久久久久久久 | 欧美视频三区在线播放| 久久久蜜桃精品| 亚洲亚洲精品在线观看| 国产精品中文有码| 欧美日韩二区三区| 国产精品理论片在线观看| 日韩电影免费在线看| 99精品黄色片免费大全| 精品美女被调教视频大全网站| 亚洲欧洲精品一区二区精品久久久| 视频在线在亚洲| 色狠狠一区二区三区香蕉| 国产无遮挡一区二区三区毛片日本| 一区二区三区高清在线| 国产成人无遮挡在线视频| 欧美精品在线一区二区三区| 亚洲天堂2014| 国产精品主播直播| 欧美一级黄色大片| 亚洲午夜在线电影| 成人h版在线观看| 精品国产区一区| 日韩高清在线一区| 91福利资源站| **欧美大码日韩| 粉嫩一区二区三区在线看| 精品少妇一区二区三区在线播放| 亚洲国产成人av网| 91首页免费视频| ㊣最新国产の精品bt伙计久久| 国产99精品在线观看| 精品久久久久久亚洲综合网| 丝袜美腿亚洲色图| 欧美人牲a欧美精品| 丁香桃色午夜亚洲一区二区三区| 日韩精品在线看片z| 日韩精品乱码免费| 欧美日韩午夜影院| 亚洲午夜激情网站| 99久久精品免费看国产免费软件| 国产网站一区二区三区| 美女网站色91| 精品毛片乱码1区2区3区| 久久精品国产精品亚洲红杏| 91精品蜜臀在线一区尤物| 日韩国产在线观看一区| 8x福利精品第一导航| 日韩和的一区二区| 欧美一区二区视频在线观看| 亚洲成av人片一区二区三区| 欧美日韩中字一区| 亚洲成人动漫av| 91麻豆精品国产91久久久使用方法| 亚洲福利一二三区| 8v天堂国产在线一区二区| 美日韩一区二区三区| 欧美xingq一区二区| 国产精品白丝jk白祙喷水网站| 国产亚洲精品中文字幕| 成人高清视频在线观看| 综合欧美亚洲日本| 欧美亚洲国产bt| 视频一区视频二区中文字幕| 欧美电影一区二区三区| 久久国产尿小便嘘嘘尿| 国产亚洲人成网站| 99在线热播精品免费| 一区二区日韩电影| 欧美日本精品一区二区三区| 蜜臀av一区二区| 久久久不卡网国产精品二区| 成人三级伦理片| 亚洲欧洲日韩在线| 欧美日韩视频专区在线播放| 免费成人av在线播放| 久久精品一区二区三区不卡牛牛| 99精品久久久久久| 天堂在线亚洲视频| 国产视频在线观看一区二区三区| 99久久精品费精品国产一区二区| 日韩电影在线免费观看|