NeoMutt  2025-12-11-79-gf03987
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dump.c File Reference

Functions to parse commands in a config file. More...

#include "config.h"
#include <stdio.h>
#include "mutt/lib.h"
#include "config/lib.h"
#include "core/lib.h"
#include "dump.h"
#include "pager/lib.h"
+ Include dependency graph for dump.c:

Go to the source code of this file.

Functions

enum CommandResult set_dump (enum GetElemListFlags flags, struct Buffer *err)
 Dump list of config variables into a file/pager.
 

Detailed Description

Functions to parse commands in a config file.

Authors
  • Michael R. Elkins
  • g10 Code GmbH
  • Richard Russon
  • Aditya De Saha
  • Matthew Hughes
  • R Primus
  • Pietro Cerutti
  • Marco Sirabella
  • Dennis Schön

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file dump.c.

Function Documentation

◆ set_dump()

enum CommandResult set_dump ( enum GetElemListFlags flags,
struct Buffer * err )

Dump list of config variables into a file/pager.

Parameters
flagsWhich config to dump, e.g. GEL_CHANGED_CONFIG
errBuffer for error message
Returns
num See CommandResult

FIXME: Move me into parse/set.c. Note: this function currently depends on pager, which is the reason it is not included in the parse library.

Definition at line 54 of file dump.c.

55{
56 struct Buffer *tempfile = buf_pool_get();
57 buf_mktemp(tempfile);
58
59 FILE *fp_out = mutt_file_fopen(buf_string(tempfile), "w");
60 if (!fp_out)
61 {
62 // L10N: '%s' is the file name of the temporary file
63 buf_printf(err, _("Could not create temporary file %s"), buf_string(tempfile));
64 buf_pool_release(&tempfile);
65 return MUTT_CMD_ERROR;
66 }
67
68 struct ConfigSet *cs = NeoMutt->sub->cs;
69 struct HashElemArray hea = get_elem_list(cs, flags);
70 dump_config(cs, &hea, CS_DUMP_NO_FLAGS, fp_out);
71 ARRAY_FREE(&hea);
72
73 mutt_file_fclose(&fp_out);
74
75 struct PagerData pdata = { 0 };
76 struct PagerView pview = { &pdata };
77
78 pdata.fname = buf_string(tempfile);
79
80 pview.banner = "set";
82 pview.mode = PAGER_MODE_OTHER;
83
84 mutt_do_pager(&pview, NULL);
85 buf_pool_release(&tempfile);
86
87 return MUTT_CMD_SUCCESS;
88}
#define ARRAY_FREE(head)
Release all memory.
Definition array.h:204
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition buffer.c:161
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
@ MUTT_CMD_SUCCESS
Success: Command worked.
Definition command.h:38
@ MUTT_CMD_ERROR
Error: Can't help the user.
Definition command.h:36
bool dump_config(struct ConfigSet *cs, struct HashElemArray *hea, ConfigDumpFlags flags, FILE *fp)
Write all the config to a file.
Definition dump.c:199
#define CS_DUMP_NO_FLAGS
No flags are set.
Definition dump.h:36
int mutt_do_pager(struct PagerView *pview, struct Email *e)
Display some page-able text to the user (help or attachment)
Definition do_pager.c:122
#define mutt_file_fclose(FP)
Definition file.h:139
#define mutt_file_fopen(PATH, MODE)
Definition file.h:138
#define _(a)
Definition message.h:28
#define MUTT_PAGER_NO_FLAGS
No flags are set.
Definition lib.h:60
@ PAGER_MODE_OTHER
Pager is invoked via 3rd path. Non-email content is likely to be shown.
Definition lib.h:140
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:96
String manipulation buffer.
Definition buffer.h:36
Container for lots of config items.
Definition set.h:248
struct ConfigSet * cs
Parent ConfigSet.
Definition subset.h:50
Container for Accounts, Notifications.
Definition neomutt.h:43
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:47
Data to be displayed by PagerView.
Definition lib.h:159
const char * fname
Name of the file to read.
Definition lib.h:163
Paged view into some data.
Definition lib.h:170
struct PagerData * pdata
Data that pager displays. NOTNULL.
Definition lib.h:171
enum PagerMode mode
Pager mode.
Definition lib.h:172
PagerFlags flags
Additional settings to tweak pager's function.
Definition lib.h:173
const char * banner
Title to display in status bar.
Definition lib.h:174
struct HashElemArray get_elem_list(struct ConfigSet *cs, enum GetElemListFlags flags)
Create a sorted list of all config items.
Definition subset.c:81
#define buf_mktemp(buf)
Definition tmp.h:33
+ Here is the call graph for this function:
+ Here is the caller graph for this function: