]>
diplodocus.org Git - nmh/blob - docs/historical/SRI-NOSC/rmf.c
4 char *anoyes
[]; /* Std no/yes gans array */
16 struct swit switches
[] {
24 register char *cp
, *ap
;
25 char *folder
, buf
[128];
29 char *arguments
[50], **argp
;
40 if((cp
= m_find(ap
)) != -1) {
41 ap
= brkstring(cp
= getcpy(cp
), " ", "\n");
42 ap
= copyip(ap
, arguments
);
49 switch(smatch(++cp
, switches
)) {
50 case -2:ambigsw(cp
, switches
); /* ambiguous */
53 case -1:printf("rmf: -%s unknown\n", cp
);
56 case 0: help("rmf [+folder] [switches]", switches
);
61 printf("Only one folder at a time.\n");
66 printf("Usage: rmf [+folder]\n");
71 folder
= m_getfolder();
74 subf
= !((!any('/', folder
)) | (*folder
== '/') | (*folder
== '.'));
75 if(def_fold
&& !subf
) {
76 cp
= concat("Remove folder \"", folder
, "\" ?? ", 0);
84 cp
= copy(folder
, buf
);
85 while(cp
> buf
&& *cp
!= '/') --cp
;
88 printf("[+%s now current]\n", buf
);
89 m_replace("folder", buf
);
102 register char *maildir
;
104 register char *cp
, *sp
;
109 if(!subf
&& equal(m_find("folder"), fold
)) { /* don't re-do */
110 printf("[+%s now current]\n", defalt
);
112 m_replace("folder", defalt
);
114 maildir
= m_maildir(fold
);
115 if(chdir(maildir
) < 0) {
116 printf("Can't chdir to: "); flush();
120 if(access(".", 2) == -1) {
121 if(!m_delete(concat("cur-", fold
, 0)))
122 printf("[Folder %s de-referenced]\n", fold
);
124 printf("You have no profile entry for the read-only folder %s\n", fold
);
129 while(read(i
, &ent
.inum
, sizeof ent
.name
+ sizeof ent
.inum
))
131 if((ent
.name
[0] >= '0' && ent
.name
[0] <= '9') ||
132 ent
.name
[0] == ',' ||
133 equal(ent
.name
, "cur") ||
134 equal(ent
.name
, "@")) {
135 if(unlink(ent
.name
) == -1) {
136 printf("Can't unlink %s:%s\n", fold
,ent
.name
);
139 } else if(!equal(ent
.name
,".")&& !equal(ent
.name
,"..")) {
140 printf("File \"%s/%s\" not deleted!\n",
145 if(!leftover
&& removedir(maildir
))
148 printf("Folder %s not removed!\n", fold
);
158 if((i
= fork()) == 0) {
161 execl("/bin/rmdir", "rmdir", dir
, 0);
162 printf("Can't exec rmdir!!?\n");
167 printf("Can't fork\n");
171 while((j
= waita(&status
)) != i
&& j
!= -1) ;
173 printf("Bad exit status (%o) from rmdir.\n", status
);