summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-10-05 16:08:05 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-10-05 16:08:05 +0800
commit20ed467d8599c745132f71bb23d3ff0d3e68bdd8 (patch)
treecee95a055cd4f8c880570571215141931a0dc4c1
parenta49d8c1a017203186e113e0d5f078c747d2b6f88 (diff)
parent4311844d85cc4e4feca1dc9221ce7725626e7c82 (diff)
downloadpttbbs-victor.fav4.tar
pttbbs-victor.fav4.tar.gz
pttbbs-victor.fav4.tar.bz2
pttbbs-victor.fav4.tar.lz
pttbbs-victor.fav4.tar.xz
pttbbs-victor.fav4.tar.zst
pttbbs-victor.fav4.zip
complete mergevictor.fav4
git-svn-id: http://opensvn.csie.org/pttbbs/branches/victor.fav4@1217 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/README3
-rw-r--r--pttbbs/blog/INSTALL4
-rw-r--r--pttbbs/docs/DONATE4
-rw-r--r--pttbbs/docs/FAQ3
-rw-r--r--pttbbs/docs/INSTALL3
-rw-r--r--pttbbs/include/bbs.h1
-rw-r--r--pttbbs/include/common.h1
-rw-r--r--pttbbs/include/fav.h54
-rw-r--r--pttbbs/include/proto.h9
-rw-r--r--pttbbs/include/pttstruct.h16
-rw-r--r--pttbbs/innbbsd/receive_article.c4
-rw-r--r--pttbbs/mbbsd/Makefile11
-rw-r--r--pttbbs/mbbsd/announce.c3
-rw-r--r--pttbbs/mbbsd/bbs.c369
-rw-r--r--pttbbs/mbbsd/board.c354
-rw-r--r--pttbbs/mbbsd/cal.c4
-rw-r--r--pttbbs/mbbsd/chat.c7
-rw-r--r--pttbbs/mbbsd/chc.c8
-rw-r--r--pttbbs/mbbsd/dice.c11
-rw-r--r--pttbbs/mbbsd/fav.c883
-rw-r--r--pttbbs/mbbsd/friend.c4
-rw-r--r--pttbbs/mbbsd/guess.c6
-rw-r--r--pttbbs/mbbsd/io.c2
-rw-r--r--pttbbs/mbbsd/mbbsd.c77
-rw-r--r--pttbbs/mbbsd/screen.c13
-rw-r--r--pttbbs/mbbsd/stuff.c38
-rw-r--r--pttbbs/mbbsd/talk.c64
-rw-r--r--pttbbs/mbbsd/var.c4
-rw-r--r--pttbbs/sample/etc/chickens/n1012
-rw-r--r--pttbbs/sample/etc/chickens/n1112
-rw-r--r--pttbbs/sample/etc/chickens/n1212
-rw-r--r--pttbbs/sample/etc/chickens/n1313
-rw-r--r--pttbbs/sample/etc/chickens/n1412
-rw-r--r--pttbbs/sample/etc/chickens/n1512
-rw-r--r--pttbbs/sample/etc/chickens/n1612
-rw-r--r--pttbbs/staticweb/INSTALL43
-rw-r--r--pttbbs/staticweb/dir.html1
-rwxr-xr-xpttbbs/staticweb/man.pl2
-rwxr-xr-xpttbbs/staticweb/manbuilder.pl3
-rw-r--r--pttbbs/util/buildir.c14
-rw-r--r--pttbbs/util/shmctl.c71
-rw-r--r--pttbbs/util/waterball.pl3
42 files changed, 872 insertions, 1310 deletions
diff --git a/pttbbs/README b/pttbbs/README
index 7825c087..a9281ad3 100644
--- a/pttbbs/README
+++ b/pttbbs/README
@@ -1,4 +1,5 @@
-$Id: README,v 1.3 2003/06/03 09:25:12 in2 Exp $
+¤å³¹ªºª©¸¹¤Î³Ì«á½s­×®É¶¡¬O:
+$Id$
§Ö³t¦w¸Ë½Ð°Ñ¦Ò docs/INSTALL ¥H¤Î docs/FAQ
¸Ô²Ó¤å¥ó½Ð¨£ docs/
diff --git a/pttbbs/blog/INSTALL b/pttbbs/blog/INSTALL
index 64e60e8c..dfbfb3d0 100644
--- a/pttbbs/blog/INSTALL
+++ b/pttbbs/blog/INSTALL
@@ -1,5 +1,5 @@
-³o½g¤å³¹¦b´y­z«ç»ò¬[³] PttBlog, ³Ì«á¤@¦¸­×¥¿ªº®É¶¡¬°:
-$Id: INSTALL,v 1.4 2003/07/06 03:58:43 in2 Exp $
+³o½g¤å³¹¦b´y­z«ç»ò¬[³] PttBlog, ³Ì«áªº½s­×¤Îª©¸¹¬O:
+$Id$
½Ðª`·N, PttBlog¥»¨Ó¥D­n¬O³]­pµ¹ Ptt2 ¯¸¥x¨Ï¥Î, ¥Ø«e¥¿¦b¶}µo¶¥¬q,
¨Ã¥¼±µ¨üÄY±Kªº´ú¸Õ, ¥i¯àÁٯʤ֫ܦh¥\¯à, ¥H¤Î¥i¯à¦³³\¦hªº bug.
diff --git a/pttbbs/docs/DONATE b/pttbbs/docs/DONATE
index 7b572441..a37c1d06 100644
--- a/pttbbs/docs/DONATE
+++ b/pttbbs/docs/DONATE
@@ -1,5 +1,5 @@
-³o½g¤å³¹´y­zÃö©óÃÙ§U PttBBS . ³Ì«á¤@¦¸­×¥¿ªº®É¶¡¦b:
-$Id: DONATE,v 1.1 2003/06/03 08:51:25 in2 Exp $
+³o½g¤å³¹´y­zÃö©óÃÙ§U PttBBS . ¤å³¹ªºª©¸¹¤Î³Ì«á½s­×®É¶¡¬O:
+$Id$
Donate to PttBBS!
PttBBS ¬O§K¶O¦Û¥Ñ³nÅé, §Ú­Ì³z¹L³o®M¨t²Î(¥¿¦p±z¤â¤W³o¤@¥÷), ¦b¥x¤j
diff --git a/pttbbs/docs/FAQ b/pttbbs/docs/FAQ
index 41b5aae1..6b1ec820 100644
--- a/pttbbs/docs/FAQ
+++ b/pttbbs/docs/FAQ
@@ -1,4 +1,5 @@
-PttBBS FAQ:
+³o½g¤å³¹´y­z PttBBS ¤¤±`³Q°Ý¨ìªº°ÝÃD¤Î¸Ñ¨M¤è¦¡. ¤å³¹ªºª©¸¹¤Î³Ì«á½s­×®É¶¡¬O:
+$Id$
1. PttBBSªº°Q½×°Ï
2. ¦b Linux©³¤U¥X²{ Makefile ¿ù»~.
diff --git a/pttbbs/docs/INSTALL b/pttbbs/docs/INSTALL
index ebaae2eb..8c953434 100644
--- a/pttbbs/docs/INSTALL
+++ b/pttbbs/docs/INSTALL
@@ -1,4 +1,5 @@
-©³¤U¬O§Ö³t¦w¸Ëªº¤èªk
+³o½g¤å¥ó»¡©ú§Ö³t¦w¸Ëªº¤èªk, ¤å³¹ªºª©¸¹¤Î³Ì«á½s­×®É¶¡¬O:
+$Id$
==============
¥H root ªºÅv­­
diff --git a/pttbbs/include/bbs.h b/pttbbs/include/bbs.h
index 60e20301..666d30c7 100644
--- a/pttbbs/include/bbs.h
+++ b/pttbbs/include/bbs.h
@@ -57,7 +57,6 @@
/* our header */
#include "config.h"
#include "pttstruct.h"
-#include "fav.h"
#include "common.h"
#include "perm.h"
#include "modes.h"
diff --git a/pttbbs/include/common.h b/pttbbs/include/common.h
index 18d377c2..786f13df 100644
--- a/pttbbs/include/common.h
+++ b/pttbbs/include/common.h
@@ -8,6 +8,7 @@
#define FN_PASSWD BBSHOME "/.PASSWDS" /* User records */
#define FN_USSONG "ussong" /* ÂIºq²Î­p */
#define FN_POST_NOTE "post.note" /* po¤å³¹³Æ§Ñ¿ý */
+#define FN_POST_BID "post.bid"
#define FN_APPLICATION "application"
#define FN_MONEY "etc/money"
#define FN_OVERRIDES "overrides"
diff --git a/pttbbs/include/fav.h b/pttbbs/include/fav.h
deleted file mode 100644
index 3cb1f9b6..00000000
--- a/pttbbs/include/fav.h
+++ /dev/null
@@ -1,54 +0,0 @@
-
-#define FAVT_BOARD 1
-#define FAVT_FOLDER 2
-#define FAVT_LINE 3
-
-#define FAVH_FAV 1
-#define FAVH_TAG 2
-#define FAVH_UNREAD 4
-
-#define TRUE 1
-#define FALSE 0
-
-#define FAV_PRE_ALLOC 8
-#define FAV_MAXDEPTH 5
-#define MAX_FAV 1024
-#define MAX_LINE 32
-#define MAX_FOLDER 32
-
-#define FAV3 ".fav3"
-#define FAV4 ".fav4"
-
-typedef struct {
- char type;
- char attr;
- /* *fp could be *fav_board_t or *fav_folder_t. */
- void *fp;
-} fav_type_t;
-
-typedef struct {
- short nAllocs;
- short nDatas;
- short nBoards;
- char nLines;
- char nFolders;
-
- /* record of boards/folders */
- fav_type_t *favh;
-} fav_t;
-
-typedef struct {
- short bid;
- time_t lastvisit;
- char attr;
-} fav_board_t;
-
-typedef struct {
- char fid;
- char title[BTLEN + 1];
- fav_t *this_folder;
-} fav_folder_t;
-
-typedef struct {
- char lid;
-} fav_line_t;
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index fa00d397..b202e20e 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -72,7 +72,6 @@ int Boards();
int root_board();
void save_brdbuf(void);
void init_brdbuf(void);
-int validboard(int bid);
#ifdef CRITICAL_MEMORY
void sigfree(int);
#endif
@@ -266,7 +265,7 @@ int guess_main();
/* indict */
int x_dict();
-int use_dict();
+int use_dict(char *dict,char *database);
/* io */
int getdata(int line, int col, char *prompt, char *buf, int len, int echo);
@@ -284,7 +283,6 @@ int num_in_buf();
int ochar(int c);
int rget(int x,char *prompt);
char getans(char *prompt);
-int timeout_read(int fd, void *pointer, int size, int sec);
/* kaede */
int Rename(char* src, char* dst);
@@ -396,6 +394,7 @@ void UnTagger (int locus);
int substitute_record(char *fpath, void *rptr, int size, int id);
int lock_substitute_record(char *fpath, void *rptr, int size, int id, int);
int get_record(char *fpath, void *rptr, int size, int id);
+int get_record_keep(char *fpath, void *rptr, int size, int id, int *fd);
void prints(char *fmt, ...) GCC_CHECK_FORMAT(1,2);
int append_record(char *fpath, fileheader_t *record, int size);
int stampfile(char *fpath, fileheader_t *fh);
@@ -444,7 +443,7 @@ void initscr();
void Jaky_outs(char *str, int line);
/* stuff */
-time_t gettime(int line, time_t dt);
+time_t gettime(int line, time_t dt, char* head);
void setcalfile(char *buf, char *userid);
void stand_title(char *title);
void pressanykey();
@@ -488,6 +487,8 @@ int not_alpha(char ch);
int valid_ident(char *ident);
int userid_is_BM(char *userid, char *list);
int is_uBM(char *list, char *id);
+inline int *intbsearch(int key, int *base0, int nmemb);
+int qsort_intcompar(const void *a, const void *b);
#ifndef CRITICAL_MEMORY
#define MALLOC(p) malloc(p)
#define FREE(p) free(p)
diff --git a/pttbbs/include/pttstruct.h b/pttbbs/include/pttstruct.h
index 991b2154..5ec26a57 100644
--- a/pttbbs/include/pttstruct.h
+++ b/pttbbs/include/pttstruct.h
@@ -2,6 +2,18 @@
#ifndef INCLUDE_STRUCT_H
#define INCLUDE_STRUCT_H
+#define IDLEN 12 /* Length of bid/uid */
+typedef struct bid_t {
+ int high;
+ int buyitnow;
+ int usermax;
+ int increment;
+ char userid[IDLEN + 1];
+ time_t enddate;
+ int payby; /* 1 cash 2 check or mail 4 wire 8 credit 16 postoffice */
+ int shipping;
+}bid_t;
+
/* ¤pÂûªº¸ê®Æ */
typedef struct chicken_t {
char name[20];
@@ -30,7 +42,6 @@ typedef struct chicken_t {
int pad[2]; /* ¯dµÛ¥H«á¥Î */
} chicken_t;
-#define IDLEN 12 /* Length of bid/uid */
#define PASSLEN 14 /* Length of encrypted passwd field */
#define REGLEN 38 /* Length of registration data */
@@ -162,6 +173,7 @@ typedef struct fileheader_t {
#define FILE_BM 0x40 /* BM only */
#define FILE_BOTH 0x80 /* both replay for mail and board */
#define FILE_MULTI 0x100 /* multi send for mail */
+#define FILE_BID 0x20 /* for bid */
#define STRLEN 80 /* Length of most string data */
@@ -226,6 +238,8 @@ typedef struct userinfo_t {
int from_alias;
char birth; /* ¬O§_¬O¥Í¤é Ptt*/
char tty[11]; /* tty port */
+ short nFriends; /* ¤U­± friend[] ¥u¥Î¨ì«e´X­Ó,
+ ¥Î¨Ó bsearch */
int friend[MAX_FRIEND];
int friend_online[MAX_FRIEND];/* point¨ì½u¤W¦n¤Í utmpshmªº¦ì¸m */
/* ¦n¤Í¤ñ¸ûªºcache «e¨â­Óbit¬Oª¬ºA */
diff --git a/pttbbs/innbbsd/receive_article.c b/pttbbs/innbbsd/receive_article.c
index 29790a96..f45fda75 100644
--- a/pttbbs/innbbsd/receive_article.c
+++ b/pttbbs/innbbsd/receive_article.c
@@ -873,8 +873,10 @@ char *pathname, *firstpath;
append_record(index, &header, sizeof(header));
- if((bid = getbnum(board)) > 0)
+ if((bid = getbnum(board)) > 0){
touchbtotal(bid);
+ touchdircache(bid);
+ }
return name;
}
diff --git a/pttbbs/mbbsd/Makefile b/pttbbs/mbbsd/Makefile
index 1d0851ce..e6a9adbd 100644
--- a/pttbbs/mbbsd/Makefile
+++ b/pttbbs/mbbsd/Makefile
@@ -9,11 +9,12 @@ LDFLAGS+= -L/usr/local/lib/mysql -lmysqlclient
PROG= mbbsd
OBJS= admin.o announce.o args.o bbs.o board.o cache.o cal.o card.o\
- chat.o chc.o chicken.o dark.o edit.o fav.o friend.o gamble.o gomo.o\
- guess.o indict.o io.o kaede.o lovepaper.o mail.o mbbsd.o menu.o\
- more.o name.o osdep.o othello.o page.o read.o record.o\
- register.o screen.o stuff.o talk.o term.o topsong.o user.o\
- vice.o vote.o xyz.o voteboard.o syspost.o var.o passwd.o calendar.o
+ chat.o chc.o chicken.o dark.o\
+ edit.o friend.o gamble.o gomo.o guess.o indict.o io.o\
+ kaede.o lovepaper.o mail.o mbbsd.o menu.o more.o name.o osdep.o\
+ othello.o page.o read.o record.o register.o screen.o stuff.o\
+ talk.o term.o topsong.o user.o vice.o vote.o xyz.o\
+ voteboard.o syspost.o var.o passwd.o calendar.o
.SUFFIXES: .c .o
.c.o: ../include/var.h
diff --git a/pttbbs/mbbsd/announce.c b/pttbbs/mbbsd/announce.c
index ac001d28..c3a267a9 100644
--- a/pttbbs/mbbsd/announce.c
+++ b/pttbbs/mbbsd/announce.c
@@ -874,8 +874,7 @@ a_menu(char *maintitle, char *path, int lastlevel)
¶·µ¥¸Ó¸ê®Æ¼g¤J .DIR ¤º¦A implement¤~¦³®Ä²v.
*/
if( !lastlevel && !HAS_PERM(PERM_SYSOP) &&
- !HAS_PERM(PERM_SYSSUBOP) && is_BM_cache(currbid) &&
- dashd(fname) )
+ !is_BM_cache(currbid) && dashd(fname) )
vmsg("¥u¦³ªO¥D¤~¥i¥H«þ¨©¥Ø¿ý­ò!");
else
a_copyitem(fname, me.header[me.now - me.page].title, 0, 1);
diff --git a/pttbbs/mbbsd/bbs.c b/pttbbs/mbbsd/bbs.c
index bb7d7f9a..756b8055 100644
--- a/pttbbs/mbbsd/bbs.c
+++ b/pttbbs/mbbsd/bbs.c
@@ -100,7 +100,6 @@ save_violatelaw()
*/
static time_t board_note_time;
-static char *brd_title;
void
set_board()
@@ -113,12 +112,10 @@ set_board()
u_exit("access control violation!");
}
board_note_time = bp->bupdate;
- brd_title = bp->BM;
- if (brd_title[0] <= ' ')
- brd_title = "¼x¨D¤¤";
- snprintf(currBM, sizeof(currBM), "ªO¥D¡G%s", brd_title);
- brd_title = ((bp->bvote != 2 && bp->bvote) ? "¥»¬ÝªO¶i¦æ§ë²¼¤¤" :
- bp->title + 7);
+ if(bp->BM[0] <= ' ')
+ strcpy(currBM, "¼x¨D¤¤");
+ else
+ snprintf(currBM, sizeof(currBM), "ªO¥D¡G%s", bp->BM);
currmode = (currmode & (MODE_DIRTY | MODE_MENU)) | MODE_STARTED;
if (HAS_PERM(PERM_ALLBOARD) || is_BM_cache(currbid))
@@ -130,9 +127,18 @@ set_board()
static void
readtitle()
{
+ boardheader_t *bp;
+ char *brd_title;
+
+ bp = getbcache(currbid);
+ if(bp->bvote != 2 && bp->bvote)
+ brd_title = "¥»¬ÝªO¶i¦æ§ë²¼¤¤";
+ else
+ brd_title = bp->title + 7;
+
showtitle(currBM, brd_title);
outs("[¡ö]Â÷¶} [¡÷]¾\\Ū [^P]µoªí¤å³¹ [b]³Æ§Ñ¿ý [d]§R°£ [z]ºëµØ°Ï "
- "[TAB]¤åºK [h]elp\n\033[7m ½s¸¹ ¤é ´Á §@ ªÌ ¤å ³¹ ¼Ð ÃD"
+ "[TAB]¤åºK [h]elp\n\033[7m ½s¸¹ ¤é ´Á §@ ªÌ ¤å ³¹ ¼Ð ÃD"
" \033[m");
}
@@ -140,12 +146,9 @@ static void
readdoent(int num, fileheader_t * ent)
{
int type;
- char *mark, *title, color, special = 0, isonline = 0;
+ char *mark, *title, color, special = 0, isonline = 0, recom[5];
userinfo_t *uentp;
- if (ent->recommend > 9 || ent->recommend < 0)
- ent->recommend = 0;
-//Ptt:¼È®É
- type = brc_unread(ent->filename, brc_num, brc_list) ? '+' : ' ';
+ type = brc_unread(ent->filename, brc_num, brc_list) ? '+' : ' ';
if ((currmode & MODE_BOARD) && (ent->filemode & FILE_DIGEST))
type = (type == ' ') ? '*' : '#';
@@ -160,13 +163,15 @@ readdoent(int num, fileheader_t * ent)
type = 's';
}
title = subject(mark = ent->title);
- if (title == mark)
+ if (ent->filemode & FILE_BID)
+ color = '1', mark = "¢C";
+ else if (title == mark)
color = '1', mark = "¡¼";
else
color = '3', mark = "R:";
- if (title[47])
- strlcpy(title + 44, " ¡K", sizeof(title) - 44); /* §â¦h¾lªº string ¬å±¼ */
+ if (title[45])
+ strlcpy(title + 42, " ¡K", sizeof(title) - 42); /* §â¦h¾lªº string ¬å±¼ */
if (!strncmp(title, "[¤½§i]", 6))
special = 1;
@@ -180,14 +185,21 @@ readdoent(int num, fileheader_t * ent)
(uentp = search_ulist(uid)) && isvisible(currutmp, uentp))
isonline = 1;
#endif
+ if(ent->recommend>99)
+ strcpy(recom,"1mÃz");
+ else if(ent->recommend>9)
+ sprintf(recom,"3m%2d",ent->recommend);
+ else if(ent->recommend>0)
+ sprintf(recom,"2m%2d",ent->recommend);
+ else strcpy(recom,"0m ");
prints(
#ifdef COLORDATE
- "%6d %c\033[1;32m%c\033[%dm%-6s\033[m\033[%dm%-13.12s",
+ "%6d %c\033[1;3%4.4s\033[%dm%-6s\033[m\033[%dm%-13.12s",
#else
- "%6d %c\033[1;32m%c\033[m%-6s\033[%dm%-13.12s",
+ "%6d %c\033[1;3%4.4s\033[m%-6s\033[%dm%-13.12s",
#endif
- num, type, ent->recommend ? ent->recommend + '0' : ' ',
+ num, type, recom,
#ifdef COLORDATE
(ent->date[3] + ent->date[4]) % 7 + 31,
#endif
@@ -440,10 +452,65 @@ do_allpost(fileheader_t *postfile, const char *fpath, const char *owner)
setbtotal(getbnum(ALLPOST));
}
}
+static void
+setupbidinfo(bid_t *bidinfo)
+{
+ char buf[256];
+ bidinfo->enddate = gettime(20, now+86400,"µ²§ô¼Ð®×©ó");
+ do
+ getdata_str(21,0,"©³»ù:",buf, 8, LCECHO, "1");
+ while((bidinfo->high=atoi(buf))<=0);
+ do
+ getdata_str(21,20, "¨C¼Ð¦Ü¤Ö¼W¥[¦h¤Ö:",buf, 5, LCECHO, "1");
+ while((bidinfo->increment=atoi(buf))<=0);
+ getdata(21,44, "ª½±µÁʶR»ù(¥i¤£³]):",buf, 5, LCECHO);
+ bidinfo->buyitnow=atoi(buf);
+
+ getdata_str(22,0,
+ "¥I´Ú¤è¦¡: 1.Ptt¹ô 2.¶l§½©Î»È¦æÂà±b 3.¤ä²¼©Î¹q¶× 4.¶l§½³f¨ì¥I´Ú [1]:",
+ buf, 3, LCECHO,"1");
+ bidinfo->payby=(buf[0]-'1');
+ if(bidinfo->payby<0 ||bidinfo->payby>3)bidinfo->payby=0;
+ getdata_str(23,0, "¹B¶O(0:§K¹B¶O©Î¤å¤¤»¡©ú)[0]:", buf, 6, LCECHO, "0");
+ bidinfo->shipping = atoi(buf);
+ if(bidinfo->shipping<0) bidinfo->shipping=0;
+}
+static void
+print_bidinfo(FILE *io, bid_t bidinfo)
+{
+ char *payby[4]={ "Ptt¹ô","¶l§½©Î»È¦æÂà±b","¤ä²¼©Î¹q¶×","¶l§½³f¨ì¥I´Ú"};
+ if(io)
+ {
+ if(!bidinfo.userid[0])
+ fprintf(io,"°_¼Ð»ù: %-20d\n",bidinfo.high);
+ else
+ fprintf(io, "¥Ø«e³Ì°ª»ù:%-20d¥X»ùªÌ:%-16s\n",bidinfo.high, bidinfo.userid);
+ fprintf(io, "¥I´Ú¤è¦¡: %-20sµ²§ô©ó:%-16s\n",payby[bidinfo.payby%4],Cdate(& bidinfo.enddate));
+ if(bidinfo.buyitnow)
+ fprintf(io, "ª½±µÁʶR»ù:%-20d",bidinfo.buyitnow);
+ if(bidinfo.shipping)
+ fprintf(io, "¹B¶O:%d", bidinfo.shipping);
+ fprintf(io, "\n");
+ }
+ else
+ {
+ if(!bidinfo.userid[0])
+ prints("°_¼Ð»ù: %-20d\n",bidinfo.high);
+ else
+ prints("¥Ø«e³Ì°ª»ù:%-20d¥X»ùªÌ:%-16s\n",bidinfo.high, bidinfo.userid);
+ prints("¥I´Ú¤è¦¡: %-20sµ²§ô©ó:%-16s\n",payby[bidinfo.payby%4],Cdate(& bidinfo.enddate));
+ if(bidinfo.buyitnow)
+ prints("ª½±µÁʶR»ù:%-20d",bidinfo.buyitnow);
+ if(bidinfo.shipping)
+ prints("¹B¶O:%d", bidinfo.shipping);
+ prints("\n");
+ }
+}
static int
-do_general()
+do_general(int isbid)
{
+ bid_t bidinfo;
fileheader_t postfile;
char fpath[80], buf[80];
int aborted, defanony, ifuseanony;
@@ -483,27 +550,46 @@ do_general()
#endif
#endif
- setbfile(genbuf, currboard, FN_POST_NOTE);
+ if(!isbid)
+ setbfile(genbuf, currboard, FN_POST_NOTE);
+ else
+ setbfile(genbuf, currboard, FN_POST_BID);
if (more(genbuf, NA) == -1)
- more("etc/" FN_POST_NOTE, NA);
-
+ {
+ if(!isbid)
+ more("etc/" FN_POST_NOTE, NA);
+ else
+ more("etc/" FN_POST_BID, NA);
+ }
move(19, 0);
- prints("µoªí¤å³¹©ó¡i\033[33m %s\033[m ¡j \033[32m%s\033[m ¬ÝªO\n\n",
+ prints("%s©ó¡i\033[33m %s\033[m ¡j \033[32m%s\033[m ¬ÝªO\n",
+ isbid?"¤½¶}©Û¼Ð":"µoªí¤å³¹",
currboard, bp->title + 7);
-
+ if(isbid)
+ {
+ memset(&bidinfo,0,sizeof(bidinfo));
+ setupbidinfo(&bidinfo);
+ postfile.money=bidinfo.high;
+ move(20,0);
+ clrtobot();
+ }
if (quote_file[0])
do_reply_title(20, currtitle);
else {
- getdata(21, 0,
- "ºØÃþ¡G1.°ÝÃD 2.«Øij 3.°Q½× 4.¤ß±o 5.¶¢²á 6.¤½§i 7.±¡³ø (1-7©Î¤£¿ï)",
+ if(!isbid)
+ {
+ getdata(21, 0,
+ "ºØÃþ¡G1.°ÝÃD 2.«Øij 3.°Q½× 4.¤ß±o 5.¶¢²á 6.¤½§i 7.±¡³ø (1-7©Î¤£¿ï)",
save_title, 3, LCECHO);
- local_article = save_title[0] - '1';
- if (local_article >= 0 && local_article <= 6)
+
+ local_article = save_title[0] - '1';
+ if (local_article >= 0 && local_article <= 6)
snprintf(save_title, sizeof(save_title),
"[%s] ", ctype[local_article]);
- else
+ else
save_title[0] = '\0';
+ }
getdata_buf(22, 0, "¼ÐÃD¡G", save_title, TTLEN, DOECHO);
strip_ansi(save_title, save_title, 0);
}
@@ -523,7 +609,16 @@ do_general()
/* build filename */
setbpath(fpath, currboard);
stampfile(fpath, &postfile);
-
+ if(isbid)
+ {
+ aborted = (int)fopen(fpath, "w");
+ if(aborted)
+ {
+ print_bidinfo((FILE*)aborted, bidinfo);
+ fclose((FILE*)aborted);
+ }
+ }
+
aborted = vedit(fpath, YEA, &islocal);
if (aborted == -1) {
unlink(fpath);
@@ -550,13 +645,20 @@ do_general()
#endif
/* ¿ú */
aborted = (aborted > MAX_POST_MONEY * 2) ? MAX_POST_MONEY : aborted / 2;
- postfile.money = aborted;
+ if(!isbid)
+ postfile.money = aborted;
strlcpy(postfile.owner, owner, sizeof(postfile.owner));
strlcpy(postfile.title, save_title, sizeof(postfile.title));
if (islocal) /* local save */
- postfile.filemode = FILE_LOCAL;
+ postfile.filemode |= FILE_LOCAL;
setbdir(buf, currboard);
+ if(isbid)
+ {
+ sprintf(genbuf, "%s.bid", fpath);
+ append_record(genbuf,(void*) &bidinfo, sizeof(bidinfo));
+ postfile.filemode |= FILE_BID ;
+ }
if (append_record(buf, &postfile, sizeof(postfile)) != -1) {
setbtotal(currbid);
@@ -576,9 +678,14 @@ do_general()
aborted = (aborted > MAX_POST_MONEY) ? MAX_POST_MONEY : aborted;
#endif
if (strcmp(currboard, "Test") && !ifuseanony) {
- prints("³o¬O±zªº²Ä %d ½g¤å³¹¡C ½Z¹S %d »È¡C",
- ++cuser.numposts, aborted);
- demoney(aborted);
+ prints("³o¬O±zªº²Ä %d ½g¤å³¹¡C",++cuser.numposts);
+ if(!(postfile.filemode&FILE_BID))
+ {
+ prints(" ½Z¹S %d »È¡C",aborted);
+ demoney(aborted);
+ }
+ else
+ prints("©Û¼Ð¤å³¹¨S¦³½Z¹S¡C");
passwd_update(usernum, &cuser); /* post ¼Æ */
} else
outs("´ú¸Õ«H¥ó¤£¦C¤J¬ö¿ý¡A·q½Ð¥]²[¡C");
@@ -605,7 +712,7 @@ do_general()
strlcpy(postfile.owner, cuser.userid, sizeof(postfile.owner));
strlcpy(postfile.title, save_title, sizeof(postfile.title));
- postfile.filemode = FILE_BOTH; /* both-reply flag */
+ postfile.filemode |= FILE_BOTH; /* both-reply flag */
sethomedir(genbuf, quote_user);
if (append_record(genbuf, &postfile, sizeof(postfile)) == -1)
msg = err_uid;
@@ -628,7 +735,18 @@ do_post()
if (bp->brdattr & BRD_VOTEBOARD)
return do_voteboard();
else if (!(bp->brdattr & BRD_GROUPBOARD))
- return do_general();
+ return do_general(0);
+ touchdircache(currbid);
+ return 0;
+}
+
+int
+do_post_openbid()
+{
+ boardheader_t *bp;
+ bp = getbcache(currbid);
+ if (!(bp->brdattr & BRD_VOTEBOARD))
+ return do_general(1);
touchdircache(currbid);
return 0;
}
@@ -1137,7 +1255,7 @@ hold_gamble(int ent, fileheader_t * fhdr, char *direct)
} while (i < 10 || i > 10000);
fprintf(fp, "%d\n", i);
if (!getdata(3, 0, "³]©w¦Û°Ê«Ê½L®É¶¡?(Y/n)", yn, 3, LCECHO) || yn[0] != 'n') {
- bp->endgamble = gettime(4, now);
+ bp->endgamble = gettime(4, now, "«Ê½L©ó");
substitute_record(fn_board, bp, sizeof(boardheader_t), currbid);
}
move(6, 0);
@@ -1252,6 +1370,138 @@ recommend_cancel(int ent, fileheader_t * fhdr, char *direct)
touchdircache(currbid);
return FULLUPDATE;
}
+static int
+do_add_recommend(char * direct,fileheader_t * fhdr, int ent, char*buf)
+{
+ char path[256];
+ lock_substitute_record(direct, fhdr, sizeof(*fhdr), ent, LOCK_EX);
+ setdirpath(path, direct, fhdr->filename);
+ log_file(path, buf);
+ if (!(fhdr->recommend < 100))
+ lock_substitute_record(direct, fhdr, sizeof(*fhdr), ent, LOCK_UN);
+ else{
+ fhdr->recommend++;
+ passwd_update(usernum, &cuser);
+ lock_substitute_record(direct, fhdr, sizeof(*fhdr), ent, LOCK_UN);
+ substitute_check(fhdr);
+ touchdircache(currbid);
+ }
+ return 0;
+}
+static int
+do_bid(int ent, fileheader_t * fhdr, boardheader_t *bp, char *direct, struct tm *ptime)
+{
+ char genbuf[200], fpath[256],say[30];
+ bid_t bidinfo;
+ int i, next;
+
+ setdirpath(fpath, direct, fhdr->filename);
+ strcat(fpath,".bid");
+ get_record(fpath, &bidinfo, sizeof(bidinfo), 1);
+
+ move(18,0); clrtobot();
+ prints("Äv¼Ð¥DÃD: %s\n", fhdr->title);
+ print_bidinfo(0, bidinfo);
+ if(now>bidinfo.enddate || bidinfo.high==bidinfo.buyitnow)
+ {
+ prints("¦¹Äv¼Ð¤w¸gµ²§ô,");
+ if( bidinfo.userid[0])
+ {
+ /*if(!payby && bidinfo.usermax!=-1)
+ {¥HPtt¹ô¦Û°Ê¦©´Ú
+ }*/
+ prints("®¥³ß %s ¥H %d ±o¼Ð!", bidinfo.userid, bidinfo.high);
+ }
+ else prints("µL¤H±o¼Ð!");
+ pressanykey();
+ return FULLUPDATE;
+ }
+ if(bidinfo.userid[0])
+ {
+ prints("¤U¦¸¥X»ù¦Ü¤Ö­n:%d", bidinfo.high + bidinfo.increment);
+ if(bidinfo.buyitnow)
+ prints(" (¶W¹L %d µ¥©óª½±µÁʶR)",bidinfo.buyitnow);
+ next=bidinfo.high + bidinfo.increment;
+ }
+ else
+ {
+ prints("°_¼Ð»ù: %d", bidinfo.high);
+ next=bidinfo.high;
+ }
+ if(!strcmp(cuser.userid,bidinfo.userid))
+ {
+ prints("§A¬O³Ì°ª±o¼ÐªÌ!");
+ pressanykey();
+ return FULLUPDATE;
+ }
+ if (strcmp(cuser.userid, fhdr->owner) == 0){
+ vmsg("ĵ§i! ¥»¤H¤£¯à¥X»ù!");
+ return FULLUPDATE;
+ }
+ getdata_str(23,0,"¬O§_­n¤U¼Ð? (y/N)", genbuf, 3, LCECHO,"n");
+ if(genbuf[0]!='y') return FULLUPDATE;
+
+ getdata(23, 0, "±zªº³Ì°ª¤U¼Ðª÷ÃB(0:¨ú®ø):", genbuf, 7, LCECHO);
+
+ i=atoi(genbuf);
+
+ get_record(fpath, &bidinfo, sizeof(bidinfo), 1);
+ if(!bidinfo.userid[0])
+ next=bidinfo.high;
+ else
+ next=bidinfo.high + bidinfo.increment;
+
+ if(i< next || (bidinfo.payby==0 && cuser.money<i ));
+ {
+ outmsg("¨ú®ø¤U¼Ð©Î¼Ðª÷¤£¨¬");
+ pressanykey();
+ }
+
+ getdata(23,0,"¤U¼Ð·P¨¥:",say,12,DOECHO);
+ snprintf(genbuf, sizeof(genbuf),
+ "\033[1;31m¡÷ \033[33m%s\033[m\033[33m:%s\033[m%*sª÷ÃB:%-15d¼Ð%15s %02d/%02d\n",
+ cuser.userid,say,
+ 31 - strlen(cuser.userid) - strlen(say), " ",
+ next, fromhost,
+ ptime->tm_mon + 1, ptime->tm_mday);
+ do_add_recommend(direct, fhdr, ent, genbuf);
+ if(next>bidinfo.usermax)
+ {
+ bidinfo.usermax=i;
+ bidinfo.high=next;
+ strcpy(bidinfo.userid,cuser.userid);
+ }
+ else if(next<bidinfo.usermax && i>bidinfo.usermax)
+ {
+ bidinfo.high=bidinfo.usermax+bidinfo.increment;
+ bidinfo.usermax=i;
+ strcpy(bidinfo.userid,cuser.userid);
+
+ snprintf(genbuf, sizeof(genbuf),
+"\033[1;31m¡÷ \033[33m¦Û°ÊÄv¼Ð%s³Ó¥X\033[m\033[33m\033[m%*sª÷ÃB:%-15d¼Ð %02d/%02d\n",
+ cuser.userid,
+ 20 - strlen(cuser.userid) , " ",
+ bidinfo.high,
+ ptime->tm_mon + 1, ptime->tm_mday);
+ do_add_recommend(direct, fhdr, ent, genbuf);
+ }
+ else
+ {
+ if(i+bidinfo.increment<bidinfo.usermax)
+ bidinfo.high=i+bidinfo.increment;
+ else
+ bidinfo.high=bidinfo.usermax; /*³oÃä©Ç©Çªº*/
+ snprintf(genbuf, sizeof(genbuf),
+"\033[1;31m¡÷ \033[33m¦Û°ÊÄv¼Ð%s³Ó¥X\033[m\033[33m\033[m%*sª÷ÃB:%-15d¼Ð %02d/%02d\n",
+ bidinfo.userid,
+ 20 - strlen(bidinfo.userid) , " ",
+ bidinfo.high,
+ ptime->tm_mon + 1, ptime->tm_mday);
+ do_add_recommend(direct, fhdr, ent, genbuf);
+ }
+ substitute_record(fpath, &bidinfo, sizeof(bidinfo), 1);
+ return FULLUPDATE;
+}
static int
recommend(int ent, fileheader_t * fhdr, char *direct)
@@ -1263,18 +1513,19 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
bp = getbcache(currbid);
if( bp->brdattr & BRD_NORECOMMEND ){
- vmsg("©êºp, ¥»ªO¸T¤î±ÀÂË");
+ vmsg("©êºp, ¥»ªO¸T¤î±ÀÂË©ÎÄv¼Ð");
return FULLUPDATE;
}
if (!(currmode & MODE_POST) || bp->brdattr & BRD_VOTEBOARD) {
- vmsg("±z¦]Åv­­¤£¨¬µLªk±ÀÂË!");
+ vmsg("±z¦]Åv­­¤£¨¬!");
return FULLUPDATE;
}
+ if( fhdr->filemode & FILE_BID)
+ return do_bid(ent, fhdr, bp, direct, ptime);
+
setdirpath(path, direct, fhdr->filename);
- if (fhdr->recommend > 9 || fhdr->recommend < 0)
- /* ¼È®É©Êªº code ­ì¨Ó¦³­È¨ú®ø */
- fhdr->recommend = 0;
+
if (fhdr->recommend == 0 && strcmp(cuser.userid, fhdr->owner) == 0){
vmsg("ĵ§i! ¥»¤H¤£¯à±ÀÂ˲Ĥ@¦¸!");
@@ -1290,6 +1541,7 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
}
#endif
+
if (!getdata(b_lines - 2, 0, "±ÀÂË»y:", path, 40, DOECHO) ||
path == NULL ||
!getdata(b_lines - 1, 0, "½T©w­n±ÀÂË, ½Ð¥J²Ó¦Ò¼{(Y/N)?[n] ",
@@ -1302,18 +1554,7 @@ recommend(int ent, fileheader_t * fhdr, char *direct)
cuser.userid, path,
51 - strlen(cuser.userid) - strlen(path), " ", fromhost,
ptime->tm_mon + 1, ptime->tm_mday);
- lock_substitute_record(direct, fhdr, sizeof(*fhdr), ent, LOCK_EX);
- setdirpath(path, direct, fhdr->filename);
- log_file(path, buf);
- if (!(fhdr->recommend < 9))
- lock_substitute_record(direct, fhdr, sizeof(*fhdr), ent, LOCK_UN);
- else{
- fhdr->recommend++;
- passwd_update(usernum, &cuser);
- lock_substitute_record(direct, fhdr, sizeof(*fhdr), ent, LOCK_UN);
- substitute_check(fhdr);
- touchdircache(currbid);
- }
+ do_add_recommend(direct, fhdr, ent, buf);
lastrecommend = now;
return FULLUPDATE;
}
@@ -1660,7 +1901,8 @@ b_note_edit_bname(int bid)
} else {
if (!getdata(2, 0, "³]©w¦³®Ä´Á­­¤Ñ¡H(n/Y)", buf, 3, LCECHO)
|| buf[0] != 'n')
- fh->bupdate = gettime(3, fh->bupdate ? fh->bupdate : now);
+ fh->bupdate = gettime(3, fh->bupdate ? fh->bupdate : now,
+ "¦³®Ä¤é´Á¦Ü");
else
fh->bupdate = 0;
substitute_record(fn_board, fh, sizeof(boardheader_t), bid);
@@ -1703,7 +1945,6 @@ static int
b_post_note()
{
char buf[200], yn[3];
-
if (currmode & MODE_BOARD) {
setbfile(buf, currboard, FN_POST_NOTE);
if (more(buf, NA) == -1)
@@ -1713,6 +1954,17 @@ b_post_note()
vedit(buf, NA, NULL);
else
unlink(buf);
+
+
+ setbfile(buf, currboard, FN_POST_BID);
+ if (more(buf, NA) == -1)
+ more("etc/" FN_POST_BID, NA);
+ getdata(b_lines - 2, 0, "¬O§_­n¥Î¦Û­qÄv¼Ð¤å³¹ª`·N¨Æ¶µ?", yn, sizeof(yn), LCECHO);
+ if (yn[0] == 'y')
+ vedit(buf, NA, NULL);
+ else
+ unlink(buf);
+
return FULLUPDATE;
}
return 0;
@@ -2067,6 +2319,7 @@ struct onekey_t read_comms[] = {
{'y', reply_post},
{'z', b_man},
{Ctrl('P'), do_post},
+ {Ctrl('O'), do_post_openbid},
{Ctrl('W'), whereami},
{'\0', NULL}
};
diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c
index 40512e18..d7f4e0b7 100644
--- a/pttbbs/mbbsd/board.c
+++ b/pttbbs/mbbsd/board.c
@@ -230,16 +230,17 @@ brc_unread(const char *fname, int bnum, const int *blist)
return 0;
}
-#define BRD_NULL 0
-#define BRD_FAV 1
-#define BRD_BOARD 2
+#define BRD_UNREAD 1
+#define BRD_FAV 2
#define BRD_LINE 4
-#define BRD_FOLDER 8
-#define BRD_TAG 16
-#define BRD_UNREAD 32
+#define BRD_TAG 8
+#define BRD_GRP_HEADER 16
+
+#define MAX_GRP_BRD 16
+#define MAX_GRP
#define FAVNB ".favnb"
-//#define FAV3 ".fav3"
+#define FAV3 ".fav3"
#define B_TOTAL(bptr) (SHM->total[(bptr)->bid - 1])
#define B_LASTPOSTTIME(bptr) (SHM->lastposttime[(bptr)->bid - 1])
@@ -249,8 +250,25 @@ typedef struct {
unsigned char myattr;
} __attribute__ ((packed)) boardstat_t;
+typedef struct {
+ short bid;
+ char attr;
+ time_t lastvisit;
+} fav_board_t;
+
+typedef struct {
+#ifdef MEM_CHECK
+ int memcheck;
+#endif
+ short nDatas;
+ short nAllocs;
+ char nLines;
+ fav_board_t b[0];
+} fav_t;
+
static boardstat_t *nbrd = NULL;
-static char choose_board_depth = 0;
+char favchange = 0, choose_board_depth = 0;
+fav_t *fav;
static short brdnum;
static char yank_flag = 1;
@@ -278,7 +296,7 @@ void updatenewfav(int mode)
if(brd[i] == BRD_NEW){
if(bcache[i].brdname[0] && Ben_Perm(&bcache[i])){ // check the permission if the board exsits
if(mode)
- fav_add_board(i + 1, -1);
+ setfav(i + 1, BRD_FAV, 1, 0);
brd[i] = BRD_OLD;
}
}
@@ -291,7 +309,7 @@ void updatenewfav(int mode)
for(i-- ; i < numboards; i++){
if(bcache[i].brdname[0] && Ben_Perm(&bcache[i])){
if(mode)
- fav_add_board(i + 1, -1);
+ setfav(i + 1, BRD_FAV, 1, 0);
brd[i] = BRD_OLD;
}
else
@@ -325,18 +343,63 @@ inline int validboard(int bid){
return bcache[bid].brdname[0];
}
+void freefav(fav_t *fav){
+ free(fav->b);
+ free(fav);
+ fav = NULL;
+}
+
void load_brdbuf(void)
{
static char firsttime = 1;
int fd;
char fname[80];
- setuserfile(fname, FAV4);
+ setuserfile(fname, FAV3);
if( (fd = open(fname, O_RDONLY)) == -1 ){
- fav_v3_to_v4();
+ // not found.
+ int i;
+ char favrec;
+ fav = (fav_t *)malloc(sizeof(fav_t) +
+ sizeof(fav_board_t) * 16);
+ fav->nDatas = 0;
+ fav->nAllocs = 16;
+ fav->nLines = 0;
+ favchange = 1;
+
+ setuserfile(fname, ".fav2");
+
+ if( (fd = open(fname, O_RDONLY)) != -1 ){
+ for( i = 1; i <= numboards; i++){
+ if(read(fd, &favrec, sizeof(char)) < 0)
+ break;
+ if( (favrec & BRD_FAV) )
+ setfav(i, BRD_FAV, 1, 0);
+ }
+ close(fd);
+ }
+ }
+ else{
+ short nDatas, i;
+ char nLines;
+ read(fd, &nDatas, sizeof(nDatas));
+ read(fd, &nLines, sizeof(nLines));
+ fav = (fav_t *)malloc(sizeof(fav_t) +
+ sizeof(fav_board_t) * (nDatas + 16));
+ fav->nDatas = nDatas;
+ fav->nAllocs = nDatas + 16;
+ fav->nLines = nLines;
+ read(fd, fav->b, sizeof(fav_board_t) * fav->nDatas);
+ for(i = 0; i < fav->nDatas; i++){
+ if( !(fav->b[i].attr & BRD_LINE) && !bcache[fav->b[i].bid - 1].brdname[0])
+ fav->b[i].attr ^= BRD_FAV;
+ }
+ close(fd);
}
- fav_load();
updatenewfav(1);
+#ifdef MEM_CHECK
+ fav->memcheck = MEM_CHECK;
+#endif
firsttime = 0;
}
@@ -349,8 +412,40 @@ init_brdbuf()
void
save_brdbuf(void)
{
- fav_save();
- fav_free();
+ int r, w, fd;
+ char fname[80];
+ if( !fav )
+ return;
+
+ if( !favchange )
+ return;
+
+#ifdef MEM_CHECK
+ if( fav->memcheck != MEM_CHECK )
+ return;
+#endif
+
+ fav->nLines = 0;
+ for( r = w = 0 ; r < fav->nDatas ; ++r ){
+ if( ( fav->b[r].attr & BRD_LINE ) ||
+ (fav->b[r].attr & BRD_FAV && bcache[fav->b[r].bid - 1].brdname[0])){
+ if(fav->b[r].attr & BRD_LINE)
+ fav->nLines--;
+ fav->b[w++] = fav->b[r];
+ }
+ }
+ fav->nDatas = w;
+ setuserfile(fname, FAV3);
+ if( (fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC, 0600)) != -1 ){
+ int i;
+ write(fd, &fav->nDatas, sizeof(short));
+ write(fd, &fav->nLines, sizeof(char));
+ for(i = 0; i < fav->nDatas; i++)
+ if(fav->b[i].attr & BRD_FAV)
+ write(fd, &fav->b[i], sizeof(fav_board_t));
+ close(fd);
+ }
+ freefav(fav);
}
int
@@ -480,11 +575,9 @@ addnewbrdstat(int n, int state)
//ptr->lastposttime = &(SHM->lastposttime[n]);
ptr->bid = n + 1;
- ptr->myattr = state;
- if ((B_BH(ptr)->brdattr & BRD_HIDE) && state == BRD_BOARD)
+ ptr->myattr = getfavattr(ptr->bid);
+ if ((B_BH(ptr)->brdattr & BRD_HIDE) && state == 1)
B_BH(ptr)->brdattr |= BRD_POSTMASK;
- if (yank_flag != 0)
- ptr->myattr &= ~BRD_FAV;
check_newpost(ptr);
return ptr;
}
@@ -496,6 +589,35 @@ cmpboardfriends(const void *brd, const void *tmp)
(B_BH((boardstat_t*)brd)->nuser));
}
+static int
+favcmpboardname(const void *brd, const void *tmp)
+{
+ int b1 = ((fav_board_t *)brd)->bid;
+ int b2 = ((fav_board_t *)tmp)->bid;
+
+ if( b1 <= 0 || b2 <= 0 ) // ¤À¹j½u
+ return 1;
+
+ return strcasecmp(bcache[b1 - 1].brdname, bcache[b2 - 1].brdname);
+}
+
+static int
+favcmpboardclass(const void *brd, const void *tmp)
+{
+ int b1 = ((fav_board_t *)brd)->bid;
+ int b2 = ((fav_board_t *)tmp)->bid;
+ int cmp;
+
+ if( b1 <= 0 || b2 <= 0 ) // ¤À¹j½u
+ return 1;
+
+ cmp = strncasecmp(bcache[b1 - 1].title, bcache[b2 - 1].title, 4);
+ if( cmp )
+ return cmp;
+ else
+ return strcasecmp(bcache[b1 - 1].brdname, bcache[b2 - 1].brdname);
+}
+
static void
load_boards(char *key)
{
@@ -517,34 +639,18 @@ load_boards(char *key)
}
if (class_bid <= 0) {
if( yank_flag == 0 ){ // fav mode
- fav_t *fav = get_current_fav();
-
nbrd = (boardstat_t *)malloc(sizeof(boardstat_t) * fav->nDatas);
for( i = 0 ; i < fav->nAllocs; ++i ){
- int state;
- if (!(fav->favh[i].attr & BRD_FAV))
- continue;
-
- if (get_item_type(&fav->favh[i]) == FAVT_LINE && !key[0])
- state = BRD_LINE;
- else if (get_item_type(&fav->favh[i]) == FAVT_FOLDER && !key[0])
- state = BRD_FOLDER;
- else{
- bptr = &bcache[ fav_getid(&fav->favh[i]) - 1];
- if( (state = Ben_Perm(bptr)) && (!key[0] || strcasestr(bptr->title, key)))
- state = BRD_BOARD;
- else
- continue;
- if (is_set_attr(&fav->favh[i], FAVH_UNREAD))
- state |= BRD_UNREAD;
+ if( fav->b[i].attr & BRD_FAV ){
+ if( fav->b[i].attr & BRD_LINE && !key[0])
+ addnewbrdstat(fav->b[i].bid - 1, BRD_FAV | BRD_LINE);
+ else{
+ bptr = &bcache[ fav->b[i].bid - 1 ];
+ if( (state = Ben_Perm(bptr)) && (!key[0] || strcasestr(bptr->title, key)))
+ addnewbrdstat(fav->b[i].bid - 1, state);
+ }
}
-
- if (is_set_attr(&fav->favh[i], FAVH_TAG))
- state |= BRD_TAG;
- addnewbrdstat(fav_getid(&fav->favh[i]) - 1, BRD_FAV | state);
}
- if (fav->nDatas == 0)
- addnewbrdstat(0, 0);
byMALLOC = 0;
needREALLOC = (fav->nDatas != brdnum);
}
@@ -579,7 +685,7 @@ load_boards(char *key)
bptr = bptr->next[type]) {
n = (int)(bptr - bcache);
if (!((state = Ben_Perm(bptr)) || (currmode & MODE_MENU))
- || (yank_flag == 0 && !(getbrdattr(n) & BRD_FAV)) ||
+ || (yank_flag == 0 && !(getfavattr(n) & BRD_FAV)) ||
(key[0] && !strcasestr(bptr->title, key)))
continue;
addnewbrdstat(n, state);
@@ -684,7 +790,7 @@ show_brdlist(int head, int clsflag, int newflag)
move(1, 0);
outs(
" "
- "¢© ¢~¡X\033[33m¡´\n"
+ "¢© ùú¡X\033[33m¡´\n"
" ùá¡X \033[m "
"¢¨¢i\033[47m¡ó\033[40m¢i¢i¢©ùç\n"
" \033[44m ¡s¡s¡s¡s¡s¡s¡s¡s "
@@ -724,7 +830,7 @@ show_brdlist(int head, int clsflag, int newflag)
if (head < brdnum) {
ptr = &nbrd[head++];
if (ptr->myattr & BRD_LINE){
- prints("%5d %c %s------------ ------------------------------------------\033[m", head, ptr->myattr & BRD_TAG ? 'D' : ' ', ptr->myattr & BRD_FAV ? "" : "\033[1;30m");
+ prints("%5d %c ------------ ------------------------------------------", head, ptr->myattr & BRD_TAG ? 'D' : ' ');
continue;
}
else if (ptr->myattr & BRD_FOLDER){
@@ -745,7 +851,7 @@ show_brdlist(int head, int clsflag, int newflag)
(B_BH(ptr)->brdattr & BRD_POSTMASK) ? ')' : '-',
(ptr->myattr & BRD_TAG) ? "D " :
(B_BH(ptr)->brdattr & BRD_GROUPBOARD) ? " " :
- unread[ptr->myattr & BRD_UNREAD ? 1 : 0]);
+ unread[ptr->myattr & BRD_UNREAD]);
} else {
if (newflag) {
if ((B_BH(ptr)->brdattr & BRD_GROUPBOARD))
@@ -802,7 +908,7 @@ static char *choosebrdhelp[] = {
"(r)(¡÷)(Rtn) ¶i¤J¦h¥\\¯à¾\\Ū¿ï³æ",
"(q)(¡ö) ¦^¨ì¥D¿ï³æ",
"(y/Z) §Úªº³Ì·R,­q¾\\¬ÝªO,©Ò¦³¬ÝªO/­q¾\\·s¶}¬ÝªO",
- "(L) ¥[¤J¤À¹j½u¦Ü§Úªº³Ì·R",
+ "(L/K) ¥[¤J¤À¹j½u¦Ü§Úªº³Ì·R / ³Æ¥÷,²M²z§Úªº³Ì·R",
"(v/V) ³q³q¬Ý§¹/¥þ³¡¥¼Åª",
"(S) «ö·Ó¦r¥À/¤ÀÃþ±Æ§Ç",
"(t/^T/^A/^D) ¼Ð°O¬ÝªO/¨ú®ø©Ò¦³¼Ð°O/ ±N¤w¼Ð°OªÌ¥[¤J/²¾¥X§Úªº³Ì·R",
@@ -835,7 +941,7 @@ choose_board(int newflag)
char keyword[13] = "";
setutmpmode(newflag ? READNEW : READBRD);
- if( get_current_fav() == NULL )
+ if( fav == NULL )
load_brdbuf();
++choose_board_depth;
brdnum = 0;
@@ -889,12 +995,9 @@ choose_board(int newflag)
if (ptr->myattr & BRD_UNREAD)
break;
num++;
- fav_cursor_down();
}
- if (num >= brdnum){
+ if (num >= brdnum)
num = tmp;
- fav_cursor_set(num);
- }
}
head = (num / p_lines) * p_lines;
show_brdlist(head, 1, newflag);
@@ -973,7 +1076,7 @@ choose_board(int newflag)
break;
case 't':
ptr = &nbrd[num];
- fav_tag_current(2);
+ setfav(ptr->bid, BRD_TAG, 2, 0);
ptr->myattr ^= BRD_TAG;
head = 9999;
case KEY_DOWN:
@@ -1029,12 +1132,15 @@ choose_board(int newflag)
"±Æ§Ç¤è¦¡ (1)«ö·ÓªO¦W±Æ§Ç (2)«ö·ÓÃþ§O±Æ§Ç ==> [0]¨ú®ø ",
input, sizeof(input), DOECHO);
if( input[0] == '1' )
- fav_sort_by_name();
+ qsort(&fav->b, fav->nDatas, sizeof(fav_board_t),
+ favcmpboardname);
else if( input[0] == '2' )
- fav_sort_by_class();
+ qsort(&fav->b, fav->nDatas, sizeof(fav_board_t),
+ favcmpboardclass);
}
else
cuser.uflag ^= BRDSORT_FLAG;
+ favchange = 1;
brdnum = -1;
break;
case 'y':
@@ -1042,30 +1148,45 @@ choose_board(int newflag)
brdnum = -1;
break;
case Ctrl('D'):
- fav_remove_all_tagged_item();
+ for (tmp = 0; tmp < fav->nDatas; tmp++) {
+ if (fav->b[tmp].attr & BRD_TAG) {
+ favchange = 1;
+ fav->b[tmp].attr &= ~BRD_FAV;
+ fav->b[tmp].attr &= ~BRD_TAG;
+ }
+ }
brdnum = -1;
break;
case Ctrl('A'):
- fav_add_all_tagged_item();
+ for (tmp = 0; tmp < fav->nDatas; tmp++) {
+ if (fav->b[tmp].attr & BRD_TAG) {
+ favchange = 1;
+ fav->b[tmp].attr |= BRD_FAV;
+ fav->b[tmp].attr &= ~BRD_TAG;
+ }
+ }
brdnum = -1;
break;
case Ctrl('T'):
- fav_remove_all_tag();
+ for (tmp = 0; tmp < fav->nDatas; tmp++)
+ fav->b[tmp].attr &= ~BRD_TAG;
+ favchange = 1;
brdnum = -1;
break;
case Ctrl('P'):
if (class_bid != 0 &&
(HAS_PERM(PERM_SYSOP) || (currmode & MODE_MENU))) {
- for (tmp = 0; tmp < brdnum; tmp++) {
- short bid = nbrd[tmp].bid;
+ for (tmp = 0; tmp < fav->nDatas; tmp++) {
+ short bid = fav->b[tmp].bid;
boardheader_t *bh = &bcache[ bid - 1 ];
/*
if (!(fav->b[tmp].attr & BRD_TAG) || bh->gid == class_bid)
continue;
*/
- if( !(nbrd[tmp].myattr & BRD_TAG) )
+ if( !(fav->b[tmp].attr & BRD_TAG) )
continue;
- nbrd[tmp].myattr &= ~BRD_TAG;
+ favchange = 1;
+ fav->b[tmp].attr &= ~BRD_TAG;
if (bh->gid != class_bid) {
bh->gid = class_bid;
substitute_record(FN_BOARD, bh,
@@ -1079,57 +1200,37 @@ choose_board(int newflag)
break;
case 'L':
if (HAS_PERM(PERM_BASIC)) {
- if(fav_add_line(brdnum - 1) < 0){
+ if(fav->nDatas > FAVMAX || fav->nLines <= -127){
vmsg("§Aªº³Ì·R¤Ó¦h¤F°Õ ¯uªá¤ß");
break;
}
- set_attr(get_current_entry(), BRD_FAV, 1);
+ setfav(0, BRD_FAV | BRD_LINE, 1, 0);
+ nbrd[brdnum].bid = fav->nLines;
+ movefav(brdnum, num);
brdnum = -1;
head = 9999;
}
break;
case 'm':
if (HAS_PERM(PERM_BASIC)) {
- if (yank_flag == 0) {
- if (num > brdnum)
- break;
- if (nbrd[num].myattr & BRD_FAV && getans("§A½T©w§R°£¶Ü? [N/y]") == 'y'){
- set_attr(get_current_entry(), BRD_FAV, 2);
- nbrd[num].myattr ^= BRD_FAV;
- }
+ if(nbrd[num].myattr & BRD_LINE){
+ delfavline(nbrd[num].bid, num);
+ brdnum = -1;
+ }
+ else if(!(nbrd[num].myattr & BRD_FAV) && (fav->nDatas > FAVMAX)){
+ vmsg("§Aªº³Ì·R¤Ó¦h¤F°Õ ¯uªá¤ß");
+ break;
}
else{
- if (nbrd[num].myattr & BRD_FAV){
- fav_remove_current();
- }
- else{
- if (fav_add_board(nbrd[num].bid, -1) < 0)
- vmsg("§Aªº³Ì·R¤Ó¦h¤F°Õ ¯uªá¤ß");
- }
+ setfav(nbrd[num].bid, BRD_FAV, 2, 0);
nbrd[num].myattr ^= BRD_FAV;
}
- brdnum = -1;
head = 9999;
}
break;
case 'M':
- if (HAS_PERM(PERM_BASIC)){
- if (class_bid == 0 && yank_flag == 0){
- imovefav(num);
- brdnum = -1;
- head = 9999;
- }
- }
- break;
- case 'g':
- if (HAS_PERM(PERM_BASIC)) {
- if (fav_max_folder_level()){
- vmsg("¥Ø¿ý¤w¹F³Ì¤j¼h¼Æ!!");
- break;
- }
- fav_type_t *ft = fav_add_folder(-1);
- fav_set_folder_title(ft, "·sªº¥Ø¿ý");
- brdnum = -1;
+ if (HAS_PERM(PERM_BASIC) && class_bid == 0 && yank_flag == 0){
+ imovefav(num);
head = 9999;
}
break;
@@ -1157,7 +1258,7 @@ choose_board(int newflag)
cleanup();
break;
case '2':
- setuserfile(fname, FAV4);
+ setuserfile(fname, FAV3);
sprintf(genbuf, "cp -f %s %s.bak", fname, fname);
system(genbuf);
break;
@@ -1171,15 +1272,17 @@ choose_board(int newflag)
close(fd);
sprintf(genbuf, "cp -f %s.bak %s", fname, fname);
system(genbuf);
- fav_free();
+ freefav(fav);
load_brdbuf();
+ favchange = 1;
break;
}
brdnum = -1;
}
break;
case 'z':
- //vmsg("¼K¼K ³o­Ó¥\\¯à¤w¸g³Q§Úªº³Ì·R¨ú¥N±¼¤F³á!");
+ if (HAS_PERM(PERM_BASIC))
+ vmsg("¼K¼K ³o­Ó¥\\¯à¤w¸g³Q§Úªº³Ì·R¨ú¥N±¼¤F³á!");
break;
case 'Z':
cuser.uflag2 ^= FAVNEW_FLAG;
@@ -1219,10 +1322,10 @@ choose_board(int newflag)
if (ch == 'v') {
ptr->myattr &= ~BRD_UNREAD;
brc_list[0] = now;
- setbrdtime(ptr->bid, now);
+ setfav(ptr->bid, 0, 0, now);
} else {
brc_list[0] = 1;
- setbrdtime(ptr->bid, 1);
+ setfav(ptr->bid, 0, 0, 1);
ptr->myattr |= BRD_UNREAD;
}
brc_num = brc_changed = 1;
@@ -1284,7 +1387,7 @@ choose_board(int newflag)
char buf[STRLEN];
ptr = &nbrd[num];
- if (ptr->myattr & BRD_LINE)
+ if(ptr->myattr & BRD_LINE)
break;
else if (ptr->myattr & BRD_FOLDER){
int t = num;
@@ -1309,7 +1412,7 @@ choose_board(int newflag)
head = tmp - t_lines / 2;
getkeep(buf, head > 1 ? head : 1, tmp + 1);
}
- board_visit_time = getbrdtime(ptr->bid);
+ board_visit_time = getfavtime(ptr->bid);
Read();
check_newpost(ptr);
head = -1;
@@ -1330,7 +1433,6 @@ choose_board(int newflag)
currmodetmp = currmode;
tmp1 = num;
num = 0;
- fav_cursor_set(num);
if (!(B_BH(ptr)->brdattr & BRD_TOP))
class_bid = ptr->bid;
else
@@ -1348,16 +1450,15 @@ choose_board(int newflag)
setutmpbid(ptr->bid);
free(nbrd);
nbrd = NULL;
- if (yank_flag == 0 ) {
- yank_flag = 1;
- choose_board(0);
- yank_flag = 0;
- }
- else
- choose_board(0);
+ if (yank_flag == 0 ) {
+ yank_flag = 1;
+ choose_board(0);
+ yank_flag = 0;
+ }
+ else
+ choose_board(0);
currmode = currmodetmp; /* Â÷¶}ªOªO«á´N§âÅv­­®³±¼³á */
num = tmp1;
- fav_cursor_set(num);
class_bid = bidtmp;
setutmpbid(tmp);
brdnum = -1;
@@ -1401,30 +1502,3 @@ New()
currstat = stat0;
return 0;
}
-
-/*
- * int v_favorite(){ char fname[256]; char inbuf[2048]; FILE* fp; int nGroup;
- * char* strtmp;
- *
- * setuserfile(fname,str_favorite);
- *
- * if (!(fp=fopen(fname,"r"))) return -1; move(0,0); clrtobot();
- * fgets(inbuf,sizeof(inbuf),fp); nGroup=atoi(inbuf);
- *
- * currutmp->nGroup=0; currutmp->ninRoot=0;
- *
- * while(nGroup!=currutmp->nGroup+1){ fgets(inbuf,sizeof(inbuf),fp);
- * prints("%s\n",strtmp=strtok(inbuf," \n"));
- * strcpy(currutmp->gfavorite[currutmp->nGroup++],strtmp);
- * while((strtmp=strtok(NULL, " \n"))){ prints(" %s
- * %d\n",strtmp,getbnum(strtmp)); } currutmp->nGroup++; }
- * prints("+++%d+++\n",currutmp->nGroup);
- *
- * fgets(inbuf,sizeof(inbuf),fp);
- *
- * for(strtmp=strtok(inbuf, " \n");strtmp;strtmp=strtok(NULL, " \n")){ if
- * (strtmp[0]!='#') prints("*** %s %d\n",strtmp, getbnum(strtmp)); else
- * prints("*** %s %d\n",strtmp+1, -1); currutmp->ninRoot++; }
- *
- * fclose(fp); pressanykey(); return 0; }
- */
diff --git a/pttbbs/mbbsd/cal.c b/pttbbs/mbbsd/cal.c
index fceaf2b1..37123a01 100644
--- a/pttbbs/mbbsd/cal.c
+++ b/pttbbs/mbbsd/cal.c
@@ -409,11 +409,11 @@ p_give()
int
p_sysinfo(void)
{
- char buf[128], *cpuloadstr;
+ char *cpuloadstr;
int load;
extern char *compile_time;
- load = cpuload(buf);
+ load = cpuload(NULL);
cpuloadstr = (load < 5 ? "¨}¦n" : (load < 20 ? "©|¥i" : "¹L­«"));
clear();
diff --git a/pttbbs/mbbsd/chat.c b/pttbbs/mbbsd/chat.c
index d7ea2f53..11988f9f 100644
--- a/pttbbs/mbbsd/chat.c
+++ b/pttbbs/mbbsd/chat.c
@@ -57,10 +57,8 @@ chat_send(int fd, char *buf)
return (send(fd, genbuf, len, 0) == len);
}
-static char chatroom[IDLEN];/* Chat-Room Name */
-
static int
-chat_recv(int fd, char *chatid)
+chat_recv(int fd, char chatroom[IDLEN], char *chatid)
{
static char buf[128];
static int bufstart = 0;
@@ -299,6 +297,7 @@ static int chatid_len = 10;
int
t_chat()
{
+ char chatroom[IDLEN];/* Chat-Room Name */
char inbuf[80], chatid[20], lastcmd[MAXLASTCMD][80], *ptr = "";
struct sockaddr_in sin;
struct hostent *h;
@@ -415,7 +414,7 @@ t_chat()
printchatline("¡» ¾´¡I¶l®t¤S¨Ó¤F...");
}
if (ch == I_OTHERDATA) {/* incoming */
- if (chat_recv(cfd, chatid) == -1) {
+ if (chat_recv(cfd, chatroom, chatid) == -1) {
chatting = chat_send(cfd, "/b");
break;
}
diff --git a/pttbbs/mbbsd/chc.c b/pttbbs/mbbsd/chc.c
index fbd716a1..1fad931a 100644
--- a/pttbbs/mbbsd/chc.c
+++ b/pttbbs/mbbsd/chc.c
@@ -318,12 +318,13 @@ chc_log_poem(void)
struct dirent **namelist;
int n;
+ // TODO use readdir(), don't use lots of memory
n = scandir(BBSHOME"/etc/chess", &namelist, chc_filter, alphasort);
if (n < 0)
perror("scandir");
else {
char buf[80];
- FILE *fp;
+ FILE *fp; // XXX shadow global fp
sprintf(buf, BBSHOME"/etc/chess/%s", namelist[rand() % n]->d_name);
if ((fp = fopen(buf, "r")) == NULL)
return -1;
@@ -829,9 +830,9 @@ chc_init_play_func(chcusr_t *user1, chcusr_t *user2, play_func_t play_func[2])
static void
chc_watch_request(int signo)
{
+ chc_act_list *tmp;
if (!(currstat & CHC))
return;
- chc_act_list *tmp;
for(tmp = act_list; tmp->next != NULL; tmp = tmp->next);
tmp->next = (chc_act_list *)malloc(sizeof(chc_act_list));
tmp = tmp->next;
@@ -1014,6 +1015,9 @@ chc_watch(void)
if (uin->uid == currutmp->uid || uin->mode != CHC)
return -1;
+ if (getans("¬O§_¶i¦æÆ[´Ñ? [N/y]") != 'y')
+ return 0;
+
if ((sock = make_connection_to_somebody(uin, 10)) < 0) {
vmsg("µLªk«Ø¥ß³s½u");
return -1;
diff --git a/pttbbs/mbbsd/dice.c b/pttbbs/mbbsd/dice.c
index ade65799..8fb0a9f9 100644
--- a/pttbbs/mbbsd/dice.c
+++ b/pttbbs/mbbsd/dice.c
@@ -332,7 +332,7 @@ dice_main(void)
char input[10], data[256], ch;
dicedata_t table[256];
int bet[3], index, money = 0, i, ya = 0, j, total, sig = 0;
- FILE *winfp /* , *lostfp */ ;
+ FILE *winfp;
more(DICE_TXT, NA);
reload_money();
@@ -344,8 +344,7 @@ dice_main(void)
}
lockreturn0(DICE, LOCK_MULTI);
winfp = fopen(DICE_WIN, "a");
- /* lostfp = fopen(DICE_LOST,"a"); */
- if (!winfp /* || !lostfp */ )
+ if (!winfp)
return 0;
do {
@@ -433,7 +432,6 @@ dice_main(void)
if (i == 0) {
fclose(winfp);
- /* fclose(lostfp); */
unlockutmpmode();
return 0;
}
@@ -445,10 +443,6 @@ dice_main(void)
continue;
ya = bingo(flag, table[j].mybet);
if (ya == 0) {
- /*
- * sprintf(data, "%-15s ¿é¤F %-8d $", cuser.userid,
- * table[j].mymoney); fprintf(lostfp, "%s\n", data);
- */
continue;
}
demoney(table[j].mymoney * ya + table[j].mymoney);
@@ -482,7 +476,6 @@ dice_main(void)
input, 2, LCECHO);
} while (input[0] != 'n' && input[0] != 'N');
fclose(winfp);
- /* fclose(lostfp); */
unlockutmpmode();
return 0;
}
diff --git a/pttbbs/mbbsd/fav.c b/pttbbs/mbbsd/fav.c
deleted file mode 100644
index 52cb44b5..00000000
--- a/pttbbs/mbbsd/fav.c
+++ /dev/null
@@ -1,883 +0,0 @@
-#include "bbs.h"
-
-#ifdef MEM_CHECK
-static int memcheck;
-#endif
-
-/* the total number of items, every level. */
-static int fav_number;
-
-/* definition of fav stack, the top one is in use now. */
-static int fav_stack_num = 0;
-static fav_t *fav_stack[FAV_MAXDEPTH] = {0};
-
-/* current fav_type_t placement */
-static int fav_place;
-
-/* fav_tmp is for recordinge while copying, moving, etc. */
-static fav_t *fav_tmp;
-//static int fav_tmp_snum; /* the sequence number in favh in fav_t */
-
-
-inline static void free_fp(fav_type_t *ft);
-
-/* for casting */
-inline static fav_board_t *cast_board(fav_type_t *p){
- return (fav_board_t *)p->fp;
-}
-
-inline static fav_line_t *cast_line(fav_type_t *p){
- return (fav_line_t *)p->fp;
-}
-
-inline static fav_folder_t *cast_folder(fav_type_t *p){
- return (fav_folder_t *)p->fp;
-}
-/* --- */
-
-/* "current" means what at the position of the cursor */
-inline fav_t *get_current_fav(void){
- if (fav_stack_num == 0)
- return NULL;
- return fav_stack[fav_stack_num - 1];
-}
-
-inline static fav_t *get_fav_folder(fav_type_t *ft){
- return cast_folder(ft)->this_folder;
-}
-
-inline int get_item_type(fav_type_t *ft){
- return ft->type;
-}
-
-inline fav_type_t *get_current_entry(void){
- fav_t *fp = fav_stack[fav_stack_num - 1];
- if (fp->nDatas <= 0)
- return NULL;
- return &fp->favh[fav_place];
-}
-
-inline void fav_set_tmp_folder(fav_t *fp){
- fav_tmp = fp;
-}
-
-inline static fav_t *fav_get_tmp_fav(void){
- return fav_tmp;
-}
-/* --- */
-
-static void fav_decrease(fav_t *fp, fav_type_t *ft){
- switch (get_item_type(ft)){
- case FAVT_BOARD:
- fp->nBoards--;
- break;
- case FAVT_LINE:
- break;
- case FAVT_FOLDER:
- break;
- }
- fav_number--;
- fp->nDatas--;
-}
-/* --- */
-
-static void fav_increase(fav_t *fp, fav_type_t *ft)
-{
- switch (get_item_type(ft)){
- case FAVT_BOARD:
- fp->nBoards++;
- break;
- case FAVT_LINE:
- fp->nLines++;
- break;
- case FAVT_FOLDER:
- fp->nFolders++;
- break;
- }
- fav_number++;
- fp->nDatas++;
-}
-/* --- */
-
-inline static int get_folder_num(fav_t *fp) {
- return fp->nFolders;
-}
-
-inline static int get_line_num(fav_t *fp) {
- return fp->nLines;
-}
-
-/* bool:
- * 0: unset 1: set 2: opposite */
-inline void set_attr(fav_type_t *ft, int bit, int bool){
- if (bool == 2)
- bool = !(ft->attr & bit);
- if (bool)
- ft->attr |= bit;
- else
- ft->attr &= ~bit;
-}
-
-inline int is_set_attr(fav_type_t *ft, int bit){
- return ft->attr & bit;
-}
-/* --- */
-
-char *get_item_title(fav_type_t *ft)
-{
- switch (get_item_type(ft)){
- case FAVT_BOARD:
- return bcache[cast_board(ft)->bid - 1].brdname;
- case FAVT_FOLDER:
- return cast_folder(ft)->title;
- case FAVT_LINE:
- return "----";
- }
- return NULL;
-}
-
-static char *get_item_class(fav_type_t *ft)
-{
- switch (get_item_type(ft)){
- case FAVT_BOARD:
- return bcache[cast_board(ft)->bid - 1].title;
- case FAVT_FOLDER:
- return "¥Ø¿ý";
- case FAVT_LINE:
- return "----";
- }
- return NULL;
-}
-
-#ifdef MEM_CHECK
-inline void fav_set_memcheck(int n) {
- memcheck = n;
-}
-
-inline int fav_memcheck(void) {
- return memcheck;
-}
-#endif
-/* ---*/
-
-static int get_type_size(int type)
-{
- switch (type){
- case FAVT_BOARD:
- return sizeof(fav_board_t);
- case FAVT_FOLDER:
- return sizeof(fav_folder_t);
- case FAVT_LINE:
- return sizeof(fav_line_t);
- }
- return 0;
-}
-
-inline static void* fav_malloc(int size){
- void *p = (void *)malloc(size);
- memset(p, 0, size);
- return p;
-}
-
-/* allocate the header(fav_type_t) and item it self. */
-static fav_type_t *fav_item_allocate(int type)
-{
- int size = 0;
- fav_type_t *ft = (fav_type_t *)fav_malloc(sizeof(fav_type_t));
-
- size = get_type_size(type);
- if (size) {
- ft->fp = fav_malloc(size);
- ft->type = type;
- }
- return ft;
-}
-
-inline static fav_t *get_fav_root(void){
- return fav_stack[0];
-}
-
-/* return: the exact number after cleaning
- * reset the line number, board number, folder number, and total number (number)
- */
-static void rebuild_fav(fav_t *fp)
-{
- int i, bid;
- fav_number = 0;
- fp->nDatas = fp->nLines = fp->nBoards = fp->nFolders = 0;
- for (i = 0; i < fp->nAllocs; i++){
- if (!is_set_attr(&fp->favh[i], FAVH_FAV))
- continue;
- switch (get_item_type(&fp->favh[i])){
- case FAVT_BOARD:
- bid = cast_board(&fp->favh[i])->bid;
- if (!validboard(bid - 1))
- continue;
- break;
- case FAVT_LINE:
- break;
- case FAVT_FOLDER:
- rebuild_fav(get_fav_folder(fp->favh[i].fp));
- break;
- default:
- continue;
- }
- fav_increase(fp, &fp->favh[i]);
- }
-}
-
-inline void cleanup(void)
-{
- rebuild_fav(get_fav_root());
-}
-
-/* sort the fav */
-static int favcmp_by_name(const void *a, const void *b)
-{
- return strcasecmp(get_item_title((fav_type_t *)a), get_item_title((fav_type_t *)b));
-}
-
-void fav_sort_by_name(void)
-{
- rebuild_fav(get_current_fav());
- qsort(get_current_fav(), get_current_fav()->nDatas, sizeof(fav_type_t), favcmp_by_name);
-}
-
-static int favcmp_by_class(const void *a, const void *b)
-{
- fav_type_t *f1, *f2;
- int cmp;
-
- f1 = (fav_type_t *)a;
- f2 = (fav_type_t *)b;
- if (get_item_type(f1) == FAVT_FOLDER || get_item_type(f2) == FAVT_FOLDER)
- return -1;
- if (get_item_type(f1) == FAVT_LINE || get_item_type(f2) == FAVT_LINE)
- return 1;
-
- cmp = strncasecmp(get_item_class(f1), get_item_class(f2), 4);
- if (cmp)
- return cmp;
- return strcasecmp(get_item_title(f1), get_item_title(f1));
-}
-
-void fav_sort_by_class(void)
-{
- rebuild_fav(get_current_fav());
- qsort(get_current_fav(), get_current_fav()->nDatas, sizeof(fav_type_t), favcmp_by_class);
-}
-/* --- */
-
-inline static void
-fav_item_copy(fav_type_t *target, const fav_type_t *source){
- target->type = source->type;
- target->attr = source->attr;
- target->fp = source->fp;
-}
-
-/*
- * The following is the movement operations in the user interface.
- */
-inline static int fav_stack_full(void){
- return fav_stack_num >= FAV_MAXDEPTH;
-}
-
-inline int fav_max_folder_level(void){
- return fav_stack_full();
-}
-
-inline static int fav_stack_push_fav(fav_t *fp){
- if (fav_stack_full())
- return -1;
- fav_stack[fav_stack_num++] = fp;
- fav_place = 0;
- return 0;
-}
-
-inline static int fav_stack_push(fav_type_t *ft){
-// if (ft->type != FAVT_FOLDER)
-// return -1;
- return fav_stack_push_fav(get_fav_folder(ft));
-}
-
-inline static void fav_stack_pop(void){
- fav_stack_num--;
-}
-
-void fav_folder_in(void)
-{
- fav_type_t *tmp = get_current_entry();
- if (get_item_type(tmp) == FAVT_FOLDER){
- fav_stack_push(tmp);
- }
-}
-
-void fav_folder_out(void)
-{
- fav_stack_pop();
-}
-
-void fav_cursor_up(void)
-{
- fav_t *ft = get_current_fav();
- do{
- if (fav_place == 0)
- fav_place = ft->nAllocs - 1;
- else
- fav_place--;
- }while(!(ft->favh[fav_place].attr & FAVH_FAV));
-}
-
-void fav_cursor_down(void)
-{
- fav_t *ft = get_current_fav();
- do{
- if (fav_place == ft->nAllocs - 1)
- fav_place = 0;
- else
- fav_place++;
- }while(!(ft->favh[fav_place].attr & FAVH_FAV));
-}
-
-void fav_cursor_up_step(int step)
-{
- int i;
- for(i = 0; i < step; i++){
- if (fav_place <= 0)
- break;
- fav_cursor_up();
- }
-}
-
-void fav_cursor_down_step(int step)
-{
- int i;
- for(i = 0; i < step; i++){
- if (fav_place >= get_current_fav()->nAllocs - 1)
- break;
- fav_cursor_down();
- }
-}
-
-/* from up to down */
-void fav_cursor_set(int where)
-{
- fav_type_t *ft = get_current_entry();
- fav_place = 0;
- if (ft == NULL || ft->fp == NULL)
- return;
- while(!get_current_entry()->attr & FAVH_FAV)
- fav_cursor_down();
- fav_cursor_down_step(where);
-}
-/* --- */
-
-/* load from the rec file */
-static void read_favrec(int fd, fav_t *fp)
-{
- int i;
- fp->nDatas = fp->nBoards + fp->nLines + fp->nFolders;
- read(fd, &fp->nDatas, sizeof(fp->nDatas));
- read(fd, &fp->nBoards, sizeof(fp->nBoards));
- read(fd, &fp->nLines, sizeof(fp->nLines));
- read(fd, &fp->nFolders, sizeof(fp->nFolders));
- fp->nAllocs = fp->nDatas + FAV_PRE_ALLOC;
- fp->favh = (fav_type_t *)fav_malloc(sizeof(fav_type_t) * fp->nAllocs);
-
- for(i = 0; i < fp->nDatas; i++){
- read(fd, &fp->favh[i].type, sizeof(fp->favh[i].type));
- read(fd, &fp->favh[i].attr, sizeof(fp->favh[i].attr));
- fp->favh[i].fp = (void *)fav_malloc(get_type_size(fp->favh[i].type));
- read(fd, fp->favh[i].fp, get_type_size(fp->favh[i].type));
- }
-
- for(i = 0; i < fp->nDatas; i++){
- if (fp->favh[i].type == FAVT_FOLDER){
- fav_t *p = get_fav_folder(&fp->favh[i]);
- p = (fav_t *)fav_malloc(sizeof(fav_t));
- read_favrec(fd, p);
- }
- }
-}
-
-int fav_load(void)
-{
- int fd;
- char buf[128];
- fav_t *fp;
- if (fav_stack_num > 0)
- return -1;
- setuserfile(buf, FAV4);
- fd = open(buf, O_RDONLY);
- if (fd < 0){
- return -1;
- }
- fp = (fav_t *)fav_malloc(sizeof(fav_t));
- read_favrec(fd, fp);
- fav_stack_push_fav(fp);
- close(fd);
- fav_set_memcheck(MEM_CHECK);
- return 0;
-}
-/* --- */
-
-/* write to the rec file */
-static void write_favrec(int fd, fav_t *fp)
-{
- int i;
- if (fp == NULL)
- return;
- fp->nDatas = fp->nBoards + fp->nLines + fp->nFolders;
- write(fd, &fp->nDatas, sizeof(fp->nDatas));
- write(fd, &fp->nBoards, sizeof(fp->nBoards));
- write(fd, &fp->nLines, sizeof(fp->nLines));
- write(fd, &fp->nFolders, sizeof(fp->nFolders));
-
- for(i = 0; i < fp->nDatas; i++){
- write(fd, &fp->favh[i].type, sizeof(fp->favh[i].type));
- write(fd, &fp->favh[i].attr, sizeof(fp->favh[i].attr));
- write(fd, fp->favh[i].fp, get_type_size(fp->favh[i].type));
- }
-
- for(i = 0; i < fp->nDatas; i++){
- if ((fp->favh[i].attr & FAVH_FAV) && (fp->favh[i].type == FAVT_FOLDER))
- write_favrec(fd, get_fav_folder(&fp->favh[i]));
- }
-}
-
-int fav_save(void)
-{
- int fd;
- char buf[128], buf2[128];
-#ifdef MEM_CHECK
- if (fav_memcheck() != MEM_CHECK)
- return -1;
-#endif
- fav_t *fp = get_fav_root();
- if (fp == NULL)
- return -1;
- cleanup();
- setuserfile(buf, FAV4".tmp");
- setuserfile(buf2, FAV4);
- fd = open(buf, O_CREAT| O_TRUNC | O_WRONLY, 0600);
- if (fd < 0)
- return -1;
- write_favrec(fd, fp);
- close(fd);
- Rename(buf, buf2);
- return 0;
-}
-/* --- */
-
-/* It didn't need to remove it self, just remove all the attributes.
- * It'll be remove when it save to the record file. */
-static void fav_free_item(fav_type_t *ft)
-{
- if (ft->fp)
- free_fp(ft->fp);
- set_attr(ft, 0xFFFF, FALSE);
-// ft = NULL;
-}
-
-static int fav_remove(fav_t *fp, fav_type_t *ft)
-{
- fav_free_item(ft);
- fav_decrease(fp, ft);
- return 0;
-}
-
-/* free the mem of whole fav tree */
-static void fav_free_branch(fav_t *fp)
-{
- int i;
- fav_type_t *ft;
- if (fp == NULL)
- return;
- for(i = 0; i < fp->nAllocs; i++){
- ft = &fp->favh[i];
- if (get_item_type(ft) & FAVT_FOLDER)
- fav_free_branch(get_fav_folder(ft));
- fav_remove(fp, ft);
- }
- free(fp);
- fp = NULL;
-}
-
-inline static void free_fp(fav_type_t *ft)
-{
- if (get_item_type(ft) == FAVT_FOLDER)
- fav_free_branch(get_fav_folder(ft));
- else
- free(ft->fp);
- ft->fp = NULL;
-}
-
-void fav_free(void)
-{
- fav_free_branch(get_fav_root());
-}
-/* --- */
-
-void fav_remove_current(void)
-{
- fav_remove(get_current_fav(), get_current_entry());
-}
-
-static fav_type_t *get_fav_item(short id, int type)
-{
- int i;
- fav_type_t *ft;
- fav_t *fp = get_current_fav();
-
- for(i = 0; i < fp->nAllocs; i++){
- ft = &fp->favh[i];
- if (!is_set_attr(ft, FAVH_FAV) || get_item_type(ft) != type)
- continue;
- if (fav_getid(ft) == id)
- return ft;
- }
- return NULL;
-}
-
-static fav_type_t *getboard(short bid)
-{
- return get_fav_item(bid, FAVT_BOARD);
-}
-
-char *get_folder_title(int fid)
-{
- return get_item_title(get_fav_item(fid, FAVT_FOLDER));
-}
-
-
-char getbrdattr(short bid)
-{
- fav_type_t *fb = getboard(bid);
- if (!fb)
- return 0;
- return fb->attr;
-}
-
-time_t getbrdtime(short bid)
-{
- fav_type_t *fb = getboard(bid);
- if (!fb)
- return 0;
- return cast_board(fb)->lastvisit;
-}
-
-void setbrdtime(short bid, time_t t)
-{
- fav_type_t *fb = getboard(bid);
- if (fb)
- cast_board(fb)->lastvisit = t;
-}
-
-int fav_getid(fav_type_t *ft)
-{
- switch(get_item_type(ft)){
- case FAVT_FOLDER:
- return cast_folder(ft)->fid;
- case FAVT_LINE:
- return cast_line(ft)->lid;
- case FAVT_BOARD:
- return cast_board(ft)->bid;
- }
- return -1;
-}
-
-/* suppose we don't add too much fav_type_t at the same time. */
-static int enlarge_if_full(fav_t *fp)
-{
- /* enlarge the volume if need. */
- if (fav_number >= MAX_FAV)
- return -1;
- if (fp->nDatas < fp->nAllocs)
- return 1;
-
- /* realloc and clean the tail */
- fp->favh = (fav_type_t *)realloc(fp->favh, sizeof(fav_type_t) * (fp->nAllocs + FAV_PRE_ALLOC));
- memset(fp->favh + fp->nAllocs, 0, sizeof(fav_type_t) * FAV_PRE_ALLOC);
- fp->nAllocs += FAV_PRE_ALLOC;
- return 0;
-}
-
-inline int is_maxsize(void){
- return fav_number >= MAX_FAV;
-}
-
-int fav_add(fav_t *fp, fav_type_t *item)
-{
- if (enlarge_if_full(fp) < 0)
- return -1;
- fav_item_copy(&fp->favh[fp->nDatas], item);
- fav_increase(fp, item);
- return 0;
-}
-
-/* just move, in one folder */
-static void move_in_folder(fav_t *fav, int from, int to)
-{
- int i;
- fav_type_t tmp;
- fav_item_copy(&tmp, &fav->favh[from]);
-
- if (from < to) {
- for(i = from; i < to; i++)
- fav_item_copy(&fav->favh[i], &fav->favh[i + 1]);
- }
- else { // to < from
- for(i = from; i > to; i--)
- fav_item_copy(&fav->favh[i], &fav->favh[i - 1]);
- }
- fav_item_copy(&fav->favh[to], &tmp);
-}
-
-void move_in_current_folder(int from, int to)
-{
- move_in_folder(get_current_fav(), from, to);
-}
-
-/* the following defines the interface of add new fav_XXX */
-inline static fav_t *alloc_folder_item(void){
- fav_t *fp = (fav_t *)fav_malloc(sizeof(fav_t));
- fp->nAllocs = FAV_PRE_ALLOC;
- fp->favh = (fav_type_t *)fav_malloc(sizeof(fav_type_t) * FAV_PRE_ALLOC);
- return fp;
-}
-
-static fav_type_t *init_add(fav_t *fp, int type, int place)
-{
- fav_type_t *ft;
- if (is_maxsize())
- return NULL;
- ft = fav_item_allocate(type);
- set_attr(ft, FAVH_FAV, TRUE);
- fav_add(fp, ft);
- if (place >= 0 && place < fp->nAllocs)
- move_in_folder(fp, fp->nDatas - 1, place);
- return ft;
-}
-
-/* if place < 0, just put the item to the tail */
-fav_type_t *fav_add_line(int place)
-{
- fav_t *fp = get_current_fav();
- fav_type_t *ft = init_add(fp, FAVT_LINE, place);
- if (ft == NULL)
- return NULL;
- cast_line(ft)->lid = get_line_num(fp);
- return ft;
-}
-
-fav_type_t *fav_add_folder(int place)
-{
- fav_t *fp = get_current_fav();
- fav_type_t *ft;
- if (fav_stack_full())
- return NULL;
- ft = init_add(fp, FAVT_FOLDER, place);
- if (ft == NULL)
- return NULL;
- cast_folder(ft)->this_folder = alloc_folder_item();
- cast_folder(ft)->fid = get_folder_num(fp); // after fav_increase
- return ft;
-}
-
-fav_type_t *fav_add_board(int bid, int place)
-{
- fav_t *fp = get_current_fav();
- fav_type_t *ft = init_add(fp, FAVT_BOARD, place);
- if (ft == NULL)
- return NULL;
- cast_board(ft)->bid = bid;
- return ft;
-}
-/* --- */
-
-/* everything about the tag in fav mode.
- * I think we don't have to implement the function 'cross-folder' tag.*/
-inline void fav_tag_current(int bool) {
- set_attr(get_current_entry(), FAVH_TAG, bool);
-}
-
-static void fav_dosomething_tagged_item(fav_t *fp, int (*act)(fav_t *, fav_type_t *))
-{
- int i;
- for(i = 0; i < fp->nAllocs; i++){
- if (is_set_attr(&fp->favh[i], FAVH_FAV) && is_set_attr(&fp->favh[i], FAVH_TAG))
- if ((*act)(fp, &fp->favh[i]) < 0)
- break;
- }
-}
-
-inline static int fav_remove_tagged_item(fav_t *fp){
- fav_dosomething_tagged_item(fp, fav_remove);
- return 0;
-}
-
-static int add_and_remove_tag(fav_t *fp, fav_type_t *ft)
-{
- fav_type_t *tmp = fav_malloc(sizeof(fav_type_t));
- fav_item_copy(tmp, ft);
- set_attr(tmp, FAVH_TAG, FALSE);
- if (fav_add(fav_get_tmp_fav(), tmp) < 0)
- return -1;
- fav_remove(fp, ft);
- return 0;
-}
-
-inline static int fav_add_tagged_item(fav_t *fp){
- if (fp == fav_get_tmp_fav())
- return -1;
- fav_dosomething_tagged_item(fp, add_and_remove_tag);
- return 0;
-}
-
-static void fav_do_recursively(int (*act)(fav_t *))
-{
- int i;
- fav_type_t *ft;
- fav_t *fp = get_current_fav();
- for(i = 0; i < fp->nAllocs; i++){
- ft = &fp->favh[i];
- if (!is_set_attr(ft, FAVH_FAV))
- continue;
- if (get_item_type(ft) == FAVT_FOLDER && get_fav_folder(ft) != NULL){
- fav_stack_push(ft);
- fav_do_recursively(act);
- fav_stack_pop();
- }
- }
- (*act)(fp);
-}
-
-static void fav_dosomething_all_tagged_item(int (*act)(fav_t *))
-{
- int tmp = fav_stack_num;
- fav_t *fp = get_current_fav();
- fav_stack_num = 1;
- fav_do_recursively(act);
- fav_stack_num = tmp;
- fav_stack[fav_stack_num - 1] = fp;
-}
-
-void fav_remove_all_tagged_item(void)
-{
- fav_dosomething_all_tagged_item(fav_remove_tagged_item);
-}
-
-void fav_add_all_tagged_item(void)
-{
- fav_set_tmp_folder(get_current_fav());
- fav_dosomething_all_tagged_item(fav_add_tagged_item);
-}
-
-inline static int remove_tag(fav_t *fp, fav_type_t *ft)
-{
- set_attr(ft, FAVH_TAG, FALSE);
- return 0;
-}
-
-inline static int remove_tags(fav_t *fp)
-{
- fav_dosomething_tagged_item(fp, remove_tag);
- return 0;
-}
-
-void fav_remove_all_tag(void)
-{
- fav_dosomething_all_tagged_item(remove_tags);
-}
-/* --- */
-
-void fav_set_folder_title(fav_type_t *ft, char *title)
-{
- if (get_item_type(ft) != FAVT_FOLDER)
- return;
- strlcpy(cast_folder(ft)->title, title, sizeof(cast_folder(ft)->title));
-}
-
-/* old struct */
-#define BRD_UNREAD 1
-#define BRD_FAV 2
-#define BRD_LINE 4
-#define BRD_TAG 8
-#define BRD_GRP_HEADER 16
-
-typedef struct {
- short bid;
- char attr;
- time_t lastvisit;
-} fav3_board_t;
-
-typedef struct {
- short nDatas;
- short nAllocs;
- char nLines;
- fav_board_t *b;
-} fav3_t;
-
-int fav_v3_to_v4(void)
-{
- int i, fd, fdw;
- char buf[128];
-
- short nDatas;
- char nLines;
- fav_t fav4;
- fav3_board_t *brd;
-
- setuserfile(buf, FAV4);
- fd = open(buf, O_RDONLY);
- if (fd >= 0){
- close(fd);
- return 0;
- }
- fdw = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0600);
- if (fdw < 0)
- return -1;
- setuserfile(buf, FAV3);
- fd = open(buf, O_RDONLY);
- if (fd < 0)
- return -1;
-
- read(fd, &nDatas, sizeof(nDatas));
- read(fd, &nLines, sizeof(nLines));
-
- fav4.nDatas = nDatas;
- fav4.nBoards = nDatas - (-nLines);
- fav4.nLines = -nLines;
- fav4.nFolders = 0;
- fav4.favh = (fav_type_t *)fav_malloc(sizeof(fav_type_t) * fav4.nDatas);
-
- brd = (fav3_board_t *)fav_malloc(sizeof(fav3_board_t) * nDatas);
- read(fd, brd, sizeof(fav3_board_t) * nDatas);
-
- for(i = 0; i < fav4.nDatas; i++){
- fav4.favh[i].type = brd[i].attr & BRD_LINE ? FAVT_LINE : FAVT_BOARD;
-
- if (brd[i].attr & BRD_UNREAD)
- fav4.favh[i].attr |= FAVH_UNREAD;
- if (brd[i].attr & BRD_FAV)
- fav4.favh[i].attr |= FAVH_FAV;
- if (brd[i].attr & BRD_TAG)
- fav4.favh[i].attr |= FAVH_TAG;
-
- fav4.favh[i].fp = (void *)fav_malloc(get_type_size(fav4.favh[i].type));
- if (brd[i].attr & BRD_LINE){
- fav4.favh[i].type = FAVT_LINE;
- cast_line(&fav4.favh[i])->lid = -brd[i].bid;
- }
- else{
- fav4.favh[i].type = FAVT_BOARD;
- cast_board(&fav4.favh[i])->bid = brd[i].bid;
- cast_board(&fav4.favh[i])->lastvisit = brd[i].lastvisit;
- }
- }
-
- write_favrec(fdw, &fav4);
- fav_free_branch(&fav4);
- free(brd);
- return 0;
-}
diff --git a/pttbbs/mbbsd/friend.c b/pttbbs/mbbsd/friend.c
index 3f97ee71..ab9f1076 100644
--- a/pttbbs/mbbsd/friend.c
+++ b/pttbbs/mbbsd/friend.c
@@ -271,7 +271,9 @@ friend_load(int type)
myfriends[friendcount++] = unum;
fclose(fp);
}
+ qsort(myfriends, friendcount, sizeof(int), qsort_intcompar);
memcpy(currutmp->friend, myfriends, sizeof(myfriends));
+ currutmp->nFriends = friendcount;
}
if (!type || type & FRIEND_REJECT) {
@@ -399,7 +401,7 @@ friend_edit(int type)
dirty = 1;
} else if (*uident == 'w' && count) {
char wall[60];
- if (!getdata(0, 0, "¸sÅé¤ô²y:", uident, sizeof(wall), DOECHO))
+ if (!getdata(0, 0, "¸sÅé¤ô²y:", wall, sizeof(wall), DOECHO))
continue;
if (getdata(0, 0, "½T©w¥á¥X¸sÅé¤ô²y? [Y]", line, 4, LCECHO) &&
*line == 'n')
diff --git a/pttbbs/mbbsd/guess.c b/pttbbs/mbbsd/guess.c
index 917951ad..5ec40080 100644
--- a/pttbbs/mbbsd/guess.c
+++ b/pttbbs/mbbsd/guess.c
@@ -32,18 +32,18 @@ get_money(void)
prints("±z¥Ø«e¦³:%d Ptt$", cuser.money);
do {
getdata(2, 0, "­n½ä¦h¤Ö(5-10©Î«öqÂ÷¶}): ", data, 9, LCECHO);
- money = strlen(data);
+ money = 0;
if (data[0] == 'q' || data[0] == 'Q') {
unlockutmpmode();
return 0;
}
- for (i = 0; i < money; i++)
+ for (i = 0; data[i]; i++)
if (data[i] < '0' || data[i] > '9') {
money = -1;
break;
}
if (money != -1) {
- money = atol(data);
+ money = atoi(data);
reload_money();
if (money > cuser.money || money <= 4 || money > 10 ||
money < 1)
diff --git a/pttbbs/mbbsd/io.c b/pttbbs/mbbsd/io.c
index 6f3cff9e..bb09d79f 100644
--- a/pttbbs/mbbsd/io.c
+++ b/pttbbs/mbbsd/io.c
@@ -492,7 +492,7 @@ getans(char *prompt)
{
char ans[5];
- getdata(t_lines - 1, 0, prompt, ans, sizeof(ans), LCECHO);
+ getdata(b_lines, 0, prompt, ans, sizeof(ans), LCECHO);
return ans[0];
}
diff --git a/pttbbs/mbbsd/mbbsd.c b/pttbbs/mbbsd/mbbsd.c
index 7968860e..e419cc1d 100644
--- a/pttbbs/mbbsd/mbbsd.c
+++ b/pttbbs/mbbsd/mbbsd.c
@@ -92,29 +92,6 @@ reapchild(int sig)
while ((pid = waitpid(-1, &state, WNOHANG | WUNTRACED)) > 0);
}
-#define BANNER \
-"¡i" BBSNAME "¡j¡· ¥x¤j¬y¦æºô ¡·(" MYHOSTNAME ") ½Õ´T(" MYIP ") "
-/* check load and print approriate banner string in buf */
-static int
-chkload(char *buf, int length)
-{
- char cpu_load[30];
- int i;
-
- i = cpuload(cpu_load);
-
- buf[0] = 0;
-#ifdef INSCREEN
- if( i > MAX_CPULOAD ){
- strlcpy(buf, BANNER "\r\n¨t²Î¹L¸ü, ½Ðµy«á¦A¨Ó\r\n", length);
- }
-#else
- snprintf(buf, length, BANNER "%s\r\n",
- (i > MAX_CPULOAD ? "°ª­t²ü¶q¡A½Ðµy«á¦A¨Ó(½Ð§Q¥Îport 3000~3010³s½u)" : ""));
-#endif
- return i > MAX_CPULOAD ? 1 : 0;
-}
-
void
log_user(char *msg)
{
@@ -786,9 +763,9 @@ inline static void birthday_make_a_wish(struct tm *ptime, struct tm *tmp){
}
}
-inline static void record_lasthost(char *fromhost){
- strncpy(cuser.lasthost, fromhost, sizeof(cuser.lasthost));
- cuser.lasthost[sizeof(cuser.lasthost - 1)] = '\0';
+inline static void record_lasthost(char *fromhost, int len){
+ strncpy(cuser.lasthost, fromhost, len);
+ cuser.lasthost[len - 1] = '\0';
}
inline static void check_mailbox_and_read(void){
@@ -916,7 +893,7 @@ user_login()
check_bad_login();
check_mailbox_and_read();
check_register();
- record_lasthost(fromhost);
+ record_lasthost(fromhost, 16);
restore_backup();
} else if (!strcmp(cuser.userid, STR_GUEST)) {
init_guest_info();
@@ -1371,41 +1348,49 @@ static int
check_ban_and_load(int fd)
{
FILE *fp;
- static char buf[256];
static time_t chkload_time = 0;
static int overload = 0; /* overload or banned, update every 1
* sec */
static int banned = 0;
#ifdef INSCREEN
- write(fd, INSCREEN, strlen(INSCREEN));
+ write(fd, INSCREEN, sizeof(INSCREEN));
+#else
+#define BANNER \
+"¡i" BBSNAME "¡j¡· ¥x¤j¬y¦æºô ¡·(" MYHOSTNAME ") ½Õ´T(" MYIP ") \r\n"
+ write(fd, BANNER, sizeof(BANNER));
#endif
if ((time(0) - chkload_time) > 1) {
- overload = chkload(buf, sizeof(buf));
- banned = !access(BBSHOME "/BAN", R_OK) &&
- (strcmp(fromhost, "localhost") != 0);
+ overload = 0;
+ banned = 0;
+
+ if(cpuload(NULL) > MAX_CPULOAD)
+ overload = 1;
+ else if (SHM->UTMPnumber >= MAX_ACTIVE
+#ifdef DYMAX_ACTIVE
+ || (SHM->GV2.e.dymaxactive > 2000 &&
+ SHM->UTMPnumber >= SHM->GV2.e.dymaxactive)
+#endif
+ ) {
+ ++SHM->GV2.e.toomanyusers;
+ overload = 2;
+ } else if(!access(BBSHOME "/" BAN_FILE, R_OK))
+ banned = 1;
+
chkload_time = time(0);
}
- write(fd, buf, strlen(buf));
- if (banned && (fp = fopen(BBSHOME "/BAN", "r"))) {
- // XXX this will mess up buf
+ if(overload == 1)
+ write(fd, "¨t²Î¹L¸ü, ½Ðµy«á¦A¨Ó\r\n", 22);
+ else if(overload == 2)
+ write(fd, "¥Ñ©ó¤H¼Æ¹L¦h¡A½Ð±zµy«á¦A¨Ó¡C", 28);
+ else if (banned && (fp = fopen(BBSHOME "/" BAN_FILE, "r"))) {
+ char buf[256];
while (fgets(buf, sizeof(buf), fp))
write(fd, buf, strlen(buf));
fclose(fp);
}
- if (SHM->UTMPnumber >= MAX_ACTIVE
-#ifdef DYMAX_ACTIVE
- || (SHM->GV2.e.dymaxactive > 2000 &&
- SHM->UTMPnumber >= SHM->GV2.e.dymaxactive)
-#endif
- ) {
- ++SHM->GV2.e.toomanyusers;
- snprintf(buf, sizeof(buf), "¥Ñ©ó¤H¼Æ¹L¦h¡A½Ð±zµy«á¦A¨Ó¡C");
- write(fd, buf, strlen(buf));
- overload = 1;
- }
if (banned || overload)
return -1;
diff --git a/pttbbs/mbbsd/screen.c b/pttbbs/mbbsd/screen.c
index bbe0e924..24dffc4d 100644
--- a/pttbbs/mbbsd/screen.c
+++ b/pttbbs/mbbsd/screen.c
@@ -217,11 +217,11 @@ clear()
register int i;
docls = YEA;
- cur_col = cur_ln = roll = downfrom = i = 0;
- do {
+ cur_col = cur_ln = roll = downfrom = 0;
+ for(i=0; i<scr_lns; i++) {
slp = &big_picture[i];
slp->mode = slp->len = slp->oldlen = 0;
- } while (++i < scr_lns);
+ }
}
void
@@ -473,12 +473,7 @@ outmsg(char *msg)
{
move(b_lines, 0);
clrtoeol();
-#ifdef SUPPORT_GB
- if (current_font_type == TYPE_GB)
- msg = hc_convert_str(msg, HC_BIGtoGB, HC_DO_SINGLE);
-#endif
- while (*msg)
- outc(*msg++);
+ outs(msg);
}
void
diff --git a/pttbbs/mbbsd/stuff.c b/pttbbs/mbbsd/stuff.c
index 9f13b2ef..a6aaec46 100644
--- a/pttbbs/mbbsd/stuff.c
+++ b/pttbbs/mbbsd/stuff.c
@@ -337,27 +337,30 @@ belong(char *filelist, char *key)
#ifndef _BBS_UTIL_C_ /* getdata_buf */
time_t
-gettime(int line, time_t dt)
+gettime(int line, time_t dt, char*head)
{
char yn[7];
+ int i;
struct tm *ptime = localtime(&dt), endtime;
memcpy(&endtime, ptime, sizeof(struct tm));
snprintf(yn, sizeof(yn), "%4d", ptime->tm_year + 1900);
+ move(line, 0); prints("%s",head);
+ i=strlen(head);
do {
- getdata_buf(line, 0, "¦è¤¸¦~:", yn, 5, LCECHO);
+ getdata_buf(line, i, " ¦è¤¸¦~:", yn, 5, LCECHO);
} while ((endtime.tm_year = atoi(yn) - 1900) < 0 || endtime.tm_year > 200);
snprintf(yn, sizeof(yn), "%d", ptime->tm_mon + 1);
do {
- getdata_buf(line, 13, "¤ë:", yn, 3, LCECHO);
+ getdata_buf(line, i+15, "¤ë:", yn, 3, LCECHO);
} while ((endtime.tm_mon = atoi(yn) - 1) < 0 || endtime.tm_mon > 11);
snprintf(yn, sizeof(yn), "%d", ptime->tm_mday);
do {
- getdata_buf(line, 22, "¤é:", yn, 3, LCECHO);
+ getdata_buf(line, i+24, "¤é:", yn, 3, LCECHO);
} while ((endtime.tm_mday = atoi(yn)) < 1 || endtime.tm_mday > 31);
snprintf(yn, sizeof(yn), "%d", ptime->tm_hour);
do {
- getdata_buf(line, 31, "®É(0-23):", yn, 3, LCECHO);
+ getdata_buf(line, i+33, "®É(0-23):", yn, 3, LCECHO);
} while ((endtime.tm_hour = atoi(yn)) < 0 || endtime.tm_hour > 23);
return mktime(&endtime);
}
@@ -660,3 +663,28 @@ StringHash(unsigned char *s)
}
return (v * 2654435769UL) >> (32 - HASH_BITS);
}
+
+inline int *intbsearch(int key, int *base0, int nmemb)
+{
+ /* §ï¦Û /usr/src/lib/libc/stdlib/bsearch.c ,
+ ±Mµ¹·j int array ¥Îªº, ¤£³z¹L compar function ¬G¸û§Ö¨Ç */
+ const char *base = (char *)base0;
+ size_t lim;
+ int *p;
+
+ for (lim = nmemb; lim != 0; lim >>= 1) {
+ p = (int *)(base + (lim >> 1) * 4);
+ if( key == *p )
+ return p;
+ if( key > *p ){/* key > p: move right */
+ base = (char *)p + 4;
+ lim--;
+ } /* else move left */
+ }
+ return (NULL);
+}
+
+int qsort_intcompar(const void *a, const void *b)
+{
+ return *(int *)a - *(int *)b;
+}
diff --git a/pttbbs/mbbsd/talk.c b/pttbbs/mbbsd/talk.c
index 7ccd1e87..9633570d 100644
--- a/pttbbs/mbbsd/talk.c
+++ b/pttbbs/mbbsd/talk.c
@@ -155,33 +155,20 @@ modestring(userinfo_t * uentp, int simple)
int
set_friend_bit(userinfo_t * me, userinfo_t * ui)
{
- int unum, *myfriends, hit = 0, n;
+ int unum, *myfriends, hit = 0;
/* §PÂ_¹ï¤è¬O§_¬°§ÚªºªB¤Í ? */
- unum = ui->uid;
- myfriends = me->friend;
- while ((n = *myfriends++)) {
- if (unum == n) {
- hit = IFH;
- break;
- }
- }
+ if( intbsearch(ui->uid, me->friend, me->nFriends) )
+ hit = IFH;
/* §PÂ_§Ú¬O§_¬°¹ï¤èªºªB¤Í ? */
- myfriends = ui->friend;
- while ((unum = *myfriends++)) {
- if (unum == me->uid) {
- hit |= HFM;
- break;
- }
- }
+ if( intbsearch(me->uid, ui->friend, ui->nFriends) )
+ hit |= HFM;
/* §PÂ_¹ï¤è¬O§_¬°§Úªº¤³¤H ? */
-
- unum = ui->uid;
myfriends = me->reject;
- while ((n = *myfriends++)) {
- if (unum == n) {
+ while ((unum = *myfriends++)) {
+ if (unum == ui->uid) {
hit |= IRH;
break;
}
@@ -396,7 +383,7 @@ my_query(char *uident)
return DONOTHING;
}
-static char t_last_write[200] = "";
+static char t_last_write[80];
void
water_scr(water_t * tw, int which, char type)
@@ -1212,8 +1199,10 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
sock = make_connection_to_somebody(uin, 20);
if (sock < 0)
vmsg("µLªk«Ø¥ß³s½u");
- strlcpy(currutmp->mateid, uin->userid, sizeof(currutmp->mateid));
- chc(sock, CHC_WATCH);
+ else {
+ strlcpy(currutmp->mateid, uin->userid, sizeof(currutmp->mateid));
+ chc(sock, CHC_WATCH);
+ }
}
else
outs("¤H®a¦b¦£°Õ");
@@ -1357,13 +1346,6 @@ my_talk(userinfo_t * uin, int fri_stat, char defact)
pressanykey();
}
-static void
-self_play(userinfo_t * uin, int fri_stat)
-{
- if (getans("[¶H´Ñ] §A½T©w­n¥´ÃжܡH[N/y]") == 'y')
- chc(0, CHC_PERSONAL);
-}
-
/* ¿ï³æ¦¡²á¤Ñ¤¶­± */
#define US_PICKUP 1234
#define US_RESORT 1233
@@ -2213,17 +2195,14 @@ userlist(void)
case 't':
if (HAS_PERM(PERM_LOGINOK)) {
- move(1, 0);
- clrtobot();
- move(3, 0);
if (uentp->pid != currpid &&
- strcmp(uentp->userid, cuser.userid) != 0) {
+ strcmp(uentp->userid, cuser.userid) != 0) {
+ move(1, 0);
+ clrtobot();
+ move(3, 0);
my_talk(uentp, fri_stat, 0);
+ redrawall = redraw = 1;
}
- else{
- self_play(uentp, fri_stat);
- }
- redrawall = redraw = 1;
}
break;
case 'K':
@@ -2275,8 +2254,15 @@ userlist(void)
if (getdata(b_lines - 1, 0, "[»È¦æÂà±b]: ",
genbuf, 7, LCECHO)) {
clrtoeol();
- if ((ch = atoi(genbuf)) <= 0 || ch <= give_tax(ch))
+ if ((ch = atoi(genbuf)) <= 0 || ch <= give_tax(ch)){
+ redrawall = redraw = 1;
break;
+ }
+ sprintf(genbuf, "½T©w­nµ¹ %s %d Ptt ¹ô¶Ü? [N/y]", uentp->userid, ch);
+ if (getans(genbuf) != 'y'){
+ redrawall = redraw = 1;
+ break;
+ }
reload_money();
if (ch > cuser.money) {
diff --git a/pttbbs/mbbsd/var.c b/pttbbs/mbbsd/var.c
index 5125442e..0ad9e78f 100644
--- a/pttbbs/mbbsd/var.c
+++ b/pttbbs/mbbsd/var.c
@@ -313,8 +313,8 @@ char *ModeTypeTable[MAX_MODES] = {
};
/* term.c */
-int b_lines = 23;
-int t_lines = 24;
+int b_lines = 23; // bottom line of screen
+int t_lines = 24; // term lines
int p_lines = 20;
int t_columns = 80;
char *strtstandout = "\33[7m";
diff --git a/pttbbs/sample/etc/chickens/n10 b/pttbbs/sample/etc/chickens/n10
index e69de29b..6bbb4100 100644
--- a/pttbbs/sample/etc/chickens/n10
+++ b/pttbbs/sample/etc/chickens/n10
@@ -0,0 +1,12 @@
+ -------- ¢¬¢­ ¢¬¢­
+ ------ ¢y¢¨ ¢i ¢©¢j
+ -------- ¢i¢«¢e¢ª¢i
+ -- ¢ª ¢© ¡Ö ¡Õ ¢¨ ¢«
+ --- ¢ª ¢¨¢©" ¡¿ "¢¨¢© ¢«
+ ---- ¢¨¢i¢ªª ¢Ø ¢« ¢e
+ ---- ¢e ¢« ¢ª¢ª¢i¢«
+ ---------- ¢e¢e¢e ¢«
+ -------- ¢¨¢ª¢i¢«¢©
+ ------- ¢© ¢« ¢ª¢¨
+ ------ ¢i¢m ¢i¢m
+ --- ¢¨ ¢ª ¢« ¢©
diff --git a/pttbbs/sample/etc/chickens/n11 b/pttbbs/sample/etc/chickens/n11
index e69de29b..939572c3 100644
--- a/pttbbs/sample/etc/chickens/n11
+++ b/pttbbs/sample/etc/chickens/n11
@@ -0,0 +1,12 @@
+ ¢¬¢­ ¢¬¢­
+ ·F ¢y¢¨ ¢i ¢©¢j ·F
+ ¢i¢«¢e¢ª¢i
+ ·F¢ª ¢© ¢­ ¢¬ ¢¨ ¢«·F
+ ¢ª ¢¨¢©" ¡¶ "¢¨¢© ¢«
+ ·F ¢e ¢ªª ¢Ø ¢« ¢e ·F
+ ¢ª¢i¢«¢« ¢ª¢ª¢i¢«
+ ·F ¢ª ¢e¢e¢e ¢« ·F
+ ¢¨¢ª¢i¢«¢©
+ ·F ¢©¢« ¢ª¢¨ ·F
+ ¢i¢m ¢i¢m
+ ·F ¢¨ ¢ª ¢« ¢© ·F
diff --git a/pttbbs/sample/etc/chickens/n12 b/pttbbs/sample/etc/chickens/n12
index e69de29b..900740cf 100644
--- a/pttbbs/sample/etc/chickens/n12
+++ b/pttbbs/sample/etc/chickens/n12
@@ -0,0 +1,12 @@
+ ¢¬¢­ ¢¬¢­
+ ¢y¢¨ ¢i ¢©¢j
+ ¢i¢«¢e¢ª¢i
+ ¢ª¢i¢© ¡E ¡E ¢¨¢i¢«
+ ¢ª ¢¨¢©" ¡E "¢¨¢© ¢«
+ ¢e ¢ª¢i¢i¢i¢« ¢e
+ ¢ª¢i¢«¢« ¢ª¢ª¢i¢«
+ ¢ª ¢e¢e¢e ¢«
+ ¢¨¢ª¢i¢«¢©
+ ¢©¢«¡´¢ª¢¨
+ ¢i¢m ¢i¢m
+ ¢¨ ¢ª ¢« ¢©
diff --git a/pttbbs/sample/etc/chickens/n13 b/pttbbs/sample/etc/chickens/n13
index 96197489..5fdba18f 100644
--- a/pttbbs/sample/etc/chickens/n13
+++ b/pttbbs/sample/etc/chickens/n13
@@ -1 +1,12 @@
- -- ¢ª ¢© ¡Ö ¡Õ ¢¨ ¢«
+ ¢¬¢­ ¢¬¢­
+ ¢y¢¨ ¢i ¢©¢j
+ ¢i¢«¢e¢ª¢i
+ ¢ª ¢© ¢­ ¢¬ ¢¨ ¢«
+ ¢ª ¢¨¢©" ¡_ "¢¨¢© ¢«¢~¢w¢¡
+ ¢e ¢ªª ¢Ø ¢« ¢i¢m¢x¡´¢x
+ ¢ª¢i¢«¢« ¢ª ¢« ¢¢¢w¢£
+ ¢ª ¢e¢e¢e
+ ¢¨¢ª¢i¢«¢©
+ ¢©¢« ¢ª¢¨
+ ¢i¢m ¢i¢m
+ ¢¨ ¢ª ¢« ¢©
diff --git a/pttbbs/sample/etc/chickens/n14 b/pttbbs/sample/etc/chickens/n14
index e69de29b..980f6117 100644
--- a/pttbbs/sample/etc/chickens/n14
+++ b/pttbbs/sample/etc/chickens/n14
@@ -0,0 +1,12 @@
+ ¢¬¢­ ¢¬¢­
+ ¢y¢¨ ¢i ¢©¢j
+ ¢i¢«¢e¢ª¢i
+ ¢ª ¢© ¢­ ¢¬ ¢¨ ¢«
+ ¢ª ¢¨¢©" ¢¯ "¢¨¢© ¢«¢­¢x¢¬
+ ¢ª  ¢ªª ¢Ø ¢«  ¢m¢w¡³¢w
+ ¢i ¢« ¢ª ¢« ¢¬¢x¢­
+ ¢e¢e¢e
+ ¢¨ ¢ª¢i¢« ¢©
+ ¢©¢« ¢ª¢¨
+ ¢i¢m ¢i¢m
+ ¢¨ ¢ª ¢« ¢©
diff --git a/pttbbs/sample/etc/chickens/n15 b/pttbbs/sample/etc/chickens/n15
index e69de29b..9a46c040 100644
--- a/pttbbs/sample/etc/chickens/n15
+++ b/pttbbs/sample/etc/chickens/n15
@@ -0,0 +1,12 @@
+ ¢©¢©¡¶¢¨¢¨
+ ¢ª ¢© £w ¢¨ ¢«
+ ¢ª ¡Ý ¡´ ¡Ý ¢«
+ ¢ª¢i¢© ¢¬ ¢­ ¢¨¢i¢«
+ ¢ª ¢¨¢©" ¡_ "¢¨¢© ¢«
+ ¢ª¢i¢i¢i¢«
+ ¢ª¢i¢« ¢ª¢i¢«
+  ¢e¢e¢e 
+ ¢¨¢ª¢i¢«¢©
+ ¢©¢« ¢ª¢¨
+ ¢i¢m ¢i¢m
+ ¢¨ ¢ª ¢« ¢©
diff --git a/pttbbs/sample/etc/chickens/n16 b/pttbbs/sample/etc/chickens/n16
index e69de29b..9f932fa5 100644
--- a/pttbbs/sample/etc/chickens/n16
+++ b/pttbbs/sample/etc/chickens/n16
@@ -0,0 +1,12 @@
+ ¢¬¢­ ¢¬¢­
+ ¢y¢¨ ¢i ¢©¢j
+   ¢i¢«¢e¢ª¢i  
+ ¢ª¢ª¢© ¡_ ¡_ ¢¨¢«¢«
+ ¢ª ¢ª¢©" ¡¿ "¢¨¢« ¢«
+ ¢¨ª ¢Ø ¢©
+ ¢« ¢ª
+ ¢e¢e¢e
+  ¢¨¢ª¢i¢«¢©
+ ¢©¢« ¢ª¢¨
+ ¢i¢m ¢i¢m
+ ¢¨ ¢ª ¢« ¢©
diff --git a/pttbbs/staticweb/INSTALL b/pttbbs/staticweb/INSTALL
new file mode 100644
index 00000000..2eadd296
--- /dev/null
+++ b/pttbbs/staticweb/INSTALL
@@ -0,0 +1,43 @@
+³o½g¤å³¹¤¶²Ð¦p¦ó¨Ï¥Î webª©ºëµØ°Ï, ¤å³¹ªºª©¸¹¤Î³Ì«á½s­×®É¶¡¬O:
+$Id$
+
+1.¦w¸Ë¦n¤U¦CªºªF¦è, §Ú­Ì¨Ã¦P®É¦C¤W FreeBSD ports¤ºªº¥Ø¿ý:
+ apache /usr/ports/www/apache13/
+ perl /usr/ports/lang/perl5.8/
+ mod_perl /usr/ports/www/mod_perl/
+
+ ¥H¤Î¤U¦Cªº module
+ Template /usr/ports/www/p5-Template-Toolkit/
+ MD5 /usr/ports/security/p5-MD5/
+ Data::Serializer /usr/ports/devel/p5-Data-Serializer/
+ OurNet::FuzzyIndex (ÁÙ¨S¦³¶i ports, ½Ð¥Î cpan ¸Ë)
+
+2.
+¶·­n¤T­Ó¥Ø¿ý, ¤@­Ó¬O©ñ¸m cgiµ{¦¡ªº¦a¤è, ¤@­Ó©ñ¸m¹ê»Ú¸ê®Æ. ¤@­Ó©ñ¸m
+½sĶ¹Lªº template , ¨ä¤¤©ñ¸m½sĶ¹Lªº template ¥Ø¿ý¶·­n¬O apache ¥i
+¥H¼g¤Jªº.
+±N pttbbs/staticweb/* «þ¨©¦Ü©ñ¸m cgiµ{¦¡ªº¥Ø¿ý¤º.
+­×§ï /home/bbs/bin/LocalVars.pm , ±N©ñ¸m¹ê»Ú¸ê®Æªº¥Ø¿ý¼gµ¹ $MANDATA ,
+±N©ñ¸m½sĶ¹L template ªº¥Ø¿ýµ¹ $MANCACHE. ³o¨â­Ó½Ð³£¨Ï¥Îµ´¹ï¸ô®|.
+
+3.
+¨Ï¥Î pttbbs/staticweb/manbuild.pl ¨Ó±N·í«eªººëµØ°Ï«Ø¦¨¸ê®Æ®w.
+usage: manbuild.pl [-n] [BoardName1/DB1 [BoardName2/DB2 [...]]]
+¨ä¤¤ -n ªí¥Ü¤£«Ø¥ß¥Î¨Ó·j´Mªº¯Á¤ÞÀÉ, «á­±½Ð¥[­n«Ø¥ßªº¬ÝªO¦WºÙ.
+²£¥Í¦n«á½Ð±N *.db, *.idx²¾¦Ü $MANDATA ¤¤, ¨Ã¥B½T»{¸ÓÀɮ׬O apache
+¥iŪ.
+
+4.
+°õ¦æ
+ pttbbs/util/boardlist > boardlist.pm
+¦A±N boardlist.pm ²¾¤Jµ{¦¡¥Ø¿ý.
+
+5.
+³]©w apache , ¨Ï¥Î mod_perl , ¨Ã¶}±Ò¸Ó¥Ø¿ýªº ExecCGIÅv­­, ¦p:
+ <Directory "/home/bbs/web/cgi">
+ Options ExecCGI
+
+ # ¤U­±¨â¦æ¬O¨Ï¥Î mod_perl ªº.
+ AddHandler perl-script .pl
+ PerlHandler Apache::Registry
+ </Directory>
diff --git a/pttbbs/staticweb/dir.html b/pttbbs/staticweb/dir.html
index c3ce33ac..50f5ef63 100644
--- a/pttbbs/staticweb/dir.html
+++ b/pttbbs/staticweb/dir.html
@@ -34,6 +34,7 @@
</form>
[% END %]
<hr />
+<font size="-1">[% IF gb %]ÖÆ×÷ʱ¼ä[% ELSE %]»s§@®É¶¡[% END %]: [% buildtime %]</font><br>
<a href="telnet://ptt.cc">[% IF gb %]ÅúÌßÌßʵҵ·»[% ELSE %]§å½ð½ð¹ê·~§{[% END %]</a> (<a href="http://ptt.cc">PttWeb</a>)
</td></tr>
</table>
diff --git a/pttbbs/staticweb/man.pl b/pttbbs/staticweb/man.pl
index 729a78d1..274797af 100755
--- a/pttbbs/staticweb/man.pl
+++ b/pttbbs/staticweb/man.pl
@@ -13,6 +13,7 @@ use Data::Serializer;
use Encode;
use Time::HiRes qw/gettimeofday tv_interval/;
use b2g;
+use POSIX;
use vars qw/%db $brdname $fpath $isgb %b2g/;
@@ -80,6 +81,7 @@ sub dirmode
$th{tmpl} = 'dir.html';
$th{isroot} = ($fpath eq '/') ? 1 : 0;
+ $th{buildtime} = POSIX::ctime($db{_buildtime} || 0);
return \%th;
}
diff --git a/pttbbs/staticweb/manbuilder.pl b/pttbbs/staticweb/manbuilder.pl
index a1ea600f..f3b18cf4 100755
--- a/pttbbs/staticweb/manbuilder.pl
+++ b/pttbbs/staticweb/manbuilder.pl
@@ -33,6 +33,7 @@ sub main
$idx = OurNet::FuzzyIndex->new("$_.idx")
if( !$Getopt::Std::opt_n );
build("/home/bbs/man/boards/".substr($_, 0, 1)."/$_", '');
+ $db{_buildtime} = time();
untie %db;
}
}
@@ -55,8 +56,8 @@ sub build($$)
tie %bfh, 'BBSFileHeader', $basedir;
foreach( 0..($bfh{num} - 1) ){
next if( $bfh{"$_.filemode"} & 32 ); # skip HIDDEN
+ next if( !($fn = $bfh{"$_.filename"}) ); # skip empty filename
- $fn = $bfh{"$_.filename"};
if( $bfh{"$_.isdir"} ){
push @tdir, ["$doffset/$fn/", # ¥Ø¿ýµ²§À­n¥[ /
$db{"title-$doffset/$fn/"} = $bfh{"$_.title"}];
diff --git a/pttbbs/util/buildir.c b/pttbbs/util/buildir.c
index 573a0178..e6b7f9d2 100644
--- a/pttbbs/util/buildir.c
+++ b/pttbbs/util/buildir.c
@@ -1,5 +1,17 @@
/* $Id$ */
-#include "bbs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "config.h"
+#include "pttstruct.h"
+#include "proto.h"
int dirselect(struct dirent *dir) {
return strchr("MDSGH", dir->d_name[0]) && dir->d_name[1] == '.';
diff --git a/pttbbs/util/shmctl.c b/pttbbs/util/shmctl.c
index 750f0763..92a220e4 100644
--- a/pttbbs/util/shmctl.c
+++ b/pttbbs/util/shmctl.c
@@ -205,7 +205,7 @@ cmputmpuid(const void *i, const void *j)
return (*((userinfo_t **) i))->uid - (*((userinfo_t **) j))->uid;
}
-inline void utmpsort(void)
+inline void utmpsort(int sortall)
{
userinfo_t *uentp;
int count, i, ns;
@@ -233,39 +233,49 @@ inline void utmpsort(void)
qsort(SHM->sorted[ns][0], count, sizeof(userinfo_t *), cmputmpuserid);
for (i = 0; i < count; ++i)
((userinfo_t *) SHM->sorted[ns][0][i])->idoffset = i;
- memcpy(SHM->sorted[ns][1], SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
- memcpy(SHM->sorted[ns][2], SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
- memcpy(SHM->sorted[ns][3], SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
- memcpy(SHM->sorted[ns][4], SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
- memcpy(SHM->sorted[ns][5], SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
- memcpy(SHM->sorted[ns][6], SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
- memcpy(SHM->sorted[ns][7], SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
- qsort(SHM->sorted[ns][1], count, sizeof(userinfo_t *), cmputmpmode);
- qsort(SHM->sorted[ns][2], count, sizeof(userinfo_t *), cmputmpidle);
- qsort(SHM->sorted[ns][3], count, sizeof(userinfo_t *), cmputmpfrom);
- qsort(SHM->sorted[ns][4], count, sizeof(userinfo_t *), cmputmpfive);
- qsort(SHM->sorted[ns][5], count, sizeof(userinfo_t *), cmputmpchc);
+ memcpy(SHM->sorted[ns][6],
+ SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
+ memcpy(SHM->sorted[ns][7],
+ SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
qsort(SHM->sorted[ns][6], count, sizeof(userinfo_t *), cmputmpuid);
qsort(SHM->sorted[ns][7], count, sizeof(userinfo_t *), cmputmppid);
+ if( sortall ){
+ memcpy(SHM->sorted[ns][1],
+ SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
+ memcpy(SHM->sorted[ns][2],
+ SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
+ memcpy(SHM->sorted[ns][3],
+ SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
+ memcpy(SHM->sorted[ns][4],
+ SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
+ memcpy(SHM->sorted[ns][5],
+ SHM->sorted[ns][0], sizeof(userinfo_t *) * count);
+ qsort(SHM->sorted[ns][1], count, sizeof(userinfo_t *), cmputmpmode);
+ qsort(SHM->sorted[ns][2], count, sizeof(userinfo_t *), cmputmpidle);
+ qsort(SHM->sorted[ns][3], count, sizeof(userinfo_t *), cmputmpfrom);
+ qsort(SHM->sorted[ns][4], count, sizeof(userinfo_t *), cmputmpfive);
+ qsort(SHM->sorted[ns][5], count, sizeof(userinfo_t *), cmputmpchc);
+ memset(nusers, 0, sizeof(nusers));
+ for (i = 0; i < count; ++i) {
+ uentp = SHM->sorted[ns][0][i];
+ if (uentp && uentp->pid &&
+ 0 < uentp->brc_id && uentp->brc_id < MAX_BOARD)
+ ++nusers[uentp->brc_id - 1];
+ }
+ for (i = 0; i < SHM->Bnumber; ++i)
+ if (SHM->bcache[i].brdname[0] != 0)
+ SHM->bcache[i].nuser = nusers[i];
+ }
+
SHM->currsorted = ns;
SHM->UTMPbusystate = 0;
-
- memset(nusers, 0, sizeof(nusers));
- for (i = 0; i < count; ++i) {
- uentp = SHM->sorted[ns][0][i];
- if (uentp && uentp->pid &&
- 0 < uentp->brc_id && uentp->brc_id < MAX_BOARD)
- ++nusers[uentp->brc_id - 1];
- }
- for (i = 0; i < SHM->Bnumber; ++i)
- if (SHM->bcache[i].brdname[0] != 0)
- SHM->bcache[i].nuser = nusers[i];
}
int utmpsortd(int argc, char **argv)
{
pid_t pid;
int interval; // sleep interval in microsecond(1/10**6)
+ int sortall, counter = 0;
if( fork() > 0 ){
puts("sortutmpd daemonized...");
@@ -273,8 +283,9 @@ int utmpsortd(int argc, char **argv)
}
setproctitle("shmctl utmpsortd");
- if( argc != 2 || (interval = atoi(argv[1])) < 500000 )
+ if( argc < 2 || (interval = atoi(argv[1])) < 500000 )
interval = 1000000; // default to 1 sec
+ sortall = ((argc < 3) ? 1 : atoi(argv[2]));
while( 1 ){
if( (pid = fork()) != 0 ){
@@ -287,8 +298,14 @@ int utmpsortd(int argc, char **argv)
for( i = 0 ; SHM->UTMPbusystate && i < 5 ; ++i )
usleep(300000);
- if( SHM->UTMPneedsort )
- utmpsort();
+ if( SHM->UTMPneedsort ){
+ if( ++counter == sortall ){
+ utmpsort(1);
+ counter = 0;
+ }
+ else
+ utmpsort(0);
+ }
usleep(interval);
}
diff --git a/pttbbs/util/waterball.pl b/pttbbs/util/waterball.pl
index 651372fa..d3fcc343 100644
--- a/pttbbs/util/waterball.pl
+++ b/pttbbs/util/waterball.pl
@@ -1,4 +1,5 @@
#!/usr/bin/perl
+# $Id$
use lib '/home/bbs/bin/';
use LocalVars;
use Time::Local;
@@ -17,7 +18,7 @@ foreach $fndes ( <$JOBSPOOL/water.des.*> ){ #des: userid, mailto, outmode
next if( !$userid );
print "$userid, $mailto, $outmode\n";
`rm -Rf $TMP/water`;
- `mkdir $TMP/water`;
+ `mkdir -p $TMP/water`;
$fnsrc = $fndes;
$fnsrc =~ s/\.des\./\.src\./;