summaryrefslogtreecommitdiffstats
path: root/mbbsd/osdep.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-07-06 01:10:28 +0800
commit1603deaec5d0a94c9a8201b0ba286e8e492a3602 (patch)
treee6405cfd39f8ac166ab7d00752ed6cfa3ac0a928 /mbbsd/osdep.c
parent10bda3e57cad194ac33ccdcd01aee2d935f1544a (diff)
downloadpttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.gz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.bz2
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.lz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.xz
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.tar.zst
pttbbs-1603deaec5d0a94c9a8201b0ba286e8e492a3602.zip
indent
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@415 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/osdep.c')
-rw-r--r--mbbsd/osdep.c74
1 files changed, 41 insertions, 33 deletions
diff --git a/mbbsd/osdep.c b/mbbsd/osdep.c
index 315cdb51..d99395c7 100644
--- a/mbbsd/osdep.c
+++ b/mbbsd/osdep.c
@@ -1,17 +1,19 @@
-/* $Id: osdep.c,v 1.3 2002/06/04 13:08:34 in2 Exp $ */
+/* $Id: osdep.c,v 1.4 2002/07/05 17:10:27 in2 Exp $ */
#include "bbs.h"
-#if __FreeBSD__
+#if __FreeBSD__
#include <kvm.h>
-int cpuload(char *str) {
- double l[3] = {-1, -1, -1};
- if(getloadavg(l, 3) != 3)
+int
+cpuload(char *str)
+{
+ double l[3] = {-1, -1, -1};
+ if (getloadavg(l, 3) != 3)
l[0] = -1;
-
- if(str) {
- if(l[0] != -1)
+
+ if (str) {
+ if (l[0] != -1)
sprintf(str, " %.2f %.2f %.2f", l[0], l[1], l[2]);
else
strcpy(str, " (unknown) ");
@@ -19,19 +21,21 @@ int cpuload(char *str) {
return (int)l[0];
}
-double swapused(long *total, long *used) {
- double percent = -1;
- kvm_t *kd;
+double
+swapused(long *total, long *used)
+{
+ double percent = -1;
+ kvm_t *kd;
struct kvm_swap swapinfo;
- int pagesize;
-
+ int pagesize;
+
kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
- if(kd) {
- if(kvm_getswapinfo(kd, &swapinfo, 1, 0) == 0) {
+ if (kd) {
+ if (kvm_getswapinfo(kd, &swapinfo, 1, 0) == 0) {
pagesize = getpagesize();
*total = swapinfo.ksw_total * pagesize;
*used = swapinfo.ksw_used * pagesize;
- if(*total != 0)
+ if (*total != 0)
percent = (double)*used / (double)*total;
}
kvm_close(kd);
@@ -40,17 +44,19 @@ double swapused(long *total, long *used) {
}
#else
-int cpuload(char *str) {
- double l[3] = {-1, -1, -1};
- FILE *fp;
-
- if((fp = fopen("/proc/loadavg", "r"))) {
- if(fscanf(fp, "%lf %lf %lf", &l[0], &l[1], &l[2]) != 3)
+int
+cpuload(char *str)
+{
+ double l[3] = {-1, -1, -1};
+ FILE *fp;
+
+ if ((fp = fopen("/proc/loadavg", "r"))) {
+ if (fscanf(fp, "%lf %lf %lf", &l[0], &l[1], &l[2]) != 3)
l[0] = -1;
fclose(fp);
}
- if(str) {
- if(l[0] != -1)
+ if (str) {
+ if (l[0] != -1)
sprintf(str, " %.2f %.2f %.2f", l[0], l[1], l[2]);
else
strcpy(str, " (unknown) ");
@@ -58,15 +64,17 @@ int cpuload(char *str) {
return (int)l[0];
}
-double swapused(long *total, long *used) {
- double percent = -1;
- char buf[101];
- FILE *fp;
-
- if((fp = fopen("/proc/meminfo","r"))) {
- while(fgets(buf, 100, fp) && buf[0] != 'S');
- if(sscanf(buf + 6, "%ld %ld", total, used) == 2)
- if(*total != 0)
+double
+swapused(long *total, long *used)
+{
+ double percent = -1;
+ char buf[101];
+ FILE *fp;
+
+ if ((fp = fopen("/proc/meminfo", "r"))) {
+ while (fgets(buf, 100, fp) && buf[0] != 'S');
+ if (sscanf(buf + 6, "%ld %ld", total, used) == 2)
+ if (*total != 0)
percent = (double)*used / (double)*total;
fclose(fp);
}