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