Add lua function bbs_get_info

This commit is contained in:
Andrew Pamment 2016-08-04 17:27:52 +10:00
parent 82005fe9e2
commit ecf5e9faf8
2 changed files with 55 additions and 34 deletions

View File

@ -1,3 +1,4 @@
#include <sys/utsname.h>
#include "bbs.h"
#include "lua/lua.h"
#include "lua/lauxlib.h"
@ -135,6 +136,19 @@ int l_getFileAreaInfo(lua_State *L) {
return 4;
}
int l_getBBSInfo(lua_State *L) {
struct utsname name;
uname(&name);
lua_pushstring(L, conf.bbs_name);
lua_pushstring(L, conf.sysop_name);
lua_pushstring(L, name.sysname);
lua_pushstring(L, name.machine);
return 4;
}
void lua_push_cfunctions(lua_State *L) {
lua_pushcfunction(L, l_bbsWString);
lua_setglobal(L, "bbs_write_string");
@ -164,4 +178,6 @@ void lua_push_cfunctions(lua_State *L) {
lua_setglobal(L, "bbs_cur_filearea_info");
lua_pushcfunction(L, l_bbsDisplayAutoMsg);
lua_setglobal(L, "bbs_display_automsg");
lua_pushcfunction(L, l_getBBSInfo);
lua_setglobal(L, "bbs_get_info");
}

View File

@ -30,13 +30,20 @@ while(true) do
end
-- Display Info
local bbsname;
local sysopname;
local systemname;
local machinename;
bbsname, sysopname, systemname, machinename = bbs_get_info();
bbs_write_string("\027[1;37mSystem Information\r\n");
bbs_write_string("\027[1;30m----------------------------------------------\r\n");
bbs_write_string("\027[1;32mBBS Name : \027[1;37mCauldron BBS\r\n");
bbs_write_string("\027[1;32mSysOp Name : \027[1;37mAndrew\r\n");
bbs_write_string("\027[1;32mBBS Name : \027[1;37m" .. bbsname .. "\r\n");
bbs_write_string("\027[1;32mSysOp Name : \027[1;37m" .. sysopname .. "\r\n");
bbs_write_string("\027[1;32mNode : \027[1;37m" .. string.format("%d", bbs_node()) .. "\r\n");
bbs_write_string("\027[1;32mBBS Version : \027[1;37m" .. bbs_version() .. "\r\n");
bbs_write_string("\027[1;32mSystem : \027[1;37mA Banana PI!\r\n");
bbs_write_string("\027[1;32mSystem : \027[1;37m" .. systemname .. " (" .. machinename .. ")"\r\n");
bbs_write_string("\027[1;30m----------------------------------------------\r\n");
bbs_write_string("\027[0mPress any key to continue...\r\n");
bbs_read_char();
@ -76,5 +83,3 @@ end
bbs_mail_scan();
-- Done!