* Copyright (c) 1980 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)cmd1.c 5.22 (Berkeley) 4/1/91";
* Print the current active headings.
* Don't change dot if invoker didn't give an argument.
register int n
, mesg
, flag
;
register struct message
*mp
;
mp
= &message
[screen
* size
];
if (mp
>= &message
[msgCount
])
mp
= &message
[msgCount
- size
];
if (dot
!= &message
[n
-1])
for (; mp
< &message
[msgCount
]; mp
++) {
if (mp
->m_flag
& MDELETED
)
printf("No more mail.\n");
* Scroll to the next/previous screen
if (s
* size
> msgCount
) {
printf("On last screenful of messages\n");
printf("On first screenful of messages\n");
printf("Unrecognized scrolling command \"%s\"\n", arg
);
if ((cp
= value("screen")) != NOSTR
&& (s
= atoi(cp
)) > 0)
* Print out the headlines for each message
* in the passed message list.
for (ip
= msgvec
; *ip
!= NULL
; ip
++)
* Print out the header of a specific message.
* This is a slight improvement to the standard one.
char headline
[LINESIZE
], wcount
[LINESIZE
], *subjline
, dispc
, curind
;
(void) readline(setinput(mp
), headline
, LINESIZE
);
if ((subjline
= hfield("subject", mp
)) == NOSTR
)
subjline
= hfield("subj", mp
);
curind
= dot
== mp
? '>' : ' ';
if (mp
->m_flag
& MPRESERVE
)
if ((mp
->m_flag
& (MREAD
|MNEW
)) == MNEW
)
if ((mp
->m_flag
& (MREAD
|MNEW
)) == 0)
parse(headline
, &hl
, pbuf
);
sprintf(wcount
, "%3d/%-5ld", mp
->m_lines
, mp
->m_size
);
subjlen
= screenwidth
- 50 - strlen(wcount
);
name
= value("show-rcpt") != NOSTR
?
skin(hfield("to", mp
)) : nameof(mp
, 0);
if (subjline
== NOSTR
|| subjlen
< 0) /* pretty pathetic */
printf("%c%c%3d %-20.20s %16.16s %s\n",
curind
, dispc
, mesg
, name
, hl
.l_date
, wcount
);
printf("%c%c%3d %-20.20s %16.16s %s \"%.*s\"\n",
curind
, dispc
, mesg
, name
, hl
.l_date
, wcount
,
* Print out the value of dot.
printf("%d\n", dot
- &message
[0] + 1);
* Print out all the possible commands.
extern struct cmd cmdtab
[];
printf("Commands are:\n");
for (cc
= 0, cp
= cmdtab
; cp
->c_name
!= NULL
; cp
++) {
cc
+= strlen(cp
->c_name
) + 2;
cc
= strlen(cp
->c_name
) + 2;
if ((cp
+1)->c_name
!= NOSTR
)
printf("%s, ", cp
->c_name
);
printf("%s\n", cp
->c_name
);
* Paginate messages, honor ignored fields.
return (type1(msgvec
, 1, 1));
* Paginate messages, even printing ignored fields.
return (type1(msgvec
, 0, 1));
* Type out messages, honor ignored fields.
return(type1(msgvec
, 1, 0));
* Type out messages, even printing ignored fields.
return(type1(msgvec
, 0, 0));
* Type out the messages requested.
type1(msgvec
, doign
, page
)
register struct message
*mp
;
if (value("interactive") != NOSTR
&&
(page
|| (cp
= value("crt")) != NOSTR
)) {
for (ip
= msgvec
; *ip
&& ip
-msgvec
< msgCount
; ip
++)
nlines
+= message
[*ip
- 1].m_lines
;
if (page
|| nlines
> (*cp
? atoi(cp
) : realscreenheight
)) {
if (cp
== NULL
|| *cp
== '\0')
signal(SIGPIPE
, brokpipe
);
for (ip
= msgvec
; *ip
&& ip
- msgvec
< msgCount
; ip
++) {
if (value("quiet") == NOSTR
)
fprintf(obuf
, "Message %d:\n", *ip
);
(void) send(mp
, obuf
, doign
? ignore
: 0, NOSTR
);
* Ignore SIGPIPE so it can't cause a duplicate close.
signal(SIGPIPE
, SIG_IGN
);
signal(SIGPIPE
, SIG_DFL
);
* Respond to a broken pipe signal --
* probably caused by quitting more.
* Print the top so many lines of each desired message.
* The number of lines is taken from the variable "toplines"
register struct message
*mp
;
int c
, topl
, lines
, lineb
;
char *valtop
, linebuf
[LINESIZE
];
valtop
= value("toplines");
if (topl
< 0 || topl
> 10000)
for (ip
= msgvec
; *ip
&& ip
-msgvec
< msgCount
; ip
++) {
if (value("quiet") == NOSTR
)
printf("Message %d:\n", *ip
);
for (lines
= 0; lines
< c
&& lines
<= topl
; lines
++) {
if (readline(ibuf
, linebuf
, LINESIZE
) < 0)
lineb
= blankline(linebuf
);
* Touch all the given messages so that they will
for (ip
= msgvec
; *ip
!= 0; ip
++) {
dot
->m_flag
&= ~MPRESERVE
;
* Make sure all passed messages get mboxed.
for (ip
= msgvec
; *ip
!= 0; ip
++) {
dot
->m_flag
|= MTOUCH
|MBOX
;
dot
->m_flag
&= ~MPRESERVE
;
* List the folders the user currently has.
if (getfold(dirname
) < 0) {
printf("No value set for \"folder\"\n");
if ((cmd
= value("LISTER")) == NOSTR
)
(void) run_command(cmd
, 0, -1, -1, dirname
, NOSTR
);