1 #ifndef EXT_DATE_COMMON_H
2 #define EXT_DATE_COMMON_H
3 
4 #include "sieve-common.h"
5 
6 #include <time.h>
7 
8 /*
9  * Extension
10  */
11 
12 extern const struct sieve_extension_def date_extension;
13 
14 bool ext_date_interpreter_load
15 	(const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
16 		sieve_size_t *address ATTR_UNUSED);
17 
18 /*
19  * Tests
20  */
21 
22 extern const struct sieve_command_def date_test;
23 extern const struct sieve_command_def currentdate_test;
24 
25 /*
26  * Operations
27  */
28 
29 enum ext_date_opcode {
30 	EXT_DATE_OPERATION_DATE,
31 	EXT_DATE_OPERATION_CURRENTDATE
32 };
33 
34 extern const struct sieve_operation_def date_operation;
35 extern const struct sieve_operation_def currentdate_operation;
36 
37 /*
38  * Zone string
39  */
40 
41 bool ext_date_parse_timezone(const char *zone, int *zone_offset_r);
42 
43 /*
44  * Current date
45  */
46 
47 time_t ext_date_get_current_date
48 	(const struct sieve_runtime_env *renv, int *zone_offset_r);
49 
50 /*
51  * Date part
52  */
53 
54 struct ext_date_part {
55 	const char *identifier;
56 
57 	const char *(*get_string)(struct tm *tm, int zone_offset);
58 };
59 
60 const struct ext_date_part *ext_date_part_find(const char *part);
61 
62 const char *ext_date_part_extract
63 	(const struct ext_date_part *dpart, struct tm *tm, int zone_offset);
64 
65 /*
66  * Date stringlist
67  */
68 
69 enum ext_date_timezone_special {
70 	EXT_DATE_TIMEZONE_LOCAL    = 100,
71 	EXT_DATE_TIMEZONE_ORIGINAL = 101
72 };
73 
74 struct sieve_stringlist *ext_date_stringlist_create
75 (const struct sieve_runtime_env *renv, struct sieve_stringlist *field_values,
76 	int time_zone, const struct ext_date_part *dpart);
77 
78 
79 
80 #endif
81