summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-11 17:02:40 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-11 17:02:40 +0800
commitae5d25576c4dc0b9ac3131c6089610a0912c1dc2 (patch)
tree1abef6a705e21cc3ff45325d0587b81cae5f01fd
parentdd9accca113a8ab310d69af18ce4bdf3c9fde56a (diff)
downloadpttbbs-ae5d25576c4dc0b9ac3131c6089610a0912c1dc2.tar
pttbbs-ae5d25576c4dc0b9ac3131c6089610a0912c1dc2.tar.gz
pttbbs-ae5d25576c4dc0b9ac3131c6089610a0912c1dc2.tar.bz2
pttbbs-ae5d25576c4dc0b9ac3131c6089610a0912c1dc2.tar.lz
pttbbs-ae5d25576c4dc0b9ac3131c6089610a0912c1dc2.tar.xz
pttbbs-ae5d25576c4dc0b9ac3131c6089610a0912c1dc2.tar.zst
pttbbs-ae5d25576c4dc0b9ac3131c6089610a0912c1dc2.zip
*** empty log message ***
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1045 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/.cvsignore2
-rw-r--r--util/boardlist.c105
2 files changed, 107 insertions, 0 deletions
diff --git a/util/.cvsignore b/util/.cvsignore
index 4e206253..431c9ff0 100644
--- a/util/.cvsignore
+++ b/util/.cvsignore
@@ -43,3 +43,5 @@ mandex
shmctl
indexuser
diskstat
+boardlist
+boardlist.pm
diff --git a/util/boardlist.c b/util/boardlist.c
new file mode 100644
index 00000000..b28b2b03
--- /dev/null
+++ b/util/boardlist.c
@@ -0,0 +1,105 @@
+/* $Id: boardlist.c,v 1.1 2003/07/11 09:02:40 in2 Exp $ */
+#include "bbs.h"
+
+static void
+load_uidofgid(const int gid, const int type)
+{
+ boardheader_t *bptr, *currbptr;
+ int n, childcount = 0;
+ currbptr = &bcache[gid - 1];
+ for (n = 0; n < numboards; ++n) {
+ bptr = SHM->bsorted[type][n];
+ if (bptr->brdname[0] == '\0')
+ continue;
+ if (bptr->gid == gid) {
+ if (currbptr == &bcache[gid - 1])
+ currbptr->firstchild[type] = bptr;
+ else {
+ currbptr->next[type] = bptr;
+ currbptr->parent = &bcache[gid - 1];
+ }
+ childcount++;
+ currbptr = bptr;
+ }
+ }
+ bcache[gid - 1].childcount = childcount;
+ if (currbptr == &bcache[gid - 1])
+ currbptr->firstchild[type] = (boardheader_t *) ~ 0;
+ else
+ currbptr->next[type] = (boardheader_t *) ~ 0;
+}
+
+char *skipEscape(char *s)
+{
+ static char buf[TTLEN * 2 + 1];
+ int r, w;
+ for( w = r = 0 ; s[r] != 0 ; ++r ){
+ if( s[r] == '\'' || s[r] == '\\' )
+ buf[w++] = '\\';
+ buf[w++] = s[r];
+ }
+ buf[w++] = 0;
+ return buf;
+}
+
+void dumpclass(int bid)
+{
+ boardheader_t *bptr;
+ int r, w;
+ bptr = &bcache[bid];
+ if (bptr->firstchild[0] == NULL || bptr->childcount <= 0)
+ load_uidofgid(bid + 1, 0); /* 因為這邊 bid從 0開始, 所以再 +1 回來 */
+ printf(" %5d => [\n", bid);
+ for (bptr = bptr->firstchild[0]; bptr != (boardheader_t *) ~ 0;
+ bptr = bptr->next[0]) {
+ if( (bptr->brdattr & (BRD_HIDE | BRD_TOP)) ||
+ (bptr->level && !(bptr->brdattr & BRD_POSTMASK) &&
+ (bptr->level &
+ ~(PERM_BASIC|PERM_CHAT|PERM_PAGE|PERM_POST|PERM_LOGINOK))) )
+ continue;
+
+ printf(" [%5d, '%s', '%s'], \n",
+ (bptr->brdattr & BRD_GROUPBOARD) ? bptr - bcache : -1,
+ bptr->brdname, skipEscape(&bptr->title[7]));
+ }
+ printf(" ],\n");
+
+ bptr = &bcache[bid];
+ for (bptr = bptr->firstchild[0]; bptr != (boardheader_t *) ~ 0;
+ bptr = bptr->next[0]) {
+ if( (bptr->brdattr & (BRD_HIDE | BRD_TOP)) ||
+ (bptr->level && !(bptr->brdattr & BRD_POSTMASK) &&
+ (bptr->level &
+ ~(PERM_BASIC|PERM_CHAT|PERM_PAGE|PERM_POST|PERM_LOGINOK))) )
+ continue;
+
+ printf(" '%d.title' => '%s',\n",
+ bptr - bcache, skipEscape(&bptr->title[7]));
+ if( bptr->brdattr & BRD_GROUPBOARD )
+ dumpclass(bptr - bcache);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ attach_SHM();
+
+ printf("# this is auto-generated perl module from boardlist.c\n"
+ "# please do NOT modify this directly\n"
+ "\n"
+ "package boardlist;\n"
+ "require 5.6;\n"
+ "use Exporter;\n"
+ "$VERSION = '0.1';\n"
+ "use vars qw(%%brd);\n"
+ "\n"
+ "%%brd = (\n");
+ dumpclass(0);
+ printf(");\n"
+ "our(@ISA, @EXPORT);\n"
+ "@ISA = qw(Exporter);\n"
+ "@EXPORT = qw(%%brd);\n"
+ "\n"
+ "1;\n");
+ return 0;
+}