Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apr_escape.h
Go to the documentation of this file.
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
20 #ifndef APR_ESCAPE_H
21 #define APR_ESCAPE_H
22 #include "apu.h"
23 #include "apr_general.h"
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
34 /* Simple escape/unescape functions.
35  *
36  * The design goal of these functions are:
37  *
38  * - Avoid unnecessary work.
39  *
40  * In most cases the strings passed in do not need to be escaped at all. In
41  * these cases the original string will be returned.
42  *
43  * - Lowest possible memory footprint.
44  *
45  * The amount of memory allocated for a given encoding is calculated based
46  * on the exact amount of memory needed, and not the theoretical worst case
47  * scenario.
48  *
49  */
50 
56 #define APR_ESCAPE_STRING (-1)
57 
61 #define APR_ESCAPE_LDAP_DN (0x01)
62 
66 #define APR_ESCAPE_LDAP_FILTER (0x02)
67 
71 #define APR_ESCAPE_LDAP_ALL (0x03)
72 
85 APR_DECLARE(apr_status_t) apr_escape_shell(char *escaped, const char *str,
86  apr_ssize_t slen, apr_size_t *len);
87 
100 APR_DECLARE(const char *) apr_pescape_shell(apr_pool_t *p, const char *str)
101  __attribute__((nonnull(1)));
102 
120 APR_DECLARE(apr_status_t) apr_unescape_url(char *escaped, const char *url,
121  apr_ssize_t slen, const char *forbid, const char *reserved, int plus,
122  apr_size_t *len);
123 
140 APR_DECLARE(const char *) apr_punescape_url(apr_pool_t *p, const char *url,
141  const char *forbid, const char *reserved, int plus)
142  __attribute__((nonnull(1)));
143 
155  const char *str, apr_ssize_t slen, apr_size_t *len);
156 
166  const char *str) __attribute__((nonnull(1)));
167 
187 APR_DECLARE(apr_status_t) apr_escape_path(char *escaped, const char *path,
188  apr_ssize_t slen, int partial, apr_size_t *len);
189 
208 APR_DECLARE(const char *) apr_pescape_path(apr_pool_t *p, const char *str,
209  int partial) __attribute__((nonnull(1)));
210 
222 APR_DECLARE(apr_status_t) apr_escape_urlencoded(char *escaped, const char *str,
223  apr_ssize_t slen, apr_size_t *len);
224 
235  const char *str) __attribute__((nonnull(1)));
236 
253 APR_DECLARE(apr_status_t) apr_escape_entity(char *escaped, const char *str,
254  apr_ssize_t slen, int toasc, apr_size_t *len);
255 
267 APR_DECLARE(const char *) apr_pescape_entity(apr_pool_t *p, const char *str,
268  int toasc) __attribute__((nonnull(1)));
269 
285 APR_DECLARE(apr_status_t) apr_unescape_entity(char *unescaped, const char *str,
286  apr_ssize_t slen, apr_size_t *len);
287 
300 APR_DECLARE(const char *) apr_punescape_entity(apr_pool_t *p, const char *str)
301  __attribute__((nonnull(1)));
302 
322 APR_DECLARE(apr_status_t) apr_escape_echo(char *escaped, const char *str,
323  apr_ssize_t slen, int quote, apr_size_t *len);
324 
342 APR_DECLARE(const char *) apr_pescape_echo(apr_pool_t *p, const char *str,
343  int quote);
344 
354 APR_DECLARE(apr_status_t) apr_escape_hex(char *dest, const void *src,
355  apr_size_t srclen, int colon, apr_size_t *len);
356 
367 APR_DECLARE(const char *) apr_pescape_hex(apr_pool_t *p, const void *src,
368  apr_size_t slen, int colon) __attribute__((nonnull(1)));
369 
380 APR_DECLARE(apr_status_t) apr_unescape_hex(void *dest, const char *str,
381  apr_ssize_t slen, int colon, apr_size_t *len);
382 
394 APR_DECLARE(const void *) apr_punescape_hex(apr_pool_t *p, const char *str,
395  int colon, apr_size_t *len);
396 
408 APR_DECLARE(apr_status_t) apr_escape_ldap(char *dest, const void *src,
409  apr_ssize_t srclen, int flags, apr_size_t *len);
410 
423 APR_DECLARE(const char *) apr_pescape_ldap(apr_pool_t *p, const void *src,
424  apr_ssize_t slen, int flags) __attribute__((nonnull(1)));
425 
427 #ifdef __cplusplus
428 }
429 #endif
430 
431 #endif /* !APR_ESCAPE_H */
size_t apr_size_t
Definition: apr.h:375
const char * apr_pescape_shell(apr_pool_t *p, const char *str) __attribute__((nonnull(1)))
const char * apr_pescape_path_segment(apr_pool_t *p, const char *str) __attribute__((nonnull(1)))
const char * apr_pescape_ldap(apr_pool_t *p, const void *src, apr_ssize_t slen, int flags) __attribute__((nonnull(1)))
apr_status_t apr_escape_path(char *escaped, const char *path, apr_ssize_t slen, int partial, apr_size_t *len)
const char * apr_pescape_hex(apr_pool_t *p, const void *src, apr_size_t slen, int colon) __attribute__((nonnull(1)))
apr_status_t apr_escape_ldap(char *dest, const void *src, apr_ssize_t srclen, int flags, apr_size_t *len)
apr_status_t apr_escape_echo(char *escaped, const char *str, apr_ssize_t slen, int quote, apr_size_t *len)
const void * apr_punescape_hex(apr_pool_t *p, const char *str, int colon, apr_size_t *len)
apr_status_t apr_escape_urlencoded(char *escaped, const char *str, apr_ssize_t slen, apr_size_t *len)
apr_status_t apr_unescape_hex(void *dest, const char *str, apr_ssize_t slen, int colon, apr_size_t *len)
apr_status_t apr_unescape_url(char *escaped, const char *url, apr_ssize_t slen, const char *forbid, const char *reserved, int plus, apr_size_t *len)
APR Miscellaneous library routines.
const char * apr_punescape_url(apr_pool_t *p, const char *url, const char *forbid, const char *reserved, int plus) __attribute__((nonnull(1)))
apr_status_t apr_unescape_entity(char *unescaped, const char *str, apr_ssize_t slen, apr_size_t *len)
const char * apr_pescape_echo(apr_pool_t *p, const char *str, int quote)
apr_status_t apr_escape_shell(char *escaped, const char *str, apr_ssize_t slen, apr_size_t *len)
dav_error * src
Definition: mod_dav.h:186
char * path
Definition: apr_arch_dso.h:40
proxy_worker proxy_server_conf char * url
Definition: mod_proxy.h:611
apr_pool_t * p
const char * apr_punescape_entity(apr_pool_t *p, const char *str) __attribute__((nonnull(1)))
const char * apr_pescape_entity(apr_pool_t *p, const char *str, int toasc) __attribute__((nonnull(1)))
apr_status_t apr_escape_path_segment(char *escaped, const char *str, apr_ssize_t slen, apr_size_t *len)
#define APR_DECLARE(x)
Definition: macros.h:6
ssize_t apr_ssize_t
Definition: apr.h:376
dav_buffer const char * str
Definition: mod_dav.h:461
#define __attribute__(__x)
Definition: apr.h:63
apr_status_t apr_escape_hex(char *dest, const void *src, apr_size_t srclen, int colon, apr_size_t *len)
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
int apr_status_t
Definition: apr_errno.h:44
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1346
apr_status_t apr_escape_entity(char *escaped, const char *str, apr_ssize_t slen, int toasc, apr_size_t *len)
const char * apr_pescape_urlencoded(apr_pool_t *p, const char *str) __attribute__((nonnull(1)))
const char * apr_pescape_path(apr_pool_t *p, const char *str, int partial) __attribute__((nonnull(1)))