1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ Header display, search, etc., related user commands.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
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. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #define n_FILE cmd_headers
38 #ifndef HAVE_AMALGAMATION
44 /* ... And place the extracted date in `date' */
45 static void _parse_from_(struct message
*mp
, char date
[FROM_DATEBUF
]);
47 /* Print out the header of a specific message
48 * __hprf: handle *headline*
49 * __subject: return -1 if Subject: yet seen, otherwise smalloc()d Subject:
50 * __putindent: print out the indenting in threaded display */
51 static void _print_head(size_t yetprinted
, size_t msgno
, FILE *f
,
53 static void __hprf(size_t yetprinted
, char const *fmt
, size_t msgno
,
54 FILE *f
, bool_t threaded
, char const *attrlist
);
55 static char * __subject(struct message
*mp
, bool_t threaded
,
57 static int __putindent(FILE *fp
, struct message
*mp
, int maxwidth
);
59 static int _dispc(struct message
*mp
, char const *a
);
61 /* Shared `z' implementation */
62 static int a_cmd_scroll(char const *arg
, bool_t onlynew
);
64 /* Shared `headers' implementation */
65 static int _headers(int msgspec
);
68 _parse_from_(struct message
*mp
, char date
[FROM_DATEBUF
]) /* TODO line pool */
76 if ((ibuf
= setinput(&mb
, mp
, NEED_HEADER
)) != NULL
&&
77 (hlen
= readline_restart(ibuf
, &hline
, &hsize
, 0)) > 0)
78 extract_date_from_from_(hline
, hlen
, date
);
85 _print_head(size_t yetprinted
, size_t msgno
, FILE *f
, bool_t threaded
)
88 char attrlist
[attrlen
+1], *cp
;
92 if ((cp
= ok_vlook(attrlist
)) != NULL
) {
93 if (strlen(cp
) == attrlen
) {
94 memcpy(attrlist
, cp
, attrlen
+1);
97 n_err(_("*attrlist* is not of the correct length, using builtin\n"));
100 if (ok_blook(bsdcompat
) || ok_blook(bsdflags
)) {
101 char const bsdattr
[attrlen
+1] = "NU *HMFAT+-$~";
102 memcpy(attrlist
, bsdattr
, sizeof bsdattr
);
103 } else if (ok_blook(SYSV3
)) {
104 char const bsdattr
[attrlen
+1] = "NU *HMFAT+-$~";
105 memcpy(attrlist
, bsdattr
, sizeof bsdattr
);
106 n_OBSOLETE(_("*SYSV3*: please use *bsdcompat* or *bsdflags*, "
107 "or set *attrlist*"));
109 char const pattr
[attrlen
+1] = "NUROSPMFAT+-$~";
110 memcpy(attrlist
, pattr
, sizeof pattr
);
114 if ((fmt
= ok_vlook(headline
)) == NULL
) {
115 fmt
= ((ok_blook(bsdcompat
) || ok_blook(bsdheadline
))
116 ? "%>%a%m %-20f %16d %4l/%-5o %i%-S"
117 : "%>%a%m %-18f %-16d %4l/%-5o %i%-s");
120 __hprf(yetprinted
, fmt
, msgno
, f
, threaded
, attrlist
);
125 __hprf(size_t yetprinted
, char const *fmt
, size_t msgno
, FILE *f
,
126 bool_t threaded
, char const *attrlist
)
128 char buf
[16], datebuf
[FROM_DATEBUF
], cbuf
[8], *cp
, *subjline
;
129 char const *datefmt
, *date
, *name
, *fp
n_COLOUR( COMMA
*colo_tag
);
130 int i
, n
, s
, wleft
, subjlen
;
133 n_COLOUR( struct n_colour_pen
*cpen_new COMMA
*cpen_cur COMMA
*cpen_bas
; )
140 _LOOP_MASK
= (1<<4) - 1,
141 _SFMT
= 1<<4, /* It is 'S' */
142 /* For the simple byte-based counts in wleft and n we sometimes need
143 * adjustments to compensate for additional bytes of UTF-8 sequences */
144 _PUTCB_UTF8_SHIFT
= 5,
145 _PUTCB_UTF8_MASK
= 3<<5
150 if ((mp
= message
+ msgno
- 1) == dot
)
154 n_COLOUR( colo_tag
= NULL
; )
156 datefmt
= ok_vlook(datefield
);
158 if (datefmt
!= NULL
) {
159 fp
= hfield1("date", mp
);/* TODO use m_date field! */
165 date
= fakedate(datet
);
166 fp
= ok_vlook(datefield_markout_older
);
167 i
= (*datefmt
!= '\0');
169 i
|= (*fp
!= '\0') ? 2 | 4 : 2; /* XXX no magics */
171 /* May we strftime(3)? */
173 memcpy(&time_current
.tc_local
, localtime(&datet
),
174 sizeof time_current
.tc_local
);
176 if ((i
& 2) && (datet
> time_current
.tc_time
+ DATE_SECSDAY
||
177 #define _6M ((DATE_DAYSYEAR / 2) * DATE_SECSDAY)
178 (datet
+ _6M
< time_current
.tc_time
))) {
180 if ((datefmt
= (i
& 4) ? fp
: NULL
) == NULL
) {
181 memset(datebuf
, ' ', FROM_DATEBUF
); /* xxx ur */
182 memcpy(datebuf
+ 4, date
+ 4, 7);
183 datebuf
[4 + 7] = ' ';
184 memcpy(datebuf
+ 4 + 7 + 1, date
+ 20, 4);
185 datebuf
[4 + 7 + 1 + 4] = '\0';
188 n_COLOUR( colo_tag
= n_COLOUR_TAG_SUM_OLDER
; )
189 } else if ((i
& 1) == 0)
191 } else if (datet
== (time_t)0 && !(mp
->m_flag
& MNOFROM
)) {
192 /* TODO eliminate this path, query the FROM_ date in setptr(),
193 * TODO all other codepaths do so by themselves ALREADY ?????
194 * TODO assert(mp->m_time != 0);, then
195 * TODO ALSO changes behaviour of datefield_markout_older */
196 _parse_from_(mp
, datebuf
);
199 date
= fakedate(datet
);
203 if (name
!= NULL
&& ok_blook(showto
) && is_myname(skin(name
))) {
204 if ((cp
= hfield1("to", mp
)) != NULL
) {
214 name
= ok_blook(showname
) ? realname(name
) : prstr(skin(name
));
218 /* Detect the width of the non-format characters in *headline*;
219 * like that we can simply use putc() in the next loop, since we have
220 * already calculated their column widths (TODO it's sick) */
221 wleft
= subjlen
= n_scrnwidth
;
223 for (fp
= fmt
; *fp
!= '\0'; ++fp
) {
229 if (digitchar(*fp
)) {
232 n
= 10*n
+ *fp
- '0';
233 while (++fp
, digitchar(*fp
));
243 if (n_mb_cur_max
> 1) {
245 if ((s
= mbtowc(&wc
, fp
, n_mb_cur_max
)) == -1)
247 else if ((n
= wcwidth(wc
)) == -1)
259 /* Walk *headline*, producing output TODO not (really) MB safe */
262 colo_tag
= n_COLOUR_TAG_SUM_DOT
;
263 cpen_bas
= n_colour_pen_create(n_COLOUR_ID_SUM_HEADER
, colo_tag
);
264 n_colour_pen_put(cpen_new
= cpen_cur
= cpen_bas
, f
);
267 for (fp
= fmt
; *fp
!= '\0'; ++fp
) {
270 if ((c
= *fp
& 0xFF) != '%') {
272 if ((cpen_new
= cpen_bas
) != cpen_cur
)
273 n_colour_pen_put(cpen_cur
= cpen_new
, f
);
282 if ((c
= *++fp
) == '-') {
287 if (digitchar(*fp
)) {
289 n
= 10*n
+ *fp
- '0';
290 while (++fp
, digitchar(*fp
));
293 if ((c
= *fp
& 0xFF) == '\0')
303 if (flags
& _ISDOT
) {
304 n_COLOUR( cpen_new
= n_colour_pen_create(n_COLOUR_ID_SUM_DOTMARK
,
306 if (n_psonce
& n_PSO_UNICODE
) {
308 /* 25B8;BLACK RIGHT-POINTING SMALL TRIANGLE: â–¸ */
309 cbuf
[1] = (char)0x96, cbuf
[2] = (char)0xB8;
311 /* 25C2;BLACK LEFT-POINTING SMALL TRIANGLE: â—‚ */
312 cbuf
[1] = (char)0x97, cbuf
[2] = (char)0x82;
315 flags
|= 2 << _PUTCB_UTF8_SHIFT
;
324 if (UICMP(32, n_ABS(n
), >, wleft
))
325 n
= (n
< 0) ? -wleft
: wleft
;
326 snprintf(buf
, sizeof buf
, "%u.%02u",
327 (mp
->m_spamscore
>> 8), (mp
->m_spamscore
& 0xFF));
328 n
= fprintf(f
, "%*s", n
, buf
);
329 wleft
= (n
>= 0) ? wleft
- n
: 0;
336 c
= _dispc(mp
, attrlist
);
339 if (cpen_new
== cpen_cur
)
341 if (cpen_new
!= cpen_cur
)
342 n_colour_pen_put(cpen_cur
= cpen_new
, f
);
344 if (UICMP(32, n_ABS(n
), >, wleft
))
345 n
= (n
< 0) ? -wleft
: wleft
;
347 n
= fprintf(f
, "%*s", n
, cbuf
);
350 if ((n
= (flags
& _PUTCB_UTF8_MASK
)) != 0) {
351 n
>>= _PUTCB_UTF8_SHIFT
;
355 wleft
= 0; /* TODO I/O error.. ? break? */
358 if ((cpen_new
= cpen_bas
) != cpen_cur
)
359 n_colour_pen_put(cpen_cur
= cpen_new
, f
);
363 if (datefmt
!= NULL
) {
364 i
= strftime(datebuf
, sizeof datebuf
, datefmt
,
365 &time_current
.tc_local
);
369 n_err(_("Ignored date format, it excesses the target "
370 "buffer (%lu bytes)\n"), (ul_i
)sizeof(datebuf
));
375 if (UICMP(32, n_ABS(n
), >, wleft
))
376 n
= (n
< 0) ? -wleft
: wleft
;
377 n
= fprintf(f
, "%*.*s", n
, n_ABS(n
), date
);
378 wleft
= (n
>= 0) ? wleft
- n
: 0;
383 if (UICMP(32, n_ABS(n
), >, wleft
))
384 n
= (n
< 0) ? -wleft
: wleft
;
385 n
= fprintf(f
, "%*u", n
, (threaded
== 1 ? mp
->m_level
: 0));
386 wleft
= (n
>= 0) ? wleft
- n
: 0;
397 n
= (n
< 0) ? -wleft
: wleft
;
399 if (flags
& _ISTO
) /* XXX tr()! */
401 n
= fprintf(f
, "%s%s", ((flags
& _ISTO
) ? "To " : n_empty
),
402 colalign(name
, i
, n
, &wleft
));
405 else if (flags
& _ISTO
)
411 cpen_new
= n_colour_pen_create(n_COLOUR_ID_SUM_THREAD
, colo_tag
);
412 if (cpen_new
!= cpen_cur
)
413 n_colour_pen_put(cpen_cur
= cpen_new
, f
);
415 n
= __putindent(f
, mp
, n_MIN(wleft
, (int)n_scrnwidth
- 60));
416 wleft
= (n
>= 0) ? wleft
- n
: 0;
418 if ((cpen_new
= cpen_bas
) != cpen_cur
)
419 n_colour_pen_put(cpen_cur
= cpen_new
, f
);
426 if (UICMP(32, n_ABS(n
), >, wleft
))
427 n
= (n
< 0) ? -wleft
: wleft
;
429 n
= fprintf(f
, "%*ld", n
, mp
->m_xlines
);
430 wleft
= (n
>= 0) ? wleft
- n
: 0;
442 for (i
= msgCount
; i
> 999; i
/= 10)
445 if (UICMP(32, n_ABS(n
), >, wleft
))
446 n
= (n
< 0) ? -wleft
: wleft
;
447 n
= fprintf(f
, "%*lu", n
, (ul_i
)msgno
);
448 wleft
= (n
>= 0) ? wleft
- n
: 0;
453 if (UICMP(32, n_ABS(n
), >, wleft
))
454 n
= (n
< 0) ? -wleft
: wleft
;
455 n
= fprintf(f
, "%*lu", n
, (ul_i
)mp
->m_xsize
);
456 wleft
= (n
>= 0) ? wleft
- n
: 0;
468 if (UICMP(32, n_ABS(n
), >, subjlen
))
469 n
= (n
< 0) ? -subjlen
: subjlen
;
471 n
-= (n
< 0) ? -2 : 2;
474 if (subjline
== NULL
)
475 subjline
= __subject(mp
, (threaded
&& (flags
& _IFMT
)), yetprinted
);
476 if (subjline
== (char*)-1) {
477 n
= fprintf(f
, "%*s", n
, n_empty
);
478 wleft
= (n
>= 0) ? wleft
- n
: 0;
480 n
= fprintf(f
, ((flags
& _SFMT
) ? "\"%s\"" : "%s"),
481 colalign(subjline
, n_ABS(n
), n
, &wleft
));
486 case 'T': { /* Message recipient flags */
487 /* We never can reuse "name" since it's the full name */
488 struct name
const *np
= lextract(hfield1("to", mp
), GTO
| GSKIN
);
492 for (; np
!= NULL
; np
= np
->n_flink
) {
493 switch (is_mlist(np
->n_name
, FAL0
)) {
494 case MLIST_SUBSCRIBED
: c
= 'S'; goto jputcb
;
495 case MLIST_KNOWN
: c
= 'L'; goto jputcb
;
503 np
= lextract(hfield1("cc", mp
), GCC
| GSKIN
);
510 for (i
= msgCount
; i
> 999; i
/= 10)
513 if (UICMP(32, n_ABS(n
), >, wleft
))
514 n
= (n
< 0) ? -wleft
: wleft
;
515 n
= fprintf(f
, "%*lu",
516 n
, (threaded
? (ul_i
)mp
->m_threadpos
: (ul_i
)msgno
));
517 wleft
= (n
>= 0) ? wleft
- n
: 0;
520 if (n_poption
& n_PO_D_V
)
521 n_err(_("Unkown *headline* format: %%%c\n"), c
);
535 if (subjline
!= NULL
&& subjline
!= (char*)-1)
541 __subject(struct message
*mp
, bool_t threaded
, size_t yetprinted
)
549 if ((ms
= hfield1("subject", mp
)) == NULL
)
552 in
.l
= strlen(in
.s
= ms
);
553 mime_fromhdr(&in
, &out
, TD_ICONV
| TD_ISPR
);
556 if (!threaded
|| mp
->m_level
== 0)
559 /* In a display thread - check whether this message uses the same
560 * Subject: as it's parent or elder neighbour, suppress printing it if
561 * this is the case. To extend this a bit, ignore any leading Re: or
562 * Fwd: plus follow-up WS. Ignore invisible messages along the way */
563 ms
= n_UNCONST(subject_re_trim(n_UNCONST(ms
)));
565 for (; (mp
= prev_in_thread(mp
)) != NULL
&& yetprinted
-- > 0;) {
568 if (visible(mp
) && (os
= hfield1("subject", mp
)) != NULL
) {
572 in
.l
= strlen(in
.s
= os
);
573 mime_fromhdr(&in
, &oout
, TD_ICONV
| TD_ISPR
);
574 x
= asccasecmp(ms
, subject_re_trim(oout
.s
));
590 __putindent(FILE *fp
, struct message
*mp
, int maxwidth
)/* XXX no magic consts */
593 int *us
, indlvl
, indw
, i
, important
= MNEW
| MFLAGGED
;
597 if (mp
->m_level
== 0 || maxwidth
== 0) {
602 cs
= ac_alloc(mp
->m_level
);
603 us
= ac_alloc(mp
->m_level
* sizeof *us
);
606 if (mp
->m_younger
&& UICMP(32, i
+ 1, ==, mp
->m_younger
->m_level
)) {
607 if (mp
->m_parent
&& mp
->m_parent
->m_flag
& important
)
608 us
[i
] = mp
->m_flag
& important
? 0x2523 : 0x2520;
610 us
[i
] = mp
->m_flag
& important
? 0x251D : 0x251C;
613 if (mp
->m_parent
&& mp
->m_parent
->m_flag
& important
)
614 us
[i
] = mp
->m_flag
& important
? 0x2517 : 0x2516;
616 us
[i
] = mp
->m_flag
& important
? 0x2515 : 0x2514;
621 for (i
= mp
->m_level
- 2; i
>= 0; --i
) {
623 if (UICMP(32, i
, >, mq
->m_level
- 1)) {
628 if (mq
->m_parent
&& (mq
->m_parent
->m_flag
& important
))
641 for (indlvl
= indw
= 0; (ui8_t
)indlvl
< mp
->m_level
&& indw
< maxwidth
;
643 if (indw
< maxwidth
- 1)
644 indw
+= (int)putuc(us
[indlvl
], cs
[indlvl
] & 0xFF, fp
);
646 indw
+= (int)putuc(0x21B8, '^', fp
);
648 indw
+= putuc(0x25B8, '>', fp
);
658 _dispc(struct message
*mp
, char const *a
)
663 if ((mp
->m_flag
& (MREAD
| MNEW
)) == MREAD
)
665 if ((mp
->m_flag
& (MREAD
| MNEW
)) == (MREAD
| MNEW
))
667 if (mp
->m_flag
& MANSWERED
)
669 if (mp
->m_flag
& MDRAFTED
)
671 if ((mp
->m_flag
& (MREAD
| MNEW
)) == MNEW
)
673 if (!(mp
->m_flag
& (MREAD
| MNEW
)))
675 if (mp
->m_flag
& MSPAM
)
677 if (mp
->m_flag
& MSPAMUNSURE
)
679 if (mp
->m_flag
& MSAVED
)
681 if (mp
->m_flag
& MPRESERVE
)
683 if (mp
->m_flag
& (MBOX
| MBOXED
))
685 if (mp
->m_flag
& MFLAGGED
)
687 if (mb
.mb_threaded
== 1 && mp
->m_collapsed
> 0)
689 if (mb
.mb_threaded
== 1 && mp
->m_collapsed
< 0)
696 a_cmd_scroll(char const *arg
, bool_t onlynew
){
699 int msgspec
, size
, maxs
;
702 /* TODO scroll problem: we do not know whether + and $ have already reached
703 * TODO the last screen in threaded mode */
704 msgspec
= onlynew
? -1 : 0;
705 size
= (int)/*TODO*/n_screensize();
706 if((maxs
= msgCount
/ size
) > 0 && msgCount
% size
== 0)
735 case '1': case '2': case '3': case '4': case '5':
736 case '6': case '7': case '8': case '9': case '0':
739 if((n_idec_siz_cp(&l
, arg
, 0, NULL
740 ) & (n_IDEC_STATE_EMASK
| n_IDEC_STATE_CONSUMED
)
741 ) != n_IDEC_STATE_CONSUMED
)
743 if(l
> maxs
- (isabs
? 0 : _screen
))
745 _screen
= isabs
? (int)l
: _screen
+ l
;
751 fprintf(n_stdout
, _("On last screenful of messages\n"));
759 if((n_idec_siz_cp(&l
, ++arg
, 0, NULL
760 ) & (n_IDEC_STATE_EMASK
| n_IDEC_STATE_CONSUMED
)
761 ) != n_IDEC_STATE_CONSUMED
)
770 fprintf(n_stdout
, _("On first screenful of messages\n"));
777 n_err(_("Unrecognized scrolling command: %s\n"), arg
);
782 size
= _headers(msgspec
);
789 _headers(int msgspec
) /* TODO rework v15 */
792 bool_t
volatile isrelax
;
793 ui32_t
volatile flag
;
794 int g
, k
, mesg
, size
;
795 int volatile lastg
= 1;
796 struct message
*mp
, *mq
, *lastmq
= NULL
;
797 enum mflag fl
= MNEW
| MFLAGGED
;
800 time_current_update(&time_current
, FAL0
);
804 n_SIGMAN_ENTER_SWITCH(&sm
, n_SIGMAN_ALL
) {
812 if (n_psonce
& n_PSO_INTERACTIVE
)
813 n_colour_env_create(n_COLOUR_CTX_SUM
, FAL0
);
816 size
= (int)/*TODO*/n_screensize();
819 #if 0 /* FIXME original code path */
832 if (mb
.mb_threaded
== 0) {
835 for (mp
= message
; PTRCMP(mp
, <, message
+ msgCount
); ++mp
)
839 if (mp
->m_flag
& fl
) {
843 if ((msgspec
> 0 && PTRCMP(mp
, ==, message
+ msgspec
- 1)) ||
844 (msgspec
== 0 && g
== k
) ||
845 (msgspec
== -2 && g
== k
+ size
&& lastmq
) ||
846 (msgspec
< 0 && g
>= k
&& (mp
->m_flag
& fl
) != 0))
850 if (lastmq
&& (msgspec
== -2 ||
851 (msgspec
== -1 && PTRCMP(mp
, ==, message
+ msgCount
)))) {
858 mesg
= (int)PTR2SIZE(mp
- message
);
859 if (PTRCMP(dot
, !=, message
+ msgspec
- 1)) { /* TODO really?? */
860 for (mq
= mp
; PTRCMP(mq
, <, message
+ msgCount
); ++mq
)
869 for (; PTRCMP(mp
, <, message
+ msgCount
); ++mp
) {
873 if (UICMP(32, flag
++, >=, size
))
875 _print_head(0, mesg
, n_stdout
, 0);
880 } else { /* threaded */
883 for (mp
= threadroot
; mp
; mp
= next_in_thread(mp
))
885 (mp
->m_collapsed
<= 0 ||
886 PTRCMP(mp
, ==, message
+ msgspec
- 1))) {
889 if (mp
->m_flag
& fl
) {
893 if ((msgspec
> 0 && PTRCMP(mp
, ==, message
+ msgspec
- 1)) ||
894 (msgspec
== 0 && g
== k
) ||
895 (msgspec
== -2 && g
== k
+ size
&& lastmq
) ||
896 (msgspec
< 0 && g
>= k
&& (mp
->m_flag
& fl
) != 0))
900 if (lastmq
&& (msgspec
== -2 ||
901 (msgspec
== -1 && PTRCMP(mp
, ==, message
+ msgCount
)))) {
907 if (PTRCMP(dot
, !=, message
+ msgspec
- 1)) { /* TODO really?? */
908 for (mq
= mp
; mq
; mq
= next_in_thread(mq
))
909 if (visible(mq
) && mq
->m_collapsed
<= 0) {
919 (mp
->m_collapsed
<= 0 ||
920 PTRCMP(mp
, ==, message
+ msgspec
- 1))) {
921 if (UICMP(32, flag
++, >=, size
))
923 _print_head(flag
- 1, PTR2SIZE(mp
- message
+ 1), n_stdout
,
927 mp
= next_in_thread(mp
);
934 fprintf(n_stdout
, _("No more mail.\n"));
935 if (n_pstate
& (n_PS_ROBOT
| n_PS_HOOK_MASK
))
939 n_sigman_cleanup_ping(&sm
);
943 n_COLOUR( n_colour_env_gut((sm
.sm_signo
!= SIGPIPE
) ? n_stdout
: NULL
); )
945 n_sigman_leave(&sm
, n_SIGMAN_VIPSIGS_NTTYOUT
);
955 rv
= print_header_group((int*)v
);
961 print_header_group(int *vector
)
966 assert(vector
!= NULL
&& vector
!= (void*)-1);
967 rv
= _headers(vector
[0]);
978 rv
= a_cmd_scroll(v
, FAL0
);
989 rv
= a_cmd_scroll(v
, TRU1
);
1001 if (*(args
= v
) == '\0' || args
[1] != '\0') {
1003 n_err(_("Synopsis: dotmove: up <-> or down <+> by one message\n"));
1005 } else switch (args
[0]) {
1008 if (msgCount
== 0) {
1009 fprintf(n_stdout
, _("At EOF\n"));
1011 } else if (getmsglist(n_UNCONST(/*TODO*/ args
), msgvec
, 0) > 0) {
1012 setdot(message
+ msgvec
[0] - 1);
1014 rv
= c_headers(msgvec
);
1029 int *msgvec
= v
, *ip
, n
;
1031 FILE * volatile obuf
;
1032 bool_t
volatile isrelax
;
1035 time_current_update(&time_current
, FAL0
);
1039 n_SIGMAN_ENTER_SWITCH(&sm
, n_SIGMAN_ALL
) {
1046 if (n_psonce
& n_PSO_INTERACTIVE
) {
1047 if ((cp
= ok_vlook(crt
)) != NULL
) {
1050 for (n
= 0, ip
= msgvec
; *ip
!= 0; ++ip
)
1054 ib
= n_screensize();
1056 n_idec_uiz_cp(&ib
, cp
, 0, NULL
);
1057 if (UICMP(z
, n
, >, ib
) && (obuf
= n_pager_open()) == NULL
)
1060 n_COLOUR( n_colour_env_create(n_COLOUR_CTX_SUM
, obuf
!= n_stdout
); )
1063 /* Update dot before display so that the dotmark etc. are correct */
1064 for (ip
= msgvec
; *ip
!= 0; ++ip
)
1067 setdot(message
+ *ip
- 1);
1071 for (n
= 0, ip
= msgvec
; *ip
!= 0; ++ip
) { /* TODO join into _print_head() */
1072 _print_head((size_t)n
++, (size_t)*ip
, obuf
, mb
.mb_threaded
);
1078 n_sigman_cleanup_ping(&sm
);
1082 n_COLOUR( n_colour_env_gut((sm
.sm_signo
!= SIGPIPE
) ? obuf
: NULL
); )
1083 if (obuf
!= n_stdout
)
1084 n_pager_close(obuf
);
1086 n_sigman_leave(&sm
, n_SIGMAN_VIPSIGS_NTTYOUT
);
1091 print_headers(size_t bottom
, size_t topx
, bool_t only_marked
)
1094 bool_t
volatile isrelax
;
1098 time_current_update(&time_current
, FAL0
);
1101 n_SIGMAN_ENTER_SWITCH(&sm
, n_SIGMAN_ALL
) {
1109 if (n_psonce
& n_PSO_INTERACTIVE
)
1110 n_colour_env_create(n_COLOUR_CTX_SUM
, FAL0
);
1115 for (printed
= 0; bottom
<= topx
; ++bottom
) {
1116 struct message
*mp
= message
+ bottom
- 1;
1118 if (!(mp
->m_flag
& MMARK
))
1120 } else if (!visible(mp
))
1122 _print_head(printed
++, bottom
, n_stdout
, FAL0
);
1128 n_sigman_cleanup_ping(&sm
);
1132 n_COLOUR( n_colour_env_gut((sm
.sm_signo
!= SIGPIPE
) ? n_stdout
: NULL
); )
1134 n_sigman_leave(&sm
, n_SIGMAN_VIPSIGS_NTTYOUT
);