comparison src/core/ngx_string.c @ 328:390b8f8309d6 NGINX_0_6_8

nginx 0.6.8 *) Change: now nginx tries to set the "worker_priority", "worker_rlimit_nofile", "worker_rlimit_core", and "worker_rlimit_sigpending" without super-user privileges. *) Change: now nginx escapes space and "%" in request to a mail proxy authentication server. *) Change: now nginx escapes "%" in $memcached_key variable. *) Bugfix: nginx used path relative to configuration prefix for non-absolute configuration file path specified in the "-c" key; bug appeared in 0.6.6. *) Bugfix: nginx did not work on FreeBSD/sparc64.
author Igor Sysoev <http://sysoev.ru>
date Mon, 20 Aug 2007 00:00:00 +0400
parents d16d691432c9
children 10cc350ed8a1
comparison
equal deleted inserted replaced
327:be18d26e067c 328:390b8f8309d6
57 * %[0][width][u][x|X]L int64_t/uint64_t 57 * %[0][width][u][x|X]L int64_t/uint64_t
58 * %[0][width|m][u][x|X]A ngx_atomic_int_t/ngx_atomic_uint_t 58 * %[0][width|m][u][x|X]A ngx_atomic_int_t/ngx_atomic_uint_t
59 * %P ngx_pid_t 59 * %P ngx_pid_t
60 * %M ngx_msec_t 60 * %M ngx_msec_t
61 * %r rlim_t 61 * %r rlim_t
62 * %p pointer 62 * %p void *
63 * %V pointer to ngx_str_t 63 * %V ngx_str_t *
64 * %v ngx_variable_value_t *
64 * %s null-terminated string 65 * %s null-terminated string
65 * %Z '\0' 66 * %Z '\0'
66 * %N '\n' 67 * %N '\n'
67 * %c char 68 * %c char
68 * %% % 69 * %% %
115 uint32_t ui32; 116 uint32_t ui32;
116 int64_t i64; 117 int64_t i64;
117 uint64_t ui64; 118 uint64_t ui64;
118 ngx_msec_t ms; 119 ngx_msec_t ms;
119 ngx_uint_t width, sign, hexadecimal, max_width; 120 ngx_uint_t width, sign, hexadecimal, max_width;
120 ngx_variable_value_t *v; 121 ngx_str_t *v;
122 ngx_variable_value_t *vv;
121 static u_char hex[] = "0123456789abcdef"; 123 static u_char hex[] = "0123456789abcdef";
122 static u_char HEX[] = "0123456789ABCDEF"; 124 static u_char HEX[] = "0123456789ABCDEF";
123 125
124 if (max == 0) { 126 if (max == 0) {
125 return buf; 127 return buf;
186 188
187 189
188 switch (*fmt) { 190 switch (*fmt) {
189 191
190 case 'V': 192 case 'V':
191 v = va_arg(args, ngx_variable_value_t *); 193 v = va_arg(args, ngx_str_t *);
192 194
193 len = v->len; 195 len = v->len;
194 len = (buf + len < last) ? len : (size_t) (last - buf); 196 len = (buf + len < last) ? len : (size_t) (last - buf);
195 197
196 buf = ngx_cpymem(buf, v->data, len); 198 buf = ngx_cpymem(buf, v->data, len);
199 fmt++;
200
201 continue;
202
203 case 'v':
204 vv = va_arg(args, ngx_variable_value_t *);
205
206 len = vv->len;
207 len = (buf + len < last) ? len : (size_t) (last - buf);
208
209 buf = ngx_cpymem(buf, vv->data, len);
197 fmt++; 210 fmt++;
198 211
199 continue; 212 continue;
200 213
201 case 's': 214 case 's':
1017 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1030 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1018 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1031 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1019 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1032 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1020 }; 1033 };
1021 1034
1022 /* " ", """, "%", "'", %00-%1F, %7F-%FF */ 1035 /* " ", "#", """, "%", "'", %00-%1F, %7F-%FF */
1023 1036
1024 static uint32_t html[] = { 1037 static uint32_t html[] = {
1025 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1038 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1026 1039
1027 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ 1040 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
1037 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1050 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1038 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1051 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1039 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1052 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1040 }; 1053 };
1041 1054
1042 /* " ", """, "'", %00-%1F, %7F-%FF */ 1055 /* " ", """, "%", "'", %00-%1F, %7F-%FF */
1043 1056
1044 static uint32_t refresh[] = { 1057 static uint32_t refresh[] = {
1045 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1058 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1046 1059
1047 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ 1060 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
1048 0x00000085, /* 0000 0000 0000 0000 0000 0000 1000 0101 */ 1061 0x000000a5, /* 0000 0000 0000 0000 0000 0000 1010 0101 */
1049 1062
1050 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */ 1063 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
1051 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ 1064 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
1052 1065
1053 /* ~}| {zyx wvut srqp onml kjih gfed cba` */ 1066 /* ~}| {zyx wvut srqp onml kjih gfed cba` */
1057 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1070 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1058 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1071 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1059 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1072 0xffffffff /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1060 }; 1073 };
1061 1074
1062 /* " ", %00-%1F */ 1075 /* " ", "%", %00-%1F */
1063 1076
1064 static uint32_t memcached[] = { 1077 static uint32_t memcached[] = {
1065 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */ 1078 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
1066 1079
1067 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */ 1080 /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
1068 0x00000001, /* 0000 0000 0000 0000 0000 0000 0000 0001 */ 1081 0x00000021, /* 0000 0000 0000 0000 0000 0000 0010 0001 */
1069 1082
1070 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */ 1083 /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
1071 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ 1084 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
1072 1085
1073 /* ~}| {zyx wvut srqp onml kjih gfed cba` */ 1086 /* ~}| {zyx wvut srqp onml kjih gfed cba` */
1077 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ 1090 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
1078 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ 1091 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
1079 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */ 1092 0x00000000, /* 0000 0000 0000 0000 0000 0000 0000 0000 */
1080 }; 1093 };
1081 1094
1082 static uint32_t *map[] = { uri, args, html, refresh, memcached }; 1095 /* mail_auth is the same as memcached */
1096
1097 static uint32_t *map[] =
1098 { uri, args, html, refresh, memcached, memcached };
1083 1099
1084 1100
1085 escape = map[type]; 1101 escape = map[type];
1086 1102
1087 if (dst == NULL) { 1103 if (dst == NULL) {