summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-07-08 08:52:38 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-07-08 08:52:38 +0800
commit423bb721d02630666d5689d1fbe0b8040e6fb5e0 (patch)
tree61d13c1903caa51b0b46e0900b7de753cbb33fee
parentda4d3a9cb114eaf7a8ed47757c82a08e19a39919 (diff)
downloadpttbbs-423bb721d02630666d5689d1fbe0b8040e6fb5e0.tar
pttbbs-423bb721d02630666d5689d1fbe0b8040e6fb5e0.tar.gz
pttbbs-423bb721d02630666d5689d1fbe0b8040e6fb5e0.tar.bz2
pttbbs-423bb721d02630666d5689d1fbe0b8040e6fb5e0.tar.lz
pttbbs-423bb721d02630666d5689d1fbe0b8040e6fb5e0.tar.xz
pttbbs-423bb721d02630666d5689d1fbe0b8040e6fb5e0.tar.zst
pttbbs-423bb721d02630666d5689d1fbe0b8040e6fb5e0.zip
add util to write money in SHM back to disk.
SVN keywords. fix bid output in showboard. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2919 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/Makefile2
-rw-r--r--util/showboard.c37
-rw-r--r--util/writemoney.c39
-rw-r--r--util/zero_limits.c4
4 files changed, 55 insertions, 27 deletions
diff --git a/util/Makefile b/util/Makefile
index b4ee84c7..7ff2f3b6 100644
--- a/util/Makefile
+++ b/util/Makefile
@@ -22,7 +22,7 @@ CPROG_WITH_UTIL= \
jungo account birth deluserfile \
expire mandex rmuid horoscope \
openvice parse_news openticket topusr \
- yearsold toplazyBM toplazyBBM \
+ yearsold toplazyBM toplazyBBM writemoney \
reaper buildAnnounce inndBM shmctl \
outmail chkhbf checkmoney merge_dir \
transman angel gamblegive checkdir \
diff --git a/util/showboard.c b/util/showboard.c
index 77bde9f1..41627cfe 100644
--- a/util/showboard.c
+++ b/util/showboard.c
@@ -4,30 +4,24 @@
boardheader_t allbrd[MAX_BOARD];
-int
-board_cmp(a, b)
- boardheader_t *a, *b;
+int board_cmp(boardheader_t *a, boardheader_t *b)
{
return (strcasecmp(a->brdname, b->brdname));
}
-int main(argc, argv)
- int argc;
- char *argv[];
+int main(int argc, char *argv[])
{
int inf, i = 0, detail_i = 0, count;
- if (argc < 2)
- {
+ if (argc < 2) {
printf("Usage:\t%s .BRD [bid]\n", argv[0]);
exit(1);
}
inf = open(argv[1], O_RDONLY);
- if (inf == -1)
- {
+ if (inf == -1) {
printf("error open file\n");
exit(1);
}
@@ -36,10 +30,8 @@ int main(argc, argv)
i = 0;
memset(allbrd, 0, MAX_BOARD * sizeof(boardheader_t));
- while (read(inf, &allbrd[i], sizeof(boardheader_t)) == sizeof(boardheader_t))
- {
- if (allbrd[i].brdname[0] )
- {
+ while (read(inf, &allbrd[i], sizeof(boardheader_t)) == sizeof(boardheader_t)) {
+ if (allbrd[i].brdname[0] ) {
i++;
}
}
@@ -53,10 +45,9 @@ int main(argc, argv)
/* write out the target file */
- if (argc > 2)
- {
+ if (argc > 2) {
detail_i = atoi(argv[2]);
- if (detail_i >= count)
+ if (detail_i < 1 || detail_i > count)
detail_i = -1;
} else {
detail_i = -1;
@@ -66,13 +57,12 @@ int main(argc, argv)
printf(
" ¬ÝªO¦WºÙ ªO¥D Ãþ§O ¤¤¤å±Ô­z\n"
" -----------------------------------------------------------------\n");
- for (i = 0; i < count; i++)
- {
- printf("%4d %-13s%-25.25s%s\n", i, allbrd[i].brdname, allbrd[i].BM, allbrd[i].title);
+ for (i = 0; i < count; i++) {
+ printf("%4d %-13s%-25.25s%s\n", i+1, allbrd[i].brdname, allbrd[i].BM, allbrd[i].title);
}
} else {
/* print details */
- boardheader_t b = allbrd[detail_i];
+ boardheader_t b = allbrd[detail_i - 1];
printf("brdname(bid):\t%s\n", b.brdname);
printf("title:\t%s\n", b.title);
printf("BM:\t%s\n", b.BM);
@@ -92,11 +82,10 @@ int main(argc, argv)
printf("firstchild[1]:\t%d\n", b.firstchild[1]);
/* traverse to find my children */
printf("---- children: ---- \n");
- for (i = 0; i < count; i++)
- {
+ for (i = 0; i < count; i++) {
if(allbrd[i].gid == detail_i)
printf("%4d %-13s%-25.25s%s\n",
- i, allbrd[i].brdname,
+ i+1, allbrd[i].brdname,
allbrd[i].BM, allbrd[i].title);
}
}
diff --git a/util/writemoney.c b/util/writemoney.c
new file mode 100644
index 00000000..0db8d99d
--- /dev/null
+++ b/util/writemoney.c
@@ -0,0 +1,39 @@
+/* $Id$ */
+/* 把 SHM 中的 money 全部寫回 .PASSWDS */
+#define _UTIL_C_
+#include "bbs.h"
+
+time4_t now;
+extern SHM_t *SHM;
+
+int invalid(char *userid) {
+ int i;
+
+ if(!isalpha(userid[0]))
+ return 1;
+
+ for(i = 1; i < IDLEN && userid[i]; i++)
+ if(!isalpha(userid[i]) && !isdigit(userid[i]))
+ return 1;
+ return 0;
+}
+
+int main()
+{
+ int num, pwdfd, money;
+ userec_t u;
+
+ attach_SHM();
+
+ if ((pwdfd = open(fn_passwd, O_WRONLY)) < 0)
+ exit(1);
+ for (num=1;num <= SHM->number;num++) {
+ lseek(pwdfd, sizeof(userec_t) * (num - 1) +
+ ((char *)&u.money - (char *)&u), SEEK_SET);
+ money = moneyof(num);
+ write(pwdfd, &money, sizeof(int));
+ }
+ close(pwdfd);
+
+ return 0;
+}
diff --git a/util/zero_limits.c b/util/zero_limits.c
index 7305abc5..435ed0a3 100644
--- a/util/zero_limits.c
+++ b/util/zero_limits.c
@@ -1,7 +1,7 @@
-#include "bbs.h"
-
+/* $Id$ */
/* Vote limits were added in r2342 which uses previously unused pads.
* This program zero outs those pads. */
+#include "bbs.h"
void transform(boardheader_t *new, boardheader_t *old)
{