HTP  0.3
utf8_decoder.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (c) 2009-2010, Open Information Security Foundation
3  * Copyright (c) 2009-2012, Qualys, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * * Neither the name of the Qualys, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  ***************************************************************************/
31 
37 #ifndef _UTF8_DECODER_H
38 #define _UTF8_DECODER_H
39 
40 /* HTP changes:
41  *
42  * - Changed the name of the function from "decode" to "utf8_decode"
43  * - Created a separate header file
44  * - Copied the license from the web page
45  * - Created a copy of the data and function "utf8_decode_allow_overlong", which
46  * does not treat overlong characters as invalid.
47  */
48 
49 /*
50 Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
51 
52 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
53 and associated documentation files (the "Software"), to deal in the Software without restriction,
54 including without limitation the rights to use, copy, modify, merge, publish, distribute,
55 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
56 furnished to do so, subject to the following conditions:
57 
58 The above copyright notice and this permission notice shall be included in all copies or
59 substantial portions of the Software.
60 
61 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
62 NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
63 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
64 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 */
67 
68 #include <stdint.h>
69 
70 #define HTP_UTF8_ACCEPT 0
71 #define HTP_UTF8_REJECT 1
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 uint32_t htp_utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte);
78 uint32_t htp_utf8_decode_allow_overlong(uint32_t* state, uint32_t* codep, uint32_t byte);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif /* _UTF8_DECODER_H */
85