static char *SccsId
= "@(#)cmd2.c 1.3 %G%";
* If any arguments were given, go to the next applicable argument
* following dot, otherwise, go to the next applicable message.
* If given as first command with no arguments, print first message.
register struct message
*mp
;
* If some messages were supplied, find the
* first applicable one following dot using
mdot
= dot
- &message
[0] + 1;
* Find the first message in the supplied
* message list which follows dot.
for (ip
= msgvec
; *ip
!= NULL
; ip
++)
if ((mp
->m_flag
& MDELETED
) == 0) {
printf("No messages applicable\n");
* If this is the first command, select message 1.
* Note that this must exist for us to get here at all.
* Just find the next good message after dot, no
for (mp
= dot
+1; mp
< &message
[msgCount
]; mp
++)
if ((mp
->m_flag
& (MDELETED
|MSAVED
)) == 0)
if (mp
>= &message
[msgCount
]) {
list
[0] = dot
- &message
[0] + 1;
* Save the indicated messages at the end of the passed file name.
register struct message
*mp
;
int f
, *msgvec
, lc
, cc
, t
;
msgvec
= (int *) salloc((msgCount
+ 2) * sizeof *msgvec
);
if ((file
= snarf(str
, &f
)) == NOSTR
)
*msgvec
= first(0, MMNORM
);
printf("No messages to save.\n");
if (f
&& getmsglist(str
, msgvec
, 0) < 0)
if ((file
= expand(file
)) == NOSTR
)
if (stat(file
, &statb
) >= 0)
if ((obuf
= fopen(file
, "a")) == NULL
) {
for (ip
= msgvec
; *ip
&& ip
-msgvec
< msgCount
; ip
++) {
if ((t
= send(mp
, obuf
)) < 0) {
printf("%s %d/%d\n", disp
, lc
, cc
);
* Write the indicated messages at the end of the passed
* file name, minus header and trailing blank line.
register struct message
*mp
;
register char *file
, *disp
;
int f
, *msgvec
, lc
, cc
, t
;
msgvec
= (int *) salloc((msgCount
+ 2) * sizeof *msgvec
);
if ((file
= snarf(str
, &f
)) == NOSTR
)
if ((file
= expand(file
)) == NOSTR
)
*msgvec
= first(0, MMNORM
);
printf("No messages to write.\n");
if (f
&& getmsglist(str
, msgvec
, 0) < 0)
if (stat(file
, &statb
) >= 0)
if ((obuf
= fopen(file
, "a")) == NULL
) {
for (ip
= msgvec
; *ip
&& ip
-msgvec
< msgCount
; ip
++) {
fgets(linebuf
, BUFSIZ
, mesf
);
printf("%s %d/%d\n", disp
, lc
, cc
);
* Snarf the file from the end of the command line and
* return a pointer to it. If there is no file attached,
* just return NOSTR. Put a null in front of the file
* name so that the message list processing won't see it,
* unless the file name is the only thing on the line, in
* which case, return 0 in the reference flag variable.
cp
= strlen(linebuf
) + linebuf
- 1;
* Strip away trailing blanks.
while (*cp
== ' ' && cp
> linebuf
)
* Now search for the beginning of the file name.
while (cp
> linebuf
&& !any(*cp
, "\t "))
printf("No file specified.\n");
* Delete messages, then type the new dot.
list
[0] = dot
- &message
[0];
printf("No more messages\n");
* Delete the indicated messages.
* Set dot to some nice place afterwards.
register struct message
*mp
;
for (ip
= msgvec
; *ip
!= NULL
; ip
++) {
mp
->m_flag
&= ~(MPRESERVE
|MSAVED
);
last
= first(0, MDELETED
);
* Following can't happen -- it keeps lint happy
* Undelete the indicated messages.
register struct message
*mp
;
for (ip
= msgvec
; ip
-msgvec
< msgCount
; ip
++) {
* Interactively dump core on "core"
if ((pid
= vfork()) == -1) {
while (wait(&status
) != pid
)
printf(" -- Core dumped\n");