summaryrefslogtreecommitdiffstats
path: root/util/showboard.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-07 23:13:44 +0800
commitae31e19f92e717919ac8e3db9039eb38d2b89aae (patch)
treec70164d6a1852344f44b04a653ae2815043512af /util/showboard.c
downloadpttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.gz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.bz2
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.lz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.xz
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.tar.zst
pttbbs-ae31e19f92e717919ac8e3db9039eb38d2b89aae.zip
Initial revision
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/showboard.c')
-rw-r--r--util/showboard.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/util/showboard.c b/util/showboard.c
new file mode 100644
index 00000000..3801dbb1
--- /dev/null
+++ b/util/showboard.c
@@ -0,0 +1,70 @@
+/* $Id: showboard.c,v 1.1 2002/03/07 15:13:46 in2 Exp $ */
+/* 看板一覽表(sorted) */
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include "config.h"
+#include "pttstruct.h"
+
+boardheader_t allbrd[MAX_BOARD];
+
+int
+board_cmp(a, b)
+ boardheader_t *a, *b;
+{
+ return (strcasecmp(a->brdname, b->brdname));
+}
+
+
+int main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int inf, i, count;
+
+ if (argc < 2)
+ {
+ printf("Usage:\t%s .BOARDS [MAXUSERS]\n", argv[0]);
+ exit(1);
+ }
+
+
+ inf = open(argv[1], O_RDONLY);
+ if (inf == -1)
+ {
+ printf("error open file\n");
+ exit(1);
+ }
+
+/* read in all boards */
+
+ 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] )
+ {
+ i++;
+ }
+ }
+ close(inf);
+
+/* sort them by name */
+ count = i;
+ qsort(allbrd, count, sizeof(boardheader_t), board_cmp);
+
+/* write out the target file */
+
+ printf(
+ "看板名稱 板主 類別 中文敘述\n"
+ "----------------------------------------------------------------------\n");
+ for (i = 0; i < count; i++)
+ {
+ printf("%-13s%-25.25s%s\n", allbrd[i].brdname, allbrd[i].BM, allbrd[i].title);
+ }
+ return 0;
+}