refactor(core): split pal from kernel

Move the BBS kernel under core/ and host I/O under platforms/.
This commit is contained in:
Ben Allfree committed 2026-10-07 15:54:38 -07:00
1 parent 6fdcc71953
commit 1243b2bc1b
131 files changed
+3500 -1428

No files matched your search

+6 -4
View File
@@ -1,8 +1,9 @@
#include "paginate.h"
#include "LoBBSReply.h"
#include "core/LoBBSReply.h"
#include "platforms/LoPlatform.h"
#include <cstdio>
#include "LoBBSStackGuard.h"
#include "core/LoBBSStackGuard.h"
bool lobbsPaginateMachine(uint32_t reqId, const std::string &document, uint32_t page1, std::string &pageOut, const char **errMsg)
{
@@ -12,7 +13,8 @@ bool lobbsPaginateMachine(uint32_t reqId, const std::string &document, uint32_t
char prefix[40];
size_t prefixLen = (size_t)snprintf(prefix, sizeof(prefix), "<%u>ok\n", reqId);
if (prefixLen + document.size() <= LOBBS_REPLY_BYTES) {
const size_t pageBytes = lobbsPlatformMaxReplyBytes();
if (prefixLen + document.size() <= pageBytes) {
if (page1 > 1) {
if (errMsg)
*errMsg = "No such page.";
@@ -29,7 +31,7 @@ bool lobbsPaginateMachine(uint32_t reqId, const std::string &document, uint32_t
uint32_t pages = 0;
while (true) {
prefixLen = (size_t)snprintf(prefix, sizeof(prefix), "<%u>ok [%u:%u]\n", reqId, widest, widest);
budget = LOBBS_REPLY_BYTES - prefixLen;
budget = pageBytes - prefixLen;
pages = (uint32_t)((document.size() + budget - 1) / budget);
if (pages <= widest)
break;
+1 -1
View File
@@ -1,7 +1,7 @@
#include "serialize.h"
#include <cstddef>
#include "LoBBSStackGuard.h"
#include "core/LoBBSStackGuard.h"
bool lobbsSerializeMachine(const LoBBSResponse &resp, std::string &out)
{
+1 -1
View File
@@ -1,5 +1,5 @@
#pragma once
#include "LoBBSResponse.h"
#include "core/LoBBSResponse.h"
#include <string>
bool lobbsSerializeMachine(const LoBBSResponse &resp, std::string &out);
+7 -5
View File
@@ -1,10 +1,11 @@
#include "paginate.h"
#include "LoBBSReply.h"
#include "core/LoBBSReply.h"
#include "platforms/LoPlatform.h"
#include <cstdio>
#include <cstring>
#include <vector>
#include "LoBBSStackGuard.h"
#include "core/LoBBSStackGuard.h"
static constexpr size_t LOBBS_PAGER_FOOTER_MAX = 16;
static constexpr int LOBBS_PAGER_MAX_PAGES = 64;
@@ -95,14 +96,15 @@ bool lobbsPaginatePlainText(const std::string &text, uint32_t page1, std::string
uint32_t pageStarts[LOBBS_PAGER_MAX_PAGES + 1];
memset(pageStarts, 0, sizeof(pageStarts));
int pageCount = 0;
lobbsHumanPackPages(lines, LOBBS_REPLY_BYTES, true, pageStarts, pageCount);
const size_t pageBytes = lobbsPlatformMaxReplyBytes();
lobbsHumanPackPages(lines, pageBytes, true, pageStarts, pageCount);
if (pageCount <= 0) {
if (errMsg)
*errMsg = "Empty.";
return false;
}
if (pageCount == 1) {
lobbsHumanPackPages(lines, LOBBS_REPLY_BYTES, false, pageStarts, pageCount);
lobbsHumanPackPages(lines, pageBytes, false, pageStarts, pageCount);
pageStarts[1] = (uint32_t)lines.size();
}
if (page1 > (uint32_t)pageCount) {
@@ -114,7 +116,7 @@ bool lobbsPaginatePlainText(const std::string &text, uint32_t page1, std::string
uint32_t from = pageStarts[page1 - 1];
uint32_t to = pageStarts[page1];
size_t footerReserve = pageCount > 1 ? LOBBS_PAGER_FOOTER_MAX : 0;
size_t maxLine = LOBBS_REPLY_BYTES > footerReserve ? LOBBS_REPLY_BYTES - footerReserve : 0;
size_t maxLine = pageBytes > footerReserve ? pageBytes - footerReserve : 0;
for (uint32_t i = from; i < to; i++) {
if (i > from)
pageOut.push_back('\n');
+2 -2
View File
@@ -1,8 +1,8 @@
#include "serialize.h"
#include "LoBBSHooks.h"
#include "core/LoBBSHooks.h"
#include <lodb/LoDB.h>
#include "LoBBSStackGuard.h"
#include "core/LoBBSStackGuard.h"
static void lobbsDisplayGeneric(const LoScalar &record, std::string &lineOut)
{
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#include "LoBBSCommandCtx.h"
#include "LoBBSResponse.h"
#include "core/LoBBSCommandCtx.h"
#include "core/LoBBSResponse.h"
#include <string>
bool lobbsSerializePlainText(const LoBBSCommandCtx &ctx, const LoBBSResponse &resp, std::string &out);