网络流量采集及分析软件

源代码在线查看: quote.c

软件大小: 968 K
上传用户: c_word
关键词: 网络流量 分析软件 采集
下载地址: 免注册下载 普通下载 VIP

相关代码

								/*! \file   quote.c								  Based on webfs Copyright (C) 1999-2001  Gerd Knorr								  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 with				  the Debian GNU/Linux distribution in file /usr/share/common-licenses/GPL;				  if not, write to the Free Software Foundation, Inc., 59 Temple Place,				  Suite 330, Boston, MA  02111-1307  USA								  Description:				  html quoting/unquoting functions								  $Id: quote.c,v 1.1.1.1 2004/12/23 05:52:34 s_zander Exp $								*/								#include "config.h"								#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 				#include 								#include "httpd.h"																static char do_quote[256];								void init_quote(void)				{				    int i;								    for (i = 0; i < 256; i++) {				        do_quote[i] = (isalnum(i) || ispunct(i)) ? 0 : 1;				    }				    do_quote['+'] = 1;				    do_quote['#'] = 1;				    do_quote['%'] = 1;				}								char *quote(unsigned char *path, int maxlength)				{				    static unsigned char buf[2048]; /* FIXME: threads break this... */				    int i,j,n=strlen(path);								    if (n > maxlength) {				        n = maxlength;				    }								    for (i=0, j=0; i				        if (!do_quote[path[i]]) {				            buf[j] = path[i];				            continue;				        }				        sprintf(buf+j,"%%%02x",path[i]);				        j += 2;				    }				    buf[j] = 0;				    return buf;				}								static int unhex(unsigned char c)				{				    if (c < '@') {				        return c - '0';				    }				    return (c & 0x0f) + 9;				}								/* handle %hex quoting, also split path / querystring */				void unquote(unsigned char *path, unsigned char *qs, unsigned char *src)				{				    int q;				    unsigned char *dst;								    q=0;				    dst = path;				    while (src[0] != 0) {				        if (!q && *src == '?') {				            q = 1;				            *dst = 0;				            dst = qs;				            src++;				            continue;				        }				        if (q && *src == '+') {				            *dst = ' ';				        } else if ((*src == '%') && isxdigit(src[1]) && isxdigit(src[2])) {				            *dst = (unhex(src[1]) 				            src += 2;				        } else {				            *dst = *src;				        }				        dst++;				        src++;				    }				    *dst = 0;				}								/* handle %hex quoting */				void unquote2(unsigned char *dst, unsigned char *src)				{				    while (src[0] != 0) {				        if (*src == '+') {				            *dst = ' ';				        } else if ((*src == '%') && isxdigit(src[1]) && isxdigit(src[2])) {				            *dst = (unhex(src[1]) 				            src += 2;				        } else {				            *dst = *src;				        }				        dst++;				        src++;				    }				    *dst = 0;								}							

相关资源