summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-27 14:26:11 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-03-27 14:26:11 +0800
commitc17b1ec0c4c66cbe2761fa0e8c83831e6258d11d (patch)
tree21e0d184cdf9f58095dce3c486522e2266449391 /mbbsd
parent3e774d4829229f4132e3b6895b572a117f60c99d (diff)
downloadpttbbs-c17b1ec0c4c66cbe2761fa0e8c83831e6258d11d.tar
pttbbs-c17b1ec0c4c66cbe2761fa0e8c83831e6258d11d.tar.gz
pttbbs-c17b1ec0c4c66cbe2761fa0e8c83831e6258d11d.tar.bz2
pttbbs-c17b1ec0c4c66cbe2761fa0e8c83831e6258d11d.tar.lz
pttbbs-c17b1ec0c4c66cbe2761fa0e8c83831e6258d11d.tar.xz
pttbbs-c17b1ec0c4c66cbe2761fa0e8c83831e6258d11d.tar.zst
pttbbs-c17b1ec0c4c66cbe2761fa0e8c83831e6258d11d.zip
- (internal) move UTIL_C API from mbbsd/stuff to cmbbs.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4031 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/Makefile9
-rw-r--r--mbbsd/merge.c237
-rw-r--r--mbbsd/stuff.c103
3 files changed, 8 insertions, 341 deletions
diff --git a/mbbsd/Makefile b/mbbsd/Makefile
index af0a28d6..439a55bb 100644
--- a/mbbsd/Makefile
+++ b/mbbsd/Makefile
@@ -83,10 +83,11 @@ DIETCC= diet -Os
LDFLAGS+=-Wl,--sort-common
.endif
-.if defined(MERGEBBS)
-CFLAGS+= -DMERGEBBS
-OBJS+= merge.o
-.endif
+#.if defined(MERGEBBS)
+#CFLAGS+= -DMERGEBBS
+#OBJS+= ../upgrade/merge_sob.o
+#.endif
+
LIBS+= $(SRCROOT)/common/bbs/libcmbbs.a \
$(SRCROOT)/common/sys/libcmsys.a
diff --git a/mbbsd/merge.c b/mbbsd/merge.c
deleted file mode 100644
index 913f94f5..00000000
--- a/mbbsd/merge.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/* $Id$ */
-#define _XOPEN_SOURCE
-#define _ISOC99_SOURCE
-/* this is a interface provided when we merge BBS */
-#include "bbs.h"
-#include "fpg.h"
-
-int
-m_sob(void)
-{
- char genbuf[256], buf[256], userid[25], passbuf[24], msg[2048]="";
- int count=0, i, isimported=0, corrected;
- FILE *fp;
- sobuserec man;
- time4_t d;
-
- clear();
- move(1,0);
-
- outs(
- " 請注意 這是只給陽光沙灘使用者!\n"
- " 讓沙灘的使用者轉移個人資產以及重要信用資料, 享有平等安全的環境.\n"
- " 如果您不需要, 請直離開.\n"
- " -----------------------------------------------------------------\n"
- " 特別叮嚀:\n"
- " 為了帳號安全,您只有連續十次密碼錯誤的機會,請小心輸入.\n"
- " 連續次錯誤您的變身功\能就會被開罰單並直接通知站長.\n"
- " 請不要在變身過程中不正常斷線, 刻意斷線變半獸人站長不救唷.\n"
- );
-
- if(getkey("是否要繼續?(y/N)")!='y') return 0;
- if(search_ulistn(usernum,2))
- {vmsg("請登出其他視窗, 以免變身失敗"); return 0;}
- do
- {
- if(!getdata(10,0, " 沙灘的ID [大小寫要完全正確]:", userid, 20,
- DOECHO)) return 0;
- if(bad_user_id(userid)) continue;
- sprintf(genbuf, "sob/passwd/%c/%s.inf",userid[0], userid);
- if(!(fp=fopen(genbuf, "r")))
- {
- isimported = 1;
- strcat(genbuf, ".done");
- if(!(fp=fopen(genbuf, "r")))
- {
- vmsg("查無此人或已經匯入過..請注意大小寫 ");
- isimported = 0;
- continue;
- }
- }
- count = fread(&man, sizeof(man), 1, fp);
- fclose(fp);
- }while(!count);
- count = 0;
- do{
- if(!getdata(11,0, " 沙灘的密碼:", passbuf, sizeof(passbuf),
- NOECHO)) return 0;
- if(++count>=10)
- {
- cuser.userlevel |= PERM_VIOLATELAW;
- cuser.vl_count++;
- passwd_update(usernum, &cuser);
- post_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤十次",
- "違法觀察");
- mail_violatelaw(cuser.userid, "[PTT警察]", "測試帳號錯誤十次",
- "違法觀察");
-
- return 0;
- }
- if(!(corrected = checkpasswd(man.passwd, passbuf)))
- vmsg("密碼錯誤");
- } while(!corrected);
- move(12,0);
- clrtobot();
-
- if(!isimported)
- {
- if(!dashf(genbuf)) // avoid multi-login
- {
- vmsg("請不要嘗試多重id踹匯入");
- return 0;
- }
- sprintf(buf,"%s.done",genbuf);
- rename(genbuf,buf);
-#ifdef MERGEMONEY
-
- reload_money();
-
- sprintf(buf,
- "您的沙灘鸚鵡螺 %10d 換算成 " MONEYNAME " 幣為 %9d (匯率 22:1), \n"
- " 沙灘貝殼有 %10d 換算為 " MONEYNAME " 幣為 %9d (匯率 222105:1), \n"
- " 原有 %10d 匯入後共有 %d\n",
- (int)man.goldmoney, (int)man.goldmoney/22,
- (int)man.silvermoney, (int)man.silvermoney/222105,
- cuser.money,
- (int)(cuser.money + man.goldmoney/22 + man.silvermoney/222105));
- demoney(man.goldmoney/22 + man.silvermoney/222105 );
- strcat(msg, buf);
-#endif
-
- i = cuser.exmailbox + man.exmailbox + man.exmailboxk/2000;
- if (i > MAX_EXKEEPMAIL) i = MAX_EXKEEPMAIL;
- sprintf(buf, "您的沙灘信箱有 %d (%dk), 原有 %d 匯入後共有 %d\n",
- man.exmailbox, man.exmailboxk, cuser.exmailbox, i);
- strcat(msg, buf);
- cuser.exmailbox = i;
-
- if(man.userlevel & PERM_MAILLIMIT)
- {
- sprintf(buf, "開啟信箱無上限\n");
- strcat(msg, buf);
- cuser.userlevel |= PERM_MAILLIMIT;
- }
-
- if (cuser.firstlogin > man.firstlogin)
- d = man.firstlogin;
- else
- d = cuser.firstlogin;
- cuser.firstlogin = d;
-
- if (cuser.numlogins < man.numlogins)
- i = man.numlogins;
- else
- i = cuser.numlogins;
-
- sprintf(buf, "沙灘進站次數 %d 此帳號 %d 將取 %d \n", man.numlogins,
- cuser.numlogins, i);
- strcat(msg,buf);
- cuser.numlogins = i;
-
- if (cuser.numposts < man.numposts )
- i = man.numposts;
- else
- i = cuser.numposts;
- sprintf(buf, "沙灘文章次數 %d 此帳號 %d 將取 %d\n",
- man.numposts,cuser.numposts,i);
- strcat(msg,buf);
- cuser.numposts = i;
- outs(msg);
- while (search_ulistn(usernum,2))
- {vmsg("請將重覆上站其他線關閉! 再繼續");}
- passwd_update(usernum, &cuser);
- }
- sethomeman(genbuf, cuser.userid);
- mkdir(genbuf, 0600);
- sprintf(buf, "tar zxvf %c/%s.tar.gz>/dev/null",
- userid[0], userid);
- chdir("sob/home");
- system(buf);
- chdir(BBSHOME);
-
- if (getans("是否匯入個人信箱? (Y/n)")!='n')
- {
- sethomedir(buf, cuser.userid);
- sprintf(genbuf, "sob/home/%c/%s/.DIR",
- userid[0], userid);
- merge_dir(buf, genbuf, 1);
- strcat(msg, "匯入個人信箱\n");
- }
- if(getans("是否匯入個人信箱精華區(個人作品集)? (會覆蓋\現有設定) (y/N)")=='y')
- {
- fileheader_t fh;
- sprintf(buf,
- "rm -rd home/%c/%s/man>/dev/null ; "
- "mv sob/home/%c/%s/man home/%c/%s>/dev/null;"
- "mv sob/home/%c/%s/gem home/%c/%s/man>/dev/null",
- cuser.userid[0], cuser.userid,
- userid[0], userid,
- cuser.userid[0], cuser.userid,
- userid[0], userid,
- cuser.userid[0], cuser.userid);
- system(buf);
- strcat(msg, "匯入個人信箱精華區(個人作品集)\n");
- sprintf(buf,"home/%c/%s/man/gem", cuser.userid[0], cuser.userid);
- if(dashd(buf))
- {
- strcat(fh.title, "◆ 個人作品集");
- strcat(fh.filename, "gem");
- sprintf(fh.owner, cuser.userid);
- sprintf(buf, "home/%c/%s/man/.DIR", cuser.userid[0], cuser.userid);
- append_record(buf, &fh, sizeof(fh));
- }
- }
- if(getans("是否匯入好友名單? (會覆蓋\現有設定, ID可能是不同人)? (y/N)")=='y')
- {
- sethomefile(genbuf, cuser.userid, "overrides");
- sprintf(buf, "sob/home/%c/%s/overrides",userid[0],userid);
- Copy(buf, genbuf);
- strcat(buf, genbuf);
- friend_load(FRIEND_OVERRIDE);
- strcat(msg, "匯入好友名單\n");
- }
- sprintf(buf, "帳號匯入報告 %s -> %s ", userid, cuser.userid);
- post_msg(GLOBAL_SECURITY, buf, msg, "[系統安全局]");
-
- vmsg("恭喜您完成帳號變身..");
- return 0;
-}
-
-void
-m_sob_brd(char *bname, char *fromdir)
-{
- char fbname[25], buf[256];
- fileheader_t fh;
-
- fromdir[0]=0;
- do{
-
- if(!getdata(20,0, "SOB的板名 [英文大小寫要完全正確]:", fbname, 20,
- DOECHO)) return;
- }
- while((invalid_brdname(fbname)&1));
-
- sprintf(buf, "sob/man/%s.tar.gz", fbname);
- if(!dashf(buf))
- {
- vmsg("無此看板");
- return;
- }
- chdir(BBSHOME"/sob/boards");
- sprintf(buf, "tar zxf %s.tar.gz >/dev/null",fbname);
- system(buf);
- chdir(BBSHOME"/sob/man");
- sprintf(buf, "tar zxf %s.tar.gz >/dev/null", fbname);
- system(buf);
- chdir(BBSHOME);
- sprintf(buf, "mv sob/man/%s man/boards/%c/%s", fbname,
- bname[0], bname);
- system(buf);
- sprintf(fh.title, "◆ %s 精華區", fbname);
- sprintf(fh.filename, fbname);
- sprintf(fh.owner, cuser.userid);
- sprintf(buf, "man/boards/%c/%s/.DIR", bname[0], bname);
- append_record(buf, &fh, sizeof(fh));
- sprintf(fromdir, "sob/boards/%s/.DIR", fbname);
- vmsgf("即將匯入 %s 板資料..按鍵後需要一點時間",fbname);
-}
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 2349a68d..1b3aace1 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -1,46 +1,16 @@
/* $Id$ */
#include "bbs.h"
+// TODO remove this
/* ----------------------------------------------------- */
/* set file path for boards/user home */
/* ----------------------------------------------------- */
static const char * const str_home_file = "home/%c/%s/%s";
static const char * const str_board_file = "boards/%c/%s/%s";
-static const char * const str_board_n_file = "boards/%c/%s/%s.%d";
-
static const char * const str_dotdir = FN_DIR;
/* XXX set*() all assume buffer size = PATHLEN */
-void
-sethomepath(char *buf, const char *userid)
-{
- assert(is_validuserid(userid));
- snprintf(buf, PATHLEN, "home/%c/%s", userid[0], userid);
-}
-
-void
-sethomedir(char *buf, const char *userid)
-{
- assert(is_validuserid(userid));
- snprintf(buf, PATHLEN, str_home_file, userid[0], userid, str_dotdir);
-}
-
-void
-sethomeman(char *buf, const char *userid)
-{
- assert(is_validuserid(userid));
- snprintf(buf, PATHLEN, str_home_file, userid[0], userid, "man");
-}
-
-
-void
-sethomefile(char *buf, const char *userid, const char *fname)
-{
- assert(is_validuserid(userid));
- assert(fname[0]);
- snprintf(buf, PATHLEN, str_home_file, userid[0], userid, fname);
-}
void
setuserfile(char *buf, const char *fname)
@@ -51,27 +21,6 @@ setuserfile(char *buf, const char *fname)
}
void
-setapath(char *buf, const char *boardname)
-{
- //assert(boardname[0]);
- snprintf(buf, PATHLEN, "man/boards/%c/%s", boardname[0], boardname);
-}
-
-void
-setadir(char *buf, const char *path)
-{
- //assert(path[0]);
- snprintf(buf, PATHLEN, "%s/%s", path, str_dotdir);
-}
-
-void
-setbpath(char *buf, const char *boardname)
-{
- //assert(boardname[0]);
- snprintf(buf, PATHLEN, "boards/%c/%s", boardname[0], boardname);
-}
-
-void
setbdir(char *buf, const char *boardname)
{
//assert(boardname[0]);
@@ -79,37 +28,6 @@ setbdir(char *buf, const char *boardname)
(currmode & MODE_DIGEST ? fn_mandex : str_dotdir));
}
-void
-setbfile(char *buf, const char *boardname, const char *fname)
-{
- //assert(boardname[0]);
- assert(fname[0]);
- snprintf(buf, PATHLEN, str_board_file, boardname[0], boardname, fname);
-}
-
-void
-setbnfile(char *buf, const char *boardname, const char *fname, int n)
-{
- //assert(boardname[0]);
- assert(fname[0]);
- snprintf(buf, PATHLEN, str_board_n_file, boardname[0], boardname, fname, n);
-}
-
-/*
- * input direct
- * output buf: copy direct
- * fname: direct 的檔名部分
- */
-void
-setdirpath(char *buf, const char *direct, const char *fname)
-{
- char *p;
- strcpy(buf, direct);
- p = strrchr(buf, '/');
- assert(p);
- strlcpy(p + 1, fname, PATHLEN-(p+1-buf));
-}
-
/**
* 給定文章標題 title,傳回指到主題的部分的指標。
* @param title
@@ -202,14 +120,7 @@ userid_is_BM(const char *userid, const char *list)
return 0;
}
-int
-belong(const char *filelist, const char *key)
-{
- return file_exist_record(filelist, key);
-}
-
-#ifndef _BBS_UTIL_C_ /* getdata_buf */
time4_t
gettime(int line, time4_t dt, const char*head)
{
@@ -259,12 +170,6 @@ void syncnow(void)
#endif
}
-#endif
-
-
-#ifndef _BBS_UTIL_C_
-/* 這一區都是有關於畫面處理的, 故 _BBS_UTIL_C_ 不須要 */
-
#ifdef PLAY_ANGEL
void
pressanykey_or_callangel(){
@@ -593,8 +498,6 @@ show_helpfile(const char *helpfile)
pressanykey();
}
-#endif // _BBS_UTIL_C_
-
/* ----------------------------------------------------- */
/* use mmap() to malloc large memory in CRITICAL_MEMORY */
/* ----------------------------------------------------- */
@@ -605,7 +508,7 @@ void *MALLOC(int size)
p = (int *)mmap(NULL, (size + 4), PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, 0);
p[0] = size;
-#if defined(DEBUG) && !defined(_BBS_UTIL_C_)
+#if defined(DEBUG)
vmsgf("critical malloc %d bytes", size);
#endif
return (void *)&p[1];
@@ -615,7 +518,7 @@ void FREE(void *ptr)
{
int size = ((int *)ptr)[-1];
munmap((void *)(&(((int *)ptr)[-1])), size);
-#if defined(DEBUG) && !defined(_BBS_UTIL_C_)
+#if defined(DEBUG)
vmsgf("critical free %d bytes", size);
#endif
}