0fc9575b5db4eeafbf6d05b5820f47f88c83c479
[apps/madmutt.git] / protos.h
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
4  *
5  * This file is part of mutt-ng, see http://www.muttng.org/.
6  * It's licensed under the GNU General Public License,
7  * please see the file GPL in the top level source directory.
8  */
9
10 #ifdef HAVE_CONFIG_H
11 # include "config.h"
12 #endif
13
14 #if HAVE_STDINT_H
15 #include <stdint.h>
16 #elif HAVE_INTTYPES_H
17 #include <inttypes.h>
18 #endif
19
20 #include "mbyte.h"
21
22 #define MoreArgs(p) (*p->dptr && *p->dptr != ';' && *p->dptr != '#')
23
24 #define mutt_make_string(A,B,C,D,E) _mutt_make_string(A,B,C,D,E,0)
25 void _mutt_make_string (char *, size_t, const char *, CONTEXT *,
26                         HEADER *, format_flag);
27
28 #define mutt_system(x) _mutt_system(x,0)
29 int _mutt_system (const char *, int);
30
31 #define mutt_new_parameter() mem_calloc (1, sizeof (PARAMETER))
32 #define mutt_new_header() mem_calloc (1, sizeof (HEADER))
33 #define mutt_new_envelope() mem_calloc (1, sizeof (ENVELOPE))
34 #define mutt_new_enter_state() mem_calloc (1, sizeof (ENTER_STATE))
35
36 typedef const char *format_t (char *, size_t, char, const char *,
37                               const char *, const char *, const char *,
38                               unsigned long, format_flag);
39
40 void mutt_FormatString (char *, size_t, const char *, format_t *,
41                         unsigned long, format_flag);
42 void mutt_parse_content_type (char *, BODY *);
43 void mutt_generate_boundary (PARAMETER **);
44 void mutt_delete_parameter (const char *attribute, PARAMETER ** p);
45 void mutt_set_parameter (const char *, const char *, PARAMETER **);
46
47 FILE *mutt_open_read (const char *, pid_t *);
48
49 void set_quadoption (int, int);
50 int query_quadoption (int, const char *);
51 int quadoption (int);
52
53 int mutt_option_value (const char* val, char* dst, size_t dstlen);
54
55 ADDRESS *mutt_default_from (void);
56 ADDRESS *mutt_remove_duplicates (ADDRESS *);
57 ADDRESS *mutt_parse_adrlist (ADDRESS *, const char *);
58
59 BODY *mutt_make_file_attach (const char *);
60 BODY *mutt_make_message_attach (CONTEXT *, HEADER *, int);
61 BODY *mutt_remove_multipart (BODY *);
62 BODY *mutt_make_multipart (BODY *);
63 BODY *mutt_new_body (void);
64 BODY *mutt_parse_multipart (FILE *, const char *, LOFF_T, int);
65 BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
66 BODY *mutt_read_mime_header (FILE *, int);
67
68 CONTENT *mutt_get_content_info (const char *fname, BODY * b);
69
70 LIST *mutt_make_references (ENVELOPE * e);
71 char* mutt_read_rfc822_line (FILE*, char*, size_t*);
72 LIST *mutt_parse_references (char *, int);
73
74 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
75 HEADER *mutt_dup_header (HEADER *);
76
77 int mutt_cmp_header (const HEADER*, const HEADER*);
78 int mutt_cmp_addr (const ADDRESS * a, const ADDRESS * b);
79 int mutt_cmp_list (const LIST * a, const LIST * b);
80 int mutt_cmp_env (const ENVELOPE * e1, const ENVELOPE * e2);
81 int mutt_cmp_param (const PARAMETER * p1, const PARAMETER * p2);
82 int mutt_cmp_body (const BODY * b1, const BODY * b2);
83
84 time_t mutt_decrease_mtime (const char *, struct stat *);
85 void mutt_set_mtime (const char*, const char*);
86 time_t mutt_local_tz (time_t);
87 time_t mutt_mktime (struct tm *, int);
88 time_t mutt_parse_date (const char *, HEADER *);
89 int is_from (const char *, char *, size_t, time_t *);
90
91 char *mutt_charset_hook (const char *);
92 char *mutt_iconv_hook (const char *);
93 char *mutt_expand_path (char *, size_t);
94 char *_mutt_expand_path (char *, size_t, int);
95 char *mutt_find_hook (int, const char *);
96 char *mutt_gecos_name (char *, size_t, struct passwd *);
97 char *mutt_gen_msgid (void);
98 char *mutt_get_body_charset (char *, size_t, BODY *);
99 const char *mutt_get_name (ADDRESS *);
100 char *mutt_get_parameter (const char *, PARAMETER *);
101 char *mutt_crypt_hook (ADDRESS *);
102 char *mutt_make_date (char *, size_t);
103
104 const char *mutt_make_version (int full);
105
106 const char *mutt_fqdn (short);
107
108 void mutt_account_hook (const char *url);
109 void mutt_add_to_reference_headers (ENVELOPE * env, ENVELOPE * curenv,
110                                     LIST *** pp, LIST *** qq);
111 void mutt_adv_mktemp (const char*, char*, size_t);
112 void mutt_allow_interrupt (int);
113 void mutt_block_signals (void);
114 void mutt_block_signals_system (void);
115 int mutt_bounce_message (FILE * fp, HEADER *, ADDRESS *);
116 void mutt_canonical_charset (char *, size_t, const char *);
117 int mutt_count_body_parts (HEADER *hdr, int flags);
118 void mutt_check_rescore (CONTEXT *);
119 void mutt_clear_error (void);
120 void mutt_default_save (char *, size_t, HEADER *);
121 void mutt_display_address (ENVELOPE *);
122 void mutt_display_sanitize (char *);
123 void mutt_edit_content_type (HEADER *, BODY *, FILE *);
124 void mutt_edit_file (const char *, const char *);
125 void mutt_edit_headers (const char *, const char *, HEADER *, char *, size_t);
126 void mutt_curses_error (const char *, ...);
127 void mutt_curses_message (const char *, ...);
128 void mutt_enter_command (void);
129 void mutt_expand_file_fmt (char *, size_t, const char *, const char *);
130 void mutt_expand_fmt (char *, size_t, const char *, const char *);
131 void mutt_expand_link (char *, const char *, const char *);
132 void mutt_fix_reply_recipients (ENVELOPE * env);
133 void mutt_folder_hook (char *);
134 void mutt_format_string (char *, size_t, int, int, int, char, const char *,
135                          size_t, int);
136 void mutt_format_s (char *, size_t, const char *, const char *);
137 void mutt_format_s_tree (char *, size_t, const char *, const char *);
138 void mutt_forward_intro (FILE * fp, HEADER * cur);
139 void mutt_forward_trailer (FILE * fp);
140 void mutt_free_body (BODY **);
141 void mutt_free_color (int fg, int bg);
142 void mutt_free_envelope (ENVELOPE **);
143 void mutt_free_header (HEADER **);
144 void mutt_free_parameter (PARAMETER **);
145 void mutt_generate_header (char *, size_t, HEADER *, int);
146 void mutt_help (int);
147 void mutt_draw_tree (CONTEXT *);
148 void mutt_make_attribution (CONTEXT * ctx, HEADER * cur, FILE * out);
149 void mutt_make_forward_subject (ENVELOPE * env, CONTEXT * ctx, HEADER * cur);
150 void mutt_make_help (char *, size_t, char *, int, int);
151 void mutt_make_misc_reply_headers (ENVELOPE * env, CONTEXT * ctx,
152                                    HEADER * cur, ENVELOPE * curenv);
153 void mutt_make_post_indent (CONTEXT * ctx, HEADER * cur, FILE * out);
154 void mutt_merge_envelopes (ENVELOPE* base, ENVELOPE** extra);
155 void mutt_message_to_7bit (BODY *, FILE *);
156
157 #define mutt_mktemp(a) _mutt_mktemp (a, __FILE__, __LINE__)
158 void _mutt_mktemp (char *, const char *, int);
159 void mutt_normalize_time (struct tm *);
160 void mutt_paddstr (int, const char *);
161 void mutt_parse_mime_message (CONTEXT * ctx, HEADER *);
162 void mutt_parse_part (FILE *, BODY *);
163 #define mutt_perror(a) _mutt_perror (a, __FILE__, __LINE__)
164 void _mutt_perror (const char*, const char*,int);
165 void mutt_prepare_envelope (ENVELOPE *, int);
166 void mutt_unprepare_envelope (ENVELOPE *);
167 void mutt_pretty_mailbox (char *);
168 void mutt_pretty_size (char *, size_t, long);
169 void mutt_pipe_message (HEADER *);
170 void mutt_print_message (HEADER *);
171 void mutt_query_exit (void);
172 void mutt_query_menu (char *, size_t);
173 void mutt_safe_path (char *s, size_t l, ADDRESS * a);
174 void mutt_save_path (char *s, size_t l, ADDRESS * a);
175 void mutt_score_message (CONTEXT *, HEADER *, int);
176 void mutt_select_fcc (char *, size_t, HEADER *);
177
178 #define mutt_select_file(A,B,C) _mutt_select_file(A,B,C,NULL,NULL)
179 void _mutt_select_file (char *, size_t, int, char ***, int *);
180 void mutt_message_hook (CONTEXT *, HEADER *, int);
181 void _mutt_set_flag (CONTEXT *, HEADER *, int, int, int);
182
183 #define mutt_set_flag(a,b,c,d) _mutt_set_flag(a,b,c,d,1)
184 void mutt_set_followup_to (ENVELOPE *);
185 void mutt_shell_escape (void);
186 void mutt_show_error (void);
187 void mutt_signal_init (void);
188 void mutt_stamp_attachment (BODY * a);
189 void mutt_tabs_to_spaces (char *);
190 void mutt_tag_set_flag (int, int);
191 void mutt_unblock_signals (void);
192 void mutt_unblock_signals_system (int);
193 void mutt_update_encoding (BODY * a);
194 void mutt_version (void);
195 void mutt_write_references (LIST *, FILE *);
196 void mutt_write_address_list (ADDRESS * adr, FILE * fp, int linelen,
197                               int display);
198
199 int mutt_addwch (wchar_t);
200 int mutt_alloc_color (int fg, int bg);
201 int mutt_any_key_to_continue (const char *);
202 int mutt_builtin_editor (const char *, HEADER *, HEADER *);
203 int mutt_can_decode (BODY *);
204 int mutt_change_flag (HEADER *, int);
205 int mutt_check_encoding (const char *);
206 int mutt_check_key (const char *);
207 int mutt_check_menu (const char *);
208 int mutt_check_mime_type (const char *);
209 int mutt_check_month (const char *);
210 int mutt_check_overwrite (const char *, const char *, char *, size_t, int *,
211                           char **);
212 int mutt_check_traditional_pgp (HEADER *, int *);
213 int mutt_command_complete (char *, size_t, int, int);
214 int mutt_var_value_complete (char *, size_t, int);
215 int mutt_complete (char *, size_t);
216 int mutt_copy_body (FILE *, BODY **, BODY *);
217
218 int mutt_display_message (HEADER * h);
219 int mutt_dump_variables (int full);
220 int mutt_edit_message (CONTEXT *, HEADER *);
221 int mutt_fetch_recips (ENVELOPE * out, ENVELOPE * in, int flags);
222 int mutt_chscmp (const char *s, const char *chs);
223
224 #define mutt_is_utf8(a) mutt_chscmp (a, "utf-8")
225 #define mutt_is_us_ascii(a) mutt_chscmp (a, "us-ascii")
226 int mutt_prepare_template (FILE *, CONTEXT *, HEADER *, HEADER *, short);
227 int mutt_resend_message (FILE *, CONTEXT *, HEADER *);
228
229 #define mutt_enter_fname(A,B,C,D,E) _mutt_enter_fname(A,B,C,D,E,0,NULL,NULL)
230 int _mutt_enter_fname (const char *, char *, size_t, int *, int, int,
231                        char ***, int *);
232 #define mutt_get_field(A,B,C,D) _mutt_get_field(A,B,C,D,0,NULL,NULL)
233 int _mutt_get_field (const char *, char *, size_t, int, int, char ***, int *);
234 int mutt_get_field_unbuffered (char *, char *, size_t, int);
235 int mutt_get_hook_type (const char *);
236 int mutt_get_postponed (CONTEXT *, HEADER *, HEADER **, char *, size_t);
237 int mutt_index_menu (void);
238 int mutt_invoke_mta (ADDRESS *, ADDRESS *, ADDRESS *, ADDRESS *, const char *,
239                      int);
240 int mutt_is_mail_list (ADDRESS *);
241 int mutt_is_list_cc (int, ADDRESS *, ADDRESS *);
242 int mutt_is_list_recipient (int, ADDRESS *, ADDRESS *);
243 int mutt_is_subscribed_list (ADDRESS *);
244 int mutt_is_text_part (BODY *);
245 int mutt_is_valid_mailbox (const char *);
246 int mutt_lookup_mime_type (BODY *, const char *);
247 int mutt_match_spam_list (const char *, SPAM_LIST *, char *, int);
248 int mutt_multi_choice (char *prompt, char *letters);
249 int mutt_needs_mailcap (BODY *);
250 int mutt_num_postponed (int);
251 int mutt_parse_bind (BUFFER *, BUFFER *, unsigned long, BUFFER *);
252 int mutt_parse_exec (BUFFER *, BUFFER *, unsigned long, BUFFER *);
253 int mutt_parse_color (BUFFER *, BUFFER *, unsigned long, BUFFER *);
254 int mutt_parse_uncolor (BUFFER *, BUFFER *, unsigned long, BUFFER *);
255 int mutt_parse_hook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
256 int mutt_parse_macro (BUFFER *, BUFFER *, unsigned long, BUFFER *);
257 int mutt_parse_mono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
258 int mutt_parse_unmono (BUFFER *, BUFFER *, unsigned long, BUFFER *);
259 int mutt_parse_push (BUFFER *, BUFFER *, unsigned long, BUFFER *);
260 int mutt_parse_rc_line ( /* const */ char *, BUFFER *, BUFFER *);
261 int mutt_parse_rfc822_line (ENVELOPE * e, HEADER * hdr, char *line, char *p,
262                             short user_hdrs, short weed, short do_2047,
263                             LIST ** lastp);
264 int mutt_parse_score (BUFFER *, BUFFER *, unsigned long, BUFFER *);
265 int mutt_parse_unscore (BUFFER *, BUFFER *, unsigned long, BUFFER *);
266 int mutt_parse_unhook (BUFFER *, BUFFER *, unsigned long, BUFFER *);
267 int mutt_pattern_func (int, char *);
268 int mutt_query_complete (char *, size_t);
269 int mutt_query_variables (LIST * queries);
270 int _mutt_save_message (HEADER *, CONTEXT *, int, int, int);
271 int mutt_save_message (HEADER *, int, int, int, int *);
272 int mutt_search_command (int, int);
273 int mutt_skipchars (const char *, const char *);
274 int mutt_strwidth (const char *);
275 int mutt_compose_menu (HEADER *, char *, size_t, HEADER *);
276 int mutt_thread_set_flag (HEADER *, int, int, int);
277 int mutt_user_is_recipient (HEADER *);
278 void mutt_update_num_postponed (void);
279 int mutt_wait_filter (pid_t);
280 int mutt_which_case (const char *);
281 int mutt_write_fcc (const char *path, HEADER * hdr, const char *msgid, int,
282                     char *);
283 int mutt_write_mime_body (BODY *, FILE *);
284 int mutt_write_mime_header (BODY *, FILE *);
285 int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int);
286 int mutt_yesorno (const char *, int);
287 void mutt_set_header_color (CONTEXT *, HEADER *);
288 void mutt_sleep (short);
289 int mutt_save_confirm (const char *, struct stat *);
290
291 int mh_valid_message (const char *);
292
293 pid_t mutt_create_filter (const char *, FILE **, FILE **, FILE **);
294 pid_t mutt_create_filter_fd (const char *, FILE **, FILE **, FILE **, int,
295                              int, int);
296
297 /* base64.c */
298 void mutt_to_base64 (unsigned char *, const unsigned char *, size_t, size_t);
299 int mutt_from_base64 (char *, const char *);
300
301 /* utf8.c */
302 int mutt_wctoutf8 (char *s, unsigned int c);
303
304 #ifdef LOCALES_HACK
305 #define IsPrint(c) (isprint((unsigned char)(c)) || \
306         ((unsigned char)(c) >= 0xa0))
307 #define IsWPrint(wc) (iswprint(wc) || wc >= 0xa0)
308 #else
309 #define IsPrint(c) (isprint((unsigned char)(c)) || \
310         (option (OPTLOCALES) ? 0 : \
311         ((unsigned char)(c) >= 0xa0)))
312 #define IsWPrint(wc) (iswprint(wc) || \
313         (option (OPTLOCALES) ? 0 : (wc >= 0xa0)))
314 #endif
315
316 #define new_pattern() mem_calloc(1, sizeof (pattern_t))
317
318 int mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags,
319                        CONTEXT * ctx, HEADER * h);
320 pattern_t *mutt_pattern_comp ( /* const */ char *s, int flags, BUFFER * err);
321 void mutt_check_simple (char *s, size_t len, const char *simple);
322 void mutt_pattern_free (pattern_t ** pat);
323
324 /* ----------------------------------------------------------------------------
325  * Prototypes for broken systems
326  */
327
328 #ifdef HAVE_SRAND48
329 #define LRAND lrand48
330 #define SRAND srand48
331 #define DRAND drand48
332 #else
333 #define LRAND rand
334 #define SRAND srand
335 #define DRAND (double)rand
336 #endif /* HAVE_SRAND48 */
337
338 /* HP-UX, ConvexOS and UNIXware don't have this macro */
339 #ifndef S_ISLNK
340 #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK ? 1 : 0)
341 #endif
342
343 int getdnsdomainname (char *, size_t);
344
345 /* According to SCO support, this is how to detect SCO */
346 #if defined (_M_UNIX) || defined (M_OS)
347 #define SCO
348 #endif
349
350 /* SCO Unix uses chsize() instead of ftruncate() */
351 #ifndef HAVE_FTRUNCATE
352 #define ftruncate chsize
353 #endif
354
355 #ifndef HAVE_SNPRINTF
356 extern int snprintf (char *, size_t, const char *, ...);
357 #endif
358
359 #ifndef HAVE_VSNPRINTF
360 extern int vsnprintf (char *, size_t, const char *, va_list);
361 #endif
362
363 #ifndef HAVE_STRERROR
364 #ifndef STDC_HEADERS
365 extern int sys_nerr;
366 extern char *sys_errlist[];
367 #endif
368
369 #define strerror(x) ((x) > 0 && (x) < sys_nerr) ? sys_errlist[(x)] : 0
370 #endif /* !HAVE_STRERROR */
371
372 #ifndef HAVE_MEMMOVE
373 #define memmove(d,s,n) bcopy((s),(d),(n))
374 #endif
375
376 /* AIX doesn't define these in any headers (sigh) */
377 int strcasecmp (const char *, const char *);
378 int strncasecmp (const char *, const char *, size_t);
379
380 #ifdef _AIX
381 int setegid (gid_t);
382 #endif /* _AIX */
383
384 #ifndef STDC_HEADERS
385 extern FILE *fdopen ();
386 extern int system ();
387 extern int puts ();
388 extern int fputs ();
389 extern int fputc ();
390 extern int fseeko ();
391 extern char *strchr ();
392 extern int getopt ();
393 extern int fputs ();
394 extern int fputc ();
395 extern int fclose ();
396 extern int fprintf ();
397 extern int printf ();
398 extern int fgetc ();
399 extern int tolower ();
400 extern int toupper ();
401 extern int sscanf ();
402 extern size_t fread ();
403 extern size_t fwrite ();
404 extern int system ();
405 extern int rename ();
406 extern time_t time ();
407 extern struct tm *localtime ();
408 extern char *asctime ();
409 extern char *strpbrk ();
410 extern int fflush ();
411 extern long lrand48 ();
412 extern void srand48 ();
413 extern time_t mktime ();
414 extern int vsprintf ();
415 extern int ungetc ();
416 extern char *mktemp ();
417 extern int ftruncate ();
418 extern void *memset ();
419 extern int pclose ();
420 extern int socket ();
421 extern int connect ();
422 extern size_t strftime ();
423 extern int lstat ();
424 extern void rewind ();
425 extern int readlink ();
426
427 /* IRIX barfs on empty var decls because the system include file uses elipsis
428    in the declaration.  So declare all the args to avoid compiler errors.  This
429    should be harmless on other systems.  */
430 int ioctl (int, int, ...);
431
432 #endif
433
434 /* unsorted */
435 void ci_bounce_message (HEADER *, int *);
436 int ci_send_message (int, HEADER *, char *, CONTEXT *, HEADER *);