Mercurial > hg > nginx-quic
annotate src/mysql/ngx_mysql.h @ 4536:ea69e97a812b stable-1.0 release-1.0.14
nginx-1.0.14-RELEASE
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 15 Mar 2012 11:50:53 +0000 |
parents | 4919fb357a5d |
children |
rev | line source |
---|---|
645 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4450
4919fb357a5d
Merge of r4406, r4413: copyrights updated.
Maxim Dounin <mdounin@mdounin.ru>
parents:
653
diff
changeset
|
4 * Copyright (C) Nginx, Inc. |
645 | 5 */ |
6 | |
7 | |
8 #ifndef _NGX_MYSQL_H_INCLUDED_ | |
9 #define _NGX_MYSQL_H_INCLUDED_ | |
10 | |
11 | |
12 #include <ngx_config.h> | |
13 #include <ngx_core.h> | |
14 #include <ngx_event.h> | |
653 | 15 #include <ngx_event_connect.h> |
16 | |
17 | |
18 typedef struct ngx_mysql_s ngx_mysql_t; | |
19 | |
20 typedef void (*ngx_mysql_handler_pt)(ngx_mysql_t *m); | |
645 | 21 |
22 | |
653 | 23 struct ngx_mysql_s { |
645 | 24 ngx_peer_connection_t peer; |
653 | 25 |
26 ngx_buf_t *buf; | |
27 ngx_pool_t *pool; | |
28 | |
29 ngx_str_t *login; | |
30 ngx_str_t *passwd; | |
31 ngx_str_t *database; | |
32 | |
33 ngx_str_t query; | |
34 | |
35 ngx_uint_t pktn; | |
36 | |
37 ngx_mysql_handler_pt handler; | |
38 void *data; | |
39 ngx_int_t state; | |
40 | |
41 }; | |
42 | |
43 | |
44 #define NGX_MYSQL_CMDPKT_LEN 5 | |
645 | 45 |
46 | |
47 #if (NGX_HAVE_LITTLE_ENDIAN && NGX_HAVE_NONALIGNED && 0) | |
48 | |
653 | 49 #define ngx_m16toh(n) (*(uint32_t *) n & 0x0000ffff) |
50 #define ngx_m24toh(n) (*(uint32_t *) n & 0x00ffffff) | |
51 #define ngx_m32toh(n) *(uint32_t *) n | |
52 | |
53 #define ngx_htom16(n, m) *(uint16_t *) n = (uint16_t) ((m) & 0xffff) | |
54 | |
55 #define ngx_htom24(n, m) (n)[0] = (u_char) ((m) & 0xff); \ | |
56 (n)[1] = (u_char) (((m) >> 8) & 0xff); \ | |
57 (n)[2] = (u_char) (((m) >> 16) & 0xff) | |
58 | |
59 #define ngx_htom32(n, m) *(uint32_t *) (n) = (m) | |
645 | 60 |
61 #else | |
62 | |
653 | 63 #define ngx_m16toh(n) (n[0] | n[1] << 8) |
64 #define ngx_m24toh(n) (n[0] | n[1] << 8 | n[2] << 16) | |
65 #define ngx_m32toh(n) (n[0] | n[1] << 8 | n[2] << 16 | n[3] << 24) | |
66 | |
67 #define ngx_htom16(n, m) (n)[0] = (u_char) (m); (n)[1] = (u_char) ((m) >> 8) | |
68 | |
69 #define ngx_htom24(n, m) (n)[0] = (u_char) ((m) & 0xff); \ | |
70 (n)[1] = (u_char) (((m) >> 8) & 0xff); \ | |
71 (n)[2] = (u_char) (((m) >> 16) & 0xff) | |
72 | |
73 #define ngx_htom32(n, m) (n)[0] = (u_char) ((m) & 0xff); \ | |
74 (n)[1] = (u_char) (((m) >> 8) & 0xff); \ | |
75 (n)[2] = (u_char) (((m) >> 16) & 0xff); \ | |
76 (n)[3] = (u_char) (((m) >> 24) & 0xff) | |
645 | 77 |
78 #endif | |
79 | |
80 | |
653 | 81 ngx_int_t ngx_mysql_connect(ngx_mysql_t *m); |
82 ngx_int_t ngx_mysql_query(ngx_mysql_t *m); | |
83 | |
84 | |
645 | 85 #endif /* _NGX_MYSQL_H_INCLUDED_ */ |