xref: /PHP-8.0/ext/imap/php_imap.h (revision c1988749)
1 /*
2    +----------------------------------------------------------------------+
3    | Copyright (c) The PHP Group                                          |
4    +----------------------------------------------------------------------+
5    | This source file is subject to version 3.01 of the PHP license,      |
6    | that is bundled with this package in the file LICENSE, and is        |
7    | available through the world-wide-web at the following url:           |
8    | http://www.php.net/license/3_01.txt                                  |
9    | If you did not receive a copy of the PHP license and are unable to   |
10    | obtain it through the world-wide-web, please send a note to          |
11    | license@php.net so we can mail you a copy immediately.               |
12    +----------------------------------------------------------------------+
13    | Authors: Rex Logan           <veebert@dimensional.com>               |
14    |          Mark Musone         <musone@afterfive.com>                  |
15    |          Brian Wang          <brian@vividnet.com>                    |
16    |          Kaj-Michael Lang    <milang@tal.org>                        |
17    |          Antoni Pamies Olive <toni@readysoft.net>                    |
18    |          Rasmus Lerdorf      <rasmus@php.net>                        |
19    |          Chuck Hagenbuch     <chuck@horde.org>                       |
20    |          Andrew Skalski      <askalski@chekinc.com>                  |
21    |          Hartmut Holzgraefe  <hholzgra@php.net>                      |
22    |          Jani Taskinen       <sniper@iki.fi>                         |
23    |          Daniel R. Kalowsky  <kalowsky@php.net>                      |
24    | PHP 4.0 updates:  Zeev Suraski <zeev@php.net>                        |
25    +----------------------------------------------------------------------+
26  */
27 
28 #ifndef PHP_IMAP_H
29 #define PHP_IMAP_H
30 
31 #ifdef HAVE_IMAP
32 
33 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
34 
35  /* For now these appear on Windows, remove this check if it appears outside */
36 # ifdef PHP_WIN32
37  /* Undefine these LOG defines to avoid warnings */
38 #  undef LOG_EMERG
39 #  undef LOG_CRIT
40 #  undef LOG_ERR
41 #  undef LOG_WARNING
42 #  undef LOG_NOTICE
43 #  undef LOG_DEBUG
44 
45  /* c-client also redefines its own ftruncate */
46 #  undef ftruncate
47 # endif
48 
49  /* these are used for quota support */
50 # include "c-client.h"	/* includes mail.h and rfc822.h */
51 # include "imap4r1.h"	/* location of c-client quota functions */
52 #else
53 # include "mail.h"
54 # include "rfc822.h"
55 #endif
56 
57 extern zend_module_entry imap_module_entry;
58 #define imap_module_ptr &imap_module_entry
59 
60 #include "php_version.h"
61 #define PHP_IMAP_VERSION PHP_VERSION
62 
63 /* Data types */
64 
65 #ifdef IMAP41
66 #define LSIZE text.size
67 #define LTEXT text.data
68 #define DTYPE int
69 #define CONTENT_PART nested.part
70 #define CONTENT_MSG_BODY nested.msg->body
71 #define IMAPVER "Imap 4R1"
72 #else
73 #define LSIZE size
74 #define LTEXT text
75 #define DTYPE char
76 #define CONTENT_PART contents.part
77 #define CONTENT_MSG_BODY contents.msg.body
78 #define IMAPVER "Imap 4"
79 #endif
80 
81 
82 /* Determines how mm_list() and mm_lsub() are to return their results. */
83 typedef enum {
84 	FLIST_ARRAY,
85 	FLIST_OBJECT
86 } folderlist_style_t;
87 
88 typedef struct php_imap_le_struct {
89 	MAILSTREAM *imap_stream;
90 	long flags;
91 } pils;
92 
93 typedef struct php_imap_mailbox_struct {
94 	SIZEDTEXT text;
95 	DTYPE delimiter;
96 	long attributes;
97 	struct php_imap_mailbox_struct *next;
98 } FOBJECTLIST;
99 
100 typedef struct php_imap_error_struct {
101 	SIZEDTEXT text;
102 	long errflg;
103 	struct php_imap_error_struct *next;
104 } ERRORLIST;
105 
106 typedef struct _php_imap_message_struct {
107 	unsigned long msgid;
108 	struct _php_imap_message_struct *next;
109 } MESSAGELIST;
110 
111 
112 /* Functions */
113 
114 PHP_MINIT_FUNCTION(imap);
115 PHP_RINIT_FUNCTION(imap);
116 PHP_RSHUTDOWN_FUNCTION(imap);
117 PHP_MINFO_FUNCTION(imap);
118 
119 ZEND_BEGIN_MODULE_GLOBALS(imap)
120 	char *imap_user;
121 	char *imap_password;
122 
123 	STRINGLIST *imap_alertstack;
124 	ERRORLIST *imap_errorstack;
125 
126 	STRINGLIST *imap_folders;
127 	STRINGLIST *imap_folders_tail;
128 	STRINGLIST *imap_sfolders;
129 	STRINGLIST *imap_sfolders_tail;
130 	MESSAGELIST *imap_messages;
131 	MESSAGELIST *imap_messages_tail;
132 	FOBJECTLIST *imap_folder_objects;
133 	FOBJECTLIST *imap_folder_objects_tail;
134 	FOBJECTLIST *imap_sfolder_objects;
135 	FOBJECTLIST *imap_sfolder_objects_tail;
136 
137 	folderlist_style_t folderlist_style;
138 	long status_flags;
139 	unsigned long status_messages;
140 	unsigned long status_recent;
141 	unsigned long status_unseen;
142 	unsigned long status_uidnext;
143 	unsigned long status_uidvalidity;
144 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
145 	zval **quota_return;
146 	zval *imap_acl_list;
147 #endif
148 	/* php_stream for php_mail_gets() */
149 	php_stream *gets_stream;
150 	zend_bool enable_rsh;
151 ZEND_END_MODULE_GLOBALS(imap)
152 
153 #if defined(ZTS) && defined(COMPILE_DL_IMAP)
154 ZEND_TSRMLS_CACHE_EXTERN()
155 #endif
156 
157 ZEND_EXTERN_MODULE_GLOBALS(imap)
158 #define IMAPG(v) ZEND_MODULE_GLOBALS_ACCESSOR(imap, v)
159 
160 #else
161 
162 #define imap_module_ptr NULL
163 
164 #endif
165 
166 #define phpext_imap_ptr imap_module_ptr
167 
168 #endif /* PHP_IMAP_H */
169