summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2010-11-06 14:04:48 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2010-11-06 14:04:48 +0800
commit44ac9522219c6a17954c01e03d7670c5828611c4 (patch)
treecdf8d08fc06bd5695725d87346af4c17db70dc87
parent2bff4e23f70b50c723be12dfd5f5e615bb75e4c0 (diff)
downloadpttbbs-44ac9522219c6a17954c01e03d7670c5828611c4.tar
pttbbs-44ac9522219c6a17954c01e03d7670c5828611c4.tar.gz
pttbbs-44ac9522219c6a17954c01e03d7670c5828611c4.tar.bz2
pttbbs-44ac9522219c6a17954c01e03d7670c5828611c4.tar.lz
pttbbs-44ac9522219c6a17954c01e03d7670c5828611c4.tar.xz
pttbbs-44ac9522219c6a17954c01e03d7670c5828611c4.tar.zst
pttbbs-44ac9522219c6a17954c01e03d7670c5828611c4.zip
- move memory usage function to osdep
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5207 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--pttbbs/common/osdep/Makefile2
-rw-r--r--pttbbs/include/osdep.h2
-rw-r--r--pttbbs/include/proto.h2
-rw-r--r--pttbbs/mbbsd/cal.c30
-rw-r--r--pttbbs/mbbsd/io.c8
-rw-r--r--pttbbs/sample/pttbbs.conf3
6 files changed, 11 insertions, 36 deletions
diff --git a/pttbbs/common/osdep/Makefile b/pttbbs/common/osdep/Makefile
index 4c47fd97..2eb3974e 100644
--- a/pttbbs/common/osdep/Makefile
+++ b/pttbbs/common/osdep/Makefile
@@ -3,7 +3,7 @@
SRCROOT= ../..
.include "$(SRCROOT)/pttbbs.mk"
-SRCS:= cpuload.c proctitle.c strlcat.c strlcpy.c
+SRCS:= cpuload.c proctitle.c strlcat.c strlcpy.c memusage.c
LIB:= osdep
all: .depend
diff --git a/pttbbs/include/osdep.h b/pttbbs/include/osdep.h
index 594259d8..f1658a34 100644
--- a/pttbbs/include/osdep.h
+++ b/pttbbs/include/osdep.h
@@ -46,4 +46,6 @@ extern void setproctitle(const char* format, ...) GCC_CHECK_FORMAT(1,2);
#endif
extern int cpuload(char *str);
+
+extern void get_memusage(int buflen, char *buf);
#endif
diff --git a/pttbbs/include/proto.h b/pttbbs/include/proto.h
index 3502fb91..d8d935b5 100644
--- a/pttbbs/include/proto.h
+++ b/pttbbs/include/proto.h
@@ -801,4 +801,6 @@ int ParseDate(const char *date, int *year, int *month, int *day);
int ParseDateTime(const char *date, int *year, int *month, int *day,
int *hour, int *min, int *sec);
+int verify_captcha(const char *reason);
+
#endif
diff --git a/pttbbs/mbbsd/cal.c b/pttbbs/mbbsd/cal.c
index 3cb6c308..9c8dc83c 100644
--- a/pttbbs/mbbsd/cal.c
+++ b/pttbbs/mbbsd/cal.c
@@ -623,34 +623,10 @@ p_sysinfo(void)
if (HasUserPerm(PERM_SYSOP)) {
struct rusage ru;
-#ifdef __linux__
- int vmdata=0, vmstk=0;
- FILE * fp;
- char buf[128];
- if ((fp = fopen("/proc/self/status", "r"))) {
- while (fgets(buf, 128, fp)) {
- sscanf(buf, "VmData: %d", &vmdata);
- sscanf(buf, "VmStk: %d", &vmstk);
- }
- fclose(fp);
- }
-#endif
+ char usage[80];
+ get_memusage(sizeof(usage), usage);
getrusage(RUSAGE_SELF, &ru);
- prints("記憶體用量: "
-#ifdef IA32
- "sbrk: %u KB, "
-#endif
-#ifdef __linux__
- "VmData: %d KB, VmStk: %d KB, "
-#endif
- "idrss: %d KB, isrss: %d KB\n",
-#ifdef IA32
- ((unsigned int)sbrk(0) - 0x8048000) / 1024,
-#endif
-#ifdef __linux__
- vmdata, vmstk,
-#endif
- (int)ru.ru_idrss, (int)ru.ru_isrss);
+ prints("記憶體用量: %s\n", usage);
prints("CPU 用量: %ld.%06ldu %ld.%06lds",
(long int)ru.ru_utime.tv_sec,
(long int)ru.ru_utime.tv_usec,
diff --git a/pttbbs/mbbsd/io.c b/pttbbs/mbbsd/io.c
index 36ea44ba..75006790 100644
--- a/pttbbs/mbbsd/io.c
+++ b/pttbbs/mbbsd/io.c
@@ -568,11 +568,9 @@ igetch(void)
#ifdef DEBUG
case Ctrl('Q'):
{
- struct rusage ru;
- getrusage(RUSAGE_SELF, &ru);
- vmsgf("sbrk: %d KB, idrss: %d KB, isrss: %d KB",
- ((int)sbrk(0) - 0x8048000) / 1024,
- (int)ru.ru_idrss, (int)ru.ru_isrss);
+ char usage[80];
+ get_memusage(sizeof(usage), usage);
+ vmsg(usage);
}
continue;
#endif
diff --git a/pttbbs/sample/pttbbs.conf b/pttbbs/sample/pttbbs.conf
index bdf190e0..ecfdf89a 100644
--- a/pttbbs/sample/pttbbs.conf
+++ b/pttbbs/sample/pttbbs.conf
@@ -254,9 +254,6 @@
/* 贈送信箱 */
//#define ADD_EXMAILBOX 100
-/* 如果是在 IA32 底下的話, 可以定義 IA32 以取得記憶體統計資訊 */
-//#define IA32
-
/* 如果 time_t 是 8 bytes的話 (如 X86_64) */
//#define TIMET64