Deleted Added
full compact
gen_test_char.c (302408) gen_test_char.c (362181)
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

--- 18 unchanged lines hidden (view full) ---

27 * To make that more efficient we encode a lookup table.
28 */
29#define T_ESCAPE_SHELL_CMD (0x01)
30#define T_ESCAPE_PATH_SEGMENT (0x02)
31#define T_OS_ESCAPE_PATH (0x04)
32#define T_ESCAPE_ECHO (0x08)
33#define T_ESCAPE_URLENCODED (0x10)
34#define T_ESCAPE_XML (0x20)
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

--- 18 unchanged lines hidden (view full) ---

27 * To make that more efficient we encode a lookup table.
28 */
29#define T_ESCAPE_SHELL_CMD (0x01)
30#define T_ESCAPE_PATH_SEGMENT (0x02)
31#define T_OS_ESCAPE_PATH (0x04)
32#define T_ESCAPE_ECHO (0x08)
33#define T_ESCAPE_URLENCODED (0x10)
34#define T_ESCAPE_XML (0x20)
35#define T_ESCAPE_LDAP_DN (0x40)
36#define T_ESCAPE_LDAP_FILTER (0x80)
35
36int main(int argc, char *argv[])
37{
38 unsigned c;
39 unsigned char flags;
40
41 printf("/* this file is automatically generated by gen_test_char, "
42 "do not edit. \"make include/private/apr_escape_test_char.h\" to regenerate. */\n"
43 "#define T_ESCAPE_SHELL_CMD (%u)\n"
44 "#define T_ESCAPE_PATH_SEGMENT (%u)\n"
45 "#define T_OS_ESCAPE_PATH (%u)\n"
46 "#define T_ESCAPE_ECHO (%u)\n"
47 "#define T_ESCAPE_URLENCODED (%u)\n"
48 "#define T_ESCAPE_XML (%u)\n"
37
38int main(int argc, char *argv[])
39{
40 unsigned c;
41 unsigned char flags;
42
43 printf("/* this file is automatically generated by gen_test_char, "
44 "do not edit. \"make include/private/apr_escape_test_char.h\" to regenerate. */\n"
45 "#define T_ESCAPE_SHELL_CMD (%u)\n"
46 "#define T_ESCAPE_PATH_SEGMENT (%u)\n"
47 "#define T_OS_ESCAPE_PATH (%u)\n"
48 "#define T_ESCAPE_ECHO (%u)\n"
49 "#define T_ESCAPE_URLENCODED (%u)\n"
50 "#define T_ESCAPE_XML (%u)\n"
51 "#define T_ESCAPE_LDAP_DN (%u)\n"
52 "#define T_ESCAPE_LDAP_FILTER (%u)\n"
49 "\n"
50 "static const unsigned char test_char_table[256] = {",
51 T_ESCAPE_SHELL_CMD,
52 T_ESCAPE_PATH_SEGMENT,
53 T_OS_ESCAPE_PATH,
54 T_ESCAPE_ECHO,
55 T_ESCAPE_URLENCODED,
53 "\n"
54 "static const unsigned char test_char_table[256] = {",
55 T_ESCAPE_SHELL_CMD,
56 T_ESCAPE_PATH_SEGMENT,
57 T_OS_ESCAPE_PATH,
58 T_ESCAPE_ECHO,
59 T_ESCAPE_URLENCODED,
56 T_ESCAPE_XML);
60 T_ESCAPE_XML,
61 T_ESCAPE_LDAP_DN,
62 T_ESCAPE_LDAP_FILTER);
57
58 for (c = 0; c < 256; ++c) {
59 flags = 0;
60 if (c % 20 == 0)
61 printf("\n ");
62
63 /* escape_shell_cmd */
64#ifdef NEED_ENHANCED_ESCAPES

--- 36 unchanged lines hidden (view full) ---

101 if (c && (!isprint(c) || c == '"' || c == '\\' || iscntrl(c))) {
102 flags |= T_ESCAPE_ECHO;
103 }
104
105 if (strchr("<>&\"", c)) {
106 flags |= T_ESCAPE_XML;
107 }
108
63
64 for (c = 0; c < 256; ++c) {
65 flags = 0;
66 if (c % 20 == 0)
67 printf("\n ");
68
69 /* escape_shell_cmd */
70#ifdef NEED_ENHANCED_ESCAPES

--- 36 unchanged lines hidden (view full) ---

107 if (c && (!isprint(c) || c == '"' || c == '\\' || iscntrl(c))) {
108 flags |= T_ESCAPE_ECHO;
109 }
110
111 if (strchr("<>&\"", c)) {
112 flags |= T_ESCAPE_XML;
113 }
114
115 /* LDAP DN escaping (RFC4514) */
116 if (!isprint(c) || strchr("\"+,;<>\\", c)) {
117 flags |= T_ESCAPE_LDAP_DN;
118 }
119
120 /* LDAP filter escaping (RFC4515) */
121 if (!isprint(c) || strchr("*()\\", c)) {
122 flags |= T_ESCAPE_LDAP_FILTER;
123 }
124
109 printf("%u%c", flags, (c < 255) ? ',' : ' ');
110 }
111
112 printf("\n};\n");
113
114 return 0;
115}
125 printf("%u%c", flags, (c < 255) ? ',' : ' ');
126 }
127
128 printf("\n};\n");
129
130 return 0;
131}