comparison src/core/ngx_inet.c @ 362:54fad6c4b555 NGINX_0_6_25

nginx 0.6.25 *) Change: now the "server_name_in_redirect" directive is used instead of the "server_name" directive's special "*" parameter. *) Change: now wildcard and regex names can be used as main name in a "server_name" directive. *) Change: the "satisfy_any" directive was replaced by the "satisfy" directive. *) Workaround: old worker processes might hog CPU after reconfiguration if they was run under Linux OpenVZ. *) Feature: the "min_delete_depth" directive. *) Bugfix: the COPY and MOVE methods did not work with single files. *) Bugfix: the ngx_http_gzip_static_module did not allow the ngx_http_dav_module to work; bug appeared in 0.6.23. *) Bugfix: socket leak in HTTPS mode if deferred accept was used. Thanks to Ben Maurer. *) Bugfix: nginx could not be built without PCRE library; bug appeared in 0.6.23.
author Igor Sysoev <http://sysoev.ru>
date Tue, 08 Jan 2008 00:00:00 +0300
parents 583decdb82a4
children a39aab45a53f
comparison
equal deleted inserted replaced
361:160660bad929 362:54fad6c4b555
4 */ 4 */
5 5
6 6
7 #include <ngx_config.h> 7 #include <ngx_config.h>
8 #include <ngx_core.h> 8 #include <ngx_core.h>
9
10
11 static size_t ngx_sprint_uchar(u_char *text, u_char c, size_t len);
9 12
10 13
11 /* AF_INET only */ 14 /* AF_INET only */
12 15
13 in_addr_t 16 in_addr_t
61 * 64 *
62 * By the way, the implementation using ngx_sprintf() is faster by 2.5-3 times 65 * By the way, the implementation using ngx_sprintf() is faster by 2.5-3 times
63 * than using FreeBSD libc's snprintf(). 66 * than using FreeBSD libc's snprintf().
64 */ 67 */
65 68
66
67 static ngx_inline size_t
68 ngx_sprint_uchar(u_char *text, u_char c, size_t len)
69 {
70 size_t n;
71 ngx_uint_t c1, c2;
72
73 n = 0;
74
75 if (len == n) {
76 return n;
77 }
78
79 c1 = c / 100;
80
81 if (c1) {
82 *text++ = (u_char) (c1 + '0');
83 n++;
84
85 if (len == n) {
86 return n;
87 }
88 }
89
90 c2 = (c % 100) / 10;
91
92 if (c1 || c2) {
93 *text++ = (u_char) (c2 + '0');
94 n++;
95
96 if (len == n) {
97 return n;
98 }
99 }
100
101 c2 = c % 10;
102
103 *text++ = (u_char) (c2 + '0');
104 n++;
105
106 return n;
107 }
108
109
110 /* AF_INET only */ 69 /* AF_INET only */
111 70
112 size_t 71 size_t
113 ngx_sock_ntop(int family, struct sockaddr *sa, u_char *text, size_t len) 72 ngx_sock_ntop(int family, struct sockaddr *sa, u_char *text, size_t len)
114 { 73 {
161 text[n] = '\0'; 120 text[n] = '\0';
162 121
163 return n; 122 return n;
164 } 123 }
165 124
125
166 size_t 126 size_t
167 ngx_inet_ntop(int family, void *addr, u_char *text, size_t len) 127 ngx_inet_ntop(int family, void *addr, u_char *text, size_t len)
168 { 128 {
169 u_char *p; 129 u_char *p;
170 size_t n; 130 size_t n;
209 text[n] = '\0'; 169 text[n] = '\0';
210 return n; 170 return n;
211 } 171 }
212 172
213 text[n] = '\0'; 173 text[n] = '\0';
174
175 return n;
176 }
177
178
179 static size_t
180 ngx_sprint_uchar(u_char *text, u_char c, size_t len)
181 {
182 size_t n;
183 ngx_uint_t c1, c2;
184
185 n = 0;
186
187 if (len == n) {
188 return n;
189 }
190
191 c1 = c / 100;
192
193 if (c1) {
194 *text++ = (u_char) (c1 + '0');
195 n++;
196
197 if (len == n) {
198 return n;
199 }
200 }
201
202 c2 = (c % 100) / 10;
203
204 if (c1 || c2) {
205 *text++ = (u_char) (c2 + '0');
206 n++;
207
208 if (len == n) {
209 return n;
210 }
211 }
212
213 c2 = c % 10;
214
215 *text++ = (u_char) (c2 + '0');
216 n++;
214 217
215 return n; 218 return n;
216 } 219 }
217 220
218 221