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 - 2014 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
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
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
41 * Mail -- a mail program
43 * Author: Kurt Shoens (UCB) March 25, 1978
49 #include <sys/types.h>
63 #if defined __STDC_VERSION__ && __STDC_VERSION__ + 0 >= 199901L
66 # include <inttypes.h>
83 #ifdef HAVE_OPENSSL_MD5
84 # include <openssl/md5.h>
88 * Constants, some nail-specific macros
91 #if !defined NI_MAXHOST || NI_MAXHOST < 1025
93 # define NI_MAXHOST 1025
96 /* TODO PATH_MAX: fixed-size buffer is always wrong (think NFS) */
99 # define PATH_MAX MAXPATHLEN
101 # define PATH_MAX 1024 /* _XOPEN_PATH_MAX POSIX 2008/Cor 1-2013 */
106 # define STDIN_FILENO 0
108 #ifndef STDOUT_FILENO
109 # define STDOUT_FILENO 1
111 #ifndef STDERR_FILENO
112 # define STDERR_FILENO 2
117 # define NSIG NSIG_MAX
119 # define NSIG ((sizeof(sigset_t) * 8) - 1)
124 #if BUFSIZ > 2560 /* TODO simply use BUFSIZ? */
125 # define LINESIZE BUFSIZ /* max readable line width */
127 # define LINESIZE 2560
129 #define BUFFER_SIZE (BUFSIZ >= (1u << 13) ? BUFSIZ : (1u << 14))
131 #define CBAD (-15555)
132 #define APPEND /* New mail goes to end of mailbox */
133 #define ESCAPE '~' /* Default escape for sending */
134 #define FIO_STACK_SIZE 20 /* Maximum recursion for sourcing */
135 #define HIST_SIZE 242 /* tty.c: history list default size */
136 #define HSHSIZE 23 /* Hash prime (aliases, vars, macros) */
137 #define MAXARGC 1024 /* Maximum list of raw strings */
138 #define MAXEXP 25 /* Maximum expansion of aliases */
139 #define NYD_CALLS_MAX 1000 /* Number of NYD calls that are remembered */
140 #define PROMPT_BUFFER_SIZE 80 /* getprompt() bufsize (> 3!) */
142 #define ACCOUNT_NULL "null" /* Name of "null" account */
143 #define MAILRC "~/.mailrc"
144 #define TMPDIR_FALLBACK "/tmp"
152 #define COLOUR_MSGINFO "fg=green"
153 #define COLOUR_PARTINFO "fg=brown"
154 #define COLOUR_FROM_ "fg=brown"
155 #define COLOUR_HEADER "fg=red"
156 #define COLOUR_UHEADER "ft=bold,fg=red"
157 #define COLOUR_TERMS \
158 "cons25,linux,rxvt,rxvt-unicode,screen,sun,vt100,vt220,wsvt25,xterm"
159 #define COLOUR_USER_HEADERS "from,subject"
161 #define FROM_DATEBUF 64 /* Size of RFC 4155 From_ line date */
162 #define DATE_DAYSYEAR 365L
163 #define DATE_SECSMIN 60L
164 #define DATE_MINSHOUR 60L
165 #define DATE_HOURSDAY 24L
166 #define DATE_SECSDAY (DATE_SECSMIN * DATE_MINSHOUR * DATE_HOURSDAY)
168 /* *indentprefix* default as of POSIX */
169 #define INDENT_DEFAULT "\t"
171 /* Default *encoding* as enum conversion below */
172 #define MIME_DEFAULT_ENCODING CONV_TOQP
174 /* Maximum allowed line length in a mail before QP folding is necessary), and
175 * the real limit we go for */
176 #define MIME_LINELEN_MAX 1000
177 #define MIME_LINELEN_LIMIT (MIME_LINELEN_MAX - 50)
179 /* Locations of mime.types(5) */
180 #define MIME_TYPES_USR "~/.mime.types"
181 #define MIME_TYPES_SYS "/etc/mime.types"
183 /* Fallback MIME charsets, if *charset-7bit* and *charset-8bit* or not set */
184 #define CHARSET_7BIT "US-ASCII"
186 # define CHARSET_8BIT "UTF-8"
187 # define CHARSET_8BIT_OKEY charset_8bit
189 # define CHARSET_8BIT "ISO-8859-1"
190 # define CHARSET_8BIT_OKEY ttycharset
193 /* Is *W* a quoting (ASCII only) character? */
195 ((W) == L'>' || (W) == L'|' || (W) == L'}' || (W) == L':')
197 /* Maximum number of quote characters (not bytes!) that'll be used on
198 * follow lines when compressing leading quote characters */
201 /* How much spaces should a <tab> count when *quote-fold*ing? (power-of-two!) */
202 #define QUOTE_TAB_SPACES 8
204 /* Maximum size of a message that is passed through to the spam system */
205 #define SPAM_MAXSIZE 420000
207 /* String dope: dynamic buffer size, and size of the single builtin one that's
209 #define SBUFFER_SIZE 0x18000u
210 #define SBUFFER_BUILTIN 0x2000u
212 /* These come from the configuration (named Xxy to not clash with sh(1)..) */
214 # define XSHELL "/bin/sh"
217 # define XLISTER "ls"
220 # define XPAGER "more"
224 * CC support, generic macros etc.
228 #if defined __GNUC__ || defined __clang__
229 # define __EXTEN __extension__
231 # define __PREREQ(X,Y) \
232 (__GNUC__ > (X) || (__GNUC__ == (X) && __GNUC_MINOR__ >= (Y)))
234 # define __PREREQ(X,Y) 1
238 # define __PREREQ(X,Y) 0
241 /* For injection macros like DBG(), NATCH_CHAR() */
244 #define EMPTY_FILE(F) typedef int CONCAT(avoid_empty_file__, F);
246 /* Pointer to size_t */
247 #define PTR2SIZE(X) ((size_t)(uintptr_t)(X))
249 /* Pointer comparison (types from below) */
250 #define PTRCMP(A,C,B) ((uintptr_t)(A) C (uintptr_t)(B))
252 /* Ditto, compare (maybe mixed-signed) integers cases to T bits, unsigned;
253 * Note: doesn't sign-extend correctly, that's still up to the caller */
254 #define UICMP(T,A,C,B) ((ui ## T ## _t)(A) C (ui ## T ## _t)(B))
256 /* Members in constant array */
258 # define NELEM(A) (sizeof(A) / sizeof(A[0]))
261 /* sizeof() for member fields */
262 #define SIZEOF_FIELD(T,F) sizeof(((T *)NULL)->F)
264 /* Casts-away (*NOT* cast-away) */
265 #define UNUSED(X) ((void)(X))
266 #define UNCONST(P) ((void*)(uintptr_t)(void const*)(P))
267 #define UNVOLATILE(P) ((void*)(uintptr_t)(void volatile*)(P))
268 #define UNXXX(T,C,P) ((T)(uintptr_t)(C)(P))
270 /* __STDC_VERSION__ is ISO C99, so also use __STDC__, which should work */
271 #if defined __STDC__ || defined __STDC_VERSION__ /*|| defined __cplusplus*/
272 # define STRING(X) #X
273 # define XSTRING(X) STRING(X)
274 # define CONCAT(S1,S2) _CONCAT(S1, S2)
275 # define _CONCAT(S1,S2) S1 ## S2
277 # define STRING(X) "X"
278 # define XSTRING STRING
279 # define CONCAT(S1,S2) S1/**/S2
282 #if defined __STDC_VERSION__ && __STDC_VERSION__ + 0 >= 199901L
283 /* Variable size arrays and structure fields */
284 # define VFIELD_SIZE(X)
285 # define VFIELD_SIZEOF(T,F) (0)
286 /* Inline functions */
288 # define INLINE inline
289 # define SINLINE static inline
291 # define VFIELD_SIZE(X) (X)
292 # define VFIELD_SIZEOF(T,F) SIZEOF_FIELD(T, F)
294 # define INLINE static __inline
295 # define SINLINE static __inline
298 # define SINLINE static
303 #if defined __STDC_VERSION__ && __STDC_VERSION__ + 0 >= 199901L
304 # define __FUN__ __func__
306 # define __FUN__ __FUNCTION__
308 # define __FUN__ uagent /* Something that is not a literal */
311 #if defined __predict_true && defined __predict_false
312 # define LIKELY(X) __predict_true(X)
313 # define UNLIKELY(X) __predict_false(X)
314 #elif __PREREQ(2, 96)
315 # define LIKELY(X) __builtin_expect(X, 1)
316 # define UNLIKELY(X) __builtin_expect(X, 0)
318 # define LIKELY(X) (X)
319 # define UNLIKELY(X) (X)
322 #undef HAVE_NATCH_CHAR
324 #if defined HAVE_SETLOCALE && defined HAVE_C90AMEND1 && defined HAVE_WCWIDTH
325 # define HAVE_NATCH_CHAR
326 # define NATCH_CHAR(X) X
328 # define NATCH_CHAR(X)
331 /* Compile-Time-Assert */
332 #define CTA(TEST) _CTA_1(TEST, __LINE__)
333 #define _CTA_1(TEST,L) _CTA_2(TEST, L)
334 #define _CTA_2(TEST,L) \
335 typedef char COMPILE_TIME_ASSERT_failed_at_line_ ## L[(TEST) ? 1 : -1]
338 #define ISPOW2(X) ((((X) - 1) & (X)) == 0)
340 #define MIN(A, B) ((A) < (B) ? (A) : (B))
342 #define MAX(A, B) ((A) < (B) ? (B) : (A))
344 #define ABS(A) ((A) < 0 ? -(A) : (A))
350 # define assert(X) UNUSED(0)
358 /* Translation (init in main.c) */
362 # define tr(c,d) catgets(catd, CATSET, c, d)
371 typedef unsigned long ul_it
;
372 typedef unsigned int ui_it
;
373 typedef unsigned short us_it
;
374 typedef unsigned char uc_it
;
376 typedef signed long sl_it
;
377 typedef signed int si_it
;
378 typedef signed short ss_it
;
379 typedef signed char sc_it
;
382 # define UI8_MAX UINT8_MAX
383 # define SI8_MIN INT8_MIN
384 # define SI8_MAX INT8_MAX
385 typedef uint8_t ui8_t
;
386 typedef int8_t si8_t
;
387 #elif UCHAR_MAX != 255
388 # error UCHAR_MAX must be 255
390 # define UI8_MAX UCHAR_MAX
391 # define SI8_MIN CHAR_MIN
392 # define SI8_MAX CHAR_MAX
393 typedef unsigned char ui8_t
;
394 typedef signed char si8_t
;
398 # define UI16_MAX UINT16_MAX
399 # define SI16_MIN INT16_MIN
400 # define SI16_MAX INT16_MAX
401 typedef uint16_t ui16_t
;
402 typedef int16_t si16_t
;
403 #elif USHRT_MAX != 0xFFFFu
404 # error USHRT_MAX must be 0xFFFF
406 # define UI16_MAX USHRT_MAX
407 # define SI16_MIN SHRT_MIN
408 # define SI16_MAX SHRT_MAX
409 typedef unsigned short ui16_t
;
410 typedef signed short si16_t
;
414 # define UI32_MAX UINT32_MAX
415 # define SI32_MIN INT32_MIN
416 # define SI32_MAX INT32_MAX
417 typedef uint32_t ui32_t
;
418 typedef int32_t si32_t
;
419 #elif ULONG_MAX == 0xFFFFFFFFu
420 # define UI32_MAX ULONG_MAX
421 # define SI32_MIN LONG_MIN
422 # define SI32_MAX LONG_MAX
423 typedef unsigned long int ui32_t
;
424 typedef signed long int si32_t
;
425 #elif UINT_MAX != 0xFFFFFFFFu
426 # error UINT_MAX must be 0xFFFFFFFF
428 # define UI32_MAX UINT_MAX
429 # define SI32_MIN INT_MIN
430 # define SI32_MAX INT_MAX
431 typedef unsigned int ui32_t
;
432 typedef signed int si32_t
;
436 # define UI64_MAX UINT64_MAX
437 # define SI64_MIN INT64_MIN
438 # define SI64_MAX INT64_MAX
439 typedef uint64_t ui64_t
;
440 #elif ULONG_MAX <= 0xFFFFFFFFu
441 # if !defined ULLONG_MAX || ULLONG_MAX != 0xFFFFFFFFFFFFFFFFu
442 # error We need a 64 bit integer
444 # define UI64_MAX ULLONG_MAX
445 # define SI64_MIN LLONG_MIN
446 # define SI64_MAX LLONG_MAX
447 __EXTEN
typedef unsigned long long ui64_t
;
448 __EXTEN
typedef signed long long si64_t
;
451 # define UI64_MAX ULONG_MAX
452 # define SI64_MIN LONG_MIN
453 # define SI64_MAX LONG_MAX
454 typedef unsigned long ui64_t
;
455 typedef signed long si64_t
;
458 /* (So that we can use UICMP() for size_t comparison, too) */
459 typedef size_t uiz_t
;
460 typedef ssize_t siz_t
;
464 # define uintptr_t size_t
465 # define UINTPTR_MAX SIZE_MAX
467 # define uintptr_t unsigned long
468 # define UINTPTR_MAX ULONG_MAX
472 /* XXX Note we don't really deal with that the right way in that we pass size_t
473 * XXX arguments without casting; should do, because above we assert UINT_MAX
474 * XXX is indeed ui32_t -- CTAsserted in main.c */
475 #if defined __STDC_VERSION__ && __STDC_VERSION__ + 0 >= 199901L
477 # define __ZFMT_CTA() CTA(1 == 1)
478 #elif defined SIZE_MAX && SIZE_MAX == 0xFFFFFFFFu && ULONG_MAX != UINT_MAX
480 # define __ZFMT_CTA() CTA(sizeof(size_t) == sizeof(unsigned int))
484 # define __ZFMT_CTA() CTA(sizeof(size_t) == sizeof(unsigned long))
488 typedef si8_t bool_t
;
490 typedef void ( *sighandler_type
)(int);
494 OPT_DEBUG
= 1u<< 0, /* -d / *debug* */
495 OPT_VERB
= 1u<< 1, /* -v / *verbose* */
496 OPT_VERBVERB
= 1u<<19, /* .. even more verbosity */
497 OPT_EXISTONLY
= 1u<< 2, /* -e */
498 OPT_HEADERSONLY
= 1u<< 3, /* -H */
499 OPT_HEADERLIST
= 1u<< 4, /* -L */
500 OPT_NOSRC
= 1u<< 5, /* -n */
501 OPT_E_FLAG
= 1u<< 6, /* -E / *skipemptybody* */
502 OPT_F_FLAG
= 1u<< 7, /* -F */
503 OPT_N_FLAG
= 1u<< 8, /* -N / *header* */
504 OPT_R_FLAG
= 1u<< 9, /* -R */
505 OPT_r_FLAG
= 1u<<10, /* -r (plus option_r_arg) */
506 OPT_t_FLAG
= 1u<<11, /* -t */
507 OPT_u_FLAG
= 1u<<12, /* -u given, or USER != getpwnam(3) */
508 OPT_TILDE_FLAG
= 1u<<13, /* -~ */
509 OPT_BATCH_FLAG
= 1u<<14, /* -# */
511 OPT_SENDMODE
= 1u<<15, /* Usage case forces send mode */
512 OPT_INTERACTIVE
= 1u<<16, /* isatty(0) */
513 OPT_TTYIN
= OPT_INTERACTIVE
,
515 OPT_UNICODE
= 1u<<18, /* We're in an UTF-8 environment */
517 /* Some easy-access shortcuts */
518 OPT_D_V
= OPT_DEBUG
| OPT_VERB
,
519 OPT_D_VV
= OPT_DEBUG
| OPT_VERBVERB
521 #define IS_TTY_SESSION() \
522 ((options & (OPT_TTYIN | OPT_TTYOUT)) == (OPT_TTYIN | OPT_TTYOUT))
525 EXIT_OK
= EXIT_SUCCESS
,
526 EXIT_ERR
= EXIT_FAILURE
,
528 EXIT_COLL_ABORT
= 1<<1, /* Message collection was aborted */
529 EXIT_SEND_ERROR
= 1<<2 /* Unspecified send error occurred */
533 FEXP_FULL
, /* Full expansion */
534 FEXP_LOCAL
= 1<<0, /* Result must be local file/maildir */
535 FEXP_SHELL
= 1<<1, /* No folder %,#,&,+ stuff, yet sh(1) */
536 FEXP_NSHORTCUT
= 1<<2, /* Don't expand shortcuts */
537 FEXP_SILENT
= 1<<3, /* Don't print but only return errors */
538 FEXP_MULTIOK
= 1<<4 /* Expansion to many entries is ok */
547 /* <0 means "stop" unless *prompt* extensions are enabled. */
549 PROMPT_STOP
= -1, /* \c */
550 /* *prompt* extensions: \$, \@ etc. */
570 MIME_NONE
, /* message is not in MIME format */
571 MIME_BIN
, /* message is in binary encoding */
572 MIME_8B
, /* message is in 8bit encoding */
573 MIME_7B
, /* message is in 7bit encoding */
574 MIME_QP
, /* message is quoted-printable */
575 MIME_B64
/* message is in base64 encoding */
579 CONV_NONE
, /* no conversion */
580 CONV_7BIT
, /* no conversion, is 7bit */
581 CONV_FROMQP
, /* convert from quoted-printable */
582 CONV_TOQP
, /* convert to quoted-printable */
583 CONV_8BIT
, /* convert to 8bit (iconv) */
584 CONV_FROMB64
, /* convert from base64 */
585 CONV_FROMB64_T
, /* convert from base64/text */
586 CONV_TOB64
, /* convert to base64 */
587 CONV_FROMHDR
, /* convert from RFC1522 format */
588 CONV_TOHDR
, /* convert to RFC1522 format */
589 CONV_TOHDR_A
/* convert addresses for header */
593 SEND_MBOX
, /* no conversion to perform */
594 SEND_RFC822
, /* no conversion, no From_ line */
595 SEND_TODISP
, /* convert to displayable form */
596 SEND_TODISP_ALL
, /* same, include all MIME parts */
597 SEND_SHOW
, /* convert to 'show' command form */
598 SEND_TOSRCH
, /* convert for IMAP SEARCH */
599 SEND_TOFLTR
, /* convert for spam mail filtering */
600 SEND_TOFILE
, /* convert for saving body to a file */
601 SEND_TOPIPE
, /* convert for pipe-content/subc. */
602 SEND_QUOTE
, /* convert for quoting */
603 SEND_QUOTE_ALL
, /* same, include all MIME parts */
604 SEND_DECRYPT
/* decrypt */
608 MIME_UNKNOWN
, /* unknown content */
609 MIME_SUBHDR
, /* inside a multipart subheader */
610 MIME_822
, /* message/rfc822 content */
611 MIME_MESSAGE
, /* other message/ content */
612 MIME_TEXT_PLAIN
, /* text/plain content */
613 MIME_TEXT_HTML
, /* text/html content */
614 MIME_TEXT
, /* other text/ content */
615 MIME_ALTERNATIVE
, /* multipart/alternative content */
616 MIME_DIGEST
, /* multipart/digest content */
617 MIME_MULTI
, /* other multipart/ content */
618 MIME_PKCS7
, /* PKCS7 content */
619 MIME_DISCARD
/* content is discarded */
622 /* Content-Transfer-Encodings as defined in RFC 2045:
623 * - Quoted-Printable, section 6.7
624 * - Base64, section 6.8 */
625 #define QP_LINESIZE (4 * 19) /* Max. compliant QP linesize */
627 #define B64_LINESIZE (4 * 19) /* Max. compliant Base64 linesize */
628 #define B64_ENCODE_INPUT_PER_LINE 57 /* Max. input for Base64 encode/line */
630 /* xxx QP came later, maybe rewrite all to use mimecte_flags directly? */
631 enum __mimecte_flags
{
633 MIMECTE_SALLOC
= 1<<0, /* Use salloc(), not srealloc().. */
634 /* ..result .s,.l point to user buffer of *_LINESIZE+[+[+]] bytes instead */
636 MIMECTE_CRLF
= 1<<2, /* (encode) Append "\r\n" to lines */
637 MIMECTE_LF
= 1<<3, /* (encode) Append "\n" to lines */
638 /* (encode) If one of _CRLF/_LF is set, honour *_LINESIZE+[+[+]] and
639 * inject the desired line-ending whenever a linewrap is desired */
640 MIMECTE_MULTILINE
= 1<<4,
641 /* (encode) Quote with header rules, do not generate soft NL breaks? */
642 MIMECTE_ISHEAD
= 1<<5
646 QP_NONE
= MIMECTE_NONE
,
647 QP_SALLOC
= MIMECTE_SALLOC
,
648 QP_BUF
= MIMECTE_BUF
,
649 QP_ISHEAD
= MIMECTE_ISHEAD
653 B64_NONE
= MIMECTE_NONE
,
654 B64_SALLOC
= MIMECTE_SALLOC
,
655 B64_BUF
= MIMECTE_BUF
,
656 B64_CRLF
= MIMECTE_CRLF
,
658 B64_MULTILINE
= MIMECTE_MULTILINE
670 OF_UNLINK
= 1<<8, /* Only for Ftmp(): unlink(2) after creation */
671 OF_HOLDSIGS
= 1<<9, /* Mutual with OF_UNLINK - await Ftmp_free() */
672 OF_REGISTER
= 1<<10 /* Register file in our file table */
676 TD_NONE
, /* no display conversion */
677 TD_ISPR
= 1<<0, /* use isprint() checks */
678 TD_ICONV
= 1<<1, /* use iconv() */
679 TD_DELCTRL
= 1<<2, /* delete control characters */
682 * NOTE: _TD_EOF and _TD_BUFCOPY may be ORd with enum conversion and
683 * enum sendaction, and may thus NOT clash with their bit range!
685 _TD_EOF
= 1<<14, /* EOF seen, last round! */
686 _TD_BUFCOPY
= 1<<15 /* Buffer may be constant, copy it */
690 PROTO_FILE
, /* refers to a local file */
691 PROTO_POP3
, /* is a pop3 server string */
692 PROTO_IMAP
, /* is an imap server string */
693 PROTO_MAILDIR
, /* refers to a maildir folder */
694 PROTO_UNKNOWN
/* unknown protocol */
704 AUTHTYPE_NONE
= 1<<0,
705 AUTHTYPE_PLAIN
= 1<<1, /* POP3: APOP is covered by this */
706 AUTHTYPE_LOGIN
= 1<<2,
707 AUTHTYPE_CRAM_MD5
= 1<<3,
708 AUTHTYPE_GSSAPI
= 1<<4
712 enum ssl_verify_level
{
720 /* A large enum with all the binary and value options a.k.a their keys.
721 * Only the constant keys are in here, to be looked up via ok_[bv]look(),
722 * ok_[bv]set() and ok_[bv]clear().
723 * Note: see the comments in acmava.c before changing *anything* in here! */
725 /* Option keys for binary options */
726 ok_b_add_file_recipients
,
736 ok_b_attachment_ask_content_description
,
737 ok_b_attachment_ask_content_disposition
,
738 ok_b_attachment_ask_content_id
,
739 ok_b_attachment_ask_content_type
,
744 ok_b_batch_exit_on_error
,
754 ok_b_debug
, /* {special=1} */
762 ok_b_forward_as_attachment
,
764 ok_b_header
, /* {special=1} */
766 ok_b_history_gabby_persist
,
771 ok_b_imap_use_starttls
,
773 ok_b_keep_content_length
,
775 ok_b_line_editor_disable
,
777 ok_b_message_id_disable
,
779 ok_b_mime_allow_text_controls
,
780 ok_b_mime_counter_evidence
,
786 ok_b_pop3_use_starttls
,
787 ok_b_print_all_chars
,
788 ok_b_print_alternatives
,
790 ok_b_quote_as_attachment
,
791 ok_b_recipients_in_cc
,
793 ok_b_reply_in_same_charset
,
795 ok_b_rfc822_body_from_
, /* {name=rfc822-body-from_} */
798 ok_b_sendcharsets_else_ttycharset
,
803 ok_b_skipemptybody
, /* {special=1} */
804 ok_b_smime_force_encryption
,
805 ok_b_smime_no_default_ca
,
807 ok_b_smtp_use_starttls
,
808 ok_b_ssl_no_default_ca
,
811 ok_b_verbose
, /* {special=1} */
812 ok_b_writebackedited
,
814 /* Option keys for values options */
822 ok_v_colour_from_
, /* {name=colour-from_} */
825 ok_v_colour_partinfo
,
828 ok_v_colour_user_headers
,
831 ok_v_datefield_markout_older
,
836 ok_v_folder
, /* {special=1} */
846 ok_v_imap_list_depth
,
848 ok_v_line_editor_cursor_right
, /* {special=1} */
852 /* TODO v15-compat: mimetypes-load-control -> mimetypes-load / mimetypes */
853 ok_v_mimetypes_load_control
,
854 ok_v_NAIL_EXTRA_RC
, /* {name=NAIL_EXTRA_RC} */
855 /* TODO v15-compat: NAIL_HEAD -> message-head? */
856 ok_v_NAIL_HEAD
, /* {name=NAIL_HEAD} */
857 /* TODO v15-compat: NAIL_HISTFILE -> history-file */
858 ok_v_NAIL_HISTFILE
, /* {name=NAIL_HISTFILE} */
859 /* TODO v15-compat: NAIL_HISTSIZE -> history-size{,limit} */
860 ok_v_NAIL_HISTSIZE
, /* {name=NAIL_HISTSIZE} */
861 /* TODO v15-compat: NAIL_TAIL -> message-tail? */
862 ok_v_NAIL_TAIL
, /* {name=NAIL_TAIL} */
877 ok_v_sendmail_arguments
,
878 ok_v_sendmail_progname
,
887 ok_v_smime_sign_cert
,
888 ok_v_smime_sign_include_certs
,
890 /* TODO v15-compat: smtp-auth: drop */
892 ok_v_smtp_auth_password
,
904 ok_v_ssl_cipher_list
,
919 enum okey_xlook_mode
{
920 OXM_PLAIN
= 1<<0, /* Plain key always tested */
921 OXM_H_P
= 1<<1, /* Check PLAIN-.url_h_p */
922 OXM_U_H_P
= 1<<2, /* Check PLAIN-.url_u_h_p */
926 /* Locale-independent character classes */
940 char *s
; /* the string's content */
941 size_t l
; /* the stings's length */
944 struct colour_table
{
945 /* Plus a copy of *colour-user-headers* */
946 struct str ct_csinfo
[COLOURSPEC_RESET
+1 + 1];
950 struct str bi_start
; /* Start of (possibly) bidirectional text */
951 struct str bi_end
; /* End of ... */
952 size_t bi_pad
; /* No of visual columns to reserve for BIDI pad */
956 char const *url_input
; /* Input as given (really) */
957 enum cproto url_cproto
; /* Communication protocol as given */
958 bool_t url_needs_tls
; /* Wether the protocol uses SSL/TLS */
959 bool_t url_had_user
; /* Wether .url_user was part of the URL */
960 ui16_t url_portno
; /* atoi .url_port or default, host endian */
961 char const *url_port
; /* Port (if given) or NULL */
962 char url_proto
[14]; /* Communication protocol as 'xy\0//' */
963 ui8_t url_proto_len
; /* Length of .url_proto ('\0' index) */
964 ui8_t url_proto_xlen
; /* .. if '\0' is replaced with ':' */
965 struct str url_user
; /* User, exactly as given / looked up */
966 struct str url_user_enc
; /* User, urlxenc()oded */
967 struct str url_pass
; /* Pass (urlxdec()oded) or NULL */
968 struct str url_pass_enc
; /* Pass (urlxenc()oded) or NULL */
969 struct str url_host
; /* Service hostname */
970 struct str url_path
; /* CPROTO_IMAP: path suffix or NULL */
971 /* TODO: url_get_component(url *, enum COMPONENT, str *store) */
972 struct str url_h_p
; /* .url_host[:.url_port] */
973 /* .url_user@.url_host
974 * Note: for CPROTO_SMTP this may resolve HOST via *smtp-hostname* (->
975 * *hostname*)! (And may later be overwritten according to *from*!) */
977 struct str url_u_h_p
; /* .url_user@.url_host[:.url_port] */
978 struct str url_eu_h_p
; /* .url_user_enc@.url_host[:.url_port] */
979 char const *url_p_u_h_p
; /* .url_proto://.url_u_h_p */
980 char const *url_p_eu_h_p
; /* .url_proto://.url_eu_h_p */
981 char const *url_p_eu_h_p_p
; /* .url_proto://.url_eu_h_p[/.url_path] */
985 enum cproto cc_cproto
; /* Communication protocol */
986 enum authtype cc_authtype
; /* Desired authentication */
987 char const *cc_auth
; /* Authentication type as string */
988 struct str cc_user
; /* User (urlxdec()oded) or NULL */
989 struct str cc_pass
; /* Password (urlxdec()oded) or NULL */
992 struct time_current
{
1000 FILE *qf_os
; /* Output stream */
1001 char const *qf_pfix
;
1002 ui32_t qf_pfix_len
; /* Length of prefix: 0: bypass */
1003 ui32_t qf_qfold_min
; /* Simple way: wrote prefix? */
1004 #ifdef HAVE_QUOTE_FOLD
1005 ui32_t qf_qfold_max
; /* Otherwise: line lengths */
1006 ui8_t qf_state
; /* *quote-fold* state machine */
1007 bool_t qf_brk_isws
; /* Breakpoint is at WS */
1009 ui32_t qf_wscnt
; /* Whitespace count */
1010 ui32_t qf_brkl
; /* Breakpoint */
1011 ui32_t qf_brkw
; /* Visual width, breakpoint */
1012 ui32_t qf_datw
; /* Current visual output line width */
1013 struct str qf_dat
; /* Current visual output line */
1014 struct str qf_currq
; /* Current quote, compressed */
1015 mbstate_t qf_mbps
[2];
1019 struct search_expr
{
1020 char const *ss_where
; /* to search for the expression (not always used) */
1021 char const *ss_sexpr
; /* String search expression; NULL: use .ss_reexpr */
1028 struct str ev_line
; /* The terminated data to evaluate */
1029 ui32_t ev_line_size
; /* May be used to store line memory size */
1030 bool_t ev_is_recursive
; /* Evaluation in evaluation? (collect ~:) */
1032 bool_t ev_add_history
; /* Enter (final) command in history? */
1033 char const *ev_new_content
; /* History: reenter line, start with this */
1036 struct termios_state
{
1037 struct termios ts_tios
;
1040 bool_t ts_needs_reset
;
1043 #define termios_state_reset() \
1045 if (termios_state.ts_needs_reset) {\
1046 tcsetattr(0, TCSADRAIN, &termios_state.ts_tios);\
1047 termios_state.ts_needs_reset = FAL0;\
1051 struct sock
{ /* data associated with a socket */
1052 int s_fd
; /* file descriptor */
1054 int s_use_ssl
; /* SSL is used */
1055 # ifdef HAVE_OPENSSL
1056 void *s_ssl
; /* SSL object */
1057 void *s_ctx
; /* SSL context object */
1060 char *s_wbuf
; /* for buffered writes */
1061 int s_wbufsize
; /* allocated size of s_buf */
1062 int s_wbufpos
; /* position of first empty data byte */
1063 char *s_rbufptr
; /* read pointer to s_rbuf */
1064 int s_rsz
; /* size of last read in s_rbuf */
1065 char const *s_desc
; /* description of error messages */
1066 void (*s_onclose
)(void); /* execute on close */
1067 char s_rbuf
[LINESIZE
+ 1]; /* for buffered reads */
1072 struct ccred sc_cred
;
1073 struct sock sc_sock
;
1078 MB_NONE
= 000, /* no reply expected */
1079 MB_COMD
= 001, /* command reply expected */
1080 MB_MULT
= 002, /* multiline reply expected */
1081 MB_PREAUTH
= 004, /* not in authenticated state */
1082 MB_BYE
= 010 /* may accept a BYE state */
1084 FILE *mb_itf
; /* temp file with messages, read open */
1085 FILE *mb_otf
; /* same, write open */
1086 char *mb_sorted
; /* sort method */
1088 MB_VOID
, /* no type (e. g. connection failed) */
1089 MB_FILE
, /* local file */
1090 MB_POP3
, /* POP3 mailbox */
1091 MB_IMAP
, /* IMAP mailbox */
1092 MB_MAILDIR
, /* maildir folder */
1093 MB_CACHE
/* cached mailbox */
1094 } mb_type
; /* type of mailbox */
1096 MB_DELE
= 01, /* may delete messages in mailbox */
1097 MB_EDIT
= 02 /* may edit messages in mailbox */
1099 int mb_compressed
; /* is a compressed mbox file */
1100 int mb_threaded
; /* mailbox has been threaded */
1104 MB_UIDPLUS
= 001 /* supports IMAP UIDPLUS */
1106 unsigned long mb_uidvalidity
; /* IMAP unique identifier validity */
1107 char *mb_imap_account
; /* name of current IMAP account */
1108 char *mb_imap_pass
; /* xxx v15-compat URL workaround */
1109 char *mb_imap_mailbox
; /* name of current IMAP mailbox */
1110 char *mb_cache_directory
; /* name of cache directory */
1112 struct sock mb_sock
; /* socket structure */
1116 NEED_UNSPEC
, /* unspecified need, don't fetch */
1117 NEED_HEADER
, /* need the header of a message */
1118 NEED_BODY
/* need header and body of a message */
1122 HAVE_NOTHING
, /* nothing downloaded yet */
1123 HAVE_HEADER
= 01, /* header is downloaded */
1124 HAVE_BODY
= 02 /* entire message is downloaded */
1127 /* flag bits. Attention: Flags that are used in cache.c may not change */
1129 MUSED
= (1<< 0), /* entry is used, but this bit isn't */
1130 MDELETED
= (1<< 1), /* entry has been deleted */
1131 MSAVED
= (1<< 2), /* entry has been saved */
1132 MTOUCH
= (1<< 3), /* entry has been noticed */
1133 MPRESERVE
= (1<< 4), /* keep entry in sys mailbox */
1134 MMARK
= (1<< 5), /* message is marked! */
1135 MODIFY
= (1<< 6), /* message has been modified */
1136 MNEW
= (1<< 7), /* message has never been seen */
1137 MREAD
= (1<< 8), /* message has been read sometime. */
1138 MSTATUS
= (1<< 9), /* message status has changed */
1139 MBOX
= (1<<10), /* Send this to mbox, regardless */
1140 MNOFROM
= (1<<11), /* no From line */
1141 MHIDDEN
= (1<<12), /* message is hidden to user */
1142 MFULLYCACHED
= (1<<13), /* message is completely cached */
1143 MBOXED
= (1<<14), /* message has been sent to mbox */
1144 MUNLINKED
= (1<<15), /* message was unlinked from cache */
1145 MNEWEST
= (1<<16), /* message is very new (newmail) */
1146 MFLAG
= (1<<17), /* message has been flagged recently */
1147 MUNFLAG
= (1<<18), /* message has been unflagged */
1148 MFLAGGED
= (1<<19), /* message is `flagged' */
1149 MANSWER
= (1<<20), /* message has been answered recently */
1150 MUNANSWER
= (1<<21), /* message has been unanswered */
1151 MANSWERED
= (1<<22), /* message is `answered' */
1152 MDRAFT
= (1<<23), /* message has been drafted recently */
1153 MUNDRAFT
= (1<<24), /* message has been undrafted */
1154 MDRAFTED
= (1<<25), /* message is marked as `draft' */
1155 MOLDMARK
= (1<<26), /* messages was marked previously */
1156 MSPAM
= (1<<27) /* message is classified as spam */
1158 #define MMNORM (MDELETED | MSAVED | MHIDDEN)
1159 #define MMNDEL (MDELETED | MHIDDEN)
1161 #define visible(mp) (((mp)->m_flag & MMNDEL) == 0)
1164 enum mflag m_flag
; /* flags */
1165 enum havespec m_have
; /* downloaded parts of the part */
1167 ui32_t m_spamscore
; /* Spam score as int, 24:8 bits */
1169 int m_block
; /* block number of this part */
1170 size_t m_offset
; /* offset in block of part */
1171 size_t m_size
; /* Bytes in the part */
1172 size_t m_xsize
; /* Bytes in the full part */
1173 long m_lines
; /* Lines in the message */
1174 long m_xlines
; /* Lines in the full message */
1175 time_t m_time
; /* time the message was sent */
1176 char const *m_from
; /* message sender */
1177 struct mimepart
*m_nextpart
; /* next part at same level */
1178 struct mimepart
*m_multipart
; /* parts of multipart */
1179 struct mimepart
*m_parent
; /* enclosing multipart part */
1180 char *m_ct_type
; /* content-type */
1181 char *m_ct_type_plain
; /* content-type without specs */
1182 enum mimecontent m_mimecontent
; /* same in enum */
1183 char const *m_charset
; /* charset */
1184 char *m_ct_transfer_enc
; /* content-transfer-encoding */
1185 enum mimeenc m_mimeenc
; /* same in enum */
1186 char *m_partstring
; /* part level string */
1187 char *m_filename
; /* attachment filename */
1191 enum mflag m_flag
; /* flags */
1192 enum havespec m_have
; /* downloaded parts of the message */
1194 ui32_t m_spamscore
; /* Spam score as int, 24:8 bits */
1196 int m_block
; /* block number of this message */
1197 size_t m_offset
; /* offset in block of message */
1198 size_t m_size
; /* Bytes in the message */
1199 size_t m_xsize
; /* Bytes in the full message */
1200 long m_lines
; /* Lines in the message */
1201 long m_xlines
; /* Lines in the full message */
1202 time_t m_time
; /* time the message was sent */
1203 time_t m_date
; /* time in the 'Date' field */
1204 unsigned m_idhash
; /* hash on Message-ID for threads */
1205 struct message
*m_child
; /* first child of this message */
1206 struct message
*m_younger
; /* younger brother of this message */
1207 struct message
*m_elder
; /* elder brother of this message */
1208 struct message
*m_parent
; /* parent of this message */
1209 unsigned m_level
; /* thread level of message */
1210 long m_threadpos
; /* position in threaded display */
1212 unsigned long m_uid
; /* IMAP unique identifier */
1214 char *m_maildir_file
; /* original maildir file of msg */
1215 ui32_t m_maildir_hash
; /* hash of file name in maildir sub */
1216 int m_collapsed
; /* collapsed thread information */
1219 /* Given a file address, determine the block number it represents */
1220 #define mailx_blockof(off) ((int) ((off) / 4096))
1221 #define mailx_offsetof(off) ((int) ((off) % 4096))
1222 #define mailx_positionof(block, offset) ((off_t)(block) * 4096 + (offset))
1224 /* Argument types */
1226 ARG_MSGLIST
= 0, /* Message list type */
1227 ARG_STRLIST
= 1, /* A pure string */
1228 ARG_RAWLIST
= 2, /* Shell string list */
1229 ARG_NOLIST
= 3, /* Just plain 0 */
1230 ARG_NDMLIST
= 4, /* Message list, no defaults */
1231 ARG_ECHOLIST
= 5, /* Like raw list, but keep quote chars */
1232 ARG_ARGMASK
= 7, /* Mask of the above */
1234 ARG_A
= 1u<< 4, /* Needs an active mailbox */
1235 ARG_F
= 1u<< 5, /* Is a conditional command */
1236 ARG_H
= 1u<< 6, /* Never place in history */
1237 ARG_I
= 1u<< 7, /* Interactive command bit */
1238 ARG_M
= 1u<< 8, /* Legal from send mode bit */
1239 ARG_P
= 1u<< 9, /* Autoprint dot after command */
1240 ARG_R
= 1u<<10, /* Cannot be called from collect / recursion */
1241 ARG_T
= 1u<<11, /* Is a transparent command */
1242 ARG_V
= 1u<<12, /* Places data in temporary_arg_v_store */
1243 ARG_W
= 1u<<13 /* Invalid when read only bit */
1247 GTO
= 1, /* Grab To: line */
1248 GSUBJECT
= 2, /* Likewise, Subject: line */
1249 GCC
= 4, /* And the Cc: line */
1250 GBCC
= 8, /* And also the Bcc: line */
1252 GNL
= 16, /* Print blank line after */
1253 GDEL
= 32, /* Entity removed from list */
1254 GCOMMA
= 64, /* detract puts in commas */
1255 GUA
= 128, /* User-Agent field */
1256 GMIME
= 256, /* MIME 1.0 fields */
1257 GMSGID
= 512, /* a Message-ID */
1259 GIDENT
= 2048, /* From:, Reply-To: and Organization: field */
1260 GREF
= 4096, /* References: field */
1261 GDATE
= 8192, /* Date: field */
1262 GFULL
= 16384, /* include full names */
1263 GSKIN
= 32768, /* skin names */
1264 GEXTRA
= 65536, /* extra fields */
1265 GFILES
= 131072 /* include filename addresses */
1267 #define GMASK (GTO | GSUBJECT | GCC | GBCC)
1269 /* Structure used to pass about the current state of a message (header) */
1271 struct name
*h_to
; /* Dynamic "To:" string */
1272 char *h_subject
; /* Subject string */
1273 struct name
*h_cc
; /* Carbon copies string */
1274 struct name
*h_bcc
; /* Blind carbon copies */
1275 struct name
*h_ref
; /* References */
1276 struct attachment
*h_attach
; /* MIME attachments */
1277 char *h_charset
; /* preferred charset */
1278 struct name
*h_from
; /* overridden "From:" field */
1279 struct name
*h_replyto
; /* overridden "Reply-To:" field */
1280 struct name
*h_sender
; /* overridden "Sender:" field */
1281 char *h_organization
; /* overridden "Organization:" field */
1284 /* Handling of namelist nodes used in processing the recipients of mail and
1285 * aliases, inspection of mail-addresses and all that kind of stuff */
1287 NAME_NAME_SALLOC
= 1<< 0, /* .n_name is doped */
1288 NAME_FULLNAME_SALLOC
= 1<< 1, /* .n_fullname is doped */
1289 NAME_SKINNED
= 1<< 2, /* Is actually skin()ned */
1290 NAME_IDNA
= 1<< 3, /* IDNA was applied */
1291 NAME_ADDRSPEC_CHECKED
= 1<< 4, /* Address has been .. and */
1292 NAME_ADDRSPEC_ISFILE
= 1<< 5, /* ..is a file path */
1293 NAME_ADDRSPEC_ISPIPE
= 1<< 6, /* ..is a command for piping */
1294 NAME_ADDRSPEC_ISFILEORPIPE
= NAME_ADDRSPEC_ISFILE
| NAME_ADDRSPEC_ISPIPE
,
1295 NAME_ADDRSPEC_ERR_EMPTY
= 1<< 7, /* An empty string (or NULL) */
1296 NAME_ADDRSPEC_ERR_ATSEQ
= 1<< 8, /* Weird @ sequence */
1297 NAME_ADDRSPEC_ERR_CHAR
= 1<< 9, /* Invalid character */
1298 NAME_ADDRSPEC_ERR_IDNA
= 1<<10, /* IDNA convertion failed */
1299 NAME_ADDRSPEC_INVALID
= NAME_ADDRSPEC_ERR_EMPTY
|
1300 NAME_ADDRSPEC_ERR_ATSEQ
| NAME_ADDRSPEC_ERR_CHAR
|
1301 NAME_ADDRSPEC_ERR_IDNA
,
1304 _NAME_MAXWC
= 0xFFFFF,
1305 _NAME_MASKWC
= _NAME_MAXWC
<< _NAME_SHIFTWC
1308 /* In the !_ERR_EMPTY case, the failing character can be queried */
1309 #define NAME_ADDRSPEC_ERR_GETWC(F) \
1310 ((((unsigned int)(F) & _NAME_MASKWC) >> _NAME_SHIFTWC) & _NAME_MAXWC)
1311 #define NAME_ADDRSPEC_ERR_SET(F, E, WC) \
1313 (F) = ((F) & ~(NAME_ADDRSPEC_INVALID | _NAME_MASKWC)) |\
1314 (E) | (((unsigned int)(WC) & _NAME_MAXWC) << _NAME_SHIFTWC);\
1318 struct name
*n_flink
; /* Forward link in list. */
1319 struct name
*n_blink
; /* Backward list link */
1320 enum gfield n_type
; /* From which list it came */
1321 enum nameflags n_flags
; /* enum nameflags */
1322 char *n_name
; /* This fella's name */
1323 char *n_fullname
; /* Sometimes, name including comment */
1327 char const *ag_input
; /* Input string as given */
1328 size_t ag_ilen
; /* strlen() of input */
1329 size_t ag_iaddr_start
; /* Start of *addr-spec* in .ag_input */
1330 size_t ag_iaddr_aend
; /* ..and one past its end */
1331 char *ag_skinned
; /* Output (alloced if !=.ag_input) */
1332 size_t ag_slen
; /* strlen() of .ag_skinned */
1333 size_t ag_sdom_start
; /* Start of domain in .ag_skinned, */
1334 enum nameflags ag_n_flags
; /* enum nameflags of .ag_skinned */
1337 /* MIME attachments */
1339 AC_DEFAULT
, /* _get_lc() -> _iter_*() */
1340 AC_FIX_OUTCS
, /* _get_lc() -> "charset=" .a_charset */
1341 AC_FIX_INCS
, /* "charset=".a_input_charset (nocnv) */
1342 AC_TMPFILE
/* attachment.a_tmpf is converted */
1346 struct attachment
*a_flink
; /* Forward link in list. */
1347 struct attachment
*a_blink
; /* Backward list link */
1348 char const *a_name
; /* file name */
1349 char const *a_content_type
; /* content type */
1350 char const *a_content_disposition
; /* content disposition */
1351 char const *a_content_id
; /* content id */
1352 char const *a_content_description
; /* content description */
1353 char const *a_input_charset
; /* Interpretation depends on .a_conv */
1354 char const *a_charset
; /* ... */
1355 FILE *a_tmpf
; /* If AC_TMPFILE */
1356 enum attach_conv a_conv
; /* User chosen conversion */
1357 int a_msgno
; /* message number */
1361 struct header
*sb_hp
;
1364 struct str sb_signer
; /* USER@HOST for signing+ */
1366 struct ccred sb_ccred
;
1370 struct group
*ge_link
; /* Next person in this group */
1371 char *ge_name
; /* This person's user name */
1375 struct grouphead
*g_link
; /* Next grouphead in list */
1376 char *g_name
; /* Name of this group */
1377 struct group
*g_list
; /* Users in group. */
1380 /* Structure of the hash table of ignored header fields */
1382 int i_count
; /* Number of entries */
1384 struct ignore
*i_link
; /* Next ignored field in bucket */
1385 char *i_field
; /* This ignored field */
1389 /* For the 'shortcut' and 'unshortcut' functionality */
1391 struct shortcut
*sh_next
; /* next shortcut in list */
1392 char *sh_short
; /* shortcut string */
1393 char *sh_long
; /* expanded form */
1396 /* For saving the current directory and later returning */
1401 char cw_wd
[PATH_MAX
];
1406 * Global variable declarations
1408 * These become instantiated in main.c.
1413 # ifndef HAVE_AMALGAMATION
1422 VL gid_t effectivegid
; /* Saved from when we started up */
1423 VL gid_t realgid
; /* Saved from when we started up */
1425 VL
int mb_cur_max
; /* Value of MB_CUR_MAX */
1426 VL
int realscreenheight
; /* The real screen height */
1427 VL
int scrnwidth
; /* Screen width, or best guess */
1428 VL
int scrnheight
; /* Screen height/guess (4 header) */
1429 VL
int enc_has_state
; /* Encoding has shift states */
1431 VL
char **altnames
; /* List of alternate names of user */
1432 VL
char const *homedir
; /* Path name of home directory */
1433 VL
char const *myname
; /* My login name */
1434 VL
char const *progname
; /* Our name */
1435 VL
char const *tempdir
; /* The temporary directory */
1437 VL
int exit_status
; /* Exit status */
1438 VL
int options
; /* Bits of enum user_options */
1439 VL
char *option_r_arg
; /* Argument to -r option */
1440 VL
char const **smopts
; /* sendmail(1) opts from commline */
1441 VL
size_t smopts_count
; /* Entries in smopts */
1443 /* TODO Join as many of these state machine bits into a single carrier! */
1444 VL
int inhook
; /* Currently executing a hook */
1445 VL bool_t exec_last_comm_error
; /* Last execute() command failed */
1446 VL bool_t edit
; /* Indicates editing a file */
1447 VL bool_t did_print_dot
; /* Current message has been printed */
1448 VL bool_t list_saw_numbers
; /* Last *LIST saw numerics */
1449 VL bool_t msglist_is_single
; /* Last NDMLIST/MSGLIST chose 1 msg */
1450 VL bool_t loading
; /* Loading user definitions */
1451 VL bool_t sourcing
; /* Currently reading variant file */
1452 VL bool_t sawcom
; /* Set after first command */
1453 VL bool_t starting
; /* Still in startup code */
1454 VL bool_t var_clear_allow_undefined
; /* v?ok_[bv]clear(): no complain */
1455 VL
int noreset
; /* String resets suspended */
1457 /* XXX stylish sorting */
1458 VL
int msgCount
; /* Count of messages read in */
1459 VL
struct mailbox mb
; /* Current mailbox */
1460 VL
int image
; /* File descriptor for msg image */
1461 VL
char mailname
[PATH_MAX
]; /* Name of current file TODO URL/object*/
1462 VL
char displayname
[80 - 40]; /* Prettyfied for display TODO URL/obj*/
1463 VL
char prevfile
[PATH_MAX
]; /* Name of previous file TODO URL/obj */
1464 VL
char const *account_name
; /* Current account name or NULL */
1465 VL off_t mailsize
; /* Size of system mailbox */
1466 VL
struct message
*dot
; /* Pointer to current message */
1467 VL
struct message
*prevdot
; /* Previous current message */
1468 VL
struct message
*message
; /* The actual message structure */
1469 VL
struct message
*threadroot
; /* first threaded message */
1470 VL
int imap_created_mailbox
; /* hack to get feedback from imap */
1472 VL
struct grouphead
*groups
[HSHSIZE
]; /* Pointer to active groups */
1473 VL
struct ignoretab ignore
[2]; /* ignored and retained fields
1474 * 0 is ignore, 1 is retain */
1475 VL
struct ignoretab saveignore
[2]; /* ignored and retained fields
1476 * on save to folder */
1477 VL
struct ignoretab allignore
[2]; /* special, ignore all headers */
1478 VL
struct ignoretab fwdignore
[2]; /* fields to ignore for forwarding */
1479 VL
struct shortcut
*shortcuts
; /* list of shortcuts */
1481 VL
struct time_current time_current
; /* time(3); send: mail1() XXXcarrier */
1482 VL
struct termios_state termios_state
; /* getpassword(); see commands().. */
1485 VL
struct colour_table
*colour_table
;
1489 VL
enum ssl_verify_level ssl_verify_level
; /* SSL verification level */
1500 VL sigjmp_buf srbuf
;
1502 VL sighandler_type dflpipe
;
1503 VL sighandler_type handlerstacktop
;
1504 #define handlerpush(f) (savedtop = handlerstacktop, handlerstacktop = (f))
1505 #define handlerpop() (handlerstacktop = savedtop)
1507 /* TODO Temporary hacks unless the codebase doesn't jump and uses pass-by-value
1508 * TODO carrier structs instead of locals */
1509 VL
char *temporary_arg_v_store
;
1510 VL
void *temporary_localopts_store
;
1512 /* The remaining variables need initialization */
1514 #ifndef HAVE_AMALGAMATION
1515 VL
char const month_names
[12 + 1][4];
1516 VL
char const weekday_names
[7 + 1][4];
1518 VL
char const uagent
[]; /* User agent */
1519 VL
char const version
[]; /* The version string */
1520 VL
char const features
[]; /* The "feature string" */
1522 VL uc_it
const class_char
[];
1526 * Finally, let's include the function prototypes XXX embed
1529 #include "nailfuns.h"
1531 /* vim:set fenc=utf-8:s-it-mode */