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