2 |
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
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) |
the Free Software Foundation; either version 2, or (at your option) |
7 |
any later version. |
any later version. |
8 |
|
|
9 |
This program is distributed in the hope that it will be useful, |
This program is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
GNU Lesser General Public License for more details. |
13 |
|
|
14 |
You should have received a copy of the GNU General Public License |
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 |
along with this program; if not, write to the Free Software |
16 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
17 |
|
|
35 |
return p; |
return p; |
36 |
} |
} |
37 |
|
|
38 |
|
void |
39 |
|
sieve_slist_destroy (list_t *plist) |
40 |
|
{ |
41 |
|
iterator_t itr; |
42 |
|
|
43 |
|
if (!plist || iterator_create (&itr, *plist)) |
44 |
|
return; |
45 |
|
|
46 |
|
for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) |
47 |
|
{ |
48 |
|
char *s; |
49 |
|
iterator_current (itr, (void **)&s); |
50 |
|
free (s); |
51 |
|
} |
52 |
|
iterator_destroy (&itr); |
53 |
|
list_destroy (plist); |
54 |
|
} |
55 |
|
|
56 |
|
sieve_value_t * |
57 |
|
sieve_value_create (sieve_data_type type, void *data) |
58 |
|
{ |
59 |
|
sieve_value_t *val = sieve_alloc (sizeof (*val)); |
60 |
|
|
61 |
|
val->type = type; |
62 |
|
switch (type) |
63 |
|
{ |
64 |
|
case SVT_NUMBER: |
65 |
|
val->v.number = * (long *) data; |
66 |
|
break; |
67 |
|
|
68 |
|
case SVT_STRING: |
69 |
|
val->v.string = data; |
70 |
|
break; |
71 |
|
|
72 |
|
case SVT_VALUE_LIST: |
73 |
|
case SVT_STRING_LIST: |
74 |
|
val->v.list = data; |
75 |
|
|
76 |
|
case SVT_TAG: |
77 |
|
case SVT_IDENT: |
78 |
|
val->v.string = data; |
79 |
|
break; |
80 |
|
|
81 |
|
default: |
82 |
|
sieve_error ("Invalid data type"); |
83 |
|
abort (); |
84 |
|
} |
85 |
|
return val; |
86 |
|
} |
87 |
|
|