Commit 916871ec 916871ec72d163e1f77273ba693cc2fb7e4a73fa by Sergey Poznyakoff

New file. Handles "require" statement

1 parent b99d129d
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18 #ifdef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <string.h>
26 #include <sieve.h>
27
28 void
29 sieve_require (list_t slist)
30 {
31 int status;
32 iterator_t itr;
33
34 status = iterator_create (&itr, slist);
35 if (status)
36 {
37 sieve_error ("%s:%d: cannot create iterator: %s",
38 sieve_filename, sieve_line_num,
39 mu_errstring (status));
40 return;
41 }
42
43 for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr))
44 {
45 char *s;
46 sieve_register_t *reg;
47
48 iterator_current (itr, (void **)&s);
49
50 /* FIXME: if (strncmp (s, "comparator-", 11) ... */
51 reg = sieve_action_lookup (s);
52 if (!reg)
53 {
54 sieve_error ("%s:%d: source for the required action %s is not available",
55 sieve_filename, sieve_line_num, s);
56 break;
57 }
58 reg->required = 1;
59 }
60 iterator_destroy (&itr);
61 }
62