comparison src/core/ngx_string.h @ 0:f0b350454894 NGINX_0_1_0

nginx 0.1.0 *) The first public version.
author Igor Sysoev <http://sysoev.ru>
date Mon, 04 Oct 2004 00:00:00 +0400
parents
children cc9f381affaa
comparison
equal deleted inserted replaced
-1:000000000000 0:f0b350454894
1
2 /*
3 * Copyright (C) Igor Sysoev
4 */
5
6
7 #ifndef _NGX_STRING_H_INCLUDED_
8 #define _NGX_STRING_H_INCLUDED_
9
10
11 #include <ngx_config.h>
12 #include <ngx_core.h>
13
14
15 typedef struct {
16 size_t len;
17 u_char *data;
18 } ngx_str_t;
19
20
21 #define ngx_string(str) { sizeof(str) - 1, (u_char *) str }
22 #define ngx_null_string { 0, NULL }
23
24
25 #if (WIN32)
26
27 #define ngx_strncasecmp(s1, s2, n) \
28 strnicmp((const char *) s1, (const char *) s2, n)
29 #define ngx_strcasecmp(s1, s2) \
30 stricmp((const char *) s1, (const char *) s2)
31
32 #define ngx_snprintf _snprintf
33 #define ngx_vsnprintf _vsnprintf
34
35 #else
36
37 #define ngx_strncasecmp(s1, s2, n) \
38 strncasecmp((const char *) s1, (const char *) s2, n)
39 #define ngx_strcasecmp(s1, s2) \
40 strcasecmp((const char *) s1, (const char *) s2)
41
42 #define ngx_snprintf snprintf
43 #define ngx_vsnprintf vsnprintf
44
45 #endif
46
47
48 #define ngx_strncmp(s1, s2, n) \
49 strncmp((const char *) s1, (const char *) s2, n)
50
51 /* msvc and icc compile strcmp() to inline loop */
52 #define ngx_strcmp(s1, s2) strcmp((const char *) s1, (const char *) s2)
53
54 #define ngx_strstr(s1, s2) strstr((const char *) s1, (const char *) s2)
55 #define ngx_strlen(s) strlen((const char *) s)
56
57 /*
58 * msvc and icc compile memset() to the inline "rep stos"
59 * while ZeroMemory() and bzero() are the calls.
60 * icc may also inline several mov's of a zeroed register for small blocks.
61 */
62 #define ngx_memzero(buf, n) memset(buf, 0, n)
63
64 /* msvc and icc compile memcpy() to the inline "rep movs" */
65 #define ngx_memcpy(dst, src, n) memcpy(dst, src, n)
66 #define ngx_cpymem(dst, src, n) ((u_char *) memcpy(dst, src, n)) + n
67
68 /* msvc and icc compile memcmp() to the inline loop */
69 #define ngx_memcmp memcmp
70
71 u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n);
72 ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
73
74 ngx_int_t ngx_atoi(u_char *line, size_t n);
75 ngx_int_t ngx_hextoi(u_char *line, size_t n);
76
77 void ngx_md5_text(u_char *text, u_char *md5);
78
79
80 #define ngx_base64_encoded_length(len) (((len + 2) / 3) * 4)
81 #define ngx_base64_decoded_length(len) (((len + 3) / 4) * 3)
82
83 void ngx_encode_base64(ngx_str_t *src, ngx_str_t *dst);
84 ngx_int_t ngx_decode_base64(ngx_str_t *src, ngx_str_t *dst);
85
86
87 #define ngx_qsort qsort
88
89
90 #define ngx_value_helper(n) #n
91 #define ngx_value(n) ngx_value_helper(n)
92
93
94 #endif /* _NGX_STRING_H_INCLUDED_ */