1 /**
2 * @file
3 * Sidebar commands
4 *
5 * @authors
6 * Copyright (C) 2020 Richard Russon <rich@flatcap.org>
7 *
8 * @copyright
9 * This program is free software: you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 2 of the License, or (at your option) any later
12 * version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 /**
24 * @page sidebar_commands Sidebar commands
25 *
26 * Sidebar commands
27 */
28
29 #include "config.h"
30 #include <stdint.h>
31 #include "private.h"
32 #include "mutt/lib.h"
33 #include "core/lib.h"
34 #include "mutt.h"
35 #include "lib.h"
36 #include "init.h"
37 #include "muttlib.h"
38
39 /**
40 * sb_parse_whitelist - Parse the 'sidebar_whitelist' command - Implements Command::parse() - @ingroup command_parse
41 */
sb_parse_whitelist(struct Buffer * buf,struct Buffer * s,intptr_t data,struct Buffer * err)42 enum CommandResult sb_parse_whitelist(struct Buffer *buf, struct Buffer *s,
43 intptr_t data, struct Buffer *err)
44 {
45 struct Buffer *path = mutt_buffer_pool_get();
46
47 do
48 {
49 mutt_extract_token(path, s, MUTT_TOKEN_BACKTICK_VARS);
50 mutt_buffer_expand_path(path);
51 add_to_stailq(&SidebarWhitelist, mutt_buffer_string(path));
52 } while (MoreArgs(s));
53 mutt_buffer_pool_release(&path);
54
55 return MUTT_CMD_SUCCESS;
56 }
57
58 /**
59 * sb_parse_unwhitelist - Parse the 'unsidebar_whitelist' command - Implements Command::parse() - @ingroup command_parse
60 */
sb_parse_unwhitelist(struct Buffer * buf,struct Buffer * s,intptr_t data,struct Buffer * err)61 enum CommandResult sb_parse_unwhitelist(struct Buffer *buf, struct Buffer *s,
62 intptr_t data, struct Buffer *err)
63 {
64 struct Buffer *path = mutt_buffer_pool_get();
65
66 do
67 {
68 mutt_extract_token(path, s, MUTT_TOKEN_BACKTICK_VARS);
69 /* Check for deletion of entire list */
70 if (mutt_str_equal(mutt_buffer_string(path), "*"))
71 {
72 mutt_list_free(&SidebarWhitelist);
73 break;
74 }
75 mutt_buffer_expand_path(path);
76 remove_from_stailq(&SidebarWhitelist, mutt_buffer_string(path));
77 } while (MoreArgs(s));
78 mutt_buffer_pool_release(&path);
79
80 return MUTT_CMD_SUCCESS;
81 }
82