sieve: implement an option to add directory to the head of the library search path.
* TODO: Update. * include/mailutils/sieve.h (mu_sieve_library_path_prefix): New variable. * libmu_argp/sieve.c (sieve_argp_option): New option --libdir-prefix. (sieve_argp_parser): Handle --libdir-prefix. * libmu_cfg/sieve.c (cb_library_path_prefix): New callback. (mu_sieve_param): New statement "library-path-prefix". * libmu_sieve/conf.c (mu_sieve_library_path_prefix): New variable. (mu_sieve_module_init): Process prefix paths. Do not call mu_sv_load_add_path. * libmu_sieve/load.c (sieve_init_load_path): Rewrite. (mu_sv_load_add_path): Remove. * libmu_sieve/sieve-priv.h (mu_sv_load_add_path): Remove declaration. (sieve_searchpath): Remove the unused "add" parameter. * sieve/tests/moderator.at: Use MUT_SIEVE_OPTIONS in all tests. * sieve/tests/testsuite.at (MUT_SIEVE_EXT_TEST): Use --libdir-prefix option to ensure that our version of the extension appears first in the path.
Showing
10 changed files
with
39 additions
and
34 deletions
1 | GNU mailutils TODO list. 2010-12-19 | 1 | GNU mailutils TODO list. 2010-12-21 |
2 | Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 Free | 2 | Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 Free |
3 | Software Foundation, Inc. | 3 | Software Foundation, Inc. |
4 | 4 | ||
... | @@ -42,9 +42,7 @@ See frm/common.c (near line 425). | ... | @@ -42,9 +42,7 @@ See frm/common.c (near line 425). |
42 | 42 | ||
43 | See guimb/scm/Makefile.am for a discussion. | 43 | See guimb/scm/Makefile.am for a discussion. |
44 | 44 | ||
45 | * sieve: needs an option to add directory at the head of the search path | 45 | * sieve: extension tests [in progress] |
46 | |||
47 | * sieve: extension tests | ||
48 | 46 | ||
49 | * mu_address_createv: pass hints as in mu_address_create_hint? | 47 | * mu_address_createv: pass hints as in mu_address_create_hint? |
50 | 48 | ... | ... |
... | @@ -122,6 +122,7 @@ typedef struct | ... | @@ -122,6 +122,7 @@ typedef struct |
122 | extern int mu_sieve_yydebug; | 122 | extern int mu_sieve_yydebug; |
123 | extern mu_list_t mu_sieve_include_path; | 123 | extern mu_list_t mu_sieve_include_path; |
124 | extern mu_list_t mu_sieve_library_path; | 124 | extern mu_list_t mu_sieve_library_path; |
125 | extern mu_list_t mu_sieve_library_path_prefix; | ||
125 | 126 | ||
126 | /* Memory allocation functions */ | 127 | /* Memory allocation functions */ |
127 | void *mu_sieve_alloc (size_t size); | 128 | void *mu_sieve_alloc (size_t size); |
... | @@ -258,7 +259,9 @@ int mu_sieve_disass (mu_sieve_machine_t mach); | ... | @@ -258,7 +259,9 @@ int mu_sieve_disass (mu_sieve_machine_t mach); |
258 | struct mu_gocs_sieve | 259 | struct mu_gocs_sieve |
259 | { | 260 | { |
260 | int clearflags; | 261 | int clearflags; |
262 | /* mu_list_t include_path_prefix;*/ | ||
261 | mu_list_t include_path; | 263 | mu_list_t include_path; |
264 | mu_list_t library_path_prefix; | ||
262 | mu_list_t library_path; | 265 | mu_list_t library_path; |
263 | }; | 266 | }; |
264 | 267 | ... | ... |
... | @@ -24,7 +24,8 @@ | ... | @@ -24,7 +24,8 @@ |
24 | 24 | ||
25 | enum { | 25 | enum { |
26 | OPT_CLEAR_INCLUDE_PATH = 256, | 26 | OPT_CLEAR_INCLUDE_PATH = 256, |
27 | OPT_CLEAR_LIBRARY_PATH | 27 | OPT_CLEAR_LIBRARY_PATH, |
28 | OPT_PREFIX_LIBRARY_PATH | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | static struct argp_option sieve_argp_option[] = { | 31 | static struct argp_option sieve_argp_option[] = { |
... | @@ -32,6 +33,9 @@ static struct argp_option sieve_argp_option[] = { | ... | @@ -32,6 +33,9 @@ static struct argp_option sieve_argp_option[] = { |
32 | N_("append DIR to the list of directories searched for include files"), 0 }, | 33 | N_("append DIR to the list of directories searched for include files"), 0 }, |
33 | { "libdir", 'L', N_("DIR"), 0, | 34 | { "libdir", 'L', N_("DIR"), 0, |
34 | N_("append DIR to the list of directories searched for library files"), 0 }, | 35 | N_("append DIR to the list of directories searched for library files"), 0 }, |
36 | { "libdir-prefix", OPT_PREFIX_LIBRARY_PATH, N_("DIR"), 0, | ||
37 | N_("add DIR to the beginning of the list of directories searched for " | ||
38 | "library files"), 0 }, | ||
35 | { "clear-include-path", OPT_CLEAR_INCLUDE_PATH, NULL, 0, | 39 | { "clear-include-path", OPT_CLEAR_INCLUDE_PATH, NULL, 0, |
36 | N_("clear Sieve include path"), 0 }, | 40 | N_("clear Sieve include path"), 0 }, |
37 | { "clear-library-path", OPT_CLEAR_LIBRARY_PATH, NULL, 0, | 41 | { "clear-library-path", OPT_CLEAR_LIBRARY_PATH, NULL, 0, |
... | @@ -55,6 +59,10 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state) | ... | @@ -55,6 +59,10 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state) |
55 | mu_argp_node_list_new (lst, "library-path", arg); | 59 | mu_argp_node_list_new (lst, "library-path", arg); |
56 | break; | 60 | break; |
57 | 61 | ||
62 | case OPT_PREFIX_LIBRARY_PATH: | ||
63 | mu_argp_node_list_new (lst, "library-path-prefix", arg); | ||
64 | break; | ||
65 | |||
58 | case OPT_CLEAR_INCLUDE_PATH: | 66 | case OPT_CLEAR_INCLUDE_PATH: |
59 | mu_argp_node_list_new (lst, "clear-include-path", "yes"); | 67 | mu_argp_node_list_new (lst, "clear-include-path", "yes"); |
60 | break; | 68 | break; | ... | ... |
... | @@ -90,6 +90,13 @@ cb_library_path (void *data, mu_config_value_t *val) | ... | @@ -90,6 +90,13 @@ cb_library_path (void *data, mu_config_value_t *val) |
90 | &sieve_settings.library_path); | 90 | &sieve_settings.library_path); |
91 | } | 91 | } |
92 | 92 | ||
93 | static int | ||
94 | cb_library_path_prefix (void *data, mu_config_value_t *val) | ||
95 | { | ||
96 | return mu_cfg_string_value_cb (val, _add_path, | ||
97 | &sieve_settings.library_path_prefix); | ||
98 | } | ||
99 | |||
93 | static struct mu_cfg_param mu_sieve_param[] = { | 100 | static struct mu_cfg_param mu_sieve_param[] = { |
94 | { "clear-library-path", mu_cfg_callback, NULL, 0, cb_clear_library_path, | 101 | { "clear-library-path", mu_cfg_callback, NULL, 0, cb_clear_library_path, |
95 | N_("Clear library search path.") }, | 102 | N_("Clear library search path.") }, |
... | @@ -99,6 +106,10 @@ static struct mu_cfg_param mu_sieve_param[] = { | ... | @@ -99,6 +106,10 @@ static struct mu_cfg_param mu_sieve_param[] = { |
99 | N_("Add directories to the library search path. Argument is a " | 106 | N_("Add directories to the library search path. Argument is a " |
100 | "colon-separated list of directories."), | 107 | "colon-separated list of directories."), |
101 | N_("list") }, | 108 | N_("list") }, |
109 | { "library-path-prefix", mu_cfg_callback, NULL, 0, cb_library_path_prefix, | ||
110 | N_("Add directories to the beginning of the library search path. " | ||
111 | "Argument is a colon-separated list of directories."), | ||
112 | N_("list") }, | ||
102 | { "include-path", mu_cfg_callback, NULL, 0, cb_include_path, | 113 | { "include-path", mu_cfg_callback, NULL, 0, cb_include_path, |
103 | N_("Add directories to the include search path. Argument is a " | 114 | N_("Add directories to the include search path. Argument is a " |
104 | "colon-separated list of directories."), | 115 | "colon-separated list of directories."), | ... | ... |
... | @@ -24,6 +24,7 @@ | ... | @@ -24,6 +24,7 @@ |
24 | 24 | ||
25 | mu_list_t mu_sieve_include_path = NULL; | 25 | mu_list_t mu_sieve_include_path = NULL; |
26 | mu_list_t mu_sieve_library_path = NULL; | 26 | mu_list_t mu_sieve_library_path = NULL; |
27 | mu_list_t mu_sieve_library_path_prefix = NULL; | ||
27 | 28 | ||
28 | static int | 29 | static int |
29 | _path_append (void *item, void *data) | 30 | _path_append (void *item, void *data) |
... | @@ -54,10 +55,15 @@ mu_sieve_module_init (enum mu_gocs_op op, void *data) | ... | @@ -54,10 +55,15 @@ mu_sieve_module_init (enum mu_gocs_op op, void *data) |
54 | mu_list_destroy (&mu_sieve_include_path); | 55 | mu_list_destroy (&mu_sieve_include_path); |
55 | mu_list_do (p->include_path, _path_append, &mu_sieve_include_path); | 56 | mu_list_do (p->include_path, _path_append, &mu_sieve_include_path); |
56 | if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH) | 57 | if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH) |
58 | { | ||
57 | mu_list_destroy (&mu_sieve_library_path); | 59 | mu_list_destroy (&mu_sieve_library_path); |
60 | mu_list_destroy (&mu_sieve_library_path_prefix); | ||
61 | } | ||
62 | mu_list_do (p->library_path_prefix, _path_append, | ||
63 | &mu_sieve_library_path_prefix); | ||
58 | mu_list_do (p->library_path, _path_append, &mu_sieve_library_path); | 64 | mu_list_do (p->library_path, _path_append, &mu_sieve_library_path); |
59 | mu_sv_load_add_path (mu_sieve_library_path); | ||
60 | mu_list_destroy (&p->library_path); | 65 | mu_list_destroy (&p->library_path); |
66 | mu_list_destroy (&p->library_path_prefix); | ||
61 | mu_list_destroy (&p->include_path); | 67 | mu_list_destroy (&p->include_path); |
62 | return 0; | 68 | return 0; |
63 | } | 69 | } | ... | ... |
... | @@ -52,10 +52,12 @@ sieve_init_load_path () | ... | @@ -52,10 +52,12 @@ sieve_init_load_path () |
52 | { | 52 | { |
53 | if (lt_dlinit ()) | 53 | if (lt_dlinit ()) |
54 | return 1; | 54 | return 1; |
55 | mu_list_do (mu_sieve_library_path_prefix, _add_load_dir, NULL); | ||
55 | #ifdef MU_SIEVE_MODDIR | 56 | #ifdef MU_SIEVE_MODDIR |
56 | _add_load_dir (MU_SIEVE_MODDIR, NULL); | 57 | _add_load_dir (MU_SIEVE_MODDIR, NULL); |
57 | inited = 1; | ||
58 | #endif | 58 | #endif |
59 | mu_list_do (mu_sieve_library_path, _add_load_dir, NULL); | ||
60 | inited = 1; | ||
59 | } | 61 | } |
60 | return 0; | 62 | return 0; |
61 | } | 63 | } |
... | @@ -134,14 +136,6 @@ _add_load_dir (void *item, void *unused) | ... | @@ -134,14 +136,6 @@ _add_load_dir (void *item, void *unused) |
134 | } | 136 | } |
135 | 137 | ||
136 | int | 138 | int |
137 | mu_sv_load_add_path (mu_list_t path) | ||
138 | { | ||
139 | if (sieve_init_load_path ()) | ||
140 | return 1; | ||
141 | return mu_list_do (path, _add_load_dir, NULL); | ||
142 | } | ||
143 | |||
144 | int | ||
145 | mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name) | 139 | mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name) |
146 | { | 140 | { |
147 | if (sieve_init_load_path ()) | 141 | if (sieve_init_load_path ()) |
... | @@ -161,12 +155,6 @@ mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name) | ... | @@ -161,12 +155,6 @@ mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name) |
161 | } | 155 | } |
162 | 156 | ||
163 | int | 157 | int |
164 | mu_sv_load_add_path (mu_list_t path) | ||
165 | { | ||
166 | return 1; | ||
167 | } | ||
168 | |||
169 | int | ||
170 | mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name) | 158 | mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name) |
171 | { | 159 | { |
172 | return 1; | 160 | return 1; | ... | ... |
... | @@ -125,5 +125,5 @@ void _mu_sv_instr_nop (mu_sieve_machine_t mach); | ... | @@ -125,5 +125,5 @@ void _mu_sv_instr_nop (mu_sieve_machine_t mach); |
125 | void _mu_sv_instr_source (mu_sieve_machine_t mach); | 125 | void _mu_sv_instr_source (mu_sieve_machine_t mach); |
126 | void _mu_sv_instr_line (mu_sieve_machine_t mach); | 126 | void _mu_sv_instr_line (mu_sieve_machine_t mach); |
127 | 127 | ||
128 | int mu_sv_load_add_path (mu_list_t path); | ||
129 | int mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name); | 128 | int mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name); |
129 | ... | ... |
... | @@ -397,18 +397,11 @@ sieve_include () | ... | @@ -397,18 +397,11 @@ sieve_include () |
397 | static void | 397 | static void |
398 | sieve_searchpath () | 398 | sieve_searchpath () |
399 | { | 399 | { |
400 | int append = 0; | ||
401 | char *p, *endp = yytext + yyleng, *name; | 400 | char *p, *endp = yytext + yyleng, *name; |
402 | 401 | ||
403 | p = strstr (yytext, "searchpath"); | 402 | p = strstr (yytext, "searchpath"); |
404 | for (p += 10; p < endp && mu_isspace (*p); p++) | 403 | for (p += 10; p < endp && mu_isspace (*p); p++) |
405 | ; | 404 | ; |
406 | if (strcmp (p, "add") == 0) | ||
407 | { | ||
408 | append = 1; | ||
409 | for (p += 3; p < endp && mu_isspace (*p); p++) | ||
410 | ; | ||
411 | } | ||
412 | name = get_file_name (p, endp, NULL); | 405 | name = get_file_name (p, endp, NULL); |
413 | if (name) | 406 | if (name) |
414 | { | 407 | { | ... | ... |
... | @@ -50,8 +50,7 @@ chmod +w mailbox | ... | @@ -50,8 +50,7 @@ chmod +w mailbox |
50 | 50 | ||
51 | MTA_DIAG=`pwd`/mta.diag | 51 | MTA_DIAG=`pwd`/mta.diag |
52 | export MTA_DIAG | 52 | export MTA_DIAG |
53 | sieve MUT_SIEVE_CMDLINE dnl | 53 | sieve MUT_SIEVE_CMDLINE MUT_SIEVE_OPTIONS -f ./mailbox prog || exit 1 |
54 | --clearpath -L "${abs_top_builddir}/libmu_sieve/extensions" -f ./mailbox prog || exit 1 | ||
55 | cat ./mta.diag | 54 | cat ./mta.diag |
56 | ], | 55 | ], |
57 | [ENVELOPE FROM: sergiusz@example.org | 56 | [ENVELOPE FROM: sergiusz@example.org |
... | @@ -76,8 +75,7 @@ chmod +w mailbox | ... | @@ -76,8 +75,7 @@ chmod +w mailbox |
76 | 75 | ||
77 | MTA_DIAG=`pwd`/mta.diag | 76 | MTA_DIAG=`pwd`/mta.diag |
78 | export MTA_DIAG | 77 | export MTA_DIAG |
79 | sieve MUT_SIEVE_CMDLINE dnl | 78 | sieve MUT_SIEVE_CMDLINE MUT_SIEVE_OPTIONS -f ./mailbox prog || exit $? |
80 | --clearpath -L "${abs_top_builddir}/libmu_sieve/extensions" -f ./mailbox prog || exit $? | ||
81 | test -f ./mta.diag && echo ./mta.diag | 79 | test -f ./mta.diag && echo ./mta.diag |
82 | exit 0 | 80 | exit 0 |
83 | ], | 81 | ], | ... | ... |
... | @@ -88,7 +88,7 @@ m4_define([MUT_SIEVE_EXT_TEST],[ | ... | @@ -88,7 +88,7 @@ m4_define([MUT_SIEVE_EXT_TEST],[ |
88 | AT_SETUP(MUT_SIEVE_EXT_NAME[: $1]) | 88 | AT_SETUP(MUT_SIEVE_EXT_NAME[: $1]) |
89 | AT_KEYWORDS([MUT_SIEVE_EXT_NAME $2]) | 89 | AT_KEYWORDS([MUT_SIEVE_EXT_NAME $2]) |
90 | m4_pushdef([MUT_SIEVE_OPTIONS], | 90 | m4_pushdef([MUT_SIEVE_OPTIONS], |
91 | [--clearpath -L "${abs_top_builddir}/libmu_sieve/extensions"]) | 91 | [--libdir-prefix "${abs_top_builddir}/libmu_sieve/extensions"]) |
92 | AT_CHECK([ | 92 | AT_CHECK([ |
93 | MUT_PREREQ_CAPA([HAVE_LIBLTDL]) | 93 | MUT_PREREQ_CAPA([HAVE_LIBLTDL]) |
94 | cwd=`pwd` | 94 | cwd=`pwd` | ... | ... |
-
Please register or sign in to post a comment