]>
diplodocus.org Git - nmh/blob - docs/historical/SRI-NOSC/open.c
9 int fout
, all
, hdrflag
, foldp
;
11 char folder
[128], *folds
[NFOLDERS
];
12 int msgtot
, foldtot
, totonly
, shrt
;
13 struct swit switches
[] {
19 "noheader", 0, /* 5 */
31 register char *cp
, *curm
;
34 int up
, down
, j
, def_short
;
36 char *arguments
[50], **argp
;
37 struct inode stbf
, *np
;
47 up
= down
= argfolder
= 0;
49 if(argv
[0][length(argv
[0])-1] == 's') /* Plural name?? */
56 if(!uleq("folder", ap
) && (cp
= m_find(ap
)) != -1) {
57 ap
= brkstring(cp
= getcpy(cp
), " ", "\n");
58 ap
= copyip(ap
, arguments
);
65 switch(smatch(++cp
, switches
)) {
66 case -2:ambigsw(cp
, switches
); /* ambiguous */
69 case -1:printf("-%s unknown\n", cp
);
71 case 0: all
++; continue; /* -all */
72 case 1: down
++; continue; /* -down */
74 case 6: shrt
= 1; continue; /* -short */
75 case 3: shrt
= 0; continue; /* -nofast */
76 case 4: hdrflag
= -1; continue; /* -header */
77 case 5: hdrflag
= 0; continue; /* -noheader */
78 case 7: all
++; totonly
= 1; /* -total */
80 case 8: if(totonly
) all
--; /* -nototal */
82 case 9: up
++; continue; /* -up */
84 case 10:help(concat( inp
, " [+folder] [msg] [switches]",0),
90 printf("Only one folder at a time.\n");
95 printf("Only one current may be given.\n");
104 for(np
= m_defs
; np
; np
= np
->n_next
) {
105 if(!ssequal("cur-", np
->n_name
))
109 printf("%s\n", np
->n_name
+4);
111 addfold(np
->n_name
+4);
118 execl(lsproc
, "mh-ls", "-x", cp
, 0);
119 printf("Can't exec: "); flush();
124 printf("Can't chdir to: "); flush();
128 if((cp
= m_find("folder")) == -1)
134 while(read(i
, &ent
.inum
, sizeof ent
.name
+ sizeof ent
.inum
))
135 if(ent
.inum
&& ent
.name
[0] != '.' &&
136 stat(ent
.name
, &stbf
) >= 0 &&
137 (stbf
.i_mode
&IFMT
) == IFDIR
)
140 for(i
= 0; i
< foldp
; i
++) {
141 pfold(folds
[i
], 0); flush();
145 printf("TOTAL= %3d message%c in %d Folder%s.\n",
146 msgtot
, msgtot
!=1? 's':' ',
147 foldtot
, foldtot
!=1? "s":"");
151 cp
= copy(argfolder
, folder
);
153 cp
= copy(m_getfolder(), folder
);
155 while(cp
> folder
&& *cp
!= '/') --cp
;
160 copy(listname
, copy("/", cp
));
163 if(pfold(folder
, curm
) && argfolder
)
164 m_replace("folder",argfolder
);
179 if(foldp
>= NFOLDERS
) {
180 printf("More than %d folders!!\n", NFOLDERS
);
184 for(i
= 0; i
< foldp
; i
++)
185 if(compare(cp
, folds
[i
]) < 0) {
186 for(j
= foldp
- 1; j
>= i
; j
--)
187 folds
[j
+1] = folds
[j
];
200 register char *mailfile
;
202 mailfile
= m_maildir(fold
);
203 if(chdir(mailfile
) < 0) {
204 printf("Can't chdir to: "); flush();
209 printf("%s\n", fold
);
214 msgtot
=+ mp
->nummsg
;
221 printf("Can't set current msg to %s\n", curm
);
224 m_setcur(mp
->curmsg
= mp
->hghsel
);
227 printf("\t\tFolder # of messages ( range ); cur msg (other files)\n");
228 printf("%22s", fold
);
229 if(equal(folder
, fold
))
234 printf("has no messages");
236 printf("has %3d message%s (%3d-%3d)",
237 mp
->nummsg
, (mp
->nummsg
==1)?" ":"s",
238 mp
->lowmsg
, mp
->hghmsg
);
239 if(mp
->curmsg
>= mp
->lowmsg
&& mp
->curmsg
<= mp
->hghmsg
)
240 printf("; cur=%3s", m_name(mp
->curmsg
));
242 if(mp
->selist
|| mp
->others
) {
245 printf("%s", listname
);
265 register char *c1
, *c2
;
270 if(i
= *c1
++ - *c2
++)