-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd1.c
849 lines (768 loc) · 19.1 KB
/
cmd1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
/* $OpenBSD: cmd1.c,v 1.5 1996/06/08 19:48:11 christos Exp $ */
/* $NetBSD: cmd1.c,v 1.5 1996/06/08 19:48:11 christos Exp $ */
/*-
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 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
* SUCH DAMAGE.
*/
#ifndef lint
#if 0
static char sccsid[] = "@(#)cmd1.c 8.1 (Berkeley) 6/6/93";
#else
static char rcsid[] = "$OpenBSD: cmd1.c,v 1.5 1996/06/08 19:48:11 christos Exp $";
#endif
#endif /* not lint */
#include "rcv.h"
#include "extern.h"
/*
* Mail -- a mail program
*
* User commands.
*/
/*
* Print the current active headings.
* Don't change dot if invoker didn't give an argument.
*
* Takes a vector, uses the first thing in that vector
* to find the start of a screen-ful, then ignores the
* rest of the vector. Use from() for printing an actual
* vector.
*/
static int screen;
int
headers(v)
void *v;
{
int *msgvec = v;
register int n, mesg, flag;
register struct message *mp;
int size;
size = screensize();
n = msgvec[0];
if (n != 0)
screen = (n-1)/size;
if (screen < 0)
screen = 0;
mp = &message[screen * size];
if (mp >= &message[msgCount])
mp = &message[msgCount - size];
if (mp < &message[0])
mp = &message[0];
flag = 0;
mesg = mp - &message[0];
if (dot != &message[n-1])
dot = mp;
for (; mp < &message[msgCount]; mp++) {
mesg++;
if (mp->m_flag & MDELETED)
continue;
if (flag++ >= size)
break;
printhead(mesg);
}
if (flag == 0) {
printf("No more mail.\n");
shown_eof = 1;
return(1);
}
return(0);
}
/*
* Scroll to the next/previous screen
*/
int
scroll(v)
void *v;
{
char *arg = v;
register int s, size;
int cur[1];
/* screen is the global index of the current page of messages; it will
* be changed if scroll() is successful, then headers is called with
* an empty vector to print current screen.
*/
cur[0] = 0;
size = screensize();
s = screen;
switch (*arg) {
case 0:
case '+':
s++;
if (s * size > msgCount) {
printf("On last screenful of messages\n");
return(0);
}
screen = s;
break;
case '-':
if (--s < 0) {
printf("On first screenful of messages\n");
return(0);
}
screen = s;
break;
default:
printf("Unrecognized scrolling command \"%s\"\n", arg);
return(1);
}
return(headers(cur));
}
/*
* Compute screen size.
*/
int
screensize()
{
int s;
char *cp;
if ((cp = value("screen")) != NOSTR && (s = atoi(cp)) > 0)
return s;
return screenheight - 4;
}
/*
* Print out the headlines for each message
* in the passed message list.
*/
int
from(v)
void *v;
{
int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != NOMVEC; ip++)
printhead(*ip);
if (--ip >= msgvec)
dot = &message[*ip - 1];
return(0);
}
extern int decode_header(char*, char*, int); /* GREP move to .h */
extern int check_utf8(char*, int); /* GREP move to .h */
extern int display_length(char*, int); /* GREP move to .h */
/*
* Print out the header of a specific message.
* This is a slight improvement to the standard one.
*/
void
printhead(mesg)
int mesg;
{
struct message *mp;
char headline[LINESIZE], wcount[LINESIZE], *subjline, dispc, curind;
char pbuf[BUFSIZ], *subj7line, bytechar, *charset;
struct headline hl;
int subjlen,k,wcl,size_adj;
char *name;
size_adj = 0;
mp = &message[mesg-1];
(void) readline(setinput(mp), headline, LINESIZE);
if ((subjline = hfield("subject", mp)) == NOSTR)
subjline = hfield("subj", mp);
/*
* Bletch!
*/
curind = dot == mp ? '>' : ' ';
/* So many dispc symbols now!
* Quick summary:
* r: already marked as read
* *: saved to a file this session
* P: flagged to preserve
* u: not marked as read
* M: flagged to save to mbox
* f: user specified message flag (overrider and saved on Status:)
* m: user specified message flag (overrider, but only this session)
* B: BOTH previous user specified message flags
* At least for now; see def.h for changes
*/
dispc = DISP_READ;
if (mp->m_flag & MSAVED)
dispc = DISP_SAVE;
if (mp->m_flag & MPRESERVE)
dispc = DISP_PRES;
if ((mp->m_flag & (MREAD|MNEW)) == MNEW)
dispc = DISP_NEW;
if ((mp->m_flag & (MREAD|MNEW)) == 0)
dispc = DISP_UNRD;
if (mp->m_flag & MBOX)
dispc = DISP_MBOX;
if (mp->m_flag & MFLAG)
dispc = DISP_FLAG;
if (mp->m_flag & MREMEMBER)
dispc = DISP_REMB;
if ((mp->m_flag & MFLAG) && (mp->m_flag & MREMEMBER))
dispc = DISP_BOTH;
parse(headline, &hl, pbuf);
subj7line = malloc(LINESIZE); /* fix to be static GREPgrep */
if(!subj7line) {
(void)fprintf(stderr,"\nOut of memory!\n");
exit(2);
}
if (screenwidth < VERY_NARROW_SCREEN) {
/* too small, skip message size altogether */
wcount[0] = '\0';
bytechar = '\0';
size_adj = 15;
} else if (screenwidth < NARROW_SCREEN) {
/* small, just show lines */
sprintf(wcount, "%4ld", mp->m_lines);
bytechar = '\0';
size_adj = 5;
} else {
/* full size or close enough */
/* make the "lines/bytes" bit */
bytechar = ' ';
k = TO_KILO(mp->m_size);
if(k < 3500) {
if(mp->m_lines > 9999) {
sprintf(wcount, "%3ldc/%-3d ", TO_CENT(mp->m_lines), k);
} else {
sprintf(wcount, "%4ld/%-3d ", mp->m_lines, k);
}
bytechar = 'k';
} else {
k = TO_MEGA(mp->m_size);
sprintf(wcount, "%3ldc/%-3d ", TO_CENT(mp->m_lines), k);
bytechar = 'M';
}
if(screenwidth >= WIDE_SCREEN) {
size_adj = -1;
}
}
/* paste in the right k/M multiplier, and shorten space
* for subject if wcount went longer than 9 chars
*/
wcl = strlen(wcount);
subjlen = screenwidth - 48 - wcl + size_adj;
/* "Why 48?" I ask myself in 2017. I'm not sure.
* Probably 55 (normal presub width) - 9 (normal wcount width) = 46
* + 2 char fudge for extra wide msg num case == 48
* size_adj is for 2017 screen size adjustments */
/* put the bytecount char somewhere in wcount, if we have one */
if(bytechar) {
while(wcount[wcl - 1] == ' ') { wcl --; }
if(wcount[wcl] == ' ') { wcount[wcl] = bytechar; }
}
name = value("show-rcpt") != NOSTR ?
skin(hfield("to", mp)) : nameof(mp, 0);
if ((charset = value("charset")) != NOSTR) { /* GREPgrep fix document setting */
if (subjline == NOSTR || subjlen < 1)
/* doesn't actually do much */
copy(NO_SUBJECT_PLACEHOLDER, subj7line);
else {
int bad_at, cut_at;
copy(subjline, subj7line);
/* decodes in place when decoding anything */
decode_header(subj7line, charset, LINESIZE);
if(strcasecmp("UTF-8", charset) == 0){
/* clean up bad UTF-8 ... */
while(-1 != (bad_at = check_utf8(subj7line, LINESIZE))) {
if(bad_at > (4 * subjlen)) {
/* we're past the end of the subject we
* may display, even if all four-octet
* UTF-8.
*/
break;
}
/* GREPgrep uses ~ as in to7strcpy, maybe make setting? */
subj7line[bad_at] = '~';
}
/* ... because display_length() only works on
* valid UTF-8 and
* printf("%.*s", subjlen, subj7line)
* will use a naive truncation.
*/
cut_at = display_length(subj7line, subjlen);
subj7line[cut_at] = 0;
} else {
/* charset naive truncation */
subj7line[subjlen] = 0;
}
}
} else {
/* go for old 7 bit clean code path */
/* no subject or no space for subject */
if (subjline == NOSTR || subjlen < 1)
/* hopefully the placeholder is 7bit already, but... */
to7strcpy(subj7line, NO_SUBJECT_PLACEHOLDER, subjlen);
else {
to7strcpy(subj7line, subjline, subjlen);
}
subj7line[subjlen] = 0;
}
/* current message pointer
* msg num | terse date (8 char)
* msg flag | | sender email |
* | | | (15 char) /
* | | | | /
* v v v v v subject (subjlen char) */
#define VERY_N_HEADER "%c%4d%c%-15.15s %8.8s %s\n"
/* ^ ^ ^ ^^ ^
* 1 4 1 15 1 8 = 28 pre-subject */
/* current message pointer
* msg num | date (17 char)
* msg flag | | sender email | message count string
* | | | (18 char) | / (4 char)
* | | | | | |
* v v v v v v subject (subjlen char) */
#define NARROW_HEADER "%c%4d%c%-18.18s %14.14s %s %s\n"
/* ^ ^ ^ ^^ ^^ ^^
* 1 4 1 18 1 14 1 4 1= 48 pre-subject */
/* current message pointer
* msg num | date (17 char)
* msg flag | | sender email | message count string
* | | | (20 char) | / (9 char)
* | | | | | |
* v v v v v v subject (subjlen char) */
#define NORMAL_HEADER "%c%4d%c%-20.20s %17.17s %s %s\n"
/* ^ ^ ^ ^^ ^^ ^^
* 1 4 1 20 1 17 1 9 1= 55 pre-subject */
/* current message pointer
* msg num | date (17 char)
* msg flag | | sender email | message count string
* | | | (20 char) | / (9 char)
* | | | | | |
* v v v v v v subject (subjlen char) */
#define WIDE_HEADER "%c %4d%c%-20.20s %17.17s %s %s\n"
/* ^^ ^ ^ ^^ ^^ ^^
* 1 1 4 1 20 1 17 1 9 1= 56 pre-subject */
if(screenwidth >= VERY_NARROW_SCREEN) {
/* Narrow, normal, and wide screen all have the same
* columns, but might have different sizes for them. */
char *use_date;
if(screenwidth < NARROW_SCREEN) {
/* skip leading day of week */
use_date = 3 + hl.l_date;
} else {
use_date = hl.l_date;
}
printf((screenwidth >= WIDE_SCREEN)? WIDE_HEADER :(
(screenwidth < NARROW_SCREEN)? NARROW_HEADER :
NORMAL_HEADER),
dispc, mesg, curind, name, use_date, wcount,
subj7line);
} else {
/* Very narrow */
char tersedate[10];
int cp, wp = 0;
/* hl.l_date looks like "Da Mm/Dd/Yy Hh:Mm", copy out the
* "Mm/Dd/Yy" bit. */
if(strlen(hl.l_date) > 11) {
for(cp = 3, wp = 0; cp < 11; cp ++, wp ++) {
tersedate[wp] = hl.l_date[cp];
}
}
tersedate[wp] = '\0';
printf(VERY_N_HEADER,
dispc, mesg, curind, name, tersedate,
subj7line);
}
free(subj7line);
}
/*
* Print out the value of dot.
*/
int
pdot(v)
void *v;
{
printf("At message %d of %d (%d of those deleted).\n",
(int)(dot - &message[0] + 1),
msgCount, delCount);
return(0);
}
/*
* Touch the EOF flag to silence confirmquit option
*/
int
toucheof(v)
void *v;
{
shown_eof = 1;
return(0);
}
/*
* Print out all the possible commands.
*/
int
pcmdlist(v)
void *v;
{
extern const struct cmd cmdtab[];
register const struct cmd *cp;
register int cc;
printf("Commands are:\n");
for (cc = 0, cp = cmdtab; cp->c_name != NULL; cp++) {
cc += strlen(cp->c_name) + 2;
if (cc > screenwidth - 2) {
printf("\n");
cc = strlen(cp->c_name) + 2;
}
if ((cp+1)->c_name != NOSTR)
printf("%s, ", cp->c_name);
else
printf("%s\n", cp->c_name);
}
return(0);
}
/*
* Paginate messages, honor ignored fields.
*/
int
more(v)
void *v;
{
int *msgvec = v;
return (type1(msgvec, USE_IGNORES, USE_PAGER));
}
/*
* Paginate messages, even printing ignored fields.
*/
int
More(v)
void *v;
{
int *msgvec = v;
return (type1(msgvec, NO_IGNORES, USE_PAGER));
}
/*
* Type out messages, honor ignored fields.
*/
int
type(v)
void *v;
{
int *msgvec = v;
return(type1(msgvec, USE_IGNORES, NO_PAGER));
}
/*
* Type out messages, even printing ignored fields.
*/
int
Type(v)
void *v;
{
int *msgvec = v;
return(type1(msgvec, NO_IGNORES, NO_PAGER));
}
/*
* Type out the messages requested.
*/
jmp_buf pipestop;
int
type1(msgvec, doign, page)
int *msgvec;
int doign, page;
{
register int *ip;
struct message *mp;
char *cp;
int nlines;
FILE *obuf;
#if __GNUC__
/* Avoid longjmp clobbering */
(void) &cp;
(void) &obuf;
#endif
obuf = stdout;
if (setjmp(pipestop))
goto close_pipe;
if (value("interactive") != NOSTR &&
(page || (cp = value("crt")) != NOSTR)) {
nlines = 0;
if (!page) {
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++)
nlines += message[*ip - 1].m_lines;
}
if (page || nlines > (*cp ? atoi(cp) : realscreenheight)) {
obuf = Pageropen();
}
}
for (ip = msgvec; *ip && ip - msgvec < msgCount; ip++) {
mp = &message[*ip - 1];
touch(mp);
dot = mp;
if (value("quiet") == NOSTR) {
if(delCount) {
fprintf(obuf, "Message %d of %d (%d of those deleted):\n",
*ip, msgCount, delCount);
} else {
fprintf(obuf, "Message %d of %d:\n", *ip, msgCount);
}
}
(void) send(mp, obuf, doign ? ignore : 0, NOSTR);
}
close_pipe:
if (obuf != stdout) {
Pagerclose(obuf);
}
return(0);
}
/*
* Respond to a broken pipe signal --
* probably caused by quitting more.
*/
void
brokpipe(signo)
int signo;
{
longjmp(pipestop, 1);
}
/*
* Print a few selected headers from each desired message.
* The headers are those listed in the interesting list,
* an ignoretab structure. If no headers on on the list,
* default to To, From, CC, and Subject (or whatever is
* hardcoded in definter() in some future time).
*/
int
headersum(v)
void *v;
{
int *msgvec = v;
register int *ip;
register struct message *mp;
int count, lines, int_cache, infld;
char *cp, *cp2, c, linebuf[LINESIZE];
FILE *ibuf;
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
/* start out like top() */
mp = &message[*ip - 1];
dot = mp;
if (value("quiet") == NOSTR) {
/* use less verbose message count, without
* noting the deleted.
*/
starthl(stdout);
printf("Message %d of %d", *ip, msgCount);
endhl(stdout);
puts(":");
}
ibuf = setinput(mp);
count = mp->m_lines;
infld = int_cache = 0;
for (lines = 0; lines < count; lines++) {
/* break on read error */
if (readline(ibuf, linebuf, LINESIZE) < 0)
break;
/* skip "From " line */
if(lines == 0)
continue;
/* break on end of headers */
if(linebuf[0] == '\0')
break;
if (infld && (linebuf[0] == ' ' || linebuf[0] == '\t')) {
/* multiline header */
if(int_cache) {
puts(linebuf);
}
continue;
}
/* Now like send() but without ancient uucp
* headerless mail case
*/
/* Find a header field. Recall "Foo : bar" is allowed */
for (cp = linebuf; (c = *cp++) && c != ':' && !isspace(c);)
;
cp2 = --cp;
*cp2 = 0; /* temporarily null terminate */
int_cache = 0;
infld = 1;
if(isinter(linebuf, highlight)) {
int_cache = 1;
*cp2 = c; /* restore */
puts(linebuf);
}
}
}
return(0);
}
/*
* Print the top so many lines of each desired message.
* The number of lines is taken from the variable "toplines"
* and defaults to 5.
*/
int
top(v)
void *v;
{
int *msgvec = v;
register int *ip;
register struct message *mp;
int c, topl, lines, lineb;
char *valtop, linebuf[LINESIZE];
FILE *ibuf;
topl = 5;
valtop = value("toplines");
if (valtop != NOSTR) {
topl = atoi(valtop);
if (topl < 0 || topl > 10000)
topl = 5;
}
lineb = 1;
for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
mp = &message[*ip - 1];
dot = mp;
if (value("quiet") == NOSTR) {
/* in 'top' use less verbose message count, without
* noting the deleted.
*/
starthl(stdout);
printf("Message %d of %d", *ip, msgCount);
endhl(stdout);
puts(":");
}
ibuf = setinput(mp);
c = mp->m_lines;
if (!lineb)
printf("\n");
for (lines = 0; lines < c && lines <= topl; lines++) {
if (readline(ibuf, linebuf, LINESIZE) < 0)
break;
puts(linebuf);
lineb = blankline(linebuf);
}
}
return(0);
}
/*
* Touch all the given messages so that they will
* get mboxed.
*/
int
stouch(v)
void *v;
{
int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
dot = &message[*ip-1];
/* the touch() used by type1() */
touch(dot);
dot->m_flag &= ~MPRESERVE;
}
return(0);
}
/*
* Set the short-term user flag on a message vector.
* Called "mark" to the user, but "mark" is used internally for
* messages to operate on during a particular action.
*/
int
sremember(v)
void *v;
{
int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
dot = &message[*ip-1];
flag(dot,FLAGSET,MREMEMBER);
}
return(0);
}
/*
* Clear the short-term user flag on a message vector.
*/
int
cremember(v)
void *v;
{
int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
dot = &message[*ip-1];
flag(dot,FLAGUNSET,MREMEMBER);
}
return(0);
}
/*
* Set the saved user flag on a message vector.
*/
int
sflag(v)
void *v;
{
int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
dot = &message[*ip-1];
/* STATUS so it will be saved */
flag(dot,FLAGSET,(MFLAG|MSTATUS));
}
return(0);
}
/*
* Clear the saved user flag on a message vector.
*/
int
cflag(v)
void *v;
{
int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
dot = &message[*ip-1];
/* STATUS so it will be saved */
flag(dot,FLAGUNSET,(MFLAG|MSTATUS));
}
return(0);
}
/*
* Make sure all passed messages get mboxed.
*/
int
mboxit(v)
void *v;
{
int *msgvec = v;
register int *ip;
for (ip = msgvec; *ip != 0; ip++) {
dot = &message[*ip-1];
dot->m_flag |= MTOUCH|MBOX;
dot->m_flag &= ~MPRESERVE;
}
return(0);
}
/*
* List the folders the user currently has.
*/
int
folders(v)
void *v;
{
char dirname[BUFSIZ];
char *cmd;
if (getfold(dirname, BUFSIZ) < 0) {
printf("No value set for \"folder\"\n");
return 1;
}
if ((cmd = value("LISTER")) == NOSTR)
cmd = "ls";
(void) run_command(cmd, 0, -1, -1, dirname, NOSTR, NOSTR);
return 0;
}