Use IMAP-stile wildcards in folder matchers by default.
* imap4d/imap4d.h: Include mailutils/imaputil.h * imap4d/list.c: Use mu_folder_imap_match/mu_imap_wildmatch. * imap4d/lsub.c: Likewise. * imap4d/util.c (util_wcard_match): Move as to libmailutils as mu_imap_wildmatch. * include/mailutils/imaputil.h: New file. * include/mailutils/Makefile.am (pkginclude_HEADERS): Add imaputil.h * include/mailutils/folder.h (mu_folder_imap_match) (mu_folder_glob_match): New protos. * include/mailutils/imapio.h (mu_imap_flag_to_attribute) (mu_imap_format_flags): Move to imaputil.h * libmailutils/imapio/wildmatch.c: New file. * libmailutils/imapio/sendflg.c: New file. * libmailutils/imapio/Makefile.am (libimapio_la_SOURCES): Add sendflg.c and wildmatch.c. * libmailutils/imapio/flags.c (mu_imapio_send_flags): Move to sendflg.c * libmailutils/mailbox/folder.c (mu_folder_match): Rename to mu_folder_glob_match. (mu_folder_imap_match): New function. (mu_folder_create_from_record): Use mu_folder_imap_match as the default matcher. * libmailutils/tests/fsfolder.c: Start command line options with a dash. New option "-glob". All uses changed. * libproto/imap/select.c: Include imaputil.h * mu/imap.c: Likewise.
Showing
19 changed files
with
204 additions
and
108 deletions
... | @@ -106,6 +106,7 @@ | ... | @@ -106,6 +106,7 @@ |
106 | #include <mailutils/io.h> | 106 | #include <mailutils/io.h> |
107 | #include <mailutils/prog.h> | 107 | #include <mailutils/prog.h> |
108 | #include <mailutils/imapio.h> | 108 | #include <mailutils/imapio.h> |
109 | #include <mailutils/imaputil.h> | ||
109 | 110 | ||
110 | #include <mu_umaxtostr.h> | 111 | #include <mu_umaxtostr.h> |
111 | #include <muaux.h> | 112 | #include <muaux.h> | ... | ... |
... | @@ -19,12 +19,6 @@ | ... | @@ -19,12 +19,6 @@ |
19 | #include <dirent.h> | 19 | #include <dirent.h> |
20 | #include <pwd.h> | 20 | #include <pwd.h> |
21 | 21 | ||
22 | static int | ||
23 | imap4d_match (const char *name, void *pat, int flags) | ||
24 | { | ||
25 | return util_wcard_match (name, pat, "/"); | ||
26 | } | ||
27 | |||
28 | struct refinfo | 22 | struct refinfo |
29 | { | 23 | { |
30 | char *refptr; /* Original reference */ | 24 | char *refptr; /* Original reference */ |
... | @@ -243,7 +237,8 @@ imap4d_list (struct imap4d_command *command, imap4d_tokbuf_t tok) | ... | @@ -243,7 +237,8 @@ imap4d_list (struct imap4d_command *command, imap4d_tokbuf_t tok) |
243 | return io_completion_response (command, RESP_NO, | 237 | return io_completion_response (command, RESP_NO, |
244 | "The requested item could not be found."); | 238 | "The requested item could not be found."); |
245 | } | 239 | } |
246 | mu_folder_set_match (folder, imap4d_match); | 240 | /* Force the right matcher */ |
241 | mu_folder_set_match (folder, mu_folder_imap_match); | ||
247 | 242 | ||
248 | memset (&refinfo, 0, sizeof refinfo); | 243 | memset (&refinfo, 0, sizeof refinfo); |
249 | 244 | ||
... | @@ -260,8 +255,8 @@ imap4d_list (struct imap4d_command *command, imap4d_tokbuf_t tok) | ... | @@ -260,8 +255,8 @@ imap4d_list (struct imap4d_command *command, imap4d_tokbuf_t tok) |
260 | failure; it is not relevant whether the user's real INBOX resides | 255 | failure; it is not relevant whether the user's real INBOX resides |
261 | on this or some other server. */ | 256 | on this or some other server. */ |
262 | 257 | ||
263 | if (!*ref && (imap4d_match ("INBOX", wcard, 0) == 0 | 258 | if (!*ref && (mu_imap_wildmatch (wcard, "INBOX", delim[0]) == 0 |
264 | || imap4d_match ("inbox", wcard, 0) == 0)) | 259 | || mu_imap_wildmatch (wcard, "inbox", delim[0]) == 0)) |
265 | io_untagged_response (RESP_NONE, "LIST (\\NoInferiors) NIL INBOX"); | 260 | io_untagged_response (RESP_NONE, "LIST (\\NoInferiors) NIL INBOX"); |
266 | 261 | ||
267 | mu_folder_enumerate (folder, NULL, wcard, 0, 0, NULL, | 262 | mu_folder_enumerate (folder, NULL, wcard, 0, 0, NULL, | ... | ... |
... | @@ -64,7 +64,7 @@ imap4d_lsub (struct imap4d_command *command, imap4d_tokbuf_t tok) | ... | @@ -64,7 +64,7 @@ imap4d_lsub (struct imap4d_command *command, imap4d_tokbuf_t tok) |
64 | 64 | ||
65 | mu_iterator_current_kv (itr, (const void **)&name, (void**)&val); | 65 | mu_iterator_current_kv (itr, (const void **)&name, (void**)&val); |
66 | 66 | ||
67 | if (util_wcard_match (name, pattern, delim) == 0) | 67 | if (mu_imap_wildmatch (pattern, name, delim[0]) == 0) |
68 | io_untagged_response (RESP_NONE, "LSUB () \"%s\" \"%s\"", | 68 | io_untagged_response (RESP_NONE, "LSUB () \"%s\" \"%s\"", |
69 | delim, name); | 69 | delim, name); |
70 | } | 70 | } | ... | ... |
... | @@ -566,63 +566,6 @@ util_localname () | ... | @@ -566,63 +566,6 @@ util_localname () |
566 | return localname; | 566 | return localname; |
567 | } | 567 | } |
568 | 568 | ||
569 | /* Match STRING against the IMAP4 wildcard pattern PATTERN. */ | ||
570 | |||
571 | #define WILD_FALSE 0 | ||
572 | #define WILD_TRUE 1 | ||
573 | #define WILD_ABORT 2 | ||
574 | |||
575 | int | ||
576 | _wild_match (const char *expr, const char *name, char delim) | ||
577 | { | ||
578 | while (expr && *expr) | ||
579 | { | ||
580 | if (*name == 0 && *expr != '*') | ||
581 | return WILD_ABORT; | ||
582 | switch (*expr) | ||
583 | { | ||
584 | case '*': | ||
585 | while (*++expr == '*') | ||
586 | ; | ||
587 | if (*expr == 0) | ||
588 | return WILD_TRUE; | ||
589 | while (*name) | ||
590 | { | ||
591 | int res = _wild_match (expr, name++, delim); | ||
592 | if (res != WILD_FALSE) | ||
593 | return res; | ||
594 | } | ||
595 | return WILD_ABORT; | ||
596 | |||
597 | case '%': | ||
598 | while (*++expr == '%') | ||
599 | ; | ||
600 | if (*expr == 0) | ||
601 | return strchr (name, delim) ? WILD_FALSE : WILD_TRUE; | ||
602 | while (*name && *name != delim) | ||
603 | { | ||
604 | int res = _wild_match (expr, name++, delim); | ||
605 | if (res != WILD_FALSE) | ||
606 | return res; | ||
607 | } | ||
608 | return _wild_match (expr, name, delim); | ||
609 | |||
610 | default: | ||
611 | if (*expr != *name) | ||
612 | return WILD_FALSE; | ||
613 | expr++; | ||
614 | name++; | ||
615 | } | ||
616 | } | ||
617 | return *name == 0; | ||
618 | } | ||
619 | |||
620 | int | ||
621 | util_wcard_match (const char *name, const char *expr, const char *delim) | ||
622 | { | ||
623 | return _wild_match (expr, name, delim[0]) != WILD_TRUE; | ||
624 | } | ||
625 | |||
626 | /* Return the uindvalidity of a mailbox. | 569 | /* Return the uindvalidity of a mailbox. |
627 | When a mailbox is selected, whose first message does not keep X-UIDVALIDITY | 570 | When a mailbox is selected, whose first message does not keep X-UIDVALIDITY |
628 | value, the uidvalidity is computed basing on the return of time(). Now, | 571 | value, the uidvalidity is computed basing on the return of time(). Now, | ... | ... |
... | @@ -72,6 +72,12 @@ extern int mu_folder_set_stream (mu_folder_t, mu_stream_t); | ... | @@ -72,6 +72,12 @@ extern int mu_folder_set_stream (mu_folder_t, mu_stream_t); |
72 | extern int mu_folder_set_match (mu_folder_t folder, mu_folder_match_fp pmatch); | 72 | extern int mu_folder_set_match (mu_folder_t folder, mu_folder_match_fp pmatch); |
73 | extern int mu_folder_get_match (mu_folder_t folder, | 73 | extern int mu_folder_get_match (mu_folder_t folder, |
74 | mu_folder_match_fp *pmatch); | 74 | mu_folder_match_fp *pmatch); |
75 | |||
76 | /* Two often used matchers: */ | ||
77 | /* 1. The default: IMAP-style wildcards: */ | ||
78 | extern int mu_folder_imap_match (const char *name, void *pattern, int flags); | ||
79 | /* 2. UNIX-style glob(7) wildcards: */ | ||
80 | extern int mu_folder_glob_match (const char *name, void *pattern, int flags); | ||
75 | 81 | ||
76 | /* Notifications. */ | 82 | /* Notifications. */ |
77 | extern int mu_folder_get_observable (mu_folder_t, mu_observable_t *); | 83 | extern int mu_folder_get_observable (mu_folder_t, mu_observable_t *); | ... | ... |
... | @@ -72,9 +72,6 @@ int mu_imapio_reply_string (mu_imapio_t io, size_t start, char **pbuf); | ... | @@ -72,9 +72,6 @@ int mu_imapio_reply_string (mu_imapio_t io, size_t start, char **pbuf); |
72 | int mu_imapio_last_error (mu_imapio_t io); | 72 | int mu_imapio_last_error (mu_imapio_t io); |
73 | void mu_imapio_clearerr (mu_imapio_t io); | 73 | void mu_imapio_clearerr (mu_imapio_t io); |
74 | 74 | ||
75 | int mu_imap_flag_to_attribute (const char *item, int *attr); | ||
76 | int mu_imap_format_flags (mu_stream_t str, int flags); | ||
77 | |||
78 | #ifdef __cplusplus | 75 | #ifdef __cplusplus |
79 | } | 76 | } |
80 | #endif | 77 | #endif | ... | ... |
include/mailutils/imaputil.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | GNU Mailutils 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 General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #ifndef _MAILUTILS_IMAPUTIL_H | ||
18 | # define _MAILUTILS_IMAPUTIL_H | ||
19 | |||
20 | #ifdef __cplusplus | ||
21 | extern "C" { | ||
22 | #endif | ||
23 | |||
24 | # include <mailutils/types.h> | ||
25 | |||
26 | int mu_imap_wildmatch (const char *pattern, const char *name, int delim); | ||
27 | |||
28 | int mu_imap_flag_to_attribute (const char *item, int *attr); | ||
29 | int mu_imap_format_flags (mu_stream_t str, int flags); | ||
30 | |||
31 | #ifdef __cplusplus | ||
32 | } | ||
33 | #endif | ||
34 | |||
35 | #endif /* _MAILUTILS_IMAPUTIL_H */ |
... | @@ -31,9 +31,11 @@ libimapio_la_SOURCES = \ | ... | @@ -31,9 +31,11 @@ libimapio_la_SOURCES = \ |
31 | sendcmd.c\ | 31 | sendcmd.c\ |
32 | sendcmdv.c\ | 32 | sendcmdv.c\ |
33 | sendcmde.c\ | 33 | sendcmde.c\ |
34 | sendflg.c\ | ||
34 | time.c\ | 35 | time.c\ |
35 | trace.c\ | 36 | trace.c\ |
36 | transport.c\ | 37 | transport.c\ |
38 | wildmatch.c\ | ||
37 | words.c\ | 39 | words.c\ |
38 | xscript.c | 40 | xscript.c |
39 | 41 | ... | ... |
... | @@ -21,7 +21,7 @@ | ... | @@ -21,7 +21,7 @@ |
21 | #include <mailutils/stream.h> | 21 | #include <mailutils/stream.h> |
22 | #include <mailutils/errno.h> | 22 | #include <mailutils/errno.h> |
23 | #include <mailutils/cstr.h> | 23 | #include <mailutils/cstr.h> |
24 | #include <mailutils/sys/imapio.h> | 24 | #include <mailutils/imaputil.h> |
25 | 25 | ||
26 | static struct | 26 | static struct |
27 | { | 27 | { |
... | @@ -84,16 +84,3 @@ mu_imap_format_flags (mu_stream_t str, int flags) | ... | @@ -84,16 +84,3 @@ mu_imap_format_flags (mu_stream_t str, int flags) |
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | 86 | ||
87 | int | ||
88 | mu_imapio_send_flags (struct _mu_imapio *io, int flags) | ||
89 | { | ||
90 | int rc; | ||
91 | |||
92 | rc = mu_stream_write (io->_imap_stream, "(", 1, NULL); | ||
93 | if (rc) | ||
94 | return rc; | ||
95 | rc = mu_imap_format_flags (io->_imap_stream, flags); | ||
96 | if (rc == 0) | ||
97 | rc = mu_stream_write (io->_imap_stream, ")", 1, NULL); | ||
98 | return rc; | ||
99 | } | ... | ... |
libmailutils/imapio/sendflg.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | GNU Mailutils 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 General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #include <config.h> | ||
18 | #include <mailutils/types.h> | ||
19 | #include <mailutils/imapio.h> | ||
20 | #include <mailutils/stream.h> | ||
21 | #include <mailutils/imaputil.h> | ||
22 | #include <mailutils/sys/imapio.h> | ||
23 | |||
24 | int | ||
25 | mu_imapio_send_flags (struct _mu_imapio *io, int flags) | ||
26 | { | ||
27 | int rc; | ||
28 | |||
29 | rc = mu_stream_write (io->_imap_stream, "(", 1, NULL); | ||
30 | if (rc) | ||
31 | return rc; | ||
32 | rc = mu_imap_format_flags (io->_imap_stream, flags); | ||
33 | if (rc == 0) | ||
34 | rc = mu_stream_write (io->_imap_stream, ")", 1, NULL); | ||
35 | return rc; | ||
36 | } |
libmailutils/imapio/wildmatch.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2011 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | GNU Mailutils 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 General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
17 | #include <config.h> | ||
18 | #include <string.h> | ||
19 | #include <mailutils/types.h> | ||
20 | #include <mailutils/imaputil.h> | ||
21 | |||
22 | /* Match STRING against the IMAP4 wildcard pattern PATTERN. */ | ||
23 | |||
24 | #define WILD_FALSE 0 | ||
25 | #define WILD_TRUE 1 | ||
26 | #define WILD_ABORT 2 | ||
27 | |||
28 | int | ||
29 | _wild_match (const char *pat, const char *name, char delim) | ||
30 | { | ||
31 | while (pat && *pat) | ||
32 | { | ||
33 | if (*name == 0 && *pat != '*') | ||
34 | return WILD_ABORT; | ||
35 | switch (*pat) | ||
36 | { | ||
37 | case '*': | ||
38 | while (*++pat == '*') | ||
39 | ; | ||
40 | if (*pat == 0) | ||
41 | return WILD_TRUE; | ||
42 | while (*name) | ||
43 | { | ||
44 | int res = _wild_match (pat, name++, delim); | ||
45 | if (res != WILD_FALSE) | ||
46 | return res; | ||
47 | } | ||
48 | return WILD_ABORT; | ||
49 | |||
50 | case '%': | ||
51 | while (*++pat == '%') | ||
52 | ; | ||
53 | if (*pat == 0) | ||
54 | return strchr (name, delim) ? WILD_FALSE : WILD_TRUE; | ||
55 | while (*name && *name != delim) | ||
56 | { | ||
57 | int res = _wild_match (pat, name++, delim); | ||
58 | if (res != WILD_FALSE) | ||
59 | return res; | ||
60 | } | ||
61 | return _wild_match (pat, name, delim); | ||
62 | |||
63 | default: | ||
64 | if (*pat != *name) | ||
65 | return WILD_FALSE; | ||
66 | pat++; | ||
67 | name++; | ||
68 | } | ||
69 | } | ||
70 | return *name == 0; | ||
71 | } | ||
72 | |||
73 | int | ||
74 | mu_imap_wildmatch (const char *pattern, const char *name, int delim) | ||
75 | { | ||
76 | return _wild_match (pattern, name, delim) != WILD_TRUE; | ||
77 | } | ||
78 |
... | @@ -37,6 +37,7 @@ | ... | @@ -37,6 +37,7 @@ |
37 | #include <mailutils/errno.h> | 37 | #include <mailutils/errno.h> |
38 | #include <mailutils/property.h> | 38 | #include <mailutils/property.h> |
39 | #include <mailutils/mailbox.h> | 39 | #include <mailutils/mailbox.h> |
40 | #include <mailutils/imaputil.h> | ||
40 | 41 | ||
41 | #include <mailutils/sys/folder.h> | 42 | #include <mailutils/sys/folder.h> |
42 | 43 | ||
... | @@ -48,11 +49,17 @@ static int is_known_folder (mu_url_t, mu_folder_t *); | ... | @@ -48,11 +49,17 @@ static int is_known_folder (mu_url_t, mu_folder_t *); |
48 | static struct mu_monitor folder_lock = MU_MONITOR_INITIALIZER; | 49 | static struct mu_monitor folder_lock = MU_MONITOR_INITIALIZER; |
49 | 50 | ||
50 | int | 51 | int |
51 | mu_folder_match (const char *name, void *pattern, int flags) | 52 | mu_folder_glob_match (const char *name, void *pattern, int flags) |
52 | { | 53 | { |
53 | return fnmatch (pattern, name[0] == '/' ? name + 1 : name, 0); | 54 | return fnmatch (pattern, name[0] == '/' ? name + 1 : name, 0); |
54 | } | 55 | } |
55 | 56 | ||
57 | int | ||
58 | mu_folder_imap_match (const char *name, void *pattern, int flags) | ||
59 | { | ||
60 | return mu_imap_wildmatch (pattern, name, '/'); | ||
61 | } | ||
62 | |||
56 | /* A folder could be remote (IMAP), or local(a spool directory) like $HOME/Mail | 63 | /* A folder could be remote (IMAP), or local(a spool directory) like $HOME/Mail |
57 | etc .. We maintain a list of known folders to avoid creating multiple | 64 | etc .. We maintain a list of known folders to avoid creating multiple |
58 | folders for the same URL. So, when mu_folder_create is called we check if | 65 | folders for the same URL. So, when mu_folder_create is called we check if |
... | @@ -126,7 +133,7 @@ mu_folder_create_from_record (mu_folder_t *pfolder, mu_url_t url, | ... | @@ -126,7 +133,7 @@ mu_folder_create_from_record (mu_folder_t *pfolder, mu_url_t url, |
126 | if (status == 0) | 133 | if (status == 0) |
127 | { | 134 | { |
128 | if (!folder->_match) | 135 | if (!folder->_match) |
129 | folder->_match = mu_folder_match; | 136 | folder->_match = mu_folder_imap_match; |
130 | *pfolder = folder; | 137 | *pfolder = folder; |
131 | folder->ref++; | 138 | folder->ref++; |
132 | /* Put on the internal list of known folders. */ | 139 | /* Put on the internal list of known folders. */ |
... | @@ -147,7 +154,7 @@ mu_folder_create_from_record (mu_folder_t *pfolder, mu_url_t url, | ... | @@ -147,7 +154,7 @@ mu_folder_create_from_record (mu_folder_t *pfolder, mu_url_t url, |
147 | } | 154 | } |
148 | } | 155 | } |
149 | 156 | ||
150 | return MU_ERR_NOENT; | 157 | return MU_ERR_NOENT; |
151 | } | 158 | } |
152 | 159 | ||
153 | int | 160 | int | ... | ... |
... | @@ -172,7 +172,7 @@ usage () | ... | @@ -172,7 +172,7 @@ usage () |
172 | struct command *cp; | 172 | struct command *cp; |
173 | 173 | ||
174 | mu_printf ( | 174 | mu_printf ( |
175 | "usage: %s [debug=SPEC] name=URL OP ARG [ARG...] [OP ARG [ARG...]...]\n", | 175 | "usage: %s [-debug=SPEC] -name=URL [-sort] [-glob] OP ARG [ARG...] [OP ARG [ARG...]...]\n", |
176 | mu_program_name); | 176 | mu_program_name); |
177 | mu_printf ("OPerations and corresponding ARGuments are:\n"); | 177 | mu_printf ("OPerations and corresponding ARGuments are:\n"); |
178 | for (cp = comtab; cp->verb; cp++) | 178 | for (cp = comtab; cp->verb; cp++) |
... | @@ -211,6 +211,7 @@ main (int argc, char **argv) | ... | @@ -211,6 +211,7 @@ main (int argc, char **argv) |
211 | int rc; | 211 | int rc; |
212 | mu_folder_t folder; | 212 | mu_folder_t folder; |
213 | char *fname = NULL; | 213 | char *fname = NULL; |
214 | int glob_option = 0; | ||
214 | 215 | ||
215 | mu_set_program_name (argv[0]); | 216 | mu_set_program_name (argv[0]); |
216 | mu_registrar_record (&test_record); | 217 | mu_registrar_record (&test_record); |
... | @@ -223,12 +224,14 @@ main (int argc, char **argv) | ... | @@ -223,12 +224,14 @@ main (int argc, char **argv) |
223 | 224 | ||
224 | for (i = 1; i < argc; i++) | 225 | for (i = 1; i < argc; i++) |
225 | { | 226 | { |
226 | if (strncmp (argv[i], "debug=", 6) == 0) | 227 | if (strncmp (argv[i], "-debug=", 7) == 0) |
227 | mu_debug_parse_spec (argv[i] + 6); | 228 | mu_debug_parse_spec (argv[i] + 7); |
228 | else if (strncmp (argv[i], "name=", 5) == 0) | 229 | else if (strncmp (argv[i], "-name=", 6) == 0) |
229 | fname = argv[i] + 5; | 230 | fname = argv[i] + 6; |
230 | else if (strcmp (argv[i], "sort") == 0) | 231 | else if (strcmp (argv[i], "-sort") == 0) |
231 | sort_option = 1; | 232 | sort_option = 1; |
233 | else if (strcmp (argv[i], "-glob") == 0) | ||
234 | glob_option = 1; | ||
232 | else | 235 | else |
233 | break; | 236 | break; |
234 | } | 237 | } |
... | @@ -261,6 +264,9 @@ main (int argc, char **argv) | ... | @@ -261,6 +264,9 @@ main (int argc, char **argv) |
261 | mu_diag_funcall (MU_DIAG_ERROR, "mu_folder_open", fname, rc); | 264 | mu_diag_funcall (MU_DIAG_ERROR, "mu_folder_open", fname, rc); |
262 | return 1; | 265 | return 1; |
263 | } | 266 | } |
267 | |||
268 | if (glob_option) | ||
269 | mu_folder_set_match (folder, mu_folder_glob_match); | ||
264 | 270 | ||
265 | while (i < argc) | 271 | while (i < argc) |
266 | { | 272 | { | ... | ... |
... | @@ -26,7 +26,7 @@ mkdir dir/subdir | ... | @@ -26,7 +26,7 @@ mkdir dir/subdir |
26 | > dir/subdir/file | 26 | > dir/subdir/file |
27 | > dir/subdir/baz.mbox | 27 | > dir/subdir/baz.mbox |
28 | 28 | ||
29 | fsfolder name=dir sort dnl | 29 | fsfolder -name=dir -sort dnl |
30 | list "" "*" dnl | 30 | list "" "*" dnl |
31 | list subdir "*" dnl | 31 | list subdir "*" dnl |
32 | list "" "*.mbox" dnl | 32 | list "" "*.mbox" dnl | ... | ... |
... | @@ -19,17 +19,17 @@ AT_KEYWORDS([fsfolder folder-subscribe]) | ... | @@ -19,17 +19,17 @@ AT_KEYWORDS([fsfolder folder-subscribe]) |
19 | 19 | ||
20 | AT_CHECK([ | 20 | AT_CHECK([ |
21 | mkdir dir | 21 | mkdir dir |
22 | fsfolder name=dir sort lsub "" "*" | 22 | fsfolder -name=dir -sort lsub "" "*" |
23 | fsfolder name=dir subscribe foo | 23 | fsfolder -name=dir subscribe foo |
24 | fsfolder name=dir sort lsub "" "*" | 24 | fsfolder -name=dir -sort lsub "" "*" |
25 | fsfolder name=dir subscribe baz subscribe foo/baz subscribe foo/bar | 25 | fsfolder -name=dir subscribe baz subscribe foo/baz subscribe foo/bar |
26 | fsfolder name=dir sort lsub "" "*" | 26 | fsfolder -name=dir -sort lsub "" "*" |
27 | fsfolder name=dir sort lsub foo "*" | 27 | fsfolder -name=dir -sort lsub foo "*" |
28 | fsfolder name=dir sort lsub "" 'foo*' | 28 | fsfolder -name=dir -sort lsub "" 'foo*' |
29 | fsfolder name=dir unsubscribe baz | 29 | fsfolder -name=dir unsubscribe baz |
30 | fsfolder name=dir sort lsub "" "*" | 30 | fsfolder -name=dir -sort lsub "" "*" |
31 | fsfolder name=dir unsubscribe foo | 31 | fsfolder -name=dir unsubscribe foo |
32 | fsfolder name=dir sort lsub "" "*" | 32 | fsfolder -name=dir -sort lsub "" "*" |
33 | ], | 33 | ], |
34 | [0], | 34 | [0], |
35 | [listing subscriptions for '' '*' | 35 | [listing subscriptions for '' '*' | ... | ... |
... | @@ -20,10 +20,10 @@ AT_KEYWORDS([fsfolder folder-rename]) | ... | @@ -20,10 +20,10 @@ AT_KEYWORDS([fsfolder folder-rename]) |
20 | AT_CHECK([ | 20 | AT_CHECK([ |
21 | mkdir dir | 21 | mkdir dir |
22 | > dir/foo | 22 | > dir/foo |
23 | fsfolder name=dir rename foo bar | 23 | fsfolder -name=dir rename foo bar |
24 | fsfolder name=dir list "" "*" | 24 | fsfolder -name=dir list "" "*" |
25 | > dir/baz | 25 | > dir/baz |
26 | fsfolder name=dir rename bar baz | 26 | fsfolder -name=dir rename bar baz |
27 | ], | 27 | ], |
28 | [0], | 28 | [0], |
29 | [renaming foo to bar | 29 | [renaming foo to bar | ... | ... |
... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
25 | #include <mailutils/assoc.h> | 25 | #include <mailutils/assoc.h> |
26 | #include <mailutils/stream.h> | 26 | #include <mailutils/stream.h> |
27 | #include <mailutils/imap.h> | 27 | #include <mailutils/imap.h> |
28 | #include <mailutils/imaputil.h> | ||
28 | #include <mailutils/sys/imap.h> | 29 | #include <mailutils/sys/imap.h> |
29 | 30 | ||
30 | static int | 31 | static int | ... | ... |
... | @@ -26,6 +26,7 @@ | ... | @@ -26,6 +26,7 @@ |
26 | #include <mailutils/mailutils.h> | 26 | #include <mailutils/mailutils.h> |
27 | #include <mailutils/imap.h> | 27 | #include <mailutils/imap.h> |
28 | #include <mailutils/imapio.h> | 28 | #include <mailutils/imapio.h> |
29 | #include <mailutils/imaputil.h> | ||
29 | #include "mu.h" | 30 | #include "mu.h" |
30 | #include "argp.h" | 31 | #include "argp.h" |
31 | #include "xalloc.h" | 32 | #include "xalloc.h" | ... | ... |
-
Please register or sign in to post a comment