Some miscellaneous functions. More...
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <sys/types.h>
#include "attach/lib.h"
Go to the source code of this file.
Functions | |
void | mutt_adv_mktemp (struct Buffer *buf) |
Create a temporary file. | |
void | buf_expand_path (struct Buffer *buf) |
Create the canonical path. | |
void | buf_expand_path_regex (struct Buffer *buf, bool regex) |
Create the canonical path (with regex char escaping) | |
void | buf_pretty_mailbox (struct Buffer *s) |
Shorten a mailbox path using '~' or '='. | |
void | buf_sanitize_filename (struct Buffer *buf, const char *path, short slash) |
Replace unsafe characters in a filename. | |
void | buf_save_path (struct Buffer *dest, const struct Address *a) |
Make a safe filename from an email address. | |
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_encode_path (struct Buffer *buf, const char *src) |
Convert a path to 'us-ascii'. | |
char * | mutt_gecos_name (char *dest, size_t destlen, struct passwd *pw) |
Lookup a user's real name in /etc/passwd. | |
void | mutt_get_parent_path (const char *path, char *buf, size_t buflen) |
Find the parent of a path (or mailbox) | |
bool | mutt_is_text_part (const struct Body *b) |
Is this part of an email in plain text? | |
const char * | mutt_make_version (void) |
Generate the NeoMutt version string. | |
bool | mutt_needs_mailcap (struct Body *b) |
Does this type need a mailcap entry do display. | |
FILE * | mutt_open_read (const char *path, pid_t *thepid) |
Run a command to read from. | |
void | mutt_pretty_mailbox (char *buf, size_t buflen) |
Shorten a mailbox path using '~' or '='. | |
void | mutt_safe_path (struct Buffer *dest, const struct Address *a) |
Make a safe filename from an email address. | |
int | mutt_save_confirm (const char *s, struct stat *st) |
Ask the user to save. | |
void | mutt_save_path (char *d, size_t dsize, const struct Address *a) |
Turn an email address into a filename (for saving) | |
void | mutt_sleep (short s) |
Sleep for a while. | |
void | mutt_str_pretty_size (char *buf, size_t buflen, 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. | |
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.h.
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 84 of file muttlib.c.
void buf_expand_path | ( | struct Buffer * | buf | ) |
Create the canonical path.
buf | Buffer with path |
Definition at line 315 of file muttlib.c.
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 122 of file muttlib.c.
void buf_pretty_mailbox | ( | struct Buffer * | buf | ) |
Shorten a mailbox path using '~' or '='.
Definition at line 519 of file muttlib.c.
void buf_sanitize_filename | ( | struct Buffer * | buf, |
const char * | path, | ||
short | slash | ||
) |
Replace unsafe characters in a filename.
Definition at line 982 of file muttlib.c.
Make a safe filename from an email address.
Definition at line 653 of file muttlib.c.
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 541 of file muttlib.c.
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 872 of file muttlib.c.
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 332 of file muttlib.c.
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 936 of file muttlib.c.
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 407 of file muttlib.c.
const char * mutt_make_version | ( | void | ) |
Generate the NeoMutt version string.
ptr | Version string |
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 379 of file muttlib.c.
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 701 of file muttlib.c.
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 440 of file muttlib.c.
Make a safe filename from an email address.
The filename will be stripped of '/', space, etc to make it safe.
Definition at line 683 of file muttlib.c.
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 746 of file muttlib.c.
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 628 of file muttlib.c.
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 843 of file muttlib.c.
void mutt_str_pretty_size | ( | char * | buf, |
size_t | buflen, | ||
size_t | num | ||
) |
Display an abbreviated size, like 3.4K.
buf | Buffer for the result |
buflen | Length of the buffer |
num | Number to abbreviate |
Definition at line 1004 of file muttlib.c.
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 1050 of file muttlib.c.
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 1075 of file muttlib.c.