Commit 11557b86 11557b860143069f31cbd5adcb2e7f21a8670bae by Sergey Poznyakoff

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.
1 parent cff44776
GNU mailutils TODO list. 2010-12-19
GNU mailutils TODO list. 2010-12-21
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 Free
Software Foundation, Inc.
......@@ -42,9 +42,7 @@ See frm/common.c (near line 425).
See guimb/scm/Makefile.am for a discussion.
* sieve: needs an option to add directory at the head of the search path
* sieve: extension tests
* sieve: extension tests [in progress]
* mu_address_createv: pass hints as in mu_address_create_hint?
......
......@@ -122,6 +122,7 @@ typedef struct
extern int mu_sieve_yydebug;
extern mu_list_t mu_sieve_include_path;
extern mu_list_t mu_sieve_library_path;
extern mu_list_t mu_sieve_library_path_prefix;
/* Memory allocation functions */
void *mu_sieve_alloc (size_t size);
......@@ -258,7 +259,9 @@ int mu_sieve_disass (mu_sieve_machine_t mach);
struct mu_gocs_sieve
{
int clearflags;
/* mu_list_t include_path_prefix;*/
mu_list_t include_path;
mu_list_t library_path_prefix;
mu_list_t library_path;
};
......
......@@ -24,7 +24,8 @@
enum {
OPT_CLEAR_INCLUDE_PATH = 256,
OPT_CLEAR_LIBRARY_PATH
OPT_CLEAR_LIBRARY_PATH,
OPT_PREFIX_LIBRARY_PATH
};
static struct argp_option sieve_argp_option[] = {
......@@ -32,6 +33,9 @@ static struct argp_option sieve_argp_option[] = {
N_("append DIR to the list of directories searched for include files"), 0 },
{ "libdir", 'L', N_("DIR"), 0,
N_("append DIR to the list of directories searched for library files"), 0 },
{ "libdir-prefix", OPT_PREFIX_LIBRARY_PATH, N_("DIR"), 0,
N_("add DIR to the beginning of the list of directories searched for "
"library files"), 0 },
{ "clear-include-path", OPT_CLEAR_INCLUDE_PATH, NULL, 0,
N_("clear Sieve include path"), 0 },
{ "clear-library-path", OPT_CLEAR_LIBRARY_PATH, NULL, 0,
......@@ -55,6 +59,10 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state)
mu_argp_node_list_new (lst, "library-path", arg);
break;
case OPT_PREFIX_LIBRARY_PATH:
mu_argp_node_list_new (lst, "library-path-prefix", arg);
break;
case OPT_CLEAR_INCLUDE_PATH:
mu_argp_node_list_new (lst, "clear-include-path", "yes");
break;
......
......@@ -90,6 +90,13 @@ cb_library_path (void *data, mu_config_value_t *val)
&sieve_settings.library_path);
}
static int
cb_library_path_prefix (void *data, mu_config_value_t *val)
{
return mu_cfg_string_value_cb (val, _add_path,
&sieve_settings.library_path_prefix);
}
static struct mu_cfg_param mu_sieve_param[] = {
{ "clear-library-path", mu_cfg_callback, NULL, 0, cb_clear_library_path,
N_("Clear library search path.") },
......@@ -99,6 +106,10 @@ static struct mu_cfg_param mu_sieve_param[] = {
N_("Add directories to the library search path. Argument is a "
"colon-separated list of directories."),
N_("list") },
{ "library-path-prefix", mu_cfg_callback, NULL, 0, cb_library_path_prefix,
N_("Add directories to the beginning of the library search path. "
"Argument is a colon-separated list of directories."),
N_("list") },
{ "include-path", mu_cfg_callback, NULL, 0, cb_include_path,
N_("Add directories to the include search path. Argument is a "
"colon-separated list of directories."),
......
......@@ -24,6 +24,7 @@
mu_list_t mu_sieve_include_path = NULL;
mu_list_t mu_sieve_library_path = NULL;
mu_list_t mu_sieve_library_path_prefix = NULL;
static int
_path_append (void *item, void *data)
......@@ -54,10 +55,15 @@ mu_sieve_module_init (enum mu_gocs_op op, void *data)
mu_list_destroy (&mu_sieve_include_path);
mu_list_do (p->include_path, _path_append, &mu_sieve_include_path);
if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH)
mu_list_destroy (&mu_sieve_library_path);
{
mu_list_destroy (&mu_sieve_library_path);
mu_list_destroy (&mu_sieve_library_path_prefix);
}
mu_list_do (p->library_path_prefix, _path_append,
&mu_sieve_library_path_prefix);
mu_list_do (p->library_path, _path_append, &mu_sieve_library_path);
mu_sv_load_add_path (mu_sieve_library_path);
mu_list_destroy (&p->library_path);
mu_list_destroy (&p->library_path_prefix);
mu_list_destroy (&p->include_path);
return 0;
}
......
......@@ -52,10 +52,12 @@ sieve_init_load_path ()
{
if (lt_dlinit ())
return 1;
mu_list_do (mu_sieve_library_path_prefix, _add_load_dir, NULL);
#ifdef MU_SIEVE_MODDIR
_add_load_dir (MU_SIEVE_MODDIR, NULL);
inited = 1;
#endif
mu_list_do (mu_sieve_library_path, _add_load_dir, NULL);
inited = 1;
}
return 0;
}
......@@ -134,14 +136,6 @@ _add_load_dir (void *item, void *unused)
}
int
mu_sv_load_add_path (mu_list_t path)
{
if (sieve_init_load_path ())
return 1;
return mu_list_do (path, _add_load_dir, NULL);
}
int
mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
{
if (sieve_init_load_path ())
......@@ -161,12 +155,6 @@ mu_sieve_load_ext (mu_sieve_machine_t mach, const char *name)
}
int
mu_sv_load_add_path (mu_list_t path)
{
return 1;
}
int
mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name)
{
return 1;
......
......@@ -125,5 +125,5 @@ void _mu_sv_instr_nop (mu_sieve_machine_t mach);
void _mu_sv_instr_source (mu_sieve_machine_t mach);
void _mu_sv_instr_line (mu_sieve_machine_t mach);
int mu_sv_load_add_path (mu_list_t path);
int mu_sv_load_add_dir (mu_sieve_machine_t mach, const char *name);
......
......@@ -397,18 +397,11 @@ sieve_include ()
static void
sieve_searchpath ()
{
int append = 0;
char *p, *endp = yytext + yyleng, *name;
p = strstr (yytext, "searchpath");
for (p += 10; p < endp && mu_isspace (*p); p++)
;
if (strcmp (p, "add") == 0)
{
append = 1;
for (p += 3; p < endp && mu_isspace (*p); p++)
;
}
name = get_file_name (p, endp, NULL);
if (name)
{
......
......@@ -50,8 +50,7 @@ chmod +w mailbox
MTA_DIAG=`pwd`/mta.diag
export MTA_DIAG
sieve MUT_SIEVE_CMDLINE dnl
--clearpath -L "${abs_top_builddir}/libmu_sieve/extensions" -f ./mailbox prog || exit 1
sieve MUT_SIEVE_CMDLINE MUT_SIEVE_OPTIONS -f ./mailbox prog || exit 1
cat ./mta.diag
],
[ENVELOPE FROM: sergiusz@example.org
......@@ -76,8 +75,7 @@ chmod +w mailbox
MTA_DIAG=`pwd`/mta.diag
export MTA_DIAG
sieve MUT_SIEVE_CMDLINE dnl
--clearpath -L "${abs_top_builddir}/libmu_sieve/extensions" -f ./mailbox prog || exit $?
sieve MUT_SIEVE_CMDLINE MUT_SIEVE_OPTIONS -f ./mailbox prog || exit $?
test -f ./mta.diag && echo ./mta.diag
exit 0
],
......
......@@ -88,7 +88,7 @@ m4_define([MUT_SIEVE_EXT_TEST],[
AT_SETUP(MUT_SIEVE_EXT_NAME[: $1])
AT_KEYWORDS([MUT_SIEVE_EXT_NAME $2])
m4_pushdef([MUT_SIEVE_OPTIONS],
[--clearpath -L "${abs_top_builddir}/libmu_sieve/extensions"])
[--libdir-prefix "${abs_top_builddir}/libmu_sieve/extensions"])
AT_CHECK([
MUT_PREREQ_CAPA([HAVE_LIBLTDL])
cwd=`pwd`
......