Config/command parsing. More...
#include "config.h"
#include <ctype.h>
#include <pwd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <unistd.h>
#include "mutt/lib.h"
#include "address/lib.h"
#include "config/lib.h"
#include "email/lib.h"
#include "core/lib.h"
#include "alias/lib.h"
#include "conn/lib.h"
#include "gui/lib.h"
#include "mutt.h"
#include "init.h"
#include "color/lib.h"
#include "history/lib.h"
#include "index/lib.h"
#include "notmuch/lib.h"
#include "command_parse.h"
#include "functions.h"
#include "keymap.h"
#include "mutt_commands.h"
#include "mutt_globals.h"
#include "mutt_lua.h"
#include "menu/lib.h"
#include "muttlib.h"
#include "myvar.h"
#include "options.h"
#include "protos.h"
#include "sort.h"
#include "sidebar/lib.h"
#include "compmbox/lib.h"
#include "imap/lib.h"
Go to the source code of this file.
Functions | |
static void | matches_ensure_morespace (int current) |
Allocate more space for auto-completion. More... | |
static void | candidate (char *user, const char *src, char *dest, size_t dlen) |
Helper function for completion. More... | |
static int | complete_all_nm_tags (const char *pt) |
Pass a list of Notmuch tags to the completion code. More... | |
static int | execute_commands (struct ListHead *p) |
Execute a set of NeoMutt commands. More... | |
static char * | find_cfg (const char *home, const char *xdg_cfg_home) |
Find a config file. More... | |
static char * | getmailname (void) |
Try to retrieve the FQDN from mailname files. More... | |
static bool | get_hostname (struct ConfigSet *cs) |
Find the Fully-Qualified Domain Name. More... | |
int | mutt_extract_token (struct Buffer *dest, struct Buffer *tok, TokenFlags flags) |
Extract one token from a string. More... | |
void | mutt_opts_free (void) |
Clean up before quitting. More... | |
HookFlags | mutt_get_hook_type (const char *name) |
Find a hook by name. More... | |
int | mutt_init (struct ConfigSet *cs, bool skip_sys_rc, struct ListHead *commands) |
Initialise NeoMutt. More... | |
enum CommandResult | mutt_parse_rc_buffer (struct Buffer *line, struct Buffer *token, struct Buffer *err) |
Parse a line of user config. More... | |
enum CommandResult | mutt_parse_rc_line (const char *line, struct Buffer *err) |
Parse a line of user config. More... | |
int | mutt_query_variables (struct ListHead *queries, bool show_docs) |
Implement the -Q command line flag. More... | |
int | mutt_command_complete (char *buf, size_t buflen, int pos, int numtabs) |
Complete a command name. More... | |
int | mutt_label_complete (char *buf, size_t buflen, int numtabs) |
Complete a label name. More... | |
bool | mutt_nm_query_complete (char *buf, size_t buflen, int pos, int numtabs) |
Complete to the nearest notmuch tag. More... | |
bool | mutt_nm_tag_complete (char *buf, size_t buflen, int numtabs) |
Complete to the nearest notmuch tag. More... | |
int | mutt_var_value_complete (char *buf, size_t buflen, int pos) |
Complete a variable/value. More... | |
Variables | |
static char | UserTyped [1024] = { 0 } |
static int | NumMatched = 0 |
static char | Completed [256] = { 0 } |
static const char ** | Matches |
static int | MatchesListsize = 512 |
static char ** | nm_tags |
Config/command parsing.
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 init.c.
|
static |
Allocate more space for auto-completion.
current | Current allocation |
Definition at line 97 of file init.c.
|
static |
Helper function for completion.
user | User entered data for completion |
src | Candidate for completion |
dest | Completion result gets here |
dlen | Length of dest buffer |
Changes the dest buffer if necessary/possible to aid completion.
Definition at line 120 of file init.c.
|
static |
Pass a list of Notmuch tags to the completion code.
pt | List of all Notmuch tags |
0 | Success |
-1 | Error |
Definition at line 149 of file init.c.
|
static |
Execute a set of NeoMutt commands.
p | List of command strings |
0 | Success, all the commands succeeded |
-1 | Error |
Definition at line 207 of file init.c.
|
static |
|
static |
Try to retrieve the FQDN from mailname files.
ptr | Heap allocated string with the FQDN |
NULL | No valid mailname file could be read |
Definition at line 280 of file init.c.
|
static |
Find the Fully-Qualified Domain Name.
true | Success |
false | Error, failed to find any name |
Use several methods to try to find the Fully-Qualified domain name of this host. If the user has already configured a hostname, this function will use it.
Definition at line 312 of file init.c.
int mutt_extract_token | ( | struct Buffer * | dest, |
struct Buffer * | tok, | ||
TokenFlags | flags | ||
) |
Extract one token from a string.
dest | Buffer for the result |
tok | Buffer containing tokens |
flags | Flags, see TokenFlags |
0 | Success |
-1 | Error |
Definition at line 398 of file init.c.
void mutt_opts_free | ( | void | ) |
Clean up before quitting.
Definition at line 644 of file init.c.
HookFlags mutt_get_hook_type | ( | const char * | name | ) |
Find a hook by name.
name | Name to find |
num | Hook ID, e.g. MUTT_FOLDER_HOOK |
MUTT_HOOK_NO_FLAGS | Error, no matching hook |
Definition at line 698 of file init.c.
int mutt_init | ( | struct ConfigSet * | cs, |
bool | skip_sys_rc, | ||
struct ListHead * | commands | ||
) |
Initialise NeoMutt.
cs | Config Set |
skip_sys_rc | If true, don't read the system config file |
commands | List of config commands to execute |
0 | Success |
1 | Error |
Definition at line 720 of file init.c.
enum CommandResult mutt_parse_rc_buffer | ( | struct Buffer * | line, |
struct Buffer * | token, | ||
struct Buffer * | err | ||
) |
Parse a line of user config.
line | config line to read |
token | scratch buffer to be used by parser |
err | where to write error messages |
CommandResult | Result e.g. MUTT_CMD_SUCCESS |
The reason for token
is to avoid having to allocate and deallocate a lot of memory if we are parsing many lines. the caller can pass in the memory to use, which avoids having to create new space for every call to this function.
Definition at line 720 of file init.c.
enum CommandResult mutt_parse_rc_line | ( | const char * | line, |
struct Buffer * | err | ||
) |
Parse a line of user config.
line | Config line to read |
err | Where to write error messages |
CommandResult | Result e.g. MUTT_CMD_SUCCESS |
Definition at line 720 of file init.c.
int mutt_query_variables | ( | struct ListHead * | queries, |
bool | show_docs | ||
) |
Implement the -Q command line flag.
queries | List of query strings |
show_docs | If true, show one-liner docs for the config item |
0 | Success, all queries exist |
1 | Error |
Definition at line 1065 of file init.c.
int mutt_command_complete | ( | char * | buf, |
size_t | buflen, | ||
int | pos, | ||
int | numtabs | ||
) |
Complete a command name.
buf | Buffer for the result |
buflen | Length of the buffer |
pos | Cursor position in the buffer |
numtabs | Number of times the user has hit 'tab' |
1 | Success, a match |
0 | Error, no match |
Definition at line 1128 of file init.c.
int mutt_label_complete | ( | char * | buf, |
size_t | buflen, | ||
int | numtabs | ||
) |
Complete a label name.
buf | Buffer for the result |
buflen | Length of the buffer |
numtabs | Number of times the user has hit 'tab' |
1 | Success, a match |
0 | Error, no match |
Definition at line 1310 of file init.c.
bool mutt_nm_query_complete | ( | char * | buf, |
size_t | buflen, | ||
int | pos, | ||
int | numtabs | ||
) |
Complete to the nearest notmuch tag.
buf | Buffer for the result |
buflen | Length of the buffer |
pos | Cursor position in the buffer |
numtabs | Number of times the user has hit 'tab' |
true | Success, a match |
false | Error, no match |
Complete the nearest "tag:"-prefixed string previous to pos.
Definition at line 1375 of file init.c.
bool mutt_nm_tag_complete | ( | char * | buf, |
size_t | buflen, | ||
int | numtabs | ||
) |
Complete to the nearest notmuch tag.
buf | Buffer for the result |
buflen | Length of the buffer |
numtabs | Number of times the user has hit 'tab' |
true | Success, a match |
false | Error, no match |
Complete the nearest "+" or "-" -prefixed string previous to pos.
Definition at line 1432 of file init.c.
int mutt_var_value_complete | ( | char * | buf, |
size_t | buflen, | ||
int | pos | ||
) |