Commit 065e591b 065e591bc2ab904ba48a1c22396df38ff6d98e2c by Sergey Poznyakoff

Updated

1 parent 6e26d7b6
1 2002-11-25 Sergey Poznyakoff
2
3 * doc/texinfo/Makefile.am: Fake configure into including
4 srcdir to VPATH.
5 * include/mailutils/libsieve.h (sieve_malloc,sieve_mstrdup)
6 (sieve_mrealloc,sieve_mfree): New functions.
7 * libsieve/util.c: Likewise.
8 * libsieve/comparator.c: Use sieve_m.* memory allocation
9 functions.
10 * libsieve/prog.c: Likewise.
11 * libsieve/sieve.l: Likewise.
12 * libsieve/sieve.y: Likewise.
13
14 * doc/texinfo/libsieve.texi: Updated
15
1 2002-11-25 Frederic Gobry <frederic.gobry@smartdata.ch> 16 2002-11-25 Frederic Gobry <frederic.gobry@smartdata.ch>
2 17
3 * mailbox/address.c (address_concatenate): cleanup the address 18 * mailbox/address.c (address_concatenate): cleanup the address
......
...@@ -16,51 +16,214 @@ ...@@ -16,51 +16,214 @@
16 @section Sieve Data Types 16 @section Sieve Data Types
17 17
18 @deftp {Data Type} sieve_machine_t 18 @deftp {Data Type} sieve_machine_t
19 This is an opaque data type representing a pointer to an instance of
20 sieve machine. The sieve_machine_t keeps all information necessary
21 for compiling and executing the script.
22
23 It is created by @code{sieve_machine_create()} and destroyed by
24 @code{sieve_machine_destroy()}. The functions for manipulating this data
25 type are described in @ref{Manipulating the Sieve Machine}.
19 @end deftp 26 @end deftp
20 27
21 @deftp {Enumeration} sieve_data_type 28 @deftp {Enumeration} sieve_data_type
29 This enumeration keeps the possible types of sieve data. These are:
30
31 @table @code
32 @item SVT_VOID
33 No datatype.
34
35 @item SVT_NUMBER
36 Numeric type.
37
38 @item SVT_STRING
39 Character string.
40
41 @item SVT_STRING_LIST
42 A @code{list_t}. Each item in this list represents a character string.
43
44 @item SVT_TAG
45 A sieve tag. See @code{sieve_runtime_tag_t} below.
46
47 @item SVT_IDENT
48 A character string representing an identifier.
49
50 @item SVT_VALUE_LIST
51 A @code{list_t}. Each item in this list is of @code{sieve_value_t}.
52
53 @item SVT_POINTER
54 An opaque pointer.
55 @end table
22 @end deftp 56 @end deftp
23 57
24 @deftp {Structure} sieve_value_t 58 @deftp {Structure} sieve_value_t
59 The @code{sieve_value_t} keeps an instance of sieve data. It is defined
60 as follows:
61
62 @example
63 @group
64 typedef struct @{
65 sieve_data_type type; /* Type of the data */
66 union @{
67 char *string; /* String value or identifier */
68 long number; /* Numeric value */
69 list_t list; /* List value */
70 sieve_runtime_tag_t *tag; /* Tag value */
71 void *ptr; /* Pointer value */
72 @} v;
73 @} sieve_value_t;
74 @end group
75 @end example
76
77 Depending on the value of @code{type} member, following members of the
78 union @code{v} keep the actual value:
79
80 @table @code
81 @item SVT_VOID
82 Never appears.
83
84 @item SVT_NUMBER
85 The numeric value is kept in @code{number} member.
86
87 @item SVT_STRING
88 The string is kept in @code{string} member.
89
90 @item SVT_STRING_LIST
91 @itemx SVT_VALUE_LIST
92 The list itself is pointed to by @code{list} member
93
94 @item SVT_TAG
95 The tag value is pointed to by @code{tag} member.
96
97 @item SVT_IDENT
98 The @code{string} member points to the identifier name.
99
100 @item SVT_POINTER
101 The data are pointed to by @code{ptr} member.
102 @end table
103
25 @end deftp 104 @end deftp
26 105
27 @deftp {Structure} sieve_tag_def_t 106 @deftp {Structure} sieve_tag_def_t
107 This structure represents a definition of a tagged (optional) argument
108 to a sieve action or test. It is defined as follows:
109
110 @example
111 @group
112 typedef struct @{
113 char *name; /* Tag name */
114 sieve_data_type argtype; /* Type of tag argument. */
115 @} sieve_tag_def_t;
116 @end group
117 @end example
118
119 The @code{name} member points to the tag's name @emph{without leading
120 colon}. The @code{argtype} is set to @code{SVT_VOID} if the tag does
121 not take argument, or to the type of the argument otherwise.
28 @end deftp 122 @end deftp
29 123
30 @deftp {Structure} sieve_runtime_tag_t 124 @deftp {Structure} sieve_runtime_tag_t
125 This structure represents the tagged (optional) argument at a runtime.
126 It is defined as:
127
128 @example
129 @group
130 struct sieve_runtime_tag @{
131 char *tag; /* Tag name */
132 sieve_value_t *arg; /* Tag argument (if any) */
133 @};
134 @end group
135 @end example
136
137 The @code{arg} member is @code{NULL} if the tag does not take an argument.
31 @end deftp 138 @end deftp
32 139
33 @deftp {Function Type} sieve_handler_t 140 @deftp {Function Type} sieve_handler_t
141
142 This is a pointer to function handler for a sieve action or test.
143 It is defined as follows:
34 @example 144 @example
35 typedef int (*sieve_handler_t) (sieve_machine_t mach, 145 typedef int (*sieve_handler_t) (sieve_machine_t @var{mach},
36 list_t args, list_t tags); 146 list_t @var{args}, list_t @var{tags});
37 @end example 147 @end example
38 @end deftp 148 @end deftp
39 149
40 @deftp {Function Type} sieve_printf_t 150 The arguments to the handler have the following meaning:
151
152 @table @var
153 @item mach
154 Sieve machine being processed.
155 @item args
156 A list of required arguments to the handler
157 @item tags
158 A list of optional arguments (tags).
159 @end table
160
161 @deftp {Function Type} sieve_printf_t
162 A pointer to a diagnostic output function. It is defined as follows:
41 @example 163 @example
42 typedef int (*sieve_printf_t) (void *data, const char *fmt, va_list ap); 164 typedef int (*sieve_printf_t) (void *@var{data}, const char *@var{fmt}, va_list @var{ap});
43 @end example 165 @end example
44 @end deftp 166 @end deftp
45 167
168 @table @var
169 @item data
170 A pointer to application specific data. These data are passed as
171 second argument to @code{sieve_machine_init()}.
172 @item fmt
173 Printf-like format string.
174 @item ap
175 Other arguments.
176 @end table
177
46 @deftp {Function Type} sieve_parse_error_t 178 @deftp {Function Type} sieve_parse_error_t
179 This data type is decalred as follows:
47 @example 180 @example
48 typedef int (*sieve_parse_error_t) (void *data, 181 typedef int (*sieve_parse_error_t) (void *@var{data},
49 const char *filename, int lineno, 182 const char *@var{filename}, int @var{lineno},
50 const char *fmt, va_list ap); 183 const char *@var{fmt}, va_list @var{ap});
51 @end example 184 @end example
52 @end deftp 185 @end deftp
53 186
187 It is used to declare error handlers for parsing errors. The
188 application-specific data are passed in the @var{data}
189 argument. Arguments @var{filename} and @var{line} indicate the location
190 of the error in the source text, while @var{fmt} and @var{ap} give
191 verbose description of the error.
192
54 @deftp {Function Type} sieve_action_log_t 193 @deftp {Function Type} sieve_action_log_t
194 A pointer to the application-specific logging function:
195
55 @example 196 @example
56 typedef void (*sieve_action_log_t) (void *data, 197 typedef void (*sieve_action_log_t) (void *@var{data},
57 const char *script, 198 const char *@var{script},
58 size_t msgno, message_t msg, 199 size_t @var{msgno}, message_t @var{msg},
59 const char *action, 200 const char *@var{action},
60 const char *fmt, va_list ap); 201 const char *@var{fmt}, va_list @var{ap});
61 @end example 202 @end example
62 @end deftp 203 @end deftp
63 204
205 @table @var
206 @item data
207 Application-specific data.
208
209 @item script
210 Name of the sieve script being executed.
211
212 @item msgno
213 Ordinal number of the message in mailbox, if appropriate. When execution
214 is started using @code{sieve_message()}, this argument is zero.
215
216 @item msg
217 The message this action is executed upon.
218
219 @item action
220 The name of the action.
221
222 @item fmt
223 @itemx var
224 These two arguments give the detaied description of the action.
225 @end table
226
64 @deftp {Function Type} sieve_comparator_t 227 @deftp {Function Type} sieve_comparator_t
65 @example 228 @example
66 typedef int (*sieve_comparator_t) (const char *, const char *); 229 typedef int (*sieve_comparator_t) (const char *, const char *);
...@@ -194,7 +357,38 @@ sieve_printf_t @var{error_printer}) ...@@ -194,7 +357,38 @@ sieve_printf_t @var{error_printer})
194 @node Memory Allocation 357 @node Memory Allocation
195 @section Memory Allocation 358 @section Memory Allocation
196 359
197 @deftypefn {void *} sieve_alloc (size_t @var{size}) 360 The following functions act as their libc counterparts. The allocated
361 memory is associated with the @var{mach} argument and is automatically
362 freed upon the call to @code{sieve_machine_destroy (@var{mach})}.
363
364 @deftypefn {void *} sieve_malloc (sieve_machine_t @var{mach}, size_t @var{size})
365 Allocates @var{size} bytes and returns a pointer to the allocated memory.
366 @end deftypefn
367
368 @deftypefn {char *} sieve_mstrdup (sieve_machine_t @var{mach}, const char *@var{str})
369 This function returns a pointer to a new string which is a duplicate of the
370 string @var{str}.
371 @end deftypefn
372
373 @deftypefn {void *} sieve_mrealloc (sieve_machine_t @var{mach}, void *@var{ptr}, size_t @var{size})
374 Changes the size of the memory block pointed to by @var{ptr} to
375 @var{size} bytes. The contents will be unchanged to the minimum of the
376 old and new sizes; newly allocated memory will be uninitialized. If
377 @var{ptr} is @code{NULL}, the call is equivalent to
378 @code{sieve_malloc(@var{mach}, @var{size})}; if @var{size} is equal to
379 zero, the call is equivalent to @code{sieve_mfree(@var{ptr})}. Unless
380 @var{ptr} is @code{NULL}, it must have been returned by an earlier
381 call to @code{sieve_malloc()} or @code{sieve_mrealloc()}.
382 @end deftypefn
383
384 @deftypefn void sieve_mfree (sieve_machine_t @var{mach}, void *@var{ptr})
385 @code{sieve_mfree()} frees the memory space pointed to by @var{ptr} and
386 detaches it from the destructor list of @var{mach}. The @var{ptr} must
387 have been returned by a previous call to @code{sieve_malloc()} or
388 @code{sieve_mrealloc()}. Otherwise, or if @code{sieve_mfree(@var{ptr})}
389 has already been called before, undefined behaviour occurs.
390
391 If @var{ptr} is @code{NULL}, no operation is performed.
198 @end deftypefn 392 @end deftypefn
199 393
200 @node Compiling and Executing the Script 394 @node Compiling and Executing the Script
......