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