forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_imap.c
5102 lines (4401 loc) · 144 KB
/
php_imap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2017 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Rex Logan <[email protected]> |
| Mark Musone <[email protected]> |
| Brian Wang <[email protected]> |
| Kaj-Michael Lang <[email protected]> |
| Antoni Pamies Olive <[email protected]> |
| Rasmus Lerdorf <[email protected]> |
| Chuck Hagenbuch <[email protected]> |
| Andrew Skalski <[email protected]> |
| Hartmut Holzgraefe <[email protected]> |
| Jani Taskinen <[email protected]> |
| Daniel R. Kalowsky <[email protected]> |
| PHP 4.0 updates: Zeev Suraski <[email protected]> |
+----------------------------------------------------------------------+
*/
/* $Id$ */
#define IMAP41
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "php_streams.h"
#include "ext/standard/php_string.h"
#include "ext/standard/info.h"
#include "ext/standard/file.h"
#include "zend_smart_str.h"
#include "ext/pcre/php_pcre.h"
#ifdef ERROR
#undef ERROR
#endif
#include "php_imap.h"
#include <time.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#ifdef PHP_WIN32
#include <winsock2.h>
#include <stdlib.h>
#include "win32/sendmail.h"
MAILSTREAM DEFAULTPROTO;
#endif
#define CRLF "\015\012"
#define CRLF_LEN sizeof("\015\012") - 1
#define PHP_EXPUNGE 32768
#define PHP_IMAP_ADDRESS_SIZE_BUF 10
#ifndef SENDBUFLEN
#define SENDBUFLEN 16385
#endif
#if defined(__GNUC__) && __GNUC__ >= 4
# define PHP_IMAP_EXPORT __attribute__ ((visibility("default")))
#else
# define PHP_IMAP_EXPORT
#endif
static void _php_make_header_object(zval *myzvalue, ENVELOPE *en);
static void _php_imap_add_body(zval *arg, BODY *body);
static zend_string* _php_imap_parse_address(ADDRESS *addresslist, zval *paddress);
static zend_string* _php_rfc822_write_address(ADDRESS *addresslist);
/* the gets we use */
static char *php_mail_gets(readfn_t f, void *stream, unsigned long size, GETS_DATA *md);
/* These function declarations are missing from the IMAP header files... */
void rfc822_date(char *date);
char *cpystr(const char *str);
char *cpytxt(SIZEDTEXT *dst, char *text, unsigned long size);
#ifndef HAVE_NEW_MIME2TEXT
long utf8_mime2text(SIZEDTEXT *src, SIZEDTEXT *dst);
#else
long utf8_mime2text (SIZEDTEXT *src, SIZEDTEXT *dst, long flags);
#endif
unsigned long find_rightmost_bit(unsigned long *valptr);
void fs_give(void **block);
void *fs_get(size_t size);
ZEND_DECLARE_MODULE_GLOBALS(imap)
static PHP_GINIT_FUNCTION(imap);
/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_open, 0, 0, 3)
ZEND_ARG_INFO(0, mailbox)
ZEND_ARG_INFO(0, user)
ZEND_ARG_INFO(0, password)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, n_retries)
ZEND_ARG_INFO(0, params)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_reopen, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, n_retries)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_append, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, folder)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, date)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_num_msg, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_ping, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_num_recent, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_END_ARG_INFO()
#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_get_quota, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, qroot)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_get_quotaroot, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mbox)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_set_quota, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, qroot)
ZEND_ARG_INFO(0, mailbox_size)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_setacl, 0, 0, 4)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_ARG_INFO(0, id)
ZEND_ARG_INFO(0, rights)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getacl, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_expunge, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_gc, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_close, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_headers, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_body, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail_copy, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msglist)
ZEND_ARG_INFO(0, mailbox)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail_move, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, sequence)
ZEND_ARG_INFO(0, mailbox)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_createmailbox, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_renamemailbox, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, old_name)
ZEND_ARG_INFO(0, new_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_deletemailbox, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_list, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, ref)
ZEND_ARG_INFO(0, pattern)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getmailboxes, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, ref)
ZEND_ARG_INFO(0, pattern)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_listscan, 0, 0, 4)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, ref)
ZEND_ARG_INFO(0, pattern)
ZEND_ARG_INFO(0, content)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_check, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_delete, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_undelete, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_headerinfo, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, from_length)
ZEND_ARG_INFO(0, subject_length)
ZEND_ARG_INFO(0, default_host)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_rfc822_parse_headers, 0, 0, 1)
ZEND_ARG_INFO(0, headers)
ZEND_ARG_INFO(0, default_host)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_lsub, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, ref)
ZEND_ARG_INFO(0, pattern)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_getsubscribed, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, ref)
ZEND_ARG_INFO(0, pattern)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_subscribe, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_unsubscribe, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetchstructure, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetchbody, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, section)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_savebody, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, file)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, section)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_base64, 0, 0, 1)
ZEND_ARG_INFO(0, text)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_qprint, 0, 0, 1)
ZEND_ARG_INFO(0, text)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_8bit, 0, 0, 1)
ZEND_ARG_INFO(0, text)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_binary, 0, 0, 1)
ZEND_ARG_INFO(0, text)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mailboxmsginfo, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_rfc822_write_address, 0, 0, 3)
ZEND_ARG_INFO(0, mailbox)
ZEND_ARG_INFO(0, host)
ZEND_ARG_INFO(0, personal)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_rfc822_parse_adrlist, 0, 0, 2)
ZEND_ARG_INFO(0, address_string)
ZEND_ARG_INFO(0, default_host)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf8, 0, 0, 1)
ZEND_ARG_INFO(0, mime_encoded_text)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf7_decode, 0, 0, 1)
ZEND_ARG_INFO(0, buf)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf7_encode, 0, 0, 1)
ZEND_ARG_INFO(0, buf)
ZEND_END_ARG_INFO()
#ifdef HAVE_IMAP_MUTF7
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_utf8_to_mutf7, 0, 0, 1)
ZEND_ARG_INFO(0, in)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mutf7_to_utf8, 0, 0, 1)
ZEND_ARG_INFO(0, in)
ZEND_END_ARG_INFO()
#endif
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_setflag_full, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, sequence)
ZEND_ARG_INFO(0, flag)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_clearflag_full, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, sequence)
ZEND_ARG_INFO(0, flag)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_sort, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, criteria)
ZEND_ARG_INFO(0, reverse)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, search_criteria)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetchheader, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_uid, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_msgno, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, unique_msg_id)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_status, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, mailbox)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_bodystruct, 0, 0, 3)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, msg_no)
ZEND_ARG_INFO(0, section)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_fetch_overview, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, sequence)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail_compose, 0, 0, 2)
ZEND_ARG_INFO(0, envelope)
ZEND_ARG_INFO(0, body)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mail, 0, 0, 3)
ZEND_ARG_INFO(0, to)
ZEND_ARG_INFO(0, subject)
ZEND_ARG_INFO(0, message)
ZEND_ARG_INFO(0, additional_headers)
ZEND_ARG_INFO(0, cc)
ZEND_ARG_INFO(0, bcc)
ZEND_ARG_INFO(0, rpath)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_search, 0, 0, 2)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, criteria)
ZEND_ARG_INFO(0, options)
ZEND_ARG_INFO(0, charset)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_imap_alerts, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_imap_errors, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_imap_last_error, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_mime_header_decode, 0, 0, 1)
ZEND_ARG_INFO(0, str)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_thread, 0, 0, 1)
ZEND_ARG_INFO(0, stream_id)
ZEND_ARG_INFO(0, options)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imap_timeout, 0, 0, 1)
ZEND_ARG_INFO(0, timeout_type)
ZEND_ARG_INFO(0, timeout)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ imap_functions[]
*/
const zend_function_entry imap_functions[] = {
PHP_FE(imap_open, arginfo_imap_open)
PHP_FE(imap_reopen, arginfo_imap_reopen)
PHP_FE(imap_close, arginfo_imap_close)
PHP_FE(imap_num_msg, arginfo_imap_num_msg)
PHP_FE(imap_num_recent, arginfo_imap_num_recent)
PHP_FE(imap_headers, arginfo_imap_headers)
PHP_FE(imap_headerinfo, arginfo_imap_headerinfo)
PHP_FE(imap_rfc822_parse_headers, arginfo_imap_rfc822_parse_headers)
PHP_FE(imap_rfc822_write_address, arginfo_imap_rfc822_write_address)
PHP_FE(imap_rfc822_parse_adrlist, arginfo_imap_rfc822_parse_adrlist)
PHP_FE(imap_body, arginfo_imap_body)
PHP_FE(imap_bodystruct, arginfo_imap_bodystruct)
PHP_FE(imap_fetchbody, arginfo_imap_fetchbody)
PHP_FE(imap_fetchmime, arginfo_imap_fetchbody)
PHP_FE(imap_savebody, arginfo_imap_savebody)
PHP_FE(imap_fetchheader, arginfo_imap_fetchheader)
PHP_FE(imap_fetchstructure, arginfo_imap_fetchstructure)
PHP_FE(imap_gc, arginfo_imap_gc)
PHP_FE(imap_expunge, arginfo_imap_expunge)
PHP_FE(imap_delete, arginfo_imap_delete)
PHP_FE(imap_undelete, arginfo_imap_undelete)
PHP_FE(imap_check, arginfo_imap_check)
PHP_FE(imap_listscan, arginfo_imap_listscan)
PHP_FE(imap_mail_copy, arginfo_imap_mail_copy)
PHP_FE(imap_mail_move, arginfo_imap_mail_move)
PHP_FE(imap_mail_compose, arginfo_imap_mail_compose)
PHP_FE(imap_createmailbox, arginfo_imap_createmailbox)
PHP_FE(imap_renamemailbox, arginfo_imap_renamemailbox)
PHP_FE(imap_deletemailbox, arginfo_imap_deletemailbox)
PHP_FE(imap_subscribe, arginfo_imap_subscribe)
PHP_FE(imap_unsubscribe, arginfo_imap_unsubscribe)
PHP_FE(imap_append, arginfo_imap_append)
PHP_FE(imap_ping, arginfo_imap_ping)
PHP_FE(imap_base64, arginfo_imap_base64)
PHP_FE(imap_qprint, arginfo_imap_qprint)
PHP_FE(imap_8bit, arginfo_imap_8bit)
PHP_FE(imap_binary, arginfo_imap_binary)
PHP_FE(imap_utf8, arginfo_imap_utf8)
PHP_FE(imap_status, arginfo_imap_status)
PHP_FE(imap_mailboxmsginfo, arginfo_imap_mailboxmsginfo)
PHP_FE(imap_setflag_full, arginfo_imap_setflag_full)
PHP_FE(imap_clearflag_full, arginfo_imap_clearflag_full)
PHP_FE(imap_sort, arginfo_imap_sort)
PHP_FE(imap_uid, arginfo_imap_uid)
PHP_FE(imap_msgno, arginfo_imap_msgno)
PHP_FE(imap_list, arginfo_imap_list)
PHP_FE(imap_lsub, arginfo_imap_lsub)
PHP_FE(imap_fetch_overview, arginfo_imap_fetch_overview)
PHP_FE(imap_alerts, arginfo_imap_alerts)
PHP_FE(imap_errors, arginfo_imap_errors)
PHP_FE(imap_last_error, arginfo_imap_last_error)
PHP_FE(imap_search, arginfo_imap_search)
PHP_FE(imap_utf7_decode, arginfo_imap_utf7_decode)
PHP_FE(imap_utf7_encode, arginfo_imap_utf7_encode)
#ifdef HAVE_IMAP_MUTF7
PHP_FE(imap_utf8_to_mutf7, arginfo_imap_utf8_to_mutf7)
PHP_FE(imap_mutf7_to_utf8, arginfo_imap_mutf7_to_utf8)
#endif
PHP_FE(imap_mime_header_decode, arginfo_imap_mime_header_decode)
PHP_FE(imap_thread, arginfo_imap_thread)
PHP_FE(imap_timeout, arginfo_imap_timeout)
#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
PHP_FE(imap_get_quota, arginfo_imap_get_quota)
PHP_FE(imap_get_quotaroot, arginfo_imap_get_quotaroot)
PHP_FE(imap_set_quota, arginfo_imap_set_quota)
PHP_FE(imap_setacl, arginfo_imap_setacl)
PHP_FE(imap_getacl, arginfo_imap_getacl)
#endif
PHP_FE(imap_mail, arginfo_imap_mail)
PHP_FALIAS(imap_header, imap_headerinfo, arginfo_imap_headerinfo)
PHP_FALIAS(imap_listmailbox, imap_list, arginfo_imap_list)
PHP_FALIAS(imap_getmailboxes, imap_list_full, arginfo_imap_getmailboxes)
PHP_FALIAS(imap_scanmailbox, imap_listscan, arginfo_imap_listscan)
PHP_FALIAS(imap_listsubscribed, imap_lsub, arginfo_imap_lsub)
PHP_FALIAS(imap_getsubscribed, imap_lsub_full, arginfo_imap_getsubscribed)
PHP_FALIAS(imap_fetchtext, imap_body, arginfo_imap_body)
PHP_FALIAS(imap_scan, imap_listscan, arginfo_imap_listscan)
PHP_FALIAS(imap_create, imap_createmailbox, arginfo_imap_createmailbox)
PHP_FALIAS(imap_rename, imap_renamemailbox, arginfo_imap_renamemailbox)
PHP_FE_END
};
/* }}} */
/* {{{ imap dependencies */
static const zend_module_dep imap_deps[] = {
ZEND_MOD_REQUIRED("standard")
ZEND_MOD_END
};
/* }}} */
/* {{{ imap_module_entry
*/
zend_module_entry imap_module_entry = {
STANDARD_MODULE_HEADER_EX, NULL,
imap_deps,
"imap",
imap_functions,
PHP_MINIT(imap),
NULL,
PHP_RINIT(imap),
PHP_RSHUTDOWN(imap),
PHP_MINFO(imap),
PHP_IMAP_VERSION,
PHP_MODULE_GLOBALS(imap),
PHP_GINIT(imap),
NULL,
NULL,
STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
#ifdef COMPILE_DL_IMAP
ZEND_GET_MODULE(imap)
#endif
/* True globals, no need for thread safety */
static int le_imap;
#define PHP_IMAP_CHECK_MSGNO(msgindex) \
if ((msgindex < 1) || ((unsigned) msgindex > imap_le_struct->imap_stream->nmsgs)) { \
php_error_docref(NULL, E_WARNING, "Bad message number"); \
RETURN_FALSE; \
} \
/* {{{ mail_close_it
*/
static void mail_close_it(zend_resource *rsrc)
{
pils *imap_le_struct = (pils *)rsrc->ptr;
/* Do not try to close prototype streams */
if (!(imap_le_struct->flags & OP_PROTOTYPE)) {
mail_close_full(imap_le_struct->imap_stream, imap_le_struct->flags);
}
if (IMAPG(imap_user)) {
efree(IMAPG(imap_user));
IMAPG(imap_user) = 0;
}
if (IMAPG(imap_password)) {
efree(IMAPG(imap_password));
IMAPG(imap_password) = 0;
}
efree(imap_le_struct);
}
/* }}} */
/* {{{ add_assoc_object
*/
static zval *add_assoc_object(zval *arg, char *key, zval *tmp)
{
HashTable *symtable;
if (Z_TYPE_P(arg) == IS_OBJECT) {
symtable = Z_OBJPROP_P(arg);
} else {
symtable = Z_ARRVAL_P(arg);
}
return zend_hash_str_update(symtable, key, strlen(key), tmp);
}
/* }}} */
/* {{{ add_next_index_object
*/
static inline zval *add_next_index_object(zval *arg, zval *tmp)
{
HashTable *symtable;
if (Z_TYPE_P(arg) == IS_OBJECT) {
symtable = Z_OBJPROP_P(arg);
} else {
symtable = Z_ARRVAL_P(arg);
}
return zend_hash_next_index_insert(symtable, tmp);
}
/* }}} */
/* {{{ mail_newfolderobjectlist
*
* Mail instantiate FOBJECTLIST
* Returns: new FOBJECTLIST list
* Author: CJH
*/
FOBJECTLIST *mail_newfolderobjectlist(void)
{
return (FOBJECTLIST *) memset(fs_get(sizeof(FOBJECTLIST)), 0, sizeof(FOBJECTLIST));
}
/* }}} */
/* {{{ mail_free_foblist
*
* Mail garbage collect FOBJECTLIST
* Accepts: pointer to FOBJECTLIST pointer
* Author: CJH
*/
void mail_free_foblist(FOBJECTLIST **foblist, FOBJECTLIST **tail)
{
FOBJECTLIST *cur, *next;
for (cur=*foblist, next=cur->next; cur; cur=next) {
next = cur->next;
if(cur->text.data)
fs_give((void **)&(cur->text.data));
fs_give((void **)&cur);
}
*tail = NIL;
*foblist = NIL;
}
/* }}} */
/* {{{ mail_newerrorlist
*
* Mail instantiate ERRORLIST
* Returns: new ERRORLIST list
* Author: CJH
*/
ERRORLIST *mail_newerrorlist(void)
{
return (ERRORLIST *) memset(fs_get(sizeof(ERRORLIST)), 0, sizeof(ERRORLIST));
}
/* }}} */
/* {{{ mail_free_errorlist
*
* Mail garbage collect FOBJECTLIST
* Accepts: pointer to FOBJECTLIST pointer
* Author: CJH
*/
void mail_free_errorlist(ERRORLIST **errlist)
{
if (*errlist) { /* only free if exists */
if ((*errlist)->text.data) {
fs_give((void **) &(*errlist)->text.data);
}
mail_free_errorlist (&(*errlist)->next);
fs_give((void **) errlist); /* return string to free storage */
}
}
/* }}} */
/* {{{ mail_newmessagelist
*
* Mail instantiate MESSAGELIST
* Returns: new MESSAGELIST list
* Author: CJH
*/
MESSAGELIST *mail_newmessagelist(void)
{
return (MESSAGELIST *) memset(fs_get(sizeof(MESSAGELIST)), 0, sizeof(MESSAGELIST));
}
/* }}} */
/* {{{ mail_free_messagelist
*
* Mail garbage collect MESSAGELIST
* Accepts: pointer to MESSAGELIST pointer
* Author: CJH
*/
void mail_free_messagelist(MESSAGELIST **msglist, MESSAGELIST **tail)
{
MESSAGELIST *cur, *next;
for (cur = *msglist, next = cur->next; cur; cur = next) {
next = cur->next;
fs_give((void **)&cur);
}
*tail = NIL;
*msglist = NIL;
}
/* }}} */
#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
/* {{{ mail_getquota
*
* Mail GET_QUOTA callback
* Called via the mail_parameter function in c-client:src/c-client/mail.c
* Author DRK
*/
void mail_getquota(MAILSTREAM *stream, char *qroot, QUOTALIST *qlist)
{
zval t_map, *return_value;
return_value = *IMAPG(quota_return);
/* put parsing code here */
for(; qlist; qlist = qlist->next) {
array_init(&t_map);
if (strncmp(qlist->name, "STORAGE", 7) == 0)
{
/* this is to add backwards compatibility */
add_assoc_long_ex(return_value, "usage", sizeof("usage") - 1, qlist->usage);
add_assoc_long_ex(return_value, "limit", sizeof("limit") - 1, qlist->limit);
}
add_assoc_long_ex(&t_map, "usage", sizeof("usage") - 1, qlist->usage);
add_assoc_long_ex(&t_map, "limit", sizeof("limit") - 1, qlist->limit);
add_assoc_zval_ex(return_value, qlist->name, strlen(qlist->name), &t_map);
}
}
/* }}} */
/* {{{ mail_getquota
*
* Mail GET_ACL callback
* Called via the mail_parameter function in c-client:src/c-client/mail.c
*/
void mail_getacl(MAILSTREAM *stream, char *mailbox, ACLLIST *alist)
{
/* walk through the ACLLIST */
for(; alist; alist = alist->next) {
add_assoc_stringl(IMAPG(imap_acl_list), alist->identifier, alist->rights, strlen(alist->rights));
}
}
/* }}} */
#endif
/* {{{ PHP_GINIT_FUNCTION
*/
static PHP_GINIT_FUNCTION(imap)
{
imap_globals->imap_user = NIL;
imap_globals->imap_password = NIL;
imap_globals->imap_alertstack = NIL;
imap_globals->imap_errorstack = NIL;
imap_globals->imap_folders = NIL;
imap_globals->imap_folders_tail = NIL;
imap_globals->imap_sfolders = NIL;
imap_globals->imap_sfolders_tail = NIL;
imap_globals->imap_messages = NIL;
imap_globals->imap_messages_tail = NIL;
imap_globals->imap_folder_objects = NIL;
imap_globals->imap_folder_objects_tail = NIL;
imap_globals->imap_sfolder_objects = NIL;
imap_globals->imap_sfolder_objects_tail = NIL;
imap_globals->folderlist_style = FLIST_ARRAY;
#if defined(HAVE_IMAP2000) || defined(HAVE_IMAP2001)
imap_globals->quota_return = NIL;
imap_globals->imap_acl_list = NIL;
#endif
imap_globals->gets_stream = NIL;
}
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(imap)
{
unsigned long sa_all = SA_MESSAGES | SA_RECENT | SA_UNSEEN | SA_UIDNEXT | SA_UIDVALIDITY;
#ifndef PHP_WIN32
mail_link(&unixdriver); /* link in the unix driver */
mail_link(&mhdriver); /* link in the mh driver */
/* mail_link(&mxdriver); */ /* According to c-client docs (internal.txt) this shouldn't be used. */
mail_link(&mmdfdriver); /* link in the mmdf driver */
mail_link(&newsdriver); /* link in the news driver */
mail_link(&philedriver); /* link in the phile driver */
#endif
mail_link(&imapdriver); /* link in the imap driver */
mail_link(&nntpdriver); /* link in the nntp driver */
mail_link(&pop3driver); /* link in the pop3 driver */
mail_link(&mbxdriver); /* link in the mbx driver */
mail_link(&tenexdriver); /* link in the tenex driver */
mail_link(&mtxdriver); /* link in the mtx driver */
mail_link(&dummydriver); /* link in the dummy driver */
#ifndef PHP_WIN32
auth_link(&auth_log); /* link in the log authenticator */
auth_link(&auth_md5); /* link in the cram-md5 authenticator */
#if HAVE_IMAP_KRB && defined(HAVE_IMAP_AUTH_GSS)
auth_link(&auth_gss); /* link in the gss authenticator */
#endif
auth_link(&auth_pla); /* link in the plain authenticator */
#endif
#ifdef HAVE_IMAP_SSL
ssl_onceonlyinit ();
#endif
/* lets allow NIL */
REGISTER_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS);
/* plug in our gets */
mail_parameters(NIL, SET_GETS, (void *) NIL);
/* set default timeout values */
mail_parameters(NIL, SET_OPENTIMEOUT, (void *) FG(default_socket_timeout));
mail_parameters(NIL, SET_READTIMEOUT, (void *) FG(default_socket_timeout));
mail_parameters(NIL, SET_WRITETIMEOUT, (void *) FG(default_socket_timeout));
mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) FG(default_socket_timeout));
/* timeout constants */
REGISTER_LONG_CONSTANT("IMAP_OPENTIMEOUT", 1, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("IMAP_READTIMEOUT", 2, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("IMAP_WRITETIMEOUT", 3, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("IMAP_CLOSETIMEOUT", 4, CONST_PERSISTENT | CONST_CS);
/* Open Options */
REGISTER_LONG_CONSTANT("OP_DEBUG", OP_DEBUG, CONST_PERSISTENT | CONST_CS);
/* debug protocol negotiations */
REGISTER_LONG_CONSTANT("OP_READONLY", OP_READONLY, CONST_PERSISTENT | CONST_CS);
/* read-only open */
REGISTER_LONG_CONSTANT("OP_ANONYMOUS", OP_ANONYMOUS, CONST_PERSISTENT | CONST_CS);
/* anonymous open of newsgroup */
REGISTER_LONG_CONSTANT("OP_SHORTCACHE", OP_SHORTCACHE, CONST_PERSISTENT | CONST_CS);
/* short (elt-only) caching */
REGISTER_LONG_CONSTANT("OP_SILENT", OP_SILENT, CONST_PERSISTENT | CONST_CS);
/* don't pass up events (internal use) */
REGISTER_LONG_CONSTANT("OP_PROTOTYPE", OP_PROTOTYPE, CONST_PERSISTENT | CONST_CS);
/* return driver prototype */
REGISTER_LONG_CONSTANT("OP_HALFOPEN", OP_HALFOPEN, CONST_PERSISTENT | CONST_CS);
/* half-open (IMAP connect but no select) */
REGISTER_LONG_CONSTANT("OP_EXPUNGE", OP_EXPUNGE, CONST_PERSISTENT | CONST_CS);
/* silently expunge recycle stream */
REGISTER_LONG_CONSTANT("OP_SECURE", OP_SECURE, CONST_PERSISTENT | CONST_CS);
/* don't do non-secure authentication */
/*
PHP re-assigns CL_EXPUNGE a custom value that can be used as part of the imap_open() bitfield
because it seems like a good idea to be able to indicate that the mailbox should be
automatically expunged during imap_open in case the script get interrupted and it doesn't get
to the imap_close() where this option is normally placed. If the c-client library adds other
options and the value for this one conflicts, simply make PHP_EXPUNGE higher at the top of
this file
*/
REGISTER_LONG_CONSTANT("CL_EXPUNGE", PHP_EXPUNGE, CONST_PERSISTENT | CONST_CS);
/* expunge silently */
/* Fetch options */
REGISTER_LONG_CONSTANT("FT_UID", FT_UID, CONST_PERSISTENT | CONST_CS);
/* argument is a UID */
REGISTER_LONG_CONSTANT("FT_PEEK", FT_PEEK, CONST_PERSISTENT | CONST_CS);
/* peek at data */
REGISTER_LONG_CONSTANT("FT_NOT", FT_NOT, CONST_PERSISTENT | CONST_CS);
/* NOT flag for header lines fetch */
REGISTER_LONG_CONSTANT("FT_INTERNAL", FT_INTERNAL, CONST_PERSISTENT | CONST_CS);
/* text can be internal strings */
REGISTER_LONG_CONSTANT("FT_PREFETCHTEXT", FT_PREFETCHTEXT, CONST_PERSISTENT | CONST_CS);
/* IMAP prefetch text when fetching header */
/* Flagging options */
REGISTER_LONG_CONSTANT("ST_UID", ST_UID, CONST_PERSISTENT | CONST_CS);
/* argument is a UID sequence */
REGISTER_LONG_CONSTANT("ST_SILENT", ST_SILENT, CONST_PERSISTENT | CONST_CS);
/* don't return results */
REGISTER_LONG_CONSTANT("ST_SET", ST_SET, CONST_PERSISTENT | CONST_CS);
/* set vs. clear */
/* Copy options */
REGISTER_LONG_CONSTANT("CP_UID", CP_UID, CONST_PERSISTENT | CONST_CS);
/* argument is a UID sequence */
REGISTER_LONG_CONSTANT("CP_MOVE", CP_MOVE, CONST_PERSISTENT | CONST_CS);
/* delete from source after copying */
/* Search/sort options */
REGISTER_LONG_CONSTANT("SE_UID", SE_UID, CONST_PERSISTENT | CONST_CS);
/* return UID */
REGISTER_LONG_CONSTANT("SE_FREE", SE_FREE, CONST_PERSISTENT | CONST_CS);
/* free search program after finished */
REGISTER_LONG_CONSTANT("SE_NOPREFETCH", SE_NOPREFETCH, CONST_PERSISTENT | CONST_CS);
/* no search prefetching */
REGISTER_LONG_CONSTANT("SO_FREE", SO_FREE, CONST_PERSISTENT | CONST_CS);
/* free sort program after finished */
REGISTER_LONG_CONSTANT("SO_NOSERVER", SO_NOSERVER, CONST_PERSISTENT | CONST_CS);
/* don't do server-based sort */
/* Status options */
REGISTER_LONG_CONSTANT("SA_MESSAGES", SA_MESSAGES , CONST_PERSISTENT | CONST_CS);
/* number of messages */
REGISTER_LONG_CONSTANT("SA_RECENT", SA_RECENT, CONST_PERSISTENT | CONST_CS);
/* number of recent messages */
REGISTER_LONG_CONSTANT("SA_UNSEEN", SA_UNSEEN , CONST_PERSISTENT | CONST_CS);
/* number of unseen messages */
REGISTER_LONG_CONSTANT("SA_UIDNEXT", SA_UIDNEXT, CONST_PERSISTENT | CONST_CS);
/* next UID to be assigned */
REGISTER_LONG_CONSTANT("SA_UIDVALIDITY", SA_UIDVALIDITY , CONST_PERSISTENT | CONST_CS);
/* UID validity value */
REGISTER_LONG_CONSTANT("SA_ALL", sa_all, CONST_PERSISTENT | CONST_CS);
/* get all status information */
/* Bits for mm_list() and mm_lsub() */
REGISTER_LONG_CONSTANT("LATT_NOINFERIORS", LATT_NOINFERIORS , CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LATT_NOSELECT", LATT_NOSELECT, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LATT_MARKED", LATT_MARKED, CONST_PERSISTENT | CONST_CS);
REGISTER_LONG_CONSTANT("LATT_UNMARKED", LATT_UNMARKED , CONST_PERSISTENT | CONST_CS);
#ifdef LATT_REFERRAL
REGISTER_LONG_CONSTANT("LATT_REFERRAL", LATT_REFERRAL, CONST_PERSISTENT | CONST_CS);
#endif
#ifdef LATT_HASCHILDREN
REGISTER_LONG_CONSTANT("LATT_HASCHILDREN", LATT_HASCHILDREN, CONST_PERSISTENT | CONST_CS);
#endif
#ifdef LATT_HASNOCHILDREN
REGISTER_LONG_CONSTANT("LATT_HASNOCHILDREN", LATT_HASNOCHILDREN, CONST_PERSISTENT | CONST_CS);
#endif
/* Sort functions */
REGISTER_LONG_CONSTANT("SORTDATE", SORTDATE , CONST_PERSISTENT | CONST_CS);
/* date */
REGISTER_LONG_CONSTANT("SORTARRIVAL", SORTARRIVAL , CONST_PERSISTENT | CONST_CS);
/* arrival date */
REGISTER_LONG_CONSTANT("SORTFROM", SORTFROM , CONST_PERSISTENT | CONST_CS);
/* from */
REGISTER_LONG_CONSTANT("SORTSUBJECT", SORTSUBJECT , CONST_PERSISTENT | CONST_CS);
/* subject */
REGISTER_LONG_CONSTANT("SORTTO", SORTTO , CONST_PERSISTENT | CONST_CS);