/[hydra]/hydra/src/escape.h
ViewVC logotype

Annotation of /hydra/src/escape.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Sep 21 13:53:16 2002 UTC (19 years, 2 months ago) by nmav
Branch point for: boas, MAIN
File MIME type: text/plain
Initial revision

1 nmav 1.1 /*
2     * Boa, an http server
3     * Copyright (C) 1995 Paul Phillips <paulp@go2net.com>
4     * Copyright (C) 2001 Jon Nelson <jnelson@boa.org>
5     * Copyright (C) 2001 Larry Doolittle <ldoolitt@boa.org>
6    
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 1, or (at your option)
10     * any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20     *
21     */
22    
23     /* $Id: escape.h,v 1.18 2002/01/31 03:12:21 jnelson Exp $ */
24    
25     #include "config.h"
26    
27     /* Highest character number that can possibly be passed through un-escaped */
28     #define NEEDS_ESCAPE_BITS 128
29    
30     #ifndef NEEDS_ESCAPE_SHIFT
31     #define NEEDS_ESCAPE_SHIFT 5 /* 1 << 5 is 32 bits */
32     #endif
33    
34     #define NEEDS_ESCAPE_WORD_LENGTH (1<<NEEDS_ESCAPE_SHIFT)
35    
36     #define NEEDS_ESCAPE_INDEX(c) ((c)>>NEEDS_ESCAPE_SHIFT)
37    
38     /* Assume variable shift is fast, otherwise this could be a table lookup */
39     #define NEEDS_ESCAPE_MASK(c) (1<<((c)&(NEEDS_ESCAPE_WORD_LENGTH - 1)))
40    
41     /* Newer compilers could use an inline function.
42     * This macro works great, as long as you pass unsigned int or unsigned char.
43     */
44     #define needs_escape(c) ((c)>=NEEDS_ESCAPE_BITS || _needs_escape[NEEDS_ESCAPE_INDEX(c)]&NEEDS_ESCAPE_MASK(c))
45    
46     extern unsigned long _needs_escape[(NEEDS_ESCAPE_BITS+NEEDS_ESCAPE_WORD_LENGTH-1)/NEEDS_ESCAPE_WORD_LENGTH];
47     void build_needs_escape(void);

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26