69 if (!rcfile_path || !pc || !pe)
74 int lineno = 0, rc = 0, warnings = 0;
76 struct Buffer *linebuf = NULL;
78 char *currentline = NULL;
89 bool ispipe = rcfile[rcfilelen - 1] ==
'|';
96 mutt_error(
_(
"Error: Can't build path of '%s'"), rcfile_path);
109 mutt_error(
_(
"Error: Cyclic sourcing of configuration file '%s'"), rcfile);
121 buf_printf(err,
"%s: %s", rcfile, strerror(errno));
131 const bool conv = c_config_charset && c_charset;
181 if (ispipe && (pid != -1))
186 mutt_error(
_(
"Command '%s' exited with status %d"), rcfile, status);
196 buf_printf(err, (rc >= -
MAX_ERRS) ?
_(
"source: errors in %s") :
_(
"source: reading aborted due to too many errors in %s"),
205 buf_printf(err, ngettext(
"source: %d warning in %s",
"source: %d warnings in %s", warnings),
290 if (!line || !cwd || !pc || !pe)
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
CommandResult
Error codes for command_t parse functions.
@ MUTT_CMD_SUCCESS
Success: Command worked.
@ MUTT_CMD_ERROR
Error: Can't help the user.
@ MUTT_CMD_WARNING
Warning: Help given to the user.
@ MUTT_CMD_FINISH
Finish: Stop processing this file.
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
Convenience wrapper for the config headers.
const char * cc_charset(void)
Get the cached value of $charset.
Convenience wrapper for the core headers.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
#define MUTT_RL_CONT
-continuation
#define mutt_file_fclose(FP)
enum CommandResult parse_source(const struct Command *cmd, struct Buffer *line, const struct ParseContext *pc, struct ParseError *pe)
Parse the 'source' command - Implements Command::parse() -.
#define mutt_warning(...)
#define mutt_debug(LEVEL,...)
struct ListNode * mutt_list_insert_head(struct ListHead *h, char *s)
Insert a string at the beginning of a List.
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
@ LL_DEBUG2
Log at debug level 2.
#define FREE(x)
Free memory and set the pointer to NULL.
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
#define MUTT_ICONV_NO_FLAGS
No flags are set.
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Convenience wrapper for the library headers.
bool mutt_path_to_absolute(char *path, const char *reference)
Convert a relative path to its absolute form.
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
void expand_path(struct Buffer *buf, bool regex)
Create the canonical path.
FILE * mutt_open_read(const char *path, pid_t *thepid)
Run a command to read from.
Some miscellaneous functions.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define STAILQ_REMOVE_HEAD(head, field)
#define STAILQ_HEAD_INITIALIZER(head)
#define STAILQ_FIRST(head)
#define STAILQ_FOREACH(var, head, field)
#define STAILQ_EMPTY(head)
enum CommandResult parse_rc_line(struct Buffer *line, struct ParseContext *pc, struct ParseError *pe)
Parse a line of user config.
enum CommandResult parse_rc_line_cwd(const char *line, char *cwd, struct ParseContext *pc, struct ParseError *pe)
Parse and run a muttrc line in a relative directory.
void source_stack_cleanup(void)
Free memory from the stack used for the source command.
static struct ListHead MuttrcStack
LIFO designed to contain the list of config files that have been sourced and avoid cyclic sourcing.
int source_rc(const char *rcfile_path, struct ParseContext *pc, struct ParseError *pe)
Read an initialization file.
char * mutt_get_sourced_cwd(void)
Get the current file path that is being parsed.
String manipulation buffer.
char * dptr
Current read/write position.
const char * name
Name of the Command.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
Context for config parsing (history/backtrace)
Detailed error information from config parsing.
struct Buffer * message
Error message.