Drop obsoleted smin()/smax()
[s-mailx.git] / nail.h
blobd75e8450af4cd147095ad9bc8fb05336d11040fd
1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ Header inclusion, macros, constants, types and the global var declarations.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2013 Steffen "Daode" Nurpmeso <sdaoden@users.sf.net>.
6 */
7 /*
8 * Copyright (c) 1980, 1993
9 * The Regents of the University of California. All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
41 * Mail -- a mail program
43 * Author: Kurt Shoens (UCB) March 25, 1978
46 #include "config.h"
48 #include <sys/stat.h>
49 #include <sys/types.h>
51 #include <errno.h>
52 #include <limits.h>
53 #include <setjmp.h>
54 #include <signal.h>
55 #include <stdarg.h>
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59 #include <termios.h>
60 #include <time.h>
61 #include <unistd.h>
63 #if defined __STDC_VERSION__ && __STDC_VERSION__ + 0 >= 199901L
64 # include <stdint.h>
65 #else
66 # include <inttypes.h>
67 #endif
69 #ifdef HAVE_DEBUG
70 # include <assert.h>
71 #endif
72 #ifdef HAVE_ICONV
73 # include <iconv.h>
74 #endif
75 #ifdef HAVE_C90AMEND1
76 # include <wchar.h>
77 # include <wctype.h>
78 #endif
81 * CC support, generic macros etc.
84 #undef __PREREQ
85 #if defined __GNUC__ || defined __clang__
86 # define __EXTEN __extension__
87 # ifdef __GNUC__
88 # define __PREREQ(X,Y) \
89 (__GNUC__ > (X) || (__GNUC__ == (X) && __GNUC_MINOR__ >= (Y)))
90 # else
91 # define __PREREQ(X,Y) 1
92 # endif
93 #else
94 # define __EXTEN
95 # define __PREREQ(X,Y) 0
96 #endif
98 #define EMPTY_FILE(F) typedef int CONCAT(avoid_empty_file__, F);
100 /* Pointer to size_t */
101 #define PTR2SIZE(X) ((size_t)(uintptr_t)(X))
103 /* Pointer comparison (types from below) */
104 #define PTRCMP(A,C,B) ((uintptr_t)(A) C (uintptr_t)(B))
106 /* Ditto, compare (maybe mixed-signed) integers cases to T bits, unsigned;
107 * Note: doesn't sign-extend correctly, that's still up to the caller */
108 #define UICMP(T,A,C,B) ((ui ## T ## _t)(A) C (ui ## T ## _t)(B))
110 /* Members in constant array */
111 #ifndef NELEM
112 # define NELEM(A) (sizeof(A) / sizeof(A[0]))
113 #endif
115 /* sizeof() for member fields */
116 #define SIZEOF_FIELD(T,F) sizeof(((T *)NULL)->F)
118 /* Casts-away (*NOT* cast-away) */
119 #define UNUSED(X) ((void)(X))
120 #define UNCONST(P) ((void*)(uintptr_t)(void const*)(P))
121 #define UNVOLATILE(P) ((void*)(uintptr_t)(void volatile*)(P))
122 #define UNXXX(T,C,P) ((T)(uintptr_t)(C)(P))
124 /* __STDC_VERSION__ is ISO C99, so also use __STDC__, which should work */
125 #if defined __STDC__ || defined __STDC_VERSION__ /*|| defined __cplusplus*/
126 # define STRING(X) #X
127 # define XSTRING(X) STRING(X)
128 # define CONCAT(S1,S2) _CONCAT(S1, S2)
129 # define _CONCAT(S1,S2) S1 ## S2
130 #else
131 # define STRING(X) "X"
132 # define XSTRING STRING
133 # define CONCAT(S1,S2) S1/**/S2
134 #endif
136 #if defined __STDC_VERSION__ && __STDC_VERSION__ + 0 >= 199901L
137 /* Variable size arrays and structure fields */
138 # define VFIELD_SIZE(X)
139 # define VFIELD_SIZEOF(T,F) (0)
140 /* Inline functions */
141 # define HAVE_INLINE
142 # define INLINE inline
143 # define SINLINE static inline
144 #else
145 # define VFIELD_SIZE(X) (X)
146 # define VFIELD_SIZEOF(T,F) SIZEOF_FIELD(T, F)
147 # if __PREREQ(2, 9)
148 # define INLINE static __inline
149 # define SINLINE static __inline
150 # else
151 # define INLINE
152 # define SINLINE static
153 # endif
154 #endif
156 #if defined __predict_true && defined __predict_false
157 # define LIKELY(X) __predict_true(X)
158 # define UNLIKELY(X) __predict_false(X)
159 #elif __PREREQ(2, 96)
160 # define LIKELY(X) __builtin_expect(X, 1)
161 # define UNLIKELY(X) __builtin_expect(X, 0)
162 #else
163 # define LIKELY(X) (X)
164 # define UNLIKELY(X) (X)
165 #endif
167 /* Compile-Time-Assert */
168 #define CTA(TEST) _CTA_1(TEST, __LINE__)
169 #define _CTA_1(TEST,L) _CTA_2(TEST, L)
170 #define _CTA_2(TEST,L) \
171 typedef char COMPILE_TIME_ASSERT_failed_at_line_ ## L[(TEST) ? 1 : -1]
173 #undef ISPOW2
174 #define ISPOW2(X) ((((X) - 1) & (X)) == 0)
175 #undef MIN
176 #define MIN(A, B) ((A) < (B) ? (A) : (B))
177 #undef MAX
178 #define MAX(A, B) ((A) < (B) ? (B) : (A))
179 #undef ABS
180 #define ABS(A) ((A) < 0 ? -(A) : (A))
182 #ifndef HAVE_DEBUG
183 # undef assert
184 # define assert(X) UNUSED(0)
185 #endif
187 /* Translation (init in main.c) */
188 #undef tr
189 #ifdef HAVE_CATGETS
190 # define CATSET 1
191 # define tr(c,d) catgets(catd, CATSET, c, d)
192 #else
193 # define tr(c,d) (d)
194 #endif
197 * Constants, some nail-specific macros
200 #if !defined NI_MAXHOST || NI_MAXHOST < 1025
201 # undef NI_MAXHOST
202 # define NI_MAXHOST 1025
203 #endif
205 #ifndef MAXPATHLEN
206 # ifdef PATH_MAX
207 # define MAXPATHLEN PATH_MAX
208 # else
209 # define MAXPATHLEN 1024
210 # endif
211 #elif defined PATH_MAX && MAXPATHLEN < PATH_MAX
212 # undef MAXPATHLEN
213 # define MAXPATHLEN PATH_MAX
214 #endif
216 #ifndef STDIN_FILENO
217 # define STDIN_FILENO 0
218 #endif
219 #ifndef STDOUT_FILENO
220 # define STDOUT_FILENO 1
221 #endif
222 #ifndef STDERR_FILENO
223 # define STDERR_FILENO 2
224 #endif
226 #ifdef NSIG_MAX
227 # undef NSIG
228 # define NSIG NSIG_MAX
229 #elif ! defined NSIG
230 # define NSIG ((sizeof(sigset_t) * 8) - 1)
231 #endif
233 /* */
235 #if BUFSIZ > 2560 /* TODO simply use BUFSIZ? */
236 # define LINESIZE BUFSIZ /* max readable line width */
237 #else
238 # define LINESIZE 2560
239 #endif
240 #define BUFFER_SIZE (BUFSIZ >= (1u << 13) ? BUFSIZ : (1u << 14))
242 #define CBAD (-15555)
243 #define APPEND /* New mail goes to end of mailbox */
244 #define ESCAPE '~' /* Default escape for sending */
245 #define HIST_SIZE 242 /* tty.c: history list default size */
246 #define HSHSIZE 23 /* Hash prime (aliases, vars, macros) */
247 #define MAXARGC 1024 /* Maximum list of raw strings */
248 #define MAXEXP 25 /* Maximum expansion of aliases */
249 #define PROMPT_BUFFER_SIZE 80 /* getprompt() bufsize (> 3!) */
251 #define ACCOUNT_NULL "null" /* Name of "null" account */
252 #define MAILRC "~/.mailrc"
253 #define TMPDIR_FALLBACK "/tmp"
255 #define FROM_DATEBUF 64 /* Size of RFC 4155 From_ line date */
256 #define DATE_DAYSYEAR 365L
257 #define DATE_SECSMIN 60L
258 #define DATE_MINSHOUR 60L
259 #define DATE_HOURSDAY 24L
260 #define DATE_SECSDAY (DATE_SECSMIN * DATE_MINSHOUR * DATE_HOURSDAY)
262 /* Default *encoding* as enum conversion below */
263 #define MIME_DEFAULT_ENCODING CONV_TOQP
265 /* Maximum allowed line length in a mail before QP folding is necessary), and
266 * the real limit we go for */
267 #define MIME_LINELEN_MAX 1000
268 #define MIME_LINELEN_LIMIT (MIME_LINELEN_MAX - 50)
270 /* Locations of mime.types(5) */
271 #define MIME_TYPES_USR "~/.mime.types"
272 #define MIME_TYPES_SYS "/etc/mime.types"
274 /* Fallback MIME charsets, if *charset-7bit* and *charset-8bit* or not set */
275 #define CHARSET_7BIT "US-ASCII"
276 #ifdef HAVE_ICONV
277 # define CHARSET_8BIT "UTF-8"
278 # define CHARSET_8BIT_VAR "charset-8bit"
279 #else
280 # define CHARSET_8BIT "ISO-8859-1"
281 # define CHARSET_8BIT_VAR "ttycharset"
282 #endif
284 /* Is *W* a quoting (ASCII only) character? */
285 #define ISQUOTE(W) \
286 ((W) == L'>' || (W) == L'|' || (W) == L'}' || (W) == L':')
288 /* Maximum number of quote characters (not bytes!) that'll be used on
289 * follow lines when compressing leading quote characters */
290 #define QUOTE_MAX 42
292 /* How much spaces should a <tab> count when *quote-fold*ing? (power-of-two!) */
293 #define QUOTE_TAB_SPACES 8
295 /* Maximum size of a message that is passed through to the spam system */
296 #define SPAM_MAXSIZE 420000
298 /* String dope: dynamic buffer size, and size of the single builtin one that's
299 * used first */
300 #define SBUFFER_SIZE 0x18000u
301 #define SBUFFER_BUILTIN 0x2000u
303 /* These come from the configuration (named Xxy to not clash with sh(1)..) */
304 #ifndef XSHELL
305 # define XSHELL "/bin/sh"
306 #endif
307 #define SHELL XSHELL
308 #ifndef XLISTER
309 # define XLISTER "ls"
310 #endif
311 #define LISTER XLISTER
312 #ifndef XPAGER
313 # define XPAGER "more"
314 #endif
315 #define PAGER XPAGER
318 * Types
321 /* TODO convert all integer types to the new [su]i(8|16|32|64)_t */
322 typedef unsigned long ul_it;
323 typedef unsigned int ui_it;
324 typedef unsigned short us_it;
325 typedef unsigned char uc_it;
327 typedef signed long sl_it;
328 typedef signed int si_it;
329 typedef signed short ss_it;
330 typedef signed char sc_it;
332 #ifdef UINT8_MAX
333 # define UI8_MAX UINT8_MAX
334 # define SI8_MIN INT8_MIN
335 # define SI8_MAX INT8_MAX
336 typedef uint8_t ui8_t;
337 typedef int8_t si8_t;
338 #elif UCHAR_MAX != 255
339 # error UCHAR_MAX must be 255
340 #else
341 # define UI8_MAX UCHAR_MAX
342 # define SI8_MIN CHAR_MIN
343 # define SI8_MAX CHAR_MAX
344 typedef unsigned char ui8_t;
345 typedef signed char si8_t;
346 #endif
348 #ifdef UINT16_MAX
349 # define UI16_MAX UINT16_MAX
350 # define SI16_MIN INT16_MIN
351 # define SI16_MAX INT16_MAX
352 typedef uint16_t ui16_t;
353 typedef int16_t si16_t;
354 #elif USHRT_MAX != 0xFFFFu
355 # error USHRT_MAX must be 0xFFFF
356 #else
357 # define UI16_MAX USHRT_MAX
358 # define SI16_MIN SHRT_MIN
359 # define SI16_MAX SHRT_MAX
360 typedef unsigned short ui16_t;
361 typedef signed short si16_t;
362 #endif
364 #ifdef UINT32_MAX
365 # define UI32_MAX UINT32_MAX
366 # define SI32_MIN INT32_MIN
367 # define SI32_MAX INT32_MAX
368 typedef uint32_t ui32_t;
369 typedef int32_t si32_t;
370 #elif ULONG_MAX == 0xFFFFFFFFu
371 # define UI32_MAX ULONG_MAX
372 # define SI32_MIN LONG_MIN
373 # define SI32_MAX LONG_MAX
374 typedef unsigned long int ui32_t;
375 typedef signed long int si32_t;
376 #elif UINT_MAX != 0xFFFFFFFFu
377 # error UINT_MAX must be 0xFFFFFFFF
378 #else
379 # define UI32_MAX UINT_MAX
380 # define SI32_MIN INT_MIN
381 # define SI32_MAX INT_MAX
382 typedef unsigned int ui32_t;
383 typedef signed int si32_t;
384 #endif
386 #ifdef UINT64_MAX
387 # define UI64_MAX UINT64_MAX
388 # define SI64_MIN INT64_MIN
389 # define SI64_MAX INT64_MAX
390 typedef uint64_t ui64_t;
391 #elif ULONG_MAX <= 0xFFFFFFFFu
392 # if !defined ULLONG_MAX || ULLONG_MAX != 0xFFFFFFFFFFFFFFFFu
393 # error We need a 64 bit integer
394 # else
395 # define UI64_MAX ULLONG_MAX
396 # define SI64_MIN LLONG_MIN
397 # define SI64_MAX LLONG_MAX
398 __EXTEN typedef unsigned long long ui64_t;
399 __EXTEN typedef signed long long si64_t;
400 # endif
401 #else
402 # define UI64_MAX ULONG_MAX
403 # define SI64_MIN LONG_MIN
404 # define SI64_MAX LONG_MAX
405 typedef unsigned long ui64_t;
406 typedef signed long si64_t;
407 #endif
409 /* (So that we can use UICMP() for size_t comparison, too) */
410 typedef size_t uiz_t;
411 /*typedef ssize_t siz_t;*/
413 #ifndef UINTPTR_MAX
414 # ifdef SIZE_MAX
415 # define uintptr_t size_t
416 # define UINTPTR_MAX SIZE_MAX
417 # else
418 # define uintptr_t unsigned long
419 # define UINTPTR_MAX ULONG_MAX
420 # endif
421 #endif
423 /* XXX Note we don't really deal with that the right way in that we pass size_t
424 * XXX arguments without casting; should do, because above we assert UINT_MAX
425 * XXX is indeed ui32_t */
426 #if defined __STDC_VERSION__ && __STDC_VERSION__ + 0 >= 199901L
427 # define ZFMT "zu"
428 #elif defined SIZE_MAX && SIZE_MAX == 0xFFFFFFFFu && ULONG_MAX != UINT_MAX
429 # define ZFMT "u"
430 #endif
431 #ifndef ZFMT
432 # define ZFMT "lu"
433 #endif
435 typedef enum {FAL0, TRU1} bool_t;
437 typedef void ( *sighandler_type)(int);
439 enum user_options {
440 OPT_NONE = 0,
441 OPT_DEBUG = 1u<< 0, /* -d / *debug* */
442 OPT_VERBOSE = 1u<< 1, /* -v / *verbose* */
443 OPT_EXISTONLY = 1u<< 2, /* -e */
444 OPT_HEADERSONLY = 1u<< 3, /* -H */
445 OPT_NOSRC = 1u<< 4, /* -n */
446 OPT_E_FLAG = 1u<< 5, /* -E / *skipemptybody* */
447 OPT_F_FLAG = 1u<< 6, /* -F */
448 OPT_N_FLAG = 1u<< 7, /* -N / *header* */
449 OPT_R_FLAG = 1u<< 8, /* -R */
450 OPT_r_FLAG = 1u<< 9, /* -r (plus option_r_arg) */
451 OPT_t_FLAG = 1u<<10, /* -t */
452 OPT_u_FLAG = 1u<<11, /* -u given, or USER != getpwnam(3) */
453 OPT_TILDE_FLAG = 1u<<12, /* -~ */
454 OPT_BATCH_FLAG = 1u<<13, /* -# */
456 OPT_SENDMODE = 1u<<14, /* Usage case forces send mode */
457 OPT_INTERACTIVE = 1u<<15, /* isatty(0) */
458 OPT_TTYIN = OPT_INTERACTIVE,
459 OPT_TTYOUT = 1u<<16
461 #define IS_TTY_SESSION() \
462 ((options & (OPT_TTYIN | OPT_TTYOUT)) == (OPT_TTYIN | OPT_TTYOUT))
464 enum exit_status {
465 EXIT_OK = EXIT_SUCCESS,
466 EXIT_ERR = EXIT_FAILURE,
467 EXIT_COLL_ABORT = 1<<1, /* Message collection was aborted */
468 EXIT_SEND_ERROR = 1<<2 /* Unspecified send error occurred */
471 enum fexp_mode {
472 FEXP_FULL, /* Full expansion */
473 FEXP_LOCAL = 1<<0, /* Result must be local file/maildir */
474 FEXP_SHELL = 1<<1, /* No folder %,#,&,+ stuff, yet sh(1) */
475 FEXP_NSHORTCUT = 1<<2, /* Don't expand shortcuts */
476 FEXP_SILENT = 1<<3, /* Don't print but only return errors */
477 FEXP_MULTIOK = 1<<4 /* Expansion to many entries is ok */
480 enum lned_mode {
481 LNED_NONE = 0,
482 LNED_LF_ESC = 1<<0, /* LF can be backslash escaped */
483 LNED_HIST_ADD = 1<<1 /* Add completed line to history */
486 /* <0 means "stop" unless *prompt* extensions are enabled. */
487 enum prompt_exp {
488 PROMPT_STOP = -1, /* \c */
489 /* *prompt* extensions: \$, \@ etc. */
490 PROMPT_DOLLAR = -2,
491 PROMPT_AT = -3
494 enum okay {
495 STOP = 0,
496 OKAY = 1
499 enum mimeenc {
500 MIME_NONE, /* message is not in MIME format */
501 MIME_BIN, /* message is in binary encoding */
502 MIME_8B, /* message is in 8bit encoding */
503 MIME_7B, /* message is in 7bit encoding */
504 MIME_QP, /* message is quoted-printable */
505 MIME_B64 /* message is in base64 encoding */
508 enum conversion {
509 CONV_NONE, /* no conversion */
510 CONV_7BIT, /* no conversion, is 7bit */
511 CONV_FROMQP, /* convert from quoted-printable */
512 CONV_TOQP, /* convert to quoted-printable */
513 CONV_8BIT, /* convert to 8bit (iconv) */
514 CONV_FROMB64, /* convert from base64 */
515 CONV_FROMB64_T, /* convert from base64/text */
516 CONV_TOB64, /* convert to base64 */
517 CONV_FROMHDR, /* convert from RFC1522 format */
518 CONV_TOHDR, /* convert to RFC1522 format */
519 CONV_TOHDR_A /* convert addresses for header */
522 enum sendaction {
523 SEND_MBOX, /* no conversion to perform */
524 SEND_RFC822, /* no conversion, no From_ line */
525 SEND_TODISP, /* convert to displayable form */
526 SEND_TODISP_ALL, /* same, include all MIME parts */
527 SEND_SHOW, /* convert to 'show' command form */
528 SEND_TOSRCH, /* convert for IMAP SEARCH */
529 SEND_TOFLTR, /* convert for spam mail filtering */
530 SEND_TOFILE, /* convert for saving body to a file */
531 SEND_TOPIPE, /* convert for pipe-content/subc. */
532 SEND_QUOTE, /* convert for quoting */
533 SEND_QUOTE_ALL, /* same, include all MIME parts */
534 SEND_DECRYPT /* decrypt */
537 enum mimecontent {
538 MIME_UNKNOWN, /* unknown content */
539 MIME_SUBHDR, /* inside a multipart subheader */
540 MIME_822, /* message/rfc822 content */
541 MIME_MESSAGE, /* other message/ content */
542 MIME_TEXT_PLAIN, /* text/plain content */
543 MIME_TEXT_HTML, /* text/html content */
544 MIME_TEXT, /* other text/ content */
545 MIME_ALTERNATIVE, /* multipart/alternative content */
546 MIME_DIGEST, /* multipart/digest content */
547 MIME_MULTI, /* other multipart/ content */
548 MIME_PKCS7, /* PKCS7 content */
549 MIME_DISCARD /* content is discarded */
552 enum tdflags {
553 TD_NONE = 0, /* no display conversion */
554 TD_ISPR = 1<<0, /* use isprint() checks */
555 TD_ICONV = 1<<1, /* use iconv() */
556 TD_DELCTRL = 1<<2, /* delete control characters */
559 * NOTE: _TD_EOF and _TD_BUFCOPY may be ORd with enum conversion and
560 * enum sendaction, and may thus NOT clash with their bit range!
562 _TD_EOF = 1<<14,/* EOF seen, last round! */
563 _TD_BUFCOPY = 1<<15 /* Buffer may be constant, copy it */
566 enum protocol {
567 PROTO_FILE, /* refers to a local file */
568 PROTO_POP3, /* is a pop3 server string */
569 PROTO_IMAP, /* is an imap server string */
570 PROTO_MAILDIR, /* refers to a maildir folder */
571 PROTO_UNKNOWN /* unknown protocol */
574 #ifdef HAVE_SSL
575 enum ssl_vrfy_level {
576 VRFY_IGNORE,
577 VRFY_WARN,
578 VRFY_ASK,
579 VRFY_STRICT
581 #endif
583 struct str {
584 char *s; /* the string's content */
585 size_t l; /* the stings's length */
588 struct time_current {
589 time_t tc_time;
590 struct tm tc_gm;
591 struct tm tc_local;
592 char tc_ctime[32];
595 struct quoteflt {
596 FILE *qf_os; /* Output stream */
597 char const *qf_pfix;
598 ui_it qf_pfix_len; /* Length of prefix: 0: bypass */
599 ui_it qf_qfold_min; /* Simple way: wrote prefix? */
600 #ifdef HAVE_QUOTE_FOLD
601 ui_it qf_qfold_max; /* Otherwise: line lengths */
602 uc_it qf_state; /* *quote-fold* state machine */
603 bool_t qf_brk_isws; /* Breakpoint is at WS */
604 uc_it __dummy[2];
605 ui_it qf_wscnt; /* Whitespace count */
606 ui_it qf_brkl; /* Breakpoint */
607 ui_it qf_brkw; /* Visual width, breakpoint */
608 ui_it qf_datw; /* Current visual output line width */
609 struct str qf_dat; /* Current visual output line */
610 struct str qf_currq; /* Current quote, compressed */
611 mbstate_t qf_mbps[2];
612 #endif
615 struct termios_state {
616 struct termios ts_tios;
617 char *ts_linebuf;
618 size_t ts_linesize;
619 bool_t ts_needs_reset;
622 #define termios_state_reset() \
623 do {\
624 if (termios_state.ts_needs_reset) {\
625 tcsetattr(0, TCSADRAIN, &termios_state.ts_tios);\
626 termios_state.ts_needs_reset = FAL0;\
628 } while (0)
630 struct sock { /* data associated with a socket */
631 int s_fd; /* file descriptor */
632 #ifdef HAVE_SSL
633 int s_use_ssl; /* SSL is used */
634 # ifdef HAVE_OPENSSL
635 void *s_ssl; /* SSL object */
636 void *s_ctx; /* SSL context object */
637 # endif
638 #endif
639 char *s_wbuf; /* for buffered writes */
640 int s_wbufsize; /* allocated size of s_buf */
641 int s_wbufpos; /* position of first empty data byte */
642 char *s_rbufptr; /* read pointer to s_rbuf */
643 int s_rsz; /* size of last read in s_rbuf */
644 char const *s_desc; /* description of error messages */
645 void (*s_onclose)(void); /* execute on close */
646 char s_rbuf[LINESIZE + 1]; /* for buffered reads */
649 struct mailbox {
650 enum {
651 MB_NONE = 000, /* no reply expected */
652 MB_COMD = 001, /* command reply expected */
653 MB_MULT = 002, /* multiline reply expected */
654 MB_PREAUTH = 004, /* not in authenticated state */
655 MB_BYE = 010 /* may accept a BYE state */
656 } mb_active;
657 FILE *mb_itf; /* temp file with messages, read open */
658 FILE *mb_otf; /* same, write open */
659 char *mb_sorted; /* sort method */
660 enum {
661 MB_VOID, /* no type (e. g. connection failed) */
662 MB_FILE, /* local file */
663 MB_POP3, /* POP3 mailbox */
664 MB_IMAP, /* IMAP mailbox */
665 MB_MAILDIR, /* maildir folder */
666 MB_CACHE /* cached mailbox */
667 } mb_type; /* type of mailbox */
668 enum {
669 MB_DELE = 01, /* may delete messages in mailbox */
670 MB_EDIT = 02 /* may edit messages in mailbox */
671 } mb_perm;
672 int mb_compressed; /* is a compressed mbox file */
673 int mb_threaded; /* mailbox has been threaded */
674 #ifdef HAVE_IMAP
675 enum mbflags {
676 MB_NOFLAGS = 000,
677 MB_UIDPLUS = 001 /* supports IMAP UIDPLUS */
678 } mb_flags;
679 unsigned long mb_uidvalidity; /* IMAP unique identifier validity */
680 char *mb_imap_account; /* name of current IMAP account */
681 char *mb_imap_mailbox; /* name of current IMAP mailbox */
682 char *mb_cache_directory; /* name of cache directory */
683 #endif
684 struct sock mb_sock; /* socket structure */
687 enum needspec {
688 NEED_UNSPEC, /* unspecified need, don't fetch */
689 NEED_HEADER, /* need the header of a message */
690 NEED_BODY /* need header and body of a message */
693 enum havespec {
694 HAVE_NOTHING = 0, /* nothing downloaded yet */
695 HAVE_HEADER = 01, /* header is downloaded */
696 HAVE_BODY = 02 /* entire message is downloaded */
700 * flag bits. Attention: Flags that are used in cache.c may not change.
702 enum mflag {
703 MUSED = (1<<0), /* entry is used, but this bit isn't */
704 MDELETED = (1<<1), /* entry has been deleted */
705 MSAVED = (1<<2), /* entry has been saved */
706 MTOUCH = (1<<3), /* entry has been noticed */
707 MPRESERVE = (1<<4), /* keep entry in sys mailbox */
708 MMARK = (1<<5), /* message is marked! */
709 MODIFY = (1<<6), /* message has been modified */
710 MNEW = (1<<7), /* message has never been seen */
711 MREAD = (1<<8), /* message has been read sometime. */
712 MSTATUS = (1<<9), /* message status has changed */
713 MBOX = (1<<10), /* Send this to mbox, regardless */
714 MNOFROM = (1<<11), /* no From line */
715 MHIDDEN = (1<<12), /* message is hidden to user */
716 MFULLYCACHED = (1<<13), /* message is completely cached */
717 MBOXED = (1<<14), /* message has been sent to mbox */
718 MUNLINKED = (1<<15), /* message was unlinked from cache */
719 MNEWEST = (1<<16), /* message is very new (newmail) */
720 MFLAG = (1<<17), /* message has been flagged recently */
721 MUNFLAG = (1<<18), /* message has been unflagged */
722 MFLAGGED = (1<<19), /* message is `flagged' */
723 MANSWER = (1<<20), /* message has been answered recently */
724 MUNANSWER = (1<<21), /* message has been unanswered */
725 MANSWERED = (1<<22), /* message is `answered' */
726 MDRAFT = (1<<23), /* message has been drafted recently */
727 MUNDRAFT = (1<<24), /* message has been undrafted */
728 MDRAFTED = (1<<25), /* message is marked as `draft' */
729 MOLDMARK = (1<<26), /* messages was marked previously */
730 MSPAM = (1<<27) /* message is classified as spam */
733 /* Oft-used mask values */
734 #define MMNORM (MDELETED | MSAVED | MHIDDEN) /* Save and deleted bits */
735 #define MMNDEL (MDELETED | MHIDDEN) /* Only deleted bit */
737 #define visible(mp) (((mp)->m_flag & MMNDEL) == 0)
739 struct mimepart {
740 enum mflag m_flag; /* flags */
741 enum havespec m_have; /* downloaded parts of the part */
742 #ifdef HAVE_SPAM
743 ui_it m_spamscore; /* Spam score as int, 24:8 bits */
744 #endif
745 int m_block; /* block number of this part */
746 size_t m_offset; /* offset in block of part */
747 size_t m_size; /* Bytes in the part */
748 size_t m_xsize; /* Bytes in the full part */
749 long m_lines; /* Lines in the message */
750 long m_xlines; /* Lines in the full message */
751 time_t m_time; /* time the message was sent */
752 char const *m_from; /* message sender */
753 struct mimepart *m_nextpart; /* next part at same level */
754 struct mimepart *m_multipart; /* parts of multipart */
755 struct mimepart *m_parent; /* enclosing multipart part */
756 char *m_ct_type; /* content-type */
757 char *m_ct_type_plain; /* content-type without specs */
758 enum mimecontent m_mimecontent; /* same in enum */
759 char const *m_charset; /* charset */
760 char *m_ct_transfer_enc; /* content-transfer-encoding */
761 enum mimeenc m_mimeenc; /* same in enum */
762 char *m_partstring; /* part level string */
763 char *m_filename; /* attachment filename */
766 struct message {
767 enum mflag m_flag; /* flags */
768 enum havespec m_have; /* downloaded parts of the message */
769 #ifdef HAVE_SPAM
770 ui_it m_spamscore; /* Spam score as int, 24:8 bits */
771 #endif
772 int m_block; /* block number of this message */
773 size_t m_offset; /* offset in block of message */
774 size_t m_size; /* Bytes in the message */
775 size_t m_xsize; /* Bytes in the full message */
776 long m_lines; /* Lines in the message */
777 long m_xlines; /* Lines in the full message */
778 time_t m_time; /* time the message was sent */
779 time_t m_date; /* time in the 'Date' field */
780 unsigned m_idhash; /* hash on Message-ID for threads */
781 struct message *m_child; /* first child of this message */
782 struct message *m_younger; /* younger brother of this message */
783 struct message *m_elder; /* elder brother of this message */
784 struct message *m_parent; /* parent of this message */
785 unsigned m_level; /* thread level of message */
786 long m_threadpos; /* position in threaded display */
787 #ifdef HAVE_IMAP
788 unsigned long m_uid; /* IMAP unique identifier */
789 #endif
790 char *m_maildir_file; /* original maildir file of msg */
791 unsigned m_maildir_hash; /* hash of file name in maildir sub */
792 int m_collapsed; /* collapsed thread information */
796 * Given a file address, determine the block number it represents.
798 #define mailx_blockof(off) ((int) ((off) / 4096))
799 #define mailx_offsetof(off) ((int) ((off) % 4096))
800 #define mailx_positionof(block, offset) ((off_t)(block) * 4096 + (offset))
803 * Argument types.
805 enum argtype {
806 MSGLIST = 0, /* Message list type */
807 STRLIST = 1, /* A pure string */
808 RAWLIST = 2, /* Shell string list */
809 NOLIST = 3, /* Just plain 0 */
810 NDMLIST = 4, /* Message list, no defaults */
811 ECHOLIST= 5, /* Like raw list, but keep quote chars */
812 P = 040, /* Autoprint dot after command */
813 I = 0100, /* Interactive command bit */
814 M = 0200, /* Legal from send mode bit */
815 W = 0400, /* Illegal when read only bit */
816 F = 01000, /* Is a conditional command */
817 T = 02000, /* Is a transparent command */
818 R = 04000, /* Cannot be called from collect */
819 A = 010000 /* Needs an active mailbox */
822 enum gfield {
823 GTO = 1, /* Grab To: line */
824 GSUBJECT= 2, /* Likewise, Subject: line */
825 GCC = 4, /* And the Cc: line */
826 GBCC = 8, /* And also the Bcc: line */
828 GNL = 16, /* Print blank line after */
829 GDEL = 32, /* Entity removed from list */
830 GCOMMA = 64, /* detract puts in commas */
831 GUA = 128, /* User-Agent field */
832 GMIME = 256, /* MIME 1.0 fields */
833 GMSGID = 512, /* a Message-ID */
834 /* 1024 */ /* unused */
835 GIDENT = 2048, /* From:, Reply-To: and Organization: field */
836 GREF = 4096, /* References: field */
837 GDATE = 8192, /* Date: field */
838 GFULL = 16384, /* include full names */
839 GSKIN = 32768, /* skin names */
840 GEXTRA = 65536, /* extra fields */
841 GFILES = 131072 /* include filename addresses */
844 #define GMASK (GTO|GSUBJECT|GCC|GBCC) /* Mask of places from whence */
847 * Structure used to pass about the current state of a message (header).
849 struct header {
850 struct name *h_to; /* Dynamic "To:" string */
851 char *h_subject; /* Subject string */
852 struct name *h_cc; /* Carbon copies string */
853 struct name *h_bcc; /* Blind carbon copies */
854 struct name *h_ref; /* References */
855 struct attachment *h_attach; /* MIME attachments */
856 char *h_charset; /* preferred charset */
857 struct name *h_from; /* overridden "From:" field */
858 struct name *h_replyto; /* overridden "Reply-To:" field */
859 struct name *h_sender; /* overridden "Sender:" field */
860 char *h_organization; /* overridden "Organization:" field */
864 * Handling of namelist nodes used in processing the recipients of mail and
865 * aliases, inspection of mail-addresses and all that kind of stuff.
868 enum nameflags {
869 NAME_NAME_SALLOC = 1<< 0, /* .n_name is doped */
870 NAME_FULLNAME_SALLOC = 1<< 1, /* .n_fullname is doped */
871 NAME_SKINNED = 1<< 2, /* Is actually skin()ned */
872 NAME_IDNA = 1<< 3, /* IDNA was applied */
873 NAME_ADDRSPEC_CHECKED = 1<< 4, /* Address has been .. and */
874 NAME_ADDRSPEC_ISFILE = 1<< 5, /* ..is a file path */
875 NAME_ADDRSPEC_ISPIPE = 1<< 6, /* ..is a command for piping */
876 NAME_ADDRSPEC_ISFILEORPIPE = NAME_ADDRSPEC_ISFILE |
877 NAME_ADDRSPEC_ISPIPE,
878 NAME_ADDRSPEC_ERR_EMPTY = 1<< 7, /* An empty string (or NULL) */
879 NAME_ADDRSPEC_ERR_ATSEQ = 1<< 8, /* Weird @ sequence */
880 NAME_ADDRSPEC_ERR_CHAR = 1<< 9, /* Invalid character */
881 NAME_ADDRSPEC_ERR_IDNA = 1<<10, /* IDNA convertion failed */
882 NAME_ADDRSPEC_INVALID = NAME_ADDRSPEC_ERR_EMPTY |
883 NAME_ADDRSPEC_ERR_ATSEQ |
884 NAME_ADDRSPEC_ERR_CHAR |
885 NAME_ADDRSPEC_ERR_IDNA,
887 _NAME_SHIFTWC = 11,
888 _NAME_MAXWC = 0xFFFFF,
889 _NAME_MASKWC = _NAME_MAXWC << _NAME_SHIFTWC
892 /* In the !_ERR_EMPTY case, the failing character can be queried */
893 #define NAME_ADDRSPEC_ERR_GETWC(F) \
894 ((((unsigned int)(F) & _NAME_MASKWC) >> _NAME_SHIFTWC) & _NAME_MAXWC)
895 #define NAME_ADDRSPEC_ERR_SET(F, E, WC) \
896 do (F) = ((F) & ~(NAME_ADDRSPEC_INVALID | _NAME_MASKWC)) | \
897 (E) | (((unsigned int)(WC) & _NAME_MAXWC) << _NAME_SHIFTWC); \
898 while (0)
900 struct name {
901 struct name *n_flink; /* Forward link in list. */
902 struct name *n_blink; /* Backward list link */
903 enum gfield n_type; /* From which list it came */
904 enum nameflags n_flags; /* enum nameflags */
905 char *n_name; /* This fella's name */
906 char *n_fullname; /* Sometimes, name including comment */
909 struct addrguts {
910 char const *ag_input; /* Input string as given */
911 size_t ag_ilen; /* strlen() of input */
912 size_t ag_iaddr_start; /* Start of *addr-spec* in .ag_input */
913 size_t ag_iaddr_aend; /* ..and one past its end */
914 char *ag_skinned; /* Output (alloced if !=.ag_input) */
915 size_t ag_slen; /* strlen() of .ag_skinned */
916 size_t ag_sdom_start; /* Start of domain in .ag_skinned, */
917 enum nameflags ag_n_flags; /* enum nameflags of .ag_skinned */
921 * MIME attachments.
924 enum attach_conv {
925 AC_DEFAULT, /* _get_lc() -> _iter_*() */
926 AC_FIX_OUTCS, /* _get_lc() -> "charset=" .a_charset */
927 AC_FIX_INCS, /* "charset=".a_input_charset (nocnv) */
928 AC_TMPFILE /* attachment.a_tmpf is converted */
931 struct attachment {
932 struct attachment *a_flink; /* Forward link in list. */
933 struct attachment *a_blink; /* Backward list link */
934 char const *a_name; /* file name */
935 char const *a_content_type; /* content type */
936 char const *a_content_disposition; /* content disposition */
937 char const *a_content_id; /* content id */
938 char const *a_content_description; /* content description */
939 char const *a_input_charset; /* Interpretation depends on .a_conv */
940 char const *a_charset; /* ... */
941 FILE *a_tmpf; /* If AC_TMPFILE */
942 enum attach_conv a_conv; /* User chosen conversion */
943 int a_msgno; /* message number */
946 struct group {
947 struct group *ge_link; /* Next person in this group */
948 char *ge_name; /* This person's user name */
951 struct grouphead {
952 struct grouphead *g_link; /* Next grouphead in list */
953 char *g_name; /* Name of this group */
954 struct group *g_list; /* Users in group. */
958 * Structure of the hash table of ignored header fields
960 struct ignoretab {
961 int i_count; /* Number of entries */
962 struct ignore {
963 struct ignore *i_link; /* Next ignored field in bucket */
964 char *i_field; /* This ignored field */
965 } *i_head[HSHSIZE];
969 * Token values returned by the scanner used for argument lists.
970 * Also, sizes of scanner-related things.
972 enum ltoken {
973 TEOL = 0, /* End of the command line */
974 TNUMBER = 1, /* A message number */
975 TDASH = 2, /* A simple dash */
976 TSTRING = 3, /* A string (possibly containing -) */
977 TDOT = 4, /* A "." */
978 TUP = 5, /* An "^" */
979 TDOLLAR = 6, /* A "$" */
980 TSTAR = 7, /* A "*" */
981 TOPEN = 8, /* An '(' */
982 TCLOSE = 9, /* A ')' */
983 TPLUS = 10, /* A '+' */
984 TERROR = 11, /* A lexical error */
985 TCOMMA = 12, /* A ',' */
986 TSEMI = 13, /* A ';' */
987 TBACK = 14 /* A '`' */
990 #define REGDEP 2 /* Maximum regret depth. */
993 * Constants for conditional commands. These describe whether
994 * we should be executing stuff or not.
996 enum condition {
997 CANY = 0, /* Execute in send or receive mode */
998 CRCV = 1, /* Execute in receive mode only */
999 CSEND = 2, /* Execute in send mode only */
1000 CTERM = 3, /* Execute only if stdin is a tty */
1001 CNONTERM= 4 /* Execute only if stdin not tty */
1005 * For the 'shortcut' and 'unshortcut' functionality.
1007 struct shortcut {
1008 struct shortcut *sh_next; /* next shortcut in list */
1009 char *sh_short; /* shortcut string */
1010 char *sh_long; /* expanded form */
1014 * Kludges to handle the change from setexit / reset to setjmp / longjmp
1016 #define setexit() (void)sigsetjmp(srbuf, 1)
1017 #define reset(x) siglongjmp(srbuf, x)
1020 * Content-Transfer-Encodings as defined in RFC 2045:
1021 * - Quoted-Printable, section 6.7
1022 * - Base64, section 6.8
1025 #define QP_LINESIZE (4 * 19 +1) /* Max. compliant QP linesize (+1) */
1027 #define B64_LINESIZE (4 * 19 +1) /* Max. compl. Base64 linesize (+1) */
1028 #define B64_ENCODE_INPUT_PER_LINE 57 /* Max. input for Base64 encode/line */
1030 /* xxx QP came later, maybe rewrite all to use mimecte_flags directly? */
1031 enum __mimecte_flags {
1032 MIMECTE_NONE,
1033 MIMECTE_SALLOC = 1<<0, /* Use salloc(), not srealloc().. */
1034 /* ..result .s,.l point to user buffer of *_LINESIZE+ bytes instead */
1035 MIMECTE_BUF = 1<<1,
1036 MIMECTE_CRLF = 1<<2, /* (encode) Append "\r\n" to lines */
1037 MIMECTE_LF = 1<<3, /* (encode) Append "\n" to lines */
1038 /* (encode) If one of _CRLF/_LF is set, honour *_LINESIZE and
1039 * inject the desired line-ending whenever a linewrap is desired */
1040 MIMECTE_MULTILINE = 1<<4,
1041 /* (encode) Quote with header rules, do not generate soft NL breaks? */
1042 MIMECTE_ISHEAD = 1<<5
1045 enum qpflags {
1046 QP_NONE = MIMECTE_NONE,
1047 QP_SALLOC = MIMECTE_SALLOC,
1048 QP_BUF = MIMECTE_BUF,
1049 QP_ISHEAD = MIMECTE_ISHEAD
1052 enum b64flags {
1053 B64_NONE = MIMECTE_NONE,
1054 B64_SALLOC = MIMECTE_SALLOC,
1055 B64_BUF = MIMECTE_BUF,
1056 B64_CRLF = MIMECTE_CRLF,
1057 B64_LF = MIMECTE_LF,
1058 B64_MULTILINE = MIMECTE_MULTILINE
1062 * Locale-independent character classes.
1065 enum {
1066 C_CNTRL = 0000,
1067 C_BLANK = 0001,
1068 C_WHITE = 0002,
1069 C_SPACE = 0004,
1070 C_PUNCT = 0010,
1071 C_OCTAL = 0020,
1072 C_DIGIT = 0040,
1073 C_UPPER = 0100,
1074 C_LOWER = 0200
1077 extern uc_it const class_char[];
1079 #define __ischarof(C, FLAGS) \
1080 (asciichar(C) && (class_char[(uc_it)(C)] & (FLAGS)) != 0)
1082 #define asciichar(c) ((uc_it)(c) <= 0177)
1083 #define alnumchar(c) __ischarof(c, C_DIGIT|C_OCTAL|C_UPPER|C_LOWER)
1084 #define alphachar(c) __ischarof(c, C_UPPER|C_LOWER)
1085 #define blankchar(c) __ischarof(c, C_BLANK)
1086 #define blankspacechar(c) __ischarof(c, C_BLANK|C_SPACE)
1087 #define cntrlchar(c) __ischarof(c, C_CNTRL)
1088 #define digitchar(c) __ischarof(c, C_DIGIT|C_OCTAL)
1089 #define lowerchar(c) __ischarof(c, C_LOWER)
1090 #define punctchar(c) __ischarof(c, C_PUNCT)
1091 #define spacechar(c) __ischarof(c, C_BLANK|C_SPACE|C_WHITE)
1092 #define upperchar(c) __ischarof(c, C_UPPER)
1093 #define whitechar(c) __ischarof(c, C_BLANK|C_WHITE)
1094 #define octalchar(c) __ischarof(c, C_OCTAL)
1096 #define upperconv(c) (lowerchar(c) ? (char)((uc_it)(c) - 'a' + 'A') : (c))
1097 #define lowerconv(c) (upperchar(c) ? (char)((uc_it)(c) - 'A' + 'a') : (c))
1098 /* RFC 822, 3.2. */
1099 #define fieldnamechar(c) \
1100 (asciichar(c) && (c) > 040 && (c) != 0177 && (c) != ':')
1103 * Try to use alloca() for some function-local buffers and data,
1104 * fall back to smalloc()/free() if not available.
1106 #ifdef HAVE_ALLOCA
1107 # define ac_alloc(n) HAVE_ALLOCA(n)
1108 # define ac_free(n) do {} while (0)
1109 #else
1110 # define ac_alloc(n) smalloc(n)
1111 # define ac_free(n) free(n)
1112 #endif
1115 * Single-threaded, use unlocked I/O.
1117 #ifdef HAVE_PUTC_UNLOCKED
1118 # undef getc
1119 # define getc(c) getc_unlocked(c)
1120 # undef putc
1121 # define putc(c, f) putc_unlocked(c, f)
1122 # undef putchar
1123 # define putchar(c) putc_unlocked((c), stdout)
1124 #endif
1127 * Truncate a file to the last character written. This is
1128 * useful just before closing an old file that was opened
1129 * for read/write.
1131 #define ftrunc(stream) do {\
1132 off_t off;\
1133 fflush(stream);\
1134 off = ftell(stream);\
1135 if (off >= 0)\
1136 ftruncate(fileno(stream), off);\
1137 } while (0)
1140 * fflush() and rewind()
1142 #define fflush_rewind(stream) do { \
1143 fflush(stream); \
1144 rewind(stream); \
1145 } while (0)
1148 * For saving the current directory and later returning.
1150 struct cw {
1151 #ifdef HAVE_FCHDIR
1152 int cw_fd;
1153 #else
1154 char cw_wd[MAXPATHLEN];
1155 #endif
1159 * Global variable declarations
1161 * These become instantiated in main.c.
1164 #undef VL
1165 #ifdef _MAIN_SOURCE
1166 # ifndef HAVE_AMALGAMATION
1167 # define VL
1168 # else
1169 # define VL static
1170 # endif
1171 #else
1172 # define VL extern
1173 #endif
1175 VL gid_t effectivegid; /* Saved from when we started up */
1176 VL gid_t realgid; /* Saved from when we started up */
1178 VL int mb_cur_max; /* Value of MB_CUR_MAX */
1179 VL int realscreenheight; /* The real screen height */
1180 VL int scrnwidth; /* Screen width, or best guess */
1181 VL int scrnheight; /* Screen height/guess (4 header) */
1182 VL int utf8; /* Locale uses UTF-8 encoding */
1183 VL int enc_has_state; /* Encoding has shift states */
1185 VL char **altnames; /* List of alternate names of user */
1186 VL char const *homedir; /* Path name of home directory */
1187 VL char const *myname; /* My login name */
1188 VL char const *progname; /* Our name */
1189 VL char const *tempdir; /* The temporary directory */
1191 VL int exit_status; /* Exit status */
1192 VL int options; /* Bits of enum user_options */
1193 VL char *option_r_arg; /* Argument to -r option */
1194 VL char const **smopts; /* sendmail(1) opts from commline */
1195 VL size_t smopts_count; /* Entries in smopts */
1197 /* TODO Join as many of these state machine bits into a single carrier! */
1198 VL int inhook; /* Currently executing a hook */
1199 VL bool_t exec_last_comm_error; /* Last execute() command failed */
1200 VL bool_t edit; /* Indicates editing a file */
1201 VL bool_t did_print_dot; /* Current message has been printed */
1202 VL bool_t msglist_is_single; /* Last NDMLIST/MSGLIST chose 1 msg */
1203 VL bool_t loading; /* Loading user definitions */
1204 VL bool_t sourcing; /* Currently reading variant file */
1205 VL bool_t sawcom; /* Set after first command */
1206 VL bool_t starting; /* Still in startup code */
1207 VL bool_t unset_allow_undefined; /* Allow to unset undefined vars */
1208 VL int noreset; /* String resets suspended */
1210 /* XXX stylish sorting */
1211 VL int msgCount; /* Count of messages read in */
1212 VL enum condition cond; /* State of conditional exc. */
1213 VL struct mailbox mb; /* Current mailbox */
1214 VL int image; /* File descriptor for msg image */
1215 VL char mailname[MAXPATHLEN]; /* Name of current file */
1216 VL char displayname[80 - 40]; /* Prettyfied for display */
1217 VL char prevfile[MAXPATHLEN]; /* Name of previous file */
1218 VL char const *account_name; /* Current account name or NULL */
1219 VL off_t mailsize; /* Size of system mailbox */
1220 VL struct message *dot; /* Pointer to current message */
1221 VL struct message *prevdot; /* Previous current message */
1222 VL struct message *message; /* The actual message structure */
1223 VL struct message *threadroot; /* first threaded message */
1224 VL int imap_created_mailbox; /* hack to get feedback from imap */
1225 VL int msgspace; /* Number of allocated struct m */
1227 VL struct grouphead *groups[HSHSIZE]; /* Pointer to active groups */
1228 VL struct ignoretab ignore[2]; /* ignored and retained fields
1229 * 0 is ignore, 1 is retain */
1230 VL struct ignoretab saveignore[2]; /* ignored and retained fields
1231 * on save to folder */
1232 VL struct ignoretab allignore[2]; /* special, ignore all headers */
1233 VL struct ignoretab fwdignore[2]; /* fields to ignore for forwarding */
1234 VL struct shortcut *shortcuts; /* list of shortcuts */
1236 VL struct time_current time_current; /* time(3); send: mail1() XXXcarrier*/
1237 VL struct termios_state termios_state; /* getpassword(); see commands().. */
1239 #ifdef HAVE_SSL
1240 VL enum ssl_vrfy_level ssl_vrfy_level; /* SSL verification level */
1241 #endif
1243 #ifdef HAVE_ICONV
1244 VL iconv_t iconvd;
1245 #endif
1247 #ifdef HAVE_CATGETS
1248 VL nl_catd catd;
1249 #endif
1251 VL sighandler_type dflpipe;
1252 VL sigjmp_buf srbuf;
1253 VL int interrupts;
1254 VL sighandler_type handlerstacktop;
1255 #define handlerpush(f) (savedtop = handlerstacktop, handlerstacktop = (f))
1256 #define handlerpop() (handlerstacktop = savedtop)
1258 /* The remaining variables need initialization */
1260 #ifndef HAVE_AMALGAMATION
1261 VL char const month_names[12 + 1][4];
1262 VL char const weekday_names[7 + 1][4];
1264 VL char const uagent[]; /* User agent */
1265 VL char const version[]; /* The version string */
1266 VL char const features[]; /* The "feature string" */
1267 #endif
1270 * Finally, let's include the function prototypes XXX embed
1273 #include "extern.h"
1275 /* vim:set fenc=utf-8:s-it-mode (TODO only partial true) */