From f01c33f6bffec99c474f109a31c8481012a83075 Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 3 Apr 2008 06:32:36 +0000 Subject: - (internal) change mail/log to specific API. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4070 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/mail.c | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'mbbsd/mail.c') diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 64a61ca9..58068c3b 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -26,8 +26,7 @@ setforward(void) int flIdiotSent2Self = 0; int oidlen = strlen(cuser.userid); - sethomepath(buf, cuser.userid); - strlcat(buf, "/.forward", sizeof(buf)); + setuserfile(buf, ".forward"); if ((fp = fopen(buf, "r"))) { fscanf(fp, "%" toSTR(sizeof(ip)) "s", ip); fclose(fp); @@ -117,18 +116,52 @@ mail_muser(userec_t muser, const char *title, const char *filename) return mail_id(muser.userid, title, filename, cuser.userid); } +int +mail_log2id(const char *id, const char *title, const char *src, const char *owner, char newmail, char trymove) +{ + fileheader_t mhdr; + char dst[PATHLEN], dirf[PATHLEN]; + + sethomepath(dst, id); + if (stampfile(dst, &mhdr) < 0) + return -1; + + strlcpy(mhdr.owner, owner, sizeof(mhdr.owner)); + strlcpy(mhdr.title, title, sizeof(mhdr.title)); + mhdr.filemode = newmail ? 0 : FILE_READ; + + // XXX try link first? + //if (HardLink(src, dst) < 0 && Copy(src, dst) < 0) + // return -1; + if (trymove) + { + if (Rename(src, dst) < 0) + return -1; + } else { + if (Copy(src, dst) < 0) + return -1; + } + + sethomedir(dirf, id); + // do not forward. + append_record(dirf, &mhdr, sizeof(mhdr)); + return 0; +} + int mail_id(const char *id, const char *title, const char *src, const char *owner) { fileheader_t mhdr; char dst[PATHLEN], dirf[PATHLEN]; sethomepath(dst, id); - if (stampfile(dst, &mhdr)) - return 0; + if (stampfile(dst, &mhdr) < 0) + return -1; + strlcpy(mhdr.owner, owner, sizeof(mhdr.owner)); strlcpy(mhdr.title, title, sizeof(mhdr.title)); mhdr.filemode = 0; - Copy(src, dst); + if (Copy(src, dst) < 0) + return -1; sethomedir(dirf, id); append_record_forward(dirf, &mhdr, sizeof(mhdr), id); @@ -1788,6 +1821,12 @@ int m_read(void) { int back_bid; + + /* // deprecated because now we kicks online people. + if (HasUserPerm(PERM_BASIC) && !HasUserPerm(PERM_LOGINOK)) + check_register_notify(); + */ + if (get_num_records(currmaildir, sizeof(fileheader_t))) { curredit = EDIT_MAIL; curredit &= ~EDIT_ITEM; -- cgit v1.2.3