1 /** 2 * @file 3 * Some miscellaneous functions 4 * 5 * @authors 6 * Copyright (C) 2018 Richard Russon <rich@flatcap.org> 7 * Copyright (C) 2019 Pietro Cerutti <gahr@gahr.ch> 8 * 9 * @copyright 10 * This program is free software: you can redistribute it and/or modify it under 11 * the terms of the GNU General Public License as published by the Free Software 12 * Foundation, either version 2 of the License, or (at your option) any later 13 * version. 14 * 15 * This program is distributed in the hope that it will be useful, but WITHOUT 16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 17 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 18 * details. 19 * 20 * You should have received a copy of the GNU General Public License along with 21 * this program. If not, see <http://www.gnu.org/licenses/>. 22 */ 23 24 #ifndef MUTT_MUTTLIB_H 25 #define MUTT_MUTTLIB_H 26 27 #include <signal.h> 28 #include <stdbool.h> 29 #include <stdint.h> 30 #include <stdio.h> 31 #include "attach/lib.h" 32 #include "format_flags.h" 33 34 struct Address; 35 struct Body; 36 struct Buffer; 37 struct ListHead; 38 struct passwd; 39 struct stat; 40 41 void mutt_adv_mktemp(struct Buffer *buf); 42 void mutt_buffer_mktemp_full(struct Buffer *buf, const char *prefix, const char *suffix, const char *src, int line); 43 void mutt_buffer_expand_path(struct Buffer *buf); 44 void mutt_buffer_expand_path_regex(struct Buffer *buf, bool regex); 45 void mutt_buffer_pretty_mailbox(struct Buffer *s); 46 void mutt_buffer_sanitize_filename (struct Buffer *buf, const char *path, short slash); 47 void mutt_buffer_save_path(struct Buffer *dest, const struct Address *a); 48 int mutt_check_overwrite(const char *attname, const char *path, struct Buffer *fname, enum SaveAttach *opt, char **directory); 49 void mutt_encode_path(struct Buffer *buf, const char *src); 50 void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags); 51 char * mutt_expand_path(char *s, size_t slen); 52 char * mutt_expand_path_regex(char *buf, size_t buflen, bool regex); 53 char * mutt_gecos_name(char *dest, size_t destlen, struct passwd *pw); 54 void mutt_get_parent_path(const char *path, char *buf, size_t buflen); 55 int mutt_inbox_cmp(const char *a, const char *b); 56 bool mutt_is_text_part(struct Body *b); 57 const char *mutt_make_version(void); 58 void mutt_mktemp_full(char *s, size_t slen, const char *prefix, const char *suffix, const char *src, int line); 59 bool mutt_needs_mailcap(struct Body *m); 60 FILE * mutt_open_read(const char *path, pid_t *thepid); 61 void mutt_pretty_mailbox(char *buf, size_t buflen); 62 void mutt_safe_path(struct Buffer *dest, const struct Address *a); 63 int mutt_save_confirm(const char *s, struct stat *st); 64 void mutt_save_path(char *d, size_t dsize, const struct Address *a); 65 void mutt_sleep(short s); 66 void mutt_str_pretty_size(char *buf, size_t buflen, size_t num); 67 68 void add_to_stailq (struct ListHead *head, const char *str); 69 void remove_from_stailq(struct ListHead *head, const char *str); 70 71 #define mutt_mktemp(buf, buflen) mutt_mktemp_pfx_sfx(buf, buflen, "neomutt", NULL) 72 #define mutt_mktemp_pfx_sfx(buf, buflen, prefix, suffix) mutt_mktemp_full(buf, buflen, prefix, suffix, __FILE__, __LINE__) 73 74 #define mutt_buffer_mktemp(buf) mutt_buffer_mktemp_pfx_sfx(buf, "neomutt", NULL) 75 #define mutt_buffer_mktemp_pfx_sfx(buf, prefix, suffix) mutt_buffer_mktemp_full(buf, prefix, suffix, __FILE__, __LINE__) 76 77 #endif /* MUTT_MUTTLIB_H */ 78