xref: /PHP-8.1/ext/imap/php_imap.h (revision 01b3fc03)
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    | https://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_mailbox_struct {
89 	SIZEDTEXT text;
90 	DTYPE delimiter;
91 	long attributes;
92 	struct php_imap_mailbox_struct *next;
93 } FOBJECTLIST;
94 
95 typedef struct php_imap_error_struct {
96 	SIZEDTEXT text;
97 	long errflg;
98 	struct php_imap_error_struct *next;
99 } ERRORLIST;
100 
101 typedef struct _php_imap_message_struct {
102 	unsigned long msgid;
103 	struct _php_imap_message_struct *next;
104 } MESSAGELIST;
105 
106 
107 /* Functions */
108 
109 PHP_MINIT_FUNCTION(imap);
110 PHP_RINIT_FUNCTION(imap);
111 PHP_RSHUTDOWN_FUNCTION(imap);
112 PHP_MINFO_FUNCTION(imap);
113 
114 ZEND_BEGIN_MODULE_GLOBALS(imap)
115 	char *imap_user;
116 	char *imap_password;
117 
118 	STRINGLIST *imap_alertstack;
119 	ERRORLIST *imap_errorstack;
120 
121 	STRINGLIST *imap_folders;
122 	STRINGLIST *imap_folders_tail;
123 	STRINGLIST *imap_sfolders;
124 	STRINGLIST *imap_sfolders_tail;
125 	MESSAGELIST *imap_messages;
126 	MESSAGELIST *imap_messages_tail;
127 	FOBJECTLIST *imap_folder_objects;
128 	FOBJECTLIST *imap_folder_objects_tail;
129 	FOBJECTLIST *imap_sfolder_objects;
130 	FOBJECTLIST *imap_sfolder_objects_tail;
131 
132 	folderlist_style_t folderlist_style;
133 	long status_flags;
134 	unsigned long status_messages;
135 	unsigned long status_recent;
136 	unsigned long status_unseen;
137 	unsigned long status_uidnext;
138 	unsigned long status_uidvalidity;
139 #if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
140 	zval **quota_return;
141 	zval *imap_acl_list;
142 #endif
143 	/* php_stream for php_mail_gets() */
144 	php_stream *gets_stream;
145 	bool enable_rsh;
146 ZEND_END_MODULE_GLOBALS(imap)
147 
148 #if defined(ZTS) && defined(COMPILE_DL_IMAP)
149 ZEND_TSRMLS_CACHE_EXTERN()
150 #endif
151 
152 ZEND_EXTERN_MODULE_GLOBALS(imap)
153 #define IMAPG(v) ZEND_MODULE_GLOBALS_ACCESSOR(imap, v)
154 
155 #else
156 
157 #define imap_module_ptr NULL
158 
159 #endif
160 
161 #define phpext_imap_ptr imap_module_ptr
162 
163 #endif /* PHP_IMAP_H */
164