~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/curl/php_curl.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
   +----------------------------------------------------------------------+
 
3
   | PHP Version 5                                                        |
 
4
   +----------------------------------------------------------------------+
 
5
   | Copyright (c) 1997-2004 The PHP Group                                |
 
6
   +----------------------------------------------------------------------+
 
7
   | This source file is subject to version 3.0 of the PHP license,       |
 
8
   | that is bundled with this package in the file LICENSE, and is        |
 
9
   | available through the world-wide-web at the following url:           |
 
10
   | http://www.php.net/license/3_0.txt.                                  |
 
11
   | If you did not receive a copy of the PHP license and are unable to   |
 
12
   | obtain it through the world-wide-web, please send a note to          |
 
13
   | license@php.net so we can mail you a copy immediately.               |
 
14
   +----------------------------------------------------------------------+
 
15
   | Author: Sterling Hughes <sterling@php.net>                           |
 
16
   |         Wez Furlong <wez@thebrainroom.com>                           |
 
17
   +----------------------------------------------------------------------+
 
18
*/
 
19
 
 
20
/* $Id: php_curl.h,v 1.41.2.1 2005/06/02 21:04:43 tony2001 Exp $ */
 
21
 
 
22
#ifndef _PHP_CURL_H
 
23
#define _PHP_CURL_H
 
24
 
 
25
#include "php.h"
 
26
#include "ext/standard/php_smart_str.h"
 
27
 
 
28
#ifdef COMPILE_DL_CURL
 
29
#undef HAVE_CURL
 
30
#define HAVE_CURL 1
 
31
#endif
 
32
 
 
33
#if HAVE_CURL
 
34
 
 
35
#define PHP_CURL_DEBUG 0
 
36
 
 
37
#include <curl/curl.h>
 
38
#include <curl/multi.h>
 
39
 
 
40
extern zend_module_entry curl_module_entry;
 
41
#define curl_module_ptr &curl_module_entry
 
42
 
 
43
#define CURLOPT_RETURNTRANSFER 19913
 
44
#define CURLOPT_BINARYTRANSFER 19914
 
45
#define PHP_CURL_STDOUT 0
 
46
#define PHP_CURL_FILE   1
 
47
#define PHP_CURL_USER   2
 
48
#define PHP_CURL_DIRECT 3
 
49
#define PHP_CURL_RETURN 4
 
50
#define PHP_CURL_ASCII  5
 
51
#define PHP_CURL_BINARY 6
 
52
#define PHP_CURL_IGNORE 7
 
53
 
 
54
int  le_curl;
 
55
#define le_curl_name "cURL handle"
 
56
int  le_curl_multi_handle;
 
57
#define le_curl_multi_handle_name "cURL Multi Handle"
 
58
 
 
59
PHP_MINIT_FUNCTION(curl);
 
60
PHP_MSHUTDOWN_FUNCTION(curl);
 
61
PHP_MINFO_FUNCTION(curl);
 
62
PHP_FUNCTION(curl_version);
 
63
PHP_FUNCTION(curl_init);
 
64
PHP_FUNCTION(curl_copy_handle);
 
65
PHP_FUNCTION(curl_setopt);
 
66
PHP_FUNCTION(curl_exec);
 
67
PHP_FUNCTION(curl_getinfo);
 
68
PHP_FUNCTION(curl_error);
 
69
PHP_FUNCTION(curl_errno);
 
70
PHP_FUNCTION(curl_close);
 
71
PHP_FUNCTION(curl_multi_init);
 
72
PHP_FUNCTION(curl_multi_add_handle);
 
73
PHP_FUNCTION(curl_multi_remove_handle);
 
74
PHP_FUNCTION(curl_multi_select);
 
75
PHP_FUNCTION(curl_multi_exec);
 
76
PHP_FUNCTION(curl_multi_getcontent);
 
77
PHP_FUNCTION(curl_multi_info_read);
 
78
PHP_FUNCTION(curl_multi_close);
 
79
void _php_curl_multi_close(zend_rsrc_list_entry * TSRMLS_DC);
 
80
 
 
81
typedef struct {
 
82
        zval            *func_name;
 
83
        zend_fcall_info_cache fci_cache;
 
84
        FILE            *fp;
 
85
        smart_str       buf;
 
86
        int             method;
 
87
        int             type;
 
88
} php_curl_write;
 
89
 
 
90
typedef struct {
 
91
        zval            *func_name;
 
92
        zend_fcall_info_cache fci_cache;
 
93
        FILE            *fp;
 
94
        long            fd;
 
95
        int             method;
 
96
} php_curl_read;
 
97
 
 
98
typedef struct {
 
99
        php_curl_write *write;
 
100
        php_curl_write *write_header;
 
101
        php_curl_read  *read;
 
102
        zval           *passwd;
 
103
} php_curl_handlers;
 
104
 
 
105
struct _php_curl_error  {
 
106
        char str[CURL_ERROR_SIZE + 1];
 
107
        int  no;
 
108
};
 
109
 
 
110
struct _php_curl_free {
 
111
        zend_llist str;
 
112
        zend_llist post;
 
113
        zend_llist slist;
 
114
};
 
115
 
 
116
typedef struct {
 
117
        struct _php_curl_error   err;
 
118
        struct _php_curl_free    to_free;
 
119
        void ***thread_ctx;
 
120
        CURL                    *cp;
 
121
        php_curl_handlers       *handlers;
 
122
        long                     id;
 
123
        unsigned int             uses;
 
124
        zend_bool                in_callback;
 
125
} php_curl;
 
126
 
 
127
typedef struct {
 
128
        int    still_running;
 
129
        CURLM *multi;
 
130
        zend_llist easyh;
 
131
} php_curlm;
 
132
 
 
133
void _php_curl_cleanup_handle(php_curl *);
 
134
 
 
135
/* streams support */
 
136
 
 
137
extern php_stream_ops php_curl_stream_ops;
 
138
#define PHP_STREAM_IS_CURL      &php_curl_stream_ops
 
139
 
 
140
php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename, char *mode,
 
141
                int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC);
 
142
 
 
143
extern php_stream_wrapper php_curl_wrapper;
 
144
 
 
145
struct php_curl_buffer {
 
146
        off_t readpos, writepos;
 
147
        php_stream *buf;
 
148
};
 
149
 
 
150
typedef struct {
 
151
        CURL    *curl;
 
152
        CURLM   *multi;
 
153
        char *url;
 
154
        struct php_curl_buffer readbuffer; /* holds downloaded data */
 
155
        struct php_curl_buffer writebuffer; /* holds data to upload */
 
156
 
 
157
        fd_set readfds, writefds, excfds;
 
158
        int maxfd;
 
159
        
 
160
        char errstr[CURL_ERROR_SIZE + 1];
 
161
        CURLMcode mcode;
 
162
        int pending;
 
163
        zval *headers;
 
164
} php_curl_stream;
 
165
 
 
166
 
 
167
#else
 
168
#define curl_module_ptr NULL
 
169
#endif /* HAVE_CURL */
 
170
#define phpext_curl_ptr curl_module_ptr
 
171
#endif  /* _PHP_CURL_H */