Diffstat (limited to 'libetpan/src/low-level/imap/mailimap_types.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libetpan/src/low-level/imap/mailimap_types.h | 3274 |
1 files changed, 3274 insertions, 0 deletions
diff --git a/libetpan/src/low-level/imap/mailimap_types.h b/libetpan/src/low-level/imap/mailimap_types.h new file mode 100644 index 0000000..532d2c0 --- a/dev/null +++ b/libetpan/src/low-level/imap/mailimap_types.h | |||
@@ -0,0 +1,3274 @@ | |||
1 | /* | ||
2 | * libEtPan! -- a mail stuff library | ||
3 | * | ||
4 | * Copyright (C) 2001, 2005 - DINH Viet Hoa | ||
5 | * All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. Neither the name of the libEtPan! project nor the names of its | ||
16 | * contributors may be used to endorse or promote products derived | ||
17 | * from this software without specific prior written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND | ||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE | ||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
29 | * SUCH DAMAGE. | ||
30 | */ | ||
31 | |||
32 | /* | ||
33 | * $Id$ | ||
34 | */ | ||
35 | |||
36 | /* | ||
37 | IMAP4rev1 grammar | ||
38 | |||
39 | address = "(" addr-name SP addr-adl SP addr-mailbox SP | ||
40 | addr-host ")" | ||
41 | |||
42 | addr-adl = nstring | ||
43 | ; Holds route from [RFC-822] route-addr if | ||
44 | ; non-NIL | ||
45 | |||
46 | addr-host = nstring | ||
47 | ; NIL indicates [RFC-822] group syntax. | ||
48 | ; Otherwise, holds [RFC-822] domain name | ||
49 | |||
50 | addr-mailbox = nstring | ||
51 | ; NIL indicates end of [RFC-822] group; if | ||
52 | ; non-NIL and addr-host is NIL, holds | ||
53 | ; [RFC-822] group name. | ||
54 | ; Otherwise, holds [RFC-822] local-part | ||
55 | ; after removing [RFC-822] quoting | ||
56 | |||
57 | |||
58 | |||
59 | addr-name = nstring | ||
60 | ; If non-NIL, holds phrase from [RFC-822] | ||
61 | ; mailbox after removing [RFC-822] quoting | ||
62 | |||
63 | append = "APPEND" SP mailbox [SP flag-list] [SP date-time] SP | ||
64 | literal | ||
65 | |||
66 | astring = 1*ASTRING-CHAR / string | ||
67 | |||
68 | ASTRING-CHAR = ATOM-CHAR / resp-specials | ||
69 | |||
70 | atom = 1*ATOM-CHAR | ||
71 | |||
72 | ATOM-CHAR = <any CHAR except atom-specials> | ||
73 | |||
74 | atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / | ||
75 | quoted-specials / resp-specials | ||
76 | |||
77 | authenticate = "AUTHENTICATE" SP auth-type *(CRLF base64) | ||
78 | |||
79 | auth-type = atom | ||
80 | ; Defined by [SASL] | ||
81 | |||
82 | base64 = *(4base64-char) [base64-terminal] | ||
83 | |||
84 | base64-char = ALPHA / DIGIT / "+" / "/" | ||
85 | ; Case-sensitive | ||
86 | |||
87 | base64-terminal = (2base64-char "==") / (3base64-char "=") | ||
88 | |||
89 | body = "(" (body-type-1part / body-type-mpart) ")" | ||
90 | |||
91 | body-extension = nstring / number / | ||
92 | "(" body-extension *(SP body-extension) ")" | ||
93 | ; Future expansion. Client implementations | ||
94 | ; MUST accept body-extension fields. Server | ||
95 | ; implementations MUST NOT generate | ||
96 | ; body-extension fields except as defined by | ||
97 | ; future standard or standards-track | ||
98 | ; revisions of this specification. | ||
99 | |||
100 | body-ext-1part = body-fld-md5 [SP body-fld-dsp [SP body-fld-lang | ||
101 | *(SP body-extension)]] | ||
102 | ; MUST NOT be returned on non-extensible | ||
103 | ; "BODY" fetch | ||
104 | |||
105 | |||
106 | body-ext-mpart = body-fld-param [SP body-fld-dsp [SP body-fld-lang | ||
107 | *(SP body-extension)]] | ||
108 | ; MUST NOT be returned on non-extensible | ||
109 | ; "BODY" fetch | ||
110 | |||
111 | body-fields = body-fld-param SP body-fld-id SP body-fld-desc SP | ||
112 | body-fld-enc SP body-fld-octets | ||
113 | |||
114 | body-fld-desc = nstring | ||
115 | |||
116 | body-fld-dsp = "(" string SP body-fld-param ")" / nil | ||
117 | |||
118 | body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ | ||
119 | "QUOTED-PRINTABLE") DQUOTE) / string | ||
120 | |||
121 | body-fld-id = nstring | ||
122 | |||
123 | body-fld-lang = nstring / "(" string *(SP string) ")" | ||
124 | |||
125 | body-fld-lines = number | ||
126 | |||
127 | body-fld-md5 = nstring | ||
128 | |||
129 | body-fld-octets = number | ||
130 | |||
131 | body-fld-param = "(" string SP string *(SP string SP string) ")" / nil | ||
132 | |||
133 | body-type-1part = (body-type-basic / body-type-msg / body-type-text) | ||
134 | [SP body-ext-1part] | ||
135 | |||
136 | body-type-basic = media-basic SP body-fields | ||
137 | ; MESSAGE subtype MUST NOT be "RFC822" | ||
138 | |||
139 | body-type-mpart = 1*body SP media-subtype | ||
140 | [SP body-ext-mpart] | ||
141 | |||
142 | body-type-msg = media-message SP body-fields SP envelope | ||
143 | SP body SP body-fld-lines | ||
144 | |||
145 | body-type-text = media-text SP body-fields SP body-fld-lines | ||
146 | |||
147 | capability = ("AUTH=" auth-type) / atom | ||
148 | ; New capabilities MUST begin with "X" or be | ||
149 | ; registered with IANA as standard or | ||
150 | ; standards-track | ||
151 | |||
152 | |||
153 | capability-data = "CAPABILITY" *(SP capability) SP "IMAP4rev1" | ||
154 | *(SP capability) | ||
155 | ; IMAP4rev1 servers which offer RFC 1730 | ||
156 | ; compatibility MUST list "IMAP4" as the first | ||
157 | ; capability. | ||
158 | |||
159 | CHAR8 = %x01-ff | ||
160 | ; any OCTET except NUL, %x00 | ||
161 | |||
162 | command = tag SP (command-any / command-auth / command-nonauth / | ||
163 | command-select) CRLF | ||
164 | ; Modal based on state | ||
165 | |||
166 | command-any = "CAPABILITY" / "LOGOUT" / "NOOP" / x-command | ||
167 | ; Valid in all states | ||
168 | |||
169 | command-auth = append / create / delete / examine / list / lsub / | ||
170 | rename / select / status / subscribe / unsubscribe | ||
171 | ; Valid only in Authenticated or Selected state | ||
172 | |||
173 | command-nonauth = login / authenticate | ||
174 | ; Valid only when in Not Authenticated state | ||
175 | |||
176 | command-select = "CHECK" / "CLOSE" / "EXPUNGE" / copy / fetch / store / | ||
177 | uid / search | ||
178 | ; Valid only when in Selected state | ||
179 | |||
180 | continue-req = "+" SP (resp-text / base64) CRLF | ||
181 | |||
182 | copy = "COPY" SP set SP mailbox | ||
183 | |||
184 | create = "CREATE" SP mailbox | ||
185 | ; Use of INBOX gives a NO error | ||
186 | |||
187 | date = date-text / DQUOTE date-text DQUOTE | ||
188 | |||
189 | date-day = 1*2DIGIT | ||
190 | ; Day of month | ||
191 | |||
192 | date-day-fixed = (SP DIGIT) / 2DIGIT | ||
193 | ; Fixed-format version of date-day | ||
194 | |||
195 | date-month = "Jan" / "Feb" / "Mar" / "Apr" / "May" / "Jun" / | ||
196 | "Jul" / "Aug" / "Sep" / "Oct" / "Nov" / "Dec" | ||
197 | |||
198 | date-text = date-day "-" date-month "-" date-year | ||
199 | |||
200 | date-year = 4DIGIT | ||
201 | |||
202 | date-time = DQUOTE date-day-fixed "-" date-month "-" date-year | ||
203 | SP time SP zone DQUOTE | ||
204 | |||
205 | delete = "DELETE" SP mailbox | ||
206 | ; Use of INBOX gives a NO error | ||
207 | |||
208 | digit-nz = %x31-39 | ||
209 | ; 1-9 | ||
210 | |||
211 | envelope = "(" env-date SP env-subject SP env-from SP env-sender SP | ||
212 | env-reply-to SP env-to SP env-cc SP env-bcc SP | ||
213 | env-in-reply-to SP env-message-id ")" | ||
214 | |||
215 | env-bcc = "(" 1*address ")" / nil | ||
216 | |||
217 | env-cc = "(" 1*address ")" / nil | ||
218 | |||
219 | env-date = nstring | ||
220 | |||
221 | env-from = "(" 1*address ")" / nil | ||
222 | |||
223 | env-in-reply-to = nstring | ||
224 | |||
225 | env-message-id = nstring | ||
226 | |||
227 | env-reply-to = "(" 1*address ")" / nil | ||
228 | |||
229 | env-sender = "(" 1*address ")" / nil | ||
230 | |||
231 | env-subject = nstring | ||
232 | |||
233 | env-to = "(" 1*address ")" / nil | ||
234 | |||
235 | examine = "EXAMINE" SP mailbox | ||
236 | |||
237 | fetch = "FETCH" SP set SP ("ALL" / "FULL" / "FAST" / fetch-att / | ||
238 | "(" fetch-att *(SP fetch-att) ")") | ||
239 | |||
240 | fetch-att = "ENVELOPE" / "FLAGS" / "INTERNALDATE" / | ||
241 | "RFC822" [".HEADER" / ".SIZE" / ".TEXT"] / | ||
242 | "BODY" ["STRUCTURE"] / "UID" / | ||
243 | "BODY" [".PEEK"] section ["<" number "." nz-number ">"] | ||
244 | |||
245 | flag = "\Answered" / "\Flagged" / "\Deleted" / | ||
246 | "\Seen" / "\Draft" / flag-keyword / flag-extension | ||
247 | ; Does not include "\Recent" | ||
248 | |||
249 | flag-extension = "\" atom | ||
250 | ; Future expansion. Client implementations | ||
251 | ; MUST accept flag-extension flags. Server | ||
252 | ; implementations MUST NOT generate | ||
253 | ; flag-extension flags except as defined by | ||
254 | ; future standard or standards-track | ||
255 | ; revisions of this specification. | ||
256 | |||
257 | flag-fetch = flag / "\Recent" | ||
258 | |||
259 | flag-keyword = atom | ||
260 | |||
261 | flag-list = "(" [flag *(SP flag)] ")" | ||
262 | |||
263 | flag-perm = flag / "\*" | ||
264 | |||
265 | greeting = "*" SP (resp-cond-auth / resp-cond-bye) CRLF | ||
266 | |||
267 | header-fld-name = astring | ||
268 | |||
269 | header-list = "(" header-fld-name *(SP header-fld-name) ")" | ||
270 | |||
271 | list = "LIST" SP mailbox SP list-mailbox | ||
272 | |||
273 | list-mailbox = 1*list-char / string | ||
274 | |||
275 | list-char = ATOM-CHAR / list-wildcards / resp-specials | ||
276 | |||
277 | list-wildcards = "%" / "*" | ||
278 | |||
279 | literal = "{" number "}" CRLF *CHAR8 | ||
280 | ; Number represents the number of CHAR8s | ||
281 | |||
282 | login = "LOGIN" SP userid SP password | ||
283 | |||
284 | lsub = "LSUB" SP mailbox SP list-mailbox | ||
285 | |||
286 | mailbox = "INBOX" / astring | ||
287 | ; INBOX is case-insensitive. All case variants of | ||
288 | ; INBOX (e.g. "iNbOx") MUST be interpreted as INBOX | ||
289 | ; not as an astring. An astring which consists of | ||
290 | ; the case-insensitive sequence "I" "N" "B" "O" "X" | ||
291 | ; is considered to be INBOX and not an astring. | ||
292 | ; Refer to section 5.1 for further | ||
293 | ; semantic details of mailbox names. | ||
294 | |||
295 | mailbox-data = "FLAGS" SP flag-list / "LIST" SP mailbox-list / | ||
296 | "LSUB" SP mailbox-list / "SEARCH" *(SP nz-number) / | ||
297 | "STATUS" SP mailbox SP "(" | ||
298 | [status-att SP number *(SP status-att SP number)] ")" / | ||
299 | number SP "EXISTS" / number SP "RECENT" | ||
300 | |||
301 | mailbox-list = "(" [mbx-list-flags] ")" SP | ||
302 | (DQUOTE QUOTED-CHAR DQUOTE / nil) SP mailbox | ||
303 | |||
304 | mbx-list-flags = *(mbx-list-oflag SP) mbx-list-sflag | ||
305 | *(SP mbx-list-oflag) / | ||
306 | mbx-list-oflag *(SP mbx-list-oflag) | ||
307 | |||
308 | mbx-list-oflag = "\Noinferiors" / flag-extension | ||
309 | ; Other flags; multiple possible per LIST response | ||
310 | |||
311 | mbx-list-sflag = "\Noselect" / "\Marked" / "\Unmarked" | ||
312 | ; Selectability flags; only one per LIST response | ||
313 | |||
314 | media-basic = ((DQUOTE ("APPLICATION" / "AUDIO" / "IMAGE" / "MESSAGE" / | ||
315 | "VIDEO") DQUOTE) / string) SP media-subtype | ||
316 | ; Defined in [MIME-IMT] | ||
317 | |||
318 | media-message = DQUOTE "MESSAGE" DQUOTE SP DQUOTE "RFC822" DQUOTE | ||
319 | ; Defined in [MIME-IMT] | ||
320 | |||
321 | media-subtype = string | ||
322 | ; Defined in [MIME-IMT] | ||
323 | |||
324 | media-text = DQUOTE "TEXT" DQUOTE SP media-subtype | ||
325 | ; Defined in [MIME-IMT] | ||
326 | |||
327 | message-data = nz-number SP ("EXPUNGE" / ("FETCH" SP msg-att)) | ||
328 | |||
329 | msg-att = "(" (msg-att-dynamic / msg-att-static) | ||
330 | *(SP (msg-att-dynamic / msg-att-static)) ")" | ||
331 | |||
332 | msg-att-dynamic = "FLAGS" SP "(" [flag-fetch *(SP flag-fetch)] ")" | ||
333 | ; MAY change for a message | ||
334 | |||
335 | msg-att-static = "ENVELOPE" SP envelope / "INTERNALDATE" SP date-time / | ||
336 | "RFC822" [".HEADER" / ".TEXT"] SP nstring / | ||
337 | "RFC822.SIZE" SP number / "BODY" ["STRUCTURE"] SP body / | ||
338 | "BODY" section ["<" number ">"] SP nstring / | ||
339 | "UID" SP uniqueid | ||
340 | ; MUST NOT change for a message | ||
341 | |||
342 | nil = "NIL" | ||
343 | |||
344 | nstring = string / nil | ||
345 | |||
346 | number = 1*DIGIT | ||
347 | ; Unsigned 32-bit integer | ||
348 | ; (0 <= n < 4,294,967,296) | ||
349 | |||
350 | nz-number = digit-nz *DIGIT | ||
351 | ; Non-zero unsigned 32-bit integer | ||
352 | ; (0 < n < 4,294,967,296) | ||
353 | |||
354 | password = astring | ||
355 | |||
356 | quoted = DQUOTE *QUOTED-CHAR DQUOTE | ||
357 | |||
358 | QUOTED-CHAR = <any TEXT-CHAR except quoted-specials> / | ||
359 | "\" quoted-specials | ||
360 | |||
361 | quoted-specials = DQUOTE / "\" | ||
362 | |||
363 | rename = "RENAME" SP mailbox SP mailbox | ||
364 | ; Use of INBOX as a destination gives a NO error | ||
365 | |||
366 | response = *(continue-req / response-data) response-done | ||
367 | |||
368 | response-data = "*" SP (resp-cond-state / resp-cond-bye / | ||
369 | mailbox-data / message-data / capability-data) CRLF | ||
370 | |||
371 | response-done = response-tagged / response-fatal | ||
372 | |||
373 | response-fatal = "*" SP resp-cond-bye CRLF | ||
374 | ; Server closes connection immediately | ||
375 | |||
376 | response-tagged = tag SP resp-cond-state CRLF | ||
377 | |||
378 | resp-cond-auth = ("OK" / "PREAUTH") SP resp-text | ||
379 | ; Authentication condition | ||
380 | |||
381 | resp-cond-bye = "BYE" SP resp-text | ||
382 | |||
383 | resp-cond-state = ("OK" / "NO" / "BAD") SP resp-text | ||
384 | ; Status condition | ||
385 | |||
386 | resp-specials = "]" | ||
387 | |||
388 | resp-text = ["[" resp-text-code "]" SP] text | ||
389 | |||
390 | resp-text-code = "ALERT" / | ||
391 | "BADCHARSET" [SP "(" astring *(SP astring) ")" ] / | ||
392 | capability-data / "PARSE" / | ||
393 | "PERMANENTFLAGS" SP "(" [flag-perm *(SP flag-perm)] ")" / | ||
394 | "READ-ONLY" / "READ-WRITE" / "TRYCREATE" / | ||
395 | "UIDNEXT" SP nz-number / "UIDVALIDITY" SP nz-number / | ||
396 | "UNSEEN" SP nz-number / | ||
397 | atom [SP 1*<any TEXT-CHAR except "]">] | ||
398 | |||
399 | search = "SEARCH" [SP "CHARSET" SP astring] 1*(SP search-key) | ||
400 | ; CHARSET argument to MUST be registered with IANA | ||
401 | |||
402 | search-key = "ALL" / "ANSWERED" / "BCC" SP astring / | ||
403 | "BEFORE" SP date / "BODY" SP astring / | ||
404 | "CC" SP astring / "DELETED" / "FLAGGED" / | ||
405 | "FROM" SP astring / "KEYWORD" SP flag-keyword / "NEW" / | ||
406 | "OLD" / "ON" SP date / "RECENT" / "SEEN" / | ||
407 | "SINCE" SP date / "SUBJECT" SP astring / | ||
408 | "TEXT" SP astring / "TO" SP astring / | ||
409 | "UNANSWERED" / "UNDELETED" / "UNFLAGGED" / | ||
410 | "UNKEYWORD" SP flag-keyword / "UNSEEN" / | ||
411 | ; Above this line were in [IMAP2] | ||
412 | "DRAFT" / "HEADER" SP header-fld-name SP astring / | ||
413 | "LARGER" SP number / "NOT" SP search-key / | ||
414 | "OR" SP search-key SP search-key / | ||
415 | "SENTBEFORE" SP date / "SENTON" SP date / | ||
416 | "SENTSINCE" SP date / "SMALLER" SP number / | ||
417 | "UID" SP set / "UNDRAFT" / set / | ||
418 | "(" search-key *(SP search-key) ")" | ||
419 | |||
420 | section = "[" [section-spec] "]" | ||
421 | |||
422 | section-msgtext = "HEADER" / "HEADER.FIELDS" [".NOT"] SP header-list / | ||
423 | "TEXT" | ||
424 | ; top-level or MESSAGE/RFC822 part | ||
425 | |||
426 | section-part = nz-number *("." nz-number) | ||
427 | ; body part nesting | ||
428 | |||
429 | section-spec = section-msgtext / (section-part ["." section-text]) | ||
430 | |||
431 | section-text = section-msgtext / "MIME" | ||
432 | ; text other than actual body part (headers, etc.) | ||
433 | |||
434 | select = "SELECT" SP mailbox | ||
435 | |||
436 | sequence-num = nz-number / "*" | ||
437 | ; * is the largest number in use. For message | ||
438 | ; sequence numbers, it is the number of messages | ||
439 | ; in the mailbox. For unique identifiers, it is | ||
440 | ; the unique identifier of the last message in | ||
441 | ; the mailbox. | ||
442 | |||
443 | set = sequence-num / (sequence-num ":" sequence-num) / | ||
444 | (set "," set) | ||
445 | ; Identifies a set of messages. For message | ||
446 | ; sequence numbers, these are consecutive | ||
447 | ; numbers from 1 to the number of messages in | ||
448 | ; the mailbox | ||
449 | ; Comma delimits individual numbers, colon | ||
450 | ; delimits between two numbers inclusive. | ||
451 | ; Example: 2,4:7,9,12:* is 2,4,5,6,7,9,12,13, | ||
452 | ; 14,15 for a mailbox with 15 messages. | ||
453 | |||
454 | |||
455 | status = "STATUS" SP mailbox SP "(" status-att *(SP status-att) ")" | ||
456 | |||
457 | status-att = "MESSAGES" / "RECENT" / "UIDNEXT" / "UIDVALIDITY" / | ||
458 | "UNSEEN" | ||
459 | |||
460 | store = "STORE" SP set SP store-att-flags | ||
461 | |||
462 | store-att-flags = (["+" / "-"] "FLAGS" [".SILENT"]) SP | ||
463 | (flag-list / (flag *(SP flag))) | ||
464 | |||
465 | string = quoted / literal | ||
466 | |||
467 | subscribe = "SUBSCRIBE" SP mailbox | ||
468 | |||
469 | tag = 1*<any ASTRING-CHAR except "+"> | ||
470 | |||
471 | text = 1*TEXT-CHAR | ||
472 | |||
473 | TEXT-CHAR = <any CHAR except CR and LF> | ||
474 | |||
475 | time = 2DIGIT ":" 2DIGIT ":" 2DIGIT | ||
476 | ; Hours minutes seconds | ||
477 | |||
478 | uid = "UID" SP (copy / fetch / search / store) | ||
479 | ; Unique identifiers used instead of message | ||
480 | ; sequence numbers | ||
481 | |||
482 | uniqueid = nz-number | ||
483 | ; Strictly ascending | ||
484 | |||
485 | unsubscribe = "UNSUBSCRIBE" SP mailbox | ||
486 | |||
487 | userid = astring | ||
488 | |||
489 | x-command = "X" atom <experimental command arguments> | ||
490 | |||
491 | zone = ("+" / "-") 4DIGIT | ||
492 | ; Signed four-digit value of hhmm representing | ||
493 | ; hours and minutes east of Greenwich (that is, | ||
494 | ; the amount that the given time differs from | ||
495 | ; Universal Time). Subtracting the timezone | ||
496 | ; from the given time will give the UT form. | ||
497 | ; The Universal Time zone is "+0000". | ||
498 | */ | ||
499 | |||
500 | |||
501 | #ifndef MAILIMAP_TYPES_H | ||
502 | |||
503 | #define MAILIMAP_TYPES_H | ||
504 | |||
505 | #ifdef __cplusplus | ||
506 | extern "C" { | ||
507 | #endif | ||
508 | |||
509 | #include <inttypes.h> | ||
510 | #include <libetpan/mailstream.h> | ||
511 | #include <libetpan/clist.h> | ||
512 | |||
513 | |||
514 | /* | ||
515 | IMPORTANT NOTE: | ||
516 | |||
517 | All allocation functions will take as argument allocated data | ||
518 | and will store these data in the structure they will allocate. | ||
519 | Data should be persistant during all the use of the structure | ||
520 | and will be freed by the free function of the structure | ||
521 | |||
522 | allocation functions will return NULL on failure | ||
523 | */ | ||
524 | |||
525 | |||
526 | /* | ||
527 | mailimap_address represents a mail address | ||
528 | |||
529 | - personal_name is the name to display in an address | ||
530 | '"name"' in '"name" <address@domain>', should be allocated | ||
531 | with a malloc() | ||
532 | |||
533 | - source_route is the source-route information in the | ||
534 | mail address (RFC 822), should be allocated with a malloc() | ||
535 | |||
536 | - mailbox_name is the name of the mailbox 'address' in | ||
537 | '"name" <address@domain>', should be allocated with a malloc() | ||
538 | |||
539 | - host_name is the name of the host 'domain' in | ||
540 | '"name" <address@domain>', should be allocated with a malloc() | ||
541 | |||
542 | if mailbox_name is not NULL and host_name is NULL, this is the name | ||
543 | of a group, the next addresses in the list are elements of the group | ||
544 | until we reach an address with a NULL mailbox_name. | ||
545 | */ | ||
546 | |||
547 | struct mailimap_address { | ||
548 | char * ad_personal_name; /* can be NULL */ | ||
549 | char * ad_source_route; /* can be NULL */ | ||
550 | char * ad_mailbox_name; /* can be NULL */ | ||
551 | char * ad_host_name; /* can be NULL */ | ||
552 | }; | ||
553 | |||
554 | |||
555 | struct mailimap_address * | ||
556 | mailimap_address_new(char * ad_personal_name, char * ad_source_route, | ||
557 | char * ad_mailbox_name, char * ad_host_name); | ||
558 | |||
559 | void mailimap_address_free(struct mailimap_address * addr); | ||
560 | |||
561 | |||
562 | /* this is the type of MIME body parsed by IMAP server */ | ||
563 | |||
564 | enum { | ||
565 | MAILIMAP_BODY_ERROR, | ||
566 | MAILIMAP_BODY_1PART, /* single part */ | ||
567 | MAILIMAP_BODY_MPART, /* multi-part */ | ||
568 | }; | ||
569 | |||
570 | /* | ||
571 | mailimap_body represent a MIME body parsed by IMAP server | ||
572 | |||
573 | - type is the type of the MIME part (single part or multipart) | ||
574 | |||
575 | - body_1part is defined if this is a single part | ||
576 | |||
577 | - body_mpart is defined if this is a multipart | ||
578 | */ | ||
579 | |||
580 | struct mailimap_body { | ||
581 | int bd_type; | ||
582 | /* can be MAILIMAP_BODY_1PART or MAILIMAP_BODY_MPART */ | ||
583 | union { | ||
584 | struct mailimap_body_type_1part * bd_body_1part; /* can be NULL */ | ||
585 | struct mailimap_body_type_mpart * bd_body_mpart; /* can be NULL */ | ||
586 | } bd_data; | ||
587 | }; | ||
588 | |||
589 | |||
590 | struct mailimap_body * | ||
591 | mailimap_body_new(int bd_type, | ||
592 | struct mailimap_body_type_1part * bd_body_1part, | ||
593 | struct mailimap_body_type_mpart * bd_body_mpart); | ||
594 | |||
595 | void mailimap_body_free(struct mailimap_body * body); | ||
596 | |||
597 | |||
598 | |||
599 | /* | ||
600 | this is the type of MIME body extension | ||
601 | */ | ||
602 | |||
603 | enum { | ||
604 | MAILIMAP_BODY_EXTENSION_ERROR, | ||
605 | MAILIMAP_BODY_EXTENSION_NSTRING, /* string */ | ||
606 | MAILIMAP_BODY_EXTENSION_NUMBER, /* number */ | ||
607 | MAILIMAP_BODY_EXTENSION_LIST, /* list of | ||
608 | (struct mailimap_body_extension *) */ | ||
609 | }; | ||
610 | |||
611 | /* | ||
612 | mailimap_body_extension is a future extension header field value | ||
613 | |||
614 | - type is the type of the body extension (string, number or | ||
615 | list of extension) | ||
616 | |||
617 | - nstring is a string value if the type is string | ||
618 | |||
619 | - number is a integer value if the type is number | ||
620 | |||
621 | - list is a list of body extension if the type is a list | ||
622 | */ | ||
623 | |||
624 | struct mailimap_body_extension { | ||
625 | int ext_type; | ||
626 | /* | ||
627 | can be MAILIMAP_BODY_EXTENSION_NSTRING, MAILIMAP_BODY_EXTENSION_NUMBER | ||
628 | or MAILIMAP_BODY_EXTENSION_LIST | ||
629 | */ | ||
630 | union { | ||
631 | char * ext_nstring; /* can be NULL */ | ||
632 | uint32_t ext_number; | ||
633 | clist * ext_body_extension_list; | ||
634 | /* list of (struct mailimap_body_extension *) */ | ||
635 | /* can be NULL */ | ||
636 | } ext_data; | ||
637 | }; | ||
638 | |||
639 | struct mailimap_body_extension * | ||
640 | mailimap_body_extension_new(int ext_type, char * ext_nstring, | ||
641 | uint32_t ext_number, | ||
642 | clist * ext_body_extension_list); | ||
643 | |||
644 | void mailimap_body_extension_free(struct mailimap_body_extension * be); | ||
645 | |||
646 | |||
647 | /* | ||
648 | mailimap_body_ext_1part is the extended result part of a single part | ||
649 | bodystructure. | ||
650 | |||
651 | - body_md5 is the value of the Content-MD5 header field, should be | ||
652 | allocated with malloc() | ||
653 | |||
654 | - body_disposition is the value of the Content-Disposition header field | ||
655 | |||
656 | - body_language is the value of the Content-Language header field | ||
657 | |||
658 | - body_extension_list is the list of extension fields value. | ||
659 | */ | ||
660 | |||
661 | struct mailimap_body_ext_1part { | ||
662 | char * bd_md5; /* != NULL */ | ||
663 | struct mailimap_body_fld_dsp * bd_disposition; /* can be NULL */ | ||
664 | struct mailimap_body_fld_lang * bd_language; /* can be NULL */ | ||
665 | |||
666 | clist * bd_extension_list; /* list of (struct mailimap_body_extension *) */ | ||
667 | /* can be NULL */ | ||
668 | }; | ||
669 | |||
670 | struct mailimap_body_ext_1part * | ||
671 | mailimap_body_ext_1part_new(char * bd_md5, | ||
672 | struct mailimap_body_fld_dsp * bd_disposition, | ||
673 | struct mailimap_body_fld_lang * bd_language, | ||
674 | clist * bd_extension_list); | ||
675 | |||
676 | |||
677 | void | ||
678 | mailimap_body_ext_1part_free(struct mailimap_body_ext_1part * body_ext_1part); | ||
679 | |||
680 | |||
681 | /* | ||
682 | mailimap_body_ext_mpart is the extended result part of a multipart | ||
683 | bodystructure. | ||
684 | |||
685 | - body_parameter is the list of parameters of Content-Type header field | ||
686 | |||
687 | - body_disposition is the value of Content-Disposition header field | ||
688 | |||
689 | - body_language is the value of Content-Language header field | ||
690 | |||
691 | - body_extension_list is the list of extension fields value. | ||
692 | */ | ||
693 | |||
694 | struct mailimap_body_ext_mpart { | ||
695 | struct mailimap_body_fld_param * bd_parameter; /* != NULL */ | ||
696 | struct mailimap_body_fld_dsp * bd_disposition; /* can be NULL */ | ||
697 | struct mailimap_body_fld_lang * bd_language; /* can be NULL */ | ||
698 | clist * bd_extension_list; /* list of (struct mailimap_body_extension *) */ | ||
699 | /* can be NULL */ | ||
700 | }; | ||
701 | |||
702 | struct mailimap_body_ext_mpart * | ||
703 | mailimap_body_ext_mpart_new(struct mailimap_body_fld_param * bd_parameter, | ||
704 | struct mailimap_body_fld_dsp * bd_disposition, | ||
705 | struct mailimap_body_fld_lang * bd_language, | ||
706 | clist * bd_extension_list); | ||
707 | |||
708 | void | ||
709 | mailimap_body_ext_mpart_free(struct mailimap_body_ext_mpart * body_ext_mpart); | ||
710 | |||
711 | |||
712 | /* | ||
713 | mailimap_body_fields is the MIME fields of a MIME part. | ||
714 | |||
715 | - body_parameter is the list of parameters of Content-Type header field | ||
716 | |||
717 | - body_id is the value of Content-ID header field, should be allocated | ||
718 | with malloc() | ||
719 | |||
720 | - body_description is the value of Content-Description header field, | ||
721 | should be allocated with malloc() | ||
722 | |||
723 | - body_encoding is the value of Content-Transfer-Encoding header field | ||
724 | |||
725 | - body_disposition is the value of Content-Disposition header field | ||
726 | |||
727 | - body_size is the size of the MIME part | ||
728 | */ | ||
729 | |||
730 | struct mailimap_body_fields { | ||
731 | struct mailimap_body_fld_param * bd_parameter; /* != NULL */ | ||
732 | char * bd_id; /* can be NULL */ | ||
733 | char * bd_description; /* can be NULL */ | ||
734 | struct mailimap_body_fld_enc * bd_encoding; /* != NULL */ | ||
735 | uint32_t bd_size; | ||
736 | }; | ||
737 | |||
738 | struct mailimap_body_fields * | ||
739 | mailimap_body_fields_new(struct mailimap_body_fld_param * bd_parameter, | ||
740 | char * bd_id, | ||
741 | char * bd_description, | ||
742 | struct mailimap_body_fld_enc * bd_encoding, | ||
743 | uint32_t bd_size); | ||
744 | |||
745 | void | ||
746 | mailimap_body_fields_free(struct mailimap_body_fields * body_fields); | ||
747 | |||
748 | |||
749 | |||
750 | /* | ||
751 | mailimap_body_fld_dsp is the parsed value of the Content-Disposition field | ||
752 | |||
753 | - disposition_type is the type of Content-Disposition | ||
754 | (usually attachment or inline), should be allocated with malloc() | ||
755 | |||
756 | - attributes is the list of Content-Disposition attributes | ||
757 | */ | ||
758 | |||
759 | struct mailimap_body_fld_dsp { | ||
760 | char * dsp_type; /* != NULL */ | ||
761 | struct mailimap_body_fld_param * dsp_attributes; /* != NULL */ | ||
762 | }; | ||
763 | |||
764 | struct mailimap_body_fld_dsp * | ||
765 | mailimap_body_fld_dsp_new(char * dsp_type, | ||
766 | struct mailimap_body_fld_param * dsp_attributes); | ||
767 | |||
768 | void mailimap_body_fld_dsp_free(struct mailimap_body_fld_dsp * bfd); | ||
769 | |||
770 | |||
771 | |||
772 | /* these are the different parsed values for Content-Transfer-Encoding */ | ||
773 | |||
774 | enum { | ||
775 | MAILIMAP_BODY_FLD_ENC_7BIT, /* 7bit */ | ||
776 | MAILIMAP_BODY_FLD_ENC_8BIT, /* 8bit */ | ||
777 | MAILIMAP_BODY_FLD_ENC_BINARY, /* binary */ | ||
778 | MAILIMAP_BODY_FLD_ENC_BASE64, /* base64 */ | ||
779 | MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE, /* quoted-printable */ | ||
780 | MAILIMAP_BODY_FLD_ENC_OTHER, /* other */ | ||
781 | }; | ||
782 | |||
783 | /* | ||
784 | mailimap_body_fld_enc is a parsed value for Content-Transfer-Encoding | ||
785 | |||
786 | - type is the kind of Content-Transfer-Encoding, this can be | ||
787 | MAILIMAP_BODY_FLD_ENC_7BIT, MAILIMAP_BODY_FLD_ENC_8BIT, | ||
788 | MAILIMAP_BODY_FLD_ENC_BINARY, MAILIMAP_BODY_FLD_ENC_BASE64, | ||
789 | MAILIMAP_BODY_FLD_ENC_QUOTED_PRINTABLE or MAILIMAP_BODY_FLD_ENC_OTHER | ||
790 | |||
791 | - in case of MAILIMAP_BODY_FLD_ENC_OTHER, this value is defined, | ||
792 | should be allocated with malloc() | ||
793 | */ | ||
794 | |||
795 | struct mailimap_body_fld_enc { | ||
796 | int enc_type; | ||
797 | char * enc_value; /* can be NULL */ | ||
798 | }; | ||
799 | |||
800 | struct mailimap_body_fld_enc * | ||
801 | mailimap_body_fld_enc_new(int enc_type, char * enc_value); | ||
802 | |||
803 | void mailimap_body_fld_enc_free(struct mailimap_body_fld_enc * bfe); | ||
804 | |||
805 | |||
806 | /* this is the type of Content-Language header field value */ | ||
807 | |||
808 | enum { | ||
809 | MAILIMAP_BODY_FLD_LANG_ERROR, /* error parse */ | ||
810 | MAILIMAP_BODY_FLD_LANG_SINGLE, /* single value */ | ||
811 | MAILIMAP_BODY_FLD_LANG_LIST /* list of values */ | ||
812 | }; | ||
813 | |||
814 | /* | ||
815 | mailimap_body_fld_lang is the parsed value of the Content-Language field | ||
816 | |||
817 | - type is the type of content, this can be MAILIMAP_BODY_FLD_LANG_SINGLE | ||
818 | if this is a single value or MAILIMAP_BODY_FLD_LANG_LIST if there are | ||
819 | several values | ||
820 | |||
821 | - single is the single value if the type is MAILIMAP_BODY_FLD_LANG_SINGLE, | ||
822 | should be allocated with malloc() | ||
823 | |||
824 | - list is the list of value if the type is MAILIMAP_BODY_FLD_LANG_LIST, | ||
825 | all elements of the list should be allocated with malloc() | ||
826 | */ | ||
827 | |||
828 | struct mailimap_body_fld_lang { | ||
829 | int lg_type; | ||
830 | union { | ||
831 | char * lg_single; /* can be NULL */ | ||
832 | clist * lg_list; /* list of string (char *), can be NULL */ | ||
833 | } lg_data; | ||
834 | }; | ||
835 | |||
836 | struct mailimap_body_fld_lang * | ||
837 | mailimap_body_fld_lang_new(int lg_type, char * lg_single, clist * lg_list); | ||
838 | |||
839 | void | ||
840 | mailimap_body_fld_lang_free(struct mailimap_body_fld_lang * fld_lang); | ||
841 | |||
842 | |||
843 | |||
844 | /* | ||
845 | mailimap_single_body_fld_param is a body field parameter | ||
846 | |||
847 | - name is the name of the parameter, should be allocated with malloc() | ||
848 | |||
849 | - value is the value of the parameter, should be allocated with malloc() | ||
850 | */ | ||
851 | |||
852 | struct mailimap_single_body_fld_param { | ||
853 | char * pa_name; /* != NULL */ | ||
854 | char * pa_value; /* != NULL */ | ||
855 | }; | ||
856 | |||
857 | struct mailimap_single_body_fld_param * | ||
858 | mailimap_single_body_fld_param_new(char * pa_name, char * pa_value); | ||
859 | |||
860 | void | ||
861 | mailimap_single_body_fld_param_free(struct mailimap_single_body_fld_param * p); | ||
862 | |||
863 | |||
864 | /* | ||
865 | mailmap_body_fld_param is a list of parameters | ||
866 | |||
867 | - list is the list of parameters. | ||
868 | */ | ||
869 | |||
870 | struct mailimap_body_fld_param { | ||
871 | clist * pa_list; /* list of (struct mailimap_single_body_fld_param *) */ | ||
872 | /* != NULL */ | ||
873 | }; | ||
874 | |||
875 | struct mailimap_body_fld_param * | ||
876 | mailimap_body_fld_param_new(clist * pa_list); | ||
877 | |||
878 | void | ||
879 | mailimap_body_fld_param_free(struct mailimap_body_fld_param * fld_param); | ||
880 | |||
881 | |||
882 | /* | ||
883 | this is the kind of single part: a text part | ||
884 | (when Content-Type is text/xxx), a message part (when Content-Type is | ||
885 | message/rfc2822) or a basic part (others than multpart/xxx) | ||
886 | */ | ||
887 | |||
888 | enum { | ||
889 | MAILIMAP_BODY_TYPE_1PART_ERROR, /* parse error */ | ||
890 | MAILIMAP_BODY_TYPE_1PART_BASIC, /* others then multipart/xxx */ | ||
891 | MAILIMAP_BODY_TYPE_1PART_MSG, /* message/rfc2822 */ | ||
892 | MAILIMAP_BODY_TYPE_1PART_TEXT /* text/xxx */ | ||
893 | }; | ||
894 | |||
895 | |||
896 | /* | ||
897 | mailimap_body_type_1part is | ||
898 | |||
899 | - type is the kind of single part, this can be | ||
900 | MAILIMAP_BODY_TYPE_1PART_BASIC, MAILIMAP_BODY_TYPE_1PART_MSG or | ||
901 | MAILIMAP_BODY_TYPE_1PART_TEXT. | ||
902 | |||
903 | - body_type_basic is the basic part when type is | ||
904 | MAILIMAP_BODY_TYPE_1PART_BASIC | ||
905 | |||
906 | - body_type_msg is the message part when type is | ||
907 | MAILIMAP_BODY_TYPE_1PART_MSG | ||
908 | |||
909 | - body_type_text is the text part when type is | ||
910 | MAILIMAP_BODY_TYPE_1PART_TEXT | ||
911 | */ | ||
912 | |||
913 | struct mailimap_body_type_1part { | ||
914 | int bd_type; | ||
915 | union { | ||
916 | struct mailimap_body_type_basic * bd_type_basic; /* can be NULL */ | ||
917 | struct mailimap_body_type_msg * bd_type_msg; /* can be NULL */ | ||
918 | struct mailimap_body_type_text * bd_type_text; /* can be NULL */ | ||
919 | } bd_data; | ||
920 | struct mailimap_body_ext_1part * bd_ext_1part; /* can be NULL */ | ||
921 | }; | ||
922 | |||
923 | struct mailimap_body_type_1part * | ||
924 | mailimap_body_type_1part_new(int bd_type, | ||
925 | struct mailimap_body_type_basic * bd_type_basic, | ||
926 | struct mailimap_body_type_msg * bd_type_msg, | ||
927 | struct mailimap_body_type_text * bd_type_text, | ||
928 | struct mailimap_body_ext_1part * bd_ext_1part); | ||
929 | |||
930 | void | ||
931 | mailimap_body_type_1part_free(struct mailimap_body_type_1part * bt1p); | ||
932 | |||
933 | |||
934 | |||
935 | /* | ||
936 | mailimap_body_type_basic is a basic field (with Content-Type other | ||
937 | than multipart/xxx, message/rfc2822 and text/xxx | ||
938 | |||
939 | - media_basic will be the MIME type of the part | ||
940 | |||
941 | - body_fields will be the parsed fields of the MIME part | ||
942 | */ | ||
943 | |||
944 | struct mailimap_body_type_basic { | ||
945 | struct mailimap_media_basic * bd_media_basic; /* != NULL */ | ||
946 | struct mailimap_body_fields * bd_fields; /* != NULL */ | ||
947 | }; | ||
948 | |||
949 | struct mailimap_body_type_basic * | ||
950 | mailimap_body_type_basic_new(struct mailimap_media_basic * bd_media_basic, | ||
951 | struct mailimap_body_fields * bd_fields); | ||
952 | |||
953 | void mailimap_body_type_basic_free(struct mailimap_body_type_basic * | ||
954 | body_type_basic); | ||
955 | |||
956 | /* | ||
957 | mailimap_body_type_mpart is a MIME multipart. | ||
958 | |||
959 | - body_list is the list of sub-parts. | ||
960 | |||
961 | - media_subtype is the subtype of the multipart (for example | ||
962 | in multipart/alternative, this is "alternative") | ||
963 | |||
964 | - body_ext_mpart is the extended fields of the MIME multipart | ||
965 | */ | ||
966 | |||
967 | struct mailimap_body_type_mpart { | ||
968 | clist * bd_list; /* list of (struct mailimap_body *) */ | ||
969 | /* != NULL */ | ||
970 | char * bd_media_subtype; /* != NULL */ | ||
971 | struct mailimap_body_ext_mpart * bd_ext_mpart; /* can be NULL */ | ||
972 | }; | ||
973 | |||
974 | struct mailimap_body_type_mpart * | ||
975 | mailimap_body_type_mpart_new(clist * bd_list, char * bd_media_subtype, | ||
976 | struct mailimap_body_ext_mpart * bd_ext_mpart); | ||
977 | |||
978 | void mailimap_body_type_mpart_free(struct mailimap_body_type_mpart * | ||
979 | body_type_mpart); | ||
980 | |||
981 | /* | ||
982 | mailimap_body_type_msg is a MIME message part | ||
983 | |||
984 | - body_fields is the MIME fields of the MIME message part | ||
985 | |||
986 | - envelope is the list of parsed RFC 822 fields of the MIME message | ||
987 | |||
988 | - body is the sub-part of the message | ||
989 | |||
990 | - body_lines is the number of lines of the message part | ||
991 | */ | ||
992 | |||
993 | struct mailimap_body_type_msg { | ||
994 | struct mailimap_body_fields * bd_fields; /* != NULL */ | ||
995 | struct mailimap_envelope * bd_envelope; /* != NULL */ | ||
996 | struct mailimap_body * bd_body; /* != NULL */ | ||
997 | uint32_t bd_lines; | ||
998 | }; | ||
999 | |||
1000 | struct mailimap_body_type_msg * | ||
1001 | mailimap_body_type_msg_new(struct mailimap_body_fields * bd_fields, | ||
1002 | struct mailimap_envelope * bd_envelope, | ||
1003 | struct mailimap_body * bd_body, | ||
1004 | uint32_t bd_lines); | ||
1005 | |||
1006 | void | ||
1007 | mailimap_body_type_msg_free(struct mailimap_body_type_msg * body_type_msg); | ||
1008 | |||
1009 | |||
1010 | |||
1011 | /* | ||
1012 | mailimap_body_type_text is a single MIME part where Content-Type is text/xxx | ||
1013 | |||
1014 | - media-text is the subtype of the text part (for example, in "text/plain", | ||
1015 | this is "plain", should be allocated with malloc() | ||
1016 | |||
1017 | - body_fields is the MIME fields of the MIME message part | ||
1018 | |||
1019 | - body_lines is the number of lines of the message part | ||
1020 | */ | ||
1021 | |||
1022 | struct mailimap_body_type_text { | ||
1023 | char * bd_media_text; /* != NULL */ | ||
1024 | struct mailimap_body_fields * bd_fields; /* != NULL */ | ||
1025 | uint32_t bd_lines; | ||
1026 | }; | ||
1027 | |||
1028 | struct mailimap_body_type_text * | ||
1029 | mailimap_body_type_text_new(char * bd_media_text, | ||
1030 | struct mailimap_body_fields * bd_fields, | ||
1031 | uint32_t bd_lines); | ||
1032 | |||
1033 | void | ||
1034 | mailimap_body_type_text_free(struct mailimap_body_type_text * body_type_text); | ||
1035 | |||
1036 | |||
1037 | |||
1038 | /* this is the type of capability field */ | ||
1039 | |||
1040 | enum { | ||
1041 | MAILIMAP_CAPABILITY_AUTH_TYPE, /* when the capability is an | ||
1042 | authentication type */ | ||
1043 | MAILIMAP_CAPABILITY_NAME, /* other type of capability */ | ||
1044 | }; | ||
1045 | |||
1046 | /* | ||
1047 | mailimap_capability is a capability of the IMAP server | ||
1048 | |||
1049 | - type is the type of capability, this is either a authentication type | ||
1050 | (MAILIMAP_CAPABILITY_AUTH_TYPE) or an other type of capability | ||
1051 | (MAILIMAP_CAPABILITY_NAME) | ||
1052 | |||
1053 | - auth_type is a type of authentication "name" in "AUTH=name", | ||
1054 | auth_type can be for example "PLAIN", when this is an authentication type, | ||
1055 | should be allocated with malloc() | ||
1056 | |||
1057 | - name is a type of capability when this is not an authentication type, | ||
1058 | should be allocated with malloc() | ||
1059 | */ | ||
1060 | |||
1061 | struct mailimap_capability { | ||
1062 | int cap_type; | ||
1063 | union { | ||
1064 | char * cap_auth_type; /* can be NULL */ | ||
1065 | char * cap_name; /* can be NULL */ | ||
1066 | } cap_data; | ||
1067 | }; | ||
1068 | |||
1069 | struct mailimap_capability * | ||
1070 | mailimap_capability_new(int cap_type, char * cap_auth_type, char * cap_name); | ||
1071 | |||
1072 | void mailimap_capability_free(struct mailimap_capability * c); | ||
1073 | |||
1074 | |||
1075 | |||
1076 | |||
1077 | /* | ||
1078 | mailimap_capability_data is a list of capability | ||
1079 | |||
1080 | - list is the list of capability | ||
1081 | */ | ||
1082 | |||
1083 | struct mailimap_capability_data { | ||
1084 | clist * cap_list; /* list of (struct mailimap_capability *), != NULL */ | ||
1085 | }; | ||
1086 | |||
1087 | struct mailimap_capability_data * | ||
1088 | mailimap_capability_data_new(clist * cap_list); | ||
1089 | |||
1090 | void | ||
1091 | mailimap_capability_data_free(struct mailimap_capability_data * cap_data); | ||
1092 | |||
1093 | |||
1094 | |||
1095 | /* this is the type of continue request data */ | ||
1096 | |||
1097 | enum { | ||
1098 | MAILIMAP_CONTINUE_REQ_ERROR, /* on parse error */ | ||
1099 | MAILIMAP_CONTINUE_REQ_TEXT, /* when data is a text response */ | ||
1100 | MAILIMAP_CONTINUE_REQ_BASE64, /* when data is a base64 response */ | ||
1101 | }; | ||
1102 | |||
1103 | /* | ||
1104 | mailimap_continue_req is a continue request (a response prefixed by "+") | ||
1105 | |||
1106 | - type is the type of continue request response | ||
1107 | MAILIMAP_CONTINUE_REQ_TEXT (when information data is text), | ||
1108 | MAILIMAP_CONTINUE_REQ_BASE64 (when information data is base64) | ||
1109 | |||
1110 | - text is the information of type text in case of text data | ||
1111 | |||
1112 | - base64 is base64 encoded data in the other case, should be allocated | ||
1113 | with malloc() | ||
1114 | */ | ||
1115 | |||
1116 | struct mailimap_continue_req { | ||
1117 | int cr_type; | ||
1118 | union { | ||
1119 | struct mailimap_resp_text * cr_text; /* can be NULL */ | ||
1120 | char * cr_base64; /* can be NULL */ | ||
1121 | } cr_data; | ||
1122 | }; | ||
1123 | |||
1124 | struct mailimap_continue_req * | ||
1125 | mailimap_continue_req_new(int cr_type, struct mailimap_resp_text * cr_text, | ||
1126 | char * cr_base64); | ||
1127 | |||
1128 | void mailimap_continue_req_free(struct mailimap_continue_req * cont_req); | ||
1129 | |||
1130 | |||
1131 | /* | ||
1132 | mailimap_date_time is a date | ||
1133 | |||
1134 | - day is the day of month (1 to 31) | ||
1135 | |||
1136 | - month (1 to 12) | ||
1137 | |||
1138 | - year (4 digits) | ||
1139 | |||
1140 | - hour (0 to 23) | ||
1141 | |||
1142 | - min (0 to 59) | ||
1143 | |||
1144 | - sec (0 to 59) | ||
1145 | |||
1146 | - zone (this is the decimal value that we can read, for example: | ||
1147 | for "-0200", the value is -200) | ||
1148 | */ | ||
1149 | |||
1150 | struct mailimap_date_time { | ||
1151 | int dt_day; | ||
1152 | int dt_month; | ||
1153 | int dt_year; | ||
1154 | int dt_hour; | ||
1155 | int dt_min; | ||
1156 | int dt_sec; | ||
1157 | int dt_zone; | ||
1158 | }; | ||
1159 | |||
1160 | struct mailimap_date_time * | ||
1161 | mailimap_date_time_new(int dt_day, int dt_month, int dt_year, int dt_hour, | ||
1162 | int dt_min, int dt_sec, int dt_zone); | ||
1163 | |||
1164 | void mailimap_date_time_free(struct mailimap_date_time * date_time); | ||
1165 | |||
1166 | |||
1167 | |||
1168 | /* | ||
1169 | mailimap_envelope is the list of fields that can be parsed by | ||
1170 | the IMAP server. | ||
1171 | |||
1172 | - date is the (non-parsed) content of the "Date" header field, | ||
1173 | should be allocated with malloc() | ||
1174 | |||
1175 | - subject is the subject of the message, should be allocated with | ||
1176 | malloc() | ||
1177 | |||
1178 | - sender is the the parsed content of the "Sender" field | ||
1179 | |||
1180 | - reply-to is the parsed content of the "Reply-To" field | ||
1181 | |||
1182 | - to is the parsed content of the "To" field | ||
1183 | |||
1184 | - cc is the parsed content of the "Cc" field | ||
1185 | |||
1186 | - bcc is the parsed content of the "Bcc" field | ||
1187 | |||
1188 | - in_reply_to is the content of the "In-Reply-To" field, | ||
1189 | should be allocated with malloc() | ||
1190 | |||
1191 | - message_id is the content of the "Message-ID" field, | ||
1192 | should be allocated with malloc() | ||
1193 | */ | ||
1194 | |||
1195 | struct mailimap_envelope { | ||
1196 | char * env_date; /* can be NULL */ | ||
1197 | char * env_subject; /* can be NULL */ | ||
1198 | struct mailimap_env_from * env_from; /* can be NULL */ | ||
1199 | struct mailimap_env_sender * env_sender; /* can be NULL */ | ||
1200 | struct mailimap_env_reply_to * env_reply_to; /* can be NULL */ | ||
1201 | struct mailimap_env_to * env_to; /* can be NULL */ | ||
1202 | struct mailimap_env_cc * env_cc; /* can be NULL */ | ||
1203 | struct mailimap_env_bcc * env_bcc; /* can be NULL */ | ||
1204 | char * env_in_reply_to; /* can be NULL */ | ||
1205 | char * env_message_id; /* can be NULL */ | ||
1206 | }; | ||
1207 | |||
1208 | struct mailimap_envelope * | ||
1209 | mailimap_envelope_new(char * env_date, char * env_subject, | ||
1210 | struct mailimap_env_from * env_from, | ||
1211 | struct mailimap_env_sender * env_sender, | ||
1212 | struct mailimap_env_reply_to * env_reply_to, | ||
1213 | struct mailimap_env_to * env_to, | ||
1214 | struct mailimap_env_cc* env_cc, | ||
1215 | struct mailimap_env_bcc * env_bcc, | ||
1216 | char * env_in_reply_to, char * env_message_id); | ||
1217 | |||
1218 | void mailimap_envelope_free(struct mailimap_envelope * env); | ||
1219 | |||
1220 | |||
1221 | |||
1222 | /* | ||
1223 | mailimap_env_bcc is the parsed "Bcc" field | ||
1224 | |||
1225 | - list is the list of addresses | ||
1226 | */ | ||
1227 | |||
1228 | struct mailimap_env_bcc { | ||
1229 | clist * bcc_list; /* list of (struct mailimap_address *), != NULL */ | ||
1230 | }; | ||
1231 | |||
1232 | struct mailimap_env_bcc * mailimap_env_bcc_new(clist * bcc_list); | ||
1233 | |||
1234 | void mailimap_env_bcc_free(struct mailimap_env_bcc * env_bcc); | ||
1235 | |||
1236 | |||
1237 | /* | ||
1238 | mailimap_env_cc is the parsed "Cc" field | ||
1239 | |||
1240 | - list is the list of addresses | ||
1241 | */ | ||
1242 | |||
1243 | struct mailimap_env_cc { | ||
1244 | clist * cc_list; /* list of (struct mailimap_address *), != NULL */ | ||
1245 | }; | ||
1246 | |||
1247 | struct mailimap_env_cc * mailimap_env_cc_new(clist * cc_list); | ||
1248 | |||
1249 | void mailimap_env_cc_free(struct mailimap_env_cc * env_cc); | ||
1250 | |||
1251 | |||
1252 | |||
1253 | /* | ||
1254 | mailimap_env_from is the parsed "From" field | ||
1255 | |||
1256 | - list is the list of addresses | ||
1257 | */ | ||
1258 | |||
1259 | struct mailimap_env_from { | ||
1260 | clist * frm_list; /* list of (struct mailimap_address *) */ | ||
1261 | /* != NULL */ | ||
1262 | }; | ||
1263 | |||
1264 | struct mailimap_env_from * mailimap_env_from_new(clist * frm_list); | ||
1265 | |||
1266 | void mailimap_env_from_free(struct mailimap_env_from * env_from); | ||
1267 | |||
1268 | |||
1269 | |||
1270 | /* | ||
1271 | mailimap_env_reply_to is the parsed "Reply-To" field | ||
1272 | |||
1273 | - list is the list of addresses | ||
1274 | */ | ||
1275 | |||
1276 | struct mailimap_env_reply_to { | ||
1277 | clist * rt_list; /* list of (struct mailimap_address *), != NULL */ | ||
1278 | }; | ||
1279 | |||
1280 | struct mailimap_env_reply_to * mailimap_env_reply_to_new(clist * rt_list); | ||
1281 | |||
1282 | void | ||
1283 | mailimap_env_reply_to_free(struct mailimap_env_reply_to * env_reply_to); | ||
1284 | |||
1285 | |||
1286 | |||
1287 | /* | ||
1288 | mailimap_env_sender is the parsed "Sender" field | ||
1289 | |||
1290 | - list is the list of addresses | ||
1291 | */ | ||
1292 | |||
1293 | struct mailimap_env_sender { | ||
1294 | clist * snd_list; /* list of (struct mailimap_address *), != NULL */ | ||
1295 | }; | ||
1296 | |||
1297 | struct mailimap_env_sender * mailimap_env_sender_new(clist * snd_list); | ||
1298 | |||
1299 | void mailimap_env_sender_free(struct mailimap_env_sender * env_sender); | ||
1300 | |||
1301 | |||
1302 | |||
1303 | /* | ||
1304 | mailimap_env_to is the parsed "To" field | ||
1305 | |||
1306 | - list is the list of addresses | ||
1307 | */ | ||
1308 | |||
1309 | struct mailimap_env_to { | ||
1310 | clist * to_list; /* list of (struct mailimap_address *), != NULL */ | ||
1311 | }; | ||
1312 | |||
1313 | struct mailimap_env_to * mailimap_env_to_new(clist * to_list); | ||
1314 | |||
1315 | void mailimap_env_to_free(struct mailimap_env_to * env_to); | ||
1316 | |||
1317 | |||
1318 | /* this is the type of flag */ | ||
1319 | |||
1320 | enum { | ||
1321 | MAILIMAP_FLAG_ANSWERED, /* \Answered flag */ | ||
1322 | MAILIMAP_FLAG_FLAGGED, /* \Flagged flag */ | ||
1323 | MAILIMAP_FLAG_DELETED, /* \Deleted flag */ | ||
1324 | MAILIMAP_FLAG_SEEN, /* \Seen flag */ | ||
1325 | MAILIMAP_FLAG_DRAFT, /* \Draft flag */ | ||
1326 | MAILIMAP_FLAG_KEYWORD, /* keyword flag */ | ||
1327 | MAILIMAP_FLAG_EXTENSION, /* \extension flag */ | ||
1328 | }; | ||
1329 | |||
1330 | |||
1331 | /* | ||
1332 | mailimap_flag is a message flag (that we can associate with a message) | ||
1333 | |||
1334 | - type is the type of the flag, MAILIMAP_FLAG_XXX | ||
1335 | |||
1336 | - keyword is the flag when the flag is of keyword type, | ||
1337 | should be allocated with malloc() | ||
1338 | |||
1339 | - extension is the flag when the flag is of extension type, should be | ||
1340 | allocated with malloc() | ||
1341 | */ | ||
1342 | |||
1343 | struct mailimap_flag { | ||
1344 | int fl_type; | ||
1345 | union { | ||
1346 | char * fl_keyword; /* can be NULL */ | ||
1347 | char * fl_extension; /* can be NULL */ | ||
1348 | } fl_data; | ||
1349 | }; | ||
1350 | |||
1351 | struct mailimap_flag * mailimap_flag_new(int fl_type, | ||
1352 | char * fl_keyword, char * fl_extension); | ||
1353 | |||
1354 | void mailimap_flag_free(struct mailimap_flag * f); | ||
1355 | |||
1356 | |||
1357 | |||
1358 | |||
1359 | /* this is the type of flag */ | ||
1360 | |||
1361 | enum { | ||
1362 | MAILIMAP_FLAG_FETCH_ERROR, /* on parse error */ | ||
1363 | MAILIMAP_FLAG_FETCH_RECENT, /* \Recent flag */ | ||
1364 | MAILIMAP_FLAG_FETCH_OTHER, /* other type of flag */ | ||
1365 | }; | ||
1366 | |||
1367 | /* | ||
1368 | mailimap_flag_fetch is a message flag (when we fetch it) | ||
1369 | |||
1370 | - type is the type of flag fetch | ||
1371 | |||
1372 | - flag is the flag when this is not a \Recent flag | ||
1373 | */ | ||
1374 | |||
1375 | struct mailimap_flag_fetch { | ||
1376 | int fl_type; | ||
1377 | struct mailimap_flag * fl_flag; /* can be NULL */ | ||
1378 | }; | ||
1379 | |||
1380 | struct mailimap_flag_fetch * | ||
1381 | mailimap_flag_fetch_new(int fl_type, struct mailimap_flag * fl_flag); | ||
1382 | |||
1383 | void mailimap_flag_fetch_free(struct mailimap_flag_fetch * flag_fetch); | ||
1384 | |||
1385 | |||
1386 | |||
1387 | |||
1388 | /* this is the type of flag */ | ||
1389 | |||
1390 | enum { | ||
1391 | MAILIMAP_FLAG_PERM_ERROR, /* on parse error */ | ||
1392 | MAILIMAP_FLAG_PERM_FLAG, /* to specify that usual flags can be changed */ | ||
1393 | MAILIMAP_FLAG_PERM_ALL /* to specify that new flags can be created */ | ||
1394 | }; | ||
1395 | |||
1396 | |||
1397 | /* | ||
1398 | mailimap_flag_perm is a flag returned in case of PERMANENTFLAGS response | ||
1399 | |||
1400 | - type is the type of returned PERMANENTFLAGS, it can be | ||
1401 | MAILIMAP_FLAG_PERM_FLAG (the given flag can be changed permanently) or | ||
1402 | MAILIMAP_FLAG_PERM_ALL (new flags can be created) | ||
1403 | |||
1404 | - flag is the given flag when type is MAILIMAP_FLAG_PERM_FLAG | ||
1405 | */ | ||
1406 | |||
1407 | struct mailimap_flag_perm { | ||
1408 | int fl_type; | ||
1409 | struct mailimap_flag * fl_flag; /* can be NULL */ | ||
1410 | }; | ||
1411 | |||
1412 | struct mailimap_flag_perm * | ||
1413 | mailimap_flag_perm_new(int fl_type, struct mailimap_flag * fl_flag); | ||
1414 | |||
1415 | void mailimap_flag_perm_free(struct mailimap_flag_perm * flag_perm); | ||
1416 | |||
1417 | |||
1418 | /* | ||
1419 | mailimap_flag_list is a list of flags | ||
1420 | |||
1421 | - list is a list of flags | ||
1422 | */ | ||
1423 | |||
1424 | struct mailimap_flag_list { | ||
1425 | clist * fl_list; /* list of (struct mailimap_flag *), != NULL */ | ||
1426 | }; | ||
1427 | |||
1428 | struct mailimap_flag_list * | ||
1429 | mailimap_flag_list_new(clist * fl_list); | ||
1430 | |||
1431 | void mailimap_flag_list_free(struct mailimap_flag_list * flag_list); | ||
1432 | |||
1433 | |||
1434 | |||
1435 | |||
1436 | /* this is the type of greeting response */ | ||
1437 | |||
1438 | enum { | ||
1439 | MAILIMAP_GREETING_RESP_COND_ERROR, /* on parse error */ | ||
1440 | MAILIMAP_GREETING_RESP_COND_AUTH, /* when connection is accepted */ | ||
1441 | MAILIMAP_GREETING_RESP_COND_BYE, /* when connection is refused */ | ||
1442 | }; | ||
1443 | |||
1444 | /* | ||
1445 | mailimap_greeting is the response returned on connection | ||
1446 | |||
1447 | - type is the type of response on connection, either | ||
1448 | MAILIMAP_GREETING_RESP_COND_AUTH if connection is accepted or | ||
1449 | MAIMIMAP_GREETING_RESP_COND_BYE if connection is refused | ||
1450 | */ | ||
1451 | |||
1452 | struct mailimap_greeting { | ||
1453 | int gr_type; | ||
1454 | union { | ||
1455 | struct mailimap_resp_cond_auth * gr_auth; /* can be NULL */ | ||
1456 | struct mailimap_resp_cond_bye * gr_bye; /* can be NULL */ | ||
1457 | } gr_data; | ||
1458 | }; | ||
1459 | |||
1460 | struct mailimap_greeting * | ||
1461 | mailimap_greeting_new(int gr_type, | ||
1462 | struct mailimap_resp_cond_auth * gr_auth, | ||
1463 | struct mailimap_resp_cond_bye * gr_bye); | ||
1464 | |||
1465 | void mailimap_greeting_free(struct mailimap_greeting * greeting); | ||
1466 | |||
1467 | |||
1468 | /* | ||
1469 | mailimap_header_list is a list of headers that can be specified when | ||
1470 | we want to fetch fields | ||
1471 | |||
1472 | - list is a list of header names, each header name should be allocated | ||
1473 | with malloc() | ||
1474 | */ | ||
1475 | |||
1476 | struct mailimap_header_list { | ||
1477 | clist * hdr_list; /* list of astring (char *), != NULL */ | ||
1478 | }; | ||
1479 | |||
1480 | struct mailimap_header_list * | ||
1481 | mailimap_header_list_new(clist * hdr_list); | ||
1482 | |||
1483 | void | ||
1484 | mailimap_header_list_free(struct mailimap_header_list * header_list); | ||
1485 | |||
1486 | |||
1487 | |||
1488 | /* this is the type of mailbox STATUS that can be returned */ | ||
1489 | |||
1490 | enum { | ||
1491 | MAILIMAP_STATUS_ATT_MESSAGES, /* when requesting the number of | ||
1492 | messages */ | ||
1493 | MAILIMAP_STATUS_ATT_RECENT, /* when requesting the number of | ||
1494 | recent messages */ | ||
1495 | MAILIMAP_STATUS_ATT_UIDNEXT, /* when requesting the next unique | ||
1496 | identifier */ | ||
1497 | MAILIMAP_STATUS_ATT_UIDVALIDITY, /* when requesting the validity of | ||
1498 | message unique identifiers*/ | ||
1499 | MAILIMAP_STATUS_ATT_UNSEEN, /* when requesting the number of | ||
1500 | unseen messages */ | ||
1501 | }; | ||
1502 | |||
1503 | /* | ||
1504 | mailimap_status_info is a returned information when a STATUS of | ||
1505 | a mailbox is requested | ||
1506 | |||
1507 | - att is the type of mailbox STATUS, the value can be | ||
1508 | MAILIMAP_STATUS_ATT_MESSAGES, MAILIMAP_STATUS_ATT_RECENT, | ||
1509 | MAILIMAP_STATUS_ATT_UIDNEXT, MAILIMAP_STATUS_ATT_UIDVALIDITY or | ||
1510 | MAILIMAP_STATUS_ATT_UNSEEN | ||
1511 | |||
1512 | - value is the value of the given information | ||
1513 | */ | ||
1514 | |||
1515 | struct mailimap_status_info { | ||
1516 | int st_att; | ||
1517 | uint32_t st_value; | ||
1518 | }; | ||
1519 | |||
1520 | struct mailimap_status_info * | ||
1521 | mailimap_status_info_new(int st_att, uint32_t st_value); | ||
1522 | |||
1523 | void mailimap_status_info_free(struct mailimap_status_info * info); | ||
1524 | |||
1525 | |||
1526 | |||
1527 | /* | ||
1528 | mailimap_mailbox_data_status is the list of information returned | ||
1529 | when a STATUS of a mailbox is requested | ||
1530 | |||
1531 | - mailbox is the name of the mailbox, should be allocated with malloc() | ||
1532 | |||
1533 | - status_info_list is the list of information returned | ||
1534 | */ | ||
1535 | |||
1536 | struct mailimap_mailbox_data_status { | ||
1537 | char * st_mailbox; | ||
1538 | clist * st_info_list; /* list of (struct mailimap_status_info *) */ | ||
1539 | /* can be NULL */ | ||
1540 | }; | ||
1541 | |||
1542 | struct mailimap_mailbox_data_status * | ||
1543 | mailimap_mailbox_data_status_new(char * st_mailbox, | ||
1544 | clist * st_info_list); | ||
1545 | |||
1546 | void | ||
1547 | mailimap_mailbox_data_status_free(struct mailimap_mailbox_data_status * info); | ||
1548 | |||
1549 | |||
1550 | |||
1551 | /* this is the type of mailbox information that is returned */ | ||
1552 | |||
1553 | enum { | ||
1554 | MAILIMAP_MAILBOX_DATA_ERROR, /* on parse error */ | ||
1555 | MAILIMAP_MAILBOX_DATA_FLAGS, /* flag that are applicable to the mailbox */ | ||
1556 | MAILIMAP_MAILBOX_DATA_LIST, /* this is a mailbox in the list of mailboxes | ||
1557 | returned on LIST command*/ | ||
1558 | MAILIMAP_MAILBOX_DATA_LSUB, /* this is a mailbox in the list of | ||
1559 | subscribed mailboxes returned on LSUB | ||
1560 | command */ | ||
1561 | MAILIMAP_MAILBOX_DATA_SEARCH, /* this is a list of messages numbers or | ||
1562 | unique identifiers returned | ||
1563 | on a SEARCH command*/ | ||
1564 | MAILIMAP_MAILBOX_DATA_STATUS, /* this is the list of information returned | ||
1565 | on a STATUS command */ | ||
1566 | MAILIMAP_MAILBOX_DATA_EXISTS, /* this is the number of messages in the | ||
1567 | mailbox */ | ||
1568 | MAILIMAP_MAILBOX_DATA_RECENT, /* this is the number of recent messages | ||
1569 | in the mailbox */ | ||
1570 | }; | ||
1571 | |||
1572 | /* | ||
1573 | mailimap_mailbox_data is an information related to a mailbox | ||
1574 | |||
1575 | - type is the type of mailbox_data that is filled, the value of this field | ||
1576 | can be MAILIMAP_MAILBOX_DATA_FLAGS, MAILIMAP_MAILBOX_DATA_LIST, | ||
1577 | MAILIMAP_MAILBOX_DATA_LSUB, MAILIMAP_MAILBOX_DATA_SEARCH, | ||
1578 | MAILIMAP_MAILBOX_DATA_STATUS, MAILIMAP_MAILBOX_DATA_EXISTS | ||
1579 | or MAILIMAP_MAILBOX_DATA_RECENT. | ||
1580 | |||
1581 | - flags is the flags that are applicable to the mailbox when | ||
1582 | type is MAILIMAP_MAILBOX_DATA_FLAGS | ||
1583 | |||
1584 | - list is a mailbox in the list of mailboxes returned on LIST command | ||
1585 | when type is MAILIMAP_MAILBOX_DATA_LIST | ||
1586 | |||
1587 | - lsub is a mailbox in the list of subscribed mailboxes returned on | ||
1588 | LSUB command when type is MAILIMAP_MAILBOX_DATA_LSUB | ||
1589 | |||
1590 | - search is a list of messages numbers or unique identifiers returned | ||
1591 | on SEARCH command when type MAILIMAP_MAILBOX_DATA_SEARCH, each element | ||
1592 | should be allocated with malloc() | ||
1593 | |||
1594 | - status is a list of information returned on STATUS command when | ||
1595 | type is MAILIMAP_MAILBOX_DATA_STATUS | ||
1596 | |||
1597 | - exists is the number of messages in the mailbox when type | ||
1598 | is MAILIMAP_MAILBOX_DATA_EXISTS | ||
1599 | |||
1600 | - recent is the number of recent messages in the mailbox when type | ||
1601 | is MAILIMAP_MAILBOX_DATA_RECENT | ||
1602 | */ | ||
1603 | |||
1604 | struct mailimap_mailbox_data { | ||
1605 | int mbd_type; | ||
1606 | union { | ||
1607 | struct mailimap_flag_list * mbd_flags; /* can be NULL */ | ||
1608 | struct mailimap_mailbox_list * mbd_list; /* can be NULL */ | ||
1609 | struct mailimap_mailbox_list * mbd_lsub; /* can be NULL */ | ||
1610 | clist * mbd_search; /* list of nz-number (uint32_t *), can be NULL */ | ||
1611 | struct mailimap_mailbox_data_status * mbd_status; /* can be NULL */ | ||
1612 | uint32_t mbd_exists; | ||
1613 | uint32_t mbd_recent; | ||
1614 | } mbd_data; | ||
1615 | }; | ||
1616 | |||
1617 | struct mailimap_mailbox_data * | ||
1618 | mailimap_mailbox_data_new(int mbd_type, struct mailimap_flag_list * mbd_flags, | ||
1619 | struct mailimap_mailbox_list * mbd_list, | ||
1620 | struct mailimap_mailbox_list * mbd_lsub, | ||
1621 | clist * mbd_search, | ||
1622 | struct mailimap_mailbox_data_status * mbd_status, | ||
1623 | uint32_t mbd_exists, | ||
1624 | uint32_t mbd_recent); | ||
1625 | |||
1626 | void | ||
1627 | mailimap_mailbox_data_free(struct mailimap_mailbox_data * mb_data); | ||
1628 | |||
1629 | |||
1630 | |||
1631 | /* this is the type of mailbox flags */ | ||
1632 | |||
1633 | enum { | ||
1634 | MAILIMAP_MBX_LIST_FLAGS_SFLAG, /* mailbox single flag - a flag in | ||
1635 | {\NoSelect, \Marked, \Unmarked} */ | ||
1636 | MAILIMAP_MBX_LIST_FLAGS_NO_SFLAG, /* mailbox other flag - mailbox flag | ||
1637 | other than \NoSelect \Marked and | ||
1638 | \Unmarked) */ | ||
1639 | }; | ||
1640 | |||
1641 | /* this is a single flag type */ | ||
1642 | |||
1643 | enum { | ||
1644 | MAILIMAP_MBX_LIST_SFLAG_ERROR, | ||
1645 | MAILIMAP_MBX_LIST_SFLAG_MARKED, | ||
1646 | MAILIMAP_MBX_LIST_SFLAG_NOSELECT, | ||
1647 | MAILIMAP_MBX_LIST_SFLAG_UNMARKED | ||
1648 | }; | ||
1649 | |||
1650 | /* | ||
1651 | mailimap_mbx_list_flags is a mailbox flag | ||
1652 | |||
1653 | - type is the type of mailbox flag, it can be MAILIMAP_MBX_LIST_FLAGS_SFLAG, | ||
1654 | or MAILIMAP_MBX_LIST_FLAGS_NO_SFLAG. | ||
1655 | |||
1656 | - oflags is a list of "mailbox other flag" | ||
1657 | |||
1658 | - sflag is a mailbox single flag | ||
1659 | */ | ||
1660 | |||
1661 | struct mailimap_mbx_list_flags { | ||
1662 | int mbf_type; | ||
1663 | clist * mbf_oflags; /* list of | ||
1664 | (struct mailimap_mbx_list_oflag *), != NULL */ | ||
1665 | int mbf_sflag; | ||
1666 | }; | ||
1667 | |||
1668 | struct mailimap_mbx_list_flags * | ||
1669 | mailimap_mbx_list_flags_new(int mbf_type, | ||
1670 | clist * mbf_oflags, int mbf_sflag); | ||
1671 | |||
1672 | void | ||
1673 | mailimap_mbx_list_flags_free(struct mailimap_mbx_list_flags * mbx_list_flags); | ||
1674 | |||
1675 | |||
1676 | |||
1677 | /* this is the type of the mailbox other flag */ | ||
1678 | |||
1679 | enum { | ||
1680 | MAILIMAP_MBX_LIST_OFLAG_ERROR, /* on parse error */ | ||
1681 | MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS, /* \NoInferior flag */ | ||
1682 | MAILIMAP_MBX_LIST_OFLAG_FLAG_EXT /* other flag */ | ||
1683 | }; | ||
1684 | |||
1685 | /* | ||
1686 | mailimap_mbx_list_oflag is a mailbox other flag | ||
1687 | |||
1688 | - type can be MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS when this is | ||
1689 | a \NoInferior flag or MAILIMAP_MBX_LIST_OFLAG_FLAG_EXT | ||
1690 | |||
1691 | - flag_ext is set when MAILIMAP_MBX_LIST_OFLAG_FLAG_EXT and is | ||
1692 | an extension flag, should be allocated with malloc() | ||
1693 | */ | ||
1694 | |||
1695 | struct mailimap_mbx_list_oflag { | ||
1696 | int of_type; | ||
1697 | char * of_flag_ext; /* can be NULL */ | ||
1698 | }; | ||
1699 | |||
1700 | struct mailimap_mbx_list_oflag * | ||
1701 | mailimap_mbx_list_oflag_new(int of_type, char * of_flag_ext); | ||
1702 | |||
1703 | void | ||
1704 | mailimap_mbx_list_oflag_free(struct mailimap_mbx_list_oflag * oflag); | ||
1705 | |||
1706 | |||
1707 | |||
1708 | /* | ||
1709 | mailimap_mailbox_list is a list of mailbox flags | ||
1710 | |||
1711 | - mb_flag is a list of mailbox flags | ||
1712 | |||
1713 | - delimiter is the delimiter of the mailbox path | ||
1714 | |||
1715 | - mb is the name of the mailbox, should be allocated with malloc() | ||
1716 | */ | ||
1717 | |||
1718 | struct mailimap_mailbox_list { | ||
1719 | struct mailimap_mbx_list_flags * mb_flag; /* can be NULL */ | ||
1720 | char mb_delimiter; | ||
1721 | char * mb_name; /* != NULL */ | ||
1722 | }; | ||
1723 | |||
1724 | struct mailimap_mailbox_list * | ||
1725 | mailimap_mailbox_list_new(struct mailimap_mbx_list_flags * mbx_flags, | ||
1726 | char mb_delimiter, char * mb_name); | ||
1727 | |||
1728 | void | ||
1729 | mailimap_mailbox_list_free(struct mailimap_mailbox_list * mb_list); | ||
1730 | |||
1731 | |||
1732 | |||
1733 | /* this is the MIME type */ | ||
1734 | |||
1735 | enum { | ||
1736 | MAILIMAP_MEDIA_BASIC_APPLICATION, /* application/xxx */ | ||
1737 | MAILIMAP_MEDIA_BASIC_AUDIO, /* audio/xxx */ | ||
1738 | MAILIMAP_MEDIA_BASIC_IMAGE, /* image/xxx */ | ||
1739 | MAILIMAP_MEDIA_BASIC_MESSAGE, /* message/xxx */ | ||
1740 | MAILIMAP_MEDIA_BASIC_VIDEO, /* video/xxx */ | ||
1741 | MAILIMAP_MEDIA_BASIC_OTHER, /* for all other cases */ | ||
1742 | }; | ||
1743 | |||
1744 | |||
1745 | /* | ||
1746 | mailimap_media_basic is the MIME type | ||
1747 | |||
1748 | - type can be MAILIMAP_MEDIA_BASIC_APPLICATION, MAILIMAP_MEDIA_BASIC_AUDIO, | ||
1749 | MAILIMAP_MEDIA_BASIC_IMAGE, MAILIMAP_MEDIA_BASIC_MESSAGE, | ||
1750 | MAILIMAP_MEDIA_BASIC_VIDEO or MAILIMAP_MEDIA_BASIC_OTHER | ||
1751 | |||
1752 | - basic_type is defined when type is MAILIMAP_MEDIA_BASIC_OTHER, should | ||
1753 | be allocated with malloc() | ||
1754 | |||
1755 | - subtype is the subtype of the MIME type, for example, this is | ||
1756 | "data" in "application/data", should be allocated with malloc() | ||
1757 | */ | ||
1758 | |||
1759 | struct mailimap_media_basic { | ||
1760 | int med_type; | ||
1761 | char * med_basic_type; /* can be NULL */ | ||
1762 | char * med_subtype; /* != NULL */ | ||
1763 | }; | ||
1764 | |||
1765 | struct mailimap_media_basic * | ||
1766 | mailimap_media_basic_new(int med_type, | ||
1767 | char * med_basic_type, char * med_subtype); | ||
1768 | |||
1769 | void | ||
1770 | mailimap_media_basic_free(struct mailimap_media_basic * media_basic); | ||
1771 | |||
1772 | |||
1773 | |||
1774 | /* this is the type of message data */ | ||
1775 | |||
1776 | enum { | ||
1777 | MAILIMAP_MESSAGE_DATA_ERROR, | ||
1778 | MAILIMAP_MESSAGE_DATA_EXPUNGE, | ||
1779 | MAILIMAP_MESSAGE_DATA_FETCH | ||
1780 | }; | ||
1781 | |||
1782 | /* | ||
1783 | mailimap_message_data is an information related to a message | ||
1784 | |||
1785 | - number is the number or the unique identifier of the message | ||
1786 | |||
1787 | - type is the type of information, this value can be | ||
1788 | MAILIMAP_MESSAGE_DATA_EXPUNGE or MAILIMAP_MESSAGE_DATA_FETCH | ||
1789 | |||
1790 | - msg_att is the message data | ||
1791 | */ | ||
1792 | |||
1793 | struct mailimap_message_data { | ||
1794 | uint32_t mdt_number; | ||
1795 | int mdt_type; | ||
1796 | struct mailimap_msg_att * mdt_msg_att; /* can be NULL */ | ||
1797 | /* if type = EXPUNGE, can be NULL */ | ||
1798 | }; | ||
1799 | |||
1800 | struct mailimap_message_data * | ||
1801 | mailimap_message_data_new(uint32_t mdt_number, int mdt_type, | ||
1802 | struct mailimap_msg_att * mdt_msg_att); | ||
1803 | |||
1804 | void | ||
1805 | mailimap_message_data_free(struct mailimap_message_data * msg_data); | ||
1806 | |||
1807 | |||
1808 | |||
1809 | /* this the type of the message attributes */ | ||
1810 | |||
1811 | enum { | ||
1812 | MAILIMAP_MSG_ATT_ITEM_ERROR, /* on parse error */ | ||
1813 | MAILIMAP_MSG_ATT_ITEM_DYNAMIC, /* dynamic message attributes (flags) */ | ||
1814 | MAILIMAP_MSG_ATT_ITEM_STATIC, /* static messages attributes | ||
1815 | (message content) */ | ||
1816 | }; | ||
1817 | |||
1818 | /* | ||
1819 | mailimap_msg_att_item is a message attribute | ||
1820 | |||
1821 | - type is the type of message attribute, the value can be | ||
1822 | MAILIMAP_MSG_ATT_ITEM_DYNAMIC or MAILIMAP_MSG_ATT_ITEM_STATIC | ||
1823 | |||
1824 | - msg_att_dyn is a dynamic message attribute when type is | ||
1825 | MAILIMAP_MSG_ATT_ITEM_DYNAMIC | ||
1826 | |||
1827 | - msg_att_static is a static message attribute when type is | ||
1828 | MAILIMAP_MSG_ATT_ITEM_STATIC | ||
1829 | */ | ||
1830 | |||
1831 | struct mailimap_msg_att_item { | ||
1832 | int att_type; | ||
1833 | union { | ||
1834 | struct mailimap_msg_att_dynamic * att_dyn; /* can be NULL */ | ||
1835 | struct mailimap_msg_att_static * att_static; /* can be NULL */ | ||
1836 | } att_data; | ||
1837 | }; | ||
1838 | |||
1839 | struct mailimap_msg_att_item * | ||
1840 | mailimap_msg_att_item_new(int att_type, | ||
1841 | struct mailimap_msg_att_dynamic * att_dyn, | ||
1842 | struct mailimap_msg_att_static * att_static); | ||
1843 | |||
1844 | void | ||
1845 | mailimap_msg_att_item_free(struct mailimap_msg_att_item * item); | ||
1846 | |||
1847 | |||
1848 | /* | ||
1849 | mailimap_msg_att is a list of attributes | ||
1850 | |||
1851 | - list is a list of message attributes | ||
1852 | |||
1853 | - number is the message number or unique identifier, this field | ||
1854 | has been added for implementation purpose | ||
1855 | */ | ||
1856 | |||
1857 | struct mailimap_msg_att { | ||
1858 | clist * att_list; /* list of (struct mailimap_msg_att_item *) */ | ||
1859 | /* != NULL */ | ||
1860 | uint32_t att_number; /* extra field to store the message number, | ||
1861 | used for mailimap */ | ||
1862 | }; | ||
1863 | |||
1864 | struct mailimap_msg_att * mailimap_msg_att_new(clist * att_list); | ||
1865 | |||
1866 | void mailimap_msg_att_free(struct mailimap_msg_att * msg_att); | ||
1867 | |||
1868 | |||
1869 | /* | ||
1870 | mailimap_msg_att_dynamic is a dynamic message attribute | ||
1871 | |||
1872 | - list is a list of flags (that have been fetched) | ||
1873 | */ | ||
1874 | |||
1875 | struct mailimap_msg_att_dynamic { | ||
1876 | clist * att_list; /* list of (struct mailimap_flag_fetch *) */ | ||
1877 | /* can be NULL */ | ||
1878 | }; | ||
1879 | |||
1880 | struct mailimap_msg_att_dynamic * | ||
1881 | mailimap_msg_att_dynamic_new(clist * att_list); | ||
1882 | |||
1883 | void | ||
1884 | mailimap_msg_att_dynamic_free(struct mailimap_msg_att_dynamic * msg_att_dyn); | ||
1885 | |||
1886 | |||
1887 | |||
1888 | /* | ||
1889 | mailimap_msg_att_body_section is a MIME part content | ||
1890 | |||
1891 | - section is the location of the MIME part in the message | ||
1892 | |||
1893 | - origin_octet is the offset of the requested part of the MIME part | ||
1894 | |||
1895 | - body_part is the content or partial content of the MIME part, | ||
1896 | should be allocated through a MMAPString | ||
1897 | |||
1898 | - length is the size of the content | ||
1899 | */ | ||
1900 | |||
1901 | struct mailimap_msg_att_body_section { | ||
1902 | struct mailimap_section * sec_section; /* != NULL */ | ||
1903 | uint32_t sec_origin_octet; | ||
1904 | char * sec_body_part; /* can be NULL */ | ||
1905 | size_t sec_length; | ||
1906 | }; | ||
1907 | |||
1908 | struct mailimap_msg_att_body_section * | ||
1909 | mailimap_msg_att_body_section_new(struct mailimap_section * section, | ||
1910 | uint32_t sec_origin_octet, | ||
1911 | char * sec_body_part, | ||
1912 | size_t sec_length); | ||
1913 | |||
1914 | void | ||
1915 | mailimap_msg_att_body_section_free(struct mailimap_msg_att_body_section * | ||
1916 | msg_att_body_section); | ||
1917 | |||
1918 | |||
1919 | |||
1920 | /* | ||
1921 | this is the type of static message attribute | ||
1922 | */ | ||
1923 | |||
1924 | enum { | ||
1925 | MAILIMAP_MSG_ATT_ERROR, /* on parse error */ | ||
1926 | MAILIMAP_MSG_ATT_ENVELOPE, /* this is the fields that can be | ||
1927 | parsed by the server */ | ||
1928 | MAILIMAP_MSG_ATT_INTERNALDATE, /* this is the message date kept | ||
1929 | by the server */ | ||
1930 | MAILIMAP_MSG_ATT_RFC822, /* this is the message content | ||
1931 | (header and body) */ | ||
1932 | MAILIMAP_MSG_ATT_RFC822_HEADER, /* this is the message header */ | ||
1933 | MAILIMAP_MSG_ATT_RFC822_TEXT, /* this is the message text part */ | ||
1934 | MAILIMAP_MSG_ATT_RFC822_SIZE, /* this is the size of the message content */ | ||
1935 | MAILIMAP_MSG_ATT_BODY, /* this is the MIME description of | ||
1936 | the message */ | ||
1937 | MAILIMAP_MSG_ATT_BODYSTRUCTURE, /* this is the MIME description of the | ||
1938 | message with additional information */ | ||
1939 | MAILIMAP_MSG_ATT_BODY_SECTION, /* this is a MIME part content */ | ||
1940 | MAILIMAP_MSG_ATT_UID, /* this is the message unique identifier */ | ||
1941 | }; | ||
1942 | |||
1943 | /* | ||
1944 | mailimap_msg_att_static is a given part of the message | ||
1945 | |||
1946 | - type is the type of the static message attribute, the value can be | ||
1947 | MAILIMAP_MSG_ATT_ENVELOPE, MAILIMAP_MSG_ATT_INTERNALDATE, | ||
1948 | MAILIMAP_MSG_ATT_RFC822, MAILIMAP_MSG_ATT_RFC822_HEADER, | ||
1949 | MAILIMAP_MSG_ATT_RFC822_TEXT, MAILIMAP_MSG_ATT_RFC822_SIZE, | ||
1950 | MAILIMAP_MSG_ATT_BODY, MAILIMAP_MSG_ATT_BODYSTRUCTURE, | ||
1951 | MAILIMAP_MSG_ATT_BODY_SECTION, MAILIMAP_MSG_ATT_UID | ||
1952 | |||
1953 | - env is the headers parsed by the server if type is | ||
1954 | MAILIMAP_MSG_ATT_ENVELOPE | ||
1955 | |||
1956 | - internal_date is the date of message kept by the server if type is | ||
1957 | MAILIMAP_MSG_ATT_INTERNALDATE | ||
1958 | |||
1959 | - rfc822 is the message content if type is MAILIMAP_MSG_ATT_RFC822, | ||
1960 | should be allocated through a MMAPString | ||
1961 | |||
1962 | - rfc822_header is the message header if type is | ||
1963 | MAILIMAP_MSG_ATT_RFC822_HEADER, should be allocated through a MMAPString | ||
1964 | |||
1965 | - rfc822_text is the message text part if type is | ||
1966 | MAILIMAP_MSG_ATT_RFC822_TEXT, should be allocated through a MMAPString | ||
1967 | |||
1968 | - rfc822_size is the message size if type is MAILIMAP_MSG_ATT_SIZE | ||
1969 | |||
1970 | - body is the MIME description of the message | ||
1971 | |||
1972 | - bodystructure is the MIME description of the message with additional | ||
1973 | information | ||
1974 | |||
1975 | - body_section is a MIME part content | ||
1976 | |||
1977 | - uid is a unique message identifier | ||
1978 | */ | ||
1979 | |||
1980 | struct mailimap_msg_att_static { | ||
1981 | int att_type; | ||
1982 | union { | ||
1983 | struct mailimap_envelope * att_env; /* can be NULL */ | ||
1984 | struct mailimap_date_time * att_internal_date; /* can be NULL */ | ||
1985 | struct { | ||
1986 | char * att_content; /* can be NULL */ | ||
1987 | size_t att_length; | ||
1988 | } att_rfc822; | ||
1989 | struct { | ||
1990 | char * att_content; /* can be NULL */ | ||
1991 | size_t att_length; | ||
1992 | } att_rfc822_header; | ||
1993 | struct { | ||
1994 | char * att_content; /* can be NULL */ | ||
1995 | size_t att_length; | ||
1996 | } att_rfc822_text; | ||
1997 | uint32_t att_rfc822_size; | ||
1998 | struct mailimap_body * att_bodystructure; /* can be NULL */ | ||
1999 | struct mailimap_body * att_body; /* can be NULL */ | ||
2000 | struct mailimap_msg_att_body_section * att_body_section; /* can be NULL */ | ||
2001 | uint32_t att_uid; | ||
2002 | } att_data; | ||
2003 | }; | ||
2004 | |||
2005 | struct mailimap_msg_att_static * | ||
2006 | mailimap_msg_att_static_new(int att_type, struct mailimap_envelope * att_env, | ||
2007 | struct mailimap_date_time * att_internal_date, | ||
2008 | char * att_rfc822, | ||
2009 | char * att_rfc822_header, | ||
2010 | char * att_rfc822_text, | ||
2011 | size_t att_length, | ||
2012 | uint32_t att_rfc822_size, | ||
2013 | struct mailimap_body * att_bodystructure, | ||
2014 | struct mailimap_body * att_body, | ||
2015 | struct mailimap_msg_att_body_section * att_body_section, | ||
2016 | uint32_t att_uid); | ||
2017 | |||
2018 | void | ||
2019 | mailimap_msg_att_static_free(struct mailimap_msg_att_static * item); | ||
2020 | |||
2021 | |||
2022 | |||
2023 | /* this is the type of a response element */ | ||
2024 | |||
2025 | enum { | ||
2026 | MAILIMAP_RESP_ERROR, /* on parse error */ | ||
2027 | MAILIMAP_RESP_CONT_REQ, /* continuation request */ | ||
2028 | MAILIMAP_RESP_RESP_DATA, /* response data */ | ||
2029 | }; | ||
2030 | |||
2031 | /* | ||
2032 | mailimap_cont_req_or_resp_data is a response element | ||
2033 | |||
2034 | - type is the type of response, the value can be MAILIMAP_RESP_CONT_REQ | ||
2035 | or MAILIMAP_RESP_RESP_DATA | ||
2036 | |||
2037 | - cont_req is a continuation request | ||
2038 | |||
2039 | - resp_data is a reponse data | ||
2040 | */ | ||
2041 | |||
2042 | struct mailimap_cont_req_or_resp_data { | ||
2043 | int rsp_type; | ||
2044 | union { | ||
2045 | struct mailimap_continue_req * rsp_cont_req; /* can be NULL */ | ||
2046 | struct mailimap_response_data * rsp_resp_data; /* can be NULL */ | ||
2047 | } rsp_data; | ||
2048 | }; | ||
2049 | |||
2050 | struct mailimap_cont_req_or_resp_data * | ||
2051 | mailimap_cont_req_or_resp_data_new(int rsp_type, | ||
2052 | struct mailimap_continue_req * rsp_cont_req, | ||
2053 | struct mailimap_response_data * rsp_resp_data); | ||
2054 | |||
2055 | void | ||
2056 | mailimap_cont_req_or_resp_data_free(struct mailimap_cont_req_or_resp_data * | ||
2057 | cont_req_or_resp_data); | ||
2058 | |||
2059 | |||
2060 | /* | ||
2061 | mailimap_response is a list of response elements | ||
2062 | |||
2063 | - cont_req_or_resp_data_list is a list of response elements | ||
2064 | |||
2065 | - resp_done is an ending response element | ||
2066 | */ | ||
2067 | |||
2068 | struct mailimap_response { | ||
2069 | clist * rsp_cont_req_or_resp_data_list; | ||
2070 | /* list of (struct mailiap_cont_req_or_resp_data *) */ | ||
2071 | /* can be NULL */ | ||
2072 | struct mailimap_response_done * rsp_resp_done; /* != NULL */ | ||
2073 | }; | ||
2074 | |||
2075 | struct mailimap_response * | ||
2076 | mailimap_response_new(clist * rsp_cont_req_or_resp_data_list, | ||
2077 | struct mailimap_response_done * rsp_resp_done); | ||
2078 | |||
2079 | void | ||
2080 | mailimap_response_free(struct mailimap_response * resp); | ||
2081 | |||
2082 | |||
2083 | |||
2084 | /* this is the type of an untagged response */ | ||
2085 | |||
2086 | enum { | ||
2087 | MAILIMAP_RESP_DATA_TYPE_ERROR, /* on parse error */ | ||
2088 | MAILIMAP_RESP_DATA_TYPE_COND_STATE, /* condition state response */ | ||
2089 | MAILIMAP_RESP_DATA_TYPE_COND_BYE, /* BYE response (server is about | ||
2090 | to close the connection) */ | ||
2091 | MAILIMAP_RESP_DATA_TYPE_MAILBOX_DATA, /* response related to a mailbox */ | ||
2092 | MAILIMAP_RESP_DATA_TYPE_MESSAGE_DATA, /* response related to a message */ | ||
2093 | MAILIMAP_RESP_DATA_TYPE_CAPABILITY_DATA, /* capability information */ | ||
2094 | }; | ||
2095 | |||
2096 | /* | ||
2097 | mailimap_reponse_data is an untagged response | ||
2098 | |||
2099 | - type is the type of the untagged response, it can be | ||
2100 | MAILIMAP_RESP_DATA_COND_STATE, MAILIMAP_RESP_DATA_COND_BYE, | ||
2101 | MAILIMAP_RESP_DATA_MAILBOX_DATA, MAILIMAP_RESP_DATA_MESSAGE_DATA | ||
2102 | or MAILIMAP_RESP_DATA_CAPABILITY_DATA | ||
2103 | |||
2104 | - cond_state is a condition state response | ||
2105 | |||
2106 | - bye is a BYE response (server is about to close the connection) | ||
2107 | |||
2108 | - mailbox_data is a response related to a mailbox | ||
2109 | |||
2110 | - message_data is a response related to a message | ||
2111 | |||
2112 | - capability is information about capabilities | ||
2113 | */ | ||
2114 | |||
2115 | struct mailimap_response_data { | ||
2116 | int rsp_type; | ||
2117 | union { | ||
2118 | struct mailimap_resp_cond_state * rsp_cond_state; /* can be NULL */ | ||
2119 | struct mailimap_resp_cond_bye * rsp_bye; /* can be NULL */ | ||
2120 | struct mailimap_mailbox_data * rsp_mailbox_data; /* can be NULL */ | ||
2121 | struct mailimap_message_data * rsp_message_data; /* can be NULL */ | ||
2122 | struct mailimap_capability_data * rsp_capability_data; /* can be NULL */ | ||
2123 | } rsp_data; | ||
2124 | }; | ||
2125 | |||
2126 | struct mailimap_response_data * | ||
2127 | mailimap_response_data_new(int rsp_type, | ||
2128 | struct mailimap_resp_cond_state * rsp_cond_state, | ||
2129 | struct mailimap_resp_cond_bye * rsp_bye, | ||
2130 | struct mailimap_mailbox_data * rsp_mailbox_data, | ||
2131 | struct mailimap_message_data * rsp_message_data, | ||
2132 | struct mailimap_capability_data * rsp_capability_data); | ||
2133 | |||
2134 | void | ||
2135 | mailimap_response_data_free(struct mailimap_response_data * resp_data); | ||
2136 | |||
2137 | |||
2138 | |||
2139 | /* this is the type of an ending response */ | ||
2140 | |||
2141 | enum { | ||
2142 | MAILIMAP_RESP_DONE_TYPE_ERROR, /* on parse error */ | ||
2143 | MAILIMAP_RESP_DONE_TYPE_TAGGED, /* tagged response */ | ||
2144 | MAILIMAP_RESP_DONE_TYPE_FATAL, /* fatal error response */ | ||
2145 | }; | ||
2146 | |||
2147 | /* | ||
2148 | mailimap_response_done is an ending response | ||
2149 | |||
2150 | - type is the type of the ending response | ||
2151 | |||
2152 | - tagged is a tagged response | ||
2153 | |||
2154 | - fatal is a fatal error response | ||
2155 | */ | ||
2156 | |||
2157 | struct mailimap_response_done { | ||
2158 | int rsp_type; | ||
2159 | union { | ||
2160 | struct mailimap_response_tagged * rsp_tagged; /* can be NULL */ | ||
2161 | struct mailimap_response_fatal * rsp_fatal; /* can be NULL */ | ||
2162 | } rsp_data; | ||
2163 | }; | ||
2164 | |||
2165 | struct mailimap_response_done * | ||
2166 | mailimap_response_done_new(int rsp_type, | ||
2167 | struct mailimap_response_tagged * rsp_tagged, | ||
2168 | struct mailimap_response_fatal * rsp_fatal); | ||
2169 | |||
2170 | void mailimap_response_done_free(struct mailimap_response_done * | ||
2171 | resp_done); | ||
2172 | |||
2173 | |||
2174 | /* | ||
2175 | mailimap_response_fatal is a fatal error response | ||
2176 | |||
2177 | - bye is a BYE response text | ||
2178 | */ | ||
2179 | |||
2180 | struct mailimap_response_fatal { | ||
2181 | struct mailimap_resp_cond_bye * rsp_bye; /* != NULL */ | ||
2182 | }; | ||
2183 | |||
2184 | struct mailimap_response_fatal * | ||
2185 | mailimap_response_fatal_new(struct mailimap_resp_cond_bye * rsp_bye); | ||
2186 | |||
2187 | void mailimap_response_fatal_free(struct mailimap_response_fatal * resp_fatal); | ||
2188 | |||
2189 | |||
2190 | |||
2191 | /* | ||
2192 | mailimap_response_tagged is a tagged response | ||
2193 | |||
2194 | - tag is the sent tag, should be allocated with malloc() | ||
2195 | |||
2196 | - cond_state is a condition state response | ||
2197 | */ | ||
2198 | |||
2199 | struct mailimap_response_tagged { | ||
2200 | char * rsp_tag; /* != NULL */ | ||
2201 | struct mailimap_resp_cond_state * rsp_cond_state; /* != NULL */ | ||
2202 | }; | ||
2203 | |||
2204 | struct mailimap_response_tagged * | ||
2205 | mailimap_response_tagged_new(char * rsp_tag, | ||
2206 | struct mailimap_resp_cond_state * rsp_cond_state); | ||
2207 | |||
2208 | void | ||
2209 | mailimap_response_tagged_free(struct mailimap_response_tagged * tagged); | ||
2210 | |||
2211 | |||
2212 | /* this is the type of an authentication condition response */ | ||
2213 | |||
2214 | enum { | ||
2215 | MAILIMAP_RESP_COND_AUTH_ERROR, /* on parse error */ | ||
2216 | MAILIMAP_RESP_COND_AUTH_OK, /* authentication is needed */ | ||
2217 | MAILIMAP_RESP_COND_AUTH_PREAUTH, /* authentication is not needed */ | ||
2218 | }; | ||
2219 | |||
2220 | /* | ||
2221 | mailimap_resp_cond_auth is an authentication condition response | ||
2222 | |||
2223 | - type is the type of the authentication condition response, | ||
2224 | the value can be MAILIMAP_RESP_COND_AUTH_OK or | ||
2225 | MAILIMAP_RESP_COND_AUTH_PREAUTH | ||
2226 | |||
2227 | - text is a text response | ||
2228 | */ | ||
2229 | |||
2230 | struct mailimap_resp_cond_auth { | ||
2231 | int rsp_type; | ||
2232 | struct mailimap_resp_text * rsp_text; /* != NULL */ | ||
2233 | }; | ||
2234 | |||
2235 | struct mailimap_resp_cond_auth * | ||
2236 | mailimap_resp_cond_auth_new(int rsp_type, | ||
2237 | struct mailimap_resp_text * rsp_text); | ||
2238 | |||
2239 | void | ||
2240 | mailimap_resp_cond_auth_free(struct mailimap_resp_cond_auth * cond_auth); | ||
2241 | |||
2242 | |||
2243 | |||
2244 | /* | ||
2245 | mailimap_resp_cond_bye is a BYE response | ||
2246 | |||
2247 | - text is a text response | ||
2248 | */ | ||
2249 | |||
2250 | struct mailimap_resp_cond_bye { | ||
2251 | struct mailimap_resp_text * rsp_text; /* != NULL */ | ||
2252 | }; | ||
2253 | |||
2254 | struct mailimap_resp_cond_bye * | ||
2255 | mailimap_resp_cond_bye_new(struct mailimap_resp_text * rsp_text); | ||
2256 | |||
2257 | void | ||
2258 | mailimap_resp_cond_bye_free(struct mailimap_resp_cond_bye * cond_bye); | ||
2259 | |||
2260 | |||
2261 | |||
2262 | /* this is the type of a condition state response */ | ||
2263 | |||
2264 | enum { | ||
2265 | MAILIMAP_RESP_COND_STATE_OK, | ||
2266 | MAILIMAP_RESP_COND_STATE_NO, | ||
2267 | MAILIMAP_RESP_COND_STATE_BAD | ||
2268 | }; | ||
2269 | |||
2270 | /* | ||
2271 | mailimap_resp_cond_state is a condition state reponse | ||
2272 | |||
2273 | - type is the type of the condition state response | ||
2274 | |||
2275 | - text is a text response | ||
2276 | */ | ||
2277 | |||
2278 | struct mailimap_resp_cond_state { | ||
2279 | int rsp_type; | ||
2280 | struct mailimap_resp_text * rsp_text; /* can be NULL */ | ||
2281 | }; | ||
2282 | |||
2283 | struct mailimap_resp_cond_state * | ||
2284 | mailimap_resp_cond_state_new(int rsp_type, | ||
2285 | struct mailimap_resp_text * rsp_text); | ||
2286 | |||
2287 | void | ||
2288 | mailimap_resp_cond_state_free(struct mailimap_resp_cond_state * cond_state); | ||
2289 | |||
2290 | |||
2291 | |||
2292 | /* | ||
2293 | mailimap_resp_text is a text response | ||
2294 | |||
2295 | - resp_code is a response code | ||
2296 | |||
2297 | - text is a human readable text, should be allocated with malloc() | ||
2298 | */ | ||
2299 | |||
2300 | struct mailimap_resp_text { | ||
2301 | struct mailimap_resp_text_code * rsp_code; /* can be NULL */ | ||
2302 | char * rsp_text; /* can be NULL */ | ||
2303 | }; | ||
2304 | |||
2305 | struct mailimap_resp_text * | ||
2306 | mailimap_resp_text_new(struct mailimap_resp_text_code * resp_code, | ||
2307 | char * rsp_text); | ||
2308 | |||
2309 | void mailimap_resp_text_free(struct mailimap_resp_text * resp_text); | ||
2310 | |||
2311 | |||
2312 | |||
2313 | /* this is the type of the response code */ | ||
2314 | |||
2315 | enum { | ||
2316 | MAILIMAP_RESP_TEXT_CODE_ALERT, /* ALERT response */ | ||
2317 | MAILIMAP_RESP_TEXT_CODE_BADCHARSET, /* BADCHARSET response */ | ||
2318 | MAILIMAP_RESP_TEXT_CODE_CAPABILITY_DATA, /* CAPABILITY response */ | ||
2319 | MAILIMAP_RESP_TEXT_CODE_PARSE, /* PARSE response */ | ||
2320 | MAILIMAP_RESP_TEXT_CODE_PERMANENTFLAGS, /* PERMANENTFLAGS response */ | ||
2321 | MAILIMAP_RESP_TEXT_CODE_READ_ONLY, /* READONLY response */ | ||
2322 | MAILIMAP_RESP_TEXT_CODE_READ_WRITE, /* READWRITE response */ | ||
2323 | MAILIMAP_RESP_TEXT_CODE_TRY_CREATE, /* TRYCREATE response */ | ||
2324 | MAILIMAP_RESP_TEXT_CODE_UIDNEXT, /* UIDNEXT response */ | ||
2325 | MAILIMAP_RESP_TEXT_CODE_UIDVALIDITY, /* UIDVALIDITY response */ | ||
2326 | MAILIMAP_RESP_TEXT_CODE_UNSEEN, /* UNSEEN response */ | ||
2327 | MAILIMAP_RESP_TEXT_CODE_OTHER, /* other type of response */ | ||
2328 | }; | ||
2329 | |||
2330 | /* | ||
2331 | mailimap_resp_text_code is a response code | ||
2332 | |||
2333 | - type is the type of the response code, the value can be | ||
2334 | MAILIMAP_RESP_TEXT_CODE_ALERT, MAILIMAP_RESP_TEXT_CODE_BADCHARSET, | ||
2335 | MAILIMAP_RESP_TEXT_CODE_CAPABILITY_DATA, MAILIMAP_RESP_TEXT_CODE_PARSE, | ||
2336 | MAILIMAP_RESP_TEXT_CODE_PERMANENTFLAGS, MAILIMAP_RESP_TEXT_CODE_READ_ONLY, | ||
2337 | MAILIMAP_RESP_TEXT_CODE_READ_WRITE, MAILIMAP_RESP_TEXT_CODE_TRY_CREATE, | ||
2338 | MAILIMAP_RESP_TEXT_CODE_UIDNEXT, MAILIMAP_RESP_TEXT_CODE_UIDVALIDITY, | ||
2339 | MAILIMAP_RESP_TEXT_CODE_UNSEEN or MAILIMAP_RESP_TEXT_CODE_OTHER | ||
2340 | |||
2341 | - badcharset is a list of charsets if type | ||
2342 | is MAILIMAP_RESP_TEXT_CODE_BADCHARSET, each element should be | ||
2343 | allocated with malloc() | ||
2344 | |||
2345 | - cap_data is a list of capabilities | ||
2346 | |||
2347 | - perm_flags is a list of flags, this is the flags that can be changed | ||
2348 | permanently on the messages of the mailbox. | ||
2349 | |||
2350 | - uidnext is the next unique identifier of a message | ||
2351 | |||
2352 | - uidvalidity is the unique identifier validity value | ||
2353 | |||
2354 | - first_unseen is the number of the first message without the \Seen flag | ||
2355 | |||
2356 | - atom is a keyword for an extension response code, should be allocated | ||
2357 | with malloc() | ||
2358 | |||
2359 | - atom_value is the data related with the extension response code, | ||
2360 | should be allocated with malloc() | ||
2361 | */ | ||
2362 | |||
2363 | struct mailimap_resp_text_code { | ||
2364 | int rc_type; | ||
2365 | union { | ||
2366 | clist * rc_badcharset; /* list of astring (char *) */ | ||
2367 | /* can be NULL */ | ||
2368 | struct mailimap_capability_data * rc_cap_data; /* != NULL */ | ||
2369 | clist * rc_perm_flags; /* list of (struct mailimap_flag_perm *) */ | ||
2370 | /* can be NULL */ | ||
2371 | uint32_t rc_uidnext; | ||
2372 | uint32_t rc_uidvalidity; | ||
2373 | uint32_t rc_first_unseen; | ||
2374 | struct { | ||
2375 | char * atom_name; /* can be NULL */ | ||
2376 | char * atom_value; /* can be NULL */ | ||
2377 | } rc_atom; | ||
2378 | } rc_data; | ||
2379 | }; | ||
2380 | |||
2381 | struct mailimap_resp_text_code * | ||
2382 | mailimap_resp_text_code_new(int rc_type, clist * rc_badcharset, | ||
2383 | struct mailimap_capability_data * rc_cap_data, | ||
2384 | clist * rc_perm_flags, | ||
2385 | uint32_t rc_uidnext, uint32_t rc_uidvalidity, | ||
2386 | uint32_t rc_first_unseen, char * rc_atom, char * rc_atom_value); | ||
2387 | |||
2388 | void | ||
2389 | mailimap_resp_text_code_free(struct mailimap_resp_text_code * resp_text_code); | ||
2390 | |||
2391 | |||
2392 | /* | ||
2393 | mailimap_section is a MIME part section identifier | ||
2394 | |||
2395 | section_spec is the MIME section identifier | ||
2396 | */ | ||
2397 | |||
2398 | struct mailimap_section { | ||
2399 | struct mailimap_section_spec * sec_spec; /* can be NULL */ | ||
2400 | }; | ||
2401 | |||
2402 | struct mailimap_section * | ||
2403 | mailimap_section_new(struct mailimap_section_spec * sec_spec); | ||
2404 | |||
2405 | void mailimap_section_free(struct mailimap_section * section); | ||
2406 | |||
2407 | |||
2408 | /* this is the type of the message/rfc822 part description */ | ||
2409 | |||
2410 | enum { | ||
2411 | MAILIMAP_SECTION_MSGTEXT_HEADER, /* header fields part of the | ||
2412 | message */ | ||
2413 | MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS, /* given header fields of the | ||
2414 | message */ | ||
2415 | MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS_NOT, /* header fields of the | ||
2416 | message except the given */ | ||
2417 | MAILIMAP_SECTION_MSGTEXT_TEXT, /* text part */ | ||
2418 | }; | ||
2419 | |||
2420 | /* | ||
2421 | mailimap_section_msgtext is a message/rfc822 part description | ||
2422 | |||
2423 | - type is the type of the content part and the value can be | ||
2424 | MAILIMAP_SECTION_MSGTEXT_HEADER, MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS, | ||
2425 | MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS_NOT | ||
2426 | or MAILIMAP_SECTION_MSGTEXT_TEXT | ||
2427 | |||
2428 | - header_list is the list of headers when type is | ||
2429 | MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS or | ||
2430 | MAILIMAP_SECTION_MSGTEXT_HEADER_FIELDS_NOT | ||
2431 | */ | ||
2432 | |||
2433 | struct mailimap_section_msgtext { | ||
2434 | int sec_type; | ||
2435 | struct mailimap_header_list * sec_header_list; /* can be NULL */ | ||
2436 | }; | ||
2437 | |||
2438 | struct mailimap_section_msgtext * | ||
2439 | mailimap_section_msgtext_new(int sec_type, | ||
2440 | struct mailimap_header_list * sec_header_list); | ||
2441 | |||
2442 | void | ||
2443 | mailimap_section_msgtext_free(struct mailimap_section_msgtext * msgtext); | ||
2444 | |||
2445 | |||
2446 | |||
2447 | /* | ||
2448 | mailimap_section_part is the MIME part location in a message | ||
2449 | |||
2450 | - section_id is a list of number index of the sub-part in the mail structure, | ||
2451 | each element should be allocated with malloc() | ||
2452 | |||
2453 | */ | ||
2454 | |||
2455 | struct mailimap_section_part { | ||
2456 | clist * sec_id; /* list of nz-number (uint32_t *) */ | ||
2457 | /* != NULL */ | ||
2458 | }; | ||
2459 | |||
2460 | struct mailimap_section_part * | ||
2461 | mailimap_section_part_new(clist * sec_id); | ||
2462 | |||
2463 | void | ||
2464 | mailimap_section_part_free(struct mailimap_section_part * section_part); | ||
2465 | |||
2466 | |||
2467 | |||
2468 | /* this is the type of section specification */ | ||
2469 | |||
2470 | enum { | ||
2471 | MAILIMAP_SECTION_SPEC_SECTION_MSGTEXT, /* if requesting data of the root | ||
2472 | MIME message/rfc822 part */ | ||
2473 | MAILIMAP_SECTION_SPEC_SECTION_PART, /* location of the MIME part | ||
2474 | in the message */ | ||
2475 | }; | ||
2476 | |||
2477 | /* | ||
2478 | mailimap_section_spec is a section specification | ||
2479 | |||
2480 | - type is the type of the section specification, the value can be | ||
2481 | MAILIMAP_SECTION_SPEC_SECTION_MSGTEXT or | ||
2482 | MAILIMAP_SECTION_SPEC_SECTION_PART | ||
2483 | |||
2484 | - section_msgtext is a message/rfc822 part description if type is | ||
2485 | MAILIMAP_SECTION_SPEC_SECTION_MSGTEXT | ||
2486 | |||
2487 | - section_part is a body part location in the message if type is | ||
2488 | MAILIMAP_SECTION_SPEC_SECTION_PART | ||
2489 | |||
2490 | - section_text is a body part location for a given MIME part, | ||
2491 | this can be NULL if the body of the part is requested (and not | ||
2492 | the MIME header). | ||
2493 | */ | ||
2494 | |||
2495 | struct mailimap_section_spec { | ||
2496 | int sec_type; | ||
2497 | union { | ||
2498 | struct mailimap_section_msgtext * sec_msgtext; /* can be NULL */ | ||
2499 | struct mailimap_section_part * sec_part; /* can be NULL */ | ||
2500 | } sec_data; | ||
2501 | struct mailimap_section_text * sec_text; /* can be NULL */ | ||
2502 | }; | ||
2503 | |||
2504 | struct mailimap_section_spec * | ||
2505 | mailimap_section_spec_new(int sec_type, | ||
2506 | struct mailimap_section_msgtext * sec_msgtext, | ||
2507 | struct mailimap_section_part * sec_part, | ||
2508 | struct mailimap_section_text * sec_text); | ||
2509 | |||
2510 | void | ||
2511 | mailimap_section_spec_free(struct mailimap_section_spec * section_spec); | ||
2512 | |||
2513 | |||
2514 | |||
2515 | /* this is the type of body part location for a given MIME part */ | ||
2516 | |||
2517 | enum { | ||
2518 | MAILIMAP_SECTION_TEXT_ERROR, /* on parse error **/ | ||
2519 | MAILIMAP_SECTION_TEXT_SECTION_MSGTEXT, /* if the MIME type is | ||
2520 | message/rfc822, headers or text | ||
2521 | can be requested */ | ||
2522 | MAILIMAP_SECTION_TEXT_MIME, /* for all MIME types, | ||
2523 | MIME headers can be requested */ | ||
2524 | }; | ||
2525 | |||
2526 | /* | ||
2527 | mailimap_section_text is the body part location for a given MIME part | ||
2528 | |||
2529 | - type can be MAILIMAP_SECTION_TEXT_SECTION_MSGTEXT or | ||
2530 | MAILIMAP_SECTION_TEXT_MIME | ||
2531 | |||
2532 | - section_msgtext is the part of the MIME part when MIME type is | ||
2533 | message/rfc822 than can be requested, when type is | ||
2534 | MAILIMAP_TEXT_SECTION_MSGTEXT | ||
2535 | */ | ||
2536 | |||
2537 | struct mailimap_section_text { | ||
2538 | int sec_type; | ||
2539 | struct mailimap_section_msgtext * sec_msgtext; /* can be NULL */ | ||
2540 | }; | ||
2541 | |||
2542 | struct mailimap_section_text * | ||
2543 | mailimap_section_text_new(int sec_type, | ||
2544 | struct mailimap_section_msgtext * sec_msgtext); | ||
2545 | |||
2546 | void | ||
2547 | mailimap_section_text_free(struct mailimap_section_text * section_text); | ||
2548 | |||
2549 | |||
2550 | |||
2551 | |||
2552 | |||
2553 | |||
2554 | |||
2555 | |||
2556 | |||
2557 | |||
2558 | /* ************************************************************************* */ | ||
2559 | /* the following part concerns only the IMAP command that are sent */ | ||
2560 | |||
2561 | |||
2562 | /* | ||
2563 | mailimap_set_item is a message set | ||
2564 | |||
2565 | - first is the first message of the set | ||
2566 | - last is the last message of the set | ||
2567 | |||
2568 | this can be message numbers of message unique identifiers | ||
2569 | */ | ||
2570 | |||
2571 | struct mailimap_set_item { | ||
2572 | uint32_t set_first; | ||
2573 | uint32_t set_last; | ||
2574 | }; | ||
2575 | |||
2576 | struct mailimap_set_item * | ||
2577 | mailimap_set_item_new(uint32_t set_first, uint32_t set_last); | ||
2578 | |||
2579 | void mailimap_set_item_free(struct mailimap_set_item * set_item); | ||
2580 | |||
2581 | |||
2582 | |||
2583 | /* | ||
2584 | set is a list of message sets | ||
2585 | |||
2586 | - list is a list of message sets | ||
2587 | */ | ||
2588 | |||
2589 | struct mailimap_set { | ||
2590 | clist * set_list; /* list of (struct mailimap_set_item *) */ | ||
2591 | }; | ||
2592 | |||
2593 | struct mailimap_set * mailimap_set_new(clist * list); | ||
2594 | |||
2595 | void mailimap_set_free(struct mailimap_set * set); | ||
2596 | |||
2597 | |||
2598 | /* | ||
2599 | mailimap_date is a date | ||
2600 | |||
2601 | - day is the day in the month (1 to 31) | ||
2602 | |||
2603 | - month (1 to 12) | ||
2604 | |||
2605 | - year (4 digits) | ||
2606 | */ | ||
2607 | |||
2608 | struct mailimap_date { | ||
2609 | int dt_day; | ||
2610 | int dt_month; | ||
2611 | int dt_year; | ||
2612 | }; | ||
2613 | |||
2614 | struct mailimap_date * | ||
2615 | mailimap_date_new(int dt_day, int dt_month, int dt_year); | ||
2616 | |||
2617 | void mailimap_date_free(struct mailimap_date * date); | ||
2618 | |||
2619 | |||
2620 | |||
2621 | |||
2622 | /* this is the type of fetch attribute for a given message */ | ||
2623 | |||
2624 | enum { | ||
2625 | MAILIMAP_FETCH_ATT_ENVELOPE, /* to fetch the headers parsed by | ||
2626 | the IMAP server */ | ||
2627 | MAILIMAP_FETCH_ATT_FLAGS, /* to fetch the flags */ | ||
2628 | MAILIMAP_FETCH_ATT_INTERNALDATE, /* to fetch the date of the message | ||
2629 | kept by the server */ | ||
2630 | MAILIMAP_FETCH_ATT_RFC822, /* to fetch the entire message */ | ||
2631 | MAILIMAP_FETCH_ATT_RFC822_HEADER, /* to fetch the headers */ | ||
2632 | MAILIMAP_FETCH_ATT_RFC822_SIZE, /* to fetch the size */ | ||
2633 | MAILIMAP_FETCH_ATT_RFC822_TEXT, /* to fetch the text part */ | ||
2634 | MAILIMAP_FETCH_ATT_BODY, /* to fetch the MIME structure */ | ||
2635 | MAILIMAP_FETCH_ATT_BODYSTRUCTURE, /* to fetch the MIME structure with | ||
2636 | additional information */ | ||
2637 | MAILIMAP_FETCH_ATT_UID, /* to fetch the unique identifier */ | ||
2638 | MAILIMAP_FETCH_ATT_BODY_SECTION, /* to fetch a given part */ | ||
2639 | MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION, /* to fetch a given part without | ||
2640 | marking the message as read */ | ||
2641 | }; | ||
2642 | |||
2643 | |||
2644 | /* | ||
2645 | mailimap_fetch_att is the description of the fetch attribute | ||
2646 | |||
2647 | - type is the type of fetch attribute, the value can be | ||
2648 | MAILIMAP_FETCH_ATT_ENVELOPE, MAILIMAP_FETCH_ATT_FLAGS, | ||
2649 | MAILIMAP_FETCH_ATT_INTERNALDATE, MAILIMAP_FETCH_ATT_RFC822, | ||
2650 | MAILIMAP_FETCH_ATT_RFC822_HEADER, MAILIMAP_FETCH_ATT_RFC822_SIZE, | ||
2651 | MAILIMAP_FETCH_ATT_RFC822_TEXT, MAILIMAP_FETCH_ATT_BODY, | ||
2652 | MAILIMAP_FETCH_ATT_BODYSTRUCTURE, MAILIMAP_FETCH_ATT_UID, | ||
2653 | MAILIMAP_FETCH_ATT_BODY_SECTION or MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION | ||
2654 | |||
2655 | - section is the location of the part to fetch if type is | ||
2656 | MAILIMAP_FETCH_ATT_BODY_SECTION or MAILIMAP_FETCH_ATT_BODY_PEEK_SECTION | ||
2657 | |||
2658 | - offset is the first byte to fetch in the given part | ||
2659 | |||
2660 | - size is the maximum size of the part to fetch | ||
2661 | */ | ||
2662 | |||
2663 | struct mailimap_fetch_att { | ||
2664 | int att_type; | ||
2665 | struct mailimap_section * att_section; | ||
2666 | uint32_t att_offset; | ||
2667 | uint32_t att_size; | ||
2668 | }; | ||
2669 | |||
2670 | struct mailimap_fetch_att * | ||
2671 | mailimap_fetch_att_new(int att_type, struct mailimap_section * att_section, | ||
2672 | uint32_t att_offset, uint32_t att_size); | ||
2673 | |||
2674 | |||
2675 | void mailimap_fetch_att_free(struct mailimap_fetch_att * fetch_att); | ||
2676 | |||
2677 | |||
2678 | /* this is the type of a FETCH operation */ | ||
2679 | |||
2680 | enum { | ||
2681 | MAILIMAP_FETCH_TYPE_ALL, /* equivalent to (FLAGS INTERNALDATE | ||
2682 | RFC822.SIZE ENVELOPE) */ | ||
2683 | MAILIMAP_FETCH_TYPE_FULL, /* equivalent to (FLAGS INTERNALDATE | ||
2684 | RFC822.SIZE ENVELOPE BODY) */ | ||
2685 | MAILIMAP_FETCH_TYPE_FAST, /* equivalent to (FLAGS INTERNALDATE | ||
2686 | RFC822.SIZE) */ | ||
2687 | MAILIMAP_FETCH_TYPE_FETCH_ATT, /* when there is only of fetch | ||
2688 | attribute */ | ||
2689 | MAILIMAP_FETCH_TYPE_FETCH_ATT_LIST, /* when there is a list of fetch | ||
2690 | attributes */ | ||
2691 | }; | ||
2692 | |||
2693 | /* | ||
2694 | mailimap_fetch_type is the description of the FETCH operation | ||
2695 | |||
2696 | - type can be MAILIMAP_FETCH_TYPE_ALL, MAILIMAP_FETCH_TYPE_FULL, | ||
2697 | MAILIMAP_FETCH_TYPE_FAST, MAILIMAP_FETCH_TYPE_FETCH_ATT or | ||
2698 | MAILIMAP_FETCH_TYPE_FETCH_ATT_LIST | ||
2699 | |||
2700 | - fetch_att is a fetch attribute if type is MAILIMAP_FETCH_TYPE_FETCH_ATT | ||
2701 | |||
2702 | - fetch_att_list is a list of fetch attributes if type is | ||
2703 | MAILIMAP_FETCH_TYPE_FETCH_ATT_LIST | ||
2704 | */ | ||
2705 | |||
2706 | struct mailimap_fetch_type { | ||
2707 | int ft_type; | ||
2708 | union { | ||
2709 | struct mailimap_fetch_att * ft_fetch_att; | ||
2710 | clist * ft_fetch_att_list; /* list of (struct mailimap_fetch_att *) */ | ||
2711 | } ft_data; | ||
2712 | }; | ||
2713 | |||
2714 | struct mailimap_fetch_type * | ||
2715 | mailimap_fetch_type_new(int ft_type, | ||
2716 | struct mailimap_fetch_att * ft_fetch_att, | ||
2717 | clist * ft_fetch_att_list); | ||
2718 | |||
2719 | |||
2720 | void mailimap_fetch_type_free(struct mailimap_fetch_type * fetch_type); | ||
2721 | |||
2722 | |||
2723 | |||
2724 | /* | ||
2725 | mailimap_store_att_flags is the description of the STORE operation | ||
2726 | (change flags of a message) | ||
2727 | |||
2728 | - sign can be 0 (set flag), +1 (add flag) or -1 (remove flag) | ||
2729 | |||
2730 | - silent has a value of 1 if the flags are changed with no server | ||
2731 | response | ||
2732 | |||
2733 | - flag_list is the list of flags to change | ||
2734 | */ | ||
2735 | |||
2736 | struct mailimap_store_att_flags { | ||
2737 | int fl_sign; | ||
2738 | int fl_silent; | ||
2739 | struct mailimap_flag_list * fl_flag_list; | ||
2740 | }; | ||
2741 | |||
2742 | struct mailimap_store_att_flags * | ||
2743 | mailimap_store_att_flags_new(int fl_sign, int fl_silent, | ||
2744 | struct mailimap_flag_list * fl_flag_list); | ||
2745 | |||
2746 | void mailimap_store_att_flags_free(struct mailimap_store_att_flags * | ||
2747 | store_att_flags); | ||
2748 | |||
2749 | |||
2750 | |||
2751 | /* this is the condition of the SEARCH operation */ | ||
2752 | |||
2753 | enum { | ||
2754 | MAILIMAP_SEARCH_KEY_ALL, /* all messages */ | ||
2755 | MAILIMAP_SEARCH_KEY_ANSWERED, /* messages with the flag \Answered */ | ||
2756 | MAILIMAP_SEARCH_KEY_BCC, /* messages whose Bcc field contains the | ||
2757 | given string */ | ||
2758 | MAILIMAP_SEARCH_KEY_BEFORE, /* messages whose internal date is earlier | ||
2759 | than the specified date */ | ||
2760 | MAILIMAP_SEARCH_KEY_BODY, /* message that contains the given string | ||
2761 | (in header and text parts) */ | ||
2762 | MAILIMAP_SEARCH_KEY_CC, /* messages whose Cc field contains the | ||
2763 | given string */ | ||
2764 | MAILIMAP_SEARCH_KEY_DELETED, /* messages with the flag \Deleted */ | ||
2765 | MAILIMAP_SEARCH_KEY_FLAGGED, /* messages with the flag \Flagged */ | ||
2766 | MAILIMAP_SEARCH_KEY_FROM, /* messages whose From field contains the | ||
2767 | given string */ | ||
2768 | MAILIMAP_SEARCH_KEY_KEYWORD, /* messages with the flag keyword set */ | ||
2769 | MAILIMAP_SEARCH_KEY_NEW, /* messages with the flag \Recent and not | ||
2770 | the \Seen flag */ | ||
2771 | MAILIMAP_SEARCH_KEY_OLD, /* messages that do not have the | ||
2772 | \Recent flag set */ | ||
2773 | MAILIMAP_SEARCH_KEY_ON, /* messages whose internal date is the | ||
2774 | specified date */ | ||
2775 | MAILIMAP_SEARCH_KEY_RECENT, /* messages with the flag \Recent */ | ||
2776 | MAILIMAP_SEARCH_KEY_SEEN, /* messages with the flag \Seen */ | ||
2777 | MAILIMAP_SEARCH_KEY_SINCE, /* messages whose internal date is later | ||
2778 | than specified date */ | ||
2779 | MAILIMAP_SEARCH_KEY_SUBJECT, /* messages whose Subject field contains the | ||
2780 | given string */ | ||
2781 | MAILIMAP_SEARCH_KEY_TEXT, /* messages whose text part contains the | ||
2782 | given string */ | ||
2783 | MAILIMAP_SEARCH_KEY_TO, /* messages whose To field contains the | ||
2784 | given string */ | ||
2785 | MAILIMAP_SEARCH_KEY_UNANSWERED, /* messages with no flag \Answered */ | ||
2786 | MAILIMAP_SEARCH_KEY_UNDELETED, /* messages with no flag \Deleted */ | ||
2787 | MAILIMAP_SEARCH_KEY_UNFLAGGED, /* messages with no flag \Flagged */ | ||
2788 | MAILIMAP_SEARCH_KEY_UNKEYWORD, /* messages with no flag keyword */ | ||
2789 | MAILIMAP_SEARCH_KEY_UNSEEN, /* messages with no flag \Seen */ | ||
2790 | MAILIMAP_SEARCH_KEY_DRAFT, /* messages with no flag \Draft */ | ||
2791 | MAILIMAP_SEARCH_KEY_HEADER, /* messages whose given field | ||
2792 | contains the given string */ | ||
2793 | MAILIMAP_SEARCH_KEY_LARGER, /* messages whose size is larger then | ||
2794 | the given size */ | ||
2795 | MAILIMAP_SEARCH_KEY_NOT, /* not operation of the condition */ | ||
2796 | MAILIMAP_SEARCH_KEY_OR, /* or operation between two conditions */ | ||
2797 | MAILIMAP_SEARCH_KEY_SENTBEFORE, /* messages whose date given in Date header | ||
2798 | is earlier than the specified date */ | ||
2799 | MAILIMAP_SEARCH_KEY_SENTON, /* messages whose date given in Date header | ||
2800 | is the specified date */ | ||
2801 | MAILIMAP_SEARCH_KEY_SENTSINCE, /* messages whose date given in Date header | ||
2802 | is later than specified date */ | ||
2803 | MAILIMAP_SEARCH_KEY_SMALLER, /* messages whose size is smaller than | ||
2804 | the given size */ | ||
2805 | MAILIMAP_SEARCH_KEY_UID, /* messages whose unique identifiers are | ||
2806 | in the given range */ | ||
2807 | MAILIMAP_SEARCH_KEY_UNDRAFT, /* messages with no flag \Draft */ | ||
2808 | MAILIMAP_SEARCH_KEY_SET, /* messages whose number (or unique | ||
2809 | identifiers in case of UID SEARCH) are | ||
2810 | in the given range */ | ||
2811 | MAILIMAP_SEARCH_KEY_MULTIPLE, /* the boolean operator between the | ||
2812 | conditions is AND */ | ||
2813 | }; | ||
2814 | |||
2815 | /* | ||
2816 | mailimap_search_key is the condition on the messages to return | ||
2817 | |||
2818 | - type is the type of the condition | ||
2819 | |||
2820 | - bcc is the text to search in the Bcc field when type is | ||
2821 | MAILIMAP_SEARCH_KEY_BCC, should be allocated with malloc() | ||
2822 | |||
2823 | - before is a date when type is MAILIMAP_SEARCH_KEY_BEFORE | ||
2824 | |||
2825 | - body is the text to search in the message when type is | ||
2826 | MAILIMAP_SEARCH_KEY_BODY, should be allocated with malloc() | ||
2827 | |||
2828 | - cc is the text to search in the Cc field when type is | ||
2829 | MAILIMAP_SEARCH_KEY_CC, should be allocated with malloc() | ||
2830 | |||
2831 | - from is the text to search in the From field when type is | ||
2832 | MAILIMAP_SEARCH_KEY_FROM, should be allocated with malloc() | ||
2833 | |||
2834 | - keyword is the keyword flag name when type is MAILIMAP_SEARCH_KEY_KEYWORD, | ||
2835 | should be allocated with malloc() | ||
2836 | |||
2837 | - on is a date when type is MAILIMAP_SEARCH_KEY_ON | ||
2838 | |||
2839 | - since is a date when type is MAILIMAP_SEARCH_KEY_SINCE | ||
2840 | |||
2841 | - subject is the text to search in the Subject field when type is | ||
2842 | MAILIMAP_SEARCH_KEY_SUBJECT, should be allocated with malloc() | ||
2843 | |||
2844 | - text is the text to search in the text part of the message when | ||
2845 | type is MAILIMAP_SEARCH_KEY_TEXT, should be allocated with malloc() | ||
2846 | |||
2847 | - to is the text to search in the To field when type is | ||
2848 | MAILIMAP_SEARCH_KEY_TO, should be allocated with malloc() | ||
2849 | |||
2850 | - unkeyword is the keyword flag name when type is | ||
2851 | MAILIMAP_SEARCH_KEY_UNKEYWORD, should be allocated with malloc() | ||
2852 | |||
2853 | - header_name is the header name when type is MAILIMAP_SEARCH_KEY_HEADER, | ||
2854 | should be allocated with malloc() | ||
2855 | |||
2856 | - header_value is the text to search in the given header when type is | ||
2857 | MAILIMAP_SEARCH_KEY_HEADER, should be allocated with malloc() | ||
2858 | |||
2859 | - larger is a size when type is MAILIMAP_SEARCH_KEY_LARGER | ||
2860 | |||
2861 | - not is a condition when type is MAILIMAP_SEARCH_KEY_NOT | ||
2862 | |||
2863 | - or1 is a condition when type is MAILIMAP_SEARCH_KEY_OR | ||
2864 | |||
2865 | - or2 is a condition when type is MAILIMAP_SEARCH_KEY_OR | ||
2866 | |||
2867 | - sentbefore is a date when type is MAILIMAP_SEARCH_KEY_SENTBEFORE | ||
2868 | |||
2869 | - senton is a date when type is MAILIMAP_SEARCH_KEY_SENTON | ||
2870 | |||
2871 | - sentsince is a date when type is MAILIMAP_SEARCH_KEY_SENTSINCE | ||
2872 | |||
2873 | - smaller is a size when type is MAILIMAP_SEARCH_KEY_SMALLER | ||
2874 | |||
2875 | - uid is a set of messages when type is MAILIMAP_SEARCH_KEY_UID | ||
2876 | |||
2877 | - set is a set of messages when type is MAILIMAP_SEARCH_KEY_SET | ||
2878 | |||
2879 | - multiple is a set of message when type is MAILIMAP_SEARCH_KEY_MULTIPLE | ||
2880 | */ | ||
2881 | |||
2882 | struct mailimap_search_key { | ||
2883 | int sk_type; | ||
2884 | union { | ||
2885 | char * sk_bcc; | ||
2886 | struct mailimap_date * sk_before; | ||
2887 | char * sk_body; | ||
2888 | char * sk_cc; | ||
2889 | char * sk_from; | ||
2890 | char * sk_keyword; | ||
2891 | struct mailimap_date * sk_on; | ||
2892 | struct mailimap_date * sk_since; | ||
2893 | char * sk_subject; | ||
2894 | char * sk_text; | ||
2895 | char * sk_to; | ||
2896 | char * sk_unkeyword; | ||
2897 | struct { | ||
2898 | char * sk_header_name; | ||
2899 | char * sk_header_value; | ||
2900 | } sk_header; | ||
2901 | uint32_t sk_larger; | ||
2902 | struct mailimap_search_key * sk_not; | ||
2903 | struct { | ||
2904 | struct mailimap_search_key * sk_or1; | ||
2905 | struct mailimap_search_key * sk_or2; | ||
2906 | } sk_or; | ||
2907 | struct mailimap_date * sk_sentbefore; | ||
2908 | struct mailimap_date * sk_senton; | ||
2909 | struct mailimap_date * sk_sentsince; | ||
2910 | uint32_t sk_smaller; | ||
2911 | struct mailimap_set * sk_uid; | ||
2912 | struct mailimap_set * sk_set; | ||
2913 | clist * sk_multiple; /* list of (struct mailimap_search_key *) */ | ||
2914 | } sk_data; | ||
2915 | }; | ||
2916 | |||
2917 | struct mailimap_search_key * | ||
2918 | mailimap_search_key_new(int sk_type, | ||
2919 | char * sk_bcc, struct mailimap_date * sk_before, char * sk_body, | ||
2920 | char * sk_cc, char * sk_from, char * sk_keyword, | ||
2921 | struct mailimap_date * sk_on, struct mailimap_date * sk_since, | ||
2922 | char * sk_subject, char * sk_text, char * sk_to, | ||
2923 | char * sk_unkeyword, char * sk_header_name, | ||
2924 | char * sk_header_value, uint32_t sk_larger, | ||
2925 | struct mailimap_search_key * sk_not, | ||
2926 | struct mailimap_search_key * sk_or1, | ||
2927 | struct mailimap_search_key * sk_or2, | ||
2928 | struct mailimap_date * sk_sentbefore, | ||
2929 | struct mailimap_date * sk_senton, | ||
2930 | struct mailimap_date * sk_sentsince, | ||
2931 | uint32_t sk_smaller, struct mailimap_set * sk_uid, | ||
2932 | struct mailimap_set * sk_set, clist * sk_multiple); | ||
2933 | |||
2934 | |||
2935 | void mailimap_search_key_free(struct mailimap_search_key * key); | ||
2936 | |||
2937 | |||
2938 | /* | ||
2939 | mailimap_status_att_list is a list of mailbox STATUS request type | ||
2940 | |||
2941 | - list is a list of mailbox STATUS request type | ||
2942 | (value of elements in the list can be MAILIMAP_STATUS_ATT_MESSAGES, | ||
2943 | MAILIMAP_STATUS_ATT_RECENT, MAILIMAP_STATUS_ATT_UIDNEXT, | ||
2944 | MAILIMAP_STATUS_ATT_UIDVALIDITY or MAILIMAP_STATUS_ATT_UNSEEN), | ||
2945 | each element should be allocated with malloc() | ||
2946 | */ | ||
2947 | |||
2948 | struct mailimap_status_att_list { | ||
2949 | clist * att_list; /* list of (uint32_t *) */ | ||
2950 | }; | ||
2951 | |||
2952 | struct mailimap_status_att_list * | ||
2953 | mailimap_status_att_list_new(clist * att_list); | ||
2954 | |||
2955 | void mailimap_status_att_list_free(struct mailimap_status_att_list * | ||
2956 | status_att_list); | ||
2957 | |||
2958 | |||
2959 | |||
2960 | |||
2961 | /* internal use functions */ | ||
2962 | |||
2963 | |||
2964 | uint32_t * mailimap_number_alloc_new(uint32_t number); | ||
2965 | |||
2966 | void mailimap_number_alloc_free(uint32_t * pnumber); | ||
2967 | |||
2968 | |||
2969 | void mailimap_addr_host_free(char * addr_host); | ||
2970 | |||
2971 | void mailimap_addr_mailbox_free(char * addr_mailbox); | ||
2972 | |||
2973 | void mailimap_addr_adl_free(char * addr_adl); | ||
2974 | |||
2975 | void mailimap_addr_name_free(char * addr_name); | ||
2976 | |||
2977 | void mailimap_astring_free(char * astring); | ||
2978 | |||
2979 | void mailimap_atom_free(char * atom); | ||
2980 | |||
2981 | void mailimap_auth_type_free(char * auth_type); | ||
2982 | |||
2983 | void mailimap_base64_free(char * base64); | ||
2984 | |||
2985 | void mailimap_body_fld_desc_free(char * body_fld_desc); | ||
2986 | |||
2987 | void mailimap_body_fld_id_free(char * body_fld_id); | ||
2988 | |||
2989 | void mailimap_body_fld_md5_free(char * body_fld_md5); | ||
2990 | |||
2991 | void mailimap_env_date_free(char * date); | ||
2992 | |||
2993 | void mailimap_env_in_reply_to_free(char * in_reply_to); | ||
2994 | |||
2995 | void mailimap_env_message_id_free(char * message_id); | ||
2996 | |||
2997 | void mailimap_env_subject_free(char * subject); | ||
2998 | |||
2999 | void mailimap_flag_extension_free(char * flag_extension); | ||
3000 | |||
3001 | void mailimap_flag_keyword_free(char * flag_keyword); | ||
3002 | |||
3003 | void | ||
3004 | mailimap_header_fld_name_free(char * header_fld_name); | ||
3005 | |||
3006 | void mailimap_literal_free(char * literal); | ||
3007 | |||
3008 | void mailimap_mailbox_free(char * mailbox); | ||
3009 | |||
3010 | void | ||
3011 | mailimap_mailbox_data_search_free(clist * data_search); | ||
3012 | |||
3013 | void mailimap_media_subtype_free(char * media_subtype); | ||
3014 | |||
3015 | void mailimap_media_text_free(char * media_text); | ||
3016 | |||
3017 | void mailimap_msg_att_envelope_free(struct mailimap_envelope * env); | ||
3018 | |||
3019 | void | ||
3020 | mailimap_msg_att_internaldate_free(struct mailimap_date_time * date_time); | ||
3021 | |||
3022 | void | ||
3023 | mailimap_msg_att_rfc822_free(char * str); | ||
3024 | |||
3025 | void | ||
3026 | mailimap_msg_att_rfc822_header_free(char * str); | ||
3027 | |||
3028 | void | ||
3029 | mailimap_msg_att_rfc822_text_free(char * str); | ||
3030 | |||
3031 | void | ||
3032 | mailimap_msg_att_body_free(struct mailimap_body * body); | ||
3033 | |||
3034 | void | ||
3035 | mailimap_msg_att_bodystructure_free(struct mailimap_body * body); | ||
3036 | |||
3037 | void mailimap_nstring_free(char * str); | ||
3038 | |||
3039 | void | ||
3040 | mailimap_string_free(char * str); | ||
3041 | |||
3042 | void mailimap_tag_free(char * tag); | ||
3043 | |||
3044 | void mailimap_text_free(char * text); | ||
3045 | |||
3046 | |||
3047 | |||
3048 | |||
3049 | |||
3050 | /* IMAP connection */ | ||
3051 | |||
3052 | /* this is the state of the IMAP connection */ | ||
3053 | |||
3054 | enum { | ||
3055 | MAILIMAP_STATE_DISCONNECTED, | ||
3056 | MAILIMAP_STATE_NON_AUTHENTICATED, | ||
3057 | MAILIMAP_STATE_AUTHENTICATED, | ||
3058 | MAILIMAP_STATE_SELECTED, | ||
3059 | MAILIMAP_STATE_LOGOUT | ||
3060 | }; | ||
3061 | |||
3062 | /* | ||
3063 | mailimap is an IMAP connection | ||
3064 | |||
3065 | - response is a human readable message returned with a reponse, | ||
3066 | must be accessed read-only | ||
3067 | |||
3068 | - stream is the connection with the IMAP server | ||
3069 | |||
3070 | - stream_buffer is the buffer where the data to parse are stored | ||
3071 | |||
3072 | - state is the state of IMAP connection | ||
3073 | |||
3074 | - tag is the current tag being used in IMAP connection | ||
3075 | |||
3076 | - response_buffer is the buffer for response messages | ||
3077 | |||
3078 | - connection_info is the information returned in response | ||
3079 | for the last command about the connection | ||
3080 | |||
3081 | - selection_info is the information returned in response | ||
3082 | for the last command about the current selected mailbox | ||
3083 | |||
3084 | - response_info is the other information returned in response | ||
3085 | for the last command | ||
3086 | */ | ||
3087 | |||
3088 | struct mailimap { | ||
3089 | char * imap_response; | ||
3090 | |||
3091 | /* internals */ | ||
3092 | mailstream * imap_stream; | ||
3093 | |||
3094 | size_t imap_progr_rate; | ||
3095 | progress_function * imap_progr_fun; | ||
3096 | |||
3097 | MMAPString * imap_stream_buffer; | ||
3098 | MMAPString * imap_response_buffer; | ||
3099 | |||
3100 | int imap_state; | ||
3101 | int imap_tag; | ||
3102 | |||
3103 | struct mailimap_connection_info * imap_connection_info; | ||
3104 | struct mailimap_selection_info * imap_selection_info; | ||
3105 | struct mailimap_response_info * imap_response_info; | ||
3106 | }; | ||
3107 | |||
3108 | typedef struct mailimap mailimap; | ||
3109 | |||
3110 | |||
3111 | /* | ||
3112 | mailimap_connection_info is the information about the connection | ||
3113 | |||
3114 | - capability is the list of capability of the IMAP server | ||
3115 | */ | ||
3116 | |||
3117 | struct mailimap_connection_info { | ||
3118 | struct mailimap_capability_data * imap_capability; | ||
3119 | }; | ||
3120 | |||
3121 | struct mailimap_connection_info * | ||
3122 | mailimap_connection_info_new(void); | ||
3123 | |||
3124 | void | ||
3125 | mailimap_connection_info_free(struct mailimap_connection_info * conn_info); | ||
3126 | |||
3127 | |||
3128 | /* this is the type of mailbox access */ | ||
3129 | |||
3130 | enum { | ||
3131 | MAILIMAP_MAILBOX_READONLY, | ||
3132 | MAILIMAP_MAILBOX_READWRITE | ||
3133 | }; | ||
3134 | |||
3135 | /* | ||
3136 | mailimap_selection_info is information about the current selected mailbox | ||
3137 | |||
3138 | - perm_flags is a list of flags that can be changed permanently on the | ||
3139 | messages of the mailbox | ||
3140 | |||
3141 | - perm is the access on the mailbox, value can be | ||
3142 | MAILIMAP_MAILBOX_READONLY or MAILIMAP_MAILBOX_READWRITE | ||
3143 | |||
3144 | - uidnext is the next unique identifier | ||
3145 | |||
3146 | - uidvalidity is the unique identifiers validity | ||
3147 | |||
3148 | - first_unseen is the number of the first unseen message | ||
3149 | |||
3150 | - flags is a list of flags that can be used on the messages of | ||
3151 | the mailbox | ||
3152 | |||
3153 | - exists is the number of messages in the mailbox | ||
3154 | |||
3155 | - recent is the number of recent messages in the mailbox | ||
3156 | |||
3157 | - unseen is the number of unseen messages in the mailbox | ||
3158 | */ | ||
3159 | |||
3160 | struct mailimap_selection_info { | ||
3161 | clist * sel_perm_flags; /* list of (struct flag_perm *) */ | ||
3162 | int sel_perm; | ||
3163 | uint32_t sel_uidnext; | ||
3164 | uint32_t sel_uidvalidity; | ||
3165 | uint32_t sel_first_unseen; | ||
3166 | struct mailimap_flag_list * sel_flags; | ||
3167 | uint32_t sel_exists; | ||
3168 | uint32_t sel_recent; | ||
3169 | uint32_t sel_unseen; | ||
3170 | }; | ||
3171 | |||
3172 | struct mailimap_selection_info * | ||
3173 | mailimap_selection_info_new(void); | ||
3174 | |||
3175 | void | ||
3176 | mailimap_selection_info_free(struct mailimap_selection_info * sel_info); | ||
3177 | |||
3178 | |||
3179 | /* | ||
3180 | mailimap_response_info is the other information returned in the | ||
3181 | response for a command | ||
3182 | |||
3183 | - alert is the human readable text returned with ALERT response | ||
3184 | |||
3185 | - parse is the human readable text returned with PARSE response | ||
3186 | |||
3187 | - badcharset is a list of charset returned with a BADCHARSET response | ||
3188 | |||
3189 | - trycreate is set to 1 if a trycreate response was returned | ||
3190 | |||
3191 | - mailbox_list is a list of mailboxes | ||
3192 | |||
3193 | - mailbox_lsub is a list of subscribed mailboxes | ||
3194 | |||
3195 | - search_result is a list of message numbers or unique identifiers | ||
3196 | |||
3197 | - status is a STATUS response | ||
3198 | |||
3199 | - expunged is a list of message numbers | ||
3200 | |||
3201 | - fetch_list is a list of fetch response | ||
3202 | */ | ||
3203 | |||
3204 | struct mailimap_response_info { | ||
3205 | char * rsp_alert; | ||
3206 | char * rsp_parse; | ||
3207 | clist * rsp_badcharset; /* list of (char *) */ | ||
3208 | int rsp_trycreate; | ||
3209 | clist * rsp_mailbox_list; /* list of (struct mailimap_mailbox_list *) */ | ||
3210 | clist * rsp_mailbox_lsub; /* list of (struct mailimap_mailbox_list *) */ | ||
3211 | clist * rsp_search_result; /* list of (uint32_t *) */ | ||
3212 | struct mailimap_mailbox_data_status * rsp_status; | ||
3213 | clist * rsp_expunged; /* list of (uint32_t 32 *) */ | ||
3214 | clist * rsp_fetch_list; /* list of (struct mailimap_msg_att *) */ | ||
3215 | }; | ||
3216 | |||
3217 | struct mailimap_response_info * | ||
3218 | mailimap_response_info_new(void); | ||
3219 | |||
3220 | void | ||
3221 | mailimap_response_info_free(struct mailimap_response_info * resp_info); | ||
3222 | |||
3223 | |||
3224 | /* these are the possible returned error codes */ | ||
3225 | |||
3226 | enum { | ||
3227 | MAILIMAP_NO_ERROR = 0, | ||
3228 | MAILIMAP_NO_ERROR_AUTHENTICATED = 1, | ||
3229 | MAILIMAP_NO_ERROR_NON_AUTHENTICATED = 2, | ||
3230 | MAILIMAP_ERROR_BAD_STATE, | ||
3231 | MAILIMAP_ERROR_STREAM, | ||
3232 | MAILIMAP_ERROR_PARSE, | ||
3233 | MAILIMAP_ERROR_CONNECTION_REFUSED, | ||
3234 | MAILIMAP_ERROR_MEMORY, | ||
3235 | MAILIMAP_ERROR_FATAL, | ||
3236 | MAILIMAP_ERROR_PROTOCOL, | ||
3237 | MAILIMAP_ERROR_DONT_ACCEPT_CONNECTION, | ||
3238 | MAILIMAP_ERROR_APPEND, | ||
3239 | MAILIMAP_ERROR_NOOP, | ||
3240 | MAILIMAP_ERROR_LOGOUT, | ||
3241 | MAILIMAP_ERROR_CAPABILITY, | ||
3242 | MAILIMAP_ERROR_CHECK, | ||
3243 | MAILIMAP_ERROR_CLOSE, | ||
3244 | MAILIMAP_ERROR_EXPUNGE, | ||
3245 | MAILIMAP_ERROR_COPY, | ||
3246 | MAILIMAP_ERROR_UID_COPY, | ||
3247 | MAILIMAP_ERROR_CREATE, | ||
3248 | MAILIMAP_ERROR_DELETE, | ||
3249 | MAILIMAP_ERROR_EXAMINE, | ||
3250 | MAILIMAP_ERROR_FETCH, | ||
3251 | MAILIMAP_ERROR_UID_FETCH, | ||
3252 | MAILIMAP_ERROR_LIST, | ||
3253 | MAILIMAP_ERROR_LOGIN, | ||
3254 | MAILIMAP_ERROR_LSUB, | ||
3255 | MAILIMAP_ERROR_RENAME, | ||
3256 | MAILIMAP_ERROR_SEARCH, | ||
3257 | MAILIMAP_ERROR_UID_SEARCH, | ||
3258 | MAILIMAP_ERROR_SELECT, | ||
3259 | MAILIMAP_ERROR_STATUS, | ||
3260 | MAILIMAP_ERROR_STORE, | ||
3261 | MAILIMAP_ERROR_UID_STORE, | ||
3262 | MAILIMAP_ERROR_SUBSCRIBE, | ||
3263 | MAILIMAP_ERROR_UNSUBSCRIBE, | ||
3264 | MAILIMAP_ERROR_STARTTLS, | ||
3265 | MAILIMAP_ERROR_INVAL, | ||
3266 | }; | ||
3267 | |||
3268 | |||
3269 | #ifdef __cplusplus | ||
3270 | } | ||
3271 | #endif | ||
3272 | |||
3273 | #endif | ||
3274 | |||