mutt stable branch with some hacks
1/*
2 * Copyright (C) 1996-2000,2007,2010,2013 Michael R. Elkins <me@mutt.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19
20#ifdef HAVE_INTTYPES_H
21# include <inttypes.h>
22#endif
23
24#include "mbyte.h"
25
26#define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#')
27
28#define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
29void _mutt_make_string (char *, size_t, const char *, CONTEXT *,
30 HEADER *, format_flag);
31
32struct hdr_format_info
33{
34 CONTEXT *ctx;
35 HEADER *hdr;
36 const char *pager_progress;
37};
38
39void mutt_make_string_info (char *, size_t, int, const char *, struct hdr_format_info *, format_flag);
40
41int mutt_extract_token (BUFFER *, BUFFER *, int);
42void mutt_free_opts (void);
43
44#define mutt_system(x) _mutt_system(x,0)
45int _mutt_system (const char *, int);
46
47#define mutt_next_thread(x) _mutt_aside_thread(x,1,0)
48#define mutt_previous_thread(x) _mutt_aside_thread(x,0,0)
49#define mutt_next_subthread(x) _mutt_aside_thread(x,1,1)
50#define mutt_previous_subthread(x) _mutt_aside_thread(x,0,1)
51int _mutt_aside_thread (HEADER *, short, short);
52
53#define mutt_collapse_thread(x,y) _mutt_traverse_thread (x,y,MUTT_THREAD_COLLAPSE)
54#define mutt_uncollapse_thread(x,y) _mutt_traverse_thread (x,y,MUTT_THREAD_UNCOLLAPSE)
55#define mutt_thread_contains_unread(x,y) _mutt_traverse_thread (x,y,MUTT_THREAD_UNREAD)
56#define mutt_thread_next_unread(x,y) _mutt_traverse_thread(x,y,MUTT_THREAD_NEXT_UNREAD)
57int _mutt_traverse_thread (CONTEXT *ctx, HEADER *hdr, int flag);
58
59
60#define mutt_new_parameter() safe_calloc (1, sizeof (PARAMETER))
61#define mutt_new_header() safe_calloc (1, sizeof (HEADER))
62#define mutt_new_envelope() safe_calloc (1, sizeof (ENVELOPE))
63#ifdef USE_AUTOCRYPT
64#define mutt_new_autocrypthdr() safe_calloc (1, sizeof (AUTOCRYPTHDR))
65#endif
66#define mutt_new_enter_state() safe_calloc (1, sizeof (ENTER_STATE))
67
68typedef const char * format_t (char *, size_t, size_t, int, char, const char *, const char *, const char *, const char *, unsigned long, format_flag);
69
70void mutt_FormatString (char *, size_t, size_t, int, const char *, format_t *, unsigned long, format_flag);
71void mutt_parse_content_type (char *, BODY *);
72void mutt_generate_boundary (PARAMETER **);
73void mutt_delete_parameter (const char *attribute, PARAMETER **p);
74void mutt_set_parameter (const char *, const char *, PARAMETER **);
75
76
77FILE *mutt_open_read (const char *, pid_t *);
78
79void set_quadoption (int, int);
80int query_quadoption (int, const char *);
81int quadoption (int);
82
83char* mutt_extract_message_id (const char *, const char **);
84
85ADDRESS *mutt_default_from (void);
86ADDRESS *mutt_get_address (ENVELOPE *, char **);
87ADDRESS *mutt_lookup_alias (const char *s);
88ADDRESS *mutt_remove_duplicates (ADDRESS *);
89ADDRESS *mutt_remove_xrefs (ADDRESS *, ADDRESS *);
90ADDRESS *mutt_expand_aliases (ADDRESS *);
91ADDRESS *mutt_parse_adrlist (ADDRESS *, const char *);
92
93BODY *mutt_run_send_alternative_filter (BODY *b);
94BODY *mutt_make_file_attach (const char *);
95BODY *mutt_make_message_attach (CONTEXT *, HEADER *, int);
96BODY *mutt_remove_multipart (BODY *);
97BODY *mutt_remove_multipart_mixed (BODY *);
98BODY *mutt_make_multipart_mixed (BODY *);
99BODY *mutt_make_multipart_alternative (BODY *b, BODY *alternative);
100BODY *mutt_remove_multipart_alternative (BODY *b);
101BODY *mutt_new_body (void);
102BODY *mutt_parse_multipart (FILE *, const char *, LOFF_T, int);
103BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
104BODY *mutt_read_mime_header (FILE *, int);
105
106CONTENT *mutt_get_content_info (const char *fname, BODY *b);
107
108HASH *mutt_make_id_hash (CONTEXT *);
109HASH *mutt_make_subj_hash (CONTEXT *);
110
111LIST *mutt_make_references(ENVELOPE *e);
112
113char *mutt_read_rfc822_line (FILE *, char *, size_t *);
114ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
115HEADER *mutt_dup_header (HEADER *);
116
117void mutt_set_mtime (const char *from, const char *to);
118time_t mutt_decrease_mtime (const char *, struct stat *);
119time_t mutt_local_tz (time_t);
120time_t mutt_mktime (struct tm *, int);
121time_t mutt_parse_date (const char *, HEADER *);
122time_t mutt_add_timeout (time_t, long);
123int is_from (const char *, char *, size_t, time_t *);
124void mutt_touch_atime (int);
125int mutt_timespec_compare (struct timespec *a, struct timespec *b);
126void mutt_get_stat_timespec (struct timespec *dest, struct stat *sb, mutt_stat_type type);
127int mutt_stat_timespec_compare (struct stat *sba, mutt_stat_type type, struct timespec *b);
128int mutt_stat_compare (struct stat *sba, mutt_stat_type sba_type, struct stat *sbb, mutt_stat_type sbb_type);
129
130
131const char *mutt_attach_fmt (
132 char *dest,
133 size_t destlen,
134 size_t col,
135 int cols,
136 char op,
137 const char *src,
138 const char *prefix,
139 const char *ifstring,
140 const char *elsestring,
141 unsigned long data,
142 format_flag flags);
143
144
145char *mutt_charset_hook (const char *);
146char *mutt_iconv_hook (const char *);
147void mutt_buffer_expand_path (BUFFER *);
148void _mutt_buffer_expand_path (BUFFER *, int);
149char *mutt_expand_path (char *, size_t);
150char *_mutt_expand_path (char *, size_t, int);
151char *mutt_find_hook (int, const char *);
152char *mutt_gecos_name (char *, size_t, struct passwd *);
153char *mutt_gen_msgid (void);
154char *mutt_get_body_charset (char *, size_t, BODY *);
155const char *mutt_get_name (ADDRESS *);
156char *mutt_get_parameter (const char *, PARAMETER *);
157LIST *mutt_crypt_hook (ADDRESS *);
158char *mutt_make_date (char *, size_t);
159
160const char *mutt_make_version (void);
161
162const char *mutt_fqdn(short);
163
164group_t *mutt_pattern_group (const char *);
165
166REGEXP *mutt_compile_regexp (const char *, int);
167
168void mutt_account_hook (const char* url);
169void mutt_add_to_reference_headers (ENVELOPE *env, ENVELOPE *curenv, LIST ***pp, LIST ***qq);
170void mutt_adv_mktemp (BUFFER *);
171void mutt_alias_menu (char *, size_t, ALIAS *);
172void mutt_allow_interrupt (int);
173void mutt_auto_subscribe (const char *);
174void mutt_block_signals (void);
175void mutt_block_signals_system (void);
176int mutt_body_handler (BODY *, STATE *);
177int mutt_bounce_message (FILE *fp, HEADER *, ADDRESS *);
178void mutt_break_thread (HEADER *);
179void mutt_browser_cleanup (void);
180void mutt_buffer_concat_path (BUFFER *, const char *, const char *);
181void mutt_buffer_concatn_path (BUFFER *dst, const char *dir, size_t dirlen,
182 const char *fname, size_t fnamelen);
183#define mutt_buffer_quote_filename(a,b) _mutt_buffer_quote_filename (a, b, 1);
184void _mutt_buffer_quote_filename (BUFFER *, const char *, int);
185void mutt_buffer_sanitize_filename (BUFFER *d, const char *f, short slash);
186void mutt_canonical_charset (char *, size_t, const char *);
187void mutt_check_stats(void);
188int mutt_count_body_parts (CONTEXT *, HEADER *);
189void mutt_check_rescore (CONTEXT *);
190void mutt_clear_error (void);
191void mutt_clear_pager_position (void);
192void mutt_create_alias (ENVELOPE *, ADDRESS *);
193void mutt_decode_attachment (BODY *, STATE *);
194void mutt_decode_base64 (STATE *s, long len, int istext, iconv_t cd);
195void mutt_default_save (char *, size_t, HEADER *);
196void mutt_display_address (ENVELOPE *);
197void mutt_display_sanitize (char *);
198int mutt_edit_content_type (HEADER *, BODY *, FILE *);
199void mutt_edit_file (const char *, const char *);
200void mutt_edit_headers (const char *, const char *, HEADER *, BUFFER *);
201char **mutt_envlist (void);
202void mutt_envlist_set (const char *name, const char *value, int overwrite);
203int mutt_filter_unprintable (char **);
204int mutt_label_message (HEADER *);
205void mutt_make_label_hash (CONTEXT *);
206void mutt_label_hash_add (CONTEXT *ctx, HEADER *hdr);
207void mutt_label_hash_remove (CONTEXT *ctx, HEADER *hdr);
208int mutt_label_complete (char *, size_t, int);
209void mutt_curses_error (const char *, ...);
210void mutt_curses_message (const char *, ...);
211void mutt_encode_descriptions (BODY *, short);
212void mutt_encode_path (BUFFER *, const char *);
213void mutt_enter_command (void);
214void mutt_error_history_display (void);
215void mutt_error_history_init (void);
216void mutt_expand_aliases_env (ENVELOPE *);
217void mutt_expand_file_fmt (BUFFER *, const char *, const char *);
218void mutt_expand_fmt (BUFFER *, const char *, const char *);
219void mutt_fix_reply_recipients (ENVELOPE *env);
220void mutt_folder_hook (const char *);
221void mutt_format_string (char *, size_t, int, int, int, char, const char *, size_t, int);
222void mutt_format_s (char *, size_t, const char *, const char *);
223void mutt_format_s_tree (char *, size_t, const char *, const char *);
224void mutt_forward_intro (CONTEXT *ctx, HEADER *cur, FILE *fp);
225void mutt_forward_trailer (CONTEXT *ctx, HEADER *cur, FILE *fp);
226void mutt_free_alias (ALIAS **);
227#ifdef USE_AUTOCRYPT
228void mutt_free_autocrypthdr (AUTOCRYPTHDR **p);
229#endif
230void mutt_free_body (BODY **);
231void mutt_free_color (int fg, int bg);
232void mutt_free_enter_state (ENTER_STATE **);
233void mutt_free_envelope (ENVELOPE **);
234void mutt_free_header (HEADER **);
235void mutt_free_parameter (PARAMETER **);
236void mutt_free_regexp (REGEXP **);
237void mutt_generate_header (char *, size_t, HEADER *, int);
238const char *mutt_getcwd (BUFFER *);
239void mutt_help (int);
240const char *mutt_idxfmt_hook (const char *, CONTEXT *, HEADER *);
241void mutt_draw_tree (CONTEXT *);
242void mutt_check_lookup_list (BODY *, char *, size_t);
243void mutt_make_attribution (CONTEXT *ctx, HEADER *cur, FILE *out);
244void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur);
245void mutt_make_help (char *, size_t, const char *, int, int);
246void mutt_make_misc_reply_headers (ENVELOPE *env, CONTEXT *ctx, HEADER *cur, ENVELOPE *curenv);
247void mutt_make_post_indent (CONTEXT *ctx, HEADER *cur, FILE *out);
248void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra);
249void mutt_message_to_7bit (BODY *, FILE *);
250#define mutt_buffer_mktemp(a) mutt_buffer_mktemp_pfx_sfx (a, "mutt", NULL)
251#define mutt_buffer_mktemp_pfx_sfx(a,b,c) _mutt_buffer_mktemp (a, b, c, __FILE__, __LINE__)
252void _mutt_buffer_mktemp (BUFFER *, const char *, const char *, const char *, int);
253#define mutt_mktemp(a,b) mutt_mktemp_pfx_sfx (a, b, "mutt", NULL)
254#define mutt_mktemp_pfx_sfx(a,b,c,d) _mutt_mktemp (a, b, c, d, __FILE__, __LINE__)
255void _mutt_mktemp (char *, size_t, const char *, const char *, const char *, int);
256void mutt_normalize_time (struct tm *);
257void mutt_paddstr (int, const char *);
258void mutt_parse_mime_message (CONTEXT *ctx, HEADER *);
259void mutt_parse_part (FILE *, BODY *);
260void mutt_perror (const char *);
261void mutt_prepare_envelope (ENVELOPE *, int);
262void mutt_unprepare_envelope (ENVELOPE *);
263void mutt_buffer_pretty_mailbox (BUFFER *);
264void mutt_pretty_mailbox (char *, size_t);
265void mutt_pretty_size (char *, size_t, LOFF_T);
266void mutt_pipe_message (HEADER *);
267void mutt_print_message (HEADER *);
268void mutt_print_patchlist (void);
269void mutt_query_exit (void);
270void mutt_query_menu (char *, size_t);
271void mutt_safe_path (BUFFER *dest, ADDRESS *a);
272int mutt_rx_sanitize_string (BUFFER *dest, const char *src);
273void mutt_save_path (char *s, size_t l, ADDRESS *a);
274void mutt_buffer_save_path (BUFFER *dest, ADDRESS *a);
275void mutt_score_message (CONTEXT *, HEADER *, int);
276void mutt_select_fcc (BUFFER *, HEADER *);
277#define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,NULL,NULL)
278void _mutt_select_file (char *, size_t, int, char ***, int *);
279#define mutt_buffer_select_file(A,B) _mutt_buffer_select_file(A,B,NULL,NULL)
280void _mutt_buffer_select_file (BUFFER *, int, char ***, int *);
281void mutt_message_hook (CONTEXT *, HEADER *, int);
282void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
283#define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1)
284void mutt_set_followup_to (ENVELOPE *);
285void mutt_shell_escape (void);
286void mutt_show_error (void);
287void mutt_signal_init (void);
288void mutt_stamp_attachment (BODY *a);
289void mutt_tabs_to_spaces (char *);
290void mutt_tag_set_flag (int, int);
291short mutt_ts_capability (void);
292void mutt_unblock_signals (void);
293void mutt_unblock_signals_system (int);
294void mutt_update_encoding (BODY *a);
295void mutt_version (void);
296void mutt_view_attachments (HEADER *);
297void mutt_write_address_list (ADDRESS *adr, FILE *fp, int linelen, int display);
298void mutt_set_virtual (CONTEXT *);
299
300int mutt_add_to_rx_list (RX_LIST **list, const char *s, int flags, BUFFER *err);
301int mutt_addr_is_user (ADDRESS *);
302int mutt_addwch (wchar_t);
303int mutt_alias_complete (char *, size_t);
304void mutt_alias_add_reverse (ALIAS *t);
305void mutt_alias_delete_reverse (ALIAS *t);
306int mutt_alloc_color (int fg, int bg);
307int mutt_any_key_to_continue (const char *);
308char *mutt_apply_replace (char *, size_t, char *, REPLACE_LIST *);
309int mutt_builtin_editor (const char *, HEADER *, HEADER *);
310int mutt_can_decode (BODY *);
311int mutt_change_flag (HEADER *, int);
312int mutt_check_alias_name (const char *, char *, size_t);
313int mutt_check_encoding (const char *);
314int mutt_check_key (const char *);
315int mutt_check_menu (const char *);
316int mutt_check_mime_type (const char *);
317int mutt_check_month (const char *);
318int mutt_check_overwrite (const char *, const char *, BUFFER *, int *, char **);
319int mutt_check_traditional_pgp (HEADER *, int *);
320int mutt_command_complete (char *, size_t, int, int);
321int mutt_var_value_complete (char *, size_t, int);
322int mutt_complete (char *, size_t);
323int mutt_compose_attachment (BODY *a);
324int mutt_copy_body (FILE *, BODY **, BODY *);
325int mutt_decode_save_attachment (FILE *, BODY *, const char *, int, int);
326int mutt_display_message (HEADER *h);
327int mutt_dump_variables (void);
328int mutt_edit_attachment(BODY *);
329int mutt_edit_address (ADDRESS **, const char *, int);
330int mutt_edit_message (CONTEXT *, HEADER *);
331int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags);
332int mutt_chscmp (const char *s, const char *chs);
333#define mutt_is_utf8(a) mutt_chscmp (a, "utf-8")
334#define mutt_is_us_ascii(a) mutt_chscmp (a, "us-ascii")
335int mutt_parent_message (CONTEXT *, HEADER *, int);
336int mutt_prepare_template(FILE*, CONTEXT *, HEADER *, HEADER *, short);
337int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
338#define mutt_buffer_enter_fname(A,B,C) _mutt_buffer_enter_fname(A,B,C,0,NULL,NULL)
339int _mutt_buffer_enter_fname (const char *, BUFFER *, int, int, char ***, int *);
340#define mutt_enter_fname(A,B,C,D) _mutt_enter_fname(A,B,C,D,0,NULL,NULL)
341int _mutt_enter_fname (const char *, char *, size_t, int, int, char ***, int *);
342int mutt_enter_string (char *buf, size_t buflen, int col, int flags);
343int _mutt_enter_string (char *, size_t, int, int, int, char ***, int *, ENTER_STATE *);
344#define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
345int _mutt_get_field (const char *, char *, size_t, int, int, char ***, int *);
346#define mutt_buffer_get_field(A,B,C) _mutt_buffer_get_field(A,B,C,0,NULL,NULL)
347int _mutt_buffer_get_field (const char *, BUFFER *, int, int, char ***, int *);
348int mutt_get_hook_type (const char *);
349int mutt_get_field_unbuffered (char *, char *, size_t, int);
350#define mutt_get_password(A,B,C) mutt_get_field_unbuffered(A,B,C,MUTT_PASS)
351int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, BUFFER *);
352int mutt_get_tmp_attachment (BODY *);
353int mutt_index_menu (void);
354int mutt_invoke_sendmail (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char *, int);
355int mutt_is_mail_list (ADDRESS *);
356int mutt_is_message_type(int, const char *);
357int mutt_is_list_cc (int, ADDRESS *, ADDRESS *);
358int mutt_is_list_recipient (int, ADDRESS *, ADDRESS *);
359int mutt_is_quote_line (char *, regmatch_t *);
360int mutt_is_subscribed_list (ADDRESS *);
361int mutt_is_text_part (BODY *);
362int mutt_is_valid_mailbox (const char *);
363int mutt_link_threads (HEADER *, HEADER *, CONTEXT *);
364int mutt_lookup_mime_type (BODY *, const char *);
365int mutt_match_rx_list (const char *, RX_LIST *);
366int mutt_match_spam_list (const char *, REPLACE_LIST *, char *, int);
367int mutt_messages_in_thread (CONTEXT *, HEADER *, int);
368int mutt_multi_choice (char *prompt, char *letters);
369int mutt_needs_mailcap (BODY *);
370int mutt_num_postponed (int);
371int mutt_parse_bind (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
372int mutt_parse_exec (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
373int mutt_parse_color (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
374int mutt_parse_uncolor (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
375int mutt_parse_hook (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
376int mutt_parse_idxfmt_hook (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
377int mutt_parse_macro (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
378int mutt_parse_mailboxes (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
379int mutt_parse_mono (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
380int mutt_parse_unmono (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
381int mutt_parse_push (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
382int mutt_parse_rc_line (/* const */ char *, BUFFER *, BUFFER *);
383int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p,
384 short user_hdrs, short weed, short do_2047, LIST **lastp);
385int mutt_parse_score (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
386int mutt_parse_unscore (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
387int mutt_parse_unhook (BUFFER *, BUFFER *, union pointer_long_t, BUFFER *);
388int mutt_pattern_func (int, char *);
389int mutt_pipe_attachment (FILE *, BODY *, const char *, const char *);
390int mutt_print_attachment (FILE *, BODY *);
391int mutt_query_complete (char *, size_t);
392int mutt_query_variables (LIST *queries);
393int mutt_save_attachment (FILE *, BODY *, const char *, int, HEADER *);
394int _mutt_save_message (HEADER *, CONTEXT *, int, int, int);
395int mutt_save_message (HEADER *, int, int, int);
396int mutt_search_command (int, int);
397#ifdef USE_SMTP
398int mutt_smtp_send (const ADDRESS *, const ADDRESS *, const ADDRESS *,
399 const ADDRESS *, const char *, int);
400#endif
401size_t mutt_wstr_trunc (const char *, size_t, size_t, size_t *);
402int mutt_charlen (const char *s, int *);
403int mutt_strwidth (const char *);
404int mutt_compose_menu (HEADER *, BUFFER *, HEADER *, int);
405int mutt_thread_set_flag (HEADER *, int, int, int);
406int mutt_user_is_recipient (HEADER *);
407void mutt_update_num_postponed (void);
408int mutt_wait_filter (pid_t);
409int mutt_wait_interactive_filter (pid_t);
410int mutt_which_case (const char *);
411int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, const char *);
412int mutt_write_mime_body (BODY *, FILE *);
413int mutt_write_mime_header (BODY *, FILE *);
414int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, int flags);
415int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, mutt_write_header_mode, int, int);
416void mutt_write_references (LIST *, FILE *, int);
417int mutt_yesorno (const char *, int);
418void mutt_set_header_color(CONTEXT *, HEADER *);
419void mutt_sleep (short);
420int mutt_save_confirm (const char *, struct stat *);
421
422int mh_valid_message (const char *);
423
424pid_t mutt_create_filter (const char *, FILE **, FILE **, FILE **);
425pid_t mutt_create_filter_fd (const char *, FILE **, FILE **, FILE **, int, int, int);
426
427ADDRESS *alias_reverse_lookup (ADDRESS *);
428
429/* lib.c files transplanted to muttlib.c */
430int mutt_rmtree (const char *);
431FILE *safe_fopen (const char *, const char *);
432int safe_open (const char *, int);
433int safe_symlink (const char *, const char *);
434
435/* base64.c */
436void mutt_to_base64 (unsigned char*, const unsigned char*, size_t, size_t);
437int mutt_from_base64 (char*, const char*, size_t);
438void mutt_buffer_to_base64 (BUFFER *, const unsigned char *, size_t);
439int mutt_buffer_from_base64 (BUFFER *, const char *);
440
441/* utf8.c */
442int mutt_wctoutf8 (char *s, unsigned int c, size_t buflen);
443
444#ifdef LOCALES_HACK
445#define IsPrint(c) (isprint((unsigned char)(c)) || \
446 ((unsigned char)(c) >= 0xa0))
447#define IsWPrint(wc) (iswprint(wc) || wc >= 0xa0)
448#else
449#define IsPrint(c) (isprint((unsigned char)(c)) || \
450 (option (OPTLOCALES) ? 0 : \
451 ((unsigned char)(c) >= 0xa0)))
452#define IsWPrint(wc) (iswprint(wc) || \
453 (option (OPTLOCALES) ? 0 : (wc >= 0xa0)))
454#endif
455
456#define new_pattern() safe_calloc(1, sizeof (pattern_t))
457
458int mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags, CONTEXT *ctx, HEADER *h, pattern_cache_t *);
459pattern_t *mutt_pattern_comp (/* const */ char *s, int flags, BUFFER *err);
460void mutt_check_simple (BUFFER *s, const char *simple);
461void mutt_pattern_free (pattern_t **pat);
462
463/* ----------------------------------------------------------------------------
464 * Prototypes for broken systems
465 */
466
467#ifdef HAVE_LONG_LONG_INT
468#ifdef LONGLONG
469#error LONGLONG is already defined
470#endif
471#define LONGLONG long long
472#else
473#define LONGLONG long
474#endif
475
476#ifdef HAVE_SRAND48
477#define LRAND lrand48
478#define SRAND srand48
479#define DRAND drand48
480#else
481#define LRAND rand
482#define SRAND srand
483#define DRAND (double)rand
484#endif /* HAVE_SRAND48 */
485
486/* HP-UX, ConvexOS and UNIXware don't have this macro */
487#ifndef S_ISLNK
488#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK ? 1 : 0)
489#endif
490
491int getdnsdomainname (char *, size_t);
492
493/* According to SCO support, this is how to detect SCO */
494#if defined (_M_UNIX) || defined (MUTT_OS)
495#define SCO
496#endif
497
498/* SCO Unix uses chsize() instead of ftruncate() */
499#ifndef HAVE_FTRUNCATE
500#define ftruncate chsize
501#endif
502
503#ifndef HAVE_SNPRINTF
504extern int snprintf (char *, size_t, const char *, ...);
505#endif
506
507#ifndef HAVE_VSNPRINTF
508extern int vsnprintf (char *, size_t, const char *, va_list);
509#endif
510
511#ifndef HAVE_STRERROR
512#ifndef STDC_HEADERS
513extern int sys_nerr;
514extern char *sys_errlist[];
515#endif
516
517#define strerror(x) ((x) > 0 && (x) < sys_nerr) ? sys_errlist[(x)] : 0
518#endif /* !HAVE_STRERROR */
519
520#ifndef HAVE_MEMMOVE
521#define memmove(d,s,n) bcopy((s),(d),(n))
522#endif
523
524/* AIX doesn't define these in any headers (sigh) */
525int strcasecmp (const char *, const char *);
526int strncasecmp (const char *, const char *, size_t);
527
528#ifdef _AIX
529int setegid (gid_t);
530#endif /* _AIX */
531
532#ifndef STDC_HEADERS
533extern FILE *fdopen ();
534extern int system ();
535extern int puts ();
536extern int fputs ();
537extern int fputc ();
538extern int fseek ();
539extern char *strchr ();
540extern int getopt ();
541extern int fputs ();
542extern int fputc ();
543extern int fclose ();
544extern int fprintf();
545extern int printf ();
546extern int fgetc ();
547extern int tolower ();
548extern int toupper ();
549extern int sscanf ();
550extern size_t fread ();
551extern size_t fwrite ();
552extern int system ();
553extern int rename ();
554extern time_t time ();
555extern struct tm *localtime ();
556extern char *asctime ();
557extern char *strpbrk ();
558extern int fflush ();
559extern long lrand48 ();
560extern void srand48 ();
561extern time_t mktime ();
562extern int vsprintf ();
563extern int ungetc ();
564extern int ftruncate ();
565extern void *memset ();
566extern int pclose ();
567extern int socket ();
568extern int connect ();
569extern size_t strftime ();
570extern int lstat ();
571extern void rewind ();
572extern int readlink ();
573
574/* IRIX barfs on empty var decls because the system include file uses elipsis
575 in the declaration. So declare all the args to avoid compiler errors. This
576 should be harmless on other systems. */
577int ioctl (int, int, ...);
578
579#endif
580
581/* unsorted */
582void ci_bounce_message (HEADER *);
583int ci_send_message (int, HEADER *, const char *, CONTEXT *, HEADER *);
584
585/* prototypes for compatibility functions */
586
587#ifndef HAVE_SETENV
588int setenv (const char *, const char *, int);
589#endif
590
591#ifndef HAVE_STRCASECMP
592int strcasecmp (char *, char *);
593int strncasecmp (char *, char *, size_t);
594#endif
595
596#ifndef HAVE_STRDUP
597char *strdup (const char *);
598#endif
599
600#ifndef HAVE_STRSEP
601char *strsep (char **, const char *);
602#endif
603
604#ifndef HAVE_STRTOK_R
605char *strtok_r (char *, const char *, char **);
606#endif
607
608#ifndef HAVE_WCSCASECMP
609int wcscasecmp (const wchar_t *a, const wchar_t *b);
610#endif
611
612#ifndef HAVE_STRCASESTR
613char *strcasestr (const char *, const char *);
614#endif
615
616#ifndef HAVE_MKDTEMP
617char *mkdtemp (char *tmpl);
618#endif