forked from SKPHP1989/php_togo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_togo.h
136 lines (114 loc) · 4.27 KB
/
php_togo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Michael Lee <[email protected]> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#ifndef PHP_TOGO_H
#define PHP_TOGO_H
extern zend_module_entry togo_module_entry;
#define phpext_togo_ptr &togo_module_entry
#define PHP_TOGO_VERSION "0.1.0" /* Replace with version number for your extension */
#ifdef PHP_WIN32
# define PHP_TOGO_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
# define PHP_TOGO_API __attribute__ ((visibility("default")))
#else
# define PHP_TOGO_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
//togo method
PHP_METHOD(Togo, __construct);
PHP_METHOD(Togo, __destruct);
PHP_METHOD(Togo, connect);
PHP_METHOD(Togo, version);
PHP_METHOD(Togo, counter_plus);
PHP_METHOD(Togo, counter_minus);
PHP_METHOD(Togo, counter_get);
PHP_METHOD(Togo, lock_lock);
PHP_METHOD(Togo, lock_unlock);
PHP_METHOD(Togo, lock_status);
PHP_METHOD(Togo, queue_lpush);
PHP_METHOD(Togo, queue_lpop);
PHP_METHOD(Togo, queue_rpush);
PHP_METHOD(Togo, queue_rpop);
PHP_METHOD(Togo, queue_count);
PHP_METHOD(Togo, queue_status);
PHP_METHOD(Togo, close);
//togo ini
PHP_MINIT_FUNCTION(togo);
PHP_MSHUTDOWN_FUNCTION(togo);
PHP_RINIT_FUNCTION(togo);
PHP_RSHUTDOWN_FUNCTION(togo);
PHP_MINFO_FUNCTION(togo);
/* {{{ struct togo_sock */
typedef struct togo_sock_ {
php_stream *stream;
char *host;
unsigned short port;
long timeout;
int status;
} TogoSock;
/* }}} */
#define togo_sock_name "Togo Socket Buffer"
#define TOGO_SOCK_STATUS_FAILED 0
#define TOGO_SOCK_STATUS_DISCONNECTED 1
#define TOGO_SOCK_STATUS_UNKNOWN 2
#define TOGO_SOCK_STATUS_CONNECTED 3
/* properties */
#define TOGO_NOT_FOUND 0
#define TOGO_STRING 1
#define TOGO_SET 2
#define TOGO_LIST 3
/* togo reponse message header content */
#define TOGO_RESPONE_HEADER "TOGO_S"
/* togo reponse message tail content */
#define TOGO_RESPONE_TAIL "TOGO_E"
/* togo reponse message status */
#define TOGO_RESPONSE_STATUS_FAIL "TOGO_FAIL"
#define TOGO_RESPONSE_STATUS_NULL "TOGO_NULL"
#define TOGO_RESPONSE_STATUS_COMMANDBIG "TOGO_COMMAND_TOO_BIG"
#define TOGO_RESPONSE_STATUS_BIG "TOO_BIG"
#define TOGO_RESPONSE_STATUS_OK "TOGO_OK"
/* {{{ internal function protos */
void add_constant_long(zend_class_entry *ce, char *name, int value);
PHPAPI void togo_check_eof(TogoSock *togo_sock TSRMLS_DC);
PHPAPI TogoSock* togo_sock_create(char *host, int host_len, unsigned short port, long timeout);
PHPAPI int togo_sock_connect(TogoSock *togo_sock TSRMLS_DC);
PHPAPI int togo_sock_disconnect(TogoSock *togo_sock TSRMLS_DC);
PHPAPI int togo_sock_server_open(TogoSock *togo_sock, int TSRMLS_DC);
PHPAPI void togo_free_socket(TogoSock *togo_sock);
PHPAPI int togo_sock_get(zval *id, TogoSock **togo_sock TSRMLS_DC);
PHPAPI char * togo_sock_read(TogoSock *togo_sock, int *buf_len TSRMLS_DC);
PHPAPI int togo_sock_write(TogoSock *togo_sock, char *cmd, size_t sz TSRMLS_DC);
PHPAPI int togo_sock_response_status_check(char *inbuf TSRMLS_DC);
PHPAPI char * togo_sock_response_parser(char *inbuf TSRMLS_DC);
/* }}} */
#ifdef ZTS
#define TOGO_G(v) TSRMG(togo_globals_id, zend_togo_globals *, v)
#else
#define TOGO_G(v) (togo_globals.v)
#endif
#endif /* PHP_TOGO_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/