X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Frmf.c;h=36c1eed24da18fcc4ece9557c28fc8dd7fa694d1;hb=8e5be81f784682822f5e868c1bf3c8624682bd23;hp=38a93ff86bd9adca00899107acf22bdf6c55d773;hpb=714b5c530ece27ea2835a313013f5b770163403c;p=mmh diff --git a/uip/rmf.c b/uip/rmf.c index 38a93ff..36c1eed 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -37,7 +37,7 @@ main(int argc, char **argv) #ifdef LOCALE setlocale(LC_ALL, ""); #endif - invo_name = r1bindex(argv[0], '/'); + invo_name = mhbasename(argv[0]); /* read user profile/context */ context_read(); @@ -74,35 +74,34 @@ main(int argc, char **argv) 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); } } - if (!context_find("path")) - free(path("./", TFOLDER)); if (!folder) { - folder = getfolder(1); + 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(0), sizeof(newfolder)); + strncpy(newfolder, getdeffol(), sizeof(newfolder)); } else { - strncpy(newfolder, getfolder(0), sizeof(newfolder)); + strncpy(newfolder, getdeffol(), sizeof(newfolder)); } if (interactive) { @@ -113,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 */ @@ -134,7 +133,7 @@ rmf(char *folder) register struct dirent *dp; register DIR *dd; - switch (i = chdir(maildir = m_maildir(folder))) { + switch (i = chdir(maildir = toabsdir(folder))) { case OK: if (access(".", W_OK) != NOTOK && access("..", W_OK) != NOTOK) @@ -142,7 +141,7 @@ rmf(char *folder) case NOTOK: snprintf(cur, sizeof(cur), "atr-%s-%s", - current, m_mailpath(folder)); + current, toabsdir(folder)); if (!context_del(cur)) { printf("[+%s de-referenced]\n", folder); return OK; @@ -159,7 +158,7 @@ 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))) { @@ -234,14 +233,14 @@ 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 ** "atr-something-folderpath", and remove them. */ for (np = m_defs, pp = NULL; np; np = np->n_next) { - if (ssequal("atr-", np->n_name) && + if (isprefix("atr-", np->n_name) && (j = strlen(np->n_name) - plen) > alen && *(np->n_name + j) == '-' && strcmp(cp, np->n_name + j + 1) == 0) { @@ -259,4 +258,5 @@ rma(char *folder) pp = np; } } + free(cp); }