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

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

?? webs.c

?? 嵌入式Linux系統用的web server,開源代碼,非常好用
?? C
?? 第 1 頁 / 共 5 頁
字號:

	va_start(vargs, fmt);

	buf = NULL;
	rc = 0;

	if (fmtValloc(&buf, WEBS_BUFSIZE, fmt, vargs) >= WEBS_BUFSIZE) {
		trace(0, T("webs: websWrite lost data, buffer overflow\n"));
	}
   
	va_end(vargs);
	a_assert(buf);
	if (buf) {
		rc = websWriteBlock(wp, buf, gstrlen(buf));
		bfree(B_L, buf);
	}
	return rc;
}

/******************************************************************************/
/*
 *	Write a block of data of length "nChars" to the user's browser. Public
 *	write block procedure.  If unicode is turned on this function expects 
 *	buf to be a unicode string and it converts it to ASCII before writing.
 *	See websWriteDataNonBlock to always write binary or ASCII data with no 
 *	unicode conversion.  This returns the number of char_t's processed.
 *	It spins until nChars are flushed to the socket.  For non-blocking
 *	behavior, use websWriteDataNonBlock.
 */

int websWriteBlock(webs_t wp, char_t *buf, int nChars)
{
	int		len, done;
	char	*asciiBuf, *pBuf;

	a_assert(wp);
	a_assert(websValid(wp));
	a_assert(buf);
	a_assert(nChars >= 0);

	done = len = 0;

/*
 *	ballocUniToAsc will convert Unicode to strings to Ascii.  If Unicode is
 *	not turned on then ballocUniToAsc will not do the conversion.
 */
	pBuf = asciiBuf = ballocUniToAsc(buf, nChars);

	while (nChars > 0) {  
#ifdef WEBS_SSL_SUPPORT
		if (wp->flags & WEBS_SECURE) {
			if ((len = websSSLWrite(wp->wsp, pBuf, nChars)) < 0) {
				bfree(B_L, asciiBuf);
				return -1;
			}
			websSSLFlush(wp->wsp);
		} else {
			if ((len = socketWrite(wp->sid, pBuf, nChars)) < 0) {
				bfree(B_L, asciiBuf);
				return -1;
			}
			socketFlush(wp->sid);
		}
#else /* ! WEBS_SSL_SUPPORT */
		if ((len = socketWrite(wp->sid, pBuf, nChars)) < 0) {
			bfree(B_L, asciiBuf);
			return -1;
		}
		socketFlush(wp->sid);
#endif /* WEBS_SSL_SUPPORT */
		nChars -= len;
		pBuf += len;
		done += len;
	}

	bfree(B_L, asciiBuf);
	return done;
}

/******************************************************************************/
/*
 *	Write a block of data of length "nChars" to the user's browser. Same as
 *	websWriteBlock except that it expects straight ASCII or binary and does no
 *	unicode conversion before writing the data.  If the socket cannot hold all
 *	the data, it will return the number of bytes flushed to the socket before
 *	it would have blocked.  This returns the number of chars processed or -1
 *	if socketWrite fails.
 */

int websWriteDataNonBlock(webs_t wp, char *buf, int nChars)
{
	int r;

	a_assert(wp);
	a_assert(websValid(wp));
	a_assert(buf);
	a_assert(nChars >= 0);

#ifdef WEBS_SSL_SUPPORT
	if (wp->flags & WEBS_SECURE) {
		r = websSSLWrite(wp->wsp, buf, nChars);
		websSSLFlush(wp->wsp);
	} else {
		r = socketWrite(wp->sid, buf, nChars);
		socketFlush(wp->sid);
	}
#else
	r = socketWrite(wp->sid, buf, nChars);
	socketFlush(wp->sid);
#endif

	return r;
}

/******************************************************************************/
/*
 *	Decode a URL (or part thereof). Allows insitu decoding.
 */

void websDecodeUrl(char_t *decoded, char_t *token, int len)
{
	char_t	*ip,  *op;
	int		num, i, c;
	
	a_assert(decoded);
	a_assert(token);

	op = decoded;
	for (ip = token; *ip && len > 0; ip++, op++) {
		if (*ip == '+') {
			*op = ' ';
		} else if (*ip == '%' && gisxdigit(ip[1]) && gisxdigit(ip[2])) {

/*
 *			Convert %nn to a single character
 */
			ip++;
			for (i = 0, num = 0; i < 2; i++, ip++) {
				c = tolower(*ip);
				if (c >= 'a' && c <= 'f') {
					num = (num * 16) + 10 + c - 'a';
				} else {
					num = (num * 16) + c - '0';
				}
			}
			*op = (char_t) num;
			ip--;

		} else {
			*op = *ip;
		}
		len--;
	}
	*op = '\0';
}

/******************************************************************************/
#ifdef WEBS_LOG_SUPPORT
/*
 *	Output a log message
 */

static void websLog(webs_t wp, int code)
{
	char_t	*buf;
	char	*abuf;
	int		len;
#define qAnlLog 1
#if (defined(qAnlLog) && !defined(CE))
   time_t timer;
   char_t* newLine = NULL;
   char_t* timeStr = NULL;
#endif
	a_assert(websValid(wp));

	buf = NULL;

#if (defined(qAnlLog) && !defined(CE))
   time(&timer);
   timeStr = ctime(&timer);
   newLine = gstrchr(timeStr, '\n');
   if (newLine)
   {
      *newLine = '\0';
   }
   fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%s\t%s\t%s\tcode = %d\n"), 
      timeStr, wp->ipaddr, wp->url, code);
#else
	fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%d %s %d %d\n"), time(0), 
		wp->url, code, wp->written);
#endif
	len = gstrlen(buf);
	abuf = ballocUniToAsc(buf, len+1);
	write(websLogFd, abuf, len);
	bfreeSafe(B_L, buf);
	bfreeSafe(B_L, abuf);
}

#endif /* WEBS_LOG_SUPPORT */

/******************************************************************************/
/*
 *	Request timeout. The timeout triggers if we have not read any data from
 *	the users browser in the last WEBS_TIMEOUT period. If we have heard from
 *	the browser, simply re-issue the timeout.
 */

void websTimeout(void *arg, int id)
{
	webs_t		wp;
	int			delay, tm;

	wp = (webs_t) arg;
	a_assert(websValid(wp));

	tm = websGetTimeSinceMark(wp) * 1000;
	if (tm >= WEBS_TIMEOUT) {
		websStats.timeouts++;
		emfUnschedCallback(id);

/*
 *		Clear the timeout id
 */
		wp->timeout = -1;
		websDone(wp, 404);
	} else {
		delay = WEBS_TIMEOUT - tm;
		a_assert(delay > 0);
		emfReschedCallback(id, delay);
	}
}

/******************************************************************************/
/*
 *	Called when the request is done.
 */

void websDone(webs_t wp, int code)
{
	a_assert(websValid(wp));

/*
 * 	Disable socket handler in case keep alive set.
 */
	socketDeleteHandler(wp->sid);

	if (code != 200) {
		wp->flags &= ~WEBS_KEEP_ALIVE;
	}

#ifdef WEBS_PROXY_SUPPORT
	if (! (wp->flags & WEBS_LOCAL_PAGE)) {
		websStats.activeNetRequests--;
	}
#endif

#ifdef WEBS_LOG_SUPPORT
	if (! (wp->flags & WEBS_REQUEST_DONE)) {
		websLog(wp, code);
	}
#endif

/*
 *	Close any opened document by a handler
 */
	websPageClose(wp);

/*
 *	Exit if secure.
 */
#ifdef WEBS_SSL_SUPPORT
	if (wp->flags & WEBS_SECURE) {
		websTimeoutCancel(wp);
		websSSLFlush(wp->wsp);
		socketCloseConnection(wp->sid);
		websFree(wp);
		return;
	}
#endif

/*
 *	If using Keep Alive (HTTP/1.1) we keep the socket open for a period
 *	while waiting for another request on the socket. 
 */
	if (wp->flags & WEBS_KEEP_ALIVE) {
		if (socketFlush(wp->sid) == 0) {
			wp->state = WEBS_BEGIN;
			wp->flags |= WEBS_REQUEST_DONE;
			if (wp->header.buf) {
				ringqFlush(&wp->header);
			}
			socketCreateHandler(wp->sid, SOCKET_READABLE, websSocketEvent, 
				(int) wp);
			websTimeoutCancel(wp);
			wp->timeout = emfSchedCallback(WEBS_TIMEOUT, websTimeout,
				(void *) wp);
			return;
		}
	} else {
		websTimeoutCancel(wp);
		socketSetBlock(wp->sid, 1);
		socketFlush(wp->sid);
		socketCloseConnection(wp->sid);
	}
	websFree(wp);
}

/******************************************************************************/
/*
 *	Allocate a new webs structure
 */

int websAlloc(int sid)
{
	webs_t		wp;
	int			wid;

/*
 *	Allocate a new handle for this connection
 */
	if ((wid = hAllocEntry((void***) &webs, &websMax,
			sizeof(struct websRec))) < 0) {
		return -1;
	}
	wp = webs[wid];

	wp->wid = wid;
	wp->sid = sid;
	wp->state = WEBS_BEGIN;
	wp->docfd = -1;
	wp->timeout = -1;
	wp->dir = NULL;
	wp->authType = NULL;
	wp->protocol = NULL;
	wp->protoVersion = NULL;
	wp->password = NULL;
	wp->userName = NULL;
#ifdef DIGEST_ACCESS_SUPPORT
	wp->realm = NULL;
	wp->nonce = NULL;
	wp->digest = NULL;
	wp->uri = NULL;
	wp->opaque = NULL;
	wp->nc = NULL;
	wp->cnonce = NULL;
	wp->qop = NULL;
#endif
#ifdef WEBS_SSL_SUPPORT
	wp->wsp = NULL;
#endif

	ringqOpen(&wp->header, WEBS_HEADER_BUFINC, WEBS_MAX_HEADER);

/*
 *	Create storage for the CGI variables. We supply the symbol tables for
 *	both the CGI variables and for the global functions. The function table
 *	is common to all webs instances (ie. all browsers)
 */
	wp->cgiVars = symOpen(WEBS_SYM_INIT);

	return wid;
}

/******************************************************************************/
/*
 *	Free a webs structure
 */

void websFree(webs_t wp)
{
	a_assert(websValid(wp));

	if (wp->path)
		bfree(B_L, wp->path);
	if (wp->url)
		bfree(B_L, wp->url);
	if (wp->host)
		bfree(B_L, wp->host);
	if (wp->lpath)
		bfree(B_L, wp->lpath);
	if (wp->query)
		bfree(B_L, wp->query);
	if (wp->decodedQuery)
		bfree(B_L, wp->decodedQuery);
	if (wp->authType)
		bfree(B_L, wp->authType);
	if (wp->password)
		bfree(B_L, wp->password);
	if (wp->userName)
		bfree(B_L, wp->userName);
	if (wp->cookie)
		bfree(B_L, wp->cookie);
	if (wp->userAgent)
		bfree(B_L, wp->userAgent);
	if (wp->dir)
		bfree(B_L, wp->dir);
	if (wp->protocol)
		bfree(B_L, wp->protocol);
	if (wp->protoVersion)
		bfree(B_L, wp->protoVersion);
	if (wp->cgiStdin)
		bfree(B_L, wp->cgiStdin);


#ifdef DIGEST_ACCESS_SUPPORT
	if (wp->realm)
		bfree(B_L, wp->realm);
	if (wp->uri)
		bfree(B_L, wp->uri);
	if (wp->digest)
		bfree(B_L, wp->digest);
	if (wp->opaque)
		bfree(B_L, wp->opaque);
	if (wp->nonce)
		bfree(B_L, wp->nonce);
	if (wp->nc)
		bfree(B_L, wp->nc);
	if (wp->cnonce)
		bfree(B_L, wp->cnonce);
	if (wp->qop)
		bfree(B_L, wp->qop);
#endif
#ifdef WEBS_SSL_SUPPORT
	websSSLFree(wp->wsp);
#endif
	symClose(wp->cgiVars);

	if (wp->header.buf) {
		ringqClose(&wp->header);
	}

	websMax = hFree((void***) &webs, wp->wid);
	bfree(B_L, wp);
	a_assert(websMax >= 0);
}

/******************************************************************************/
/*
 *	Return the server address
 */

char_t *websGetHost()
{
	return websHost;
}

/******************************************************************************/
/*
 *	Return the the url to access the server. (ip address)
 */

char_t *websGetIpaddrUrl()
{
	return websIpaddrUrl;
}

/******************************************************************************/
/*
 *	Return the server address
 */

char_t *websGetHostUrl()
{
	return websHostUrl;
}

/******************************************************************************/
/*
 *	Return the listen port
 */

int websGetPort()
{
	return websPort;
}

/******************************************************************************/
/*
 *	Get the number of bytes to write
 */

int websGetRequestBytes(webs_t wp)
{
	a_assert(websValid(wp));

	return wp->numbytes;
}

/******************************************************************************/
/*
 *	Get the directory for this request
 */

char_t *websGetRequestDir(webs_t wp)
{
	a_assert(websValid(wp));

	if (wp->dir == NULL) {
		return T("");
	}

	return wp->dir;
}

/******************************************************************************/
/*
 *	Get the flags for this request
 */

int websGetRequestFlags(webs_t wp)
{
	a_assert(websValid(wp));

	return wp->flags;
}

/******************************************************************************/
/*
 *	Return the IP address
 */

char_t *websGetRequestIpaddr(webs_t wp)
{
	a_assert(websValid(wp));

	return wp->ipaddr;
}

/******************************************************************************/
/*
 *	Set the local path for the request
 */

char_t *websGetRequestLpath(webs_t wp)
{
	a_assert(websValid(wp));

#ifdef WEBS_PAGE_ROM
	return wp->path;
#else
	return wp->lpath;
#endif
}

/******************************************************************************/
/*
 *	Get the path for this request
 */

char_t *websGetRequestPath(webs_t wp)
{
	a_assert(websValid(wp));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷综合久久久久中文一区二区 | 88在线观看91蜜桃国自产| 欧美岛国在线观看| 亚洲精品中文在线观看| 韩国精品主播一区二区在线观看| 91麻豆产精品久久久久久| 久久综合国产精品| 免费成人在线观看| 色呦呦日韩精品| 欧美激情一区二区在线| 裸体在线国模精品偷拍| 欧美日韩免费电影| 亚洲一区二区三区四区在线观看| www.在线欧美| 久久综合视频网| 激情六月婷婷久久| 久久这里只有精品首页| 久久不见久久见免费视频7 | 欧美亚洲动漫另类| 亚洲日本一区二区| 99久久精品免费看国产免费软件| 国产亚洲成年网址在线观看| 麻豆国产精品一区二区三区| 日韩亚洲国产中文字幕欧美| 日韩av在线免费观看不卡| 欧美精品777| 五月天激情小说综合| 欧美日韩国产另类一区| 亚洲福利一区二区| 欧美日韩国产免费一区二区 | 91麻豆精品国产综合久久久久久| 亚洲精品大片www| 色婷婷综合久久| 亚洲综合精品久久| 精品视频1区2区| 日韩电影网1区2区| 精品欧美一区二区久久| 国产一区二区美女诱惑| 中文字幕成人网| 99久久婷婷国产综合精品| 国产精品不卡视频| 欧美午夜不卡在线观看免费| 亚洲一二三区不卡| 欧美一区二区三区在线| 狠狠v欧美v日韩v亚洲ⅴ| 久久伊人蜜桃av一区二区| 国产69精品久久99不卡| 最新欧美精品一区二区三区| 91久久久免费一区二区| 日韩精品午夜视频| 337p日本欧洲亚洲大胆精品| 成人免费高清视频在线观看| 亚洲综合在线视频| 日韩欧美一级特黄在线播放| 成人一区二区三区中文字幕| 夜夜操天天操亚洲| 欧美精品一区二区三区蜜桃视频 | 成人福利视频在线看| 亚洲大片免费看| 欧美成人精品高清在线播放| av亚洲精华国产精华| 午夜精品久久久久久久久久久| 亚洲精品在线免费观看视频| 99精品桃花视频在线观看| 午夜激情一区二区三区| 国产日韩欧美一区二区三区乱码 | 亚洲3atv精品一区二区三区| 精品第一国产综合精品aⅴ| 国产精品一品二品| 亚洲第一主播视频| 久久综合资源网| 在线亚洲一区二区| 国产大陆a不卡| 日韩极品在线观看| 亚洲欧美在线视频| 欧美一级生活片| 色综合久久中文综合久久97| 韩日欧美一区二区三区| 亚洲韩国精品一区| 久久久国产精品麻豆| 欧美丰满一区二区免费视频| 成人av影院在线| 国产综合色精品一区二区三区| 亚洲二区在线视频| 亚洲图片欧美激情| wwww国产精品欧美| 91精品国产黑色紧身裤美女| 色综合天天在线| 国产成人高清视频| 精品亚洲国产成人av制服丝袜| 亚洲制服丝袜一区| 亚洲裸体在线观看| 中文字幕av一区二区三区免费看| 欧美一区二区三区影视| 欧美性色欧美a在线播放| 成人爱爱电影网址| 国产成人一区在线| 国产伦理精品不卡| 韩国成人精品a∨在线观看| 天天色图综合网| 亚洲资源中文字幕| 亚洲高清视频中文字幕| 亚洲私人黄色宅男| 中文字幕一区二区三区四区不卡| 国产午夜精品久久| 久久精品一区二区三区av| 精品精品国产高清a毛片牛牛| 欧美一区二区免费观在线| 欧美日韩国产在线观看| 欧美中文字幕一二三区视频| 色综合色综合色综合色综合色综合| 成人三级伦理片| av电影在线不卡| 99麻豆久久久国产精品免费| 成人app软件下载大全免费| 粉嫩绯色av一区二区在线观看| 国产99精品在线观看| caoporm超碰国产精品| 色av成人天堂桃色av| 欧美日韩一区二区三区四区五区| 欧美精品 国产精品| 欧美久久久影院| 日韩欧美一级二级三级久久久| 精品999在线播放| 国产欧美一区视频| 亚洲男人的天堂在线aⅴ视频| 亚洲国产精品久久久久婷婷884 | 国产精品一区三区| 成人精品高清在线| 91久久精品一区二区三区| 欧美无砖专区一中文字| 日韩一区二区在线免费观看| 欧美精品一区二区高清在线观看| 久久综合九色综合97婷婷| 国产精品久久久久久久久动漫| 亚洲精选在线视频| 免费成人美女在线观看| 久久se精品一区精品二区| 成人小视频在线| 欧美裸体一区二区三区| 国产偷v国产偷v亚洲高清| 亚洲精品免费在线播放| 久久超碰97中文字幕| 91在线观看高清| 日韩一级大片在线观看| 亚洲欧美另类综合偷拍| 美女国产一区二区| 成人在线视频一区二区| 色婷婷国产精品综合在线观看| 欧美一区二区三区喷汁尤物| 欧美精品一区在线观看| 一区二区三区四区中文字幕| 亚洲高清免费视频| 国产在线精品不卡| 一本一道久久a久久精品| 欧美一区二区大片| 国产精品久久综合| 免费的成人av| 色女孩综合影院| 久久亚洲精精品中文字幕早川悠里| 中文字幕日本乱码精品影院| 欧美aa在线视频| 97se狠狠狠综合亚洲狠狠| 精品88久久久久88久久久| 亚洲国产日日夜夜| 波多野结衣一区二区三区| 欧美mv和日韩mv的网站| 亚洲一区二区三区激情| 成人亚洲精品久久久久软件| 欧美理论在线播放| 亚洲女人小视频在线观看| 国产精品一区免费视频| 欧美一二三区在线| 婷婷亚洲久悠悠色悠在线播放| 成人污污视频在线观看| 欧美r级在线观看| 日韩精品乱码免费| 欧美亚洲综合在线| **网站欧美大片在线观看| 国产精品一区免费在线观看| 日韩精品中文字幕在线一区| 亚洲6080在线| 欧洲国内综合视频| 亚洲嫩草精品久久| 91视频一区二区三区| 亚洲丝袜另类动漫二区| 91在线你懂得| 亚洲欧洲在线观看av| 成人一区二区视频| 国产精品蜜臀av| 成人一级片网址| 国产精品久久久久永久免费观看 | 一区二区三区免费在线观看| 91色九色蝌蚪| ●精品国产综合乱码久久久久| av在线播放不卡| 国产精品免费视频观看| www.亚洲国产| 亚洲免费av在线| 欧美日本在线播放|