1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ Account, macro and variable handling.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2013 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
40 #ifndef HAVE_AMALGAMATION
45 * HOWTO add a new non-dynamic binary or value option:
46 * - add an entry to nail.h:enum okeys
47 * - run create-okey-map.pl
51 /* Note: changing the hash function must be reflected in create-okey-map.pl */
52 #define MA_PRIME HSHSIZE
53 #define MA_NAME2HASH(N) torek_hash(N)
54 #define MA_HASH2PRIME(H) ((H) % MA_PRIME)
59 MA_TYPE_MASK
= MA_ACC
,
60 MA_UNDEF
= 1<<1 /* Unlink after lookup */
64 struct macro
*ma_next
;
66 struct mline
*ma_contents
;
67 size_t ma_maxlen
; /* Maximum line length */
68 enum ma_flags ma_flags
;
69 struct var
*ma_localopts
; /* `account' unroll list, for `localopts' */
75 char l_line
[VFIELD_SIZE(sizeof(size_t))];
81 char v_name
[VFIELD_SIZE(sizeof(size_t))];
96 struct var_map
const *vc_vmap
;
101 struct lostack
*s_up
; /* Outer context */
102 struct macro
*s_mac
; /* Context (`account' or `define') */
103 struct var
*s_localopts
;
104 bool_t s_unroll
; /* Unroll? */
107 /* Include the constant create-okey-map.pl output */
110 static struct macro
*_acc_curr
; /* Currently active account */
111 static struct lostack
*_localopts
; /* Currently executing macro unroll list */
113 /* TODO once we have a dynamically sized hashtable we could unite _macros and
114 * TODO _variables into a single hashtable, stripping down fun interface;
115 * TODO also, setting and clearing a variable can be easily joined */
116 static struct macro
*_macros
[MA_PRIME
]; /* TODO dynamically spaced */
117 static struct var
*_vars
[MA_PRIME
]; /* TODO dynamically spaced */
119 /* Special cased value string allocation */
120 static char * _vcopy(char const *str
);
121 static void _vfree(char *cp
);
123 /* Check for special housekeeping. */
124 static bool_t
_check_special_vars(enum okeys okey
, bool_t enable
,
127 /* If a variable name begins with a lowercase-character and contains at
128 * least one '@', it is converted to all-lowercase. This is necessary
129 * for lookups of names based on email addresses.
131 * Following the standard, only the part following the last '@' should
132 * be lower-cased, but practice has established otherwise here */
133 static char const * _canonify(char const *vn
);
135 /* Try to reverse lookup an option name to an enum okeys mapping.
136 * Updates vcp.vc_name and vcp.vc_hash; vcp.vc_vmap is NULL on "error" */
137 static bool_t
_var_revlookup(struct var_carrier
*vcp
, char const *name
);
139 /* Lookup a variable from vcp.vc_(vmap|name|hash).
140 * Sets vcp.vc_prime; vcp.vc_var is NULL on "error" */
141 static bool_t
_var_lookup(struct var_carrier
*vcp
);
143 /* Set variable from vcp.vc_(vmap|name|hash); sets vcp.vc_var if NULL */
144 static bool_t
_var_set(struct var_carrier
*vcp
, char const *value
);
146 /* Clear variable from vcp.vc_(vmap|name|hash); sets vcp.vc_var to NULL */
147 static bool_t
_var_clear(struct var_carrier
*vcp
);
149 /* Line *cp* consists solely of WS and a } */
150 static bool_t
_is_closing_angle(char const *cp
);
152 /* Lookup for macros/accounts */
153 static struct macro
*_malook(char const *name
, struct macro
*data
,
156 /* Walk all lines of a macro and execute() them */
157 static int _maexec(struct macro
const *mp
, struct var
**unroller
);
159 /* User display helpers */
160 static int _list_macros(enum ma_flags mafl
);
163 static bool_t
_define1(char const *name
, enum ma_flags mafl
);
164 static void _undef1(char const *name
, enum ma_flags mafl
);
165 static void _freelines(struct mline
*lp
);
167 /* var_list_all(): qsort(3) helper */
168 static int _var_list_all_cmp(void const *s1
, void const *s2
);
170 /* Update replay-log */
171 static void _localopts_add(struct lostack
*losp
, char const *name
,
173 static void _localopts_unroll(struct var
**vapp
);
176 _vcopy(char const *str
)
184 len
= strlen(str
) + 1;
186 memcpy(news
, str
, len
);
199 _check_special_vars(enum okeys okey
, bool_t enable
, char **val
)
213 case ok_b_skipemptybody
:
220 rv
= (val
== NULL
|| var_folder_updated(*val
, &cp
));
221 if (rv
&& cp
!= NULL
) {
223 /* It's smalloc()ed, but ensure we don't leak */
232 case ok_v_line_editor_cursor_right
:
233 if ((rv
= (val
!= NULL
&& *val
!= NULL
))) {
234 /* Set with no value? TODO very guly */
235 if (*(cp
= *val
) != '\0') {
239 c
= expand_shell_escape(&x
, FAL0
);
243 } while (*x
!= '\0');
263 _canonify(char const *vn
)
265 if (!upperchar(*vn
)) {
268 for (vp
= vn
; *vp
!= '\0' && *vp
!= '@'; ++vp
)
270 vn
= (*vp
== '@') ? i_strdup(vn
) : vn
;
276 _var_revlookup(struct var_carrier
*vcp
, char const *name
)
279 struct var_map
const *vmp
;
281 vcp
->vc_name
= name
= _canonify(name
);
282 vcp
->vc_hash
= hash
= MA_NAME2HASH(name
);
284 for (i
= hash
% _VAR_REV_PRIME
, j
= 0; j
<= _VAR_REV_LONGEST
; ++j
) {
285 ui32_t x
= _var_revmap
[i
];
286 if (x
== _VAR_REV_ILL
)
289 if (vmp
->vm_hash
== hash
&&
290 !strcmp(_var_keydat
+ vmp
->vm_keyoff
, name
)) {
292 vcp
->vc_okey
= (enum okeys
)x
;
295 if (++i
== _VAR_REV_PRIME
) {
296 #ifdef _VAR_REV_WRAPAROUND
306 return (vcp
!= NULL
);
310 _var_lookup(struct var_carrier
*vcp
)
312 struct var
**vap
, *lvp
, *vp
;
314 vap
= _vars
+ (vcp
->vc_prime
= MA_HASH2PRIME(vcp
->vc_hash
));
316 for (lvp
= NULL
, vp
= *vap
; vp
!= NULL
; lvp
= vp
, vp
= vp
->v_link
)
317 if (strcmp(vp
->v_name
, vcp
->vc_name
) == 0) {
318 /* Relink as head, hope it "sorts on usage" over time */
320 lvp
->v_link
= vp
->v_link
;
333 _var_set(struct var_carrier
*vcp
, char const *value
)
340 bool_t tmp
= var_clear_allow_undefined
;
341 var_clear_allow_undefined
= TRU1
;
342 err
= _var_clear(vcp
);
343 var_clear_allow_undefined
= tmp
;
349 /* Don't care what happens later on, store this in the unroll list */
350 if (_localopts
!= NULL
)
351 _localopts_add(_localopts
, vcp
->vc_name
, vcp
->vc_var
);
353 if ((vp
= vcp
->vc_var
) == NULL
) {
354 size_t l
= strlen(vcp
->vc_name
) + 1;
357 vp
= smalloc(sizeof(*vp
) - VFIELD_SIZEOF(struct var
, v_name
) + l
);
358 vp
->v_link
= _vars
[vcp
->vc_prime
];
359 _vars
[vcp
->vc_prime
] = vp
;
360 memcpy(vp
->v_name
, vcp
->vc_name
, l
);
364 vp
->v_value
= _vcopy(value
);
366 /* Check if update allowed XXX wasteful on error! */
367 if (vcp
->vc_vmap
!= NULL
&& vcp
->vc_vmap
->vm_special
&&
368 (err
= !_check_special_vars(vcp
->vc_okey
, TRU1
, &vp
->v_value
))) {
369 char *cp
= vp
->v_value
;
381 _var_clear(struct var_carrier
*vcp
)
385 if (!_var_lookup(vcp
)) {
386 if (!sourcing
&& !var_clear_allow_undefined
) {
387 fprintf(stderr
, tr(203, "\"%s\": undefined variable\n"),
392 if (_localopts
!= NULL
)
393 _localopts_add(_localopts
, vcp
->vc_name
, vcp
->vc_var
);
395 /* Always listhead after _var_lookup() */
396 _vars
[vcp
->vc_prime
] = _vars
[vcp
->vc_prime
]->v_link
;
397 _vfree(vcp
->vc_var
->v_value
);
401 if (vcp
->vc_vmap
!= NULL
&& vcp
->vc_vmap
->vm_special
&&
402 !_check_special_vars(vcp
->vc_okey
, FAL0
, NULL
))
411 _is_closing_angle(char const *cp
)
415 while (spacechar(*cp
))
419 while (spacechar(*cp
))
426 static struct macro
*
427 _malook(char const *name
, struct macro
*data
, enum ma_flags mafl
)
429 enum ma_flags save_mafl
;
431 struct macro
*lmp
, *mp
;
434 mafl
&= MA_TYPE_MASK
;
435 h
= MA_NAME2HASH(name
);
436 h
= MA_HASH2PRIME(h
);
438 for (lmp
= NULL
, mp
= _macros
[h
]; mp
!= NULL
; lmp
= mp
, mp
= mp
->ma_next
) {
439 if ((mp
->ma_flags
& MA_TYPE_MASK
) == mafl
&&
440 strcmp(mp
->ma_name
, name
) == 0) {
441 if (save_mafl
& MA_UNDEF
) {
443 _macros
[h
] = mp
->ma_next
;
445 lmp
->ma_next
= mp
->ma_next
;
452 data
->ma_next
= _macros
[h
];
461 _maexec(struct macro
const *mp
, struct var
**unroller
)
465 struct mline
const *lp
;
466 char *buf
= ac_alloc(mp
->ma_maxlen
+ 1);
468 los
.s_up
= _localopts
;
469 los
.s_mac
= UNCONST(mp
);
470 los
.s_localopts
= NULL
;
474 for (lp
= mp
->ma_contents
; lp
; lp
= lp
->l_next
) {
475 var_clear_allow_undefined
= TRU1
;
476 memcpy(buf
, lp
->l_line
, lp
->l_length
+ 1);
477 rv
|= execute(buf
, 0, lp
->l_length
); /* XXX break if != 0 ? */
478 var_clear_allow_undefined
= FAL0
;
481 _localopts
= los
.s_up
;
482 if (unroller
== NULL
)
483 _localopts_unroll(&los
.s_localopts
);
485 *unroller
= los
.s_localopts
;
492 _list_macros(enum ma_flags mafl
)
501 if ((fp
= Ftemp(&cp
, "Ra", "w+", 0600, 1)) == NULL
) {
508 mafl
&= MA_TYPE_MASK
;
509 typestr
= (mafl
& MA_ACC
) ? "account" : "define";
511 for (ti
= mc
= 0; ti
< MA_PRIME
; ++ti
)
512 for (mq
= _macros
[ti
]; mq
; mq
= mq
->ma_next
)
513 if ((mq
->ma_flags
& MA_TYPE_MASK
) == mafl
) {
516 fprintf(fp
, "%s %s {\n", typestr
, mq
->ma_name
);
517 for (lp
= mq
->ma_contents
; lp
; lp
= lp
->l_next
)
518 fprintf(fp
, " %s\n", lp
->l_line
);
522 page_or_print(fp
, 0);
524 mc
= (ui32_t
)ferror(fp
);
530 _define1(char const *name
, enum ma_flags mafl
)
534 struct mline
*lp
, *lst
= NULL
, *lnd
= NULL
;
535 char *linebuf
= NULL
, *cp
;
536 size_t linesize
= 0, maxlen
= 0;
539 mp
= scalloc(1, sizeof *mp
);
540 mp
->ma_name
= sstrdup(name
);
544 n
= readline_input(LNED_LF_ESC
, "", &linebuf
, &linesize
);
546 fprintf(stderr
, tr(75, "Unterminated %s definition: \"%s\".\n"),
547 (mafl
& MA_ACC
? "account" : "macro"), mp
->ma_name
);
552 if (_is_closing_angle(linebuf
))
556 for (cp
= linebuf
, i
= 0; i
< n
; ++cp
, ++i
)
562 while (whitechar(cp
[n
- 1]))
568 maxlen
= MAX(maxlen
, (size_t)n
);
571 lp
= scalloc(1, sizeof(*lp
) - VFIELD_SIZEOF(struct mline
, l_line
) + n
);
572 memcpy(lp
->l_line
, cp
, n
);
573 lp
->l_length
= (size_t)--n
;
580 mp
->ma_contents
= lst
;
581 mp
->ma_maxlen
= maxlen
;
583 if (_malook(mp
->ma_name
, mp
, mafl
) != NULL
) {
584 if (!(mafl
& MA_ACC
)) {
585 fprintf(stderr
, tr(76, "A macro named \"%s\" already exists.\n"),
587 lst
= mp
->ma_contents
;
590 _undef1(mp
->ma_name
, MA_ACC
);
591 _malook(mp
->ma_name
, mp
, MA_ACC
);
608 _undef1(char const *name
, enum ma_flags mafl
)
612 if ((mp
= _malook(name
, NULL
, mafl
| MA_UNDEF
)) != NULL
) {
613 _freelines(mp
->ma_contents
);
620 _freelines(struct mline
*lp
)
624 for (lq
= NULL
; lp
!= NULL
; ) {
635 _var_list_all_cmp(void const *s1
, void const *s2
)
637 return strcmp(*(char**)UNCONST(s1
), *(char**)UNCONST(s2
));
641 _localopts_add(struct lostack
*losp
, char const *name
, struct var
*ovap
)
646 /* Propagate unrolling up the stack, as necessary */
647 while (!losp
->s_unroll
&& (losp
= losp
->s_up
) != NULL
)
652 /* We've found a level that wants to unroll; check wether it does it yet */
653 for (vap
= losp
->s_localopts
; vap
!= NULL
; vap
= vap
->v_link
)
654 if (strcmp(vap
->v_name
, name
) == 0)
657 nl
= strlen(name
) + 1;
658 vl
= (ovap
!= NULL
) ? strlen(ovap
->v_value
) + 1 : 0;
659 vap
= smalloc(sizeof(*vap
) - VFIELD_SIZEOF(struct var
, v_name
) + nl
+ vl
);
660 vap
->v_link
= losp
->s_localopts
;
661 losp
->s_localopts
= vap
;
662 memcpy(vap
->v_name
, name
, nl
);
666 vap
->v_value
= vap
->v_name
+ nl
;
667 memcpy(vap
->v_value
, ovap
->v_value
, vl
);
674 _localopts_unroll(struct var
**vapp
)
676 struct lostack
*save_los
;
682 save_los
= _localopts
;
684 while (vap
!= NULL
) {
687 vok_vset(x
->v_name
, x
->v_value
);
690 _localopts
= save_los
;
694 _var_oklook(enum okeys okey
)
696 struct var_carrier vc
;
699 vc
.vc_vmap
= _var_map
+ okey
;
700 vc
.vc_name
= _var_keydat
+ _var_map
[okey
].vm_keyoff
;
701 vc
.vc_hash
= _var_map
[okey
].vm_hash
;
704 if (!_var_lookup(&vc
)) {
705 if ((rv
= getenv(vc
.vc_name
)) != NULL
) {
707 assert(vc
.vc_var
!= NULL
);
712 rv
= vc
.vc_var
->v_value
;
717 _var_okset(enum okeys okey
, uintptr_t val
)
719 struct var_carrier vc
;
721 vc
.vc_vmap
= _var_map
+ okey
;
722 vc
.vc_name
= _var_keydat
+ _var_map
[okey
].vm_keyoff
;
723 vc
.vc_hash
= _var_map
[okey
].vm_hash
;
726 return _var_set(&vc
, (val
== 0x1 ? "" : (char const*)val
));
730 _var_okclear(enum okeys okey
)
732 struct var_carrier vc
;
734 vc
.vc_vmap
= _var_map
+ okey
;
735 vc
.vc_name
= _var_keydat
+ _var_map
[okey
].vm_keyoff
;
736 vc
.vc_hash
= _var_map
[okey
].vm_hash
;
739 return _var_clear(&vc
);
743 _var_voklook(char const *vokey
)
745 struct var_carrier vc
;
748 _var_revlookup(&vc
, vokey
);
750 if (!_var_lookup(&vc
)) {
751 if ((rv
= getenv(vc
.vc_name
)) != NULL
) {
753 assert(vc
.vc_var
!= NULL
);
758 rv
= vc
.vc_var
->v_value
;
763 _var_vokset(char const *vokey
, uintptr_t val
)
765 struct var_carrier vc
;
767 _var_revlookup(&vc
, vokey
);
769 return _var_set(&vc
, (val
== 0x1 ? "" : (char const*)val
));
773 _var_vokclear(char const *vokey
)
775 struct var_carrier vc
;
777 _var_revlookup(&vc
, vokey
);
779 return _var_clear(&vc
);
786 char *cp
, **vacp
, **cap
;
791 if ((fp
= Ftemp(&cp
, "Ra", "w+", 0600, 1)) == NULL
) {
798 for (no
= i
= 0; i
< MA_PRIME
; ++i
)
799 for (vp
= _vars
[i
]; vp
!= NULL
; vp
= vp
->v_link
)
801 vacp
= salloc(no
* sizeof(*vacp
));
802 for (cap
= vacp
, i
= 0; i
< MA_PRIME
; ++i
)
803 for (vp
= _vars
[i
]; vp
!= NULL
; vp
= vp
->v_link
)
807 qsort(vacp
, no
, sizeof *vacp
, &_var_list_all_cmp
);
809 i
= (ok_blook(bsdcompat
) || ok_blook(bsdset
));
810 fmt
= (i
!= 0) ? "%s\t%s\n" : "%s=\"%s\"\n";
812 for (cap
= vacp
; no
!= 0; ++cap
, --no
) {
813 cp
= vok_vlook(*cap
); /* XXX when lookup checks value/binary, change */
816 if (i
|| *cp
!= '\0')
817 fprintf(fp
, fmt
, *cap
, cp
);
819 fprintf(fp
, "%s\n", *cap
);
822 page_or_print(fp
, PTR2SIZE(cap
- vacp
));
829 c_var_inspect(void *v
)
831 struct var_carrier vc
;
832 char **argv
= v
, *val
;
840 for (; *argv
!= NULL
; ++argv
) {
841 memset(&vc
, 0, sizeof vc
);
842 _var_revlookup(&vc
, *argv
);
843 if (_var_lookup(&vc
)) {
844 val
= vc
.vc_var
->v_value
;
847 isenv
= ((val
= getenv(vc
.vc_name
)) != NULL
);
849 val
= UNCONST("NULL");
850 isset
= (vc
.vc_var
!= NULL
);
852 if (vc
.vc_vmap
!= NULL
) {
853 if (vc
.vc_vmap
->vm_binary
)
854 printf("%s: binary option (%d): isset=%d/environ=%d\n",
855 vc
.vc_name
, vc
.vc_okey
, isset
, isenv
);
857 printf("%s: value option (%d): isset=%d/environ=%d value<%s>\n",
858 vc
.vc_name
, vc
.vc_okey
, isset
, isenv
, val
);
860 printf("%s: isset=%d/environ=%d value<%s>\n",
861 vc
.vc_name
, isset
, isenv
, val
);
864 return (v
== NULL
? !STOP
: !OKAY
); /* xxx 1:bad 0:good -- do some */
874 if (args
[0] == NULL
) {
875 errs
= tr(504, "Missing macro name to `define'");
878 if (args
[1] == NULL
|| args
[1][0] != '{' || args
[1][1] != '\0' ||
880 errs
= tr(505, "Syntax is: define <name> {");
883 rv
= !_define1(args
[0], MA_NONE
);
887 fprintf(stderr
, "%s\n", errs
);
898 fprintf(stderr
, tr(506, "Missing macro name to `undef'\n"));
902 _undef1(*args
, MA_NONE
);
903 while (*++args
!= NULL
);
914 char const *errs
, *name
;
917 if (args
[0] == NULL
|| (args
[1] != NULL
&& args
[2] != NULL
)) {
918 errs
= tr(507, "Syntax is: call <%s>\n");
923 if ((mp
= _malook(*args
, NULL
, MA_NONE
)) == NULL
) {
924 errs
= tr(508, "Undefined macro called: \"%s\"\n");
929 rv
= _maexec(mp
, NULL
);
933 fprintf(stderr
, errs
, name
);
938 callhook(char const *name
, int nmail
)
944 var
= ac_alloc(len
= strlen(name
) + 13);
945 snprintf(var
, len
, "folder-hook-%s", name
);
946 if ((cp
= vok_vlook(var
)) == NULL
&& (cp
= ok_vlook(folder_hook
)) == NULL
) {
950 if ((mp
= _malook(cp
, NULL
, MA_NONE
)) == NULL
) {
951 fprintf(stderr
, tr(49, "Cannot call hook for folder \"%s\": "
952 "Macro \"%s\" does not exist.\n"), name
, cp
);
957 inhook
= nmail
? 3 : 1; /* XXX enum state machine */
958 rv
= _maexec(mp
, NULL
);
969 return _list_macros(MA_NONE
);
977 int rv
= 1, i
, oqf
, nqf
;
979 if (args
[0] == NULL
) {
980 rv
= _list_macros(MA_ACC
);
984 if (args
[1] && args
[1][0] == '{' && args
[1][1] == '\0') {
985 if (args
[2] != NULL
) {
986 fprintf(stderr
, tr(517, "Syntax is: account <name> {\n"));
989 if (asccasecmp(args
[0], ACCOUNT_NULL
) == 0) {
990 fprintf(stderr
, tr(521, "Error: `%s' is a reserved name.\n"),
994 rv
= !_define1(args
[0], MA_ACC
);
999 fprintf(stderr
, tr(518, "Cannot change account from within a hook.\n"));
1003 save_mbox_for_possible_quitstuff();
1006 if (asccasecmp(args
[0], ACCOUNT_NULL
) != 0 &&
1007 (mp
= _malook(args
[0], NULL
, MA_ACC
)) == NULL
) {
1008 fprintf(stderr
, tr(519, "Account `%s' does not exist.\n"), args
[0]);
1012 oqf
= savequitflags();
1013 if (_acc_curr
!= NULL
)
1014 _localopts_unroll(&_acc_curr
->ma_localopts
);
1015 account_name
= (mp
!= NULL
) ? mp
->ma_name
: NULL
;
1018 if (mp
!= NULL
&& _maexec(mp
, &mp
->ma_localopts
) == CBAD
) {
1019 /* XXX account switch incomplete, unroll? */
1020 fprintf(stderr
, tr(520, "Switching to account `%s' failed.\n"), args
[0]);
1024 if (!starting
&& !inhook
) {
1025 nqf
= savequitflags(); /* TODO obsolete (leave -> void -> new box!) */
1026 restorequitflags(oqf
);
1027 if ((i
= setfile("%", 0)) < 0)
1029 callhook(mailname
, 0);
1030 if (i
> 0 && !ok_blook(emptystart
))
1032 announce(ok_blook(bsdcompat
) || ok_blook(bsdannounce
));
1033 restorequitflags(nqf
);
1041 c_localopts(void *v
)
1046 if (_localopts
== NULL
) {
1047 fprintf(stderr
, tr(522,
1048 "Cannot use `localopts' but from within a `define' or `account'\n"));
1052 _localopts
->s_unroll
= (**c
== '0') ? FAL0
: TRU1
;
1058 /* vim:set fenc=utf-8:s-it-mode */