summaryrefslogtreecommitdiff
path: root/libmailutils/tests/fsfolder.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-03-26 21:12:03 +0200
committerSergey Poznyakoff <gray@gnu.org>2019-03-26 21:12:03 +0200
commit5b69ce81ec29afeea0e67bd8b0f0b193a7b0c022 (patch)
tree8e4579dde855742117781426ea92ab08bf0b6432 /libmailutils/tests/fsfolder.c
parent7a1b9263d79005cd66ed7ebdd8b8e2842e7cd6b3 (diff)
downloadmailutils-5b69ce81ec29afeea0e67bd8b0f0b193a7b0c022.tar.gz
mailutils-5b69ce81ec29afeea0e67bd8b0f0b193a7b0c022.tar.bz2
Implement selection of requested mailbox formats in scanning the local file system folders.
* include/mailutils/registrar.h (mu_record_match): New struct. (mu_registrar_match_records): New proto. * libmailutils/base/registrar.c (mu_registrar_match_records): New function. * libmailutils/mailbox/fsfolder.c (list_helper): Actually select the matching record from scn->records (if supplied). * libmailutils/tests/Makefile.am: Add new tests. * libmailutils/tests/fsfolder.c: Minor changes. * libmailutils/tests/testsuite.at: Add new tests. * libmailutils/tests/fsfolder03.at: New file. * libmailutils/tests/fsfolder04.at: New file.
Diffstat (limited to 'libmailutils/tests/fsfolder.c')
-rw-r--r--libmailutils/tests/fsfolder.c38
1 files changed, 10 insertions, 28 deletions
diff --git a/libmailutils/tests/fsfolder.c b/libmailutils/tests/fsfolder.c
index 8c2579838..5a4d9df7d 100644
--- a/libmailutils/tests/fsfolder.c
+++ b/libmailutils/tests/fsfolder.c
@@ -152,28 +152,6 @@ com_unsubscribe (int argc, char **argv, mu_assoc_t options, void *env)
return 0;
}
-static mu_record_t
-find_record (char const *scheme)
-{
- mu_iterator_t itr;
- mu_record_t result = NULL;
-
- MU_ASSERT (mu_registrar_get_iterator (&itr));
- for (mu_iterator_first (itr); !mu_iterator_is_done (itr);
- mu_iterator_next (itr))
- {
- mu_record_t rec;
- mu_iterator_current (itr, (void **)&rec);
- if (strcmp (rec->scheme, scheme) == 0)
- {
- result = rec;
- break;
- }
- }
- mu_iterator_destroy (&itr);
- return result;
-}
-
static int
com_scan (int argc, char **argv, mu_assoc_t options, void *env)
{
@@ -205,9 +183,9 @@ com_scan (int argc, char **argv, mu_assoc_t options, void *env)
if (mu_assoc_lookup (options, "type", &s) == 0)
{
- mu_record_t rec = find_record (s);
-
- if (rec)
+ mu_record_t rec;
+ rc = mu_registrar_lookup_scheme (s, &rec);
+ if (rc == 0)
{
if (!scn.records)
MU_ASSERT (mu_list_create (&scn.records));
@@ -215,7 +193,11 @@ com_scan (int argc, char **argv, mu_assoc_t options, void *env)
}
else
{
- mu_error ("%s: no such record found", s);
+ if (rc == MU_ERR_NOENT)
+ mu_error ("%s: no such record found", s);
+ else
+ mu_diag_funcall (MU_DIAG_ERROR, "mu_registrar_lookup_scheme",
+ NULL, rc);
mu_list_destroy (&scn.records);
return 0;
}
@@ -284,7 +266,7 @@ _always_is_scheme (mu_record_t record, mu_url_t url, int flags)
return res & flags;
}
-static struct _mu_record test_record =
+static struct _mu_record any_record =
{
10,
"any",
@@ -339,7 +321,7 @@ main (int argc, char **argv)
int glob_option = 0;
mu_tesh_init (argv[0]);
- mu_registrar_record (&test_record);
+ mu_registrar_record (&any_record);
mu_registrar_record (&reg_record);
if (argc == 1)

Return to:

Send suggestions and report system problems to the System administrator.