Mercurial > hg > nginx
annotate src/core/ngx_string.h @ 784:5a164305b960
fix building by Debian gcc-4.1.2 amd64
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 16 Oct 2006 13:29:52 +0000 |
parents | 400711951595 |
children | eeadc558e86d |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
5 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
6 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #ifndef _NGX_STRING_H_INCLUDED_ |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #define _NGX_STRING_H_INCLUDED_ |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 #include <ngx_config.h> |
100
7ebc8b7fb816
nginx-0.0.1-2003-06-03-19:42:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
98
diff
changeset
|
12 #include <ngx_core.h> |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
13 |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
14 |
19
d7908993fdeb
nginx-0.0.1-2002-12-02-19:09:40 import; resume after 2 months stall
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
15 typedef struct { |
649 | 16 size_t len; |
17 u_char *data; | |
19
d7908993fdeb
nginx-0.0.1-2002-12-02-19:09:40 import; resume after 2 months stall
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
18 } ngx_str_t; |
d7908993fdeb
nginx-0.0.1-2002-12-02-19:09:40 import; resume after 2 months stall
Igor Sysoev <igor@sysoev.ru>
parents:
0
diff
changeset
|
19 |
40
d5d4f3bba6f0
nginx-0.0.1-2002-12-26-10:24:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
20 |
649 | 21 typedef struct { |
22 ngx_str_t key; | |
23 ngx_str_t value; | |
24 } ngx_keyval_t; | |
25 | |
26 | |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
27 #define ngx_string(str) { sizeof(str) - 1, (u_char *) str } |
67
5a7d1aaa1618
nginx-0.0.1-2003-03-11-23:38:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
54
diff
changeset
|
28 #define ngx_null_string { 0, NULL } |
40
d5d4f3bba6f0
nginx-0.0.1-2002-12-26-10:24:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
29 |
d5d4f3bba6f0
nginx-0.0.1-2002-12-26-10:24:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
26
diff
changeset
|
30 |
477 | 31 #define ngx_tolower(c) (u_char) ((c >= 'A' && c <= 'Z') ? (c | 0x20) : c) |
501 | 32 #define ngx_toupper(c) (u_char) ((c >= 'a' && c <= 'z') ? (c & ~0x20) : c) |
477 | 33 |
34 | |
461 | 35 #if (NGX_WIN32) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
36 |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
37 #define ngx_strncasecmp(s1, s2, n) \ |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
38 strnicmp((const char *) s1, (const char *) s2, n) |
292
a472bfb778b3
nginx-0.0.3-2004-03-17-00:26:01 import
Igor Sysoev <igor@sysoev.ru>
parents:
290
diff
changeset
|
39 #define ngx_strcasecmp(s1, s2) \ |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
40 stricmp((const char *) s1, (const char *) s2) |
47
d81326c3b21b
nginx-0.0.1-2003-01-15-10:02:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
41 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
42 #else |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
43 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
44 #define ngx_strncasecmp(s1, s2, n) \ |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
45 strncasecmp((const char *) s1, (const char *) s2, n) |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
46 #define ngx_strcasecmp(s1, s2) \ |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
47 strcasecmp((const char *) s1, (const char *) s2) |
47
d81326c3b21b
nginx-0.0.1-2003-01-15-10:02:27 import
Igor Sysoev <igor@sysoev.ru>
parents:
45
diff
changeset
|
48 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
49 #endif |
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
50 |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
175
diff
changeset
|
51 |
461 | 52 #define ngx_strncmp(s1, s2, n) strncmp((const char *) s1, (const char *) s2, n) |
53 | |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
175
diff
changeset
|
54 |
573 | 55 /* msvc and icc7 compile strcmp() to inline loop */ |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
56 #define ngx_strcmp(s1, s2) strcmp((const char *) s1, (const char *) s2) |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
175
diff
changeset
|
57 |
461 | 58 |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
59 #define ngx_strstr(s1, s2) strstr((const char *) s1, (const char *) s2) |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
60 #define ngx_strlen(s) strlen((const char *) s) |
288
f81d075ad172
nginx-0.0.2-2004-03-14-23:46:25 import
Igor Sysoev <igor@sysoev.ru>
parents:
175
diff
changeset
|
61 |
461 | 62 |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
63 /* |
573 | 64 * msvc and icc7 compile memset() to the inline "rep stos" |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
409
diff
changeset
|
65 * while ZeroMemory() and bzero() are the calls. |
573 | 66 * icc7 may also inline several mov's of a zeroed register for small blocks. |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
67 */ |
515 | 68 #define ngx_memzero(buf, n) (void) memset(buf, 0, n) |
69 #define ngx_memset(buf, c, n) (void) memset(buf, c, n) | |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
70 |
461 | 71 |
583 | 72 #if (NGX_MEMCPY_LIMIT) |
73 | |
74 void *ngx_memcpy(void *dst, void *src, size_t n); | |
75 #define ngx_cpymem(dst, src, n) ((u_char *) ngx_memcpy(dst, src, n)) + (n) | |
76 | |
77 #else | |
78 | |
573 | 79 /* |
80 * gcc3, msvc, and icc7 compile memcpy() to the inline "rep movs". | |
81 * gcc3 compiles memcpy(d, s, 4) to the inline "mov"es. | |
82 * icc8 compile memcpy(d, s, 4) to the inline "mov"es or XMM moves. | |
83 */ | |
515 | 84 #define ngx_memcpy(dst, src, n) (void) memcpy(dst, src, n) |
479 | 85 #define ngx_cpymem(dst, src, n) ((u_char *) memcpy(dst, src, n)) + (n) |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
86 |
583 | 87 #endif |
88 | |
461 | 89 |
573 | 90 #if ( __INTEL_COMPILER >= 800 ) |
91 | |
92 /* | |
93 * the simple inline cycle copies the variable length strings up to 16 | |
94 * bytes faster than icc8 autodetecting _intel_fast_memcpy() | |
95 */ | |
96 | |
97 static ngx_inline u_char * | |
98 ngx_copy(u_char *dst, u_char *src, size_t len) | |
99 { | |
100 if (len < 17) { | |
101 | |
102 while (len) { | |
103 *dst++ = *src++; | |
104 len--; | |
105 } | |
106 | |
107 return dst; | |
108 | |
109 } else { | |
110 return ngx_cpymem(dst, src, len); | |
111 } | |
112 } | |
113 | |
114 #else | |
115 | |
116 #define ngx_copy ngx_cpymem | |
117 | |
118 #endif | |
119 | |
120 | |
121 /* msvc and icc7 compile memcmp() to the inline loop */ | |
107
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
122 #define ngx_memcmp memcmp |
b5be4b0448d3
nginx-0.0.1-2003-07-01-19:00:03 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
123 |
461 | 124 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
125 u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n); |
485 | 126 u_char *ngx_pstrdup(ngx_pool_t *pool, ngx_str_t *src); |
503 | 127 u_char * ngx_cdecl ngx_sprintf(u_char *buf, const char *fmt, ...); |
128 u_char * ngx_cdecl ngx_snprintf(u_char *buf, size_t max, const char *fmt, ...); | |
461 | 129 u_char *ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args); |
455 | 130 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
131 ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n); |
455 | 132 ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n); |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
133 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
134 ngx_int_t ngx_atoi(u_char *line, size_t n); |
501 | 135 ssize_t ngx_atosz(u_char *line, size_t n); |
136 off_t ngx_atoof(u_char *line, size_t n); | |
137 time_t ngx_atotm(u_char *line, size_t n); | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
292
diff
changeset
|
138 ngx_int_t ngx_hextoi(u_char *line, size_t n); |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
139 |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
288
diff
changeset
|
140 void ngx_md5_text(u_char *text, u_char *md5); |
174
ea464a6c0581
nginx-0.0.1-2003-11-05-01:12:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
135
diff
changeset
|
141 |
409
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
142 |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
143 #define ngx_base64_encoded_length(len) (((len + 2) / 3) * 4) |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
144 #define ngx_base64_decoded_length(len) (((len + 3) / 4) * 3) |
8ac40cae79f0
nginx-0.0.10-2004-08-29-07:55:41 import
Igor Sysoev <igor@sysoev.ru>
parents:
408
diff
changeset
|
145 |
452 | 146 void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src); |
147 ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src); | |
461 | 148 |
657 | 149 uint32_t ngx_utf_decode(u_char **p, size_t n); |
150 size_t ngx_utf_length(u_char *p, size_t n); | |
527 | 151 u_char * ngx_utf_cpystrn(u_char *dst, u_char *src, size_t n); |
152 | |
461 | 153 |
601 | 154 #define NGX_ESCAPE_URI 0 |
155 #define NGX_ESCAPE_ARGS 1 | |
156 #define NGX_ESCAPE_HTML 2 | |
157 | |
158 #define NGX_UNESCAPE_URI 1 | |
461 | 159 |
485 | 160 uintptr_t ngx_escape_uri(u_char *dst, u_char *src, size_t size, |
493 | 161 ngx_uint_t type); |
601 | 162 void ngx_unescape_uri(u_char **dst, u_char **src, size_t size, ngx_uint_t type); |
408
d6e2b445c1b8
nginx-0.0.10-2004-08-27-19:40:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
163 |
174
ea464a6c0581
nginx-0.0.1-2003-11-05-01:12:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
135
diff
changeset
|
164 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
165 #define ngx_qsort qsort |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 |
97
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
167 |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
168 #define ngx_value_helper(n) #n |
70d2345a903f
nginx-0.0.1-2003-05-29-17:02:09 import
Igor Sysoev <igor@sysoev.ru>
parents:
91
diff
changeset
|
169 #define ngx_value(n) ngx_value_helper(n) |
91
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
84
diff
changeset
|
170 |
637625a2acdb
nginx-0.0.1-2003-05-19-20:39:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
84
diff
changeset
|
171 |
0
4eff17414a43
nginx-0.0.1-2002-08-06-20:39:45 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
172 #endif /* _NGX_STRING_H_INCLUDED_ */ |