Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / msc_util.h
1 /*
2  * ModSecurity for Apache 2.x, http://www.modsecurity.org/
3  * Copyright (c) 2004-2009 Breach Security, Inc. (http://www.breach.com/)
4  *
5  * This product is released under the terms of the General Public Licence,
6  * version 2 (GPLv2). Please refer to the file LICENSE (included with this
7  * distribution) which contains the complete text of the licence.
8  *
9  * There are special exceptions to the terms and conditions of the GPL
10  * as it is applied to this software. View the full text of the exception in
11  * file MODSECURITY_LICENSING_EXCEPTION in the directory of this software
12  * distribution.
13  *
14  * If any of the files related to licensing are missing or if you have any
15  * other questions related to licensing please contact Breach Security, Inc.
16  * directly using the email address support@breach.com.
17  *
18  */
19 #ifndef _UTIL_H_
20 #define _UTIL_H_
21
22 #include <sys/types.h>
23 #include <apr_file_info.h>
24
25 #include "modsecurity.h"
26
27 int DSOLOCAL normalise_path_inplace(unsigned char *input, int len, int win, int *changed);
28
29 int DSOLOCAL parse_boolean(const char *input);
30
31 int DSOLOCAL parse_name_eq_value(apr_pool_t *mp, const char *input, char **name, char **value);
32
33 char DSOLOCAL *url_encode(apr_pool_t *mp, char *input, unsigned int input_len, int *changed);
34
35 char DSOLOCAL *strnurlencat(char *destination, char *source, unsigned int maxlen);
36
37 char DSOLOCAL *file_dirname(apr_pool_t *p, const char *filename);
38
39 char DSOLOCAL *file_basename(apr_pool_t *p, const char *filename);
40
41 int DSOLOCAL hex2bytes_inplace(unsigned char *data, int len);
42
43 char DSOLOCAL *bytes2hex(apr_pool_t *pool, unsigned char *data, int len);
44
45 int DSOLOCAL is_token_char(unsigned char c);
46
47 int DSOLOCAL remove_lf_crlf_inplace(char *text);
48
49 unsigned char DSOLOCAL x2c(unsigned char *what);
50
51 unsigned char DSOLOCAL xsingle2c(unsigned char *what);
52
53 char DSOLOCAL *guess_tmp_dir(apr_pool_t *p);
54
55 char DSOLOCAL *current_logtime(apr_pool_t *mp);
56
57 char DSOLOCAL *current_filetime(apr_pool_t *mp);
58
59 int DSOLOCAL msc_mkstemp_ex(char *template, int mode);
60
61 int DSOLOCAL msc_mkstemp(char *template);
62
63 char DSOLOCAL *strtolower_inplace(unsigned char *str);
64
65 unsigned char DSOLOCAL *c2x(unsigned what, unsigned char *where);
66
67 char DSOLOCAL *log_escape(apr_pool_t *p, const char *text);
68
69 char DSOLOCAL *log_escape_nq(apr_pool_t *p, const char *text);
70
71 char DSOLOCAL *log_escape_ex(apr_pool_t *p, const char *text, unsigned long int text_length);
72
73 char DSOLOCAL *log_escape_nq_ex(apr_pool_t *p, const char *text, unsigned long int text_length);
74
75 char DSOLOCAL *log_escape_header_name(apr_pool_t *p, const char *text);
76
77 char DSOLOCAL *log_escape_hex(apr_pool_t *mp, const unsigned char *text, unsigned long int text_length);
78
79 char DSOLOCAL *log_escape_raw(apr_pool_t *mp, const unsigned char *text, unsigned long int text_length);
80
81 char DSOLOCAL *_log_escape(apr_pool_t *p, const unsigned char *input,
82     unsigned long int input_length, int escape_quotes, int escape_colon);
83
84 int DSOLOCAL js_decode_nonstrict_inplace(unsigned char *input, long int input_len);
85
86 int DSOLOCAL urldecode_uni_nonstrict_inplace_ex(unsigned char *input, long int input_length, int * changed);
87
88 int DSOLOCAL urldecode_nonstrict_inplace_ex(unsigned char *input, long int input_length, int *invalid_count, int *changed);
89
90 int DSOLOCAL html_entities_decode_inplace(apr_pool_t *mp, unsigned char *input, int len);
91
92 int DSOLOCAL ansi_c_sequences_decode_inplace(unsigned char *input, int len);
93
94 char DSOLOCAL *modsec_build(apr_pool_t *mp);
95
96 int DSOLOCAL is_empty_string(const char *string);
97
98 char DSOLOCAL *resolve_relative_path(apr_pool_t *pool, const char *parent_filename, const char *filename);
99
100 int DSOLOCAL css_decode_inplace(unsigned char *input, long int input_len);
101
102 apr_fileperms_t DSOLOCAL mode2fileperms(int mode);
103
104 #endif