summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-11-22 16:03:14 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-11-22 16:03:14 +0800
commit466da544fda3aa6ed86480162b607e1a2ae6ec55 (patch)
treed672bba9618f0a4b51b137a34e2595a3772705d3 /mbbsd
parent4f9a777998858d0aea9ccb5daf390a54fece4923 (diff)
downloadpttbbs-466da544fda3aa6ed86480162b607e1a2ae6ec55.tar
pttbbs-466da544fda3aa6ed86480162b607e1a2ae6ec55.tar.gz
pttbbs-466da544fda3aa6ed86480162b607e1a2ae6ec55.tar.bz2
pttbbs-466da544fda3aa6ed86480162b607e1a2ae6ec55.tar.lz
pttbbs-466da544fda3aa6ed86480162b607e1a2ae6ec55.tar.xz
pttbbs-466da544fda3aa6ed86480162b607e1a2ae6ec55.tar.zst
pttbbs-466da544fda3aa6ed86480162b607e1a2ae6ec55.zip
fix assess bug
some comments git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2348 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/args.c2
-rw-r--r--mbbsd/assess.c3
-rw-r--r--mbbsd/edit.c17
-rw-r--r--mbbsd/file.c36
-rw-r--r--mbbsd/screen.c6
-rw-r--r--mbbsd/stuff.c47
6 files changed, 100 insertions, 11 deletions
diff --git a/mbbsd/args.c b/mbbsd/args.c
index bf36827b..32156517 100644
--- a/mbbsd/args.c
+++ b/mbbsd/args.c
@@ -1,4 +1,4 @@
-/* $Id: args.c,v 1.8 2003/06/26 01:04:03 kcwu Exp $ */
+/* $Id$ */
#include "bbs.h"
#ifdef HAVE_SETPROCTITLE
diff --git a/mbbsd/assess.c b/mbbsd/assess.c
index ee89e436..35badc8c 100644
--- a/mbbsd/assess.c
+++ b/mbbsd/assess.c
@@ -21,7 +21,8 @@ int inc_##_attr(char *userid, int num) \
if( uid > 0 ){ \
userinfo_t *uinfo = search_ulist(uid); \
inc(&uinfo->_attr, num); \
- inc(&xuser._attr, num); \
+ if (uinfo != NULL) \
+ inc(&xuser._attr, num); \
passwd_update(uid, &xuser); \
return xuser._attr; }\
return 0;\
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index 8fda0c95..a115c214 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -95,13 +95,13 @@ static char *BIG_mode[13] = {
static char *table[8] = {
"xw|r}uqtzs{",
- "",
+ "",
"w",
- "x",
+ "x",
"xwruqt~s",
- "",
+ "䢣~ޢ",
"w",
- "x"
+ "x"
};
static char *table_mode[6] = {
@@ -110,7 +110,7 @@ static char *table_mode[6] = {
"q",
"",
"",
- ""
+ ""
};
@@ -694,7 +694,9 @@ erase_tmpbuf()
unlink(fp_tmpbuf);
}
-/* s边۰ʳƥ */
+/**
+ * s边۰ʳƥ
+ */
void
auto_backup()
{
@@ -717,6 +719,9 @@ auto_backup()
}
}
+/**
+ * ^s边ƥ
+ */
void
restore_backup()
{
diff --git a/mbbsd/file.c b/mbbsd/file.c
index 2c9374bf..e1422713 100644
--- a/mbbsd/file.c
+++ b/mbbsd/file.c
@@ -2,6 +2,14 @@
#include "bbs.h"
+/**
+ * file.c 是針對以"行"為單位的檔案所定義的一些 operation。
+ **/
+
+/**
+ * 傳回 file 檔的行數
+ * @param file
+ */
int file_count_line(char *file)
{
FILE *fp;
@@ -9,13 +17,22 @@ int file_count_line(char *file)
char buf[200];
if ((fp = fopen(file, "r"))) {
- while (fgets(buf, sizeof(buf), fp))
+ while (fgets(buf, sizeof(buf), fp)) {
+ if (strchr(buf, '\n') == NULL)
+ continue;
count++;
+ }
fclose(fp);
}
return count;
}
+/**
+ * 將 string append 到檔案 file 後端
+ * @param file 要被 append 的檔
+ * @param string
+ * @return 成功傳回 0,失敗傳回 -1。
+ */
int file_append_line(char *file, char *string)
{
FILE *fp;
@@ -29,7 +46,12 @@ int file_append_line(char *file, char *string)
}
#ifndef _BBS_UTIL_C_
-/* Rename() is in kaede.c but not linked to util/ */
+/**
+ * 從檔案 file 中刪除 prefix 為 string 的每一行。(小心 race)
+ * @param file
+ * @param string
+ * @param case_sensitive 字串比對是否 case sensitive
+ */
int file_delete_line(char *file, char *string, int case_sensitive)
{
FILE *fp, *nfp = NULL;
@@ -56,6 +78,9 @@ int file_delete_line(char *file, char *string, int case_sensitive)
}
#endif
+/**
+ * 傳回檔案 file 中是否有 string 這個字串。
+ */
int file_exist_record(char *file, char *string)
{
FILE *fp;
@@ -72,6 +97,13 @@ int file_exist_record(char *file, char *string)
return 0;
}
+/**
+ * 對每一筆 record 做 func 這件事。
+ * @param file
+ * @param func 處理每筆 record 的 handler,為一 function pointer。
+ * 第一個參數是檔案中的一行,第二個參數為 info。
+ * @param info 一個額外的參數。
+ */
int file_foreach_entry(char *file, int (*func)(char *, int), int info)
{
char line[80];
diff --git a/mbbsd/screen.c b/mbbsd/screen.c
index a58be429..e0b55ddb 100644
--- a/mbbsd/screen.c
+++ b/mbbsd/screen.c
@@ -241,6 +241,9 @@ clrtoeol()
slp->len = cur_col;
}
+/**
+ * 從目前的行數(scr_ln) clear 到第 line 行
+ */
void
clrtoline(int line)
{
@@ -257,6 +260,9 @@ clrtoline(int line)
}
}
+/**
+ * 從目前的行數(scr_ln) clear 到底
+ */
inline void
clrtobot()
{
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 608c1384..a40995dc 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -92,6 +92,10 @@ setdirpath(char *buf, char *direct, char *fname)
strcpy(direct + 1, fname);
}
+/**
+ * w峹D titleAǦ^DDСC
+ * @param title
+ */
char *
subject(char *title)
{
@@ -137,6 +141,10 @@ strstr_lower(char *str, char *tag)
return strstr(buf, tag);
}
+/**
+ * r buf ݦhlťաC
+ * @param buf
+ */
void
trim(char *buf)
{ /* remove trailing space */
@@ -152,7 +160,10 @@ trim(char *buf)
}
}
-/* remove last '\n' */
+/**
+ * src '\n' ç令 '\0'
+ * @param src
+ */
void chomp(char *src)
{
while(*src){
@@ -262,6 +273,11 @@ userid_is_BM(char *userid, char *list)
/* ----------------------------------------------------- */
/* ɮˬdơGɮסBؿBݩ */
/* ----------------------------------------------------- */
+
+/**
+ * Ǧ^ fname ɮפjp
+ * @param fname
+ */
off_t
dashs(char *fname)
{
@@ -273,6 +289,10 @@ dashs(char *fname)
return -1;
}
+/**
+ * Ǧ^ fname mtime
+ * @param fname
+ */
time_t
dasht(char *fname)
{
@@ -284,6 +304,10 @@ dasht(char *fname)
return -1;
}
+/**
+ * Ǧ^ fname O_ symbolic link
+ * @param fname
+ */
int
dashl(char *fname)
{
@@ -292,6 +316,10 @@ dashl(char *fname)
return (lstat(fname, &st) == 0 && S_ISLNK(st.st_mode));
}
+/**
+ * Ǧ^ fname O_@몺ɮ
+ * @param fname
+ */
int
dashf(char *fname)
{
@@ -300,6 +328,10 @@ dashf(char *fname)
return (stat(fname, &st) == 0 && S_ISREG(st.st_mode));
}
+/**
+ * Ǧ^ fname O_ؿ
+ * @param fname
+ */
int
dashd(char *fname)
{
@@ -506,6 +538,15 @@ vmsg(const char *fmt,...)
return vmsg_lines(b_lines, msg);
}
+/**
+ * q y C}l show X filename ɮפe lines C
+ * mode output ҦAѼƦP strip_ansiC
+ * @param filename
+ * @param x
+ * @param lines
+ * @param mode
+ * @return ѶǦ^ 0A_h 1C
+ */
int
show_file(char *filename, int y, int lines, int mode)
{
@@ -585,6 +626,10 @@ search_num(int ch, int max)
return clen - 1;
}
+/**
+ * bW show X "ititlej"
+ * @param title
+ */
void
stand_title(char *title)
{