NeoMutt  2025-12-11-79-gf03987
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
dump.c
Go to the documentation of this file.
1
30
36
37#include "config.h"
38#include <stdio.h>
39#include "mutt/lib.h"
40#include "config/lib.h"
41#include "core/lib.h"
42#include "dump.h"
43#include "pager/lib.h"
44
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
CommandResult
Error codes for command_t parse functions.
Definition command.h:35
@ 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
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
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
Convenience wrapper for the library headers.
#define _(a)
Definition message.h:28
GUI display a file/email/help in a viewport with paging.
#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
enum CommandResult set_dump(enum GetElemListFlags flags, struct Buffer *err)
Dump list of config variables into a file/pager.
Definition dump.c:54
Functions to parse commands in a config file.
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
GetElemListFlags
Flags for get_elem_list()
Definition subset.h:80
#define buf_mktemp(buf)
Definition tmp.h:33