forked from johnj/pecl-oauth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
php_oauth.h
162 lines (135 loc) · 4.87 KB
/
php_oauth.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
+----------------------------------------------------------------------+
| See LICENSE file for further copyright information |
+----------------------------------------------------------------------+
| Authors: John Jawed <jawed@php.net> |
| Felipe Pena <felipe@php.net> |
| Rasmus Lerdorf <rasmus@php.net> |
+----------------------------------------------------------------------+
*/
/* $Id: php_oauth.h,v 1.18 2009/05/10 06:40:59 jawed Exp $ */
#ifndef PHP_OAUTH_H
#define PHP_OAUTH_H
#ifndef Z_ADDREF_P
#define Z_ADDREF_P(pz) (pz)->refcount++
#define Z_ADDREF_PP(ppz) Z_ADDREF_P(*(ppz))
#endif
#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 2) || PHP_MAJOR_VERSION > 5
# define OAUTH_ARGINFO
# define OAUTH_IS_CALLABLE_CC TSRMLS_CC
#else
# define OAUTH_ARGINFO static
# define OAUTH_IS_CALLABLE_CC
#endif
#define OAUTH_EXT_VER "0.99.9"
#define OAUTH_HTTP_PORT 80
#define OAUTH_HTTPS_PORT 443
#define OAUTH_MAX_REDIRS 4L
#define OAUTH_MAX_HEADER_LEN 512L
#define OAUTH_AUTH_TYPE_URI "uri"
#define OAUTH_AUTH_TYPE_FORM "form"
#define OAUTH_AUTH_TYPE_AUTHORIZATION "authorization"
#define OAUTH_AUTH_TYPE_NONE "noauth"
#define OAUTH_SIG_METHOD_HMACSHA1 "HMAC-SHA1"
#if LIBCURL_VERSION_NUM >= 0x071304
#define OAUTH_PROTOCOLS_ALLOWED CURLPROTO_HTTP | CURLPROTO_HTTPS
#endif
extern zend_module_entry oauth_module_entry;
#define phpext_oauth_ptr &oauth_module_entry
#define PHP_OAUTH_API
#define OAUTH_ATTR_CONSUMER_KEY "oauth_consumer_key"
#define OAUTH_ATTR_CONSUMER_SECRET "oauth_consumer_secret"
#define OAUTH_ATTR_ACCESS_TOKEN "oauth_access_token"
#define OAUTH_RAW_LAST_RES "oauth_last_response_raw"
#define OAUTH_ATTR_LAST_RES_INFO "oauth_last_response_info"
#define OAUTH_ATTR_SIGMETHOD "oauth_sig_method"
#define OAUTH_ATTR_TOKEN "oauth_token"
#define OAUTH_ATTR_TOKEN_SECRET "oauth_token_secret"
#define OAUTH_ATTR_AUTHMETHOD "oauth_auth_method"
#define OAUTH_ATTR_OAUTH_VERSION "oauth_version"
#define OAUTH_ATTR_OAUTH_NONCE "oauth_nonce"
#define OAUTH_ATTR_OAUTH_USER_NONCE "oauth_user_nonce"
#define OAUTH_ATTR_CA_PATH "oauth_ssl_ca_path"
#define OAUTH_ATTR_CA_INFO "oauth_ssl_ca_info"
#define OAUTH_HTTP_METHOD_GET "GET"
#define OAUTH_HTTP_METHOD_POST "POST"
#define OAUTH_HTTP_METHOD_PUT "PUT"
#define OAUTH_HTTP_METHOD_HEAD "HEAD"
#define PARAMS_FILTER_OAUTH 1
#define PARAMS_FILTER_NON_OAUTH 2
#define PARAMS_FILTER_NONE 0
#define OAUTH_FETCH_USETOKEN 1
#define OAUTH_DEFAULT_VERSION "1.0"
/* errors */
#define OAUTH_ERR_CONTENT_TYPE "invalidcontentttype"
#define OAUTH_ERR_BAD_REQUEST 400
#define OAUTH_ERR_BAD_AUTH 401
#define OAUTH_ERR_INTERNAL_ERROR 503
/* params */
#define OAUTH_PARAM_CONSUMER_KEY "oauth_consumer_key"
#define OAUTH_PARAM_SIGNATURE "oauth_signature"
#define OAUTH_PARAM_SIGNATURE_METHOD "oauth_signature_method"
#define OAUTH_PARAM_TIMESTAMP "oauth_timestamp"
#define OAUTH_PARAM_NONCE "oauth_nonce"
#define OAUTH_PARAM_VERSION "oauth_version"
#define OAUTH_PARAM_TOKEN "oauth_token"
#define OAUTH_PARAM_ASH "oauth_session_handle"
#define OAUTH_PARAM_VERIFIER "oauth_verifier"
#define OAUTH_PARAM_CALLBACK "oauth_callback"
/* values */
#define OAUTH_CALLBACK_OOB "oob"
#define OAUTH_PARAM_PREFIX "oauth_"
#define OAUTH_PARAM_PREFIX_LEN 6
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(oauth);
PHP_MSHUTDOWN_FUNCTION(oauth);
PHP_MINFO_FUNCTION(oauth);
#ifdef ZTS
#define OAUTH(v) TSRMG(oauth_globals_id, zend_oauth_globals *, v)
#else
#define OAUTH(v) (oauth_globals.v)
#endif
typedef struct {
char *sbs;
smart_str headers_in;
smart_str headers_out;
smart_str body_in;
smart_str body_out;
smart_str curl_info;
} php_so_debug;
typedef struct {
zend_object zo;
HashTable *properties;
smart_str lastresponse;
void ***thread_ctx;
char last_location_header[OAUTH_MAX_HEADER_LEN];
uint redirects;
uint sslcheck; /* whether we check for SSL verification or not */
uint debug; /* verbose output */
uint follow_redirects; /* follow and sign redirects? */
zval *this_ptr;
zval *debugArr;
php_so_debug *debug_info;
} php_so_object;
static inline zval **soo_get_property(php_so_object *soo, char *prop_name TSRMLS_DC);
static int soo_set_nonce(php_so_object *soo TSRMLS_DC);
static inline int soo_set_property(php_so_object *soo, zval *prop, char *prop_name TSRMLS_DC);
static void make_standard_query(HashTable *ht, php_so_object *soo TSRMLS_DC);
static CURLcode make_req(php_so_object *soo, const char *url, const smart_str *payload, const char *http_method, HashTable *request_headers TSRMLS_DC);
#ifndef zend_hash_quick_del
#define HASH_DEL_KEY_QUICK 2
#define zend_hash_quick_del(ht, arKey, nKeyLength, h) \
zend_hash_del_key_or_index(ht, arKey, nKeyLength, h, HASH_DEL_KEY_QUICK)
#endif
#endif
/**
* Local Variables:
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: t
* End:
* vim600: fdm=marker
* vim: noet sw=4 ts=4 noexpandtab
*/