xref: /PHP-7.2/ext/imap/php_imap.h (revision 336d2086)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2018 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 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_01.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    | Authors: Rex Logan           <veebert@dimensional.com>               |
16    |          Mark Musone         <musone@afterfive.com>                  |
17    |          Brian Wang          <brian@vividnet.com>                    |
18    |          Kaj-Michael Lang    <milang@tal.org>                        |
19    |          Antoni Pamies Olive <toni@readysoft.net>                    |
20    |          Rasmus Lerdorf      <rasmus@php.net>                        |
21    |          Chuck Hagenbuch     <chuck@horde.org>                       |
22    |          Andrew Skalski      <askalski@chekinc.com>                  |
23    |          Hartmut Holzgraefe  <hholzgra@php.net>                      |
24    |          Jani Taskinen       <sniper@iki.fi>                         |
25    |          Daniel R. Kalowsky  <kalowsky@php.net>                      |
26    | PHP 4.0 updates:  Zeev Suraski <zeev@zend.com>                       |
27    +----------------------------------------------------------------------+
28  */
29 
30 /* $Id$ */
31 
32 #ifndef PHP_IMAP_H
33 #define PHP_IMAP_H
34 
35 #if HAVE_IMAP
36 
37 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
38 
39  /* For now these appear on Windows, remove this check if it appears outside */
40 # ifdef PHP_WIN32
41  /* Undefine these LOG defines to avoid warnings */
42 #  undef LOG_EMERG
43 #  undef LOG_CRIT
44 #  undef LOG_ERR
45 #  undef LOG_WARNING
46 #  undef LOG_NOTICE
47 #  undef LOG_DEBUG
48 
49  /* c-client also redefines its own ftruncate */
50 #  undef ftruncate
51 # endif
52 
53  /* these are used for quota support */
54 # include "c-client.h"	/* includes mail.h and rfc822.h */
55 # include "imap4r1.h"	/* location of c-client quota functions */
56 #else
57 # include "mail.h"
58 # include "rfc822.h"
59 #endif
60 
61 extern zend_module_entry imap_module_entry;
62 #define imap_module_ptr &imap_module_entry
63 
64 #include "php_version.h"
65 #define PHP_IMAP_VERSION PHP_VERSION
66 
67 /* Data types */
68 
69 #ifdef IMAP41
70 #define LSIZE text.size
71 #define LTEXT text.data
72 #define DTYPE int
73 #define CONTENT_PART nested.part
74 #define CONTENT_MSG_BODY nested.msg->body
75 #define IMAPVER "Imap 4R1"
76 #else
77 #define LSIZE size
78 #define LTEXT text
79 #define DTYPE char
80 #define CONTENT_PART contents.part
81 #define CONTENT_MSG_BODY contents.msg.body
82 #define IMAPVER "Imap 4"
83 #endif
84 
85 
86 /* Determines how mm_list() and mm_lsub() are to return their results. */
87 typedef enum {
88 	FLIST_ARRAY,
89 	FLIST_OBJECT
90 } folderlist_style_t;
91 
92 typedef struct php_imap_le_struct {
93 	MAILSTREAM *imap_stream;
94 	long flags;
95 } pils;
96 
97 typedef struct php_imap_mailbox_struct {
98 	SIZEDTEXT text;
99 	DTYPE delimiter;
100 	long attributes;
101 	struct php_imap_mailbox_struct *next;
102 } FOBJECTLIST;
103 
104 typedef struct php_imap_error_struct {
105 	SIZEDTEXT text;
106 	long errflg;
107 	struct php_imap_error_struct *next;
108 } ERRORLIST;
109 
110 typedef struct _php_imap_message_struct {
111 	unsigned long msgid;
112 	struct _php_imap_message_struct *next;
113 } MESSAGELIST;
114 
115 
116 /* Functions */
117 
118 PHP_MINIT_FUNCTION(imap);
119 PHP_RINIT_FUNCTION(imap);
120 PHP_RSHUTDOWN_FUNCTION(imap);
121 PHP_MINFO_FUNCTION(imap);
122 
123 PHP_FUNCTION(imap_open);
124 PHP_FUNCTION(imap_popen);
125 PHP_FUNCTION(imap_reopen);
126 PHP_FUNCTION(imap_num_msg);
127 PHP_FUNCTION(imap_num_recent);
128 PHP_FUNCTION(imap_headers);
129 PHP_FUNCTION(imap_headerinfo);
130 PHP_FUNCTION(imap_rfc822_parse_headers);
131 PHP_FUNCTION(imap_body);
132 PHP_FUNCTION(imap_fetchstructure);
133 PHP_FUNCTION(imap_fetchbody);
134 PHP_FUNCTION(imap_fetchmime);
135 PHP_FUNCTION(imap_savebody);
136 PHP_FUNCTION(imap_gc);
137 PHP_FUNCTION(imap_expunge);
138 PHP_FUNCTION(imap_delete);
139 PHP_FUNCTION(imap_undelete);
140 PHP_FUNCTION(imap_check);
141 PHP_FUNCTION(imap_close);
142 PHP_FUNCTION(imap_mail_copy);
143 PHP_FUNCTION(imap_mail_move);
144 PHP_FUNCTION(imap_createmailbox);
145 PHP_FUNCTION(imap_renamemailbox);
146 PHP_FUNCTION(imap_deletemailbox);
147 PHP_FUNCTION(imap_listmailbox);
148 PHP_FUNCTION(imap_scanmailbox);
149 PHP_FUNCTION(imap_subscribe);
150 PHP_FUNCTION(imap_unsubscribe);
151 PHP_FUNCTION(imap_append);
152 PHP_FUNCTION(imap_ping);
153 PHP_FUNCTION(imap_base64);
154 PHP_FUNCTION(imap_qprint);
155 PHP_FUNCTION(imap_8bit);
156 PHP_FUNCTION(imap_binary);
157 PHP_FUNCTION(imap_mailboxmsginfo);
158 PHP_FUNCTION(imap_rfc822_write_address);
159 PHP_FUNCTION(imap_rfc822_parse_adrlist);
160 PHP_FUNCTION(imap_setflag_full);
161 PHP_FUNCTION(imap_clearflag_full);
162 PHP_FUNCTION(imap_sort);
163 PHP_FUNCTION(imap_fetchheader);
164 PHP_FUNCTION(imap_fetchtext);
165 PHP_FUNCTION(imap_uid);
166 PHP_FUNCTION(imap_msgno);
167 PHP_FUNCTION(imap_list);
168 PHP_FUNCTION(imap_list_full);
169 PHP_FUNCTION(imap_listscan);
170 PHP_FUNCTION(imap_lsub);
171 PHP_FUNCTION(imap_lsub_full);
172 PHP_FUNCTION(imap_create);
173 PHP_FUNCTION(imap_rename);
174 PHP_FUNCTION(imap_status);
175 PHP_FUNCTION(imap_bodystruct);
176 PHP_FUNCTION(imap_fetch_overview);
177 PHP_FUNCTION(imap_mail_compose);
178 PHP_FUNCTION(imap_alerts);
179 PHP_FUNCTION(imap_errors);
180 PHP_FUNCTION(imap_last_error);
181 PHP_FUNCTION(imap_mail);
182 PHP_FUNCTION(imap_search);
183 PHP_FUNCTION(imap_utf8);
184 PHP_FUNCTION(imap_utf7_decode);
185 PHP_FUNCTION(imap_utf7_encode);
186 #ifdef HAVE_IMAP_MUTF7
187 PHP_FUNCTION(imap_utf8_to_mutf7);
188 PHP_FUNCTION(imap_mutf7_to_utf8);
189 #endif
190 PHP_FUNCTION(imap_mime_header_decode);
191 PHP_FUNCTION(imap_thread);
192 PHP_FUNCTION(imap_timeout);
193 
194 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
195 PHP_FUNCTION(imap_get_quota);
196 PHP_FUNCTION(imap_get_quotaroot);
197 PHP_FUNCTION(imap_set_quota);
198 PHP_FUNCTION(imap_setacl);
199 PHP_FUNCTION(imap_getacl);
200 #endif
201 
202 
203 ZEND_BEGIN_MODULE_GLOBALS(imap)
204 	char *imap_user;
205 	char *imap_password;
206 
207 	STRINGLIST *imap_alertstack;
208 	ERRORLIST *imap_errorstack;
209 
210 	STRINGLIST *imap_folders;
211 	STRINGLIST *imap_folders_tail;
212 	STRINGLIST *imap_sfolders;
213 	STRINGLIST *imap_sfolders_tail;
214 	MESSAGELIST *imap_messages;
215 	MESSAGELIST *imap_messages_tail;
216 	FOBJECTLIST *imap_folder_objects;
217 	FOBJECTLIST *imap_folder_objects_tail;
218 	FOBJECTLIST *imap_sfolder_objects;
219 	FOBJECTLIST *imap_sfolder_objects_tail;
220 
221 	folderlist_style_t folderlist_style;
222 	long status_flags;
223 	unsigned long status_messages;
224 	unsigned long status_recent;
225 	unsigned long status_unseen;
226 	unsigned long status_uidnext;
227 	unsigned long status_uidvalidity;
228 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
229 	zval **quota_return;
230 	zval *imap_acl_list;
231 #endif
232 	/* php_stream for php_mail_gets() */
233 	php_stream *gets_stream;
234 	zend_bool enable_rsh;
235 ZEND_END_MODULE_GLOBALS(imap)
236 
237 #ifdef ZTS
238 # define IMAPG(v) TSRMG(imap_globals_id, zend_imap_globals *, v)
239 #else
240 # define IMAPG(v) (imap_globals.v)
241 #endif
242 
243 #else
244 
245 #define imap_module_ptr NULL
246 
247 #endif
248 
249 #define phpext_imap_ptr imap_module_ptr
250 
251 #endif /* PHP_IMAP_H */
252