From 83431f2cd992c38eb2fbc3b5095c52034fd2ff3f Mon Sep 17 00:00:00 2001
From: piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>
Date: Fri, 22 Jul 2005 16:57:36 +0000
Subject: sync with PTT1 local modified source: - debug with msgfwderr -
 enlarge thread search range - more verbose board info

git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2942 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
---
 include/pttbbs.conf |  1 +
 mbbsd/mail.c        | 37 ++++++++++++++++++++++++++++++++++---
 mbbsd/read.c        | 23 +++++++++++++++++++----
 sample/pttbbs.conf  |  7 +++++++
 util/shmctl.c       | 34 ++++++++++++++++++++++++++++++----
 5 files changed, 91 insertions(+), 11 deletions(-)

diff --git a/include/pttbbs.conf b/include/pttbbs.conf
index f4ed772a..3017382d 100644
--- a/include/pttbbs.conf
+++ b/include/pttbbs.conf
@@ -7,6 +7,7 @@
 #define BBSUID          9999
 #define BBSGID          99
 
+#define THREAD_SEARCH_RANGE (500)
 #define MAX_USERS 150000
 #define MAX_ACTIVE 4096
 #define MAX_CPULOAD 50
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 59b1c30b..8d863d63 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -120,11 +120,42 @@ mail_id(const char *id, const char *title, const char *src, const char *owner)
 int
 invalidaddr(const char *addr)
 {
+#ifdef DEBUG_FWDADDRERR
+    const char *origaddr = addr;
+    char errmsg[PATHLEN];
+#endif
+
     if (*addr == '\0')
 	return 1;		/* blank */
+
     while (*addr) {
+#ifdef DEBUG_FWDADDRERR
 	if (not_alnum(*addr) && !strchr("[].@-_", *addr))
+	{
+	    int c = (*addr) & 0xff;
+	    clear();
+	    move(2,0);
+	    outs(
+		"�z��J����}���~ (address error)�C \n\n"
+		"�ѩ�̪�\\�h�H�������J���T����}(id��email)��t�η|�P�_���~\n"
+		"���ˬd���X��]�A�ҥH�ڭ̻ݭn���T�����~�^���C\n\n"
+		"�p�G�A�T�ꥴ���F�A�Ъ������L�U���������C\n"
+		"�p�G�A�{���A��J����}�T��O�諸�A�Ч�U�����T���ƻs�_��\n"
+		"�öK�� SYSOP �� PttBug �O�C�������y�����K�`�P��p�C\n\n"
+		ANSI_COLOR(1;33));
+	    sprintf(errmsg, "��l��J��}: [%s]\n"
+		    "���~��m: �� %d �r��: 0x%02X [ %c ]\n", 
+		    origaddr, (int)(addr - origaddr+1), c, c);
+	    outs(errmsg);
+	    outs(ANSI_RESET);
+	    vmsg("�����N���~��");
+	    clear();
 	    return 1;
+	}
+#else
+	if (not_alnum(*addr) && !strchr("[].@-_", *addr))
+	    return 1;
+#endif
 	addr++;
     }
     return 0;
@@ -1607,10 +1638,10 @@ bsmtp(const char *fpath, const char *title, const char *rcpt, int method)
 int
 doforward(const char *direct, const fileheader_t * fh, int mode)
 {
-    static char     address[60];
-    char            fname[500];
+    static char     address[STRLEN] = "";
+    char            fname[PATHLEN];
+    char            genbuf[PATHLEN];
     int             return_no;
-    char            genbuf[200];
 
     if (!address[0])
      	strlcpy(address, cuser.email, sizeof(address));
diff --git a/mbbsd/read.c b/mbbsd/read.c
index 62d9acdb..0e9974e7 100644
--- a/mbbsd/read.c
+++ b/mbbsd/read.c
@@ -313,7 +313,7 @@ static int
 thread(const keeploc_t * locmem, int stypen)
 {
     fileheader_t fh;
-    int     pos = locmem->crs_ln, jump = 200, new_ln;
+    int     pos = locmem->crs_ln, jump = THREAD_SEARCH_RANGE, new_ln;
     int     fd = -1, amatch = -1;
     int     step = (stypen & RS_FORWARD) ? 1 : -1;
     char    *key;
@@ -336,7 +336,8 @@ thread(const keeploc_t * locmem, int stypen)
 		    break;
 		else if( !strncmp(&fh.title[4], key, PROPER_TITLE_LEN) ) {
 		    amatch = new_ln;
-		    jump = 200; /* ���j�M�P�D�D�Ĥ@�g, �s��䤣�� 200 �g�~�� */
+		    jump = THREAD_SEARCH_RANGE; 
+		    /* ���j�M�P�D�D�Ĥ@�g, �s��䤣��h�ֽg�~�� */
 		}
 	    }
             else if( !strncmp(subject(fh.title), key, PROPER_TITLE_LEN) )
@@ -366,7 +367,8 @@ mail_forward(const fileheader_t * fhdr, const char *direct, int mode)
     char            buf[STRLEN];
     char           *p;
 
-    strncpy(buf, direct, sizeof(buf));
+    strncpy(buf, direct, sizeof(buf)-1);
+    buf[sizeof(buf)-1] = 0;
     if ((p = strrchr(buf, '/')))
 	*p = '\0';
     switch (i = doforward(buf, fhdr, mode)) {
@@ -377,7 +379,9 @@ mail_forward(const fileheader_t * fhdr, const char *direct, int mode)
 	vmsg(msg_fwd_err1);
 	break;
     case -2:
+#ifndef DEBUG_FWDADDRERR
 	vmsg(msg_fwd_err2);
+#endif
 	break;
     default:
 	break;
@@ -696,7 +700,8 @@ i_read_key(const onekey_t * rcmdlist, keeploc_t * locmem,
 		mail_forward(&headers[locmem->crs_ln - locmem->top_ln],
 			     currdirect, ch /* == 'U' */ );
 		/* by CharlieL */
-		mode = READ_REDRAW;
+		// mode = READ_REDRAW;
+		return FULLUPDATE;
 	    }
 	    break;
 
@@ -918,9 +923,19 @@ i_read(int cmdmode, const char *direct, void (*dotitle) (),
 		if (bidcache > 0 && !(currmode & (MODE_SELECT | MODE_DIGEST))){
 		    bottom_line = getbtotal(currbid);
 		    num = bottom_line+getbottomtotal(currbid);
+		    if(num == 0)
+		    {
+			recbase = -1;
+		    }
 		}
 		else
+		{
 		    num = get_num_records(currdirect, FHSZ);
+		    if(num == 0)
+		    {
+			recbase = -1;
+		    }
+		}
 
 		if (last_line != num) {
 		    last_line = num;
diff --git a/sample/pttbbs.conf b/sample/pttbbs.conf
index 0d728b61..3ec5fe88 100644
--- a/sample/pttbbs.conf
+++ b/sample/pttbbs.conf
@@ -43,6 +43,9 @@
 /* �̤j�}�O�Ӽ�, �C�ӷ|�α� 6420 bytes �� shared-memory */
 #define	MAX_BOARD	(8192)
 
+/* �D�D���\Ū�j�M�d��A�峹�h�i�յۥ[�j�A���p�߹�į�v�T */
+#define THREAD_SEARCH_RANGE (500)
+
 /* �����H�H�� server, �@��]���ۤv(�Yip: 127.0.0.1)�N�i�H */
 #define	RELAY_SERVER_IP	"127.0.0.1"
 
@@ -79,6 +82,10 @@
 /* �Y�w�q, �Y�{������, �|���� 86400 ���H�� gdb�� attach */
 #define DEBUGSLEEP
 
+/* �Y�w�q, �b��H��}��J���~�ɷ|�����ϥΪ̦^���T�������� */
+/* �o�ӿﶵ�s�b����]�O�]���������ϥΪ̫H�}�������L�̨S�������ݤ��X�{�����~ */
+//#define DEBUG_FWDADDRERR
+
 /* �Y�w�q, �Τ@�ө_�Ǫ��Ʀr���ˬd�ڪ��̷R�M�ݪO�C���O�_���~ */
 #define MEM_CHECK 0x98761234
 
diff --git a/util/shmctl.c b/util/shmctl.c
index 0430f4f1..8629fc4f 100644
--- a/util/shmctl.c
+++ b/util/shmctl.c
@@ -600,10 +600,36 @@ int listbrd(int argc, char **argv)
 
 	/* print details */
 	boardheader_t b = bcache[di-1];
-        printf("brdname(bid):\t%s\n", b.brdname);
-        printf("title:\t%s\n", b.title);
-        printf("BM:\t%s\n", b.BM);
-        printf("brdattr:\t%08x\n", b.brdattr);
+	printf("brdname(bid):\t%s\n", b.brdname);
+	printf("title:\t%s\n", b.title);
+	printf("BM:\t%s\n", b.BM);
+	printf("brdattr:\t%08x ", b.brdattr);
+
+	if (b.brdattr & BRD_NOZAP) printf("BRD_NOZAP ");
+	if (b.brdattr & BRD_NOCOUNT) printf("BRD_NOCOUNT ");
+	if (b.brdattr & BRD_NOTRAN) printf("BRD_NOTRAN ");
+	if (b.brdattr & BRD_GROUPBOARD) printf("BRD_GROUPBOARD ");
+	if (b.brdattr & BRD_HIDE) printf("BRD_HIDE ");
+	if (b.brdattr & BRD_POSTMASK) printf("BRD_POSTMASK ");
+	if (b.brdattr & BRD_ANONYMOUS) printf("BRD_ANONYMOUS ");
+	if (b.brdattr & BRD_DEFAULTANONYMOUS) printf("BRD_DEFAULTANONYMOUS ");
+	if (b.brdattr & BRD_BAD) printf("BRD_BAD ");
+	if (b.brdattr & BRD_VOTEBOARD) printf("BRD_VOTEBOARD ");
+	if (b.brdattr & BRD_WARNEL) printf("BRD_WARNEL ");
+	if (b.brdattr & BRD_TOP) printf("BRD_TOP ");
+	if (b.brdattr & BRD_NORECOMMEND) printf("BRD_NORECOMMEND ");
+	if (b.brdattr & BRD_BLOG) printf("BRD_BLOG ");
+	if (b.brdattr & BRD_BMCOUNT) printf("BRD_BMCOUNT ");
+	if (b.brdattr & BRD_SYMBOLIC) printf("BRD_SYMBOLIC ");
+	if (b.brdattr & BRD_NOBOO) printf("BRD_NOBOO ");
+	if (b.brdattr & BRD_LOCALSAVE) printf("BRD_LOCALSAVE ");
+	if (b.brdattr & BRD_RESTRICTEDPOST) printf("BRD_RESTRICTEDPOST ");
+	if (b.brdattr & BRD_GUESTPOST) printf("BRD_GUESTPOST ");
+#ifdef USE_COOLDOWN
+	if (b.brdattr & BRD_COOLDOWN) printf("BRD_COOLDOWN ");
+#endif
+	printf("\n");
+
         printf("post_limit_posts:\t%d\n", b.post_limit_posts);
         printf("post_limit_logins:\t%d\n", b.post_limit_logins);
         printf("post_limit_regtime:\t%d\n", b.post_limit_regtime);
-- 
cgit v1.2.3