├── .gitattributes ├── maple ├── make_export.conf.in ├── acct.c ├── bbsd.c ├── edit.c ├── gem.c ├── mail.c ├── menu.c ├── more.c ├── post.c ├── talk.c ├── board.c ├── cache.c ├── pfterm.c ├── pmore.c ├── socket.c ├── visio.c ├── window.c ├── xchatd.c ├── xover.c ├── popupmenu.c ├── myfavorite.c ├── CMakeLists.txt └── Makefile ├── VERSION ├── so ├── bj.c ├── bank.c ├── chat.c ├── list.c ├── mine.c ├── pip.c ├── shop.c ├── song.c ├── vote.c ├── xyz.c ├── admin.c ├── aloha.c ├── ascii.c ├── banmail.c ├── bbslua.c ├── bbsruby.c ├── brdstat.c ├── contact.c ├── gamef.c ├── innbbs.c ├── mailgem.c ├── observe.c ├── passwd.c ├── pnote.c ├── violate.c ├── adminutil.c ├── chatmenu.c ├── guessnum.c ├── newboard.c ├── personal.c ├── showvote.c ├── classtable2.c ├── memorandum.c ├── cleanrecommend.c ├── so.cmake ├── so.mk ├── pipfun.c ├── Makefile ├── same_mail.c ├── CMakeLists.txt └── bbsluaext.c ├── CHANGELOG ├── COPYRIGHT ├── lib ├── acl.c ├── dns.c ├── shm.c ├── acct.c ├── date.c ├── file.c ├── header.c ├── mime.c ├── passwd.c ├── record.c ├── string.c ├── attr_lib.c ├── xwrite.c ├── CMakeLists.txt ├── Makefile ├── radix32.c ├── isnot.c ├── proc.c ├── logger.c ├── splay.c ├── xsort.c └── dl_lib.c ├── util ├── acpro.c ├── match.c ├── outgo.c ├── redir.c ├── Makefile ├── account.c ├── addpost.c ├── addsong.c ├── backup.c ├── bbsmail.c ├── brdmail.c ├── brdstat.c ├── camera.c ├── counter.c ├── expire.c ├── makeUSR.c ├── makefw.c ├── msgall.c ├── reaper.c ├── showBRD.c ├── topusr.c ├── tranBRD.c ├── tranufo.c ├── userno.c ├── acl-sort.c ├── bmw-dump.c ├── brdcheck.c ├── checkemail.c ├── clean_acl.c ├── gem-check.c ├── gem-index.c ├── hdr-dump.c ├── mailexpire.c ├── mailpost.c ├── mailtoall.c ├── makeusrno.c ├── poststat.c ├── remboxdir.c ├── resetvmail.c ├── restorebrd.c ├── restoregem.c ├── restoreusr.c ├── rmbadmail.c ├── showACCT.c ├── stopperm.c ├── template.c ├── transacct.c ├── utmp-dump.c ├── dump-brdstat.c ├── classtable_alert.c ├── ipconv.c ├── readUSR.c ├── readBENZ.c ├── readFRIENZ.c ├── CMakeLists.txt └── base64encode.c ├── include ├── bbs.h ├── hdr.h ├── perm.h ├── pip.h ├── battr.h ├── config.h ├── cppdef.h ├── global.h ├── modes.h ├── struct.h ├── theme.h ├── xchat.h ├── pipstruct.h ├── global_def.h ├── splay.h ├── popup.h ├── skin.h ├── attr.h ├── bbs_script.h ├── logger.h ├── timetype.h ├── dns.h ├── fnv_hash.h ├── so.h ├── pfterm.h ├── attrdef.h └── proto.h ├── innbbsd ├── Makefile ├── bbslib.c ├── bbslink.c ├── channel.c ├── history.c ├── nocem.c ├── nocem.h ├── convcode.c ├── inntobbs.c ├── innbbsconf.h ├── rec_article.c ├── inntobbs.h ├── CMakeLists.txt ├── bbslib.h └── nntp.h ├── sample ├── crontab.in ├── dreambbs.conf ├── xchatd.service.in ├── bbsd.service.in ├── startbbs.service.in ├── bbs-sshd.service.in ├── bbsd_unixsocket.service.in ├── CMakeLists.txt └── Makefile ├── scripts ├── top.sh.in ├── start.sh.in ├── clean.sh.in ├── Makefile ├── checkACCT.sh.in ├── wsproxy │ ├── README.md │ └── wsproxy.lua ├── CMakeLists.txt ├── checkbrdDIR.sh.in ├── checkusrDIR.sh.in └── verinfo.sh ├── test ├── lib_str_decode.c ├── lib_str_xor.c ├── lib_f_rm.c ├── lib_f_mv.c ├── lib_f_cp.c ├── lib_str_pat.c ├── test.h ├── lib_xsort.c ├── testsize.c ├── CMakeLists.txt ├── lib_from_parse.c ├── testscript.sh ├── lib_splay.c └── Makefile ├── make_export.conf.in ├── .github └── workflows │ ├── sync_wiki.yml │ ├── sync_with_wiki.yml │ ├── sent_repo_dispatch.yml │ └── build.yml ├── .gitignore ├── Makefile ├── README.md ├── dreambbs.mk └── CMakeLists.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | * encoding=big5 2 | -------------------------------------------------------------------------------- /maple/make_export.conf.in: -------------------------------------------------------------------------------- 1 | #cmakedefine01 NO_SO 2 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/VERSION -------------------------------------------------------------------------------- /so/bj.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/bj.c -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/CHANGELOG -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/COPYRIGHT -------------------------------------------------------------------------------- /lib/acl.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/acl.c -------------------------------------------------------------------------------- /lib/dns.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/dns.c -------------------------------------------------------------------------------- /lib/shm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/shm.c -------------------------------------------------------------------------------- /so/bank.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/bank.c -------------------------------------------------------------------------------- /so/chat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/chat.c -------------------------------------------------------------------------------- /so/list.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/list.c -------------------------------------------------------------------------------- /so/mine.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/mine.c -------------------------------------------------------------------------------- /so/pip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/pip.c -------------------------------------------------------------------------------- /so/shop.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/shop.c -------------------------------------------------------------------------------- /so/song.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/song.c -------------------------------------------------------------------------------- /so/vote.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/vote.c -------------------------------------------------------------------------------- /so/xyz.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/xyz.c -------------------------------------------------------------------------------- /lib/acct.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/acct.c -------------------------------------------------------------------------------- /lib/date.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/date.c -------------------------------------------------------------------------------- /lib/file.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/file.c -------------------------------------------------------------------------------- /lib/header.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/header.c -------------------------------------------------------------------------------- /lib/mime.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/mime.c -------------------------------------------------------------------------------- /lib/passwd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/passwd.c -------------------------------------------------------------------------------- /lib/record.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/record.c -------------------------------------------------------------------------------- /lib/string.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/string.c -------------------------------------------------------------------------------- /maple/acct.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/acct.c -------------------------------------------------------------------------------- /maple/bbsd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/bbsd.c -------------------------------------------------------------------------------- /maple/edit.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/edit.c -------------------------------------------------------------------------------- /maple/gem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/gem.c -------------------------------------------------------------------------------- /maple/mail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/mail.c -------------------------------------------------------------------------------- /maple/menu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/menu.c -------------------------------------------------------------------------------- /maple/more.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/more.c -------------------------------------------------------------------------------- /maple/post.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/post.c -------------------------------------------------------------------------------- /maple/talk.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/talk.c -------------------------------------------------------------------------------- /so/admin.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/admin.c -------------------------------------------------------------------------------- /so/aloha.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/aloha.c -------------------------------------------------------------------------------- /so/ascii.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/ascii.c -------------------------------------------------------------------------------- /so/banmail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/banmail.c -------------------------------------------------------------------------------- /so/bbslua.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/bbslua.c -------------------------------------------------------------------------------- /so/bbsruby.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/bbsruby.c -------------------------------------------------------------------------------- /so/brdstat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/brdstat.c -------------------------------------------------------------------------------- /so/contact.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/contact.c -------------------------------------------------------------------------------- /so/gamef.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/gamef.c -------------------------------------------------------------------------------- /so/innbbs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/innbbs.c -------------------------------------------------------------------------------- /so/mailgem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/mailgem.c -------------------------------------------------------------------------------- /so/observe.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/observe.c -------------------------------------------------------------------------------- /so/passwd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/passwd.c -------------------------------------------------------------------------------- /so/pnote.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/pnote.c -------------------------------------------------------------------------------- /so/violate.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/violate.c -------------------------------------------------------------------------------- /util/acpro.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/acpro.c -------------------------------------------------------------------------------- /util/match.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/match.c -------------------------------------------------------------------------------- /util/outgo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/outgo.c -------------------------------------------------------------------------------- /util/redir.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/redir.c -------------------------------------------------------------------------------- /include/bbs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/bbs.h -------------------------------------------------------------------------------- /include/hdr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/hdr.h -------------------------------------------------------------------------------- /include/perm.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/perm.h -------------------------------------------------------------------------------- /include/pip.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/pip.h -------------------------------------------------------------------------------- /lib/attr_lib.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/lib/attr_lib.c -------------------------------------------------------------------------------- /maple/board.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/board.c -------------------------------------------------------------------------------- /maple/cache.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/cache.c -------------------------------------------------------------------------------- /maple/pfterm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/pfterm.c -------------------------------------------------------------------------------- /maple/pmore.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/pmore.c -------------------------------------------------------------------------------- /maple/socket.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/socket.c -------------------------------------------------------------------------------- /maple/visio.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/visio.c -------------------------------------------------------------------------------- /maple/window.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/window.c -------------------------------------------------------------------------------- /maple/xchatd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/xchatd.c -------------------------------------------------------------------------------- /maple/xover.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/xover.c -------------------------------------------------------------------------------- /so/adminutil.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/adminutil.c -------------------------------------------------------------------------------- /so/chatmenu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/chatmenu.c -------------------------------------------------------------------------------- /so/guessnum.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/guessnum.c -------------------------------------------------------------------------------- /so/newboard.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/newboard.c -------------------------------------------------------------------------------- /so/personal.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/personal.c -------------------------------------------------------------------------------- /so/showvote.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/showvote.c -------------------------------------------------------------------------------- /util/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/Makefile -------------------------------------------------------------------------------- /util/account.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/account.c -------------------------------------------------------------------------------- /util/addpost.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/addpost.c -------------------------------------------------------------------------------- /util/addsong.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/addsong.c -------------------------------------------------------------------------------- /util/backup.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/backup.c -------------------------------------------------------------------------------- /util/bbsmail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/bbsmail.c -------------------------------------------------------------------------------- /util/brdmail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/brdmail.c -------------------------------------------------------------------------------- /util/brdstat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/brdstat.c -------------------------------------------------------------------------------- /util/camera.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/camera.c -------------------------------------------------------------------------------- /util/counter.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/counter.c -------------------------------------------------------------------------------- /util/expire.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/expire.c -------------------------------------------------------------------------------- /util/makeUSR.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/makeUSR.c -------------------------------------------------------------------------------- /util/makefw.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/makefw.c -------------------------------------------------------------------------------- /util/msgall.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/msgall.c -------------------------------------------------------------------------------- /util/reaper.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/reaper.c -------------------------------------------------------------------------------- /util/showBRD.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/showBRD.c -------------------------------------------------------------------------------- /util/topusr.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/topusr.c -------------------------------------------------------------------------------- /util/tranBRD.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/tranBRD.c -------------------------------------------------------------------------------- /util/tranufo.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/tranufo.c -------------------------------------------------------------------------------- /util/userno.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/userno.c -------------------------------------------------------------------------------- /include/battr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/battr.h -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/config.h -------------------------------------------------------------------------------- /include/cppdef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/cppdef.h -------------------------------------------------------------------------------- /include/global.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/global.h -------------------------------------------------------------------------------- /include/modes.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/modes.h -------------------------------------------------------------------------------- /include/struct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/struct.h -------------------------------------------------------------------------------- /include/theme.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/theme.h -------------------------------------------------------------------------------- /include/xchat.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/xchat.h -------------------------------------------------------------------------------- /innbbsd/Makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/Makefile -------------------------------------------------------------------------------- /innbbsd/bbslib.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/bbslib.c -------------------------------------------------------------------------------- /innbbsd/bbslink.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/bbslink.c -------------------------------------------------------------------------------- /innbbsd/channel.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/channel.c -------------------------------------------------------------------------------- /innbbsd/history.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/history.c -------------------------------------------------------------------------------- /innbbsd/nocem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/nocem.c -------------------------------------------------------------------------------- /innbbsd/nocem.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/nocem.h -------------------------------------------------------------------------------- /maple/popupmenu.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/popupmenu.c -------------------------------------------------------------------------------- /sample/crontab.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/sample/crontab.in -------------------------------------------------------------------------------- /scripts/top.sh.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/scripts/top.sh.in -------------------------------------------------------------------------------- /so/classtable2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/classtable2.c -------------------------------------------------------------------------------- /so/memorandum.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/memorandum.c -------------------------------------------------------------------------------- /util/acl-sort.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/acl-sort.c -------------------------------------------------------------------------------- /util/bmw-dump.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/bmw-dump.c -------------------------------------------------------------------------------- /util/brdcheck.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/brdcheck.c -------------------------------------------------------------------------------- /util/checkemail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/checkemail.c -------------------------------------------------------------------------------- /util/clean_acl.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/clean_acl.c -------------------------------------------------------------------------------- /util/gem-check.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/gem-check.c -------------------------------------------------------------------------------- /util/gem-index.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/gem-index.c -------------------------------------------------------------------------------- /util/hdr-dump.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/hdr-dump.c -------------------------------------------------------------------------------- /util/mailexpire.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/mailexpire.c -------------------------------------------------------------------------------- /util/mailpost.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/mailpost.c -------------------------------------------------------------------------------- /util/mailtoall.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/mailtoall.c -------------------------------------------------------------------------------- /util/makeusrno.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/makeusrno.c -------------------------------------------------------------------------------- /util/poststat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/poststat.c -------------------------------------------------------------------------------- /util/remboxdir.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/remboxdir.c -------------------------------------------------------------------------------- /util/resetvmail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/resetvmail.c -------------------------------------------------------------------------------- /util/restorebrd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/restorebrd.c -------------------------------------------------------------------------------- /util/restoregem.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/restoregem.c -------------------------------------------------------------------------------- /util/restoreusr.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/restoreusr.c -------------------------------------------------------------------------------- /util/rmbadmail.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/rmbadmail.c -------------------------------------------------------------------------------- /util/showACCT.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/showACCT.c -------------------------------------------------------------------------------- /util/stopperm.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/stopperm.c -------------------------------------------------------------------------------- /util/template.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/template.c -------------------------------------------------------------------------------- /util/transacct.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/transacct.c -------------------------------------------------------------------------------- /util/utmp-dump.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/utmp-dump.c -------------------------------------------------------------------------------- /include/pipstruct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/pipstruct.h -------------------------------------------------------------------------------- /innbbsd/convcode.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/convcode.c -------------------------------------------------------------------------------- /innbbsd/inntobbs.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/inntobbs.c -------------------------------------------------------------------------------- /maple/myfavorite.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/maple/myfavorite.c -------------------------------------------------------------------------------- /so/cleanrecommend.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/so/cleanrecommend.c -------------------------------------------------------------------------------- /util/dump-brdstat.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/dump-brdstat.c -------------------------------------------------------------------------------- /include/global_def.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/include/global_def.h -------------------------------------------------------------------------------- /innbbsd/innbbsconf.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/innbbsconf.h -------------------------------------------------------------------------------- /innbbsd/rec_article.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/innbbsd/rec_article.c -------------------------------------------------------------------------------- /sample/dreambbs.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/sample/dreambbs.conf -------------------------------------------------------------------------------- /test/lib_str_decode.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/test/lib_str_decode.c -------------------------------------------------------------------------------- /util/classtable_alert.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ccns/dreambbs/HEAD/util/classtable_alert.c -------------------------------------------------------------------------------- /scripts/start.sh.in: -------------------------------------------------------------------------------- 1 | if [ "${BBSHOME}" = "" ]; then BBSHOME="@BBSHOME@"; fi 2 | if [ "${BBSVER}" = "" ]; then BBSVER="@BBSVER@"; fi 3 | "${BBSHOME}"/bin"${BBSVER}"/camera 4 | "${BBSHOME}"/bin"${BBSVER}"/acpro 5 | "${BBSHOME}"/bin"${BBSVER}"/makefw 6 | -------------------------------------------------------------------------------- /test/lib_str_xor.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include "dao.h" 6 | #include "test.h" 7 | 8 | int main(void) 9 | { 10 | char t[]="Hello"; 11 | str_xor(t, "he3"); 12 | assert(!strcmp(t, " e_lo")); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /test/lib_f_rm.c: -------------------------------------------------------------------------------- 1 | #include "bbs.h" 2 | #include "test.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | if (argc!=2) { 7 | exit(2); 8 | } 9 | char *source = argv[1]; 10 | fprintf(stderr, "\x1b[1;33mRemoving %s ....\x1b[0m\n", source); 11 | assert(!f_rm(source)); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /lib/xwrite.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include "dao.h" 5 | 6 | int xwrite(int fd, const char *data, int size) 7 | { 8 | while (size > 0) 9 | { 10 | int cc = write(fd, data, size); 11 | if (cc < 0) 12 | return cc; 13 | data += cc; 14 | size -= cc; 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /test/lib_f_mv.c: -------------------------------------------------------------------------------- 1 | #include "bbs.h" 2 | #include "test.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | if (argc!=3) { 7 | exit(2); 8 | } 9 | char *source = argv[1]; 10 | char *destination = argv[2]; 11 | fprintf(stderr, "\x1b[1;33mMoving %s to %s ....\x1b[0m\n", source, destination); 12 | assert(!f_mv(source, destination)); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /test/lib_f_cp.c: -------------------------------------------------------------------------------- 1 | #include "bbs.h" 2 | #include "test.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | if (argc!=3) { 7 | exit(2); 8 | } 9 | char *source = argv[1]; 10 | char *destination = argv[2]; 11 | fprintf(stderr, "\x1b[1;33mCopying %s to %s ....\x1b[0m\n", source, destination); 12 | assert(!f_cp(source, destination, 0600)); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /sample/xchatd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DreamBBS Chatroom Daemon 3 | After=syslog.target network.target remote-fs.target nss-lookup.target startbbs.service 4 | Requires=startbbs.service 5 | 6 | [Service] 7 | User=@BBSUSR@ 8 | Group=@BBSGROUP@ 9 | Type=forking 10 | PIDFile=@BBSHOME@/run/chat.pid 11 | ExecStart=@BBSHOME@/bin/xchatd 12 | ExecStop=/bin/kill -s QUIT $MAINPID 13 | Restart=on-failure 14 | RestartSec=42s 15 | PrivateTmp=true 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /sample/bbsd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DreamBBS Telnet server 3 | After=syslog.target network.target remote-fs.target nss-lookup.target startbbs.service 4 | Requires=startbbs.service 5 | Wants=xchatd.service 6 | 7 | [Service] 8 | Type=forking 9 | PIDFile=@BBSHOME@/run/bbs.pid 10 | ExecStart=@BBSHOME@/bin/bbsd 23 11 | ExecStop=/bin/kill -s TERM $MAINPID 12 | Restart=on-failure 13 | RestartSec=42s 14 | KillMode=process 15 | PrivateTmp=true 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /test/lib_str_pat.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include "dao.h" 5 | #include "test.h" 6 | 7 | #define STR_PAT(x, y) (void) (printf("<%s, %s> : %d\n", x, y, str_pat(x, y)), assert(str_pat(x, y))) 8 | 9 | int main(void) 10 | { 11 | STR_PAT("a", "a*"); 12 | STR_PAT("abc", "a*"); 13 | STR_PAT("abc", "a*c"); 14 | STR_PAT("abc", "a?c"); 15 | STR_PAT("level", "l*l"); 16 | STR_PAT("level", "l*e*l"); 17 | STR_PAT("lelelelel", "l*l*l*l"); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /sample/startbbs.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Start DreamBBS Telnet server 3 | After=syslog.target network.target remote-fs.target nss-lookup.target 4 | 5 | [Service] 6 | User=@BBSUSR@ 7 | Group=@BBSGROUP@ 8 | Type=oneshot 9 | ## if set User and Group as bbs, then we don't need sudo commands 10 | ExecStart=@BBSHOME@/bin/camera 11 | ExecStart=@BBSHOME@/bin/account 12 | ExecStart=@BBSHOME@/bin/acpro 13 | ExecStart=@BBSHOME@/bin/makefw 14 | PrivateTmp=true 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /sample/bbs-sshd.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=bbs-sshd, an SSH-to-telnet-over-UNIX-socket proxy (https://github.com/ptt/bbs-sshd) 3 | After=syslog.target network.target remote-fs.target nss-lookup.target 4 | 5 | [Service] 6 | Type=forking 7 | PIDFile=@BBSHOME@/run/bbs-sshd.pid 8 | ExecStart=@BBS_SSHD_ROOT@/target/release/bbs-sshd -f @BBS_SSHD_ROOT@/bbs-sshd.toml 9 | ExecStop=/bin/kill -s TERM $MAINPID 10 | Restart=on-failure 11 | RestartSec=42s 12 | KillMode=process 13 | PrivateTmp=true 14 | 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /util/ipconv.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | 5 | int main(int argc, char **argv) 6 | { 7 | FILE *fp; 8 | unsigned int a; 9 | 10 | if (argc !=2) 11 | return 2; 12 | 13 | fp = fopen(argv[1], "r"); 14 | if (fp) 15 | { 16 | do 17 | { 18 | fscanf(fp, "%x", &a); 19 | printf("%u.%u.%u.%u\n", (a&0xFF), (a&0x0000FF00)>>8, (a&0x00FF0000)>>16, (a&0xFF000000)>>24); 20 | } while (!feof(fp)); 21 | fclose(fp); 22 | } 23 | return !fp; 24 | } 25 | -------------------------------------------------------------------------------- /make_export.conf.in: -------------------------------------------------------------------------------- 1 | #undef BBSUSR 2 | #define BBSUSR "@BBSUSR@" 3 | #undef BBSGROUP 4 | #define BBSGROUP "@BBSGROUP@" 5 | #undef WWWGROUP 6 | #define WWWGROUP "@WWWGROUP@" 7 | #undef BBSUID 8 | #define BBSUID @BBSUID@ 9 | #undef BBSGID 10 | #define BBSGID @BBSGID@ 11 | #undef WWWGID 12 | #define WWWGID @WWWGID@ 13 | #undef BBSHOME 14 | #define BBSHOME "@BBSHOME@" 15 | #undef BBSUTCZONE 16 | #define BBSUTCZONE "@BBSUTCZONE@" 17 | #undef MRB_CONFIG 18 | #define MRB_CONFIG "@MRB_CONFIG@" 19 | #undef BBS_SSHD_ROOT 20 | #define BBS_SSHD_ROOT "@BBS_SSHD_ROOT@" 21 | -------------------------------------------------------------------------------- /sample/bbsd_unixsocket.service.in: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=DreamBBS Unixsocket server 3 | After=syslog.target network.target remote-fs.target nss-lookup.target startbbs.service 4 | Requires=startbbs.service 5 | Wants=xchatd.service bbs-sshd.service 6 | 7 | [Service] 8 | User=@BBSUSR@ 9 | Group=@BBSGROUP@ 10 | Type=forking 11 | PIDFile=@BBSHOME@/run/bbs_unixsocket.pid 12 | ExecStart=@BBSHOME@/bin/bbsd -u run/bbsd.socket 13 | ExecStop=/bin/kill -s TERM $MAINPID 14 | Restart=on-failure 15 | RestartSec=42s 16 | KillMode=process 17 | PrivateTmp=true 18 | 19 | [Install] 20 | WantedBy=multi-user.target 21 | -------------------------------------------------------------------------------- /include/splay.h: -------------------------------------------------------------------------------- 1 | #ifndef SPLAY_H 2 | #define SPLAY_H 3 | 4 | typedef struct SplayNode 5 | { 6 | void *data; 7 | struct SplayNode *left; 8 | struct SplayNode *right; 9 | } SplayNode; 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | SplayNode *splay_in(SplayNode *top, void *data, int (*compare)(const void *x, const void *y)); 16 | void splay_out(const SplayNode * top, void (*data_out) (const void *data, FILE *fp), FILE *fp); 17 | void splay_free(SplayNode * top, void (*data_free) (void *data)); 18 | 19 | #ifdef __cplusplus 20 | } /* extern "C" */ 21 | #endif 22 | 23 | #endif /* SPLAY_H */ 24 | -------------------------------------------------------------------------------- /scripts/clean.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | BBSHOME=${BBSHOME:-"@BBSHOME@"} 3 | declare -i a 4 | #declare -i b 5 | #declare -i c 6 | cd "${BBSHOME}/brd" || exit 1 7 | for file in */; do 8 | cd "${BBSHOME}/brd/$file" || continue 9 | if (test -e usies); then 10 | rm -f usies 11 | let a++ 12 | fi 13 | # if (test -e brdstat); then 14 | # rm -f brdstat 15 | # let b++ 16 | # fi 17 | # if (test -e bstatcount); then 18 | # rm -f bstatcount 19 | # let c++ 20 | # fi 21 | done 22 | echo "clean $a board usies" 23 | #echo "clean $b board brdstat" 24 | #echo "clean $c board bstatcount" 25 | -------------------------------------------------------------------------------- /test/test.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* test/testdef.h ( NCKU CCNS WindTop-DreamBBS 3.21 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* Author: Wei-Cheng Yeh (IID) */ 5 | /* Target: Macro definitions for test programs */ 6 | /* Create: 2021-05-24 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #ifndef TEST_H 10 | #define TEST_H 11 | 12 | /* Enable `assert()` functionality from `` */ 13 | #undef NDEBUG 14 | 15 | #include 16 | 17 | #endif // #ifndef TEST_H 18 | -------------------------------------------------------------------------------- /scripts/Makefile: -------------------------------------------------------------------------------- 1 | SRCROOT = $(.CURDIR)/.. 2 | .include "$(SRCROOT)/dreambbs.mk" 3 | 4 | SH = checkACCT.sh checkbrdDIR.sh checkusrDIR.sh clean.sh start.sh top.sh 5 | WSPROXY = wsproxy/wsproxy.lua 6 | 7 | .for target in $(SH) 8 | $(target): $(target).in 9 | sed 's/@BBSHOME@/$(BBSHOME:S/\//\\\//g)/g; s/@BBSVER@/$(BBSVER)/g' $? > $@ 10 | .endfor 11 | 12 | all: $(SH) 13 | 14 | install: $(SH) 15 | $(INSTALL) -d "$(BBSHOME)/sh$(BBSVER)" 16 | $(INSTALL) -m 0700 $(SH) "$(BBSHOME)/sh$(BBSVER)" 17 | $(INSTALL) -d "$(BBSHOME)/wsproxy$(BBSVER)" 18 | $(INSTALL) -m 0755 $(WSPROXY) "$(BBSHOME)/wsproxy$(BBSVER)" 19 | 20 | clean: 21 | rm -rf $(SH) *~ 22 | -------------------------------------------------------------------------------- /innbbsd/inntobbs.h: -------------------------------------------------------------------------------- 1 | #ifndef INNTOBBS_H 2 | #define INNTOBBS_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* inntobbs.c */ 9 | extern const char *NODENAME; 10 | extern char *BODY; 11 | extern const char *DATE, *PATH, *MSGID, *POSTHOST, *CONTROL; 12 | extern char *SUBJECT, *FROM, *GROUP, *SITE; 13 | 14 | /* inntobbs.c */ 15 | int readlines(char *data); 16 | 17 | /* history.c */ 18 | void HISmaint(void); 19 | void HISadd(const char *msgid, const char *board, const char *xname); 20 | int HISfetch(const char *msgid, char *board, char *xname); 21 | 22 | #ifdef __cplusplus 23 | } /* extern "C" */ 24 | #endif 25 | 26 | #endif /* INNTOBBS_H */ 27 | -------------------------------------------------------------------------------- /.github/workflows/sync_wiki.yml: -------------------------------------------------------------------------------- 1 | name: Synchronizing GitHub Wiki with branch "wiki" 2 | 3 | on: 4 | push: 5 | branches: [wiki] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | sync-wiki: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | with: 14 | ref: 'wiki' 15 | persist-credentials: false 16 | fetch-depth: 0 17 | - name: sync 18 | run: | 19 | git remote add wiki "${GITHUB_SERVER_URL%%://*}://${PAT_USERNAME}:${PAT_TOKEN}@${GITHUB_SERVER_URL#*://}/$GITHUB_REPOSITORY.wiki.git" 20 | git push wiki @:master 21 | env: 22 | PAT_USERNAME: ${{ secrets.PAT_USERNAME }} 23 | PAT_TOKEN: ${{ secrets.PAT_TOKEN }} 24 | -------------------------------------------------------------------------------- /test/lib_xsort.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "dao.h" 7 | #include "test.h" 8 | 9 | #define MMM 0x40000 10 | 11 | int main(void) 12 | { 13 | int *x, *y, *z, n; 14 | 15 | x = (int *) malloc(MMM * sizeof(int)); 16 | if (!x) 17 | return 0; 18 | 19 | y = x; 20 | z = x + MMM; 21 | 22 | n = time(0) % 0x40000U /* 16387 */; 23 | 24 | do 25 | { 26 | *x = n = (n * 10001) % 0x100000U; 27 | } while (++x < z); 28 | 29 | xsort(y, MMM, sizeof(int), int_cmp); 30 | 31 | for (int i = 1; i < MMM; ++i) 32 | { 33 | assert(int_cmp(&y[i-1], &y[i]) <= 0); 34 | } 35 | 36 | free(y); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /.github/workflows/sync_with_wiki.yml: -------------------------------------------------------------------------------- 1 | name: Synchronizing branch "wiki" with GitHub Wiki 2 | 3 | on: 4 | [gollum, workflow_dispatch] 5 | 6 | jobs: 7 | sync-with-wiki: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | with: 12 | repository: ${{ format('{0}.wiki', github.repository) }} 13 | persist-credentials: false 14 | fetch-depth: 0 15 | - name: sync 16 | run: | 17 | git remote add main-repo "${GITHUB_SERVER_URL%%://*}://${PAT_USERNAME}:${PAT_TOKEN}@${GITHUB_SERVER_URL#*://}/$GITHUB_REPOSITORY.git" 18 | git push main-repo @:wiki 19 | env: 20 | PAT_USERNAME: ${{ secrets.PAT_USERNAME }} 21 | PAT_TOKEN: ${{ secrets.PAT_TOKEN }} 22 | -------------------------------------------------------------------------------- /sample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # sample/CMakeLists.txt ( NCKU CCNS DreamBBS 3.0 ) # 3 | # ------------------------------------------------------- # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for DreamBBS sample files # 6 | # Create: 2020-10-15 # 7 | # ------------------------------------------------------- # 8 | 9 | set(DEST 10 | bbsd.service bbsd_unixsocket.service 11 | startbbs.service xchatd.service 12 | bbs-sshd.service 13 | crontab 14 | ) 15 | 16 | foreach(target IN LISTS DEST) 17 | configure_file( 18 | ${target}.in ${target} 19 | @ONLY NEWLINE_STYLE LF 20 | ) 21 | endforeach(target) 22 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ # 2 | # lib/CMakeLists.txt ( NCKU CCNS WindTop-DreamBBS 3.0 ) # 3 | # ------------------------------------------------------ # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for DreamBBS library # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------ # 8 | 9 | set_property(DIRECTORY PROPERTY LINK_LIBRARIES "") 10 | 11 | add_library(dao STATIC 12 | acl.c file.c isnot.c radix32.c shm.c 13 | dl_lib.c record.c splay.c date.c xsort.c 14 | attr_lib.c dns.c header.c string.c xwrite.c 15 | proc.c passwd.c mime.c logger.c acct.c 16 | ) 17 | -------------------------------------------------------------------------------- /scripts/checkACCT.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | BBSHOME=${BBSHOME:-"@BBSHOME@"} 3 | declare -i a 4 | declare -i b 5 | cd "${BBSHOME}/run" || exit 1 6 | if (test -e NOACCT.log); then 7 | rm NOACCT.log 8 | fi 9 | cd "${BBSHOME}/usr" || exit 1 10 | for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do 11 | cd "${BBSHOME}/usr/$i" || continue 12 | for usr in */; do 13 | cd "${BBSHOME}/usr/$i/$usr" || continue 14 | if ! (test -e .ACCT); then 15 | echo "$usr" >> "${BBSHOME}/run/NOACCT.log" 16 | let a++ 17 | fi 18 | let b++ 19 | done 20 | done 21 | echo "$a user(s) have no ACCT" >> "${BBSHOME}/run/NOACCT.log" 22 | echo "$b user(s) is checked" >> "${BBSHOME}/run/NOACCT.log" 23 | #mail -s 'NOACCT.log' *********@gmail.com < "${BBSHOME}/NOACCT.log" 24 | #rm "${BBSHOME}/NOACCT.log" 25 | -------------------------------------------------------------------------------- /util/readUSR.c: -------------------------------------------------------------------------------- 1 | #include "bbs.h" 2 | 3 | int main(void) 4 | { 5 | int fd, n; 6 | SCHEMA *usr; 7 | struct stat st; 8 | char userid[IDLEN+1]; 9 | 10 | setgid(BBSGID); 11 | setuid(BBSUID); 12 | 13 | if ((fd = open(BBSHOME "/.USR", O_RDONLY)) < 0) 14 | { 15 | printf("ERROR at open file\n"); 16 | 17 | exit(1); 18 | } 19 | fstat(fd, &st); 20 | usr = (SCHEMA *) malloc(st.st_size); 21 | read(fd, usr, st.st_size); 22 | close(fd); 23 | printf("st.st_size=%lld\n", (long long)st.st_size); 24 | for (n=0; n < (st.st_size/sizeof(SCHEMA)); n++) 25 | { 26 | str_scpy(userid, usr[n].userid, sizeof(userid)); 27 | printf("uptime:%s userid:%-*s\n", 28 | Btime_any(&usr[n].uptime), IDLEN, userid); 29 | } 30 | free(usr); 31 | } 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /so/so.cmake: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------# 2 | # so/so.cmake ( NCKU CCNS WindTop-DreamBBS 3.0 ) # 3 | # -------------------------------------------------------# 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: Shared libraries for DreamBBS # 6 | # Create: 2019/11/30 # 7 | # -------------------------------------------------------# 8 | 9 | set(SO 10 | chat vote xyz guessnum 11 | admin chatmenu mailgem 12 | memorandum aloha newboard violate song same_mail 13 | showvote list mine bj 14 | pnote passwd adminutil ascii 15 | classtable2 observe pip brdstat personal 16 | cleanrecommend shop bank innbbs contact banmail 17 | ) 18 | 19 | if(USE_BBSLUA) 20 | list(APPEND SO bbslua) 21 | endif() 22 | 23 | if (USE_BBSRUBY) 24 | list(APPEND SO bbsruby) 25 | endif() 26 | -------------------------------------------------------------------------------- /.github/workflows/sent_repo_dispatch.yml: -------------------------------------------------------------------------------- 1 | name: Sending workflow dispatch to "imagedreambbs" project 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | 7 | jobs: 8 | sent-dispatch-job: 9 | if: ${{ !contains(github.event.head_commit.message, 'skip-ci') }} 10 | runs-on: ubuntu-latest 11 | steps: 12 | - env: 13 | WORKFLOW_ID: 'push_container.yml' 14 | run: | 15 | curl \ 16 | -X POST \ 17 | -u "${{ secrets.PAT_USERNAME}}:${{secrets.PAT_TOKEN}}" \ 18 | -H "Accept: application/vnd.github.v3+json" \ 19 | -H "Content-Type: application/json" \ 20 | https://api.github.com/repos/bbsdocker/imagedreambbs/actions/workflows/$WORKFLOW_ID/dispatches \ 21 | --data '{ 22 | "ref": "refs/heads/master", 23 | "inputs": {"src_ref": "'"$GITHUB_REF"'", "src_sha": "'"$GITHUB_SHA"'"} 24 | }' 25 | echo "Dispatch sent." 26 | -------------------------------------------------------------------------------- /sample/Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # sample/Makefile ( NCKU CCNS DreamBBS 3.0 ) # 3 | # ------------------------------------------------------- # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: Makefile for DreamBBS sample files # 6 | # Create: 2020-10-15 # 7 | # ------------------------------------------------------- # 8 | 9 | SRCROOT = $(.CURDIR)/.. 10 | .include "$(SRCROOT)/dreambbs.mk" 11 | 12 | DEST += bbsd.service bbsd_unixsocket.service \ 13 | startbbs.service xchatd.service \ 14 | bbs-sshd.service \ 15 | crontab 16 | 17 | all: $(DEST) 18 | 19 | .for target in $(DEST) 20 | $(target): $(target).in 21 | sed 's/@BBSHOME@/$(BBSHOME:S/\//\\\//g)/g; s/@BBSUSR@/$(BBSUSR)/g; s/@BBSGROUP@/$(BBSGROUP)/g; s/@BBS_SSHD_ROOT@/$(BBS_SSHD_ROOT:S/\//\\\//g)/g' $? > $@ 22 | .endfor 23 | 24 | clean: 25 | rm -rf $(DEST) *~ 26 | -------------------------------------------------------------------------------- /test/testsize.c: -------------------------------------------------------------------------------- 1 | #include "bbs.h" 2 | #include "test.h" 3 | 4 | #if __STDC_VERSION__ >= 201112L /* C11 */ || __cplusplus >= 201103L /* C++11 */ 5 | #define EXPECT_SIZE(Type, expect) \ 6 | static_assert(sizeof(Type) == (expect), #Type " check failed!") 7 | #else 8 | #define EXPECT_SIZE(Type, expect) assert(sizeof(Type) == (expect)) 9 | #endif 10 | 11 | #define SHOW_SIZE(Type) (void)( \ 12 | (void)printf("sizeof(" #Type "): %zu\n", sizeof(Type)) \ 13 | ) 14 | 15 | #define CHECK_SIZE(Type, expect) do { \ 16 | SHOW_SIZE(Type); \ 17 | EXPECT_SIZE(Type, expect); \ 18 | } while (0) 19 | 20 | int main(void) 21 | { 22 | // print out variable size 23 | SHOW_SIZE(size_t); 24 | SHOW_SIZE(int); 25 | SHOW_SIZE(long); 26 | SHOW_SIZE(time_t); 27 | 28 | //print out bbs struct size 29 | CHECK_SIZE(BRD, 256); 30 | CHECK_SIZE(BRH, 12); 31 | CHECK_SIZE(HDR, 256); 32 | CHECK_SIZE(ACCT, 512); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /innbbsd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # innbbsd/CMakeLists.txt (NCKU CCNS WindTop-DreamBBS 3.0)# 3 | # ------------------------------------------------------- # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for Newsgroup program innbbsd # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------- # 8 | 9 | add_executable(bbslink 10 | bbslink.c bbslib.c convcode.c inntobbs.c rec_article.c nocem.c history.c 11 | ) 12 | add_executable(innbbsd 13 | channel.c bbslib.c convcode.c inntobbs.c rec_article.c nocem.c history.c 14 | ) 15 | 16 | install( 17 | TARGETS bbslink innbbsd 18 | DESTINATION innd${BBSVER} 19 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE 20 | ) 21 | install( 22 | CODE "execute_process(COMMAND chown -R ${BBSUSR}:${BBSGROUP} ${CMAKE_INSTALL_PREFIX}/innd${BBSVER})" 23 | ) 24 | -------------------------------------------------------------------------------- /util/readBENZ.c: -------------------------------------------------------------------------------- 1 | #include "bbs.h" 2 | 3 | int main(void) 4 | { 5 | char c; 6 | 7 | setgid(BBSGID); 8 | setuid(BBSUID); 9 | 10 | for (c = 'a'; c <= 'z'; c++) 11 | { 12 | char buf[64]/*, rmbuf[64]*/; 13 | struct dirent *de; 14 | DIR *dirp; 15 | 16 | sprintf(buf, BBSHOME "/usr/%c", c); 17 | chdir(buf); 18 | 19 | if (!(dirp = opendir("."))) 20 | continue; 21 | 22 | while ((de = readdir(dirp))) 23 | { 24 | int fd; 25 | BMW bmw; 26 | if (de->d_name[0] <= ' ' || de->d_name[0] == '.') 27 | continue; 28 | sprintf(buf, "%.*s/%s", IDLEN, de->d_name, FN_BENZ); 29 | if ((fd = open(buf, O_RDWR)) < 0) 30 | continue; 31 | 32 | while (read(fd, &bmw, sizeof(bmw))) 33 | { 34 | printf("ID:%-*s sender:%-4d recver:%-4d msg:%s\n", 35 | IDLEN, bmw.userid, bmw.sender, bmw.recver, bmw.msg); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /util/readFRIENZ.c: -------------------------------------------------------------------------------- 1 | #include "bbs.h" 2 | 3 | int main(void) 4 | { 5 | char c; 6 | 7 | setgid(BBSGID); 8 | setuid(BBSUID); 9 | 10 | for (c = 'a'; c <= 'z'; c++) 11 | { 12 | char buf[64]/*, rmbuf[64]*/; 13 | struct dirent *de; 14 | DIR *dirp; 15 | 16 | sprintf(buf, BBSHOME "/usr/%c", c); 17 | chdir(buf); 18 | 19 | if (!(dirp = opendir("."))) 20 | continue; 21 | 22 | while ((de = readdir(dirp))) 23 | { 24 | int fd; 25 | BMW bmw; 26 | if (de->d_name[0] <= ' ' || de->d_name[0] == '.') 27 | continue; 28 | sprintf(buf, "%.*s/%s", IDLEN, de->d_name, FN_FRIEND_BENZ); 29 | if ((fd = open(buf, O_RDWR)) < 0) 30 | continue; 31 | 32 | while (read(fd, &bmw, sizeof(bmw))) 33 | { 34 | printf("ID:%-*s sender:%-4d recver:%-4d msg:%s\n", 35 | IDLEN, bmw.userid, bmw.sender, bmw.recver, bmw.msg); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /include/popup.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* popup.h ( YZU_CSE WindTop BBS ) */ 3 | /*-------------------------------------------------------*/ 4 | /* author : verit.bbs@bbs.yzu.edu.tw */ 5 | /* target : popup menu */ 6 | /* create : 2003/02/12 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | 10 | #ifndef POPUP_H 11 | #define POPUP_H 12 | 13 | #include "modes.h" 14 | 15 | #define POPUP_QUIT M_QUIT 16 | #define POPUP_FUN M_FUN 17 | #define POPUP_XO (M_FUN | M_XO) 18 | #define POPUP_MENU M_MENU 19 | #define POPUP_MENUTITLE (M_MENU | M_MENUTITLE) 20 | #if NO_SO 21 | #define POPUP_SO M_FUN 22 | #else 23 | #define POPUP_SO M_DL(M_FUN) /* For dynamic library loading */ 24 | #endif 25 | 26 | #define POPUP_ARG M_ARG /* `item` is a function and a `void *` argument */ 27 | 28 | #endif /* #ifndef POPUP_H */ 29 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # test/CMakeLists.txt ( NCKU CCNS WindTop-DreamBBS 3.0 ) # 3 | # ------------------------------------------------------- # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for test programs # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------- # 8 | 9 | set(LIBSTR 10 | lib_str_decode lib_str_pat lib_str_xor lib_from_parse 11 | ) 12 | 13 | set(LIBFILE 14 | lib_f_mv lib_f_cp lib_f_rm 15 | ) 16 | 17 | set(LIBOTHER 18 | lib_xsort lib_splay testsize 19 | ) 20 | 21 | enable_testing() 22 | 23 | foreach(target IN LISTS LIBSTR LIBOTHER) 24 | add_executable(${target} ${target}.c) 25 | add_test(NAME test_${target} COMMAND ${target}) 26 | endforeach(target) 27 | 28 | foreach(target IN LISTS LIBFILE) 29 | add_executable(${target} ${target}.c) 30 | endforeach(target) 31 | add_test(NAME scripttest COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/testscript.sh) 32 | -------------------------------------------------------------------------------- /test/lib_from_parse.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include "dao.h" 6 | #include "test.h" 7 | 8 | int main(void) 9 | { 10 | char addr[48]; 11 | char nick[32]; 12 | 13 | #define CHECK_CASE(input, addr_exp, nick_exp, ret_exp) (void) ( \ 14 | printf("`%s`: ", input), \ 15 | assert(from_parse(input, addr, nick) == (ret_exp)), \ 16 | printf("Address: `%s`, nick name: `%s`\n", addr, nick), \ 17 | assert(!strcmp(addr, addr_exp)), \ 18 | assert(!strcmp(nick, nick_exp)) \ 19 | ) 20 | 21 | CHECK_CASE("user@domain", "user@domain", "", 0); 22 | CHECK_CASE("user@domain (nick)", "user@domain", "nick", 0); 23 | CHECK_CASE("user@domain (\"nick\")", "user@domain", "nick", 0); 24 | CHECK_CASE("nick ", "user@domain", "nick", 0); 25 | CHECK_CASE("\"nick\" ", "user@domain", "nick", 0); 26 | CHECK_CASE("@", "@", "", 0); 27 | CHECK_CASE("<", "<", "", -1); 28 | CHECK_CASE("", "", "", -1); 29 | 30 | #undef CHECK_CASE 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /include/skin.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* skin.h ( YZU WindTopBBS Ver 3.02 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* target : skin definitions & variables */ 5 | /* create : */ 6 | /* update : */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #ifndef SKIN_H 10 | #define SKIN_H 11 | 12 | #ifdef MAIN_C 13 | # undef MAIN_C /* For including declarations */ 14 | # undef SKIN_H /* Temporarily disable the header guard */ 15 | # include __FILE__ /* Include the declarations */ 16 | # define MAIN_C /* Restore `MAIN_C` */ 17 | # define VAR 18 | # define INI(...) = __VA_ARGS__ 19 | #else 20 | # define VAR extern 21 | # define INI(...) 22 | #endif 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | VAR void (*s_menu)(void); 29 | 30 | #ifdef __cplusplus 31 | } /* extern "C" */ 32 | #endif 33 | 34 | #undef VAR 35 | #undef INI 36 | 37 | #endif /* SKIN_H */ 38 | -------------------------------------------------------------------------------- /so/so.mk: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------# 2 | # so/so.mk ( NCKU CCNS WindTop-DreamBBS 2.0 ) # 3 | # -------------------------------------------------------# 4 | # Author: opus.bbs@bbs.cs.nthu.edu.tw # 5 | # Target: Shared object target files for DreamBBS # 6 | # Create: 95/03/29 (so/Makefile) # 7 | # Update: 2019/05/07 (split from so/Makefile) # 8 | # : by Wei-Cheng Yeh (IID) # 9 | # -------------------------------------------------------# 10 | 11 | HDR = bbs.h config.h global.h modes.h perm.h struct.h bbs_script.h cppdef.h 12 | 13 | SO = chat.so vote.so xyz.so guessnum.so \ 14 | admin.so chatmenu.so mailgem.so\ 15 | memorandum.so aloha.so newboard.so violate.so song.so same_mail.so\ 16 | showvote.so list.so mine.so bj.so \ 17 | pnote.so passwd.so adminutil.so ascii.so\ 18 | classtable2.so observe.so pip.so brdstat.so personal.so \ 19 | cleanrecommend.so shop.so bank.so innbbs.so contact.so banmail.so 20 | 21 | .if $(USE_BBSLUA) 22 | SO += bbslua.so 23 | .endif 24 | 25 | .if $(USE_BBSRUBY) 26 | SO += bbsruby.so 27 | .endif 28 | -------------------------------------------------------------------------------- /innbbsd/bbslib.h: -------------------------------------------------------------------------------- 1 | #ifndef BBSLIB_H 2 | #define BBSLIB_H 3 | 4 | #include "attrdef.h" /* Macros for implementation-defined attributes */ 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | /* bbslib.c */ 11 | extern int NLCOUNT; 12 | extern nodelist_t *NODELIST; 13 | GCC_PURE int nl_bynamecmp(const void *a, const void *b); 14 | 15 | /* bbslib.c */ 16 | extern int NFCOUNT; 17 | extern newsfeeds_t *NEWSFEEDS; 18 | extern newsfeeds_t *NEWSFEEDS_B; 19 | extern newsfeeds_t *NEWSFEEDS_G; 20 | GCC_PURE int nf_byboardcmp(const void *a, const void *b); 21 | GCC_PURE int nf_bygroupcmp(const void *a, const void *b); 22 | 23 | /* bbslib.c */ 24 | extern int SPAMCOUNT; 25 | extern spamrule_t *SPAMRULE; 26 | 27 | /* bbslib.c */ 28 | int initial_bbs(void); 29 | GCC_FORMAT(1, 2) void bbslog(const char *fmt, ...); 30 | 31 | /* convcode.c */ 32 | void b52gb(char *str); 33 | void gb2b5(char *str); 34 | 35 | /* rec_article.c */ 36 | extern BCACHE *bshm; 37 | int cancel_article(const char *msgid); 38 | int receive_article(void); 39 | #ifdef NoCeM 40 | int receive_nocem(void); 41 | int read_ncmperm(void); 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } /* extern "C" */ 46 | #endif 47 | 48 | #endif /* BBSLIB_H */ 49 | -------------------------------------------------------------------------------- /test/testscript.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eux 4 | 5 | SHA256=: 6 | test "$(uname -o)" = "GNU/Linux" && SHA256=sha256sum 7 | test "$(uname -o)" = "FreeBSD" && SHA256=sha256 8 | 9 | ################### test f_mv() 10 | printf "putsometextin" > before_mv.txt 11 | sha256_before_mv=$(${SHA256} before_mv.txt |awk '{print $1}') 12 | ./lib_f_mv before_mv.txt after_mv.txt 13 | sha256_after_mv=$(${SHA256} after_mv.txt |awk '{print $1}') 14 | test "$sha256_before_mv" = "$sha256_after_mv" && (>&2 printf "\033[1;32mtest f_mv ok!\033[0m\n") 15 | rm after_mv.txt 16 | 17 | ################### test f_cp() 18 | printf "putanoterrrrrtextin" > before_cp.txt 19 | sha256_before_cp=$(${SHA256} before_cp.txt |awk '{print $1}') 20 | ./lib_f_cp before_cp.txt after_cp.txt 21 | sha256_after_cp=$(${SHA256} after_cp.txt |awk '{print $1}') 22 | test "$sha256_before_cp" = "$sha256_after_cp" && (>&2 printf "\033[1;32mtest f_cp ok!\033[0m\n") 23 | rm before_cp.txt after_cp.txt 24 | 25 | ################### test f_rm() 26 | printf "thisfileshouldbedeleted" > before_rm.txt 27 | ./lib_f_rm before_rm.txt 28 | test ! -e before_rm.txt || (>&2 printf "\033[1;31mtest f_rm failed!\033[0m\n"; false) 29 | (>&2 printf "\033[1;32mtest f_rm (for single file) ok!\033[0m\n") 30 | -------------------------------------------------------------------------------- /scripts/wsproxy/README.md: -------------------------------------------------------------------------------- 1 | # wsproxy 2 | 3 | The websocket to telnet bbs proxy. 4 | 5 | ## Install 6 | 7 | - Install OpenResty. 8 | 9 | Follow the [installation instruction](https://openresty.org/en/installation.html) on the OpenResty 10 | official website. 11 | 12 | - Configure nginx 13 | 14 | ```nginx 15 | map $http_origin $bbs_origin_checked { 16 | "http://www.ptt.cc" 1; 17 | "https://www.ptt.cc" 1; 18 | "~^app://" 1; 19 | "~^https?://127\." 1; 20 | default 0; 21 | } 22 | 23 | server { 24 | location /bbs { 25 | # Optional: lport sent to logind. 26 | # Values: an integer. 27 | # Default: server port. 28 | set $bbs_lport 443; 29 | 30 | # Optional: Whether it is a secure connection. 31 | # Values: 1 for secure, otherwise non-secure. 32 | # Default: non-secure. 33 | set $bbs_secure 1; 34 | 35 | # Required: The logind address. 36 | set $bbs_logind_addr "unix:/home/bbs/run/logind.connfwd.sock"; 37 | 38 | content_by_lua_file /home/bbs/wsproxy/wsproxy.lua; 39 | } 40 | } 41 | ``` 42 | 43 | - Configure logind (etc/bindports.conf) 44 | 45 | ``` 46 | logind unix run/logind.connfwd.sock 47 | ``` 48 | 49 | ## License 50 | 51 | MIT 52 | -------------------------------------------------------------------------------- /test/lib_splay.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include "dao.h" 7 | #include "test.h" 8 | 9 | typedef struct { 10 | FILE *fp; 11 | int last; 12 | } PrintCtx; 13 | 14 | typedef struct 15 | { 16 | int i; 17 | } intnode; 18 | 19 | GCC_PURE int 20 | compareint(const void *a, const void *b) 21 | { 22 | const intnode *A = (const intnode *)a; 23 | const intnode *B = (const intnode *)b; 24 | return A->i - B->i; 25 | } 26 | 27 | 28 | void 29 | printint(const void *a, FILE *fp) 30 | { 31 | PrintCtx *pctx = (PrintCtx *)fp; 32 | const intnode *A = (const intnode *) a; 33 | fprintf(pctx->fp, "%d ", A->i); 34 | assert(A->i > pctx->last); 35 | pctx->last = A->i; 36 | } 37 | 38 | int main(int argc, char *argv[]) 39 | { 40 | PrintCtx ctx = {stdout, -1}; 41 | SplayNode *top = NULL; 42 | srandom(time(NULL)); 43 | for (int i = 0; i < 100; i++) 44 | { 45 | intnode *I = (intnode *) malloc(sizeof(intnode)); 46 | I->i = random() % 1000; 47 | top = splay_in(top, I, compareint); 48 | } 49 | splay_out(top, printint, (FILE *)&ctx); 50 | splay_free(top, free); 51 | printf("\n"); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /scripts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # scripts/CMakeLists.txt (NCKU CCNS WindTop-DreamBBS 3.0)# 3 | # ------------------------------------------------------- # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for scripts # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------- # 8 | 9 | set(SH 10 | checkACCT.sh checkbrdDIR.sh checkusrDIR.sh clean.sh start.sh top.sh 11 | ) 12 | set(WSPROXY 13 | wsproxy/wsproxy.lua 14 | ) 15 | 16 | foreach(target IN LISTS SH) 17 | configure_file( 18 | ${target}.in ${target} 19 | @ONLY NEWLINE_STYLE LF 20 | ) 21 | install( 22 | PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${target} 23 | DESTINATION sh${BBSVER} 24 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE 25 | ) 26 | endforeach(target) 27 | 28 | install( 29 | CODE "execute_process(COMMAND chown -R ${BBSUSR}:${BBSGROUP} ${CMAKE_INSTALL_PREFIX}/sh${BBSVER})" 30 | ) 31 | 32 | install( 33 | PROGRAMS ${WSPROXY} 34 | DESTINATION wsproxy${BBSVER} 35 | ) 36 | install( 37 | CODE "execute_process(COMMAND chown -R ${BBSUSR}:${BBSGROUP} ${CMAKE_INSTALL_PREFIX}/wsproxy${BBSVER})" 38 | ) 39 | -------------------------------------------------------------------------------- /util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ # 2 | # util/CMakeLists.txt ( NCKU CCNS WindTop-DreamBBS 3.0 )# 3 | # ------------------------------------------------------ # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for maintenance tools # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------ # 8 | 9 | set(EXE 10 | account acl-sort camera expire gem-check gem-index makeUSR 11 | hdr-dump poststat reaper rmbadmail restorebrd 12 | mailpost bbsmail topusr acpro addsong userno template restoregem 13 | checkemail match mailexpire utmp-dump 14 | stopperm mailtoall clean_acl makefw 15 | resetvmail counter restoreusr makeusrno outgo redir 16 | classtable_alert bmw-dump tranBRD 17 | brdstat brdcheck dump-brdstat base64encode 18 | msgall transacct showACCT showBRD 19 | readBENZ readFRIENZ readUSR 20 | backup brdmail addpost 21 | ) 22 | 23 | foreach(target IN LISTS EXE) 24 | add_executable(${target} ${target}.c) 25 | install( 26 | TARGETS ${target} 27 | DESTINATION bin${BBSVER} 28 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE 29 | ) 30 | endforeach(target) 31 | 32 | install( 33 | CODE "execute_process(COMMAND chown -R ${BBSUSR}:${BBSGROUP} ${CMAKE_INSTALL_PREFIX}/bin${BBSVER})" 34 | ) 35 | -------------------------------------------------------------------------------- /lib/Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ # 2 | # lib/Makefile ( NTHU CS MapleBBS Ver 3.00 ) # 3 | # ------------------------------------------------------ # 4 | # author : opus.bbs@bbs.cs.nthu.edu.tw # 5 | # target : Makefile for MapleBBS library routines # 6 | # create : 95/03/29 # 7 | # update : 95/12/15 # 8 | # ------------------------------------------------------ # 9 | 10 | SRCROOT = $(.CURDIR)/.. 11 | .include "$(SRCROOT)/dreambbs.mk" 12 | 13 | HDR = dao.h dao.p 14 | 15 | SRC = acl.c file.c isnot.c radix32.c shm.c \ 16 | dl_lib.c record.c splay.c date.c xsort.c \ 17 | attr_lib.c dns.c header.c string.c xwrite.c \ 18 | proc.c passwd.c mime.c logger.c acct.c 19 | 20 | OBJ = acl.o file.o isnot.o radix32.o shm.o \ 21 | dl_lib.o record.o splay.o date.o xsort.o \ 22 | attr_lib.o dns.o header.o string.o xwrite.o \ 23 | proc.o passwd.o mime.o logger.o acct.o 24 | 25 | .c.o: ;$(CC) $(CFLAGS) -c $*.c 26 | 27 | all: libdao.a 28 | 29 | dao.p: $(SRC) 30 | $(CPROTO) $> | sed '/querybuf/d' > dao.p 31 | 32 | libdao.a: $(OBJ) 33 | ar rv $@ $? 34 | $(RANLIB) $@ 35 | 36 | clean: 37 | rm -fr $(OBJ) *.a *.bak *.BAK *~ *.p tags 38 | 39 | tags: 40 | ctags $(SRC) $(SRCROOT)/include/*.h 41 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # test/Makefile ( NTHU CS MapleBBS Ver 3.x ) # 3 | # ------------------------------------------------------- # 4 | # target : Makefile for common library test utils # 5 | # create : / / # 6 | # update : 19/07/28 # 7 | # ------------------------------------------------------- # 8 | # 9 | # TODO: make variable size test utils. 10 | # 11 | 12 | SRCROOT = $(.CURDIR)/.. 13 | .include "$(SRCROOT)/dreambbs.mk" 14 | 15 | .SUFFIXES: .o .c 16 | 17 | .c.o: ; $(CC) $(MAKEFLAG) $(CFLAGS) -g -c $*.c 18 | 19 | LIBSTR = lib_str_decode lib_str_pat lib_str_xor lib_from_parse 20 | 21 | LIBFILE = lib_f_mv lib_f_cp lib_f_rm 22 | 23 | LIBOTHER= lib_xsort lib_splay testsize 24 | 25 | EXE = $(LIBSTR) $(LIBFILE) $(LIBOTHER) 26 | 27 | all: $(EXE) 28 | 29 | .for targets in $(EXE) 30 | $(targets): $(targets).o 31 | $(CC) $(MAKEFLAG) -o $@ $? $(LDFLAGS) 32 | .endfor 33 | 34 | runtest: noargtest scripttest 35 | 36 | noargtest: 37 | @(>&2 printf "\n"); for i in $(LIBSTR) $(LIBOTHER); do ./$$i && (>&2 printf "\033[1;32m$$i test done!\033[0m\n") || ( (>&2 printf "\033[1;31m$$i test failed!\n\033[0m") && exit 1 ); done 38 | 39 | scripttest: 40 | @(>&2 printf "\n\033[1;33mrunning testing script...\033[0m\n"); sh testscript.sh 41 | 42 | clean: 43 | rm -fr $(EXE) *.o *.bak *.BAK *.log *~ 44 | -------------------------------------------------------------------------------- /scripts/checkbrdDIR.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | BBSHOME=${BBSHOME:-"@BBSHOME@"} 3 | declare -i a 4 | declare -i b 5 | declare -i c 6 | #declare -i d 7 | cd "${BBSHOME}/run" || exit 1 8 | if (test -e NOBRDDIR.log); then 9 | rm NOBRDDIR.log 10 | fi 11 | cd "${BBSHOME}/brd" || exit 1 12 | for file in */; do 13 | cd "${BBSHOME}/brd/$file" || continue 14 | if (! (test -e .DIR) || ! (test -e .DIR.o)); then 15 | echo "-- $file" >> "${BBSHOME}/run/NOBRDDIR.log" 16 | if ! (test -e .DIR); then 17 | echo "NO .DIR" >> "${BBSHOME}/run/NOBRDDIR.log" 18 | let a++ 19 | fi 20 | if ! (test -e .DIR.o); then 21 | echo "NO .DIR.o" >> "${BBSHOME}/run/NOBRDDIR.log" 22 | let b++ 23 | fi 24 | fi 25 | # for folder in 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V; do 26 | # if ! (test -d $folder); then 27 | # echo "=== $file lose some folder" >> "${BBSHOME}/NODIR.log" 28 | # let d++; 29 | # break 30 | # fi 31 | # done 32 | let c++ 33 | done 34 | { 35 | echo "$a board(s) have no .DIR" 36 | echo "$b board(s) have no .DIR.o" 37 | echo "$c board(s) are checked" 38 | } >> "${BBSHOME}/run/NOBRDDIR.log" 39 | #echo "$d board(s) lose folder" >> "${BBSHOME}/NODIR.log" 40 | #mail -s 'DIR.log' *********@gmail.com < "${BBSHOME}/NODIR.log" 41 | #mail -s 'DIR.log' *********@gmail.com < "${BBSHOME}/NODIR.log" 42 | -------------------------------------------------------------------------------- /include/attr.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* attr.h ( NTHU CS MapleBBS Ver 3.10 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* target : dynamic attribute database */ 5 | /* create : 99/03/11 */ 6 | /* update : / / */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #ifndef ATTR_H 10 | #define ATTR_H 11 | 12 | #if 0 13 | int key; 14 | key < 0 is reserved. 15 | (key & 0xff) == 0 is reserved. 16 | sizeof(attr): key & 0xff 17 | 18 | file: $userhome/.ATTR 19 | #endif 20 | 21 | #define ATTR_OTHELLO_TOTAL 0x00001004 22 | #define ATTR_FIVE_TOTAL 0x00001104 23 | #define ATTR_BLOCK_TOTAL 0x00001204 24 | #define ATTR_OTHELLO_WIN 0x00001404 25 | #define ATTR_FIVE_WIN 0x00001504 26 | #define ATTR_BLOCK_WIN 0x00001604 27 | 28 | /*-------------------------------------------------------*/ 29 | /* USER for WindTop */ 30 | /*-------------------------------------------------------*/ 31 | 32 | #define ATTR_USER_KEY 0x000100FF 33 | #define ATTR_REG_KEY 0x00010104 34 | #define ATTR_CROSS_KEY 0x00010230 35 | 36 | #define REG_REQUEST 0x00000001 37 | #define REG_OPEN 0x00000002 38 | #define REG_FAULT 0x00000004 39 | #define REG_SENT 0x00000008 40 | #define REG_OK 0x00000010 41 | 42 | #endif /* ifndef ATTR_H */ 43 | -------------------------------------------------------------------------------- /include/bbs_script.h: -------------------------------------------------------------------------------- 1 | #ifndef BBS_SCRIPT_H 2 | #define BBS_SCRIPT_H 3 | 4 | #include "cppdef.h" 5 | 6 | /* BBS-Lua */ 7 | 8 | #ifdef M3_USE_BBSLUA 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | #include 13 | 14 | #ifdef BBSLUA_USE_LUAJIT 15 | #include 16 | #endif 17 | #ifdef __cplusplus 18 | } // extern "C" 19 | #endif 20 | #endif 21 | 22 | #define HAVE_BBSLUA 23 | 24 | // Must be consistent with "bbslua.c" 25 | 26 | #define BBSLUA_INTERFACE_VER 0.119 // 0.201 27 | #define BBSLUA_DL_PATCH_VERSION 1 28 | #define BBSLUA_INTERFACE_VER_STR CPP_STR(BBSLUA_INTERFACE_VER) 29 | #define BBSLUA_VERSION_STR \ 30 | VERSION_DL_PATCH_STR(BBSLUA_INTERFACE_VER, BBSLUA_DL_PATCH_VERSION) 31 | 32 | 33 | /* BBS-Ruby */ 34 | 35 | #ifdef M3_USE_BBSRUBY 36 | #ifdef BBSRUBY_USE_MRUBY 37 | #include 38 | 39 | #define RUBY_RELEASE_STR MRUBY_RUBY_VERSION 40 | #else 41 | #include 42 | 43 | #define RUBY_RELEASE_STR \ 44 | VER_PATCH_STR(RUBY_API_VERSION_MAJOR, RUBY_API_VERSION_MINOR, RUBY_API_VERSION_TEENY) 45 | #endif 46 | #endif 47 | 48 | #define HAVE_BBSRUBY 49 | 50 | // Must be consistent with "bbsruby.c" 51 | 52 | #define BBSRUBY_MAJOR_VERSION 0 53 | #define BBSRUBY_MINOR_VERSION 3 54 | #define BBSRUBY_DL_PATCH_VERSION 2 55 | #define BBSRUBY_VERSION_STR \ 56 | VER_DL_STR(BBSRUBY_MAJOR_VERSION, BBSRUBY_MINOR_VERSION, BBSRUBY_DL_PATCH_VERSION) 57 | 58 | #define BBSRUBY_INTERFACE_VER 0.111 59 | #define BBSRUBY_INTERFACE_VER_STR CPP_STR(BBSRUBY_INTERFACE_VER) 60 | 61 | #endif // #ifndef BBS_SCRIPT_H 62 | -------------------------------------------------------------------------------- /lib/radix32.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------- */ 2 | /* chrono ==> file name (32-based) */ 3 | /* 0123456789ABCDEFGHIJKLMNOPQRSTUV */ 4 | /* ----------------------------------------------------- */ 5 | 6 | #include "dao.h" 7 | 8 | const char radix32[32] = { 9 | '0', '1', '2', '3', '4', '5', '6', '7', 10 | '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 11 | 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 12 | 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 13 | }; 14 | 15 | void archiv32(time_t chrono, /* 32 bits */ 16 | char *fname /* 7 chars */ 17 | ) 18 | { 19 | char *str; 20 | 21 | str = fname + 7; 22 | *str = '\0'; 23 | for (;;) 24 | { 25 | *(--str) = radix32[chrono % 32U]; 26 | if (str == fname) 27 | return; 28 | chrono /= 32U; 29 | } 30 | } 31 | 32 | void archiv32m(time_t chrono, /* 32 bits */ 33 | char *fname /* 7 chars */ 34 | ) 35 | { 36 | char *str; 37 | 38 | str = fname + 8; 39 | *str = '\0'; 40 | for (;;) 41 | { 42 | *(--str) = radix32[chrono % 32U]; 43 | if (str == fname) 44 | return; 45 | chrono /= 32U; 46 | } 47 | } 48 | 49 | GCC_PURE time_t chrono32(const char *str /* M0123456 */ 50 | ) 51 | { 52 | unsigned long chrono; 53 | unsigned int ch; 54 | 55 | chrono = 0; 56 | while ((ch = *++str)) 57 | { 58 | ch -= '0'; 59 | if (ch >= 10) 60 | ch -= 'A' - '0' - 10; 61 | chrono = (32 * chrono) + ch; 62 | } 63 | return chrono; 64 | } 65 | -------------------------------------------------------------------------------- /so/pipfun.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | static inline void 4 | clrchyiuan( 5 | int i, int j) 6 | { 7 | while (i <= j) 8 | { 9 | move(i, 0); 10 | clrtoeol(); 11 | i++; 12 | } 13 | } 14 | 15 | static inline void 16 | outs_centered(const char *str) 17 | { 18 | prints("%*s", d_cols>>1, ""); 19 | outs(str); 20 | } 21 | 22 | GCC_FORMAT(1, 2) static inline void 23 | prints_centered(const char *fmt, ...) 24 | { 25 | va_list args; 26 | char buf[512], *str; 27 | int cc; 28 | 29 | prints("%*s", d_cols>>1, ""); 30 | 31 | va_start(args, fmt); 32 | vsprintf(buf, fmt, args); 33 | va_end(args); 34 | for (str = buf; (cc = (unsigned char) *str); str++) 35 | outc(cc); 36 | } 37 | 38 | static inline int 39 | show_file(const char *filename, int y, int lines, int mode) 40 | { 41 | FILE *fp; 42 | clrchyiuan(y, y + lines); 43 | move(y, d_cols>>1); 44 | if ((fp = fopen(filename, "r"))) 45 | { 46 | char buf[256]; 47 | while (fgets(buf, 256, fp) && lines--) { 48 | move(++y, d_cols>>1); 49 | outs(buf); 50 | } 51 | fclose(fp); 52 | } 53 | else 54 | return 0; 55 | 56 | return 1; 57 | } 58 | 59 | static inline void 60 | usercomplete( 61 | const char *msg, char *buf) 62 | { 63 | vget(1, 0, msg, buf, IDLEN + 1, GET_USER); 64 | } 65 | 66 | static inline char * 67 | Cdate( 68 | const time_t *chrono) 69 | { 70 | struct tm *ptime; 71 | 72 | ptime = localtime(chrono); 73 | /* Thor.990329: y2k */ 74 | sprintf(Bdate, "%02d/%02d/%02d", 75 | ptime->tm_year % 100, ptime->tm_mon + 1, ptime->tm_mday); 76 | return Bdate; 77 | } 78 | -------------------------------------------------------------------------------- /include/logger.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* include/logger.h ( NCKU CCNS WindTop-DreamBBS 3.0 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* Author: Wei-Cheng Yeh (IID) */ 5 | /* Target: Header file for message logging */ 6 | /* Create: 2021/02/06 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #ifndef LOGGER_H 10 | #define LOGGER_H 11 | 12 | #include "config.h" 13 | 14 | #include 15 | 16 | enum LogLevel { 17 | LOGLV_EMERG, 18 | LOGLV_ALERT, 19 | LOGLV_CRIT, 20 | LOGLV_ERR, 21 | LOGLV_WARN, 22 | LOGLV_NOTICE, 23 | LOGLV_INFO, 24 | LOGLV_DEBUG, 25 | 26 | LOGLV_COUNT, 27 | 28 | /* Aliases for `Logger::lv_skip` */ 29 | LOGLV_SKIP_ALL = LOGLV_EMERG, 30 | LOGLV_SKIP_NONE = LOGLV_COUNT, 31 | }; 32 | 33 | typedef struct { 34 | FILE *file; 35 | const char *path; // Path to the log file 36 | enum LogLevel lv_skip; // The minimum log level to ignore 37 | } Logger; 38 | 39 | /* Tag Logger: A logger with tag and custom formatter */ 40 | typedef struct { 41 | Logger logger; 42 | void (*formatter)(char *buf, size_t size, const char *tag, const char *msg); 43 | } TLogger; 44 | 45 | #define TLOGGER_DEFAULT_LVSKIP(_lv_skip) \ 46 | LISTLIT(TLogger){ \ 47 | .logger = { \ 48 | .file = NULL, \ 49 | .path = NULL, /* Use the default log file (`stderr`) */ \ 50 | .lv_skip = (_lv_skip), \ 51 | }, \ 52 | .formatter = NULL, /* Use the default formatter */ \ 53 | } 54 | 55 | #define TLOGGER_DEFAULT TLOGGER_DEFAULT_LVSKIP(LOGLV_WARN) 56 | 57 | #endif // LOGGER_H 58 | -------------------------------------------------------------------------------- /so/Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ # 2 | # so/Makefile ( NTHU CS MapleBBS Ver 3.x ) # 3 | # ------------------------------------------------------ # 4 | # author : opus.bbs@bbs.cs.nthu.edu.tw # 5 | # target : Makefile for MapleBBS main programs # 6 | # create : 95/03/29 # 7 | # update : 18/03/28 # 8 | # ------------------------------------------------------ # 9 | 10 | SRCROOT = $(.CURDIR)/.. 11 | .include "$(SRCROOT)/dreambbs.mk" 12 | .include "./so.mk" 13 | 14 | .if $(USE_BBSLUA) 15 | CFLAGS += $(LUA_CFLAGS) 16 | .endif 17 | 18 | .if $(USE_BBSRUBY) 19 | CFLAGS += $(RUBY_CFLAGS) 20 | .endif 21 | 22 | .SUFFIXES: .o .c .ln .x .so 23 | 24 | CFLAGS_SO += -fPIC 25 | 26 | .c.o: ; $(CC) $(MAKEFLAG) $(CFLAGS) $(CFLAGS_SO) -DDL_CURRENT_MODULE_STR="\"$*.so\"" -c $*.c 27 | .c.x: ; $(CPROTO) -o $*.x $*.c 28 | .c.ln: ; lint -abhi $*.c 29 | 30 | LDFLAGS_SO = -fPIC -shared -Wl,-G 31 | 32 | LDFLAGS_SO += -L$(SRCROOT)/lib -ldao 33 | 34 | .o.so: ; $(CC) $*.o -o $*.so $(LDFLAGS_SO) $(LDFLAGS_SO_ARCHI) 35 | 36 | .if $(USE_BBSLUA) 37 | BBSLUA_OBJ = bbslua.o 38 | .if !$(USE_LUAJIT) 39 | BBSLUA_OBJ += bbsluaext.o 40 | .endif 41 | 42 | bbslua.so: $(BBSLUA_OBJ) 43 | $(CC) $*.o -o $*.so $(LDFLAGS_SO) $(LDFLAGS_SO_ARCHI) $(LUA_LDFLAGS) $(LUA_LDFLAGS_ARCHI) 44 | .endif 45 | 46 | .if $(USE_BBSRUBY) 47 | BBSRUBY_OBJ = bbsruby.o 48 | bbsruby.so: $(BBSRUBY_OBJ) 49 | $(CC) $*.o -o $*.so $(LDFLAGS_SO) $(LDFLAGS_SO_ARCHI) $(RUBY_LDFLAGS) $(RUBY_LDFLAGS_ARCHI) 50 | .endif 51 | 52 | all: $(SO) 53 | 54 | install: $(SO) 55 | $(INSTALL) -m 0700 $(SO) "$(BBSHOME)/bin$(BBSVER)" 56 | 57 | clean: /tmp 58 | rm -fr $(SO) *~ *.o 59 | -------------------------------------------------------------------------------- /include/timetype.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* timetype.h ( NCKU CCNS WindTop-DreamBBS 3.21 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* Author: Wei-Cheng Yeh (IID) */ 5 | /* Target: Helper functions for fixed-size `time_t` */ 6 | /* Create: 2021-02-23 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #ifndef TIMETYPE_H 10 | #define TIMETYPE_H 11 | 12 | #include 13 | 14 | #include "attrdef.h" 15 | #include "cppdef.h" 16 | 17 | /* Integral `time_t` types */ 18 | 19 | typedef int32_t time32_t; 20 | typedef uint32_t utime32_t; 21 | typedef int64_t time64_t; 22 | typedef uint64_t utime64_t; 23 | 24 | /* Helper functions for fixed-size `time_t` */ 25 | 26 | static inline time32_t time32(time32_t *tloc) 27 | { 28 | if (tloc) 29 | return *tloc = (time32_t)(utime32_t)time(NULL); 30 | return (time32_t)(utime32_t)time(NULL); 31 | } 32 | 33 | static inline time64_t time64(time64_t *tloc) 34 | { 35 | if (tloc) 36 | return *tloc = time(NULL); 37 | return time(NULL); 38 | } 39 | 40 | /* Helper macros for fixed-size `time_t` */ 41 | 42 | #define ctime_any(_timep) \ 43 | ctime(&TEMPLVAL(time_t, {*(_timep)})) 44 | 45 | #define ctime_any_r(_timep, _buf) \ 46 | ctime_r(&TEMPLVAL(time_t, {*(_timep)}), _buf) 47 | 48 | #define gmtime_any(_timep) \ 49 | gmtime(&TEMPLVAL(time_t, {*(_timep)})) 50 | 51 | #define gmtime_any_r(_timep, _result) \ 52 | gmtime_r(&TEMPLVAL(time_t, {*(_timep)}), _result) 53 | 54 | #define localtime_any(_timep) \ 55 | localtime(&TEMPLVAL(time_t, {*(_timep)})) 56 | 57 | #define localtime_any_r(_timep, _result) \ 58 | localtime_r(&TEMPLVAL(time_t, {*(_timep)}), _result) 59 | 60 | #endif // #ifndef TIMETYPE_H 61 | -------------------------------------------------------------------------------- /scripts/checkusrDIR.sh.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | BBSHOME=${BBSHOME:-"@BBSHOME@"} 3 | declare -i a 4 | declare -i b 5 | declare -i c 6 | cd "${BBSHOME}/run" || exit 1 7 | if (test -e NOUSRDIR.log); then 8 | rm NOUSRDIR.log 9 | fi 10 | cd "${BBSHOME}/usr" || exit 1 11 | for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do 12 | cd "${BBSHOME}/usr/$i" || continue 13 | for usr in */; do 14 | cd "${BBSHOME}/usr/$i/$usr" || continue 15 | if (! (test -d @)); then 16 | mkdir @ 17 | fi 18 | if (! (test -e .DIR) || ! (test -e .DIR.o)); then 19 | echo "$usr" >> "${BBSHOME}/run/NOUSRDIR.log" 20 | if ! (test -e .DIR); then 21 | echo "NO .DIR" >> "${BBSHOME}/run/NOUSRDIR.log" 22 | let a++ 23 | fi 24 | if ! (test -e .DIR.o); then 25 | echo "NO .DIR.o" >> "${BBSHOME}/run/NOUSRDIR.log" 26 | let b++ 27 | fi 28 | fi 29 | let c++ 30 | done 31 | done 32 | 33 | #cd "${BBSHOME}/usr/$1" || exit 1 34 | #for file in */; do 35 | # cd "${BBSHOME}/usr/$1/$file" || continue 36 | # if (! (test -e .DIR) || ! (test -e .DIR.o)); then 37 | # echo $file >> "${BBSHOME}/run/USRNODIR.log" 38 | # if ! (test -e .DIR); then 39 | # echo "NO .DIR" >> "${BBSHOME}/run/USRNODIR.log" 40 | # let a++ 41 | # fi 42 | # if ! (test -e .DIR.o); then 43 | # echo "NO .DIR.o" >> "${BBSHOME}/run/USRNODIR.log" 44 | # let b++ 45 | # fi 46 | # fi 47 | # let c++ 48 | #done 49 | 50 | { 51 | echo "$a user mail(s) have no .DIR" 52 | echo "$b user mail(s) have no .DIR.o" 53 | echo "$c user(s) are checked" 54 | } >> "${BBSHOME}/run/NOUSRDIR.log" 55 | #mail -s 'DIR.log' *********@gmail.com < "${BBSHOME}/USRNODIR.log" 56 | -------------------------------------------------------------------------------- /so/same_mail.c: -------------------------------------------------------------------------------- 1 | 2 | #include "bbs.h" 3 | 4 | static const char *kmail; 5 | static int total; 6 | static FILE *flog; 7 | 8 | static void 9 | reaper( 10 | const char *fpath, 11 | const char *lowid) 12 | { 13 | int fd; 14 | 15 | char buf[256]; 16 | ACCT acct; 17 | 18 | sprintf(buf, "%s/.ACCT", fpath); 19 | fd = open(buf, O_RDONLY, 0); 20 | if (fd < 0) 21 | return; 22 | 23 | if (read(fd, &acct, sizeof(acct)) != sizeof(acct)) 24 | { 25 | close(fd); 26 | return; 27 | } 28 | close(fd); 29 | 30 | if (!strcmp(acct.email, kmail)) 31 | { 32 | fprintf(flog, "%-*s\n", IDLEN, acct.userid); 33 | total++; 34 | } 35 | } 36 | 37 | static void 38 | traverse( 39 | char *fpath) 40 | { 41 | DIR *dirp; 42 | struct dirent *de; 43 | char *fname, *str; 44 | 45 | if (!(dirp = opendir(fpath))) 46 | { 47 | return; 48 | } 49 | for (str = fpath; *str; str++); 50 | *str++ = '/'; 51 | 52 | while ((de = readdir(dirp))) 53 | { 54 | fname = de->d_name; 55 | if (fname[0] > ' ' && fname[0] != '.') 56 | { 57 | strcpy(str, fname); 58 | reaper(fpath, fname); 59 | } 60 | } 61 | closedir(dirp); 62 | } 63 | 64 | int 65 | same_mail( 66 | char *mail) 67 | { 68 | DL_HOLD; 69 | int ch; 70 | char *fname, fpath[256]; 71 | kmail = mail; 72 | total = 0; 73 | 74 | flog = fopen(FN_SAMEEMAIL_LOG, "w"); 75 | if (flog == NULL) 76 | return DL_RELEASE(0); 77 | 78 | strcpy(fname = fpath, BBSHOME"/usr/@"); 79 | fname = (char *) strchr(fname, '@'); 80 | 81 | for (ch = 'a'; ch <= 'z'; ch++) 82 | { 83 | fname[0] = ch; 84 | fname[1] = '\0'; 85 | traverse(fpath); 86 | } 87 | fclose(flog); 88 | return DL_RELEASE(total); 89 | } 90 | -------------------------------------------------------------------------------- /so/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ # 2 | # so/CMakeLists.txt ( NCKU CCNS WindTop-DreamBBS 3.0 ) # 3 | # ------------------------------------------------------ # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for DreamBBS shared libraries # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------ # 8 | 9 | include(${PROJECT_SOURCE_DIR}/so/so.cmake) 10 | 11 | set_property(DIRECTORY PROPERTY LINK_LIBRARIES "") 12 | 13 | foreach(module IN LISTS SO) 14 | if(NO_SO) 15 | unset(so_${module}_LIB_DEPENDS CACHE) 16 | add_library(so_${module} OBJECT ${module}.c) 17 | else() 18 | add_library(so_${module} MODULE ${module}.c) 19 | target_link_libraries(so_${module} PRIVATE dao) 20 | target_compile_definitions(so_${module} PRIVATE 21 | DL_CURRENT_MODULE_STR="$" 22 | ) 23 | set_target_properties(so_${module} 24 | PROPERTIES PREFIX "" 25 | ) 26 | install( 27 | TARGETS so_${module} 28 | DESTINATION bin${BBSVER} 29 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE 30 | ) 31 | endif() 32 | 33 | target_compile_options(so_${module} PRIVATE -imacros${EXPORT_MAPLE}) 34 | 35 | if(USE_BBSLUA) 36 | target_compile_options(so_${module} PRIVATE ${LUA_CFLAGS}) 37 | endif() 38 | 39 | if(USE_BBSRUBY) 40 | target_compile_options(so_${module} PRIVATE ${RUBY_CFLAGS}) 41 | endif() 42 | 43 | set_target_properties(so_${module} 44 | PROPERTIES OUTPUT_NAME ${module} 45 | ) 46 | endforeach(module) 47 | 48 | if(USE_BBSLUA) 49 | if(NOT USE_LUAJIT) 50 | target_sources(so_bbslua PRIVATE bbsluaext.c) 51 | endif() 52 | target_link_libraries(so_bbslua PRIVATE ${LUA_LDFLAGS}) 53 | endif() 54 | 55 | if(USE_BBSRUBY) 56 | target_link_libraries(so_bbsruby PRIVATE ${RUBY_LDFLAGS}) 57 | endif() 58 | 59 | if(NOT NO_SO) 60 | install( 61 | CODE "execute_process(COMMAND chown -R ${BBSUSR}:${BBSGROUP} ${CMAKE_INSTALL_PREFIX}/bin${BBSVER})" 62 | ) 63 | endif() 64 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [master] 9 | schedule: 10 | - cron: '0 10 * * 5' 11 | 12 | jobs: 13 | main: 14 | name: Build and analyze ${{ matrix.opt_modules && ' with optional modules' || '' }} (${{ matrix.language }}) 15 | if: ${{ !contains(github.event.head_commit.message, 'skip-ci') }} 16 | runs-on: ubuntu-latest 17 | permissions: 18 | actions: read 19 | contents: read 20 | security-events: write 21 | 22 | strategy: 23 | fail-fast: false 24 | matrix: 25 | language: ['C', 'C++'] 26 | opt_modules: [true, false] 27 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 28 | # Learn more about CodeQL language support at https://git.io/codeql-language-support 29 | 30 | steps: 31 | - 32 | name: Checkout repository 33 | uses: actions/checkout@v3 34 | - 35 | name: Initialize CodeQL 36 | uses: github/codeql-action/init@v4 37 | with: 38 | languages: ${{ matrix.language }} 39 | # If you wish to specify custom queries, you can do so here or in a config file. 40 | # By default, queries listed here will override any specified in a config file. 41 | # Prefix the list here with "+" to use these queries and those in the config file. 42 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 43 | - 44 | name: Enable optional modules 45 | if: ${{ matrix.opt_modules }} 46 | run: | 47 | echo "#define M3_USE_PMORE" >> dreambbs.conf 48 | echo "#define M3_USE_PFTERM" >> dreambbs.conf 49 | - 50 | name: Build project 51 | run: | 52 | touch dreambbs.conf 53 | mkdir build 54 | cd build 55 | cmake "-DUSE_CXX=$USE_CXX" .. 56 | make 57 | env: 58 | USE_CXX: ${{ matrix.language == 'C++' && 'ON' || 'OFF' }} 59 | - 60 | name: Run tests 61 | continue-on-error: true 62 | run: | 63 | cd build 64 | make test 65 | - 66 | name: Perform CodeQL analysis 67 | uses: github/codeql-action/analyze@v4 68 | -------------------------------------------------------------------------------- /maple/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # maple/CMakeLists.txt ( NCKU CCNS WindTop-DreamBBS 3.0 )# 3 | # ------------------------------------------------------- # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for DreamBBS main programs # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------- # 8 | 9 | include(${PROJECT_SOURCE_DIR}/so/so.cmake) 10 | 11 | EXPORT_CONF(${CMAKE_CURRENT_SOURCE_DIR}/make_export.conf) 12 | 13 | add_executable(bbsd 14 | acct.c bbsd.c board.c cache.c edit.c 15 | gem.c mail.c menu.c more.c post.c 16 | talk.c visio.c xover.c socket.c popupmenu.c 17 | window.c myfavorite.c 18 | ) 19 | target_compile_options(bbsd PRIVATE -imacros${EXPORT_MAPLE}) 20 | 21 | if(USE_BBSLUA) 22 | target_compile_options(bbsd PRIVATE ${LUA_CFLAGS}) 23 | endif() 24 | 25 | if(USE_BBSRUBY) 26 | target_compile_options(bbsd PRIVATE ${RUBY_CFLAGS}) 27 | endif() 28 | 29 | if(USE_PFTERM) 30 | target_sources(bbsd PRIVATE pfterm.c) 31 | endif() 32 | 33 | if(USE_PMORE) 34 | target_sources(bbsd PRIVATE pmore.c) 35 | endif() 36 | 37 | if(NO_SO) 38 | if(USE_BBSLUA) 39 | target_link_libraries(bbsd PRIVATE ${LUA_LDFLAGS}) 40 | endif() 41 | 42 | if(USE_BBSRUBY) 43 | target_link_libraries(bbsd PRIVATE ${RUBY_LDFLAGS}) 44 | endif() 45 | 46 | foreach(module IN LISTS SO) 47 | unset(so_${module}_LIB_DEPENDS CACHE) 48 | target_sources(bbsd PRIVATE $) 49 | endforeach() 50 | endif() 51 | 52 | add_executable(xchatd xchatd.c) 53 | 54 | install( 55 | TARGETS bbsd xchatd 56 | DESTINATION bin${BBSVER} 57 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE 58 | ) 59 | install( 60 | CODE "execute_process(COMMAND chown -R ${BBSUSR}:${BBSGROUP} ${CMAKE_INSTALL_PREFIX}/bin${BBSVER})" 61 | CODE "string(TIMESTAMP BUILDTIME %s)" 62 | CODE "execute_process(COMMAND mv -f ${CMAKE_INSTALL_PREFIX}/bin${BBSVER}/bbsd ${CMAKE_INSTALL_PREFIX}/bin${BBSVER}/bbsd.\${BUILDTIME})" 63 | CODE "execute_process(COMMAND ln -sv ${CMAKE_INSTALL_PREFIX}/bin${BBSVER}/bbsd.\${BUILDTIME} ${CMAKE_INSTALL_PREFIX}/bin${BBSVER}/bbsd)" 64 | ) 65 | -------------------------------------------------------------------------------- /include/dns.h: -------------------------------------------------------------------------------- 1 | #ifndef DNS_H 2 | 3 | #define DNS_H 4 | /*-------------------------------------------------------*/ 5 | /* lib/dns.h ( NTHU CS MapleBBS Ver 3.00 ) */ 6 | /*-------------------------------------------------------*/ 7 | /* target : header file for DNS routines */ 8 | /* create : 96/11/20 */ 9 | /* update : 96/12/15 */ 10 | /*-------------------------------------------------------*/ 11 | 12 | #define _DEFAULT_SOURCE 1 13 | 14 | #include "config.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "cppdef.h" 27 | 28 | #ifndef INADDR_NONE 29 | #define INADDR_NONE 0xffffffff 30 | #endif 31 | #define INADDR_FMT "%u.%u.%u.%u" 32 | #define INADDR6_FMT "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x" 33 | 34 | typedef union 35 | { 36 | sa_family_t family; 37 | struct sockaddr_in v4; 38 | struct sockaddr_in6 v6; 39 | } ip_addr; /* SHMDATA(raw); dependency(UTMP) */ 40 | 41 | #define IPADDR_NONE LISTLIT(ip_addr){0} 42 | 43 | /* 44 | * The standard udp packet size PACKETSZ (512) is not sufficient for some 45 | * nameserver answers containing very many resource records. The resolver may 46 | * switch to tcp and retry if it detects udp packet overflow. Also note that 47 | * the resolver routines res_query and res_search return the size of the 48 | * untruncated answer in case the supplied answer buffer it not big enough 49 | * to accommodate the entire answer. 50 | */ 51 | 52 | #if PACKETSZ > 1024 53 | #define MAXPACKET PACKETSZ 54 | #else 55 | #define MAXPACKET 1024 /* max packet size used internally by BIND */ 56 | #endif 57 | 58 | #define MAX_MXLIST 1024 59 | 60 | typedef union 61 | { 62 | HEADER hdr; 63 | unsigned char buf[MAXPACKET]; 64 | } querybuf; /* response of DNS query */ 65 | 66 | static inline unsigned short 67 | getshort(const unsigned char *c) 68 | { 69 | unsigned short u; 70 | 71 | u = c[0]; 72 | return (u << 8) + c[1]; 73 | } 74 | 75 | #endif /* DNS_H */ 76 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.so 19 | *.so.* 20 | *.dylib 21 | 22 | # Executables 23 | *.out 24 | *.app 25 | *.i*86 26 | *.x86_64 27 | *.hex 28 | 29 | # Debug files 30 | *.dSYM/ 31 | *.su 32 | 33 | # config for any BBS sites 34 | /dreambbs.conf 35 | make_export.conf 36 | maple/make_export.conf 37 | 38 | # git version info 39 | verinfo_export.conf 40 | 41 | # add split-out build directory for cmake 42 | build/ 43 | 44 | innbbsd/bbslink 45 | innbbsd/innbbsd 46 | 47 | maple/bbsd 48 | maple/xchatd 49 | 50 | test/lib_splay 51 | test/lib_str_decode 52 | test/lib_str_pat 53 | test/lib_str_xor 54 | test/lib_from_parse 55 | test/lib_xsort 56 | test/testsize 57 | test/lib_f_mv 58 | test/lib_f_cp 59 | test/lib_f_rm 60 | 61 | util/account 62 | util/acl-sort 63 | util/acpro 64 | util/addpost 65 | util/addsong 66 | util/backup 67 | util/base64encode 68 | util/bbsmail 69 | util/bmw-dump 70 | util/brdmail 71 | util/brdstat 72 | util/brdcheck 73 | util/camera 74 | util/checkemail 75 | util/classtable_alert 76 | util/clean_acl 77 | util/countage 78 | util/countbirth 79 | util/counter 80 | util/countstar 81 | util/dump-brdstat 82 | util/expire 83 | util/gem-check 84 | util/gem-index 85 | util/hdr-dump 86 | util/mailexpire 87 | util/mailpost 88 | util/mailtoall 89 | util/makeUSR 90 | util/makefw 91 | util/makeusrno 92 | util/match 93 | util/msgall 94 | util/outgo 95 | util/poststat 96 | util/readBENZ 97 | util/readFRIENZ 98 | util/readUSR 99 | util/reaper 100 | util/redir 101 | util/resetvmail 102 | util/restorebrd 103 | util/restoregem 104 | util/restoreusr 105 | util/rmbadmail 106 | util/showACCT 107 | util/showBRD 108 | util/stopperm 109 | util/template 110 | util/topusr 111 | util/tranBRD 112 | util/transacct 113 | util/userno 114 | util/utmp-dump 115 | 116 | # Processed sample files with real values 117 | sample/bbsd.service 118 | sample/bbsd_unixsocket.service 119 | sample/crontab 120 | sample/startbbs.service 121 | sample/xchatd.service 122 | 123 | # Processed scripts with real values 124 | scripts/checkACCT.sh 125 | scripts/checkbrdDIR.sh 126 | scripts/checkusrDIR.sh 127 | scripts/clean.sh 128 | scripts/start.sh 129 | scripts/top.sh 130 | -------------------------------------------------------------------------------- /util/base64encode.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* util/base64encode.c ( YZU WindTopBBS Ver 3.00 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* target : */ 5 | /* create : */ 6 | /* update : */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #include "bbs.h" 10 | 11 | /* ----------------------------------------------------- */ 12 | /* encode BASE64 */ 13 | /* ----------------------------------------------------- */ 14 | 15 | 16 | void 17 | base64_encode(FILE *in, FILE *out) 18 | { 19 | const char *const ascii = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; 20 | char base[3], *dst; 21 | char dest[73]; 22 | unsigned char c1, c2, c3; 23 | int n; 24 | 25 | dst = dest; 26 | 27 | while ((n=fread(base, 1, sizeof(base), in))) 28 | { 29 | 30 | c1 = base[0]; 31 | c2 = base[1]; 32 | c3 = base[2]; 33 | *dst++ = ascii[c1 >> 2]; 34 | if (n==1) 35 | { 36 | *dst++ = ascii[(c1 & 0x3) << 4]; 37 | *dst++ = '='; 38 | *dst++ = '='; 39 | break; 40 | } 41 | if (n==2) 42 | { 43 | *dst++ = ascii[(c1 & 0x3) << 4 | (c2 & 0xf0) >> 4]; 44 | *dst++ = ascii[(c2 & 0xf) << 2]; 45 | *dst++ = '='; 46 | break; 47 | } 48 | // n==3 49 | { 50 | *dst++ = ascii[(c1 & 0x3) << 4 | (c2 & 0xf0) >> 4]; 51 | *dst++ = ascii[(c2 & 0xf) << 2 | (c3 & 0xc0) >> 6]; 52 | *dst++ = ascii[(c3 & 0x3f)]; 53 | } 54 | if ((dst - dest) >= 72) 55 | { 56 | *dst = '\0'; 57 | fprintf(out, "%s\n", dest); 58 | dst = dest; 59 | } 60 | } 61 | if ((dst - dest) > 0) 62 | { 63 | *dst = '\0'; 64 | fprintf(out, "%s\n", dest); 65 | } 66 | } 67 | 68 | 69 | int 70 | main( 71 | int argc, 72 | char *argv[]) 73 | { 74 | 75 | if (argc > 1) 76 | { 77 | fclose(stdin); 78 | stdin = fopen(argv[1], "r"); 79 | } 80 | if (stdin) 81 | base64_encode(stdin, stdout); 82 | else 83 | fprintf(stdout, "error open file\n"); 84 | 85 | return 0; 86 | } 87 | -------------------------------------------------------------------------------- /scripts/verinfo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # prevent localized logs 4 | LC_ALL=C.UTF-8 5 | export LC_ALL 6 | 7 | source_dir="${source_dir:-"."}" 8 | build_make="$1" 9 | build_arch="$2" 10 | 11 | format_url() { 12 | echo "$@" | sed 's/^https\?:\/\///g' | sed 's/\.git$//g' 13 | } 14 | 15 | format_commit() { 16 | echo "r$(git rev-list --count "$1" 2>/dev/null)/$(git rev-parse --short "$1" 2>/dev/null)" 17 | } 18 | 19 | build_branch="$(git symbolic-ref --short HEAD 2>/dev/null)" 20 | # if [ -z "${build_branch}" ]; then 21 | # build_branch="" 22 | # fi 23 | 24 | build_head="$(format_commit HEAD)" 25 | if ! git diff --quiet 2>/dev/null; then 26 | build_head="${build_head} M" 27 | fi 28 | 29 | # `branch..pushRemote` > `remote.pushDefault` > `branch..remote` 30 | build_remote="$(git config --get "branch.${build_branch}.pushRemote" 2>/dev/null)" 31 | if [ -z "${build_remote}" ]; then 32 | build_remote="$(git config --get "remote.pushDefault" 2>/dev/null)" 33 | fi 34 | if [ -z "${build_remote}" ]; then 35 | build_remote="$(git config --get "branch.${build_branch}.remote" 2>/dev/null)" 36 | fi 37 | # `/.merge>` > `/` > `/master` > `origin/master` 38 | build_branch_remote="${build_remote}/$(git config --get "branch.${build_branch}.merge" 2>/dev/null | sed 's/^.*\///g')" 39 | if ! git rev-parse -q --verify "${build_branch_remote}" >/dev/null; then 40 | build_branch_remote="${build_remote}/${build_branch}" 41 | fi 42 | if ! git rev-parse -q --verify "${build_branch_remote}" >/dev/null; then 43 | build_branch_remote="${build_remote}/master" 44 | fi 45 | if ! git rev-parse -q --verify "${build_branch_remote}" >/dev/null; then 46 | build_branch_remote="origin/master" 47 | fi 48 | build_head_remote="$(format_commit ${build_branch_remote})" 49 | build_remote="${build_branch_remote%/*}" 50 | build_branch_remote="${build_branch_remote##*/}" 51 | 52 | build_remote_url="$(format_url "$(git config --get "remote.${build_remote}.url" 2>/dev/null)")" 53 | 54 | build_date="$(date "+%Y-%m-%d %T %z")" 55 | build_time="$(date -d"${build_date}" "+%s")" 56 | 57 | export_file="${source_dir}/verinfo_export.conf" 58 | 59 | printf "\033[1;36mGenerating '%s'...\033[0m\n" "${export_file}" 60 | iconv -t big5 -o "${export_file}" < 4 | #include "dao.h" 5 | 6 | GCC_CONSTEXPR bool is_alnum(int ch) 7 | { 8 | return ((ch >= '0' && ch <= '9') || 9 | (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')); 10 | } 11 | 12 | GCC_CONSTEXPR bool is_alpha(int ch) 13 | { 14 | return ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')); 15 | } 16 | 17 | GCC_PURE bool is_fname(const char *str) 18 | { 19 | int ch; 20 | 21 | ch = *str; 22 | if (ch == '/') 23 | return false; 24 | 25 | do 26 | { 27 | if (!is_alnum(ch) && !strchr("-._/+@", ch)) 28 | return false; 29 | } 30 | while ((ch = *++str)); 31 | return true; 32 | } 33 | 34 | /* ----------------------------------------------------- */ 35 | /* transform to real path & security check */ 36 | /* ----------------------------------------------------- */ 37 | 38 | int is_fpath(char *path) 39 | { 40 | int level; 41 | char *source, *target; 42 | 43 | level = 0; 44 | source = target = path; 45 | 46 | 47 | for (;;) 48 | { 49 | int ch = *source; 50 | 51 | if (ch == '/') 52 | { 53 | int next; 54 | 55 | next = source[1]; 56 | 57 | if (next == '/') 58 | { 59 | return 0; /* [//] */ 60 | } 61 | else if (next == '.') 62 | { 63 | next = source[2]; 64 | 65 | if (next == '/') 66 | return 0; /* [/./] */ 67 | 68 | if (next == '.' && source[3] == '/') 69 | { 70 | /* -------------------------- */ 71 | /* abc/xyz/../def ==> abc/def */ 72 | /* -------------------------- */ 73 | 74 | for (;;) 75 | { 76 | if (target <= path) 77 | return 0; 78 | 79 | target--; 80 | if (*target == '/') 81 | break; 82 | } 83 | 84 | source += 3; 85 | continue; 86 | } 87 | } 88 | 89 | level++; 90 | } 91 | 92 | *target = ch; 93 | 94 | if (ch == 0) 95 | return level; 96 | 97 | target++; 98 | source++; 99 | } 100 | } 101 | 102 | #define STRICT_FQDN_EMAIL 103 | 104 | GCC_PURE int not_addr(const char *addr) 105 | { 106 | int ch, mode; 107 | 108 | mode = -1; 109 | 110 | while ((ch = *addr)) 111 | { 112 | if (ch == '@') 113 | { 114 | if (++mode) 115 | break; 116 | } 117 | 118 | #ifdef STRICT_FQDN_EMAIL 119 | else if ((ch != '.') && (ch != '-') && (ch != '_') && !is_alnum(ch)) 120 | #else 121 | else if (!is_alnum(ch) && !strchr(".-_[]%!:", ch)) 122 | #endif 123 | 124 | return 1; 125 | 126 | addr++; 127 | } 128 | 129 | return mode; 130 | } 131 | -------------------------------------------------------------------------------- /lib/proc.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* lib/proc.c ( NCKU CCNS WindTop-DreamBBS 3.0 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* Author: Wei-Cheng Yeh (IID) */ 5 | /* Target: Process manipulation library for DreamBBS */ 6 | /* Create: 2020/02/24 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #include "config.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "dao.h" 17 | 18 | /* `proc_run*()`: Run executable `path` in a child process */ 19 | 20 | static int runv(bool wait, const char *path, const char *argv[]) 21 | { 22 | const pid_t pid = fork(); 23 | 24 | switch (pid) 25 | { 26 | case 0: // Children 27 | if (!wait) 28 | { 29 | /* Detach from parent */ 30 | setsid(); 31 | signal(SIGHUP, SIG_IGN); 32 | } 33 | execv(path, (char **)argv); 34 | exit(127); // `execv()` failed 35 | 36 | case -1: // Error 37 | return -1; 38 | 39 | default: 40 | if (wait) 41 | waitpid(pid, &SINKVAL(int), 0); 42 | return 0; 43 | } 44 | } 45 | 46 | static int runvl(bool wait, const char *path, const char *arg0, va_list args) 47 | { 48 | /* Collect args first */ 49 | 50 | int argc = 0; 51 | int argv_len = 8; 52 | const char **argv = (const char **)malloc(sizeof(const char *) * argv_len); 53 | const char *ptr; 54 | int ret; 55 | 56 | argv[argc++] = arg0; 57 | 58 | if (arg0) 59 | { 60 | while ((ptr = va_arg(args, const char *))) 61 | { 62 | argv[argc++] = ptr; 63 | if (argc >= argv_len) 64 | { 65 | const char **argv_new = (const char **)realloc(argv, sizeof(const char *) * (argv_len *= 2)); 66 | if (!argv_new) 67 | return -1; // `realloc()` failed 68 | argv = argv_new; 69 | } 70 | } 71 | 72 | argv[argc++] = NULL; 73 | } 74 | 75 | /* And then invoke it */ 76 | 77 | ret = runv(wait, path, argv); 78 | free(argv); 79 | return ret; 80 | } 81 | 82 | int proc_runv(const char *path, const char *argv[]) 83 | { 84 | return runv(true, path, argv); 85 | } 86 | 87 | /* Variadic version for convenience */ 88 | GCC_SENTINEL(0) 89 | int proc_runl(const char *path, const char *arg0, ...) 90 | { 91 | int ret; 92 | va_list args; 93 | va_start(args, arg0); 94 | ret = runvl(true, path, arg0, args); 95 | va_end(args); 96 | return ret; 97 | } 98 | 99 | /* Run in background */ 100 | int proc_runv_bg(const char *path, const char *argv[]) 101 | { 102 | return runv(false, path, argv); 103 | } 104 | 105 | GCC_SENTINEL(0) 106 | int proc_runl_bg(const char *path, const char *arg0, ...) 107 | { 108 | int ret; 109 | va_list args; 110 | va_start(args, arg0); 111 | ret = runvl(false, path, arg0, args); 112 | va_end(args); 113 | return ret; 114 | } 115 | -------------------------------------------------------------------------------- /include/fnv_hash.h: -------------------------------------------------------------------------------- 1 | #ifndef FNV_HASH_H_ 2 | #define FNV_HASH_H_ 3 | /* 4 | * Fowler / Noll / Vo Hash (FNV Hash) 5 | * http://www.isthe.com/chongo/tech/comp/fnv/ 6 | * 7 | * This is an implementation of the algorithms posted above. 8 | * This file is placed in the public domain by Peter Wemm. 9 | * 10 | * $FreeBSD: src/sys/sys/fnv_hash.h,v 1.2 2001/03/20 02:10:18 peter Exp $ 11 | */ 12 | 13 | typedef unsigned int Fnv32_t; 14 | typedef unsigned long long Fnv64_t; 15 | 16 | #define FNV1_32_INIT 33554467UL 17 | #define FNV1_64_INIT 0xcbf29ce484222325ULL 18 | 19 | #define FNV_32_PRIME 0x01000193UL 20 | #define FNV_64_PRIME 0x100000001b3ULL 21 | 22 | static __inline Fnv32_t 23 | fnv_32_buf(const void *buf, size_t len, Fnv32_t hval) 24 | { 25 | const unsigned char *s = (const unsigned char *)buf; 26 | 27 | while (len-- != 0) { 28 | hval *= FNV_32_PRIME; 29 | hval ^= *s++; 30 | } 31 | return hval; 32 | } 33 | 34 | static __inline Fnv32_t 35 | fnv_32_str(const char *str, Fnv32_t hval) 36 | { 37 | const unsigned char *s = (const unsigned char *)str; 38 | Fnv32_t c; 39 | 40 | while ((c = *s++) != 0) { 41 | hval *= FNV_32_PRIME; 42 | hval ^= c; 43 | } 44 | return hval; 45 | } 46 | 47 | static __inline Fnv32_t 48 | fnv1a_32_str(const char *str, Fnv32_t hval) 49 | { 50 | const unsigned char *s = (const unsigned char *)str; 51 | Fnv32_t c; 52 | 53 | while ((c = *s++) != 0) { 54 | hval ^= c; 55 | hval *= FNV_32_PRIME; 56 | } 57 | return hval; 58 | } 59 | 60 | static __inline Fnv32_t 61 | fnv1a_32_strcase(const char *str, Fnv32_t hval) 62 | { 63 | const unsigned char *s = (const unsigned char *)str; 64 | Fnv32_t c; 65 | 66 | while ((c = *s++) != 0) { 67 | hval ^= toupper(c); 68 | hval *= FNV_32_PRIME; 69 | } 70 | return hval; 71 | } 72 | 73 | static __inline Fnv32_t 74 | fnv1a_32_dbcs_strcase(const char *str, Fnv32_t hval) 75 | { 76 | const unsigned char *s = (const unsigned char *)str; 77 | Fnv32_t c; 78 | char isDBCS = 0; 79 | 80 | while ((c = *s++) != 0) { 81 | if (isDBCS) 82 | { 83 | // 2nd DBCS 84 | isDBCS = 0; 85 | } else { 86 | // ASCII? 87 | if (c < 0x80) 88 | c = toupper(c); 89 | else 90 | isDBCS = 1; 91 | } 92 | hval ^= c; 93 | hval *= FNV_32_PRIME; 94 | } 95 | return hval; 96 | } 97 | 98 | static __inline Fnv64_t 99 | fnv_64_buf(const void *buf, size_t len, Fnv64_t hval) 100 | { 101 | const unsigned char *s = (const unsigned char *)buf; 102 | 103 | while (len-- != 0) { 104 | hval *= FNV_64_PRIME; 105 | hval ^= *s++; 106 | } 107 | return hval; 108 | } 109 | 110 | static __inline Fnv64_t 111 | fnv_64_str(const char *str, Fnv64_t hval) 112 | { 113 | const unsigned char *s = (const unsigned char *)str; 114 | Fnv64_t c; 115 | 116 | while ((c = *s++) != 0) { 117 | hval *= FNV_64_PRIME; 118 | hval ^= c; 119 | } 120 | return hval; 121 | } 122 | 123 | static __inline Fnv64_t 124 | fnv1a_64_strcase(const char *str, Fnv64_t hval) 125 | { 126 | const unsigned char *s = (const unsigned char *)str; 127 | Fnv64_t c; 128 | 129 | while ((c = *s++) != 0) { 130 | hval ^= toupper(c); 131 | hval *= FNV_64_PRIME; 132 | } 133 | return hval; 134 | } 135 | 136 | #define FNV1A_CHAR(c, hval) (void) ( (hval)^=(unsigned char)(c), (hval)*=FNV_32_PRIME, (void)0 ) 137 | #endif 138 | -------------------------------------------------------------------------------- /maple/Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ # 2 | # maple/Makefile ( NTHU CS MapleBBS Ver 3.x ) # 3 | # ------------------------------------------------------ # 4 | # author : opus.bbs@bbs.cs.nthu.edu.tw # 5 | # target : Makefile for MapleBBS main programs # 6 | # create : 95/03/29 # 7 | # update : 18/03/28 # 8 | # ------------------------------------------------------ # 9 | 10 | SRCROOT = $(.CURDIR)/.. 11 | EXPORT_FILE = $(.CURDIR)/make_export.conf 12 | .include "$(SRCROOT)/dreambbs.mk" 13 | 14 | .if $(NO_SO) 15 | .include "$(SRCROOT)/so/so.mk" 16 | .endif 17 | 18 | CFLAGS += $(CFLAGS_MAPLE) 19 | 20 | .if $(USE_BBSLUA) 21 | CFLAGS += $(LUA_CFLAGS) 22 | .endif 23 | 24 | .if $(USE_BBSRUBY) 25 | CFLAGS += $(RUBY_CFLAGS) 26 | .endif 27 | 28 | .if $(USE_PFTERM) 29 | SRC += pfterm.c 30 | OBJ += pfterm.o 31 | .endif 32 | 33 | SRC += acct.c bbsd.c board.c cache.c edit.c \ 34 | gem.c mail.c menu.c more.c post.c \ 35 | talk.c visio.c xover.c socket.c popupmenu.c \ 36 | window.c myfavorite.c 37 | 38 | OBJ += acct.o bbsd.o board.o cache.o edit.o \ 39 | gem.o mail.o menu.o more.o post.o \ 40 | talk.o visio.o xover.o socket.o popupmenu.o \ 41 | window.o myfavorite.o 42 | 43 | .if $(USE_PMORE) 44 | SRC += pmore.c 45 | OBJ += pmore.o 46 | .endif 47 | 48 | .if $(NO_SO) 49 | SO_SRC = $(SO:R:@v@$(SRCROOT)/so/$v.c@) # Add path 50 | SO_OBJ = $(SO:R:@v@$(SRCROOT)/so/$v.o@) 51 | 52 | .if $(USE_BBSLUA) 53 | LDFLAGS += $(LUA_LDFLAGS) $(LUA_LDFLAGS_ARCHI) 54 | .if !$(USE_LUAJIT) 55 | SO_SRC += $(SRCROOT)/so/bbsluaext.c 56 | SO_OBJ += $(SRCROOT)/so/bbsluaext.o 57 | .endif 58 | .endif 59 | 60 | .if $(USE_BBSRUBY) 61 | LDFLAGS += $(RUBY_LDFLAGS) $(RUBY_LDFLAGS_ARCHI) 62 | .endif 63 | 64 | SRC += $(SO_SRC) 65 | OBJ += $(SO_OBJ) 66 | 67 | .for target in $(SO_OBJ) 68 | $(target): 69 | $(CC) $(CFLAGS) -c $(target:R).c -o $(target) 70 | .endfor 71 | .endif 72 | 73 | EXE = bbsd xchatd 74 | 75 | .SUFFIXES: .o .c 76 | 77 | .c.o: ; $(CC) $(CFLAGS) -c $*.c 78 | 79 | all: $(EXE) 80 | 81 | xchatd: xchatd.o 82 | $(CC) -o $@ $? $(LDFLAGS) 83 | 84 | bbsd: $(OBJ) 85 | $(CC) $(MAKEFLAG) -o $@ $(OBJ) $(LDFLAGS) $(LIBS) 86 | 87 | maple.p: $(SRC) 88 | $(CPROTO) -o $@ $? 89 | 90 | export: 91 | @> $(EXPORT_FILE) 92 | @$("$(NO_SO_CLI:M*YES*)" != "" :? $(EXPORTCONF$(exconf::= NO_SO)$(exvalue::= 1)) :) 93 | 94 | configure: 95 | @printf "\033[1;36mGenerating '$(EXPORT_FILE)'...\033[0m\n" >&2 96 | @$(DREAMBBS_MK::=) 97 | @sh -c "$(MAKE) export $(MAKEFLAGS)" 98 | @printf "\033[1;33m" 99 | @cat $(EXPORT_FILE) 100 | @printf "\033[m" 101 | @$(TARGETS_REST::=$(.TARGETS:tW:C/^ *configure *//)) 102 | # Continue execution with a new `bmake` instace and stop current `bmake` instance 103 | @if [ "$(TARGETS_REST)" ]; then sh -c "$(MAKE) $(TARGETS_REST) $(MAKEFLAGS)"; printf "\033[1;36mJob done. Force stop.\033[m\n" >&2; false; fi 104 | 105 | install: $(EXE) 106 | $(INSTALL) -d "$(BBSHOME)/bin$(BBSVER)" 107 | $(INSTALL) -m 0755 $? "$(BBSHOME)/bin$(BBSVER)" 108 | mv -f "$(BBSHOME)/bin$(BBSVER)/bbsd" "$(BBSHOME)/bin$(BBSVER)/bbsd.$(BUILDTIME)" 109 | ln -sv "$(BBSHOME)/bin$(BBSVER)/bbsd.$(BUILDTIME)" "$(BBSHOME)/bin$(BBSVER)/bbsd" 110 | 111 | clean: 112 | rm -rf $(OBJ) $(EXE) *~ *.o *.so *.p tags 113 | 114 | tags: $(SRC) $(SRCROOT)/include/*.h $(SRCROOT)/lib/*.c 115 | exctags $(SRC) $(SRCROOT)/include/*.h $(SRCROOT)/lib/*.c 116 | 117 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # Makefile ( NTHU CS MapleBBS Ver 3.x ) # 3 | # ------------------------------------------------------- # 4 | # target : Makefile for ALL # 5 | # create : 00/02/12 # 6 | # update : 18/03/28 # 7 | # ------------------------------------------------------- # 8 | 9 | OPSYS != uname -o 10 | NPROC != getconf _NPROCESSORS_ONLN 11 | 12 | REALSRCROOT := $(.CURDIR) 13 | EXPORT_FILE := "$(REALSRCROOT)/make_export.conf" 14 | 15 | != touch $(EXPORT_FILE) # Needed by `include/config.h` 16 | .include "$(REALSRCROOT)/dreambbs.mk" 17 | .export 18 | != [ -s $(EXPORT_FILE) ] || rm $(EXPORT_FILE) # Empty 19 | 20 | # some directories need to be compiled: 21 | # lib innbbsd maple so util test 22 | 23 | all: deprecated verinfo 24 | @(cd lib; $(MAKE) all) 25 | @(cd maple; $(MAKE) all) 26 | @(cd util; $(MAKE) all) 27 | @(cd innbbsd; $(MAKE) all) 28 | @(cd sample; $(MAKE) all) 29 | @(cd scripts; $(MAKE) all) 30 | .if !$(NO_SO) 31 | @(cd so; $(MAKE) all) 32 | .endif 33 | @(cd test; $(MAKE) all) 34 | 35 | njob: deprecated verinfo 36 | @(cd lib; $(MAKE) -j$(NPROC) all) 37 | @(cd maple; $(MAKE) -j$(NPROC) all) 38 | @(cd util; $(MAKE) -j$(NPROC) all) 39 | @(cd innbbsd; $(MAKE) -j$(NPROC) all) 40 | @(cd sample; $(MAKE) -j$(NPROC) all) 41 | @(cd scripts; $(MAKE) -j$(NPROC) all) 42 | .if !$(NO_SO) 43 | @(cd so; $(MAKE) -j$(NPROC) all) 44 | .endif 45 | @(cd test; $(MAKE) -j$(NPROC) all) 46 | 47 | deprecated: .PHONY 48 | @printf "\033[1mMakefile: \033[35mwarning: \033[;1mbmake makefiles is deprecated and will be removed in DreamBBS 3.21.1. Use CMake to build the project instead.\n\033[m" 49 | 50 | export: deprecated 51 | @> $(EXPORT_FILE) 52 | @$(EXPORTVAR$(exconf::= BBSUSR)) 53 | @$(EXPORTVAR$(exconf::= BBSGROUP)) 54 | @$(EXPORTVAR$(exconf::= WWWGROUP)) 55 | @$(EXPORTVAR$(exconf::= BBSUID)) 56 | @$(EXPORTVAR$(exconf::= BBSGID)) 57 | @$(EXPORTVAR$(exconf::= WWWGID)) 58 | @$(EXPORTCONF$(exconf::= BBSHOME)$(exvalue::= \"$(BBSHOME)\")) 59 | @$(EXPORTCONF$(exconf::= BBSUTCZONE)$(exvalue::= \"$(BBSUTCZONE)\")) 60 | @$(EXPORTCONF$(exconf::= MRB_CONFIG)$(exvalue::= \"$(MRB_CONFIG)\")) 61 | @$(EXPORTCONF$(exconf::= BBS_SSHD_ROOT)$(exvalue::= \"$(BBS_SSHD_ROOT)\")) 62 | 63 | configure: deprecated 64 | @printf "\033[1;36mGenerating '$(EXPORT_FILE)'...\033[0m\n" >&2 65 | @$(DREAMBBS_MK::=) 66 | @sh -c "$(MAKE) export $(MAKEFLAGS)" 67 | @printf "\033[1;33m" 68 | @cat $(EXPORT_FILE) 69 | @printf "\033[m" 70 | @(cd maple; $(MAKE) configure $(MAKEFLAGS)) 71 | @$(TARGETS_REST::=$(.TARGETS:tW:C/^ *configure *//)) 72 | # Continue execution with a new `bmake` instace and stop current `bmake` instance 73 | @if [ "$(TARGETS_REST)" ]; then sh -c "$(MAKE) $(TARGETS_REST) $(MAKEFLAGS)"; printf "\033[1;36mJob done. Force stop.\033[m\n" >&2; false; fi 74 | 75 | verinfo: deprecated .PHONY 76 | @sh scripts/verinfo.sh "BSD-make" "$(MULTIARCH)" 77 | 78 | runtest: deprecated 79 | @(cd test; $(MAKE) runtest) 80 | 81 | install: deprecated 82 | @(cd maple; $(MAKE) install) 83 | @(cd innbbsd; $(MAKE) install) 84 | @(cd util; $(MAKE) install) 85 | .if !$(NO_SO) 86 | @(cd so; $(MAKE) install) 87 | .endif 88 | @(cd scripts; $(MAKE) install) 89 | 90 | clean: deprecated 91 | @(cd lib; $(MAKE) clean) 92 | @(cd test; $(MAKE) clean) 93 | @(cd maple; $(MAKE) clean) 94 | @(cd util; $(MAKE) clean) 95 | @(cd innbbsd; $(MAKE) clean) 96 | @(cd sample; $(MAKE) clean) 97 | @(cd scripts; $(MAKE) clean) 98 | @(cd so; $(MAKE) clean) 99 | -------------------------------------------------------------------------------- /include/so.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* so.h ( NCKU CCNS WindTop-DreamBBS 2.0 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* Author: Wei-Cheng Yeh (IID) */ 5 | /* Target: Prototype for shared object library */ 6 | /* Create: 2019/05/07 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #ifndef PROTO_SO_H 10 | #define PROTO_SO_H 11 | 12 | /* Macros for implementation-defined attributes */ 13 | #include "attrdef.h" 14 | 15 | #include "cppdef.h" 16 | 17 | /* ----------------------------------------------------- */ 18 | /* prototypes */ 19 | /* ----------------------------------------------------- */ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /* so/admin.c */ 26 | int Admin(void); 27 | 28 | /* so/adminutil.c */ 29 | int m_expire(void); 30 | int mail_to_bm(void); 31 | int mail_to_all(void); 32 | int bm_check(void); 33 | int user_check_bm(void); 34 | int update_all(void); 35 | int special_search(void); 36 | int m_xfile(void); 37 | int m_xhlp(void); 38 | int m_resetsys(const void *arg); 39 | 40 | /* so/aloha.c */ 41 | int t_aloha(void); 42 | 43 | /* so/ascii.c */ 44 | void input_tools(void); 45 | 46 | /* so/bank.c */ 47 | int money_back(void); 48 | int bank_main(void); 49 | 50 | /* so/banmail.c */ 51 | int BanMail(void); 52 | void post_mail(void); 53 | 54 | /* so/bbslua.c */ 55 | int bbslua(const char *fpath); 56 | int bbslua_isHeader(const char *ps, const char *pe); 57 | 58 | /* so/bbsruby.c */ 59 | void run_ruby(const char *fpath); 60 | 61 | /* so/bj.c */ 62 | int BlackJack(void); 63 | 64 | /* so/brdstat.c */ 65 | int main_bstat(XO *xo, int pos); 66 | 67 | /* so/chat.c */ 68 | int t_chat(void); 69 | 70 | /* so/chatmenu.c */ 71 | int Chatmenu(void); 72 | 73 | /* so/classtable2.c */ 74 | int main_classtable(void); 75 | 76 | /* so/cleanrecommend.c */ 77 | int clean(XO *xo, int pos); 78 | 79 | /* so/contact.c */ 80 | int Contact(void); 81 | 82 | /* so/gamef.c */ 83 | 84 | /* so/guessnum.c */ 85 | int mainNum(int fighting); 86 | int guessNum(void); 87 | int fightNum(void); 88 | 89 | /* so/innbbs.c */ 90 | int a_innbbs(void); 91 | 92 | /* so/list.c */ 93 | int List(void); 94 | 95 | /* so/mailgem.c */ 96 | int mailgem_gather(XO *xo, int pos); 97 | void mailgem_main(void); 98 | int gcheck(int level, char *fpath); 99 | 100 | /* so/memorandum.c */ 101 | int Memorandum(void); 102 | 103 | /* so/mine.c */ 104 | int Mine(void); 105 | 106 | /* so/newboard.c */ 107 | int XoNewBoard(void); 108 | 109 | /* so/observe.c */ 110 | int Observe_list(void); 111 | 112 | /* so/passwd.c */ 113 | int new_passwd(void); 114 | 115 | /* so/personal.c */ 116 | int personal_apply(void); 117 | int personal_admin(void); 118 | 119 | /* so/pip.c */ 120 | int p_pipple(void); 121 | #ifdef HAVE_PIP_FIGHT 122 | int pip_vf_fight(int fd, int first); 123 | #endif 124 | 125 | /* so/pipfun.c */ 126 | 127 | /* so/pnote.c */ 128 | int main_note(void); 129 | 130 | /* so/same_mail.c */ 131 | int same_mail(char *mail); 132 | 133 | /* so/shop.c */ 134 | int shop_main(void); 135 | 136 | /* so/showvote.c */ 137 | int Showvote(XO *xo, int pos); 138 | 139 | /* so/song.c */ 140 | int XoSongMain(void); 141 | int XoSongSub(void); 142 | int XoSongLog(void); 143 | int AddRequestTimes(void); 144 | 145 | /* so/violate.c */ 146 | int Violate(void); 147 | 148 | /* so/vote.c */ 149 | int vote_result(XO *xo); 150 | int XoVote(XO *xo); 151 | int SystemVote(void); 152 | 153 | /* so/xyz.c */ 154 | int x_siteinfo(void); 155 | 156 | #ifdef __cplusplus 157 | } /* extern "C" */ 158 | #endif 159 | 160 | #endif /* #define PROTO_SO_H */ 161 | -------------------------------------------------------------------------------- /include/pfterm.h: -------------------------------------------------------------------------------- 1 | #ifndef PFTERM_H 2 | #define PFTERM_H 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // Flat Terminal Data Type 6 | ////////////////////////////////////////////////////////////////////////// 7 | 8 | typedef unsigned char ftattr; // primitive attribute type 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | ////////////////////////////////////////////////////////////////////////// 15 | // Flat Terminal API 16 | ////////////////////////////////////////////////////////////////////////// 17 | 18 | //// common ncurse-like library interface 19 | 20 | // initialization 21 | void initscr (void); 22 | int resizeterm (int rows, int cols); 23 | int endwin (void); 24 | 25 | // attributes 26 | ftattr attrget (void); 27 | void attrset (ftattr attr); 28 | void attrsetfg (ftattr attr); 29 | void attrsetbg (ftattr attr); 30 | 31 | // cursor 32 | void getyx (int *y, int *x); 33 | void getmaxyx (int *y, int *x); 34 | void move (int y, int x); 35 | 36 | // clear 37 | void clear (void); // clrscr + move(0, 0) 38 | void clrtoeol (void); // end of line 39 | void clrtobot (void); 40 | // clear (non-ncurses) 41 | void clrtoln (int ln); // clear down to ln ( excluding ln, as [y, ln) ) 42 | void clrcurln (void); // whole line 43 | void clrtobeg (void); // begin of line 44 | void clrtohome (void); 45 | void clrscr (void); // clear and keep cursor untouched 46 | void clrregion (int r1, int r2); // clear [r1, r2], bi-directional. 47 | 48 | // window control 49 | void newwin (int nlines, int ncols, int y, int x); 50 | 51 | // flushing 52 | void refresh (void); // optimized refresh 53 | void doupdate (void); // optimized refresh, ignore input queue 54 | void redrawwin (void); // invalidate whole screen 55 | int typeahead (int fd); // prevent refresh if input queue is not empty 56 | 57 | // scrolling 58 | void scroll (void); // scroll up 59 | void rscroll (void); // scroll down 60 | void scrl (int rows); 61 | 62 | // output (ncurses flavor) 63 | void addch (unsigned char c); // equivalent to outc() 64 | void addstr (const char *s); // equivalent to outs() 65 | void addnstr (const char *s, int n); 66 | 67 | // output (non-ncurses) 68 | void outc (unsigned char c); 69 | void outs (const char *s); 70 | void outns (const char *s, int n); 71 | void outstr (const char *str); // prepare and print a complete string. 72 | void addstring (const char *str); // ncurses-like of outstr(). 73 | 74 | // readback 75 | int instr (char *str); 76 | int innstr (char *str, int n); // n includes \0 77 | int inansistr (char *str, int n); // n includes \0 78 | 79 | // deprecated 80 | void standout (void); 81 | void standend (void); 82 | 83 | // grayout advanced control 84 | void grayoutrect (int y, int yend, int x, int xend, int level); 85 | void grayout (int y, int end, int level); 86 | 87 | ////////////////////////////////////////////////////////////////////////// 88 | // environment specific 89 | ////////////////////////////////////////////////////////////////////////// 90 | void scr_dump (screen_backup_t *psb); 91 | void scr_redump (screen_backup_t *psb); 92 | void scr_free (screen_backup_t *psb); 93 | void scr_restore_free (screen_backup_t *psb); 94 | void scr_restore_keep (const screen_backup_t *psb); 95 | static inline void scr_restore (screen_backup_t *psb) { scr_restore_free(psb); } 96 | 97 | void move_ansi(int y, int x); 98 | void getyx_ansi(int *y, int *x); 99 | void region_scroll_up(int top, int bottom); 100 | 101 | #ifdef __cplusplus 102 | } /* extern "C" */ 103 | #endif 104 | 105 | 106 | #endif // PFTERM_H 107 | -------------------------------------------------------------------------------- /lib/logger.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* lib/logger.c ( NCKU CCNS WindTop-DreamBBS 3.0 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* Author: Wei-Cheng Yeh (IID) */ 5 | /* Target: Message logging library for DreamBBS */ 6 | /* Create: 2021/02/06 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #include "config.h" 10 | 11 | #include "logger.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #include "dao.h" 21 | 22 | static const char *const loglv_name[LOGLV_COUNT] = { 23 | "emerg", 24 | "alert", 25 | "crit", 26 | "err", 27 | "warn", 28 | "notice", 29 | "info", 30 | "debug", 31 | }; 32 | 33 | /* Log a formatted message with log level `level` using the setting of `logger` 34 | * Use `logger->file` if it is not `NULL`, 35 | * otherwise temporarily open and then close the file with path `logger->path` if it is not `NULL`, 36 | * otherwise output the message to `stderr`. 37 | * Messages with its log level >= `logger->lv_skip` will be ignored. 38 | * An extra newline will be appended to the message for output, 39 | * therefore it is not needed to include a trailing newline in `format`. */ 40 | GCC_FORMAT(3, 4) GCC_NONNULL(1, 3) 41 | void loggerf(const Logger *logger, enum LogLevel level, const char *format, ...) 42 | { 43 | if (level < 0 || level >= logger->lv_skip) 44 | return; 45 | 46 | /* Temporarily open the file if necessary */ 47 | FILE *const file = logger->file ? logger->file : logger->path ? fopen(logger->path, "a") : stderr; 48 | 49 | if (!file) 50 | return; 51 | 52 | const int fd = fileno(file); 53 | 54 | va_list args; 55 | va_start(args, format); 56 | 57 | char buf[32]; 58 | strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S%z", localtime(&TEMPLVAL(time_t, {time(NULL)}))); 59 | 60 | f_exlock(fd); 61 | 62 | fprintf(file, "%s [%s] %d: ", buf, loglv_name[level], INT(getpid())); 63 | vfprintf(file, format, args); 64 | fputc('\n', file); 65 | fflush(file); 66 | 67 | f_unlock(fd); 68 | 69 | va_end(args); 70 | 71 | /* Close the temporarily opened file */ 72 | if (!logger->file) 73 | fclose(file); 74 | } 75 | 76 | /* The default formatter for message logging with tag */ 77 | static void logger_tag_formatter_default(char *buf, size_t size, const char *tag, const char *msg) 78 | { 79 | snprintf(buf, size, "[%s] %s", tag, msg); 80 | } 81 | 82 | /* Log a message with tag and custom formatter to the file specified by `tlogger` 83 | * Use `tlogger->logger.file` if it is not `NULL`, 84 | * otherwise temporarily open and then close the file with path `tlogger->logger.path` if it is not `NULL`, 85 | * otherwise output the message to `stderr`. 86 | * If `tlogger->formatter` is `NULL`, the default formatter is used. 87 | * All messages are not ignored. 88 | * An extra newline will be appended to the message for output, 89 | * therefore it is not needed to add a trailing newline in the formatter. */ 90 | GCC_NONNULLS 91 | void logger_tag(const TLogger *tlogger, const char *tag, const char *msg) 92 | { 93 | const Logger *const logger = &tlogger->logger; 94 | FILE *const file = logger->file ? logger->file : logger->path ? fopen(logger->path, "a") : stderr; 95 | 96 | if (!file) 97 | return; 98 | 99 | void (*const formatter)(char *buf, size_t size, const char *mode, const char *msg) = 100 | tlogger->formatter ? tlogger->formatter : logger_tag_formatter_default; 101 | const int fd = fileno(file); 102 | 103 | char buf[512]; 104 | 105 | formatter(buf, sizeof(buf) - 1, tag, msg); // Reserve 1 byte for the trailing newline 106 | strcat(buf, "\n"); 107 | write(fd, buf, strlen(buf)); 108 | 109 | if (!logger->file) 110 | fclose(file); 111 | } 112 | -------------------------------------------------------------------------------- /lib/splay.c: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* lib/splay.c ( NTHU CS MapleBBS Ver 3.00 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* author : opus.bbs@bbs.cs.nthu.edu.tw */ 5 | /* target : splay-tree sort routines */ 6 | /* create : 97/03/29 */ 7 | /* update : 97/03/29 */ 8 | /*-------------------------------------------------------*/ 9 | 10 | #include "config.h" 11 | 12 | #include 13 | #include 14 | #include "splay.h" 15 | 16 | SplayNode *splay_in(SplayNode * top, 17 | void *data, int (*compare) (const void *lhs, const void *rhs)) 18 | { 19 | int splay_cmp; 20 | SplayNode *node, *l, *r, *x, N; 21 | 22 | node = (SplayNode *) malloc(sizeof(SplayNode)); 23 | node->data = data; 24 | 25 | if (top == NULL) 26 | { 27 | node->left = node->right = NULL; 28 | return node; 29 | } 30 | 31 | /* --------------------------------------------------- */ 32 | /* splay this splay tree */ 33 | /* --------------------------------------------------- */ 34 | 35 | N.left = N.right = NULL; 36 | l = r = &N; 37 | 38 | for (;;) 39 | { 40 | splay_cmp = compare(data, top->data); 41 | if (splay_cmp < 0) 42 | { 43 | if (!(x = top->left)) 44 | break; 45 | if ((splay_cmp = compare(data, x->data)) < 0) 46 | { 47 | /* rotate right */ 48 | 49 | top->left = x->right; 50 | x->right = top; 51 | top = x; 52 | if (top->left == NULL) 53 | break; 54 | } 55 | r->left = top; /* link right */ 56 | r = top; 57 | top = top->left; 58 | } 59 | else if (splay_cmp > 0) 60 | { 61 | if (!(x = top->right)) 62 | break; 63 | if ((splay_cmp = compare(data, x->data)) > 0) 64 | { 65 | /* rotate left */ 66 | 67 | top->right = x->left; 68 | x->left = top; 69 | top = x; 70 | if (top->right == NULL) 71 | break; 72 | } 73 | l->right = top; /* link left */ 74 | l = top; 75 | top = top->right; 76 | } 77 | else 78 | { 79 | break; 80 | } 81 | } 82 | 83 | l->right = top->left; /* assemble */ 84 | r->left = top->right; 85 | top->left = N.right; 86 | top->right = N.left; 87 | 88 | /* --------------------------------------------------- */ 89 | /* construct this splay tree */ 90 | /* --------------------------------------------------- */ 91 | 92 | if (splay_cmp < 0) 93 | { 94 | node->left = top->left; 95 | node->right = top; 96 | top->left = NULL; 97 | return node; 98 | } 99 | 100 | if (splay_cmp > 0) 101 | { 102 | node->right = top->right; 103 | node->left = top; 104 | top->right = NULL; 105 | return node; 106 | } 107 | 108 | /* duplicate entry */ 109 | 110 | free(node); 111 | return top; 112 | } 113 | 114 | void 115 | splay_out(const SplayNode * top, void (*data_out) (const void *data, FILE *fp), FILE *fp) 116 | { 117 | if (top == NULL) 118 | return; 119 | 120 | splay_out(top->left, data_out, fp); 121 | data_out(top->data, fp); 122 | splay_out(top->right, data_out, fp); 123 | } 124 | 125 | void 126 | splay_free(SplayNode * top, void (*data_free) (void *data)) 127 | { 128 | SplayNode *node; 129 | 130 | if (top == NULL) 131 | return; 132 | 133 | if ((node = top->left)) 134 | splay_free(node, data_free); 135 | 136 | if ((node = top->right)) 137 | splay_free(node, data_free); 138 | 139 | data_free(top->data); 140 | free(top); 141 | } 142 | -------------------------------------------------------------------------------- /lib/xsort.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | 3 | #include 4 | #include 5 | #include "dao.h" 6 | 7 | #define min(a, b) ((a) < (b) ? (a) : (b)) 8 | #undef TEST 9 | 10 | /* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". */ 11 | 12 | #define swapcode(TYPE, parmi, parmj, n) do { \ 13 | long i = (n) / sizeof (TYPE); \ 14 | TYPE *pi = (TYPE *) (parmi); \ 15 | TYPE *pj = (TYPE *) (parmj); \ 16 | do { \ 17 | TYPE t = *pi; \ 18 | *pi++ = *pj; \ 19 | *pj++ = t; \ 20 | } while (--i > 0); \ 21 | } while (0) 22 | 23 | #define SWAPINIT(a, es) (void) \ 24 | (swaptype = (((char *)(a) - (char *)0) % sizeof(long) || \ 25 | (es) % sizeof(long)) ? 2 : ((es) == sizeof(long)? 0 : 1), (void)0) 26 | 27 | static inline void swapfunc(char *a, char *b, int n, int swaptype) 28 | { 29 | if (swaptype <= 1) 30 | swapcode(long, a, b, n); 31 | else 32 | swapcode(char, a, b, n); 33 | } 34 | 35 | #define swap(a, b) do { \ 36 | if (swaptype == 0) { \ 37 | long t = *(long *)(a); \ 38 | *(long *)(a) = *(long *)(b); \ 39 | *(long *)(b) = t; \ 40 | } else \ 41 | swapfunc(a, b, es, swaptype); \ 42 | } while (0) 43 | 44 | #define vecswap(a, b, n) (void) ((void)(((n) > 0) && (swapfunc(a, b, n, swaptype), 0))) 45 | 46 | static inline char *med3(char *a, 47 | char *b, char *c, int (*cmp) (const void *lhs, const void *rhs)) 48 | { 49 | return cmp(a, b) < 0 ? 50 | (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a)) 51 | : (cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c)); 52 | } 53 | 54 | void xsort(void *a, size_t n, size_t es, int (*cmp) (const void *lhs, const void *rhs)) 55 | { 56 | char *pa, *pb, *pc, *pd, *pl, *pm, *pn; 57 | int d, r, swaptype, swap_cnt; 58 | 59 | SWAPINIT(a, es); 60 | 61 | loop: 62 | 63 | swap_cnt = 0; 64 | if (n < 7) 65 | { 66 | for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) 67 | for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0; pl -= es) 68 | swap(pl, pl - es); 69 | return; 70 | } 71 | 72 | pm = (char *)a + (n / 2) * es; 73 | 74 | if (n > 7) 75 | { 76 | pl = (char *)a; 77 | pn = (char *)a + (n - 1) * es; 78 | if (n > 40) 79 | { 80 | d = (n >> 3) * es; 81 | pl = med3(pl, pl + d, pl + d + d, cmp); 82 | pm = med3(pm - d, pm, pm + d, cmp); 83 | pn = med3(pn - 2 * d, pn - d, pn, cmp); 84 | } 85 | pm = med3(pl, pm, pn, cmp); 86 | } 87 | swap((char *)a, pm); 88 | pa = pb = (char *)a + es; 89 | 90 | pc = pd = (char *)a + (n - 1) * es; 91 | for (;;) 92 | { 93 | while (pb <= pc && (r = cmp(pb, a)) <= 0) 94 | { 95 | if (r == 0) 96 | { 97 | swap_cnt = 1; 98 | swap(pa, pb); 99 | pa += es; 100 | } 101 | pb += es; 102 | } 103 | while (pb <= pc && (r = cmp(pc, a)) >= 0) 104 | { 105 | if (r == 0) 106 | { 107 | swap_cnt = 1; 108 | swap(pc, pd); 109 | pd -= es; 110 | } 111 | pc -= es; 112 | } 113 | if (pb > pc) 114 | break; 115 | swap(pb, pc); 116 | swap_cnt = 1; 117 | pb += es; 118 | pc -= es; 119 | } 120 | 121 | if (swap_cnt == 0) 122 | { /* Switch to insertion sort */ 123 | for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es) 124 | for (pl = pm; pl > (char *)a && cmp(pl - es, pl) > 0; pl -= es) 125 | swap(pl, pl - es); 126 | return; 127 | } 128 | 129 | pn = (char *)a + n * es; 130 | r = min(pa - (char *)a, pb - pa); 131 | vecswap((char *)a, pb - r, r); 132 | 133 | r = min(pd - pc, pn - pd - es); 134 | vecswap(pb, pn - r, r); 135 | 136 | if ((r = pb - pa) > es) 137 | xsort(a, r / es, es, cmp); 138 | 139 | if ((r = pd - pc) > es) 140 | { 141 | /* Iterate rather than recurse to save stack space */ 142 | a = pn - r; 143 | n = r / es; 144 | goto loop; 145 | } 146 | /* xsort(pn - r, r / es, es, cmp); */ 147 | } 148 | -------------------------------------------------------------------------------- /lib/dl_lib.c: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------- */ 2 | /* author : thor.bbs@bbs.cs.nthu.edu.tw */ 3 | /* target : dynamic link modules library for maple bbs */ 4 | /* create : 99/02/14 */ 5 | /* update : / / */ 6 | /* ----------------------------------------------------- */ 7 | 8 | #include "config.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "dao.h" 18 | 19 | typedef struct /* Hashable */ 20 | { 21 | char *path; 22 | void *handle; 23 | } DL_list; 24 | 25 | DL_list *dl_pool; 26 | int dl_size, dl_head; 27 | 28 | #define DL_ALLOC_MIN 5 29 | 30 | #if defined(__OpenBSD__) 31 | #define DL_OPEN_FLAGS RTLD_LAZY 32 | #else 33 | #define DL_OPEN_FLAGS RTLD_NOW 34 | #endif 35 | 36 | /* `DL_list` manipulations */ 37 | 38 | static DL_list *DL_find(const char *path, int path_len) 39 | { 40 | const DL_list *const tail = dl_pool + dl_head; 41 | DL_list *p; 42 | for (p = dl_pool; p < tail; p++) 43 | { 44 | if (!strncmp(path, p->path, path_len)) 45 | break; 46 | } 47 | return p; 48 | } 49 | 50 | static DL_list *DL_insert(const char *path, int path_len) 51 | { 52 | DL_list *p; 53 | 54 | if (dl_head >= dl_size) 55 | { /* not enough space or not initialized */ 56 | dl_size += DL_ALLOC_MIN; 57 | dl_pool = (DL_list *) realloc(dl_pool, dl_size * sizeof(DL_list)); 58 | } 59 | 60 | p = DL_find(path, path_len); 61 | if (p >= dl_pool + dl_head) 62 | { /* not found */ 63 | p->path = strndup(path, path_len); 64 | p->handle = dlopen(p->path, DL_OPEN_FLAGS); 65 | dl_head++; 66 | } 67 | 68 | return p; 69 | } 70 | 71 | /* For preventing unloading a library in use */ 72 | /* `struct DL_handle *`: A opaque pointer for preventing misusage. */ 73 | 74 | #define DL_HANDLE_INUSE ((struct DL_handle *) -1) 75 | 76 | static struct DL_handle *DL_exchange_handle(const char *path, struct DL_handle *handle) 77 | { 78 | DL_list *const p = DL_find(path, strnlen(path, PATH_MAX)); 79 | const DL_list *const tail = dl_pool + dl_head; 80 | struct DL_handle *handle_prev = NULL; 81 | if (p < tail) /* Exchange if found */ 82 | { 83 | handle_prev = (struct DL_handle *)p->handle; 84 | p->handle = handle; 85 | } 86 | return handle_prev; 87 | } 88 | GCC_NODISCARD struct DL_handle *DL_hold(const char *path) 89 | { 90 | return DL_exchange_handle(path, DL_HANDLE_INUSE); 91 | } 92 | int DL_release(const char *path, struct DL_handle *handle) 93 | { 94 | return (bool)DL_exchange_handle(path, handle); 95 | } 96 | 97 | /* Dynamic library object getters */ 98 | 99 | /* format: "Xmodule_path:Xname" */ 100 | static inline char *DL_name_delim(const char *name) 101 | { 102 | return (char *)memchr(name, ':', strnlen(name, PATH_MAX)); 103 | } 104 | 105 | void *DL_get(const char *name) 106 | { 107 | const char *t = DL_name_delim(name); 108 | DL_list *p; 109 | if (!t) 110 | return NULL; 111 | 112 | p = DL_insert(name, t - name); 113 | if (!p->handle) /* IID.20200104: Failed to load the last time; try again */ 114 | p->handle = dlopen(p->path, DL_OPEN_FLAGS); 115 | if (!p->handle) /* Still failed; continue */ 116 | return NULL; 117 | 118 | return dlsym(p->handle, t+1); 119 | } 120 | 121 | void *DL_get_hotswap(const char *name) 122 | { 123 | const char *t = DL_name_delim(name); 124 | DL_list *p; 125 | if (!t) 126 | return NULL; 127 | 128 | p = DL_insert(name, t - name); 129 | if (p->handle && p->handle != DL_HANDLE_INUSE) 130 | { 131 | /* Unload the library to load a updated one */ 132 | dlclose(p->handle); 133 | p->handle = NULL; 134 | } 135 | if (!p->handle) 136 | p->handle = dlopen(p->path, DL_OPEN_FLAGS); 137 | if (!p->handle) 138 | return NULL; 139 | 140 | return dlsym(p->handle, t+1); 141 | } 142 | 143 | /* Dynamic library function invokers */ 144 | 145 | static int DL_invoke(int (*f)(va_list), ...) 146 | { 147 | va_list args; 148 | int ret; 149 | 150 | if (!f) /* not get func */ 151 | return -1; 152 | 153 | va_start(args, f); 154 | ret = (*f)(args); 155 | va_end(args); 156 | 157 | return ret; 158 | } 159 | 160 | int DL_func(const char *name, ...) 161 | { 162 | return DL_invoke((int (*)(va_list)) DL_get(name)); 163 | } 164 | int DL_func_hotswap(const char *name, ...) 165 | { 166 | return DL_invoke((int (*)(va_list)) DL_get_hotswap(name)); 167 | } 168 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DreamBBS 2 | 3 | Build status: `master` [![master branch build status](https://github.com/ccns/dreambbs/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/ccns/dreambbs/actions/workflows/build.yml?query=branch%3Amaster) 4 | 5 | [![](https://i.imgur.com/0EpI7Fa.png)](https://github.com/ccns/dreambbs) 6 | 7 | The current code of the BBS server for Dream-Land BBS at NCKU — . 8 | 9 | This project was based on Wind's Top BBS — — and has subsequently been developed by Pang-Wei Tsai ([cache](https://github.com/pwtsai)) and other volunteers from the Campus Computer & Network Society (CCNS — ) at National Cheng Kung University (NCKU) in Taiwan. 10 | 11 | For the copyright information of this project, please refer to `COPYRIGHT` and `VERSION`. 12 | 13 | Different licenses may apply to individual modules. Please refer to their source code file for the license. Such modules are list below. 14 | 15 | ## To Set up a New BBS site 16 | 17 | Please refer to for the instructions for setting up a BBS site using DreamBBS. 18 | 19 | Note that you would need to clone the repository *dreambbs_snap* — — for the essential files. 20 | 21 | If you have cloned this repository, you can also find the wiki contents on the branch "wiki". 22 | 23 | ## Project Layout 24 | 25 | * `CHANGELOG`: The changelog. Unmaintained since 2018. 26 | For more up-to-dated information, please refer to the release note pages of 27 | 28 | * `COPYRIGHT`: The historical copyright declaration from the MapleBBS 3 core team. 29 | 30 | * `VERSION`: The copyright information of the ancestors of this project as well as this project. 31 | 32 | * `dreambbs.conf`: The compile-time configuration file. 33 | * *Not present after cloning*. `sample/dreambbs.conf` is a basic example for this file. 34 | 35 | * `make_export.conf`: The automatically genetated compile-time configuration file. 36 | * *Not present after cloning*. This file will be generated upon the first build of the project and can be edited afterward. 37 | 38 | * `build/`: The recommended building directory. 39 | * *Not present after cloning*. Please refer to [To Set up a New BBS site](#to-set-up-a-new-bbs-site) for building instructions. 40 | 41 | * `sample/`: Sample configuration files and templates. Containing templates of [systemd](https://en.wikipedia.org/wiki/Systemd) service unit files. 42 | * `bbs-sshd.service.in`: Template file for starting *bbs-sshd*, an SSH-to-Telnet-over-UNIX-socket proxy server, Apache License 2.0 — . 43 | bbs-sshd is developed by Robert Wang (robertabcd) et al. 44 | * You can find the processed sample configuration files under `build/sample/` 45 | 46 | * `innbbsd/`: A [Usenet](https://en.wikipedia.org/wiki/Usenet) newsgroup client daemon. 47 | First developed by Shih-Kun Huang (skhuang) et al. for Eagles BBS–derived BBSes. 48 | Later maintained by Yu-Xuan Tu (itoc) specifically for MapleBBS 3 BBSes. 49 | 50 | * `include/`: The header files. Some header files are under `innbbsd/` instead. 51 | 52 | * `lib/`: The static library *libdao* (Data Abstract Operation). 53 | 54 | * `maple/`: The BBS server `bbsd` and the chat room–managing daemon `xchatd`. Containing frequently used modules. 55 | * `pmore.c`: The optional module *pmore* (piaip's more), BSD-like custom license. 56 | Developed by Hung-Te Lin (piaip) et al. 57 | * `pfterm.c`: The optional module *pfterm* (piaip's flat terminal system), BSD-like custom license. 58 | Developed by Hung-Te Lin (piaip) et al. 59 | * Installed to `${BBSHOME}/bin/` 60 | 61 | * `so/`: The shared libraries. Containing less frequently used modules. 62 | * `bbslua.c`: The optional module *BBS-Lua*, MIT license (Expat). 63 | Developed by Hung-Te Lin (piaip) et al. 64 | * `bbsluaext.c`: The dependency module *Lua BitOp* for `bbslua.c`, MIT license (Expat). 65 | Developed by Mike Pall et al. 66 | * `bbsruby.c`: The optional module *BBS-Ruby*, MIT license (Expat). 67 | Developed by Hung-Te Lin (piaip) et al. 68 | * Installed to `${BBSHOME}/bin/` if allowed to be compiled into shared libraries. 69 | 70 | * `util/`: Helper programs. Containing programs to be run periodly by [cron](https://en.wikipedia.org/wiki/Cron). 71 | 72 | * `scripts/`: Helper scripts and templates. Containing `wsproxy`. 73 | * `wsproxy/`: *wsproxy*, a Telnet-over-WebSocket server script for OpenResty, MIT license (Expat). 74 | Developed by Robert Wang (robertabcd) et al. 75 | * Installed to `${BBSHOME}/sh/` 76 | 77 | * `test/`: Test programs and scripts. Used for verifying the build. 78 | 79 | * `.github/`: The GitHub configurations. 80 | * `workflows/`: The GitHub Action automation configurations for aiding development. 81 | -------------------------------------------------------------------------------- /include/attrdef.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* attrdef.h ( NCKU CCNS WindTop-DreamBBS 2.0 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* Author: Wei-Cheng Yeh (IID) */ 5 | /* Target: Implementation-defined attribute macros */ 6 | /* : Some were adopted/adapted from PttBBS headers */ 7 | /* Create: 2019/09/25 */ 8 | /*-------------------------------------------------------*/ 9 | 10 | #ifndef ATTRDEF_H 11 | #define ATTRDEF_H 12 | 13 | /* Attributes about the arguments of a function */ 14 | 15 | /* For checking the arguments for variadic functions */ 16 | 17 | /* Indicates that the `ifmt`-th argument (`1` for the first) is a format string which should follow the `printf` syntax, 18 | * and that the `iarg`-th and the following arguments are the format arguments which should be consistent with the format string */ 19 | #ifndef GCC_CHECK_FORMAT 20 | #ifdef __GNUC__ 21 | #define GCC_CHECK_FORMAT(ifmt, iarg) __attribute__((format(printf, ifmt, iarg))) 22 | #else 23 | #define GCC_CHECK_FORMAT(ifmt, iarg) /* Ignored */ 24 | #endif 25 | #endif 26 | #define GCC_FORMAT GCC_CHECK_FORMAT 27 | 28 | /* Indicates that the `ri_nul`-th-to-last argument (`0` for the last) should be NULL */ 29 | #ifndef GCC_CHECK_SENTINEL 30 | #if defined __GNUC__ 31 | #define GCC_CHECK_SENTINEL(ri_nul) __attribute__((sentinel(ri_nul))) 32 | #else 33 | #define GCC_CHECK_SENTINEL(ri_nul) /* Ignored */ 34 | #endif 35 | #endif 36 | #define GCC_SENTINEL GCC_CHECK_SENTINEL 37 | 38 | /* For functions with pointer parameters */ 39 | 40 | /* Indicates that the specified arguments (`1` for the first) should not be NULL */ 41 | #if !defined GCC_CHECK_NONNULL_ALL || !defined GCC_CHECK_NONNULL 42 | #undef GCC_CHECK_NONNULL_ALL 43 | #undef GCC_CHECK_NONNULL 44 | #if defined __GNUC__ 45 | #define GCC_CHECK_NONNULL_ALL __attribute__((nonnull)) 46 | #define GCC_CHECK_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) 47 | #else 48 | #define GCC_CHECK_NONNULL_ALL /* Ignored */ 49 | #define GCC_CHECK_NONNULL(...) /* Ignored */ 50 | #endif 51 | #endif 52 | #define GCC_NONNULL_ALL GCC_CHECK_NONNULL_ALL 53 | #define GCC_NONNULLS GCC_CHECK_NONNULL_ALL 54 | #define GCC_NONNULL GCC_CHECK_NONNULL 55 | 56 | /* Attributes about the return value of a function */ 57 | 58 | /* Indicates that the function does not return normally */ 59 | #ifndef GCC_NORETURN 60 | #if __STDC_VERSION__ >= 201112L /* C11 */ 61 | #define GCC_NORETURN _Noreturn 62 | #elif __cplusplus >= 201103L /* C++11 */ 63 | #define GCC_NORETURN [[noreturn]] 64 | #elif defined __GNUC__ 65 | #define GCC_NORETURN __attribute__((noreturn)) 66 | #else 67 | #define GCC_NORETURN /* Ignored */ 68 | #endif 69 | #endif 70 | 71 | /* Indicates that the return value should not be ignored */ 72 | #ifndef GCC_NODISCARD 73 | #if __cplusplus >= 201703L /* C++17 */ 74 | #define GCC_NODISCARD [[nodiscard]] 75 | #elif defined __GNUC__ 76 | #define GCC_NODISCARD __attribute__((warn_unused_result)) 77 | #else 78 | #define GCC_NODISCARD /* Ignored */ 79 | #endif 80 | #endif 81 | 82 | /* Indicates that the memory to which the return value points always contains no pointers */ 83 | #ifndef GCC_MALLOC 84 | #if defined __GNUC__ 85 | #define GCC_MALLOC __attribute__((malloc)) 86 | #else 87 | #define GCC_MALLOC /* Ignored */ 88 | #endif 89 | #endif 90 | 91 | /* Indicates that the return value is always non-NULL */ 92 | #ifndef GCC_RETURNS_NONNULL 93 | #if defined __GNUC__ 94 | #define GCC_RETURNS_NONNULL __attribute__((returns_nonnull)) 95 | #else 96 | #define GCC_RETURNS_NONNULL /* Ignored */ 97 | #endif 98 | #endif 99 | #define GCC_RET_NONNULL GCC_RETURNS_NONNULL 100 | 101 | /* Attributes about the side-effects of a function */ 102 | 103 | /* Indicates that the function does not write to any non-local objects or static local objects */ 104 | #ifndef GCC_PURE 105 | #if defined __GNUC__ 106 | #define GCC_PURE __attribute__((pure)) 107 | #else 108 | #define GCC_PURE /* Ignored */ 109 | #endif 110 | #endif 111 | 112 | /* Indicates that the function does not read or write to any non-local objects or static local objects */ 113 | #ifndef GCC_CONSTEXPR 114 | #if defined __GNUC__ 115 | #define GCC_CONSTEXPR __attribute__((const)) 116 | #else 117 | #define GCC_CONSTEXPR /* Ignored */ 118 | #endif 119 | #endif 120 | 121 | /* General/other attributes */ 122 | 123 | /* Indicates that the array of `char` or the pointer to the array may contain a byte sequence without the `\0` string end */ 124 | #ifndef GCC_NONSTRING 125 | #if defined __GNUC__ && !defined __clang__ && __GNUC__ >= 8 /* GCC 8 */ 126 | #define GCC_NONSTRING __attribute__((nonstring)) 127 | #else 128 | #define GCC_NONSTRING /* Ignored */ 129 | #endif 130 | #endif 131 | 132 | /* Indicates that the object is unused in some build configurations */ 133 | #ifndef GCC_UNUSED 134 | #if defined __GNUC__ 135 | #define GCC_UNUSED __attribute__((unused)) 136 | #else 137 | #define GCC_UNUSED /* Ignored */ 138 | #endif 139 | #endif 140 | 141 | /* Indicates that the object is deprecated 142 | * and a message providing available alternatives will be shown if used */ 143 | #ifndef GCC_DEPRECATED 144 | #if __cplusplus >= 201402L /* C++14 */ 145 | #define GCC_DEPRECATED(msg_str) [[deprecated(msg_str)]] 146 | #elif defined __GNUC__ 147 | #define GCC_DEPRECATED(msg_str) __attribute__((deprecated(msg_str))) 148 | #else 149 | #define GCC_DEPRECATED(msg_str) /* Ignored */ 150 | #endif 151 | #endif 152 | 153 | /* Indicates that the fall through behavior of the `switch` case which ends at the null statement where the attribute applies is intentional */ 154 | #ifndef GCC_FALLTHROUGH 155 | #if __cplusplus >= 201703L /* C++17 */ 156 | #define GCC_FALLTHROUGH [[fallthrough]] 157 | #elif defined __GNUC__ 158 | #define GCC_FALLTHROUGH __attribute__((fallthrough)) 159 | #else 160 | #define GCC_FALLTHROUGH /* Ignored */ 161 | #endif 162 | #endif 163 | 164 | #endif /* ATTRDEF_H */ 165 | -------------------------------------------------------------------------------- /so/bbsluaext.c: -------------------------------------------------------------------------------- 1 | /* This file contains non-standard modules which 2 | * are fundamental in BBSLua framework. 3 | */ 4 | 5 | /* 6 | ** Lua BitOp -- a bit operations library for Lua 5.1/5.2. 7 | ** http://bitop.luajit.org/ 8 | ** 9 | ** Copyright (C) 2008-2012 Mike Pall. All rights reserved. 10 | ** 11 | ** Permission is hereby granted, free of charge, to any person obtaining 12 | ** a copy of this software and associated documentation files (the 13 | ** "Software"), to deal in the Software without restriction, including 14 | ** without limitation the rights to use, copy, modify, merge, publish, 15 | ** distribute, sublicense, and/or sell copies of the Software, and to 16 | ** permit persons to whom the Software is furnished to do so, subject to 17 | ** the following conditions: 18 | ** 19 | ** The above copyright notice and this permission notice shall be 20 | ** included in all copies or substantial portions of the Software. 21 | ** 22 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 25 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 26 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 27 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 28 | ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | ** 30 | ** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] 31 | */ 32 | 33 | #define LUA_BITOP_VERSION "1.0.2" 34 | 35 | #define LUA_LIB 36 | #include "lua.h" 37 | #include "lauxlib.h" 38 | 39 | #ifdef _MSC_VER 40 | /* MSVC is stuck in the last century and doesn't have C99's stdint.h. */ 41 | typedef __int32 int32_t; 42 | typedef unsigned __int32 uint32_t; 43 | typedef unsigned __int64 uint64_t; 44 | #else 45 | #include 46 | #endif 47 | 48 | typedef int32_t SBits; 49 | typedef uint32_t UBits; 50 | 51 | typedef union { 52 | lua_Number n; 53 | #ifdef LUA_NUMBER_DOUBLE 54 | uint64_t b; 55 | #else 56 | UBits b; 57 | #endif 58 | } BitNum; 59 | 60 | /* Convert argument to bit type. */ 61 | static UBits barg(lua_State *L, int idx) 62 | { 63 | BitNum bn; 64 | UBits b; 65 | #if LUA_VERSION_NUM < 502 66 | bn.n = lua_tonumber(L, idx); 67 | #else 68 | bn.n = luaL_checknumber(L, idx); 69 | #endif 70 | #if defined(LUA_NUMBER_DOUBLE) 71 | bn.n += 6755399441055744.0; /* 2^52+2^51 */ 72 | #ifdef SWAPPED_DOUBLE 73 | b = (UBits)(bn.b >> 32); 74 | #else 75 | b = (UBits)bn.b; 76 | #endif 77 | #elif defined(LUA_NUMBER_INT) || defined(LUA_NUMBER_LONG) || \ 78 | defined(LUA_NUMBER_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \ 79 | defined(LUA_NUMBER_LLONG) 80 | if (sizeof(UBits) == sizeof(lua_Number)) 81 | b = bn.b; 82 | else 83 | b = (UBits)(SBits)bn.n; 84 | #elif defined(LUA_NUMBER_FLOAT) 85 | #error "A 'float' lua_Number type is incompatible with this library" 86 | #else 87 | #error "Unknown number type, check LUA_NUMBER_* in luaconf.h" 88 | #endif 89 | #if LUA_VERSION_NUM < 502 90 | if (b == 0 && !lua_isnumber(L, idx)) { 91 | luaL_typerror(L, idx, "number"); 92 | } 93 | #endif 94 | return b; 95 | } 96 | 97 | /* Return bit type. */ 98 | #define BRET(b) lua_pushnumber(L, (lua_Number)(SBits)(b)); return 1; 99 | 100 | static int bit_tobit(lua_State *L) { BRET(barg(L, 1)) } 101 | static int bit_bnot(lua_State *L) { BRET(~barg(L, 1)) } 102 | 103 | #define BIT_OP(func, opr) \ 104 | static int func(lua_State *L) { int i; UBits b = barg(L, 1); \ 105 | for (i = lua_gettop(L); i > 1; i--) b opr barg(L, i); BRET(b) } 106 | BIT_OP(bit_band, &=) 107 | BIT_OP(bit_bor, |=) 108 | BIT_OP(bit_bxor, ^=) 109 | 110 | #define bshl(b, n) (b << n) 111 | #define bshr(b, n) (b >> n) 112 | #define bsar(b, n) ((SBits)b >> n) 113 | #define brol(b, n) ((b << n) | (b >> (32-n))) 114 | #define bror(b, n) ((b << (32-n)) | (b >> n)) 115 | #define BIT_SH(func, fn) \ 116 | static int func(lua_State *L) { \ 117 | UBits b = barg(L, 1); UBits n = barg(L, 2) & 31; BRET(fn(b, n)) } 118 | BIT_SH(bit_lshift, bshl) 119 | BIT_SH(bit_rshift, bshr) 120 | BIT_SH(bit_arshift, bsar) 121 | BIT_SH(bit_rol, brol) 122 | BIT_SH(bit_ror, bror) 123 | 124 | static int bit_bswap(lua_State *L) 125 | { 126 | UBits b = barg(L, 1); 127 | b = (b >> 24) | ((b >> 8) & 0xff00) | ((b & 0xff00) << 8) | (b << 24); 128 | BRET(b) 129 | } 130 | 131 | static int bit_tohex(lua_State *L) 132 | { 133 | UBits b = barg(L, 1); 134 | SBits n = lua_isnone(L, 2) ? 8 : (SBits)barg(L, 2); 135 | const char *hexdigits = "0123456789abcdef"; 136 | char buf[8]; 137 | int i; 138 | if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; } 139 | if (n > 8) n = 8; 140 | for (i = (int)n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; } 141 | lua_pushlstring(L, buf, (size_t)n); 142 | return 1; 143 | } 144 | 145 | static const struct luaL_Reg bit_funcs[] = { 146 | { "tobit", bit_tobit }, 147 | { "bnot", bit_bnot }, 148 | { "band", bit_band }, 149 | { "bor", bit_bor }, 150 | { "bxor", bit_bxor }, 151 | { "lshift", bit_lshift }, 152 | { "rshift", bit_rshift }, 153 | { "arshift", bit_arshift }, 154 | { "rol", bit_rol }, 155 | { "ror", bit_ror }, 156 | { "bswap", bit_bswap }, 157 | { "tohex", bit_tohex }, 158 | { NULL, NULL } 159 | }; 160 | 161 | /* Signed right-shifts are implementation-defined per C89/C99. 162 | ** But the de facto standard are arithmetic right-shifts on two's 163 | ** complement CPUs. This behaviour is required here, so test for it. 164 | */ 165 | #define BAD_SAR (bsar(-8, 2) != (SBits)-2) 166 | 167 | LUALIB_API int luaopen_bit(lua_State *L) 168 | { 169 | UBits b; 170 | lua_pushnumber(L, (lua_Number)1437217655L); 171 | b = barg(L, -1); 172 | if (b != (UBits)1437217655L || BAD_SAR) { /* Perform a simple self-test. */ 173 | const char *msg = "compiled with incompatible luaconf.h"; 174 | #ifdef LUA_NUMBER_DOUBLE 175 | #ifdef _WIN32 176 | if (b == (UBits)1610612736L) 177 | msg = "use D3DCREATE_FPU_PRESERVE with DirectX"; 178 | #endif 179 | if (b == (UBits)1127743488L) 180 | msg = "not compiled with SWAPPED_DOUBLE"; 181 | #endif 182 | if (BAD_SAR) 183 | msg = "arithmetic right-shift broken"; 184 | luaL_error(L, "bit library self-test failed (%s)", msg); 185 | } 186 | #if LUA_VERSION_NUM < 502 187 | luaL_register(L, "bit", bit_funcs); 188 | #else 189 | luaL_newlib(L, bit_funcs); 190 | #endif 191 | return 1; 192 | } 193 | 194 | -------------------------------------------------------------------------------- /innbbsd/nntp.h: -------------------------------------------------------------------------------- 1 | /* $Revision: 1.1.1.1 $ 2 | ** 3 | ** Here be a set of NNTP response codes as defined in RFC977 and elsewhere. 4 | ** The response codes are three digits, RFI, defined like this: 5 | ** R, Response: 6 | ** 1xx Informative message 7 | ** 2xx Command ok 8 | ** 3xx Command ok so far, send the rest of it. 9 | ** 4xx Command was correct, but couldn't be performed for 10 | ** some reason. 11 | ** 5xx Command unimplemented, or incorrect, or a serious 12 | ** program error occurred. 13 | ** F, Function: 14 | ** x0x Connection, setup, and miscellaneous messages 15 | ** x1x Newsgroup selection 16 | ** x2x Article selection 17 | ** x3x Distribution functions 18 | ** x4x Posting 19 | ** x8x Nonstandard extensions (AUTHINFO, XGTITLE) 20 | ** x9x Debugging output 21 | ** I, Information: 22 | ** No defined semantics 23 | */ 24 | #define NNTP_HELPOK_VAL 100 25 | #define NNTP_BAD_COMMAND_VAL 500 26 | #define NNTP_BAD_COMMAND "500 Syntax error or bad command" 27 | #define NNTP_TEMPERR_VAL 503 28 | #define NNTP_ACCESS "502 Permission denied" 29 | #define NNTP_ACCESS_VAL 502 30 | #define NNTP_GOODBYE_ACK "205" 31 | #define NNTP_GOODBYE_ACK_VAL 205 32 | #define NNTP_GOODBYE "400" 33 | #define NNTP_GOODBYE_VAL 400 34 | #define NNTP_HAVEIT "435 Duplicate" 35 | #define NNTP_HAVEIT_BADID "435 Bad Message-ID" 36 | #define NNTP_HAVEIT_VAL 435 37 | #define NNTP_LIST_FOLLOWS "215" 38 | #define NNTP_LIST_FOLLOWS_VAL 215 39 | #define NNTP_HELP_FOLLOWS "100 Legal commands" 40 | #define NNTP_HELP_FOLLOWS_VAL 100 41 | #define NNTP_NOTHING_FOLLOWS_VAL 223 42 | #define NNTP_ARTICLE_FOLLOWS "220" 43 | #define NNTP_ARTICLE_FOLLOWS_VAL 220 44 | #define NNTP_NEWGROUPS_FOLLOWS_VAL 231 45 | #define NNTP_HEAD_FOLLOWS "221" 46 | #define NNTP_HEAD_FOLLOWS_VAL 221 47 | #define NNTP_BODY_FOLLOWS_VAL 222 48 | #define NNTP_OVERVIEW_FOLLOWS_VAL 224 49 | #define NNTP_DATE_FOLLOWS_VAL 111 50 | #define NNTP_POSTOK "200" 51 | #define NNTP_POSTOK_VAL 200 52 | #define NNTP_START_POST_VAL 340 53 | #define NNTP_NOPOSTOK_VAL 201 54 | #define NNTP_SLAVEOK_VAL 202 55 | #define NNTP_REJECTIT_VAL 437 56 | #define NNTP_REJECTIT_EMPTY "437 Empty article" 57 | #define NNTP_DONTHAVEIT "430" 58 | #define NNTP_DONTHAVEIT_VAL 430 59 | #define NNTP_RESENDIT_NOHIST "436 Can't write history" 60 | #define NNTP_RESENDIT_NOSPACE "436 No space" 61 | #define NNTP_RESENDIT_VAL 436 62 | #define NNTP_POSTEDOK "240 Article posted" 63 | #define NNTP_POSTEDOK_VAL 240 64 | #define NNTP_POSTFAIL_VAL 441 65 | #define NNTP_GROUPOK_VAL 211 66 | #define NNTP_SENDIT "335" 67 | #define NNTP_SENDIT_VAL 335 68 | #define NNTP_SYNTAX_USE "501 Bad command use" 69 | #define NNTP_SYNTAX_VAL 501 70 | #define NNTP_TOOKIT "235" 71 | #define NNTP_TOOKIT_VAL 235 72 | #define NNTP_NOTINGROUP "412 Not in a newsgroup" 73 | #define NNTP_NOTINGROUP_VAL 412 74 | #define NNTP_NOSUCHGROUP "411 No such group" 75 | #define NNTP_NOSUCHGROUP_VAL 411 76 | #define NNTP_NEWNEWSOK "230 New news follows" 77 | #define NNTP_NOARTINGRP "423 Bad article number" 78 | #define NNTP_NOARTINGRP_VAL 423 79 | #define NNTP_NOCURRART "420 No current article" 80 | #define NNTP_NOCURRART_VAL 420 81 | #define NNTP_NONEXT_VAL 421 82 | #define NNTP_NOPREV_VAL 422 83 | #define NNTP_CANTPOST "440 Posting not allowed" 84 | #define NNTP_CANTPOST_VAL 440 85 | 86 | 87 | /* 88 | ** The first character of an NNTP reply can be used as a category class. 89 | */ 90 | #define NNTP_CLASS_OK '2' 91 | #define NNTP_CLASS_ERROR '4' 92 | #define NNTP_CLASS_FATAL '5' 93 | 94 | 95 | /* 96 | ** The NNTP protocol currently has no way to say "offer me this article 97 | ** later, but don't close the connection." That will be fixed in NNTP2. 98 | #define NNTP_RESENDIT_LATER "?" 99 | #define NNTP_RESENDIT_LATER_VAL ? 100 | */ 101 | 102 | 103 | /* 104 | ** Authentication commands from the RFC update (not official). 105 | */ 106 | #define NNTP_AUTH_NEEDED "480" 107 | #define NNTP_AUTH_NEEDED_VAL 480 108 | #define NNTP_AUTH_BAD "481" 109 | #define NNTP_AUTH_NEXT "381" 110 | #define NNTP_AUTH_NEXT_VAL 381 111 | #define NNTP_AUTH_OK "281" 112 | #define NNTP_AUTH_OK_VAL 281 113 | #define NNTP_AUTH_REJECT_VAL 482 114 | 115 | /* 116 | ** XGTITLE, from ANU news. 117 | */ 118 | #define NNTP_XGTITLE_BAD 481 /* Yes, 481. */ 119 | #define NNTP_XGTITLE_OK 282 120 | 121 | #define NNTP_STRSIZE 512 122 | 123 | /* Aliases for backward compatibility */ 124 | #define NNTP_STRLEN NNTP_STRSIZE 125 | 126 | /* 127 | ** For tin newsreader 128 | */ 129 | #define OK_XINDEX 218 /* Tin style group index file follows */ 130 | #define OK_XMOTD 217 /* Motd (message of the day) file follows */ 131 | #define ERR_XINDEX 418 /* No tin style index file for newsgroup */ 132 | #define ERR_XMOTD 417 /* No motd (message of the day) file */ 133 | 134 | /* For DBZ server */ 135 | #define NNTP_ADDHIST_OK 283 /* addhist OK */ 136 | #define NNTP_GREPHIST_OK 284 /* grephist OK */ 137 | #define NNTP_MIDCHECK_OK 285 /* grephist OK */ 138 | #define NNTP_SHUTDOWN_OK 286 /* grephist OK */ 139 | #define NNTP_RELOAD_OK 287 /* grephist OK */ 140 | #define NNTP_MODE_OK 101 /* grephist OK */ 141 | #define NNTP_VERBOSELOG_OK 289 /* grephist OK */ 142 | #define NNTP_ADDHIST_BAD 483 /* addhist fail */ 143 | #define NNTP_GREPHIST_BAD 484 /* grephist fail */ 144 | #define NNTP_MIDCHECK_BAD 485 /* grephist fail */ 145 | #define NNTP_SHUTDOWN_BAD 486 /* grephist fail */ 146 | #define NNTP_RELOAD_BAD 487 /* grephist fail */ 147 | #define NNTP_MODE_BAD 488 /* grephist fail */ 148 | #define NNTP_VERBOSELOG_BAD 489 /* grephist fail */ 149 | -------------------------------------------------------------------------------- /scripts/wsproxy/wsproxy.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | wsproxy: the websocket to telnet bbs proxy 3 | 4 | Copyright (c) 2017 Robert Wang 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | --]] 24 | 25 | local server = require "resty.websocket.server" 26 | local ffi = require "ffi" 27 | 28 | local timeout_ms = 7*24*60*60*1000 29 | local bbs_receive_size = 1024 30 | 31 | -- Special code for nginx to close connection directly. 32 | -- This is used to close websocket, because we can't send a normal http 33 | -- response code back. 34 | local ngx_close_conn_code = 444 35 | 36 | local function check_origin() 37 | local checked = tonumber(ngx.var.bbs_origin_checked) 38 | if checked ~= 1 then 39 | ngx.log(ngx.ERR, "origin checked failed: ", ngx.req.get_headers().origin) 40 | return ngx.exit(403) 41 | end 42 | end 43 | 44 | local function build_conn_data() 45 | ffi.cdef[[ 46 | typedef struct 47 | { 48 | // size of current structure 49 | uint32_t cb; 50 | uint32_t encoding; 51 | uint32_t raddr_len; 52 | uint8_t raddr[16]; 53 | uint16_t rport; 54 | uint16_t lport; 55 | uint32_t flags; 56 | } __attribute__ ((packed)) conn_data; 57 | ]] 58 | local flags = 0 59 | local bbs_lport = tonumber(ngx.var.bbs_lport) 60 | local bbs_secure = tonumber(ngx.var.bbs_secure) 61 | if bbs_secure == 1 then 62 | flags = flags + 1 -- CONN_FLAG_SECURE 63 | end 64 | return ffi.string(ffi.new("conn_data", { 65 | cb = 36, 66 | encoding = 0, 67 | raddr_len = ngx.var.binary_remote_addr:len(), 68 | raddr = ngx.var.binary_remote_addr, 69 | rport = tonumber(ngx.var.remote_port) or 0, 70 | lport = bbs_lport or tonumber(ngx.var.server_port) or 0, 71 | flags = flags, 72 | }), ffi.sizeof("conn_data")) 73 | end 74 | 75 | local function connect_mbbsd() 76 | local addr = ngx.var.bbs_logind_addr 77 | if not addr then 78 | ngx.log(ngx.ERR, "bbs_logind_addr not set") 79 | return 80 | end 81 | 82 | local mbbsd = ngx.socket.stream() 83 | local ok, err = mbbsd:connect(addr) 84 | if not ok then 85 | ngx.log(ngx.ERR, "failed to connect to mbbsd: ", addr, " err: ", err) 86 | return 87 | end 88 | 89 | local _, err = mbbsd:send(build_conn_data()) 90 | if err then 91 | ngx.log(ngx.ERR, "failed to send conn data to mbbsd: ", err) 92 | return 93 | end 94 | 95 | return mbbsd 96 | end 97 | 98 | local function start_websocket_server() 99 | local ws, err = server:new({ 100 | timeout = timeout_ms, 101 | max_payload_len = 65535, 102 | }) 103 | if not ws then 104 | ngx.log(ngx.ERR, "failed to new websocket: ", err) 105 | return 106 | end 107 | return ws 108 | end 109 | 110 | local function ws2sock(ws, sock) 111 | local last_typ = "" 112 | while true do 113 | local data, typ, err = ws:recv_frame() 114 | if err or not data then 115 | ngx.log(ngx.DEBUG, "failed to receive a frame: ", err) 116 | return err 117 | end 118 | 119 | if typ == "continuation" then 120 | typ = last_typ 121 | end 122 | 123 | if typ == "binary" then 124 | local _, err = sock:send(data) 125 | if err then 126 | ngx.log(ngx.DEBUG, "failed to send to mbbsd: ", err) 127 | ws:send_close(1006, "bbs disconnected") 128 | return err 129 | end 130 | elseif typ == "close" then 131 | sock:close() 132 | local _, err = ws:send_close(1000, "bye") 133 | if err then 134 | ngx.log(ngx.DEBUG, "failed to send the close frame: ", err) 135 | return err 136 | end 137 | ngx.log(ngx.INFO, "closing with err ", err, " and message ", data) 138 | return 139 | elseif typ == "ping" then 140 | -- send a pong frame back: 141 | local _, err = ws:send_pong(data) 142 | if err then 143 | ngx.log(ngx.DEBUG, "failed to send frame: ", err) 144 | return err 145 | end 146 | elseif typ == "pong" then 147 | -- just discard the incoming pong frame 148 | else 149 | ngx.log(ngx.INFO, "received a frame of type ", typ, " and payload ", data) 150 | end 151 | 152 | last_typ = typ 153 | end 154 | end 155 | 156 | local function sock2ws(sock, ws) 157 | while true do 158 | sock:settimeout(timeout_ms) 159 | local data, err = sock:receiveany(bbs_receive_size) 160 | if not data then 161 | local bytes, send_err = ws:send_close(1000, "bbs disconnected") 162 | ngx.log(ngx.DEBUG, "send_close: ", send_err, " bytes: ", bytes) 163 | ngx.log(ngx.DEBUG, "failed to recv from mbbsd: ", err) 164 | return err or send_err 165 | else 166 | ngx.log(ngx.DEBUG, "receive bytes from mbbsd: len: ", data:len()) 167 | local bytes, err = ws:send_binary(data) 168 | if not bytes then 169 | ngx.log(ngx.DEBUG, "failed to send a binary frame: ", err) 170 | return err 171 | end 172 | end 173 | end 174 | end 175 | 176 | local function main() 177 | check_origin() 178 | 179 | -- Start websocket first to make protocol-level dos harder. 180 | local ws = start_websocket_server() 181 | if not ws then 182 | return ngx.exit(400) 183 | end 184 | 185 | local sock = connect_mbbsd() 186 | if not sock then 187 | return ngx.exit(ngx_close_conn_code) 188 | end 189 | 190 | ngx.log(ngx.INFO, "client connect over websocket, ", 191 | ngx.var.server_name, ":", ngx.var.server_port, " ", ngx.var.server_protocol) 192 | 193 | ngx.thread.spawn(function () 194 | local err = ws2sock(ws, sock) 195 | if err then 196 | sock:close() 197 | -- Abort the request and stop other threads. 198 | ngx.exit(ngx_close_conn_code) 199 | end 200 | end) 201 | ngx.thread.spawn(function () 202 | local err = sock2ws(sock, ws) 203 | if err then 204 | sock:close() 205 | -- Abort the request and stop other threads. 206 | ngx.exit(ngx_close_conn_code) 207 | end 208 | end) 209 | end 210 | 211 | main() 212 | -------------------------------------------------------------------------------- /dreambbs.mk: -------------------------------------------------------------------------------- 1 | ## Common BSD make rules for DreamBBS Project 2 | 3 | ## Toolchain settings 4 | 5 | CC = clang 6 | 7 | RANLIB = ranlib 8 | 9 | CPROTO = cproto -E"$(CC) -pipe -E" -I$$(SRCROOT)/include 10 | 11 | INSTALL = install -o $(BBSUSR) 12 | 13 | 14 | .if "$(DREAMBBS_MK)" == "" 15 | DREAMBBS_MK := 1 16 | 17 | REALSRCROOT ?= $(SRCROOT) 18 | 19 | ARCHI != getconf LONG_BIT 20 | 21 | OPSYS != uname -o 22 | 23 | BUILDTIME != date '+%s' 24 | 25 | ## To be expanded 26 | 27 | CFLAGS_WARN = -Wall -Wpointer-arith -Wcast-qual -Wwrite-strings -Werror=format 28 | CFLAGS_MK = -ggdb3 -O0 -pipe $(CFLAGS_WARN) -I$$(SRCROOT)/include $(CFLAGS_ARCHI) $(CFLAGS_COMPAT) 29 | 30 | LDFLAGS_MK = -L$$(SRCROOT)/lib -ldao -lcrypt $(LDFLAGS_ARCHI) 31 | 32 | 33 | ## Tool functions 34 | ## Called with $(function$(para1::=arg1)$(para2::=arg2)...) 35 | 36 | UNQUOTE = S/^"//:S/"$$// 37 | 38 | VALUEIF = "\#ifdef $(conf)$(.newline)$(conf:M*)$(.newline)\#else$(.newline)$(default:M*)$(.newline)\#endif" 39 | DEFVAR = "\#undef $(exconf:M*)$(.newline)\#define $(exconf:M*) $($(exconf:M*):M*)" 40 | DEFCONF = "\#undef $(exconf:M*)$(.newline)\#define $(exconf:M*) $(exvalue:M*)" 41 | 42 | GETVAR = [ "$(var:M*:$(UNQUOTE))" ] && echo "$(var:M*:$(UNQUOTE))" || $(else_var) 43 | GETCONFS = echo "" | $(CC) -x c -dM -E -P $(hdr:@v@-imacros "$v"@) - 2>/dev/null 44 | GETVALUE = { echo $(VALUEIF$(conf::= $(conf:M*:$(UNQUOTE)))$(default::= $(default:M*))) | $(CC) -x c -E -P $(hdr:@v@-imacros "$v"@) - | xargs; } 2>/dev/null 45 | EXPORTVAR = echo $(DEFVAR$(exconf::= $(exconf:M*))) >> $(EXPORT_FILE) 46 | EXPORTCONF = echo $(DEFCONF$(exconf::= $(exconf:M*))$(exvalue::= $(exvalue:M*))) >> $(EXPORT_FILE) 47 | 48 | # Read variables from the configuration C files 49 | 50 | BBSCONF := $(REALSRCROOT)/dreambbs.conf 51 | BBSCONF_ORIGIN := $(REALSRCROOT)/include/config.h 52 | EXPORT_MAPLE := $(REALSRCROOT)/maple/make_export.conf 53 | EXPORT_VERINFO := $(REALSRCROOT)/verinfo_export.conf 54 | != touch $(EXPORT_MAPLE) 55 | CFLAGS_MK += -imacros "$(EXPORT_VERINFO)" 56 | 57 | # User names and group names 58 | BBSUSR != $(GETVAR$(var::= "$(BBSUSR)")$(else_var::= $(GETVALUE$(conf::= "BBSUSR")$(default::= "$(:!id -un!)")$(hdr::= $(BBSCONF_ORIGIN))))) 59 | BBSGROUP != $(GETVAR$(var::= "$(BBSGROUP)")$(else_var::= $(GETVALUE$(conf::= "BBSGROUP")$(default::= "$(:!id -gn!)")$(hdr::= $(BBSCONF_ORIGIN))))) 60 | WWWGROUP != $(GETVAR$(var::= "$(WWWGROUP)")$(else_var::= $(GETVALUE$(conf::= "WWWGROUP")$(default::= "www-data")$(hdr::= $(BBSCONF_ORIGIN))))) 61 | 62 | # UIDs and GIDs 63 | ID_DEFAULT = 9999 64 | ID_FALLBACK = 2>/dev/null || echo $(ID_DEFAULT) 65 | BBSUID != $(GETVAR$(var::= "$(BBSUID)")$(else_var::= $(GETVALUE$(conf::= "BBSUID")$(default::= "$(:!id -u $(BBSUSR) $(ID_FALLBACK)!)")$(hdr::= $(BBSCONF))))) 66 | BBSGROUP_GID != getent group $(BBSGROUP) | cut -d: -f3 67 | BBSGROUP_GID != $(GETVAR$(var::= "$(BBSGROUP_GID)")$(else_var::= echo $(ID_DEFAULT))) 68 | BBSGID != $(GETVAR$(var::= "$(BBSGID)")$(else_var::= $(GETVALUE$(conf::= "BBSGID")$(default::= "$(BBSGROUP_GID)")$(hdr::= $(BBSCONF))))) 69 | WWWGROUP_GID != getent group $(WWWGROUP) | cut -d: -f3 70 | WWWGROUP_GID != $(GETVAR$(var::= "$(WWWGROUP_GID)")$(else_var::= echo $(ID_DEFAULT))) 71 | WWWGID != $(GETVAR$(var::= "$(WWWGID)")$(else_var::= $(GETVALUE$(conf::= "WWWGID")$(default::= "$(WWWGROUP_GID)")$(hdr::= $(BBSCONF))))) 72 | 73 | ## BBS path prefixes and suffixes 74 | BBSVER != $(GETVALUE$(conf::= "BBSVER_SUFFIX")$(default::= "")$(hdr::= $(BBSCONF_ORIGIN))) 75 | BBSUSR_HOME != getent passwd $(BBSUSR) | cut -d: -f6 76 | BBSHOME != $(GETVAR$(var::= "$(BBSHOME)")$(else_var::= $(GETVALUE$(conf::= "BBSHOME")$(default::= "$(BBSUSR_HOME)")$(hdr::= $(BBSCONF))))) 77 | 78 | ## Numeric local timezone 79 | BBSUTCZONE != $(GETVAR$(var::= "$(BBSUTCZONE)")$(else_var::= $(GETVALUE$(conf::= "BBSUTCZONE")$(default::= "$(:!date +%z!)")$(hdr::= $(BBSCONF))))) 80 | 81 | ## `mruby-config` executable path for building BBS-Ruby with mruby 82 | MRB_CONFIG_PATH != which mruby-config 83 | MRB_CONFIG != $(GETVAR$(var::= "$(MRB_CONFIG)")$(else_var::= $(GETVALUE$(conf::= "MRB_CONFIG")$(default::= "$(MRB_CONFIG_PATH)")$(hdr::= $(BBSCONF_ORIGIN))))) 84 | 85 | ## The project root directory of bbs-sshd 86 | BBS_SSHD_ROOT != $(GETVAR$(var::= "$(BBS_SSHD_ROOT)")$(else_var::= $(GETVALUE$(conf::= "BBS_SSHD_ROOT")$(default::= "$(BBSHOME)/bbs-sshd")$(hdr::= $(BBSCONF))))) 87 | 88 | # rules ref: PttBBS: mbbsd/Makefile 89 | DEF_LIST != sh -c '$(GETCONFS$(hdr::= $(BBSCONF)))' 90 | DEF_TEST = [ $(DEF_LIST:M$(conf:M*:S/"//g:N")) ] # Balance the quotes 91 | DEF_YES := && echo "YES" || echo "" 92 | USE_PMORE != sh -c '$(DEF_TEST$(conf::= "M3_USE_PMORE")) $(DEF_YES)' 93 | USE_PFTERM != sh -c '$(DEF_TEST$(conf::= "M3_USE_PFTERM")) $(DEF_YES)' 94 | USE_BBSLUA != sh -c '$(DEF_TEST$(conf::= "M3_USE_BBSLUA")) $(DEF_YES)' 95 | USE_BBSRUBY != sh -c '$(DEF_TEST$(conf::= "M3_USE_BBSRUBY")) $(DEF_YES)' 96 | USE_LUAJIT != sh -c '$(DEF_TEST$(conf::= "BBSLUA_USE_LUAJIT")) $(DEF_YES)' 97 | USE_MRUBY != sh -c '$(DEF_TEST$(conf::= "BBSRUBY_USE_MRUBY")) $(DEF_YES)' 98 | 99 | # Flags for disabling shared objects 100 | NO_SO_CLI := $("$(NO_SO_CLI)" != "" :? $(NO_SO_CLI) : $(NO_SO:DYES:UNO)) 101 | NO_SO_CONF != sh -c '$(DEF_TEST$(conf::= "NO_SO")) $(DEF_YES)' 102 | NO_SO_CONF != $(GETVALUE$(conf::= "NO_SO")$(default::= "0")$(hdr::= $(EXPORT_MAPLE))) 103 | NO_SO = $(NO_SO_CLI:S/NO//g)$(NO_SO_CONF:S/0//g) 104 | 105 | CC_HASFLAGS = echo "" | $(CC) -x c -E $(flags:M*) -Werror - >/dev/null 2>&1 106 | 107 | # Prevent `-Wformat-overflow=` warnings from halting the compilation 108 | .if $(CC:Mgcc*) 109 | CFLAGS_WARN = -Wno-format-overflow -Wno-error=format-overflow -Wformat-overflow 110 | .endif 111 | 112 | .if $(CC:Mclang*) 113 | CFLAGS_WARN += -Wno-invalid-source-encoding 114 | .endif 115 | 116 | # Architecture information 117 | MULTIARCH != $(CC) -dumpmachine | sed 's/^\(.*\)-\(.*\)-\(.*\)-\(.*\)$$/\1-\3-\4/' 118 | 119 | .if $(ARCHI)=="64" 120 | CFLAGS_ARCHI += -fPIC 121 | .endif 122 | 123 | .if $(OPSYS) == "GNU/Linux" 124 | LDFLAGS_ARCHI += -lresolv -ldl -rdynamic 125 | .endif 126 | 127 | .if $(OPSYS) == "FreeBSD" 128 | LDFLAGS_ARCHI += -Wl,-export-dynamic 129 | .endif 130 | 131 | .if $(NO_SO) 132 | CFLAGS_MAPLE += -DNO_SO 133 | CFLAGS_SO += -DNO_SO 134 | .else 135 | CFLAGS_MAPLE += -DNO_SO=0 136 | CFLAGS_SO += -DNO_SO=0 137 | .endif 138 | 139 | .if $(CC:M*++) || $(CC:M*++-*) 140 | CFLAGS_COMPAT += -x c++ 141 | .else 142 | CFLAGS_WARN += -Wstrict-prototypes -Werror=incompatible-pointer-types -Werror=int-conversion 143 | # Prevent `-Wincompatible-pointer-types-discards-qualifiers` warnings from halting the compilation 144 | .if $(CC:Mclang*) 145 | CFLAGS_WARN += -Wno-incompatible-pointer-types-discards-qualifiers -Wno-error=incompatible-pointer-types-discards-qualifiers -Wincompatible-pointer-types-discards-qualifiers -Werror=pointer-to-int-cast 146 | .endif 147 | .endif 148 | 149 | CC_HAS_W_UNREACHABLE_CODE_AGGRESSIVE != $(CC_HASFLAGS$(flags::= -Wunreachable-code-aggressive)) $(DEF_YES) 150 | .if $(CC_HAS_W_UNREACHABLE_CODE_AGGRESSIVE) 151 | CFLAGS_COMPAT += -Wunreachable-code-aggressive 152 | .else 153 | CFLAGS_COMPAT += -Wunreachable-code 154 | .endif 155 | 156 | CC_HAS_F_COLOR_DIAGNOSTICS != $(CC_HASFLAGS$(flags::= -fcolor-diagnostics)) $(DEF_YES) 157 | .if $(CC_HAS_F_COLOR_DIAGNOSTICS) 158 | CFLAGS_COMPAT += -fcolor-diagnostics 159 | .endif 160 | 161 | # BBS-Lua & BBS-Ruby make rule definitions 162 | 163 | .if $(USE_BBSLUA) 164 | .if $(OPSYS) == "FreeBSD" 165 | LUA_LDFLAGS_ARCHI = -Wl,--no-as-needed 166 | .endif 167 | 168 | .if $(USE_LUAJIT) 169 | LUA_PKG_NAME ?= luajit 170 | .else 171 | .if $(OPSYS) == "FreeBSD" 172 | LUA_PKG_NAME ?= lua-5.1 173 | .else 174 | LUA_PKG_NAME ?= lua5.1 175 | .endif 176 | .endif 177 | 178 | LUA_CFLAGS != pkg-config --cflags $(LUA_PKG_NAME) 179 | LUA_LDFLAGS != pkg-config --libs $(LUA_PKG_NAME) 180 | .endif 181 | 182 | 183 | .if $(USE_BBSRUBY) 184 | .if $(OPSYS) == "FreeBSD" 185 | RUBY_LDFLAGS_ARCHI = -Wl,--no-as-needed 186 | .endif 187 | 188 | .if $(USE_MRUBY) 189 | MRB_CFLAGS != "$(MRB_CONFIG)" --cflags 190 | MRB_LDFLAGS != "$(MRB_CONFIG)" --ldflags 191 | RUBY_CFLAGS = $(MRB_CFLAGS) 192 | RUBY_LDFLAGS = $(MRB_LDFLAGS) -lmruby -lm 193 | .else 194 | RUBY_CFLAGS != pkg-config --cflags ruby-2.2 195 | RUBY_LDFLAGS != pkg-config --libs ruby-2.2 196 | .endif 197 | .endif 198 | 199 | .endif # .ifndef DREAMBBS_MK 200 | 201 | 202 | ## Expand `SRCROOT` 203 | .ifdef SRCROOT 204 | CPROTO := $(CPROTO) 205 | CFLAGS := $(CFLAGS_MK) 206 | LDFLAGS := $(LDFLAGS_MK) 207 | .endif 208 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------- # 2 | # CMakeLists.txt ( NCKU CCNS WindTop-DreamBBS 3.0 ) # 3 | # ------------------------------------------------------- # 4 | # Author: Wei-Cheng Yeh (IID) # 5 | # Target: CMakeLists for ALL # 6 | # Create: 2019/11/30 # 7 | # ------------------------------------------------------- # 8 | 9 | cmake_minimum_required(VERSION 3.1) 10 | 11 | # set the project name 12 | project(DreamBBS LANGUAGES C CXX VERSION 3.0) 13 | 14 | # For debugging `CMakeLists.txt` 15 | # set(CMAKE_VERBOSE_MAKEFILE ON) 16 | 17 | # Mark `CMakeCache.txt` as up-to-date if necessary 18 | set(MARK_CACHE_UPDATED OFF) 19 | 20 | # Required cmake modules 21 | include(CheckCCompilerFlag) 22 | include(CheckSymbolExists) 23 | include(FindPkgConfig) 24 | 25 | # 26 | 27 | set(CMAKE_REQUIRED_INCLUDES "string.h") 28 | check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY) 29 | check_symbol_exists(strlcat "string.h" HAVE_STRLCAT) 30 | 31 | if (HAVE_STRLCPY) 32 | add_definitions(-DHAVE_STRLCPY=1) 33 | endif() 34 | if (HAVE_STRLCAT) 35 | add_definitions(-DHAVE_STRLCAT=1) 36 | endif() 37 | 38 | ## Toolchain settings 39 | 40 | if(NOT USE_CXX) 41 | # specify the C standard 42 | add_compile_options(-x c --std=gnu99) 43 | set(USE_CXX OFF CACHE BOOL "Compile C code using C++ mode") 44 | else() 45 | # specify the C++ standard 46 | add_compile_options(-x c++ --std=gnu++14) 47 | link_libraries(stdc++) 48 | set(USE_CXX ON CACHE BOOL "Compile C code using C++ mode") 49 | endif() 50 | 51 | if(DEFINED ENV{CMAKE_BUILD_TYPE}) 52 | set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) 53 | elseif(NOT CMAKE_BUILD_TYPE) 54 | set(CMAKE_BUILD_TYPE RelWithDebInfo) 55 | endif() 56 | 57 | message(STATUS "Using build configuration: ${CMAKE_BUILD_TYPE}") 58 | 59 | add_compile_options( 60 | $<$:> 61 | "$<$:-ggdb3>" 62 | "$<$:-ggdb3>" 63 | $<$:> 64 | -pipe 65 | ) 66 | add_compile_options(-Wall -Wpointer-arith -Wcast-qual -Wwrite-strings -Werror=format) 67 | include_directories(${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include) 68 | 69 | link_libraries(-L${PROJECT_BINARY_DIR}/lib dao crypt) 70 | 71 | ## Tool functions 72 | 73 | function(GETVALUE conf default hdr output) 74 | set(valueif "#ifdef ${conf}\n${conf}\n#else\n${default}\n#endif") 75 | execute_process( 76 | COMMAND echo ${valueif} 77 | COMMAND ${CMAKE_C_COMPILER} -x c -E -P -imacros "${hdr}" - 78 | COMMAND xargs 79 | OUTPUT_VARIABLE "${output}" 80 | OUTPUT_STRIP_TRAILING_WHITESPACE 81 | ERROR_QUIET 82 | ) 83 | set("${output}" "${${output}}" PARENT_SCOPE) 84 | endfunction(GETVALUE) 85 | 86 | function(LOADVALUE conf default hdr output) 87 | if(DEFINED ENV{${conf}}) 88 | set("${output}" "$ENV{${conf}}") 89 | elseif(DEFINED "${conf}") 90 | set("${output}" "${${conf}}") 91 | else() 92 | GETVALUE("${conf}" "${default}" "${hdr}" "${output}") 93 | endif() 94 | set("${output}" "${${output}}" PARENT_SCOPE) 95 | endfunction(LOADVALUE) 96 | 97 | set(ID_DEFAULT 9999) 98 | 99 | function(GETUID name output) 100 | execute_process( 101 | COMMAND sh -c "id -u ${name} || echo ${ID_DEFAULT}" 102 | OUTPUT_VARIABLE "${output}" 103 | OUTPUT_STRIP_TRAILING_WHITESPACE 104 | ERROR_QUIET 105 | ) 106 | set("${output}" "${${output}}" PARENT_SCOPE) 107 | endfunction(GETUID) 108 | 109 | function(GETGID name output) 110 | execute_process( 111 | COMMAND getent group ${name} 112 | COMMAND cut -d: -f3 - 113 | OUTPUT_VARIABLE "${output}" 114 | OUTPUT_STRIP_TRAILING_WHITESPACE 115 | ) 116 | if ("${${output}}" STREQUAL "") 117 | set("${output}" ${ID_DEFAULT}) 118 | endif() 119 | set("${output}" "${${output}}" PARENT_SCOPE) 120 | endfunction(GETGID) 121 | 122 | function(DEF_TEST conf hdr output) 123 | if("${hdr}" IS_NEWER_THAN ${CMAKE_CACHEFILE_DIR}/CMakeCache.txt) 124 | set(MARK_CACHE_UPDATED ON) 125 | unset("${output}" CACHE) 126 | check_symbol_exists("${conf}" "${hdr}" "${output}") 127 | endif() 128 | set("${output}" "${${output}}" PARENT_SCOPE) 129 | endfunction(DEF_TEST) 130 | 131 | ## Read variables from the configuration C files 132 | 133 | set(BBSCONF "${PROJECT_SOURCE_DIR}/dreambbs.conf") 134 | set(BBSCONF_ORIGIN "${PROJECT_SOURCE_DIR}/include/config.h") 135 | set(EXPORT_PROJECT "${PROJECT_SOURCE_DIR}/make_export.conf") 136 | set(EXPORT_MAPLE "${PROJECT_SOURCE_DIR}/maple/make_export.conf") 137 | set(EXPORT_VERINFO "${PROJECT_SOURCE_DIR}/verinfo_export.conf") 138 | 139 | if(NOT EXISTS ${EXPORT_PROJECT}) 140 | execute_process(COMMAND touch ${EXPORT_PROJECT}) 141 | endif() 142 | if(NOT EXISTS ${EXPORT_MAPLE}) 143 | execute_process(COMMAND touch ${EXPORT_MAPLE}) 144 | endif() 145 | 146 | # User names and group names 147 | execute_process(COMMAND id -un OUTPUT_VARIABLE BBSUSR_DEFAULT OUTPUT_STRIP_TRAILING_WHITESPACE) 148 | execute_process(COMMAND id -gn OUTPUT_VARIABLE BBSGROUP_DEFAULT OUTPUT_STRIP_TRAILING_WHITESPACE) 149 | LOADVALUE(BBSUSR "${BBSUSR_DEFAULT}" ${BBSCONF_ORIGIN} BBSUSR) 150 | LOADVALUE(BBSGROUP "${BBSGROUP_DEFAULT}" ${BBSCONF_ORIGIN} BBSGROUP) 151 | LOADVALUE(WWWGROUP "www-data" ${BBSCONF_ORIGIN} WWWGROUP) 152 | 153 | # UIDs and GIDs 154 | GETUID("${BBSUSR}" BBSUID_DEFAULT) 155 | GETGID("${BBSGROUP}" BBSGID_DEFAULT) 156 | GETGID("${WWWGROUP}" WWWGID_DEFAULT) 157 | LOADVALUE(BBSUID "${BBSUID_DEFAULT}" ${BBSCONF_ORIGIN} BBSUID) 158 | LOADVALUE(BBSGID "${BBSGID_DEFAULT}" ${BBSCONF_ORIGIN} BBSGID) 159 | LOADVALUE(WWWGID "${WWWGID_DEFAULT}" ${BBSCONF_ORIGIN} WWWGID) 160 | 161 | # BBS path prefixes and suffixes 162 | LOADVALUE(BBSVER_SUFFIX "" ${BBSCONF_ORIGIN} BBSVER) 163 | execute_process( 164 | COMMAND getent passwd ${BBSUSR} 165 | COMMAND cut -d: -f6 - 166 | OUTPUT_VARIABLE BBSUSR_HOME 167 | OUTPUT_STRIP_TRAILING_WHITESPACE 168 | ) 169 | LOADVALUE(BBSHOME "${BBSUSR_HOME}" ${BBSCONF_ORIGIN} BBSHOME) 170 | 171 | ## Numeric local timezone 172 | execute_process( 173 | COMMAND date +%z 174 | OUTPUT_VARIABLE BBSUTCZONE_DEFAULT 175 | OUTPUT_STRIP_TRAILING_WHITESPACE 176 | ) 177 | LOADVALUE(BBSUTCZONE "${BBSUTCZONE_DEFAULT}" ${BBSCONF_ORIGIN} BBSUTCZONE) 178 | 179 | ## `mruby-config` executable path for building BBS-Ruby with mruby 180 | execute_process( 181 | COMMAND which mruby-config 182 | OUTPUT_VARIABLE MRB_CONFIG_PATH 183 | OUTPUT_STRIP_TRAILING_WHITESPACE 184 | ) 185 | LOADVALUE(MRB_CONFIG "${MRB_CONFIG_PATH}" ${BBSCONF_ORIGIN} MRB_CONFIG) 186 | 187 | ## The project root directory of bbs-sshd 188 | LOADVALUE(BBS_SSHD_ROOT "${BBSHOME}/bbs-sshd" ${BBSCONF_ORIGIN} BBS_SSHD_ROOT) 189 | 190 | # Flags for enabling modules 191 | DEF_TEST(M3_USE_PMORE ${BBSCONF} USE_PMORE) 192 | DEF_TEST(M3_USE_PFTERM ${BBSCONF} USE_PFTERM) 193 | DEF_TEST(M3_USE_BBSLUA ${BBSCONF} USE_BBSLUA) 194 | DEF_TEST(M3_USE_BBSRUBY ${BBSCONF} USE_BBSRUBY) 195 | DEF_TEST(BBSLUA_USE_LUAJIT ${BBSCONF} USE_LUAJIT) 196 | DEF_TEST(BBSRUBY_USE_MRUBY ${BBSCONF} USE_MRUBY) 197 | 198 | # Flags for disabling shared objects 199 | if(DEFINED ENV{NO_SO}) 200 | set(NO_SO_CLI "$ENV{NO_SO}") 201 | elseif(DEFINED NO_SO) 202 | set(NO_SO_CLI "${NO_SO}") 203 | endif() 204 | 205 | if(DEFINED NO_SO_CLI) 206 | set(NO_SO "${NO_SO_CLI}") 207 | else() 208 | LOADVALUE(NO_SO OFF ${EXPORT_MAPLE} NO_SO) 209 | endif() 210 | 211 | ## Other compile options and link options settings 212 | 213 | # Prevent `-Wformat-overflow=` warnings from halting the compilation 214 | set(W_NO_ERROR_FORMAT_OVERFLOW -Wno-format-overflow -Wno-error=format-overflow -Wformat-overflow) 215 | if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 216 | add_compile_options(${W_NO_ERROR_FORMAT_OVERFLOW}) 217 | endif() 218 | 219 | if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 220 | add_compile_options(-Wno-invalid-source-encoding) 221 | endif() 222 | 223 | if(NOT USE_CXX) 224 | add_compile_options(-Wstrict-prototypes -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=pointer-to-int-cast) 225 | 226 | # Prevent `-Wincompatible-pointer-types-discards-qualifiers` warnings from halting the compilation 227 | set(W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS -Wno-incompatible-pointer-types-discards-qualifiers -Wno-error=incompatible-pointer-types-discards-qualifiers -Wincompatible-pointer-types-discards-qualifiers) 228 | if(CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 229 | add_compile_options(${W_NO_INCOMPATIBLE_POINTER_TYPES_DISCARDS_QUALIFIERS}) 230 | endif() 231 | endif() 232 | 233 | check_c_compiler_flag(-Wunreachable-code-aggressive CC_HAS_W_UNREACHABLE_CODE_AGGRESSIVE) 234 | if(CC_HAS_W_UNREACHABLE_CODE_AGGRESSIVE) 235 | add_compile_options(-Wunreachable-code-aggressive) 236 | else() 237 | add_compile_options(-Wunreachable-code) 238 | endif() 239 | 240 | check_c_compiler_flag(-fcolor-diagnostics CC_HAS_F_COLOR_DIAGNOSTICS) 241 | if(CC_HAS_F_COLOR_DIAGNOSTICS) 242 | add_compile_options(-fcolor-diagnostics) 243 | endif() 244 | 245 | # Architecture information 246 | execute_process( 247 | COMMAND ${CMAKE_C_COMPILER} -dumpmachine 248 | OUTPUT_VARIABLE MULTIARCH 249 | OUTPUT_STRIP_TRAILING_WHITESPACE 250 | ) 251 | string(REGEX REPLACE "^(.*)-(.*)-(.*)-(.*)$" \\1-\\3-\\4 MULTIARCH ${MULTIARCH}) 252 | 253 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 254 | add_compile_options(-fPIC) 255 | endif() 256 | 257 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 258 | link_libraries(resolv ${CMAKE_DL_LIBS} -rdynamic) 259 | endif() 260 | 261 | if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") 262 | link_libraries(-Wl,-export-dynamic) 263 | endif() 264 | 265 | # BBS-Lua & BBS-Ruby make rule definitions 266 | 267 | if(USE_BBSLUA) 268 | if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") 269 | link_libraries(-Wl,--no-as-needed) 270 | endif() 271 | if(USE_LUAJIT) 272 | pkg_search_module(LUA REQUIRED luajit) 273 | else() 274 | # Prevent LuaJIT from being chosen 275 | pkg_search_module(LUA REQUIRED lua-5.1 lua5.1 luajit<-1) 276 | endif() 277 | endif() 278 | 279 | if(USE_BBSRUBY) 280 | if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") 281 | link_libraries(-Wl,--no-as-needed) 282 | endif() 283 | if(USE_MRUBY) 284 | execute_process( 285 | COMMAND ${MRB_CONFIG} --cflags 286 | OUTPUT_VARIABLE MRB_CFLAGS 287 | OUTPUT_STRIP_TRAILING_WHITESPACE 288 | ) 289 | separate_arguments(MRB_CFLAGS) 290 | execute_process( 291 | COMMAND ${MRB_CONFIG} --ldflags 292 | OUTPUT_VARIABLE MRB_LDFLAGS 293 | OUTPUT_STRIP_TRAILING_WHITESPACE 294 | ) 295 | separate_arguments(MRB_LDFLAGS) 296 | set(RUBY_CFLAGS ${MRB_CFLAGS}) 297 | set(RUBY_LDFLAGS ${MRB_LDFLAGS} mruby m) 298 | else() 299 | pkg_search_module(RUBY REQUIRED ruby<=2.2 ruby-2.2) 300 | endif() 301 | endif() 302 | 303 | ## Generate configure file 304 | function(EXPORT_CONF export_file) 305 | execute_process(COMMAND printf "\\033[1;36mGenerating '${export_file}'...\\033[0m\n") 306 | configure_file( 307 | ${export_file}.in ${export_file} 308 | NEWLINE_STYLE LF 309 | ) 310 | file(READ ${export_file} EXPORT_FILE_CONTENT) 311 | execute_process(COMMAND printf "\\033[1;33m${EXPORT_FILE_CONTENT}\\033[0m") 312 | endfunction() 313 | 314 | EXPORT_CONF(${CMAKE_CURRENT_SOURCE_DIR}/make_export.conf) 315 | 316 | add_custom_target(verinfo 317 | ALL 318 | sh scripts/verinfo.sh CMake ${MULTIARCH} 319 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} 320 | ) 321 | add_compile_options(-imacros "${EXPORT_VERINFO}") 322 | 323 | set(CMAKE_INSTALL_PREFIX ${BBSHOME}) 324 | 325 | add_subdirectory(lib) 326 | add_subdirectory(maple) 327 | add_subdirectory(util) 328 | add_subdirectory(innbbsd) 329 | add_subdirectory(so) 330 | add_subdirectory(scripts) 331 | add_subdirectory(sample) 332 | 333 | enable_testing() 334 | add_subdirectory(test) 335 | 336 | # Mark the cache file as up-to-date 337 | if(MARK_CACHE_UPDATED AND CMAKE_CACHEFILE_DIR) 338 | execute_process(COMMAND touch ${CMAKE_CACHEFILE_DIR}/CMakeCache.txt) 339 | endif() 340 | -------------------------------------------------------------------------------- /include/proto.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------*/ 2 | /* proto.h ( NTHU CS MapleBBS Ver 3.02 ) */ 3 | /*-------------------------------------------------------*/ 4 | /* target : prototype and macros */ 5 | /* create : 95/03/29 */ 6 | /* update : 95/12/15 */ 7 | /*-------------------------------------------------------*/ 8 | 9 | #ifndef PROTO_H 10 | #define PROTO_H 11 | 12 | #include 13 | 14 | /* Macros for implementation-defined attributes */ 15 | #include "attrdef.h" 16 | 17 | #include "cppdef.h" 18 | 19 | #ifdef NO_SO 20 | #include "so.h" 21 | #endif 22 | 23 | #ifdef M3_USE_PFTERM 24 | #include "pfterm.h" 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /* ----------------------------------------------------- */ 32 | /* External function declarations */ 33 | /* ----------------------------------------------------- */ 34 | 35 | /* OS */ 36 | char *genpasswd(char *pw, int mode); 37 | 38 | /* ----------------------------------------------------- */ 39 | /* prototypes */ 40 | /* ----------------------------------------------------- */ 41 | 42 | /* acct.c */ 43 | void logitfile(const char *file, const char *key, const char *msg); 44 | int acct_get(const char *msg, ACCT *acct); 45 | void x_file(int mode, const char *const xlist[], const char *const flist[]); 46 | int check_admin(const char *name); 47 | void bitmsg(const char *msg, const char *str, int level); 48 | unsigned int bitset(unsigned int pbits, int count, int maxon, const char *msg, const char *const perms[]); 49 | void acct_show(const ACCT *u, int adm); 50 | void bm_setup(ACCT *u, int adm); 51 | int add_deny(ACCT *u, int adm, int cross); 52 | void acct_setup(ACCT *u, int adm); 53 | int u_info(void); 54 | int m_user(void); 55 | int m_bmset(void); 56 | int u_addr(void); 57 | void su_setup(ACCT *u); 58 | int u_setup(void); 59 | int ue_setup(void); 60 | int u_lock(void); 61 | int u_xfile(void); 62 | int m_newbrd(void); 63 | void brd_edit(int bno); 64 | int a_editbrd(void); 65 | int u_verify(void); 66 | /* bbsd.c */ 67 | void blog_pid(const char *mode, const char *msg, pid_t pid); 68 | void blog(const char *mode, const char *msg); 69 | void u_exit(const char *mode); 70 | GCC_NORETURN void abort_bbs(void); 71 | void talk_rqst_signal(int signum); 72 | /* board.c */ 73 | void brh_get(time_t bstamp, int bhno); 74 | GCC_PURE int brh_unread(time_t chrono); 75 | void brh_visit(int mode); 76 | void brh_add(time_t prev, time_t chrono, time_t next); 77 | void force_board(void); 78 | void remove_perm(void); 79 | int Ben_Perm(const BRD *bhdr, unsigned int ulevel); 80 | GCC_PURE int bstamp2bno(time_t stamp); 81 | void brh_load(void); 82 | void brh_save(void); 83 | bool XoPostSimple(int bno); 84 | bool XoPost(int bno); 85 | void board_outs(int chn, int num); 86 | void class_outs(const char *title, int num); 87 | int Select(void); 88 | int Class(void); 89 | void check_new(BRD *brd); 90 | void board_main(void); 91 | int Boards(void); 92 | int brd_list(int reciper); 93 | /* cache.c */ 94 | void sem_init(void); 95 | void utmp_mode(int mode); 96 | int utmp_new(const UTMP *up); 97 | void utmp_free(void); 98 | GCC_PURE UTMP *utmp_find(int userno); 99 | GCC_PURE UTMP *pid_find(int pid); 100 | int utmp_count(int userno, int show); 101 | GCC_PURE int cmpclasstable(const void *ptr); 102 | void classtable_free(void); 103 | void classtable_main(void); 104 | GCC_PURE int brd_bno(const char *bname); 105 | GCC_PURE int observeshm_find(int userno); 106 | void count_update(void); 107 | int film_out(int tag, int row); 108 | GCC_PURE UTMP *utmp_check(const char *userid); 109 | /* edit.c */ 110 | void ve_string(const char *str); 111 | const char *tbf_ask(int n); 112 | FILE *tbf_open(int n); 113 | void ve_backup(void); 114 | void ve_recover(void); 115 | void ve_header(FILE *fp); 116 | int ve_subject(int row, const char *topic, const char *dft); 117 | int vedit(char *fpath, int ve_op); 118 | /* gem.c */ 119 | void brd2gem(const BRD *brd, HDR *gem); 120 | int gem_gather(XO *xo, int pos); 121 | void XoGem(const char *folder, const char *title, int level); 122 | void gem_main(void); 123 | /* mail.c */ 124 | void ll_new(void); 125 | void ll_add(const char *name); 126 | int ll_del(const char *name); 127 | GCC_PURE int ll_has(const char *name); 128 | void ll_out(int row, int column, const char *msg); 129 | int bsmtp(const char *fpath, const char *title, char *rcpt, int method); 130 | int m_verify(void); 131 | int m_total_size(void); 132 | unsigned int m_quota(void); 133 | int m_zip(void); 134 | int m_query(const char *userid); 135 | void m_biff(int userno); 136 | int m_setforward(void); 137 | int m_setmboxdir(void); 138 | int hdr_reply(int row, const HDR *hdr); 139 | int mail_external(char *addr); 140 | int mail_send(char *rcpt, const char *title); 141 | void mail_reply(HDR *hdr); 142 | void my_send(char *rcpt); 143 | int m_send(void); 144 | int mail_sysop(void); 145 | int mail_list(void); 146 | int tag_char(int chrono); 147 | void hdr_outs(const HDR *hdr, int width); 148 | int mbox_send(XO *xo); 149 | int mail_stat(int mode); 150 | int mbox_check(void); 151 | void mbox_main(void); 152 | /* menu.c */ 153 | int pad_view(void); 154 | void vs_mid(const char *mid); 155 | void vs_head(const char *title, const char *mid); 156 | void clear_notification(void); 157 | void movie(void); 158 | GCC_PURE int strip_ansi_n_len(const char *str, int maxlen); 159 | GCC_PURE int strip_ansi_len(const char *str); 160 | const char *check_info(const void *func, const char *input); 161 | void main_menu(void); 162 | void domenu(MENU *menu, int y_ref, int x_ref, int height_ref, int width_ref, int cmdcur_max); 163 | void domenu_cursor_show(XO *xo); 164 | /* more.c */ 165 | char *mgets(int fd); 166 | void *mread(int fd, int len); 167 | int more(const char *fpath, const char *footer); 168 | /* post.c */ 169 | GCC_PURE int cmpchrono(const void *hdr); 170 | int checksum_find(const char *fpath, int check, int state); 171 | void btime_update(int bno); 172 | void outgo_post(const HDR *hdr, const char *board); 173 | void cancel_post(const HDR *hdr); 174 | void move_post(const HDR *hdr, const char *board, int by_bm); 175 | void log_anonymous(const char *fname); 176 | GCC_PURE int seek_log(const char *title, int state); 177 | int getsubject(int row, int reply); 178 | int post_cross(XO *xo, int pos); 179 | void post_history(XO *xo, int pos, const HDR *fhdr); 180 | int post_gem(XO *xo); 181 | int post_tag(XO *xo, int pos); 182 | int post_edit(XO *xo, int pos); 183 | void header_replace(XO *xo, const HDR *hdr); 184 | int post_title(XO *xo, int pos); 185 | int post_ban_mail(XO *xo); 186 | void record_recommend(int chrono, const char *text); 187 | int post_resetscore(XO *xo, int pos); 188 | int post_recommend(XO *xo, int pos); 189 | int post_manage(XO *xo); 190 | int post_write(XO *xo, int pos); 191 | /* talk.c */ 192 | const char *bmode(const UTMP *up, int simple); 193 | #ifdef NO_SO /* For the main program and the modules of `bbsd` */ 194 | GCC_PURE bool can_message(const UTMP *up); 195 | #endif 196 | GCC_PURE bool is_boardpal(const UTMP *up); 197 | GCC_PURE bool is_pal(int userno); 198 | GCC_PURE bool is_banmsg(int userno); 199 | void pal_cache(void); 200 | void aloha_sync(void); 201 | #ifdef NO_SO /* For the main program and the modules of `bbsd` */ 202 | void pal_sync(const char *fpath); 203 | #endif 204 | int t_pal(void); 205 | int t_bmw(void); 206 | int bm_belong(const char *board); 207 | int XoBM(XO *xo); 208 | void my_query(const char *userid, int paling); 209 | void bmw_edit(UTMP *up, const char *hint, BMW *bmw, int cc); 210 | void bmw_reply(int replymode); 211 | int pal_list(int reciper); 212 | void aloha(void); 213 | int t_loginNotify(void); 214 | void loginNotify(void); 215 | int t_recall(void); 216 | void talk_save(void); 217 | void bmw_save(void); 218 | void bmw_rqst(void); 219 | int t_message(void); 220 | int t_pager(void); 221 | int t_cloak(XO *xo); 222 | int t_query(void); 223 | void talk_rqst(void); 224 | void talk_main(void); 225 | int check_personal_note(int newflag, const char *userid); 226 | void banmsg_cache(void); 227 | void banmsg_sync(const char *fpath); 228 | int t_banmsg(void); 229 | 230 | /* visio.c */ 231 | void bell(void); 232 | #ifdef M3_USE_PFTERM 233 | void ochar(int ch); 234 | void outl(int line, const char *msg); 235 | void outr(const char *str); 236 | void oflush(void); 237 | #else 238 | void move(int y, int x); 239 | void move_ansi(int y, int x); 240 | void move_ref(int y, int x); 241 | void refresh(void); 242 | void clear(void); 243 | void clrtoeol(void); 244 | void clrtobot(void); 245 | void outc(int ch); 246 | void outns(const char *str, int n); 247 | void outs(const char *str); 248 | void scroll(void); 249 | void rscroll(void); 250 | void save_foot(screenline *slp); 251 | void restore_foot(const screenline *slp); 252 | void vs_save_line(screenline *slp, int y); 253 | void vs_restore_line(const screenline *slp, int y); 254 | int vs_save(screen_backup_t *psb); 255 | int vs_resave(screen_backup_t *psb); 256 | void vs_free(screen_backup_t *psb); 257 | void vs_restore_free(screen_backup_t *psb); 258 | void vs_restore(const screen_backup_t *psb); 259 | void clearange(int from, int to); 260 | #endif /* #ifdef M3_USE_PFTERM */ 261 | 262 | void getyx(int *y, int *x); 263 | GCC_PURE int gety_ref(int y_ref); 264 | GCC_PURE int getx_ref(int x_ref); 265 | void move_ref(int y, int x); 266 | int expand_esc_star_visio(char *buf, const char *src, int szbuf); 267 | void outx(const char *str); 268 | void outnz(const char *msg, int n); 269 | void outz(const char *msg); 270 | void outf(const char *str); 271 | void outsep(int xend, const char *pat); 272 | GCC_FORMAT(1, 2) void prints(const char *fmt, ...); 273 | void cursor_save(void); 274 | void cursor_restore(void); 275 | void vmsg_body(const char *msg); 276 | int vmsg(const char *msg); 277 | void zmsg(const char *msg); 278 | void vs_bar(const char *title); 279 | void cursor_bar_show(int row, int column, int width); 280 | void cursor_bar_clear(int row, int column, int width); 281 | int cursor_bar_key(int row, int column, int width); 282 | void cursor_show(int row, int column); 283 | void cursor_clear(int row, int column); 284 | int cursor_key(int row, int column); 285 | #ifndef M3_USE_PFTERM 286 | void grayoutrect(int y, int yend, int x, int xend, int level); 287 | void grayout(int y, int end, int level); 288 | #endif /* #ifndef M3_USE_PFTERM */ 289 | void add_io(int fd, int timeout); 290 | int iac_process(const unsigned char *current, const unsigned char *end, int *pcount); 291 | int iac_count(const unsigned char *current); 292 | int igetch(void); 293 | GCC_NONNULLS int vkey_process(int (*fgetch)(void)); 294 | GCC_NONNULLS int vkey_process_no_dbcs_repeat(int (*fgetch)(void)); 295 | int vkey(void); 296 | BRD *ask_board(char *board, unsigned int perm, const char *msg); 297 | int vget(int y_ref, int x_ref, const char *prompt, char *data, int max, int echo); 298 | int vans(const char *prompt); 299 | 300 | /* xover.c */ 301 | XO *xo_new(const char *path); 302 | XO *xo_get(const char *path); 303 | void xo_load(XO *xo, int recsiz); 304 | void xo_fpath(char *fpath, const char *dir, HDR *hdr); 305 | int hdr_prune(const char *folder, int nhead, int ntail, int post); 306 | int xo_delete(XO *xo); 307 | int Tagger(time_t chrono, int recno, int op); 308 | void EnumTagHdr(HDR *hdr, const char *dir, int locus); 309 | int AskTag(const char *msg); 310 | int xo_uquery_lite(XO *xo, int pos); 311 | int xo_uquery(XO *xo, int pos); 312 | int xo_usetup(XO *xo, int pos); 313 | int xo_getch(XO *xo, int pos, int ch); 314 | int xo_cb_init(XO *xo); 315 | int xo_cb_load(XO *xo); 316 | int xo_cb_head(XO *xo); 317 | int xo_cb_neck(XO *xo); 318 | int xo_cb_body(XO *xo); 319 | int xo_cb_foot(XO *xo); 320 | int xo_cb_last(XO *xo); 321 | int xo_cb_quit(XO *xo); 322 | void xover(int cmd); 323 | int xover_exec_cb(XO *xo, int cmd); 324 | int xover_exec_cb_pos(XO *xo, int cmd, int pos); 325 | int xover_key(XO *xo, int zone, int cmd); 326 | void every_Z(XO *xo); 327 | void every_U(void); 328 | void every_B(void); 329 | void every_S(void); 330 | /* socket.c */ 331 | int Get_Socket(const char *site, int *sock); 332 | int POP3_Check(const char *site, const char *account, const char *passwd); 333 | int Ext_POP3_Check(const char *site, const char *account, const char *passwd); 334 | #ifdef M3_USE_PMORE 335 | /* pmore.c */ 336 | int pmore(const char *fpath, int promptend); 337 | #endif /* #ifdef M3_USE_PMORE */ 338 | /* popupmenu.c */ 339 | int popupmenu_ans(const char *const desc[], const char *title, int y_ref, int x_ref); 340 | void popupmenu(MENU pmenu[], XO *xo, int y_ref, int x_ref); 341 | void pmsg_body(const char *msg); 342 | int pmsg(const char *msg); 343 | int Every_Z_Screen(void); 344 | /* window.c */ 345 | int popupmenu_ans2(const char *const desc[], const char *title, int y_ref, int x_ref); 346 | void pmsg2_body(const char *msg); 347 | int pmsg2(const char *msg); 348 | /* myfavorite.c */ 349 | void brd2myfavorite(const BRD *brd, HDR *gem); 350 | int MyFavorite(void); 351 | int myfavorite_find_chn(const char *brdname); 352 | void myfavorite_parse(char *fpath); 353 | void myfavorite_main(void); 354 | int class_add(XO *xo, int pos); 355 | 356 | #ifdef __cplusplus 357 | } /* extern "C" */ 358 | #endif 359 | 360 | /* ----------------------------------------------------- */ 361 | /* macros */ 362 | /* ----------------------------------------------------- */ 363 | 364 | #define dashd(fpath) S_ISDIR(f_mode(fpath)) 365 | #define dashf(fpath) S_ISREG(f_mode(fpath)) 366 | 367 | #ifdef M3_USE_PFTERM 368 | #define foot_dump(pfoot) scr_dump(pfoot) 369 | #define foot_redump(pfoot) scr_redump(pfoot) 370 | #define foot_free(pfoot) scr_free(pfoot) 371 | #define foot_restore(pfoot) scr_restore(pfoot) 372 | #define foot_restore_free(pfoot) scr_restore_free(pfoot) 373 | #define foot_restore_keep(pfoot) scr_restore_keep(pfoot) 374 | #else 375 | #define scr_dump(pscr) vs_save(pscr) 376 | #define scr_redump(pscr) vs_resave(pscr) 377 | #define scr_free(pscr) vs_free(pscr) 378 | #define scr_restore(pscr) vs_restore_free(pscr) 379 | #define scr_restore_free(pscr) vs_restore_free(pscr) 380 | #define scr_restore_keep(pscr) vs_restore(pscr) 381 | 382 | #define foot_dump(pfoot) save_foot(*(pfoot)) 383 | #define foot_redump(pfoot) save_foot(*(pfoot)) 384 | #define foot_free(pfoot) ((void)0) 385 | #define foot_restore(pfoot) restore_foot(*(pfoot)) 386 | #define foot_restore_free(pfoot) restore_foot(*(pfoot)) 387 | #define foot_restore_keep(pfoot) restore_foot(*(pfoot)) 388 | #endif 389 | 390 | #endif /* PROTO_H */ 391 | --------------------------------------------------------------------------------