From ae31e19f92e717919ac8e3db9039eb38d2b89aae Mon Sep 17 00:00:00 2001 From: in2 Date: Thu, 7 Mar 2002 15:13:44 +0000 Subject: Initial revision git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/showboard.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 util/showboard.c (limited to 'util/showboard.c') 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 +#include +#include +#include +#include +#include +#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; +} -- cgit v1.2.3