X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Frmf.c;h=f214f59a8e12baa3ed46e178e267dede1a742587;hp=3b532e0e591e029b3f26a09ff00e9840af96bc9a;hb=5b792c4424571f05bc2008e3109797d18d7d00d1;hpb=3d78b9c80a95f4e7885ed607018f9b1b9be559b4 diff --git a/uip/rmf.c b/uip/rmf.c index 3b532e0..f214f59 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -48,33 +48,33 @@ main(int argc, char **argv) while ((cp = *argp++)) { if (*cp == '-') { switch (smatch(++cp, switches)) { - case AMBIGSW: - ambigsw(cp, switches); - done(1); - case UNKWNSW: - adios(NULL, "-%s unknown", cp); - - case HELPSW: - snprintf(buf, sizeof(buf), "%s [+folder] [switches]", invo_name); - print_help(buf, switches, 1); - done(1); - case VERSIONSW: - print_version(invo_name); - done(1); - - case INTRSW: - interactive = 1; - continue; - case NINTRSW: - interactive = 0; - continue; + case AMBIGSW: + ambigsw(cp, switches); + done(1); + case UNKWNSW: + adios(NULL, "-%s unknown", cp); + + case HELPSW: + snprintf(buf, sizeof(buf), "%s [+folder] [switches]", invo_name); + print_help(buf, switches, 1); + done(1); + case VERSIONSW: + print_version(invo_name); + done(1); + + case INTRSW: + interactive = 1; + continue; + case NINTRSW: + interactive = 0; + continue; } } if (*cp == '+' || *cp == '@') { if (folder) adios(NULL, "only one folder at a time!"); else - folder = pluspath(cp); + folder = getcpy(expandfol(cp)); } else { adios(NULL, "usage: %s [+folder] [switches]", invo_name); @@ -82,25 +82,26 @@ main(int argc, char **argv) } if (!folder) { - folder = getfolder(FCUR); + folder = getcurfol(); defolder++; } - if (strcmp(m_mailpath(folder), pwd()) == 0) - adios(NULL, "sorry, you can't remove the current working directory"); + if (strcmp(toabsdir(folder), pwd()) == 0) + adios(NULL, "You can't remove the current working directory"); if (interactive == -1) interactive = defolder; if (strchr(folder, '/') && (*folder != '/') && (*folder != '.')) { - for (cp = copy(folder, newfolder); - cp > newfolder && *cp != '/'; cp--) - continue; + strcpy(newfolder, folder); + cp = newfolder + strlen(newfolder); + while (cp > newfolder && *cp != '/') + cp--; if (cp > newfolder) *cp = '\0'; else - strncpy(newfolder, getfolder(FDEF), sizeof(newfolder)); + strncpy(newfolder, getdeffol(), sizeof(newfolder)); } else { - strncpy(newfolder, getfolder(FDEF), sizeof(newfolder)); + strncpy(newfolder, getdeffol(), sizeof(newfolder)); } if (interactive) { @@ -111,11 +112,11 @@ main(int argc, char **argv) } if (rmf(folder) == OK) { - char *cfolder = context_find(pfolder); + char *cfolder = context_find(curfolder); if (cfolder && strcmp(cfolder, newfolder)) { printf("[+%s now current]\n", newfolder); /* update current folder */ - context_replace(pfolder, newfolder); + context_replace(curfolder, newfolder); } } context_save(); /* save the context file */ @@ -132,21 +133,22 @@ rmf(char *folder) register struct dirent *dp; register DIR *dd; - switch (i = chdir(maildir = m_maildir(folder))) { - case OK: - if (access(".", W_OK) != NOTOK && - access("..", W_OK) != NOTOK) - break; /* fall otherwise */ - - case NOTOK: - snprintf(cur, sizeof(cur), "atr-%s-%s", - current, m_mailpath(folder)); - if (!context_del(cur)) { - printf("[+%s de-referenced]\n", folder); - return OK; - } - advise(NULL, "you have no profile entry for the %s folder +%s", i == NOTOK ? "unreadable" : "read-only", folder); - return NOTOK; + switch (i = chdir(maildir = toabsdir(folder))) { + case OK: + if (access(".", W_OK) != NOTOK && access("..", W_OK) != NOTOK) + break; /* fall otherwise */ + + case NOTOK: + snprintf(cur, sizeof(cur), "atr-%s-%s", + current, toabsdir(folder)); + if (!context_del(cur)) { + printf("[+%s de-referenced]\n", folder); + return OK; + } + advise(NULL, "you have no profile entry for the %s folder +%s", + i == NOTOK ? "unreadable" : "read-only", + folder); + return NOTOK; } if ((dd = opendir(".")) == NULL) @@ -157,38 +159,38 @@ rmf(char *folder) ** Run the external delete hook program. */ - (void)ext_hook("del-hook", maildir, (char *)0); + ext_hook("del-hook", maildir, NULL); j = strlen(backup_prefix); while ((dp = readdir(dd))) { switch (dp->d_name[0]) { - case '.': - if (strcmp(dp->d_name, ".") == 0 || - strcmp(dp->d_name, "..") == 0) - continue; /* else fall */ + case '.': + if (strcmp(dp->d_name, ".") == 0 || + strcmp(dp->d_name, "..") == 0) + continue; /* else fall */ - case ',': + case ',': #ifdef MHE - case '+': + case '+': #endif /* MHE */ #ifdef UCI - case '_': - case '#': + case '_': + case '#': #endif /* UCI */ + break; + + default: + if (m_atoi(dp->d_name)) + break; + if (strcmp(dp->d_name, altmsglink) == 0 || + strncmp(dp->d_name, + backup_prefix, j) == 0) break; - default: - if (m_atoi(dp->d_name)) - break; - if (strcmp(dp->d_name, altmsglink) == 0 || - strncmp(dp->d_name, - backup_prefix, j) == 0) - break; - - admonish(NULL, "file \"%s/%s\" not deleted", - folder, dp->d_name); - others++; - continue; + admonish(NULL, "file \"%s/%s\" not deleted", + folder, dp->d_name); + others++; + continue; } if (unlink(dp->d_name) == NOTOK) { admonish(dp->d_name, "unable to unlink %s:", folder); @@ -232,7 +234,7 @@ rma(char *folder) register struct node *np, *pp; alen = strlen("atr-"); - plen = strlen(cp = m_mailpath(folder)) + 1; + plen = strlen(cp = getcpy(toabsdir(folder))) + 1; /* ** Search context list for keys that look like @@ -257,4 +259,5 @@ rma(char *folder) pp = np; } } + free(cp); }