Some miscellaneous functions. More...
#include "config.h"#include <errno.h>#include <limits.h>#include <pwd.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.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 "gui/lib.h"#include "mutt.h"#include "muttlib.h"#include "browser/lib.h"#include "editor/lib.h"#include "history/lib.h"#include "imap/lib.h"#include "ncrypt/lib.h"#include "question/lib.h"#include "globals.h"#include "hook.h"#include "mx.h"#include "protos.h"
Include dependency graph for muttlib.c:Go to the source code of this file.
Functions | |
| void | mutt_adv_mktemp (struct Buffer *buf) |
| Create a temporary file. | |
| void | buf_expand_path_regex (struct Buffer *buf, bool regex) |
| Create the canonical path (with regex char escaping) | |
| void | buf_expand_path (struct Buffer *buf) |
| Create the canonical path. | |
| char * | mutt_gecos_name (char *dest, size_t destlen, struct passwd *pw) |
| Lookup a user's real name in /etc/passwd. | |
| bool | mutt_needs_mailcap (struct Body *b) |
| Does this type need a mailcap entry do display. | |
| bool | mutt_is_text_part (const struct Body *b) |
| Is this part of an email in plain text? | |
| void | mutt_pretty_mailbox (char *buf, size_t buflen) |
| Shorten a mailbox path using '~' or '='. | |
| void | buf_pretty_mailbox (struct Buffer *buf) |
| Shorten a mailbox path using '~' or '='. | |
| int | mutt_check_overwrite (const char *attname, const char *path, struct Buffer *fname, enum SaveAttach *opt, char **directory) |
| Ask the user if overwriting is necessary. | |
| void | mutt_save_path (char *buf, size_t buflen, const struct Address *addr) |
| Turn an email address into a filename (for saving) | |
| void | buf_save_path (struct Buffer *dest, const struct Address *a) |
| Make a safe filename from an email address. | |
| void | mutt_safe_path (struct Buffer *dest, const struct Address *a) |
| Make a safe filename from an email address. | |
| FILE * | mutt_open_read (const char *path, pid_t *thepid) |
| Run a command to read from. | |
| int | mutt_save_confirm (const char *s, struct stat *st) |
| Ask the user to save. | |
| void | mutt_sleep (short s) |
| Sleep for a while. | |
| void | mutt_encode_path (struct Buffer *buf, const char *src) |
| Convert a path to 'us-ascii'. | |
| int | mutt_set_xdg_path (enum XdgType type, struct Buffer *buf) |
| Find an XDG path or its fallback. | |
| void | mutt_get_parent_path (const char *path, char *buf, size_t buflen) |
| Find the parent of a path (or mailbox) | |
| void | buf_sanitize_filename (struct Buffer *buf, const char *path, short slash) |
| Replace unsafe characters in a filename. | |
| int | mutt_str_pretty_size (struct Buffer *buf, size_t num) |
| Display an abbreviated size, like 3.4K. | |
| void | add_to_stailq (struct ListHead *head, const char *str) |
| Add a string to a list. | |
| void | remove_from_stailq (struct ListHead *head, const char *str) |
| Remove an item, matching a string, from a List. | |
| void | mutt_exit (int code) |
| Leave NeoMutt NOW. | |
Variables | |
| static const char * | XdgEnvVars [] |
| Accepted XDG environment variables. | |
| static const char * | XdgDefaults [] |
| XDG default locations. | |
Some miscellaneous functions.
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 muttlib.c.
| void mutt_adv_mktemp | ( | struct Buffer * | buf | ) |
Create a temporary file.
| buf | Buffer for the name |
Accept a "suggestion" for file name. If that file exists, then construct one with unique name but keep any extension. This might fail, I guess.
Definition at line 83 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void buf_expand_path_regex | ( | struct Buffer * | buf, |
| bool | regex ) |
Create the canonical path (with regex char escaping)
| buf | Buffer with path |
| regex | If true, escape any regex characters |
Definition at line 121 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void buf_expand_path | ( | struct Buffer * | buf | ) |
Create the canonical path.
| buf | Buffer with path |
Definition at line 314 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| char * mutt_gecos_name | ( | char * | dest, |
| size_t | destlen, | ||
| struct passwd * | pw ) |
Lookup a user's real name in /etc/passwd.
| dest | Buffer for the result |
| destlen | Length of buffer |
| pw | Passwd entry |
| ptr | Result buffer on success |
Extract the real name from /etc/passwd's GECOS field. When set, honor the regular expression in $gecos_mask, otherwise assume that the GECOS field is a comma-separated list. Replace "&" by a capitalized version of the user's login name.
Definition at line 331 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| bool mutt_needs_mailcap | ( | struct Body * | b | ) |
Does this type need a mailcap entry do display.
| b | Attachment body to be displayed |
| true | NeoMutt requires a mailcap entry to display |
| false | otherwise |
Definition at line 378 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| bool mutt_is_text_part | ( | const struct Body * | b | ) |
Is this part of an email in plain text?
| b | Part of an email |
| true | Part is in plain text |
Definition at line 406 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_pretty_mailbox | ( | char * | buf, |
| size_t | buflen ) |
Shorten a mailbox path using '~' or '='.
| buf | Buffer containing string to shorten |
| buflen | Length of buffer |
Collapse the pathname using ~ or = when possible
Definition at line 439 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void buf_pretty_mailbox | ( | struct Buffer * | buf | ) |
Shorten a mailbox path using '~' or '='.
Definition at line 518 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int mutt_check_overwrite | ( | const char * | attname, |
| const char * | path, | ||
| struct Buffer * | fname, | ||
| enum SaveAttach * | opt, | ||
| char ** | directory ) |
Ask the user if overwriting is necessary.
| [in] | attname | Attachment name |
| [in] | path | Path to save the file |
| [out] | fname | Buffer for filename |
| [out] | opt | Save option, see SaveAttach |
| [out] | directory | Directory to save under (OPTIONAL) |
| 0 | Success |
| -1 | Abort |
| 1 | Error |
Definition at line 540 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_save_path | ( | char * | buf, |
| size_t | buflen, | ||
| const struct Address * | addr ) |
Turn an email address into a filename (for saving)
If the user hasn't set $save_address the name will be truncated to the '@' character.
Definition at line 626 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:Make a safe filename from an email address.
Definition at line 651 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:Make a safe filename from an email address.
The filename will be stripped of '/', space, etc to make it safe.
Definition at line 681 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| FILE * mutt_open_read | ( | const char * | path, |
| pid_t * | thepid ) |
Run a command to read from.
| [in] | path | Path to command |
| [out] | thepid | PID of the command |
| ptr | File containing output of command |
This function allows the user to specify a command to read stdout from in place of a normal file. If the last character in the string is a pipe (|), then we assume it is a command to run instead of a normal file.
Definition at line 699 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int mutt_save_confirm | ( | const char * | s, |
| struct stat * | st ) |
Ask the user to save.
| s | Save location |
| st | Timestamp |
| 0 | OK to proceed |
| -1 | to abort |
| 1 | to retry |
Definition at line 744 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_sleep | ( | short | s | ) |
Sleep for a while.
| s | Number of seconds to sleep |
If the user config '$sleep_time' is larger, sleep that long instead.
Definition at line 841 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_encode_path | ( | struct Buffer * | buf, |
| const char * | src ) |
Convert a path to 'us-ascii'.
| buf | Buffer for the result |
| src | Path to convert (OPTIONAL) |
If src is NULL, the path in buf will be converted in-place.
Definition at line 857 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:Find an XDG path or its fallback.
| type | Type of XDG variable, e.g. XDG_CONFIG_HOME |
| buf | Buffer to save path |
| 1 | An entry was found that actually exists on disk and 0 otherwise |
Process an XDG environment variable or its fallback.
Definition at line 882 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_get_parent_path | ( | const char * | path, |
| char * | buf, | ||
| size_t | buflen ) |
Find the parent of a path (or mailbox)
| path | Path to use |
| buf | Buffer for the result |
| buflen | Length of buffer |
Definition at line 921 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void buf_sanitize_filename | ( | struct Buffer * | buf, |
| const char * | path, | ||
| short | slash ) |
Replace unsafe characters in a filename.
Definition at line 967 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| int mutt_str_pretty_size | ( | struct Buffer * | buf, |
| size_t | num ) |
Display an abbreviated size, like 3.4K.
| [out] | buf | Buffer for the result |
| [in] | num | Number to abbreviate |
| num | Bytes written to buf |
Definition at line 989 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void add_to_stailq | ( | struct ListHead * | head, |
| const char * | str ) |
Add a string to a list.
| head | String list |
| str | String to add |
Definition at line 1038 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void remove_from_stailq | ( | struct ListHead * | head, |
| const char * | str ) |
Remove an item, matching a string, from a List.
| head | Head of the List |
| str | String to match |
Definition at line 1063 of file muttlib.c.
Here is the call graph for this function:
Here is the caller graph for this function:| void mutt_exit | ( | int | code | ) |
Leave NeoMutt NOW.
| code | Value to return to the calling environment |
Definition at line 1089 of file muttlib.c.
Here is the call graph for this function:
|
static |
Accepted XDG environment variables.
|
static |
XDG default locations.