blob: 09de18e52199954e31885735add8782ace733111 [file] [log] [blame]
Igor Sysoev6de5c2c2002-08-06 16:39:45 +00001#ifndef _NGX_STRING_H_INCLUDED_
2#define _NGX_STRING_H_INCLUDED_
3
4
5#include <ngx_config.h>
Igor Sysoev1c104622003-06-03 15:42:58 +00006#include <ngx_core.h>
Igor Sysoev6de5c2c2002-08-06 16:39:45 +00007
8
Igor Sysoeva0bb31f2002-12-02 16:09:40 +00009typedef struct {
Igor Sysoev10a543a2004-03-16 07:10:12 +000010 size_t len;
11 u_char *data;
Igor Sysoeva0bb31f2002-12-02 16:09:40 +000012} ngx_str_t;
13
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000014
Igor Sysoev10a543a2004-03-16 07:10:12 +000015#define ngx_string(str) { sizeof(str) - 1, (u_char *) str }
Igor Sysoevb7387572003-03-11 20:38:13 +000016#define ngx_null_string { 0, NULL }
Igor Sysoev960ffa42002-12-26 07:24:21 +000017
18
19#if (WIN32)
Igor Sysoev42feecb2002-12-15 06:25:09 +000020
Igor Sysoevda85f7f2004-03-16 21:26:01 +000021#define ngx_strncasecmp(s1, s2, n) \
22 strnicmp((const char *) s1, (const char *) s2, n)
23#define ngx_strcasecmp(s1, s2) \
24 stricmp((const char *) s1, (const char *) s2)
Igor Sysoevad22e012003-01-15 07:02:27 +000025
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000026#define ngx_snprintf _snprintf
27#define ngx_vsnprintf _vsnprintf
28
29#else
30
Igor Sysoev10a543a2004-03-16 07:10:12 +000031#define ngx_strncasecmp(s1, s2, n) \
32 strncasecmp((const char *) s1, (const char *) s2, n)
33#define ngx_strcasecmp(s1, s2) \
34 strcasecmp((const char *) s1, (const char *) s2)
Igor Sysoevad22e012003-01-15 07:02:27 +000035
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000036#define ngx_snprintf snprintf
37#define ngx_vsnprintf vsnprintf
38
39#endif
40
Igor Sysoev3646a162004-03-14 20:46:25 +000041
Igor Sysoev10a543a2004-03-16 07:10:12 +000042#define ngx_strncmp(s1, s2, n) \
43 strncmp((const char *) s1, (const char *) s2, n)
Igor Sysoev3646a162004-03-14 20:46:25 +000044
45/* msvc and icc compile strcmp() to inline loop */
Igor Sysoev10a543a2004-03-16 07:10:12 +000046#define ngx_strcmp(s1, s2) strcmp((const char *) s1, (const char *) s2)
Igor Sysoev3646a162004-03-14 20:46:25 +000047
Igor Sysoev10a543a2004-03-16 07:10:12 +000048#define ngx_strstr(s1, s2) strstr((const char *) s1, (const char *) s2)
49#define ngx_strlen(s) strlen((const char *) s)
Igor Sysoev3646a162004-03-14 20:46:25 +000050
Igor Sysoev6abfde62003-07-01 15:00:03 +000051/*
52 * msvc and icc compile memset() to inline "rep stos"
53 * while ZeroMemory and bzero are calls.
Igor Sysoev3646a162004-03-14 20:46:25 +000054 *
55 * icc can also inline mov's of a zeroed register for small blocks.
Igor Sysoev6abfde62003-07-01 15:00:03 +000056 */
Igor Sysoev9d9f58f2003-07-02 18:51:41 +000057#define ngx_memzero(buf, n) memset(buf, 0, n)
Igor Sysoev6abfde62003-07-01 15:00:03 +000058
59/* msvc and icc compile memcpy() to inline "rep movs" */
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000060#define ngx_memcpy(dst, src, n) memcpy(dst, src, n)
Igor Sysoev10a543a2004-03-16 07:10:12 +000061#define ngx_cpymem(dst, src, n) ((u_char *) memcpy(dst, src, n)) + n
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000062
Igor Sysoev6abfde62003-07-01 15:00:03 +000063/* msvc and icc compile memcmp() to inline loop */
64#define ngx_memcmp memcmp
65
Igor Sysoev10a543a2004-03-16 07:10:12 +000066u_char *ngx_cpystrn(u_char *dst, u_char *src, size_t n);
67ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
68ngx_int_t ngx_atoi(u_char *line, size_t n);
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000069
Igor Sysoev10a543a2004-03-16 07:10:12 +000070void ngx_md5_text(u_char *text, u_char *md5);
Igor Sysoev9cc1ace2003-11-04 22:12:39 +000071
72
Igor Sysoev13933252003-05-29 13:02:09 +000073#define ngx_qsort qsort
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000074
Igor Sysoev13933252003-05-29 13:02:09 +000075
76#define ngx_value_helper(n) #n
77#define ngx_value(n) ngx_value_helper(n)
Igor Sysoeva9830112003-05-19 16:39:14 +000078
79
Igor Sysoev6de5c2c2002-08-06 16:39:45 +000080#endif /* _NGX_STRING_H_INCLUDED_ */