summaryrefslogtreecommitdiff
path: root/imap/src/osdep/unix/dummy.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2013-05-31 17:16:44 -0600
committerEduardo Chappa <chappa@washington.edu>2013-05-31 17:16:44 -0600
commita46157ba61f2c65f88b42abb31db60c4a714f87b (patch)
treee37bc41ad2f57b3fd2bad310576cc155a58ca6b7 /imap/src/osdep/unix/dummy.c
parent81e994d7907f850506ddc248f84761a54995e58c (diff)
downloadalpine-a46157ba61f2c65f88b42abb31db60c4a714f87b.tar.xz
* somehow all.patch got here. Reversing.
Diffstat (limited to 'imap/src/osdep/unix/dummy.c')
-rw-r--r--imap/src/osdep/unix/dummy.c48
1 files changed, 9 insertions, 39 deletions
diff --git a/imap/src/osdep/unix/dummy.c b/imap/src/osdep/unix/dummy.c
index 92a2c463..b003a0ba 100644
--- a/imap/src/osdep/unix/dummy.c
+++ b/imap/src/osdep/unix/dummy.c
@@ -106,19 +106,13 @@ MAILSTREAM dummyproto = {&dummydriver};
* Accepts: mailbox name
* Returns: our driver if name is valid, NIL otherwise
*/
-char * maildir_remove_root(char *);
+
DRIVER *dummy_valid (char *name)
{
- char *s,tmp[MAILTMPLEN], *rname;
+ char *s,tmp[MAILTMPLEN];
struct stat sbuf;
-
- if(strlen(name) > MAILTMPLEN)
- name[MAILTMPLEN] = '\0';
-
- strcpy(tmp, name);
- rname = maildir_remove_root(tmp);
/* must be valid local mailbox */
- if (rname && *rname && (*rname != '{') && (s = mailboxfile (tmp,rname))) {
+ if (name && *name && (*name != '{') && (s = mailboxfile (tmp,name))) {
/* indeterminate clearbox INBOX */
if (!*s) return &dummydriver;
else if (!stat (s,&sbuf)) switch (sbuf.st_mode & S_IFMT) {
@@ -127,9 +121,8 @@ DRIVER *dummy_valid (char *name)
return &dummydriver;
}
/* blackbox INBOX does not exist yet */
- else if (!compare_cstring (rname,"INBOX")) return &dummydriver;
+ else if (!compare_cstring (name,"INBOX")) return &dummydriver;
}
- if(rname) fs_give((void **)&rname);
return NIL;
}
@@ -461,8 +454,6 @@ long dummy_create (MAILSTREAM *stream,char *mailbox)
{
char *s,tmp[MAILTMPLEN];
long ret = NIL;
- if(!strncmp(mailbox,"#md/",4) || !strncmp(mailbox,"#mc/", 4))
- return maildir_create(stream, mailbox);
/* validate name */
if (!(compare_cstring (mailbox,"INBOX") && (s = dummy_file (tmp,mailbox)))) {
sprintf (tmp,"Can't create %.80s: invalid name",mailbox);
@@ -528,14 +519,6 @@ long dummy_delete (MAILSTREAM *stream,char *mailbox)
{
struct stat sbuf;
char *s,tmp[MAILTMPLEN];
- if (!strncmp(mailbox,"#md/",4) || !strncmp(mailbox,"#mc/", 4)
- || is_valid_maildir(&mailbox)){
- char tmp[MAILTMPLEN] = {'\0'};
- strcpy(tmp, mailbox);
- if(tmp[strlen(tmp) - 1] != '/')
- tmp[strlen(tmp)] = '/';
- return maildir_delete(stream, tmp);
- }
if (!(s = dummy_file (tmp,mailbox))) {
sprintf (tmp,"Can't delete - invalid name: %.80s",s);
MM_LOG (tmp,ERROR);
@@ -561,23 +544,12 @@ long dummy_delete (MAILSTREAM *stream,char *mailbox)
long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
{
struct stat sbuf;
- char c,*s,tmp[MAILTMPLEN],mbx[MAILTMPLEN],oldname[MAILTMPLEN], *rold, *rnewname;
-
- if(strlen(old) > MAILTMPLEN)
- old[MAILTMPLEN] = '\0';
-
- if(strlen(newname) > MAILTMPLEN)
- newname[MAILTMPLEN] = '\0';
-
- strcpy(tmp, old);
- rold = maildir_remove_root(tmp);
- strcpy(tmp, newname);
- rnewname = maildir_remove_root(tmp);
+ char c,*s,tmp[MAILTMPLEN],mbx[MAILTMPLEN],oldname[MAILTMPLEN];
/* no trailing / allowed */
- if (!dummy_file (oldname,rold) || !(s = dummy_file (mbx,rnewname)) ||
+ if (!dummy_file (oldname,old) || !(s = dummy_file (mbx,newname)) ||
stat (oldname,&sbuf) || ((s = strrchr (s,'/')) && !s[1] &&
((sbuf.st_mode & S_IFMT) != S_IFDIR))) {
- sprintf (mbx,"Can't rename %.80s to %.80s: invalid name",rold,rnewname);
+ sprintf (mbx,"Can't rename %.80s to %.80s: invalid name",old,newname);
MM_LOG (mbx,ERROR);
return NIL;
}
@@ -593,16 +565,14 @@ long dummy_rename (MAILSTREAM *stream,char *old,char *newname)
}
}
/* rename of non-ex INBOX creates dest */
- if (!compare_cstring (rold,"INBOX") && stat (oldname,&sbuf))
+ if (!compare_cstring (old,"INBOX") && stat (oldname,&sbuf))
return dummy_create (NIL,mbx);
if (rename (oldname,mbx)) {
- sprintf (tmp,"Can't rename mailbox %.80s to %.80s: %.80s",rold,rnewname,
+ sprintf (tmp,"Can't rename mailbox %.80s to %.80s: %.80s",old,newname,
strerror (errno));
MM_LOG (tmp,ERROR);
return NIL;
}
- if(rold) fs_give((void **)&rold);
- if(rnewname) fs_give((void **)&rnewname);
return T; /* return success */
}