feat: rename 'ZenithOS' => 'MontaukOS' and fix build system issues

This commit is contained in:
2026-02-28 12:06:18 +01:00
parent 1809ae55e5
commit 83016847b4
136 changed files with 1669 additions and 51769 deletions
+17 -17
View File
@@ -4,15 +4,15 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
extern "C" void _start() {
char args[256];
int len = zenith::getargs(args, sizeof(args));
int len = montauk::getargs(args, sizeof(args));
if (len <= 0 || args[0] == '\0') {
zenith::print("Usage: cat <filename>\n");
zenith::exit(1);
montauk::print("Usage: cat <filename>\n");
montauk::exit(1);
}
// Build VFS path. If the path already starts with "<digit>:", use as-is.
@@ -34,18 +34,18 @@ extern "C" void _start() {
}
path[i] = '\0';
int handle = zenith::open(path);
int handle = montauk::open(path);
if (handle < 0) {
zenith::print("cat: cannot open '");
zenith::print(args);
zenith::print("'\n");
zenith::exit(1);
montauk::print("cat: cannot open '");
montauk::print(args);
montauk::print("'\n");
montauk::exit(1);
}
uint64_t size = zenith::getsize(handle);
uint64_t size = montauk::getsize(handle);
if (size == 0) {
zenith::close(handle);
zenith::exit(0);
montauk::close(handle);
montauk::exit(0);
}
uint8_t buf[512];
@@ -53,14 +53,14 @@ extern "C" void _start() {
while (offset < size) {
uint64_t chunk = size - offset;
if (chunk > sizeof(buf) - 1) chunk = sizeof(buf) - 1;
int bytesRead = zenith::read(handle, buf, offset, chunk);
int bytesRead = montauk::read(handle, buf, offset, chunk);
if (bytesRead <= 0) break;
buf[bytesRead] = '\0';
zenith::print((const char*)buf);
montauk::print((const char*)buf);
offset += bytesRead;
}
zenith::close(handle);
zenith::putchar('\n');
zenith::exit(0);
montauk::close(handle);
montauk::putchar('\n');
montauk::exit(0);
}
+4 -4
View File
@@ -4,10 +4,10 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
extern "C" void _start() {
zenith::print("\033[2J"); // Clear entire screen
zenith::print("\033[H"); // Move cursor to top-left
zenith::exit(0);
montauk::print("\033[2J"); // Clear entire screen
montauk::print("\033[H"); // Move cursor to top-left
montauk::exit(0);
}
+14 -14
View File
@@ -4,11 +4,11 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
static void print_int(uint64_t n) {
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
char buf[20];
@@ -18,12 +18,12 @@ static void print_int(uint64_t n) {
n /= 10;
}
for (int j = i - 1; j >= 0; j--) {
zenith::putchar(buf[j]);
montauk::putchar(buf[j]);
}
}
static void print_int_padded(uint64_t n) {
if (n < 10) zenith::putchar('0');
if (n < 10) montauk::putchar('0');
print_int(n);
}
@@ -37,20 +37,20 @@ static const char* month_name(int m) {
}
extern "C" void _start() {
Zenith::DateTime dt;
zenith::gettime(&dt);
Montauk::DateTime dt;
montauk::gettime(&dt);
print_int(dt.Day);
zenith::putchar(' ');
zenith::print(month_name(dt.Month));
zenith::putchar(' ');
montauk::putchar(' ');
montauk::print(month_name(dt.Month));
montauk::putchar(' ');
print_int(dt.Year);
zenith::print(", ");
montauk::print(", ");
print_int(dt.Hour);
zenith::putchar(':');
montauk::putchar(':');
print_int_padded(dt.Minute);
zenith::putchar(':');
montauk::putchar(':');
print_int_padded(dt.Second);
zenith::print(" UTC\n");
zenith::exit(0);
montauk::print(" UTC\n");
montauk::exit(0);
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Makefile for desktop (GUI desktop environment) on ZenithOS
# Makefile for desktop (GUI desktop environment) on MontaukOS
# Copyright (c) 2025 Daniel Hammer
MAKEFLAGS += -rR
+7 -7
View File
@@ -1,6 +1,6 @@
/*
* app_calculator.cpp
* ZenithOS Desktop - Calculator application
* MontaukOS Desktop - Calculator application
* Integer-only 4-function calculator (values scaled by 100 for 2 decimal places)
* Copyright (c) 2026 Daniel Hammer
*/
@@ -61,7 +61,7 @@ static void calc_format_display(CalcState* cs) {
// Trim trailing zeros after decimal point (unless user is entering decimals)
if (!cs->has_decimal) {
int len = zenith::slen(cs->display_str);
int len = montauk::slen(cs->display_str);
while (len > 1 && cs->display_str[len - 1] == '0') {
cs->display_str[--len] = '\0';
}
@@ -237,7 +237,7 @@ static void calculator_on_draw(Window* win, Framebuffer& fb) {
text_w = fonts::system_font->measure_text(cs->display_str, fonts::LARGE_SIZE);
large_h = fonts::system_font->get_line_height(fonts::LARGE_SIZE);
} else {
int text_len = zenith::slen(cs->display_str);
int text_len = montauk::slen(cs->display_str);
text_w = text_len * FONT_WIDTH * 2;
large_h = FONT_HEIGHT * 2;
}
@@ -342,7 +342,7 @@ static void calculator_on_mouse(Window* win, MouseEvent& ev) {
// Keyboard handling
// ============================================================================
static void calculator_on_key(Window* win, const Zenith::KeyEvent& key) {
static void calculator_on_key(Window* win, const Montauk::KeyEvent& key) {
CalcState* cs = (CalcState*)win->app_data;
if (!cs || !key.pressed) return;
@@ -369,7 +369,7 @@ static void calculator_on_key(Window* win, const Zenith::KeyEvent& key) {
static void calculator_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -386,8 +386,8 @@ void open_calculator(DesktopState* ds) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
CalcState* cs = (CalcState*)zenith::malloc(sizeof(CalcState));
zenith::memset(cs, 0, sizeof(CalcState));
CalcState* cs = (CalcState*)montauk::malloc(sizeof(CalcState));
montauk::memset(cs, 0, sizeof(CalcState));
cs->display_val = 0;
cs->accumulator = 0;
cs->pending_op = 0;
+9 -9
View File
@@ -1,6 +1,6 @@
/*
* app_devexplorer.cpp
* ZenithOS Desktop - Device Explorer (lists hardware detected by the kernel)
* MontaukOS Desktop - Device Explorer (lists hardware detected by the kernel)
* Copyright (c) 2026 Daniel Hammer
*/
@@ -43,7 +43,7 @@ static Color category_colors[] = {
struct DevExplorerState {
DesktopState* desktop;
Zenith::DevInfo devs[DE_MAX_DEVS];
Montauk::DevInfo devs[DE_MAX_DEVS];
int dev_count;
bool collapsed[NUM_CATEGORIES]; // per-category collapse state
int selected_row; // index into visible display rows (-1 = none)
@@ -130,11 +130,11 @@ static void devexplorer_on_poll(Window* win) {
DevExplorerState* de = (DevExplorerState*)win->app_data;
if (!de) return;
uint64_t now = zenith::get_milliseconds();
uint64_t now = montauk::get_milliseconds();
if (now - de->last_poll_ms < DE_POLL_MS) return;
de->last_poll_ms = now;
de->dev_count = zenith::devlist(de->devs, DE_MAX_DEVS);
de->dev_count = montauk::devlist(de->devs, DE_MAX_DEVS);
}
static void devexplorer_on_draw(Window* win, Framebuffer& fb) {
@@ -364,7 +364,7 @@ static void devexplorer_on_mouse(Window* win, MouseEvent& ev) {
}
}
static void devexplorer_on_key(Window* win, const Zenith::KeyEvent& key) {
static void devexplorer_on_key(Window* win, const Montauk::KeyEvent& key) {
DevExplorerState* de = (DevExplorerState*)win->app_data;
if (!de || !key.pressed) return;
@@ -437,7 +437,7 @@ static void devexplorer_on_key(Window* win, const Zenith::KeyEvent& key) {
static void devexplorer_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -452,8 +452,8 @@ void open_devexplorer(DesktopState* ds) {
Window* win = &ds->windows[idx];
DevExplorerState* de = (DevExplorerState*)zenith::malloc(sizeof(DevExplorerState));
zenith::memset(de, 0, sizeof(DevExplorerState));
DevExplorerState* de = (DevExplorerState*)montauk::malloc(sizeof(DevExplorerState));
montauk::memset(de, 0, sizeof(DevExplorerState));
de->desktop = ds;
de->selected_row = -1;
de->scroll_y = 0;
@@ -464,7 +464,7 @@ void open_devexplorer(DesktopState* ds) {
de->collapsed[i] = false;
// Initial poll
de->dev_count = zenith::devlist(de->devs, DE_MAX_DEVS);
de->dev_count = montauk::devlist(de->devs, DE_MAX_DEVS);
win->app_data = de;
win->on_draw = devexplorer_on_draw;
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* app_doom.cpp
* ZenithOS Desktop - DOOM launcher (spawns standalone doom.elf)
* MontaukOS Desktop - DOOM launcher (spawns standalone doom.elf)
* Copyright (c) 2026 Daniel Hammer
*/
@@ -8,5 +8,5 @@
void open_doom(DesktopState* ds) {
(void)ds;
zenith::spawn("0:/games/doom.elf");
montauk::spawn("0:/games/doom.elf");
}
+40 -40
View File
@@ -1,6 +1,6 @@
/*
* app_filemanager.cpp
* ZenithOS Desktop - Enhanced File Manager application
* MontaukOS Desktop - Enhanced File Manager application
* Copyright (c) 2026 Daniel Hammer
*/
@@ -44,8 +44,8 @@ static constexpr int FM_GRID_PAD = 4;
// ============================================================================
static bool str_ends_with(const char* s, const char* suffix) {
int slen = zenith::slen(s);
int suflen = zenith::slen(suffix);
int slen = montauk::slen(s);
int suflen = montauk::slen(suffix);
if (suflen > slen) return false;
for (int i = 0; i < suflen; i++) {
char sc = s[slen - suflen + i];
@@ -77,7 +77,7 @@ static int detect_file_type(const char* name, bool is_dir) {
static void filemanager_read_dir(FileManagerState* fm) {
const char* names[64];
fm->entry_count = zenith::readdir(fm->current_path, names, 64);
fm->entry_count = montauk::readdir(fm->current_path, names, 64);
if (fm->entry_count < 0) fm->entry_count = 0;
// readdir returns full paths from the VFS (e.g. "man/fetch.1" instead
@@ -92,8 +92,8 @@ static void filemanager_read_dir(FileManagerState* fm) {
char prefix[256] = {0};
int prefix_len = 0;
if (after_drive[0] != '\0') {
zenith::strcpy(prefix, after_drive);
prefix_len = zenith::slen(prefix);
montauk::strcpy(prefix, after_drive);
prefix_len = montauk::slen(prefix);
if (prefix_len > 0 && prefix[prefix_len - 1] != '/') {
prefix[prefix_len++] = '/';
prefix[prefix_len] = '\0';
@@ -110,8 +110,8 @@ static void filemanager_read_dir(FileManagerState* fm) {
}
if (match) raw += prefix_len;
}
zenith::strncpy(fm->entry_names[i], raw, 63);
int len = zenith::slen(fm->entry_names[i]);
montauk::strncpy(fm->entry_names[i], raw, 63);
int len = montauk::slen(fm->entry_names[i]);
// Detect directory
if (len > 0 && fm->entry_names[i][len - 1] == '/') {
@@ -131,16 +131,16 @@ static void filemanager_read_dir(FileManagerState* fm) {
fm->entry_sizes[i] = 0;
if (!fm->is_dir[i]) {
char fullpath[512];
zenith::strcpy(fullpath, fm->current_path);
int plen = zenith::slen(fullpath);
montauk::strcpy(fullpath, fm->current_path);
int plen = montauk::slen(fullpath);
if (plen > 0 && fullpath[plen - 1] != '/') {
str_append(fullpath, "/", 512);
}
str_append(fullpath, fm->entry_names[i], 512);
int fd = zenith::open(fullpath);
int fd = montauk::open(fullpath);
if (fd >= 0) {
fm->entry_sizes[i] = (int)zenith::getsize(fd);
zenith::close(fd);
fm->entry_sizes[i] = (int)montauk::getsize(fd);
montauk::close(fd);
}
}
}
@@ -151,7 +151,7 @@ static void filemanager_read_dir(FileManagerState* fm) {
int tmp_type = fm->entry_types[i];
int tmp_size = fm->entry_sizes[i];
bool tmp_isdir = fm->is_dir[i];
zenith::strcpy(tmp_name, fm->entry_names[i]);
montauk::strcpy(tmp_name, fm->entry_names[i]);
int j = i - 1;
while (j >= 0) {
@@ -165,13 +165,13 @@ static void filemanager_read_dir(FileManagerState* fm) {
}
if (!swap) break;
zenith::strcpy(fm->entry_names[j + 1], fm->entry_names[j]);
montauk::strcpy(fm->entry_names[j + 1], fm->entry_names[j]);
fm->entry_types[j + 1] = fm->entry_types[j];
fm->entry_sizes[j + 1] = fm->entry_sizes[j];
fm->is_dir[j + 1] = fm->is_dir[j];
j--;
}
zenith::strcpy(fm->entry_names[j + 1], tmp_name);
montauk::strcpy(fm->entry_names[j + 1], tmp_name);
fm->entry_types[j + 1] = tmp_type;
fm->entry_sizes[j + 1] = tmp_size;
fm->is_dir[j + 1] = tmp_isdir;
@@ -190,16 +190,16 @@ static void filemanager_read_dir(FileManagerState* fm) {
static void filemanager_push_history(FileManagerState* fm) {
// Don't push if same as current position
if (fm->history_count > 0 && fm->history_pos >= 0) {
if (zenith::streq(fm->history[fm->history_pos], fm->current_path)) return;
if (montauk::streq(fm->history[fm->history_pos], fm->current_path)) return;
}
fm->history_pos++;
if (fm->history_pos >= 16) fm->history_pos = 15;
zenith::strcpy(fm->history[fm->history_pos], fm->current_path);
montauk::strcpy(fm->history[fm->history_pos], fm->current_path);
fm->history_count = fm->history_pos + 1;
}
static void filemanager_navigate(FileManagerState* fm, const char* name) {
int path_len = zenith::slen(fm->current_path);
int path_len = montauk::slen(fm->current_path);
if (path_len > 0 && fm->current_path[path_len - 1] != '/') {
str_append(fm->current_path, "/", 256);
}
@@ -209,7 +209,7 @@ static void filemanager_navigate(FileManagerState* fm, const char* name) {
}
static void filemanager_go_up(FileManagerState* fm) {
int len = zenith::slen(fm->current_path);
int len = montauk::slen(fm->current_path);
if (len <= 3) return; // "0:/" is root
if (len > 0 && fm->current_path[len - 1] == '/') {
@@ -231,19 +231,19 @@ static void filemanager_go_up(FileManagerState* fm) {
static void filemanager_go_back(FileManagerState* fm) {
if (fm->history_pos <= 0) return;
fm->history_pos--;
zenith::strcpy(fm->current_path, fm->history[fm->history_pos]);
montauk::strcpy(fm->current_path, fm->history[fm->history_pos]);
filemanager_read_dir(fm);
}
static void filemanager_go_forward(FileManagerState* fm) {
if (fm->history_pos >= fm->history_count - 1) return;
fm->history_pos++;
zenith::strcpy(fm->current_path, fm->history[fm->history_pos]);
montauk::strcpy(fm->current_path, fm->history[fm->history_pos]);
filemanager_read_dir(fm);
}
static void filemanager_go_home(FileManagerState* fm) {
zenith::strcpy(fm->current_path, "0:/");
montauk::strcpy(fm->current_path, "0:/");
filemanager_push_history(fm);
filemanager_read_dir(fm);
}
@@ -368,14 +368,14 @@ static void filemanager_on_draw(Window* win, Framebuffer& fb) {
// Filename centered below icon, truncated if needed
char label[16];
int nlen = zenith::slen(fm->entry_names[i]);
int nlen = montauk::slen(fm->entry_names[i]);
if (nlen > 9) {
for (int k = 0; k < 9; k++) label[k] = fm->entry_names[i][k];
label[9] = '.';
label[10] = '.';
label[11] = '\0';
} else {
zenith::strncpy(label, fm->entry_names[i], 15);
montauk::strncpy(label, fm->entry_names[i], 15);
}
int tw = text_width(label);
int tx = cell_x + (FM_GRID_CELL_W - tw) / 2;
@@ -539,7 +539,7 @@ static void filemanager_on_mouse(Window* win, MouseEvent& ev) {
int clicked_idx = row * cols + col;
if (clicked_idx >= 0 && clicked_idx < fm->entry_count && col < cols) {
uint64_t now = zenith::get_milliseconds();
uint64_t now = montauk::get_milliseconds();
if (fm->last_click_item == clicked_idx &&
(now - fm->last_click_time) < 400) {
@@ -547,16 +547,16 @@ static void filemanager_on_mouse(Window* win, MouseEvent& ev) {
filemanager_navigate(fm, fm->entry_names[clicked_idx]);
} else {
char fullpath[512];
zenith::strcpy(fullpath, fm->current_path);
int plen = zenith::slen(fullpath);
montauk::strcpy(fullpath, fm->current_path);
int plen = montauk::slen(fullpath);
if (plen > 0 && fullpath[plen - 1] != '/') {
str_append(fullpath, "/", 512);
}
str_append(fullpath, fm->entry_names[clicked_idx], 512);
if (is_image_file(fm->entry_names[clicked_idx])) {
zenith::spawn("0:/os/imageviewer.elf", fullpath);
montauk::spawn("0:/os/imageviewer.elf", fullpath);
} else if (is_font_file(fm->entry_names[clicked_idx])) {
zenith::spawn("0:/os/fontpreview.elf", fullpath);
montauk::spawn("0:/os/fontpreview.elf", fullpath);
} else if (fm->desktop) {
open_texteditor_with_file(fm->desktop, fullpath);
}
@@ -578,7 +578,7 @@ static void filemanager_on_mouse(Window* win, MouseEvent& ev) {
int clicked_idx = rel_y / FM_ITEM_H;
if (clicked_idx >= 0 && clicked_idx < fm->entry_count) {
uint64_t now = zenith::get_milliseconds();
uint64_t now = montauk::get_milliseconds();
// Double-click detection
if (fm->last_click_item == clicked_idx &&
@@ -588,16 +588,16 @@ static void filemanager_on_mouse(Window* win, MouseEvent& ev) {
} else {
// Open file in appropriate viewer
char fullpath[512];
zenith::strcpy(fullpath, fm->current_path);
int plen = zenith::slen(fullpath);
montauk::strcpy(fullpath, fm->current_path);
int plen = montauk::slen(fullpath);
if (plen > 0 && fullpath[plen - 1] != '/') {
str_append(fullpath, "/", 512);
}
str_append(fullpath, fm->entry_names[clicked_idx], 512);
if (is_image_file(fm->entry_names[clicked_idx])) {
zenith::spawn("0:/os/imageviewer.elf", fullpath);
montauk::spawn("0:/os/imageviewer.elf", fullpath);
} else if (is_font_file(fm->entry_names[clicked_idx])) {
zenith::spawn("0:/os/fontpreview.elf", fullpath);
montauk::spawn("0:/os/fontpreview.elf", fullpath);
} else if (fm->desktop) {
open_texteditor_with_file(fm->desktop, fullpath);
}
@@ -633,7 +633,7 @@ static void filemanager_on_mouse(Window* win, MouseEvent& ev) {
// Keyboard handling
// ============================================================================
static void filemanager_on_key(Window* win, const Zenith::KeyEvent& key) {
static void filemanager_on_key(Window* win, const Montauk::KeyEvent& key) {
FileManagerState* fm = (FileManagerState*)win->app_data;
if (!fm || !key.pressed) return;
@@ -682,7 +682,7 @@ static void filemanager_on_key(Window* win, const Zenith::KeyEvent& key) {
static void filemanager_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -696,9 +696,9 @@ void open_filemanager(DesktopState* ds) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
FileManagerState* fm = (FileManagerState*)zenith::malloc(sizeof(FileManagerState));
zenith::memset(fm, 0, sizeof(FileManagerState));
zenith::strcpy(fm->current_path, "0:/");
FileManagerState* fm = (FileManagerState*)montauk::malloc(sizeof(FileManagerState));
montauk::memset(fm, 0, sizeof(FileManagerState));
montauk::strcpy(fm->current_path, "0:/");
fm->selected = -1;
fm->last_click_item = -1;
fm->history_pos = -1;
+12 -12
View File
@@ -1,6 +1,6 @@
/*
* app_klog.cpp
* ZenithOS Desktop - Kernel Log viewer (tails the kernel ring buffer)
* MontaukOS Desktop - Kernel Log viewer (tails the kernel ring buffer)
* Copyright (c) 2026 Daniel Hammer
*/
@@ -64,7 +64,7 @@ static void klog_on_mouse(Window* win, MouseEvent& ev) {
// Read-only viewer — no mouse interaction needed
}
static void klog_on_key(Window* win, const Zenith::KeyEvent& key) {
static void klog_on_key(Window* win, const Montauk::KeyEvent& key) {
// Read-only viewer — no keyboard input
}
@@ -72,11 +72,11 @@ static void klog_on_poll(Window* win) {
KlogState* klog = (KlogState*)win->app_data;
if (!klog) return;
uint64_t now = zenith::get_milliseconds();
uint64_t now = montauk::get_milliseconds();
if (now - klog->last_poll_ms < KLOG_POLL_MS) return;
klog->last_poll_ms = now;
int n = (int)zenith::read_klog(klog->klog_buf, KLOG_READ_SIZE);
int n = (int)montauk::read_klog(klog->klog_buf, KLOG_READ_SIZE);
if (n <= 0 && klog->last_len <= 0) return;
if (n > klog->last_len) {
@@ -101,10 +101,10 @@ static void klog_on_poll(Window* win) {
static void klog_on_close(Window* win) {
KlogState* klog = (KlogState*)win->app_data;
if (klog) {
if (klog->term.cells) zenith::mfree(klog->term.cells);
if (klog->term.alt_cells) zenith::mfree(klog->term.alt_cells);
if (klog->klog_buf) zenith::mfree(klog->klog_buf);
zenith::mfree(klog);
if (klog->term.cells) montauk::mfree(klog->term.cells);
if (klog->term.alt_cells) montauk::mfree(klog->term.alt_cells);
if (klog->klog_buf) montauk::mfree(klog->klog_buf);
montauk::mfree(klog);
win->app_data = nullptr;
}
}
@@ -122,20 +122,20 @@ void open_klog(DesktopState* ds) {
int cols = cr.w / mono_cell_width();
int rows = cr.h / mono_cell_height();
KlogState* klog = (KlogState*)zenith::malloc(sizeof(KlogState));
zenith::memset(klog, 0, sizeof(KlogState));
KlogState* klog = (KlogState*)montauk::malloc(sizeof(KlogState));
montauk::memset(klog, 0, sizeof(KlogState));
// Initialize the terminal cell grid (reuse terminal infrastructure)
terminal_init_cells(&klog->term, cols, rows);
// Allocate klog read buffer
klog->klog_buf = (char*)zenith::malloc(KLOG_READ_SIZE);
klog->klog_buf = (char*)montauk::malloc(KLOG_READ_SIZE);
klog->last_len = 0;
klog->last_tail_byte = 0;
klog->last_poll_ms = 0;
// Do an initial read to show existing log content
int n = (int)zenith::read_klog(klog->klog_buf, KLOG_READ_SIZE);
int n = (int)montauk::read_klog(klog->klog_buf, KLOG_READ_SIZE);
if (n > 0) {
klog_refeed(klog, n);
klog->last_len = n;
+5 -5
View File
@@ -1,6 +1,6 @@
/*
* app_mandelbrot.cpp
* ZenithOS Desktop - Mandelbrot set visualizer
* MontaukOS Desktop - Mandelbrot set visualizer
* Supports zoom (scroll wheel), pan (drag), and reset (R key)
* Copyright (c) 2026 Daniel Hammer
*/
@@ -242,7 +242,7 @@ static void mb_on_mouse(Window* win, MouseEvent& ev) {
}
}
static void mb_on_key(Window* win, const Zenith::KeyEvent& key) {
static void mb_on_key(Window* win, const Montauk::KeyEvent& key) {
MandelbrotState* mb = (MandelbrotState*)win->app_data;
if (!mb || !key.pressed) return;
@@ -262,7 +262,7 @@ static void mb_on_key(Window* win, const Zenith::KeyEvent& key) {
static void mb_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -278,8 +278,8 @@ void open_mandelbrot(DesktopState* ds) {
Window* win = &ds->windows[idx];
Rect cr = win->content_rect();
MandelbrotState* mb = (MandelbrotState*)zenith::malloc(sizeof(MandelbrotState));
zenith::memset(mb, 0, sizeof(MandelbrotState));
MandelbrotState* mb = (MandelbrotState*)montauk::malloc(sizeof(MandelbrotState));
montauk::memset(mb, 0, sizeof(MandelbrotState));
mb->desktop = ds;
mb->center_x = -fp_from_int(1) / 2; // -0.5
mb->center_y = 0;
+11 -11
View File
@@ -1,6 +1,6 @@
/*
* app_procmgr.cpp
* ZenithOS Desktop - Process Manager
* MontaukOS Desktop - Process Manager
* Copyright (c) 2026 Daniel Hammer
*/
@@ -18,7 +18,7 @@ static constexpr int PM_POLL_MS = 1000;
struct ProcMgrState {
DesktopState* desktop;
Zenith::ProcInfo procs[PM_MAX_PROCS];
Montauk::ProcInfo procs[PM_MAX_PROCS];
int proc_count;
int selected; // selected row index (-1 = none)
uint64_t last_poll_ms;
@@ -32,7 +32,7 @@ static void procmgr_on_poll(Window* win) {
ProcMgrState* pm = (ProcMgrState*)win->app_data;
if (!pm) return;
uint64_t now = zenith::get_milliseconds();
uint64_t now = montauk::get_milliseconds();
if (now - pm->last_poll_ms < PM_POLL_MS) return;
pm->last_poll_ms = now;
@@ -42,7 +42,7 @@ static void procmgr_on_poll(Window* win) {
prev_pid = pm->procs[pm->selected].pid;
}
pm->proc_count = zenith::proclist(pm->procs, PM_MAX_PROCS);
pm->proc_count = montauk::proclist(pm->procs, PM_MAX_PROCS);
// Restore selection by matching PID
pm->selected = -1;
@@ -172,7 +172,7 @@ static void procmgr_on_mouse(Window* win, MouseEvent& ev) {
if (btn_rect.contains(lx, ly)) {
if (pm->selected >= 0 && pm->selected < pm->proc_count
&& pm->procs[pm->selected].pid != 0) {
zenith::kill(pm->procs[pm->selected].pid);
montauk::kill(pm->procs[pm->selected].pid);
pm->last_poll_ms = 0; // force refresh
}
return;
@@ -191,7 +191,7 @@ static void procmgr_on_mouse(Window* win, MouseEvent& ev) {
}
}
static void procmgr_on_key(Window* win, const Zenith::KeyEvent& key) {
static void procmgr_on_key(Window* win, const Montauk::KeyEvent& key) {
ProcMgrState* pm = (ProcMgrState*)win->app_data;
if (!pm || !key.pressed) return;
@@ -203,7 +203,7 @@ static void procmgr_on_key(Window* win, const Zenith::KeyEvent& key) {
} else if (key.scancode == 0x53) { // Delete key
if (pm->selected >= 0 && pm->selected < pm->proc_count
&& pm->procs[pm->selected].pid != 0) {
zenith::kill(pm->procs[pm->selected].pid);
montauk::kill(pm->procs[pm->selected].pid);
pm->last_poll_ms = 0; // force refresh
}
}
@@ -211,7 +211,7 @@ static void procmgr_on_key(Window* win, const Zenith::KeyEvent& key) {
static void procmgr_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -226,14 +226,14 @@ void open_procmgr(DesktopState* ds) {
Window* win = &ds->windows[idx];
ProcMgrState* pm = (ProcMgrState*)zenith::malloc(sizeof(ProcMgrState));
zenith::memset(pm, 0, sizeof(ProcMgrState));
ProcMgrState* pm = (ProcMgrState*)montauk::malloc(sizeof(ProcMgrState));
montauk::memset(pm, 0, sizeof(ProcMgrState));
pm->desktop = ds;
pm->selected = -1;
pm->last_poll_ms = 0;
// Initial poll
pm->proc_count = zenith::proclist(pm->procs, PM_MAX_PROCS);
pm->proc_count = montauk::proclist(pm->procs, PM_MAX_PROCS);
win->app_data = pm;
win->on_draw = procmgr_on_draw;
+17 -17
View File
@@ -1,6 +1,6 @@
/*
* app_settings.cpp
* ZenithOS Desktop - Settings application
* MontaukOS Desktop - Settings application
* Copyright (c) 2026 Daniel Hammer
*/
@@ -14,7 +14,7 @@
struct SettingsState {
DesktopState* desktop;
int active_tab; // 0=Appearance, 1=Display, 2=About
Zenith::SysInfo sys_info;
Montauk::SysInfo sys_info;
uint64_t uptime_ms;
WallpaperFileList wp_files;
bool wp_scanned;
@@ -180,11 +180,11 @@ static void settings_draw_appearance(Canvas& c, SettingsState* st) {
for (int i = 0; i < st->wp_files.count && i < 8; i++) {
// Build full path for comparison
char fullpath[256];
zenith::strcpy(fullpath, "0:/home/");
montauk::strcpy(fullpath, "0:/home/");
str_append(fullpath, st->wp_files.names[i], 256);
bool selected = s.bg_image &&
zenith::streq(s.bg_image_path, fullpath);
montauk::streq(s.bg_image_path, fullpath);
if (selected) {
c.fill_rounded_rect(x, y, c.w - 2 * x, WP_ITEM_H, 3, accent);
@@ -192,15 +192,15 @@ static void settings_draw_appearance(Canvas& c, SettingsState* st) {
// Truncate long filenames
char label[40];
int nlen = zenith::slen(st->wp_files.names[i]);
int nlen = montauk::slen(st->wp_files.names[i]);
if (nlen > 35) {
zenith::strncpy(label, st->wp_files.names[i], 32);
montauk::strncpy(label, st->wp_files.names[i], 32);
label[32] = '.';
label[33] = '.';
label[34] = '.';
label[35] = '\0';
} else {
zenith::strncpy(label, st->wp_files.names[i], 39);
montauk::strncpy(label, st->wp_files.names[i], 39);
}
Color tc = selected ? colors::WHITE : colors::TEXT_COLOR;
@@ -292,7 +292,7 @@ static void settings_draw_display(Canvas& c, SettingsState* st) {
}
static void settings_draw_about(Canvas& c, SettingsState* st) {
st->uptime_ms = zenith::get_milliseconds();
st->uptime_ms = montauk::get_milliseconds();
Color dim = Color::from_rgb(0x88, 0x88, 0x88);
int x = 16;
@@ -463,7 +463,7 @@ static void settings_on_mouse(Window* win, MouseEvent& ev) {
mx >= x && mx < win->content_w - x) {
// Build full path and load wallpaper
char fullpath[256];
zenith::strcpy(fullpath, "0:/home/");
montauk::strcpy(fullpath, "0:/home/");
str_append(fullpath, st->wp_files.names[i], 256);
wallpaper_load(&s, fullpath,
st->desktop->screen_w, st->desktop->screen_h);
@@ -552,21 +552,21 @@ static void settings_on_mouse(Window* win, MouseEvent& ev) {
if (mx >= bx && mx < bx + sbw && cy >= y && cy < y + btn_h) {
s.ui_scale = 0;
apply_ui_scale(0);
zenith::win_setscale(0);
montauk::win_setscale(0);
return;
}
// Default
if (mx >= bx + sbw + 8 && mx < bx + sbw * 2 + 8 && cy >= y && cy < y + btn_h) {
s.ui_scale = 1;
apply_ui_scale(1);
zenith::win_setscale(1);
montauk::win_setscale(1);
return;
}
// Large
if (mx >= bx + (sbw + 8) * 2 && mx < bx + sbw * 3 + 16 && cy >= y && cy < y + btn_h) {
s.ui_scale = 2;
apply_ui_scale(2);
zenith::win_setscale(2);
montauk::win_setscale(2);
return;
}
}
@@ -578,7 +578,7 @@ static void settings_on_mouse(Window* win, MouseEvent& ev) {
static void settings_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -592,12 +592,12 @@ void open_settings(DesktopState* ds) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
SettingsState* st = (SettingsState*)zenith::malloc(sizeof(SettingsState));
zenith::memset(st, 0, sizeof(SettingsState));
SettingsState* st = (SettingsState*)montauk::malloc(sizeof(SettingsState));
montauk::memset(st, 0, sizeof(SettingsState));
st->desktop = ds;
st->active_tab = 0;
zenith::get_info(&st->sys_info);
st->uptime_ms = zenith::get_milliseconds();
montauk::get_info(&st->sys_info);
st->uptime_ms = montauk::get_milliseconds();
st->wp_scanned = false;
st->wp_files.count = 0;
+10 -10
View File
@@ -1,6 +1,6 @@
/*
* app_sysinfo.cpp
* ZenithOS Desktop - System Info application
* MontaukOS Desktop - System Info application
* Copyright (c) 2026 Daniel Hammer
*/
@@ -11,8 +11,8 @@
// ============================================================================
struct SysInfoState {
Zenith::SysInfo sys_info;
Zenith::NetCfg net_cfg;
Montauk::SysInfo sys_info;
Montauk::NetCfg net_cfg;
uint64_t uptime_ms;
};
@@ -20,7 +20,7 @@ static void sysinfo_on_draw(Window* win, Framebuffer& fb) {
SysInfoState* si = (SysInfoState*)win->app_data;
if (!si) return;
si->uptime_ms = zenith::get_milliseconds();
si->uptime_ms = montauk::get_milliseconds();
Canvas c(win);
c.fill(colors::WINDOW_BG);
@@ -107,7 +107,7 @@ static void sysinfo_on_draw(Window* win, Framebuffer& fb) {
static void sysinfo_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -121,11 +121,11 @@ void open_sysinfo(DesktopState* ds) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
SysInfoState* si = (SysInfoState*)zenith::malloc(sizeof(SysInfoState));
zenith::memset(si, 0, sizeof(SysInfoState));
zenith::get_info(&si->sys_info);
zenith::get_netcfg(&si->net_cfg);
si->uptime_ms = zenith::get_milliseconds();
SysInfoState* si = (SysInfoState*)montauk::malloc(sizeof(SysInfoState));
montauk::memset(si, 0, sizeof(SysInfoState));
montauk::get_info(&si->sys_info);
montauk::get_netcfg(&si->net_cfg);
si->uptime_ms = montauk::get_milliseconds();
win->app_data = si;
win->on_draw = sysinfo_on_draw;
+6 -6
View File
@@ -1,6 +1,6 @@
/*
* app_terminal.cpp
* ZenithOS Desktop - Terminal application
* MontaukOS Desktop - Terminal application
* Copyright (c) 2026 Daniel Hammer
*/
@@ -30,7 +30,7 @@ static void terminal_on_mouse(Window* win, MouseEvent& ev) {
// Terminal doesn't need mouse handling for now
}
static void terminal_on_key(Window* win, const Zenith::KeyEvent& key) {
static void terminal_on_key(Window* win, const Montauk::KeyEvent& key) {
TerminalState* ts = (TerminalState*)win->app_data;
if (!ts) return;
terminal_handle_key(ts, key);
@@ -39,8 +39,8 @@ static void terminal_on_key(Window* win, const Zenith::KeyEvent& key) {
static void terminal_on_close(Window* win) {
TerminalState* ts = (TerminalState*)win->app_data;
if (ts) {
if (ts->cells) zenith::mfree(ts->cells);
zenith::mfree(ts);
if (ts->cells) montauk::mfree(ts->cells);
montauk::mfree(ts);
win->app_data = nullptr;
}
}
@@ -63,8 +63,8 @@ void open_terminal(DesktopState* ds) {
int cols = cr.w / mono_cell_width();
int rows = cr.h / mono_cell_height();
TerminalState* ts = (TerminalState*)zenith::malloc(sizeof(TerminalState));
zenith::memset(ts, 0, sizeof(TerminalState));
TerminalState* ts = (TerminalState*)montauk::malloc(sizeof(TerminalState));
montauk::memset(ts, 0, sizeof(TerminalState));
terminal_init(ts, cols, rows);
win->app_data = ts;
+30 -30
View File
@@ -1,6 +1,6 @@
/*
* app_texteditor.cpp
* ZenithOS Desktop - Text Editor application
* MontaukOS Desktop - Text Editor application
* Single-buffer text editor with line numbers, cursor, scrolling, file I/O
* Copyright (c) 2026 Daniel Hammer
*/
@@ -48,7 +48,7 @@ struct TextEditorState {
static void te_recompute_lines(TextEditorState* te) {
if (!te->line_offsets) {
te->line_offsets = (int*)zenith::malloc(TE_MAX_LINES * sizeof(int));
te->line_offsets = (int*)montauk::malloc(TE_MAX_LINES * sizeof(int));
}
te->line_count = 0;
@@ -94,7 +94,7 @@ static void te_ensure_capacity(TextEditorState* te, int needed) {
int new_cap = te->buf_cap * 2;
if (new_cap > TE_MAX_CAP) new_cap = TE_MAX_CAP;
if (new_cap < te->buf_len + needed) new_cap = te->buf_len + needed;
te->buffer = (char*)zenith::realloc(te->buffer, new_cap);
te->buffer = (char*)montauk::realloc(te->buffer, new_cap);
te->buf_cap = new_cap;
}
@@ -236,21 +236,21 @@ static void te_ensure_cursor_visible(TextEditorState* te, int visible_lines, int
// ============================================================================
static void te_load_file(TextEditorState* te, const char* path) {
int fd = zenith::open(path);
int fd = montauk::open(path);
if (fd < 0) return;
uint64_t size = zenith::getsize(fd);
uint64_t size = montauk::getsize(fd);
if (size > TE_MAX_CAP) size = TE_MAX_CAP;
if ((int)size >= te->buf_cap) {
int new_cap = (int)size + 1024;
if (new_cap > TE_MAX_CAP) new_cap = TE_MAX_CAP;
te->buffer = (char*)zenith::realloc(te->buffer, new_cap);
te->buffer = (char*)montauk::realloc(te->buffer, new_cap);
te->buf_cap = new_cap;
}
zenith::read(fd, (uint8_t*)te->buffer, 0, size);
zenith::close(fd);
montauk::read(fd, (uint8_t*)te->buffer, 0, size);
montauk::close(fd);
te->buf_len = (int)size;
te->cursor_pos = 0;
@@ -258,7 +258,7 @@ static void te_load_file(TextEditorState* te, const char* path) {
te->scroll_x = 0;
te->modified = false;
zenith::strncpy(te->filepath, path, 255);
montauk::strncpy(te->filepath, path, 255);
// Extract filename from path
int last_slash = -1;
@@ -266,9 +266,9 @@ static void te_load_file(TextEditorState* te, const char* path) {
if (path[i] == '/') last_slash = i;
}
if (last_slash >= 0) {
zenith::strncpy(te->filename, path + last_slash + 1, 63);
montauk::strncpy(te->filename, path + last_slash + 1, 63);
} else {
zenith::strncpy(te->filename, path, 63);
montauk::strncpy(te->filename, path, 63);
}
te_recompute_lines(te);
@@ -278,11 +278,11 @@ static void te_load_file(TextEditorState* te, const char* path) {
static void te_save_file(TextEditorState* te) {
if (te->filepath[0] == '\0') return;
int fd = zenith::fcreate(te->filepath);
int fd = montauk::fcreate(te->filepath);
if (fd < 0) return;
zenith::fwrite(fd, (const uint8_t*)te->buffer, 0, te->buf_len);
zenith::close(fd);
montauk::fwrite(fd, (const uint8_t*)te->buffer, 0, te->buf_len);
montauk::close(fd);
te->modified = false;
}
@@ -502,8 +502,8 @@ static void texteditor_on_mouse(Window* win, MouseEvent& ev) {
te->show_pathbar = !te->show_pathbar;
if (te->show_pathbar) {
// Pre-fill with current filepath
zenith::strncpy(te->pathbar_text, te->filepath, 255);
te->pathbar_len = zenith::slen(te->pathbar_text);
montauk::strncpy(te->pathbar_text, te->filepath, 255);
te->pathbar_len = montauk::slen(te->pathbar_text);
te->pathbar_cursor = te->pathbar_len;
}
return;
@@ -529,7 +529,7 @@ static void texteditor_on_mouse(Window* win, MouseEvent& ev) {
// Update window title
char title[64];
snprintf(title, 64, "%s - Editor", te->filename);
zenith::strncpy(win->title, title, 63);
montauk::strncpy(win->title, title, 63);
te->show_pathbar = false;
}
}
@@ -566,7 +566,7 @@ static void texteditor_on_mouse(Window* win, MouseEvent& ev) {
// Keyboard handling
// ============================================================================
static void texteditor_on_key(Window* win, const Zenith::KeyEvent& key) {
static void texteditor_on_key(Window* win, const Montauk::KeyEvent& key) {
TextEditorState* te = (TextEditorState*)win->app_data;
if (!te || !key.pressed) return;
@@ -577,7 +577,7 @@ static void texteditor_on_key(Window* win, const Zenith::KeyEvent& key) {
te_load_file(te, te->pathbar_text);
char title[64];
snprintf(title, 64, "%s - Editor", te->filename);
zenith::strncpy(win->title, title, 63);
montauk::strncpy(win->title, title, 63);
te->show_pathbar = false;
}
return;
@@ -628,8 +628,8 @@ static void texteditor_on_key(Window* win, const Zenith::KeyEvent& key) {
if (key.ctrl && (key.ascii == 'o' || key.ascii == 'O')) {
te->show_pathbar = !te->show_pathbar;
if (te->show_pathbar) {
zenith::strncpy(te->pathbar_text, te->filepath, 255);
te->pathbar_len = zenith::slen(te->pathbar_text);
montauk::strncpy(te->pathbar_text, te->filepath, 255);
te->pathbar_len = montauk::slen(te->pathbar_text);
te->pathbar_cursor = te->pathbar_len;
}
return;
@@ -678,9 +678,9 @@ static void texteditor_on_key(Window* win, const Zenith::KeyEvent& key) {
static void texteditor_on_close(Window* win) {
TextEditorState* te = (TextEditorState*)win->app_data;
if (te) {
if (te->buffer) zenith::mfree(te->buffer);
if (te->line_offsets) zenith::mfree(te->line_offsets);
zenith::mfree(te);
if (te->buffer) montauk::mfree(te->buffer);
if (te->line_offsets) montauk::mfree(te->line_offsets);
montauk::mfree(te);
win->app_data = nullptr;
}
}
@@ -694,10 +694,10 @@ void open_texteditor(DesktopState* ds) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
TextEditorState* te = (TextEditorState*)zenith::malloc(sizeof(TextEditorState));
zenith::memset(te, 0, sizeof(TextEditorState));
TextEditorState* te = (TextEditorState*)montauk::malloc(sizeof(TextEditorState));
montauk::memset(te, 0, sizeof(TextEditorState));
te->buffer = (char*)zenith::malloc(TE_INIT_CAP);
te->buffer = (char*)montauk::malloc(TE_INIT_CAP);
te->buf_cap = TE_INIT_CAP;
te->buf_len = 0;
te->modified = false;
@@ -731,10 +731,10 @@ void open_texteditor_with_file(DesktopState* ds, const char* path) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
TextEditorState* te = (TextEditorState*)zenith::malloc(sizeof(TextEditorState));
zenith::memset(te, 0, sizeof(TextEditorState));
TextEditorState* te = (TextEditorState*)montauk::malloc(sizeof(TextEditorState));
montauk::memset(te, 0, sizeof(TextEditorState));
te->buffer = (char*)zenith::malloc(TE_INIT_CAP);
te->buffer = (char*)montauk::malloc(TE_INIT_CAP);
te->buf_cap = TE_INIT_CAP;
te->buf_len = 0;
te->modified = false;
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* app_weather.cpp
* ZenithOS Desktop - Weather app launcher
* MontaukOS Desktop - Weather app launcher
* Spawns weather.elf as a standalone Window Server process
* Copyright (c) 2026 Daniel Hammer
*/
@@ -9,5 +9,5 @@
void open_weather(DesktopState* ds) {
(void)ds;
zenith::spawn("0:/os/weather.elf");
montauk::spawn("0:/os/weather.elf");
}
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* app_wiki.cpp
* ZenithOS Desktop - Wikipedia launcher
* MontaukOS Desktop - Wikipedia launcher
* Spawns wikipedia.elf as a standalone Window Server process
* Copyright (c) 2026 Daniel Hammer
*/
@@ -9,5 +9,5 @@
void open_wiki(DesktopState* ds) {
(void)ds;
zenith::spawn("0:/os/wikipedia.elf");
montauk::spawn("0:/os/wikipedia.elf");
}
+4 -4
View File
@@ -6,9 +6,9 @@
#pragma once
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <zenith/heap.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <gui/gui.hpp>
#include <gui/framebuffer.hpp>
#include <gui/font.hpp>
@@ -95,7 +95,7 @@ inline int snprintf(char* buf, int size, const char* fmt, ...) {
// ============================================================================
inline void str_append(char* dst, const char* src, int max) {
int len = zenith::slen(dst);
int len = montauk::slen(dst);
int i = 0;
while (src[i] && len < max - 1) {
dst[len++] = src[i++];
+81 -81
View File
@@ -1,6 +1,6 @@
/*
* main.cpp
* ZenithOS Desktop Environment - window manager, compositor, and run loop
* MontaukOS Desktop Environment - window manager, compositor, and run loop
* Copyright (c) 2026 Daniel Hammer
*/
@@ -32,8 +32,8 @@ void gui::desktop_init(DesktopState* ds) {
ds->prev_buttons = 0;
ds->app_menu_open = false;
zenith::memset(&ds->mouse, 0, sizeof(Zenith::MouseState));
zenith::set_mouse_bounds(ds->screen_w - 1, ds->screen_h - 1);
montauk::memset(&ds->mouse, 0, sizeof(Montauk::MouseState));
montauk::set_mouse_bounds(ds->screen_w - 1, ds->screen_h - 1);
// Load SVG icons — scalable (colorful) for app menu, symbolic for toolbar/panel
Color defColor = colors::ICON_COLOR;
@@ -87,17 +87,17 @@ void gui::desktop_init(DesktopState* ds) {
ds->settings.ui_scale = 1;
// Try to load default wallpaper
wallpaper_load(&ds->settings, "0:/home/troy-olson-MhYIwOiyZpM-unsplash.jpg",
wallpaper_load(&ds->settings, "0:/home/gustav-gullstrand-d6kSvT2xZQo-unsplash.jpg",
ds->screen_w, ds->screen_h);
zenith::win_setscale(1);
montauk::win_setscale(1);
ds->ctx_menu_open = false;
ds->ctx_menu_x = 0;
ds->ctx_menu_y = 0;
ds->net_popup_open = false;
zenith::get_netcfg(&ds->cached_net_cfg);
ds->net_cfg_last_poll = zenith::get_milliseconds();
montauk::get_netcfg(&ds->cached_net_cfg);
ds->net_cfg_last_poll = montauk::get_milliseconds();
ds->net_icon_rect = {0, 0, 0, 0};
}
@@ -107,9 +107,9 @@ int gui::desktop_create_window(DesktopState* ds, const char* title, int x, int y
int idx = ds->window_count;
Window* win = &ds->windows[idx];
zenith::memset(win, 0, sizeof(Window));
montauk::memset(win, 0, sizeof(Window));
zenith::strncpy(win->title, title, MAX_TITLE_LEN);
montauk::strncpy(win->title, title, MAX_TITLE_LEN);
win->frame = {x, y, w, h};
win->state = WIN_NORMAL;
win->z_order = idx;
@@ -124,8 +124,8 @@ int gui::desktop_create_window(DesktopState* ds, const char* title, int x, int y
win->content_w = cr.w;
win->content_h = cr.h;
int buf_size = cr.w * cr.h * 4;
win->content = (uint32_t*)zenith::alloc(buf_size);
zenith::memset(win->content, 0xFF, buf_size);
win->content = (uint32_t*)montauk::alloc(buf_size);
montauk::memset(win->content, 0xFF, buf_size);
win->on_draw = nullptr;
win->on_mouse = nullptr;
@@ -153,17 +153,17 @@ void gui::desktop_close_window(DesktopState* ds, int idx) {
// For external windows, send a close event instead of freeing the buffer
if (win->external) {
Zenith::WinEvent ev;
zenith::memset(&ev, 0, sizeof(ev));
Montauk::WinEvent ev;
montauk::memset(&ev, 0, sizeof(ev));
ev.type = 3; // close
zenith::win_sendevent(win->ext_win_id, &ev);
montauk::win_sendevent(win->ext_win_id, &ev);
}
if (win->on_close) win->on_close(win);
// Free content buffer (skip for external windows — shared memory)
if (win->content && !win->external) {
zenith::free(win->content);
montauk::free(win->content);
win->content = nullptr;
}
@@ -359,7 +359,7 @@ void gui::desktop_draw_panel(DesktopState* ds) {
// Truncate title if too long
char short_title[20];
zenith::strncpy(short_title, win->title, 18);
montauk::strncpy(short_title, win->title, 18);
int tx = indicator_x + pad;
int ty = 4 + (24 - system_font_height()) / 2;
@@ -369,8 +369,8 @@ void gui::desktop_draw_panel(DesktopState* ds) {
}
// Date + Clock (right side)
Zenith::DateTime dt;
zenith::gettime(&dt);
Montauk::DateTime dt;
montauk::gettime(&dt);
char clock_str[12];
if (ds->settings.clock_24h) {
@@ -395,9 +395,9 @@ void gui::desktop_draw_panel(DesktopState* ds) {
draw_text(fb, date_x, clock_y, date_str, colors::PANEL_TEXT);
// Network icon (to the left of the date)
uint64_t now = zenith::get_milliseconds();
uint64_t now = montauk::get_milliseconds();
if (now - ds->net_cfg_last_poll > 5000) {
zenith::get_netcfg(&ds->cached_net_cfg);
montauk::get_netcfg(&ds->cached_net_cfg);
ds->net_cfg_last_poll = now;
}
@@ -574,7 +574,7 @@ static void desktop_draw_net_popup(DesktopState* ds) {
int line_h = system_font_height() + 6;
char line[64];
Zenith::NetCfg& nc = ds->cached_net_cfg;
Montauk::NetCfg& nc = ds->cached_net_cfg;
if (nc.ipAddress != 0) {
char ipbuf[20];
@@ -670,7 +670,7 @@ static void reboot_dialog_on_mouse(Window* win, MouseEvent& ev) {
rs->hover_cancel = cb.contains(lx, ly);
if (ev.left_pressed()) {
if (rs->hover_reboot) zenith::reset();
if (rs->hover_reboot) montauk::reset();
if (rs->hover_cancel) {
for (int i = 0; i < rs->ds->window_count; i++) {
if (rs->ds->windows[i].app_data == rs) {
@@ -682,12 +682,12 @@ static void reboot_dialog_on_mouse(Window* win, MouseEvent& ev) {
}
}
static void reboot_dialog_on_key(Window* win, const Zenith::KeyEvent& key) {
static void reboot_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
RebootDialogState* rs = (RebootDialogState*)win->app_data;
if (!rs || !key.pressed) return;
if (key.ascii == '\n' || key.ascii == '\r') {
zenith::reset();
montauk::reset();
}
if (key.scancode == 0x01) { // Escape
for (int i = 0; i < rs->ds->window_count; i++) {
@@ -701,7 +701,7 @@ static void reboot_dialog_on_key(Window* win, const Zenith::KeyEvent& key) {
static void reboot_dialog_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -713,8 +713,8 @@ void open_reboot_dialog(DesktopState* ds) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
RebootDialogState* rs = (RebootDialogState*)zenith::malloc(sizeof(RebootDialogState));
zenith::memset(rs, 0, sizeof(RebootDialogState));
RebootDialogState* rs = (RebootDialogState*)montauk::malloc(sizeof(RebootDialogState));
montauk::memset(rs, 0, sizeof(RebootDialogState));
rs->ds = ds;
win->app_data = rs;
@@ -782,7 +782,7 @@ static void shutdown_dialog_on_mouse(Window* win, MouseEvent& ev) {
ss->hover_cancel = cb.contains(lx, ly);
if (ev.left_pressed()) {
if (ss->hover_shutdown) zenith::shutdown();
if (ss->hover_shutdown) montauk::shutdown();
if (ss->hover_cancel) {
for (int i = 0; i < ss->ds->window_count; i++) {
if (ss->ds->windows[i].app_data == ss) {
@@ -794,12 +794,12 @@ static void shutdown_dialog_on_mouse(Window* win, MouseEvent& ev) {
}
}
static void shutdown_dialog_on_key(Window* win, const Zenith::KeyEvent& key) {
static void shutdown_dialog_on_key(Window* win, const Montauk::KeyEvent& key) {
ShutdownDialogState* ss = (ShutdownDialogState*)win->app_data;
if (!ss || !key.pressed) return;
if (key.ascii == '\n' || key.ascii == '\r') {
zenith::shutdown();
montauk::shutdown();
}
if (key.scancode == 0x01) { // Escape
for (int i = 0; i < ss->ds->window_count; i++) {
@@ -813,7 +813,7 @@ static void shutdown_dialog_on_key(Window* win, const Zenith::KeyEvent& key) {
static void shutdown_dialog_on_close(Window* win) {
if (win->app_data) {
zenith::mfree(win->app_data);
montauk::mfree(win->app_data);
win->app_data = nullptr;
}
}
@@ -825,8 +825,8 @@ void open_shutdown_dialog(DesktopState* ds) {
if (idx < 0) return;
Window* win = &ds->windows[idx];
ShutdownDialogState* ss = (ShutdownDialogState*)zenith::malloc(sizeof(ShutdownDialogState));
zenith::memset(ss, 0, sizeof(ShutdownDialogState));
ShutdownDialogState* ss = (ShutdownDialogState*)montauk::malloc(sizeof(ShutdownDialogState));
montauk::memset(ss, 0, sizeof(ShutdownDialogState));
ss->ds = ds;
win->app_data = ss;
@@ -1100,20 +1100,20 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
if (!win->external) {
Rect cr = win->content_rect();
if (cr.w != win->content_w || cr.h != win->content_h) {
if (win->content) zenith::free(win->content);
if (win->content) montauk::free(win->content);
win->content_w = cr.w;
win->content_h = cr.h;
win->content = (uint32_t*)zenith::alloc(cr.w * cr.h * 4);
zenith::memset(win->content, 0xFF, cr.w * cr.h * 4);
win->content = (uint32_t*)montauk::alloc(cr.w * cr.h * 4);
montauk::memset(win->content, 0xFF, cr.w * cr.h * 4);
}
} else {
Rect cr = win->content_rect();
Zenith::WinEvent rev;
zenith::memset(&rev, 0, sizeof(rev));
Montauk::WinEvent rev;
montauk::memset(&rev, 0, sizeof(rev));
rev.type = 2;
rev.resize.w = cr.w;
rev.resize.h = cr.h;
zenith::win_sendevent(win->ext_win_id, &rev);
montauk::win_sendevent(win->ext_win_id, &rev);
}
} else if (mx >= ds->screen_w - 1) {
win->saved_frame = win->frame;
@@ -1122,20 +1122,20 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
if (!win->external) {
Rect cr = win->content_rect();
if (cr.w != win->content_w || cr.h != win->content_h) {
if (win->content) zenith::free(win->content);
if (win->content) montauk::free(win->content);
win->content_w = cr.w;
win->content_h = cr.h;
win->content = (uint32_t*)zenith::alloc(cr.w * cr.h * 4);
zenith::memset(win->content, 0xFF, cr.w * cr.h * 4);
win->content = (uint32_t*)montauk::alloc(cr.w * cr.h * 4);
montauk::memset(win->content, 0xFF, cr.w * cr.h * 4);
}
} else {
Rect cr = win->content_rect();
Zenith::WinEvent rev;
zenith::memset(&rev, 0, sizeof(rev));
Montauk::WinEvent rev;
montauk::memset(&rev, 0, sizeof(rev));
rev.type = 2;
rev.resize.w = cr.w;
rev.resize.h = cr.h;
zenith::win_sendevent(win->ext_win_id, &rev);
montauk::win_sendevent(win->ext_win_id, &rev);
}
}
}
@@ -1188,21 +1188,21 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
if (!win->external) {
Rect cr = win->content_rect();
if (cr.w != win->content_w || cr.h != win->content_h) {
if (win->content) zenith::free(win->content);
if (win->content) montauk::free(win->content);
win->content_w = cr.w;
win->content_h = cr.h;
win->content = (uint32_t*)zenith::alloc(cr.w * cr.h * 4);
zenith::memset(win->content, 0xFF, cr.w * cr.h * 4);
win->content = (uint32_t*)montauk::alloc(cr.w * cr.h * 4);
montauk::memset(win->content, 0xFF, cr.w * cr.h * 4);
}
win->dirty = true;
} else {
Rect cr = win->content_rect();
Zenith::WinEvent rev;
zenith::memset(&rev, 0, sizeof(rev));
Montauk::WinEvent rev;
montauk::memset(&rev, 0, sizeof(rev));
rev.type = 2;
rev.resize.w = cr.w;
rev.resize.h = cr.h;
zenith::win_sendevent(win->ext_win_id, &rev);
montauk::win_sendevent(win->ext_win_id, &rev);
}
}
return;
@@ -1355,20 +1355,20 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
if (!win->external) {
Rect cr = win->content_rect();
if (cr.w != win->content_w || cr.h != win->content_h) {
if (win->content) zenith::free(win->content);
if (win->content) montauk::free(win->content);
win->content_w = cr.w;
win->content_h = cr.h;
win->content = (uint32_t*)zenith::alloc(cr.w * cr.h * 4);
zenith::memset(win->content, 0xFF, cr.w * cr.h * 4);
win->content = (uint32_t*)montauk::alloc(cr.w * cr.h * 4);
montauk::memset(win->content, 0xFF, cr.w * cr.h * 4);
}
} else {
Rect cr = win->content_rect();
Zenith::WinEvent rev;
zenith::memset(&rev, 0, sizeof(rev));
Montauk::WinEvent rev;
montauk::memset(&rev, 0, sizeof(rev));
rev.type = 2;
rev.resize.w = cr.w;
rev.resize.h = cr.h;
zenith::win_sendevent(win->ext_win_id, &rev);
montauk::win_sendevent(win->ext_win_id, &rev);
}
desktop_raise_window(ds, i);
return;
@@ -1416,15 +1416,15 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
Window* raised = &ds->windows[new_idx];
if (raised->external) {
// Forward mouse event to external window
Zenith::WinEvent wev;
zenith::memset(&wev, 0, sizeof(wev));
Montauk::WinEvent wev;
montauk::memset(&wev, 0, sizeof(wev));
wev.type = 1; // mouse
wev.mouse.x = mx - cr.x;
wev.mouse.y = my - cr.y;
wev.mouse.scroll = ev.scroll;
wev.mouse.buttons = buttons;
wev.mouse.prev_buttons = prev;
zenith::win_sendevent(raised->ext_win_id, &wev);
montauk::win_sendevent(raised->ext_win_id, &wev);
} else if (raised->on_mouse) {
ev.x = mx;
ev.y = my;
@@ -1450,15 +1450,15 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
Rect cr = win->content_rect();
if (cr.contains(mx, my)) {
if (win->external) {
Zenith::WinEvent wev;
zenith::memset(&wev, 0, sizeof(wev));
Montauk::WinEvent wev;
montauk::memset(&wev, 0, sizeof(wev));
wev.type = 1; // mouse
wev.mouse.x = mx - cr.x;
wev.mouse.y = my - cr.y;
wev.mouse.scroll = ev.scroll;
wev.mouse.buttons = buttons;
wev.mouse.prev_buttons = prev;
zenith::win_sendevent(win->ext_win_id, &wev);
montauk::win_sendevent(win->ext_win_id, &wev);
} else if (win->on_mouse) {
win->on_mouse(win, ev);
}
@@ -1486,7 +1486,7 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
}
}
void gui::desktop_handle_keyboard(DesktopState* ds, const Zenith::KeyEvent& key) {
void gui::desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key) {
// Global shortcuts (only on key press)
if (key.pressed && key.ctrl && key.alt) {
if (key.ascii == 't' || key.ascii == 'T') {
@@ -1524,11 +1524,11 @@ void gui::desktop_handle_keyboard(DesktopState* ds, const Zenith::KeyEvent& key)
Window* win = &ds->windows[ds->focused_window];
if (win->external) {
// Forward key event to external window via syscall
Zenith::WinEvent ev;
zenith::memset(&ev, 0, sizeof(ev));
Montauk::WinEvent ev;
montauk::memset(&ev, 0, sizeof(ev));
ev.type = 0; // key
ev.key = key;
zenith::win_sendevent(win->ext_win_id, &ev);
montauk::win_sendevent(win->ext_win_id, &ev);
} else if (win->on_key) {
win->on_key(win, key);
}
@@ -1540,8 +1540,8 @@ void gui::desktop_handle_keyboard(DesktopState* ds, const Zenith::KeyEvent& key)
// ============================================================================
void desktop_poll_external_windows(DesktopState* ds) {
Zenith::WinInfo extWins[8];
int extCount = zenith::win_enumerate(extWins, 8);
Montauk::WinInfo extWins[8];
int extCount = montauk::win_enumerate(extWins, 8);
// Check for new external windows and map them
for (int e = 0; e < extCount; e++) {
@@ -1559,7 +1559,7 @@ void desktop_poll_external_windows(DesktopState* ds) {
// Re-map if external app resized its buffer
if (extWins[e].width != ds->windows[i].content_w ||
extWins[e].height != ds->windows[i].content_h) {
uint64_t va = zenith::win_map(extId);
uint64_t va = montauk::win_map(extId);
if (va != 0) {
ds->windows[i].content = (uint32_t*)va;
ds->windows[i].content_w = extWins[e].width;
@@ -1573,14 +1573,14 @@ void desktop_poll_external_windows(DesktopState* ds) {
if (!found && ds->window_count < MAX_WINDOWS) {
// Map the pixel buffer into our address space
uint64_t va = zenith::win_map(extId);
uint64_t va = montauk::win_map(extId);
if (va == 0) continue;
int idx = ds->window_count;
Window* win = &ds->windows[idx];
zenith::memset(win, 0, sizeof(Window));
montauk::memset(win, 0, sizeof(Window));
zenith::strncpy(win->title, extWins[e].title, MAX_TITLE_LEN);
montauk::strncpy(win->title, extWins[e].title, MAX_TITLE_LEN);
int w = extWins[e].width;
int h = extWins[e].height;
// Position the window centered-ish
@@ -1643,12 +1643,12 @@ void gui::desktop_run(DesktopState* ds) {
for (;;) {
// Poll mouse state
ds->prev_buttons = ds->mouse.buttons;
zenith::mouse_state(&ds->mouse);
montauk::mouse_state(&ds->mouse);
// Poll keyboard events
while (zenith::is_key_available()) {
Zenith::KeyEvent key;
zenith::getkey(&key);
while (montauk::is_key_available()) {
Montauk::KeyEvent key;
montauk::getkey(&key);
desktop_handle_keyboard(ds, key);
}
@@ -1672,7 +1672,7 @@ void gui::desktop_run(DesktopState* ds) {
ds->fb.flip();
// Target ~60fps
zenith::sleep_ms(16);
montauk::sleep_ms(16);
}
}
@@ -1683,8 +1683,8 @@ void gui::desktop_run(DesktopState* ds) {
static DesktopState* g_desktop;
extern "C" void _start() {
DesktopState* ds = (DesktopState*)zenith::malloc(sizeof(DesktopState));
zenith::memset(ds, 0, sizeof(DesktopState));
DesktopState* ds = (DesktopState*)montauk::malloc(sizeof(DesktopState));
montauk::memset(ds, 0, sizeof(DesktopState));
// Placement-new the Framebuffer since it has a constructor
new (&ds->fb) Framebuffer();
@@ -1694,5 +1694,5 @@ extern "C" void _start() {
desktop_init(ds);
desktop_run(ds);
zenith::exit(0);
montauk::exit(0);
}
+8 -8
View File
@@ -1,13 +1,13 @@
/*
* stb_truetype_impl.cpp
* Single compilation unit for stb_truetype in ZenithOS freestanding environment
* Single compilation unit for stb_truetype in MontaukOS freestanding environment
* Copyright (c) 2026 Daniel Hammer
*/
#include <cstdint>
#include <cstddef>
#include <zenith/heap.h>
#include <zenith/string.h>
#include <montauk/heap.h>
#include <montauk/string.h>
#include <gui/stb_math.h>
// Override all stb_truetype dependencies before including the implementation
@@ -21,13 +21,13 @@
#define STBTT_acos(x) stb_acos(x)
#define STBTT_fabs(x) stb_fabs(x)
#define STBTT_malloc(x,u) ((void)(u), zenith::malloc(x))
#define STBTT_free(x,u) ((void)(u), zenith::mfree(x))
#define STBTT_malloc(x,u) ((void)(u), montauk::malloc(x))
#define STBTT_free(x,u) ((void)(u), montauk::mfree(x))
#define STBTT_memcpy(d,s,n) zenith::memcpy(d,s,n)
#define STBTT_memset(d,v,n) zenith::memset(d,v,n)
#define STBTT_memcpy(d,s,n) montauk::memcpy(d,s,n)
#define STBTT_memset(d,v,n) montauk::memset(d,v,n)
#define STBTT_strlen(x) zenith::slen(x)
#define STBTT_strlen(x) montauk::slen(x)
#define STBTT_assert(x) ((void)(x))
+22 -22
View File
@@ -1,14 +1,14 @@
/*
* wallpaper.hpp
* ZenithOS Desktop - JPEG wallpaper loading, scaling, and directory scanning
* MontaukOS Desktop - JPEG wallpaper loading, scaling, and directory scanning
* Copyright (c) 2026 Daniel Hammer
*/
#pragma once
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <zenith/heap.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <gui/gui.hpp>
#include <gui/desktop.hpp>
@@ -35,41 +35,41 @@ inline bool wallpaper_load(DesktopSettings* s, const char* path,
int screen_w, int screen_h) {
// Free existing wallpaper
if (s->bg_wallpaper) {
zenith::mfree(s->bg_wallpaper);
montauk::mfree(s->bg_wallpaper);
s->bg_wallpaper = nullptr;
s->bg_wallpaper_w = 0;
s->bg_wallpaper_h = 0;
}
// Read file
int fd = zenith::open(path);
int fd = montauk::open(path);
if (fd < 0) return false;
uint64_t size = zenith::getsize(fd);
uint64_t size = montauk::getsize(fd);
if (size == 0 || size > 16 * 1024 * 1024) {
zenith::close(fd);
montauk::close(fd);
return false;
}
uint8_t* filedata = (uint8_t*)zenith::malloc(size);
if (!filedata) { zenith::close(fd); return false; }
uint8_t* filedata = (uint8_t*)montauk::malloc(size);
if (!filedata) { montauk::close(fd); return false; }
int bytes_read = zenith::read(fd, filedata, 0, size);
zenith::close(fd);
if (bytes_read <= 0) { zenith::mfree(filedata); return false; }
int bytes_read = montauk::read(fd, filedata, 0, size);
montauk::close(fd);
if (bytes_read <= 0) { montauk::mfree(filedata); return false; }
// Decode JPEG
int img_w, img_h, channels;
unsigned char* rgb = stbi_load_from_memory(filedata, bytes_read,
&img_w, &img_h, &channels, 3);
zenith::mfree(filedata);
montauk::mfree(filedata);
if (!rgb) return false;
// Scale to cover screen (crop to fill, maintain aspect ratio)
int dst_w = screen_w;
int dst_h = screen_h;
uint32_t* scaled = (uint32_t*)zenith::malloc((uint64_t)dst_w * dst_h * 4);
uint32_t* scaled = (uint32_t*)montauk::malloc((uint64_t)dst_w * dst_h * 4);
if (!scaled) { stbi_image_free(rgb); return false; }
// Compute source crop region for "cover" scaling
@@ -110,7 +110,7 @@ inline bool wallpaper_load(DesktopSettings* s, const char* path,
s->bg_wallpaper = scaled;
s->bg_wallpaper_w = dst_w;
s->bg_wallpaper_h = dst_h;
zenith::strncpy(s->bg_image_path, path, 127);
montauk::strncpy(s->bg_image_path, path, 127);
s->bg_image = true;
s->bg_gradient = false;
@@ -119,7 +119,7 @@ inline bool wallpaper_load(DesktopSettings* s, const char* path,
inline void wallpaper_free(DesktopSettings* s) {
if (s->bg_wallpaper) {
zenith::mfree(s->bg_wallpaper);
montauk::mfree(s->bg_wallpaper);
s->bg_wallpaper = nullptr;
s->bg_wallpaper_w = 0;
s->bg_wallpaper_h = 0;
@@ -143,7 +143,7 @@ inline void wallpaper_scan_dir(const char* dir_path, WallpaperFileList* list) {
list->count = 0;
const char* raw_names[64];
int total = zenith::readdir(dir_path, raw_names, 64);
int total = montauk::readdir(dir_path, raw_names, 64);
if (total <= 0) return;
// Compute prefix to strip (readdir returns full paths from VFS root)
@@ -157,8 +157,8 @@ inline void wallpaper_scan_dir(const char* dir_path, WallpaperFileList* list) {
char prefix[256] = {0};
int prefix_len = 0;
if (after_drive[0] != '\0') {
zenith::strcpy(prefix, after_drive);
prefix_len = zenith::slen(prefix);
montauk::strcpy(prefix, after_drive);
prefix_len = montauk::slen(prefix);
if (prefix_len > 0 && prefix[prefix_len - 1] != '/') {
prefix[prefix_len++] = '/';
prefix[prefix_len] = '\0';
@@ -181,7 +181,7 @@ inline void wallpaper_scan_dir(const char* dir_path, WallpaperFileList* list) {
if (match) name += prefix_len;
}
int nlen = zenith::slen(name);
int nlen = montauk::slen(name);
// Skip directories
if (nlen > 0 && name[nlen - 1] == '/') continue;
@@ -206,7 +206,7 @@ inline void wallpaper_scan_dir(const char* dir_path, WallpaperFileList* list) {
}
if (is_jpeg) {
zenith::strncpy(list->names[list->count], name, 63);
montauk::strncpy(list->names[list->count], name, 63);
list->count++;
}
}
+64 -64
View File
@@ -1,15 +1,15 @@
/*
* main.cpp
* DHCP client for ZenithOS
* DHCP client for MontaukOS
* Obtains network configuration automatically via DHCP (RFC 2131)
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
using zenith::memcpy;
using zenith::memset;
using montauk::memcpy;
using montauk::memset;
// ---- Minimal snprintf (no libc available) ----
@@ -332,62 +332,62 @@ static constexpr uint32_t BROADCAST_IP = 0xFFFFFFFF;
extern "C" void _start() {
char msg[256];
zenith::print("ZenithOS DHCP Client\n");
montauk::print("MontaukOS DHCP Client\n");
// 1. Get MAC address
Zenith::NetCfg origCfg;
zenith::get_netcfg(&origCfg);
Montauk::NetCfg origCfg;
montauk::get_netcfg(&origCfg);
char macStr[32];
format_mac(macStr, sizeof(macStr), origCfg.macAddress);
snprintf(msg, sizeof(msg), "MAC address: %s\n", macStr);
zenith::print(msg);
montauk::print(msg);
// 2. Set IP to 0.0.0.0 to allow broadcast send/receive
Zenith::NetCfg zeroCfg;
Montauk::NetCfg zeroCfg;
zeroCfg.ipAddress = 0;
zeroCfg.subnetMask = 0;
zeroCfg.gateway = 0;
zenith::set_netcfg(&zeroCfg);
montauk::set_netcfg(&zeroCfg);
// 3. Create UDP socket and bind to port 68
int fd = zenith::socket(Zenith::SOCK_UDP);
int fd = montauk::socket(Montauk::SOCK_UDP);
if (fd < 0) {
zenith::print("Error: failed to create UDP socket\n");
zenith::set_netcfg(&origCfg);
zenith::exit(1);
montauk::print("Error: failed to create UDP socket\n");
montauk::set_netcfg(&origCfg);
montauk::exit(1);
}
if (zenith::bind(fd, DHCP_CLIENT_PORT) < 0) {
zenith::print("Error: failed to bind to port 68\n");
zenith::closesocket(fd);
zenith::set_netcfg(&origCfg);
zenith::exit(1);
if (montauk::bind(fd, DHCP_CLIENT_PORT) < 0) {
montauk::print("Error: failed to bind to port 68\n");
montauk::closesocket(fd);
montauk::set_netcfg(&origCfg);
montauk::exit(1);
}
// 4. Send DISCOVER
DhcpPacket pkt;
int pktLen = build_discover(&pkt, origCfg.macAddress);
zenith::print("Sending DHCPDISCOVER...\n");
if (zenith::sendto(fd, (const void*)&pkt, pktLen, BROADCAST_IP, DHCP_SERVER_PORT) < 0) {
zenith::print("Error: failed to send DISCOVER\n");
zenith::closesocket(fd);
zenith::set_netcfg(&origCfg);
zenith::exit(1);
montauk::print("Sending DHCPDISCOVER...\n");
if (montauk::sendto(fd, (const void*)&pkt, pktLen, BROADCAST_IP, DHCP_SERVER_PORT) < 0) {
montauk::print("Error: failed to send DISCOVER\n");
montauk::closesocket(fd);
montauk::set_netcfg(&origCfg);
montauk::exit(1);
}
// 5. Wait for OFFER
DhcpPacket resp;
DhcpOffer offer;
uint64_t startMs = zenith::get_milliseconds();
uint64_t startMs = montauk::get_milliseconds();
bool gotOffer = false;
zenith::print("Waiting for DHCPOFFER...\n");
while (zenith::get_milliseconds() - startMs < 10000) {
montauk::print("Waiting for DHCPOFFER...\n");
while (montauk::get_milliseconds() - startMs < 10000) {
uint32_t srcIp;
uint16_t srcPort;
int r = zenith::recvfrom(fd, (void*)&resp, sizeof(resp), &srcIp, &srcPort);
int r = montauk::recvfrom(fd, (void*)&resp, sizeof(resp), &srcIp, &srcPort);
if (r > 0) {
if (resp.op == BOOTREPLY && resp.xid == g_xid) {
parse_options(&resp, &offer);
@@ -397,41 +397,41 @@ extern "C" void _start() {
}
}
}
zenith::yield();
montauk::yield();
}
if (!gotOffer) {
zenith::print("Error: no DHCPOFFER received (timeout)\n");
zenith::closesocket(fd);
zenith::set_netcfg(&origCfg);
zenith::exit(1);
montauk::print("Error: no DHCPOFFER received (timeout)\n");
montauk::closesocket(fd);
montauk::set_netcfg(&origCfg);
montauk::exit(1);
}
char ipStr[32];
format_ip(ipStr, sizeof(ipStr), offer.offeredIp);
snprintf(msg, sizeof(msg), "Received OFFER: %s\n", ipStr);
zenith::print(msg);
montauk::print(msg);
// 6. Send REQUEST
pktLen = build_request(&pkt, origCfg.macAddress, offer.offeredIp, offer.serverId);
zenith::print("Sending DHCPREQUEST...\n");
if (zenith::sendto(fd, (const void*)&pkt, pktLen, BROADCAST_IP, DHCP_SERVER_PORT) < 0) {
zenith::print("Error: failed to send REQUEST\n");
zenith::closesocket(fd);
zenith::set_netcfg(&origCfg);
zenith::exit(1);
montauk::print("Sending DHCPREQUEST...\n");
if (montauk::sendto(fd, (const void*)&pkt, pktLen, BROADCAST_IP, DHCP_SERVER_PORT) < 0) {
montauk::print("Error: failed to send REQUEST\n");
montauk::closesocket(fd);
montauk::set_netcfg(&origCfg);
montauk::exit(1);
}
// 7. Wait for ACK
bool gotAck = false;
startMs = zenith::get_milliseconds();
startMs = montauk::get_milliseconds();
zenith::print("Waiting for DHCPACK...\n");
while (zenith::get_milliseconds() - startMs < 10000) {
montauk::print("Waiting for DHCPACK...\n");
while (montauk::get_milliseconds() - startMs < 10000) {
uint32_t srcIp;
uint16_t srcPort;
int r = zenith::recvfrom(fd, (void*)&resp, sizeof(resp), &srcIp, &srcPort);
int r = montauk::recvfrom(fd, (void*)&resp, sizeof(resp), &srcIp, &srcPort);
if (r > 0) {
if (resp.op == BOOTREPLY && resp.xid == g_xid) {
parse_options(&resp, &offer);
@@ -440,57 +440,57 @@ extern "C" void _start() {
break;
}
if (offer.valid && offer.msgType == DHCPNAK) {
zenith::print("Error: received DHCPNAK from server\n");
zenith::closesocket(fd);
zenith::set_netcfg(&origCfg);
zenith::exit(1);
montauk::print("Error: received DHCPNAK from server\n");
montauk::closesocket(fd);
montauk::set_netcfg(&origCfg);
montauk::exit(1);
}
}
}
zenith::yield();
montauk::yield();
}
zenith::closesocket(fd);
montauk::closesocket(fd);
if (!gotAck) {
zenith::print("Error: no DHCPACK received (timeout)\n");
zenith::set_netcfg(&origCfg);
zenith::exit(1);
montauk::print("Error: no DHCPACK received (timeout)\n");
montauk::set_netcfg(&origCfg);
montauk::exit(1);
}
// 8. Apply configuration
Zenith::NetCfg newCfg;
Montauk::NetCfg newCfg;
newCfg.ipAddress = offer.offeredIp;
newCfg.subnetMask = offer.subnetMask;
newCfg.gateway = offer.router;
newCfg.dnsServer = offer.dns;
zenith::set_netcfg(&newCfg);
montauk::set_netcfg(&newCfg);
// 9. Print results
zenith::print("\nDHCP configuration applied:\n");
montauk::print("\nDHCP configuration applied:\n");
format_ip(ipStr, sizeof(ipStr), offer.offeredIp);
snprintf(msg, sizeof(msg), " IP Address: %s\n", ipStr);
zenith::print(msg);
montauk::print(msg);
format_ip(ipStr, sizeof(ipStr), offer.subnetMask);
snprintf(msg, sizeof(msg), " Subnet Mask: %s\n", ipStr);
zenith::print(msg);
montauk::print(msg);
format_ip(ipStr, sizeof(ipStr), offer.router);
snprintf(msg, sizeof(msg), " Gateway: %s\n", ipStr);
zenith::print(msg);
montauk::print(msg);
if (offer.dns != 0) {
format_ip(ipStr, sizeof(ipStr), offer.dns);
snprintf(msg, sizeof(msg), " DNS Server: %s\n", ipStr);
zenith::print(msg);
montauk::print(msg);
}
if (offer.leaseTime != 0) {
snprintf(msg, sizeof(msg), " Lease Time: %u seconds\n", offer.leaseTime);
zenith::print(msg);
montauk::print(msg);
}
zenith::exit(0);
montauk::exit(0);
}
+2 -2
View File
@@ -1,4 +1,4 @@
# Makefile for DOOM (doomgeneric) on ZenithOS
# Makefile for DOOM (doomgeneric) on MontaukOS
# Copyright (c) 2025 Daniel Hammer
MAKEFLAGS += -rR
@@ -153,7 +153,7 @@ DOOM_SRCS := \
z_zone.c
# Local source files
LOCAL_SRCS := doomgeneric_zenith.c libc.c
LOCAL_SRCS := doomgeneric_montauk.c libc.c
# ---- Object files ----
@@ -1,6 +1,6 @@
/*
* doomgeneric_zenith.c
* DOOM platform implementation for ZenithOS (standalone window server client)
* doomgeneric_montauk.c
* DOOM platform implementation for MontaukOS (standalone window server client)
* Copyright (c) 2025 Daniel Hammer
*/
@@ -66,7 +66,7 @@ static inline long _zos_syscall4(long nr, long a1, long a2, long a3, long a4) {
#define SYS_WINPRESENT 56
#define SYS_WINPOLL 57
/* Window server structs (must match Zenith::WinCreateResult and Zenith::WinEvent) */
/* Window server structs (must match Montauk::WinCreateResult and Montauk::WinEvent) */
struct WinCreateResult {
int id; /* -1 on failure */
unsigned _pad;
+1 -1
View File
@@ -1,6 +1,6 @@
/*
* libc.c
* Minimal C standard library for ZenithOS userspace (DOOM port)
* Minimal C standard library for MontaukOS userspace (DOOM port)
* Copyright (c) 2025 Daniel Hammer
*/
+39 -39
View File
@@ -1,16 +1,16 @@
/*
* main.cpp
* edit - Text editor for ZenithOS
* edit - Text editor for MontaukOS
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/heap.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/heap.h>
#include <montauk/string.h>
using zenith::slen;
using zenith::memcpy;
using zenith::memmove;
using montauk::slen;
using montauk::memcpy;
using montauk::memmove;
// ---- Integer to string ----
@@ -30,8 +30,8 @@ static int itoa(int val, char* buf) {
// ---- Terminal output helpers ----
static void print(const char* s) { zenith::print(s); }
static void putch(char c) { zenith::putchar(c); }
static void print(const char* s) { montauk::print(s); }
static void putch(char c) { montauk::putchar(c); }
static void print_int(int v) {
char buf[12];
@@ -105,7 +105,7 @@ static uint64_t statusMsgTime = 0;
static void line_init(Line* ln) {
ln->cap = INITIAL_LINE_CAP;
ln->data = (char*)zenith::malloc(ln->cap);
ln->data = (char*)montauk::malloc(ln->cap);
ln->len = 0;
ln->data[0] = '\0';
}
@@ -114,7 +114,7 @@ static void line_ensure(Line* ln, int needed) {
if (needed + 1 <= ln->cap) return;
int newCap = ln->cap;
while (newCap < needed + 1) newCap *= 2;
ln->data = (char*)zenith::realloc(ln->data, newCap);
ln->data = (char*)montauk::realloc(ln->data, newCap);
ln->cap = newCap;
}
@@ -165,7 +165,7 @@ static void delete_line(int at) {
lines[at].data[0] = '\0';
return;
}
zenith::mfree(lines[at].data);
montauk::mfree(lines[at].data);
for (int i = at; i < numLines - 1; i++) {
lines[i] = lines[i + 1];
}
@@ -188,7 +188,7 @@ static void set_status(const char* msg) {
int i = 0;
while (msg[i] && i < 126) { statusMsg[i] = msg[i]; i++; }
statusMsg[i] = '\0';
statusMsgTime = zenith::get_milliseconds();
statusMsgTime = montauk::get_milliseconds();
}
// Build VFS path from filename
@@ -210,7 +210,7 @@ static void load_file(const char* fname) {
char path[256];
build_path(fname, path, sizeof(path));
int handle = zenith::open(path);
int handle = montauk::open(path);
if (handle < 0) {
// New file
numLines = 1;
@@ -219,21 +219,21 @@ static void load_file(const char* fname) {
return;
}
uint64_t size = zenith::getsize(handle);
uint64_t size = montauk::getsize(handle);
// Read entire file into a temp buffer
uint8_t* buf = nullptr;
if (size > 0) {
buf = (uint8_t*)zenith::malloc(size + 1);
buf = (uint8_t*)montauk::malloc(size + 1);
uint64_t off = 0;
while (off < size) {
int r = zenith::read(handle, buf + off, off, size - off);
int r = montauk::read(handle, buf + off, off, size - off);
if (r <= 0) break;
off += r;
}
buf[size] = '\0';
}
zenith::close(handle);
montauk::close(handle);
// Parse into lines
numLines = 0;
@@ -253,7 +253,7 @@ static void load_file(const char* fname) {
}
}
if (buf) zenith::mfree(buf);
if (buf) montauk::mfree(buf);
if (numLines == 0) {
numLines = 1;
@@ -280,10 +280,10 @@ static bool save_file() {
}
// Try to open existing file first
int handle = zenith::open(path);
int handle = montauk::open(path);
if (handle < 0) {
// Create new file
handle = zenith::fcreate(path);
handle = montauk::fcreate(path);
if (handle < 0) {
set_status("Error: could not create file");
return false;
@@ -291,7 +291,7 @@ static bool save_file() {
}
// Build content buffer and write
uint8_t* buf = (uint8_t*)zenith::malloc(totalSize + 1);
uint8_t* buf = (uint8_t*)montauk::malloc(totalSize + 1);
uint64_t off = 0;
for (int i = 0; i < numLines; i++) {
if (lines[i].len > 0) {
@@ -303,9 +303,9 @@ static bool save_file() {
}
}
int result = zenith::fwrite(handle, buf, 0, totalSize);
zenith::close(handle);
zenith::mfree(buf);
int result = montauk::fwrite(handle, buf, 0, totalSize);
montauk::close(handle);
montauk::mfree(buf);
if (result < 0) {
set_status("Error: write failed");
@@ -332,13 +332,13 @@ static int prompt_input(const char* promptStr, char* out, int outMax) {
out[0] = '\0';
while (true) {
if (!zenith::is_key_available()) {
zenith::yield();
if (!montauk::is_key_available()) {
montauk::yield();
continue;
}
Zenith::KeyEvent ev;
zenith::getkey(&ev);
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (!ev.pressed) continue;
if (ev.ascii == '\033' || (ev.ctrl && ev.ascii == 'q')) {
@@ -416,7 +416,7 @@ static void draw_hint_bar() {
clear_line();
// Show status message if recent (within 3 seconds)
uint64_t now = zenith::get_milliseconds();
uint64_t now = montauk::get_milliseconds();
if (statusMsg[0] && (now - statusMsgTime) < 3000) {
print(" ");
print(statusMsg);
@@ -647,7 +647,7 @@ static constexpr uint8_t SC_DELETE = 0x53;
// ---- Input handling ----
static void handle_key(const Zenith::KeyEvent& ev) {
static void handle_key(const Montauk::KeyEvent& ev) {
if (!ev.pressed) return;
// Ctrl key combinations
@@ -781,15 +781,15 @@ static void handle_key(const Zenith::KeyEvent& ev) {
extern "C" void _start() {
// Allocate line buffer
lines = (Line*)zenith::malloc(sizeof(Line) * MAX_LINES);
lines = (Line*)montauk::malloc(sizeof(Line) * MAX_LINES);
// Get terminal size
zenith::termsize(&screenCols, &screenRows);
montauk::termsize(&screenCols, &screenRows);
editorRows = screenRows - 2;
// Parse arguments
char args[256];
int argLen = zenith::getargs(args, sizeof(args));
int argLen = montauk::getargs(args, sizeof(args));
if (argLen > 0 && args[0] != '\0') {
// Copy filename
@@ -814,12 +814,12 @@ extern "C" void _start() {
render();
// Wait for input
while (!zenith::is_key_available()) {
zenith::yield();
while (!montauk::is_key_available()) {
montauk::yield();
}
Zenith::KeyEvent ev;
zenith::getkey(&ev);
Montauk::KeyEvent ev;
montauk::getkey(&ev);
handle_key(ev);
}
@@ -828,5 +828,5 @@ extern "C" void _start() {
show_cursor();
reset_attrs();
zenith::exit(0);
montauk::exit(0);
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Makefile for fetch (HTTP/HTTPS client) on ZenithOS
# Makefile for fetch (HTTP/HTTPS client) on MontaukOS
# Copyright (c) 2025-2026 Daniel Hammer
MAKEFLAGS += -rR
+76 -76
View File
@@ -1,13 +1,13 @@
/*
* main.cpp
* HTTP/HTTPS client for ZenithOS (TLS 1.2 via BearSSL)
* HTTP/HTTPS client for MontaukOS (TLS 1.2 via BearSSL)
* Usage: fetch [-v] <url>
* fetch [-v] <host> <port> [path] (legacy mode, plain HTTP)
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <tls/tls.hpp>
extern "C" {
@@ -16,7 +16,7 @@ extern "C" {
#include <stdio.h>
}
using zenith::skip_spaces;
using montauk::skip_spaces;
// ---- IP/port parsing ----
@@ -159,9 +159,9 @@ static void parse_status_text(const char* buf, int len, char* out, int outMax) {
// ---- Keyboard abort check for TLS ----
static bool check_keyboard_abort() {
if (zenith::is_key_available()) {
Zenith::KeyEvent ev;
zenith::getkey(&ev);
if (montauk::is_key_available()) {
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (ev.pressed && ev.ctrl && ev.ascii == 'q') return true;
}
return false;
@@ -173,33 +173,33 @@ static int plain_http_exchange(int fd, const char* request, int reqLen,
char* respBuf, int respMax) {
// Send request
int sent = 0;
uint64_t deadline = zenith::get_milliseconds() + 15000;
uint64_t deadline = montauk::get_milliseconds() + 15000;
while (sent < reqLen) {
int r = zenith::send(fd, request + sent, reqLen - sent);
if (r > 0) { sent += r; deadline = zenith::get_milliseconds() + 15000; }
int r = montauk::send(fd, request + sent, reqLen - sent);
if (r > 0) { sent += r; deadline = montauk::get_milliseconds() + 15000; }
else if (r < 0) return -1;
else {
if (zenith::get_milliseconds() >= deadline) return -1;
zenith::sleep_ms(1);
if (montauk::get_milliseconds() >= deadline) return -1;
montauk::sleep_ms(1);
}
}
// Receive response
int respLen = 0;
deadline = zenith::get_milliseconds() + 15000;
deadline = montauk::get_milliseconds() + 15000;
while (respLen < respMax - 1) {
if (zenith::is_key_available()) {
Zenith::KeyEvent ev;
zenith::getkey(&ev);
if (montauk::is_key_available()) {
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (ev.pressed && ev.ctrl && ev.ascii == 'q') return -2; // aborted
}
int r = zenith::recv(fd, respBuf + respLen, respMax - 1 - respLen);
if (r > 0) { respLen += r; deadline = zenith::get_milliseconds() + 15000; }
int r = montauk::recv(fd, respBuf + respLen, respMax - 1 - respLen);
if (r > 0) { respLen += r; deadline = montauk::get_milliseconds() + 15000; }
else if (r < 0) break;
else {
if (zenith::get_milliseconds() >= deadline) break;
zenith::sleep_ms(1);
if (montauk::get_milliseconds() >= deadline) break;
montauk::sleep_ms(1);
}
}
return respLen;
@@ -209,13 +209,13 @@ static int plain_http_exchange(int fd, const char* request, int reqLen,
static void print_response(const char* respBuf, int respLen, bool verbose) {
if (respLen <= 0) {
zenith::print("Error: empty response\n");
montauk::print("Error: empty response\n");
return;
}
int headerEnd = find_header_end(respBuf, respLen);
if (headerEnd < 0) {
zenith::print("Warning: malformed response (no header boundary)\n\n");
montauk::print("Warning: malformed response (no header boundary)\n\n");
// Print raw
char chunk[512];
int printed = 0;
@@ -224,10 +224,10 @@ static void print_response(const char* respBuf, int respLen, bool verbose) {
if (n > 511) n = 511;
memcpy(chunk, respBuf + printed, n);
chunk[n] = '\0';
zenith::print(chunk);
montauk::print(chunk);
printed += n;
}
zenith::putchar('\n');
montauk::putchar('\n');
return;
}
@@ -239,7 +239,7 @@ static void print_response(const char* respBuf, int respLen, bool verbose) {
if (verbose) {
char msg[256];
snprintf(msg, sizeof(msg), "HTTP %d %s (%d bytes)\n\n", statusCode, statusText, bodyLen);
zenith::print(msg);
montauk::print(msg);
}
if (bodyLen > 0) {
@@ -251,10 +251,10 @@ static void print_response(const char* respBuf, int respLen, bool verbose) {
if (n > 511) n = 511;
memcpy(chunk, body + printed, n);
chunk[n] = '\0';
zenith::print(chunk);
montauk::print(chunk);
printed += n;
}
zenith::putchar('\n');
montauk::putchar('\n');
}
}
@@ -262,21 +262,21 @@ static void print_response(const char* respBuf, int respLen, bool verbose) {
extern "C" void _start() {
char argbuf[1024];
zenith::getargs(argbuf, sizeof(argbuf));
montauk::getargs(argbuf, sizeof(argbuf));
const char* arg = skip_spaces(argbuf);
if (*arg == '\0') {
zenith::print("Usage: fetch [-v] <url>\n");
zenith::print(" fetch [-v] <host> <port> [path]\n");
zenith::print("\n");
zenith::print(" -v Verbose output (show connection info and headers)\n");
zenith::print("\n");
zenith::print("Examples:\n");
zenith::print(" fetch https://icanhazip.com\n");
zenith::print(" fetch http://example.com/index.html\n");
zenith::print(" fetch -v https://example.com\n");
zenith::print(" fetch 10.0.68.1 80 /\n");
zenith::exit(0);
montauk::print("Usage: fetch [-v] <url>\n");
montauk::print(" fetch [-v] <host> <port> [path]\n");
montauk::print("\n");
montauk::print(" -v Verbose output (show connection info and headers)\n");
montauk::print("\n");
montauk::print("Examples:\n");
montauk::print(" fetch https://icanhazip.com\n");
montauk::print(" fetch http://example.com/index.html\n");
montauk::print(" fetch -v https://example.com\n");
montauk::print(" fetch 10.0.68.1 80 /\n");
montauk::exit(0);
}
// Check for -v flag
@@ -297,8 +297,8 @@ extern "C" void _start() {
if (urlMode) {
ParsedUrl url = parse_url(arg);
if (!url.valid) {
zenith::print("Error: invalid URL\n");
zenith::exit(1);
montauk::print("Error: invalid URL\n");
montauk::exit(1);
}
strcpy(hostStr, url.host);
strcpy(path, url.path);
@@ -318,10 +318,10 @@ extern "C" void _start() {
arg = skip_spaces(arg + i);
if (!parse_uint16(portStr, &port)) {
zenith::print("Invalid port: ");
zenith::print(portStr);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Invalid port: ");
montauk::print(portStr);
montauk::putchar('\n');
montauk::exit(1);
}
if (*arg) {
@@ -336,12 +336,12 @@ extern "C" void _start() {
// Resolve host to IP
uint32_t serverIp;
if (!parse_ip(hostStr, &serverIp)) {
serverIp = zenith::resolve(hostStr);
serverIp = montauk::resolve(hostStr);
if (serverIp == 0) {
zenith::print("Error: could not resolve ");
zenith::print(hostStr);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Error: could not resolve ");
montauk::print(hostStr);
montauk::putchar('\n');
montauk::exit(1);
}
}
@@ -352,7 +352,7 @@ extern "C" void _start() {
char msg[256];
snprintf(msg, sizeof(msg), "Connecting to %s:%d (%s)...\n",
hostStr, (int)port, useHttps ? "HTTPS" : "HTTP");
zenith::print(msg);
montauk::print(msg);
}
// Build HTTP request
@@ -360,7 +360,7 @@ extern "C" void _start() {
int reqLen = snprintf(request, sizeof(request),
"GET %s HTTP/1.0\r\n"
"Host: %s\r\n"
"User-Agent: ZenithOS/1.0\r\n"
"User-Agent: MontaukOS/1.0\r\n"
"Connection: close\r\n"
"\r\n",
path, hostStr);
@@ -368,15 +368,15 @@ extern "C" void _start() {
if (verbose) {
char msg[128];
snprintf(msg, sizeof(msg), "GET %s\n", path);
zenith::print(msg);
montauk::print(msg);
}
// Allocate response buffer on heap (stack is only 16 KB)
static constexpr int RESP_MAX = 65536;
char* respBuf = (char*)malloc(RESP_MAX);
if (!respBuf) {
zenith::print("Error: out of memory\n");
zenith::exit(1);
montauk::print("Error: out of memory\n");
montauk::exit(1);
}
int respLen;
@@ -387,26 +387,26 @@ extern "C" void _start() {
if (verbose) {
char msg[64];
snprintf(msg, sizeof(msg), "Loaded %u trust anchors\n", (unsigned)tas.count);
zenith::print(msg);
montauk::print(msg);
}
if (tas.count == 0) {
zenith::print("Error: no trust anchors loaded\n");
montauk::print("Error: no trust anchors loaded\n");
free(respBuf);
zenith::exit(1);
montauk::exit(1);
}
if (verbose) {
uint32_t days, secs;
tls::get_bearssl_time(&days, &secs);
Zenith::DateTime dt;
zenith::gettime(&dt);
Montauk::DateTime dt;
montauk::gettime(&dt);
char tmsg[128];
snprintf(tmsg, sizeof(tmsg), "System time: %u-%02u-%02u %02u:%02u:%02u (days=%u secs=%u)\n",
(unsigned)dt.Year, (unsigned)dt.Month, (unsigned)dt.Day,
(unsigned)dt.Hour, (unsigned)dt.Minute, (unsigned)dt.Second,
(unsigned)days, (unsigned)secs);
zenith::print(tmsg);
zenith::print("TLS handshake...\n");
montauk::print(tmsg);
montauk::print("TLS handshake...\n");
}
respLen = tls::https_fetch(hostStr, serverIp, port,
@@ -414,38 +414,38 @@ extern "C" void _start() {
respBuf, RESP_MAX, check_keyboard_abort);
if (verbose && respLen > 0) {
zenith::print("TLS connection established\n");
montauk::print("TLS connection established\n");
}
} else {
// ---- Plain HTTP ----
int fd = zenith::socket(Zenith::SOCK_TCP);
int fd = montauk::socket(Montauk::SOCK_TCP);
if (fd < 0) {
zenith::print("Error: failed to create socket\n");
zenith::exit(1);
montauk::print("Error: failed to create socket\n");
montauk::exit(1);
}
if (zenith::connect(fd, serverIp, port) < 0) {
zenith::print("Error: connection failed\n");
zenith::closesocket(fd);
zenith::exit(1);
if (montauk::connect(fd, serverIp, port) < 0) {
montauk::print("Error: connection failed\n");
montauk::closesocket(fd);
montauk::exit(1);
}
respLen = plain_http_exchange(fd, request, reqLen, respBuf, RESP_MAX);
zenith::closesocket(fd);
montauk::closesocket(fd);
if (respLen == -2) {
zenith::print("\nAborted.\n");
zenith::exit(0);
montauk::print("\nAborted.\n");
montauk::exit(0);
}
}
if (respLen <= 0) {
zenith::print("Error: no response received\n");
zenith::exit(1);
montauk::print("Error: no response received\n");
montauk::exit(1);
}
respBuf[respLen] = '\0';
print_response(respBuf, respLen, verbose);
zenith::exit(0);
montauk::exit(0);
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Makefile for fontpreview (standalone TTF font previewer) on ZenithOS
# Makefile for fontpreview (standalone TTF font previewer) on MontaukOS
# Copyright (c) 2026 Daniel Hammer
MAKEFLAGS += -rR
+30 -30
View File
@@ -1,13 +1,13 @@
/*
* main.cpp
* ZenithOS Font Preview app
* MontaukOS Font Preview app
* Displays TTF font samples at multiple sizes with vertical scrolling
* Copyright (c) 2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <zenith/heap.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <gui/gui.hpp>
#include <gui/truetype.hpp>
@@ -115,7 +115,7 @@ static void int_to_str(char* buf, int val) {
}
static void str_append(char* dst, const char* src, int maxlen) {
int len = zenith::slen(dst);
int len = montauk::slen(dst);
int i = 0;
while (src[i] && len + i < maxlen - 1) {
dst[len + i] = src[i];
@@ -161,7 +161,7 @@ static void prerrender_glyphs() {
g->yoff = y0;
if (g->width > 0 && g->height > 0) {
g->bitmap = (uint8_t*)zenith::malloc(g->width * g->height);
g->bitmap = (uint8_t*)montauk::malloc(g->width * g->height);
if (g->bitmap) {
stbtt_MakeCodepointBitmap(&g_preview_info, g->bitmap,
g->width, g->height, g->width, scale, scale, cp);
@@ -334,15 +334,15 @@ static void clamp_scroll() {
extern "C" void _start() {
char filepath[512] = {};
int arglen = zenith::getargs(filepath, sizeof(filepath));
if (arglen <= 0) zenith::strcpy(filepath, "");
int arglen = montauk::getargs(filepath, sizeof(filepath));
if (arglen <= 0) montauk::strcpy(filepath, "");
// Load UI font for labels
auto load_font = [](const char* path) -> TrueTypeFont* {
TrueTypeFont* f = (TrueTypeFont*)zenith::malloc(sizeof(TrueTypeFont));
TrueTypeFont* f = (TrueTypeFont*)montauk::malloc(sizeof(TrueTypeFont));
if (!f) return nullptr;
zenith::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { zenith::mfree(f); return nullptr; }
montauk::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { montauk::mfree(f); return nullptr; }
return f;
};
g_ui_font = load_font("0:/fonts/Roboto-Medium.ttf");
@@ -351,25 +351,25 @@ extern "C" void _start() {
char title[64] = "Font Preview";
if (filepath[0]) {
const char* name = basename(filepath);
if (name[0]) zenith::strncpy(title, name, 63);
if (name[0]) montauk::strncpy(title, name, 63);
}
// Load preview font via stbtt
if (filepath[0]) {
int fd = zenith::open(filepath);
int fd = montauk::open(filepath);
if (fd >= 0) {
uint64_t size = zenith::getsize(fd);
uint64_t size = montauk::getsize(fd);
if (size > 0 && size <= 1024 * 1024) {
g_preview_data = (uint8_t*)zenith::malloc(size);
g_preview_data = (uint8_t*)montauk::malloc(size);
if (g_preview_data) {
zenith::read(fd, g_preview_data, 0, size);
montauk::read(fd, g_preview_data, 0, size);
if (stbtt_InitFont(&g_preview_info, g_preview_data,
stbtt_GetFontOffsetForIndex(g_preview_data, 0))) {
g_load_ok = true;
}
}
}
zenith::close(fd);
montauk::close(fd);
}
}
@@ -379,24 +379,24 @@ extern "C" void _start() {
g_content_h = calc_content_height();
// Create window
Zenith::WinCreateResult wres;
if (zenith::win_create(title, INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
zenith::exit(1);
Montauk::WinCreateResult wres;
if (montauk::win_create(title, INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
montauk::exit(1);
int win_id = wres.id;
uint32_t* pixels = (uint32_t*)(uintptr_t)wres.pixelVa;
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
while (true) {
Zenith::WinEvent ev;
int r = zenith::win_poll(win_id, &ev);
Montauk::WinEvent ev;
int r = montauk::win_poll(win_id, &ev);
if (r < 0) break;
if (r == 0) {
zenith::sleep_ms(16);
montauk::sleep_ms(16);
continue;
}
@@ -405,10 +405,10 @@ extern "C" void _start() {
if (ev.type == 2) {
g_win_w = ev.resize.w;
g_win_h = ev.resize.h;
pixels = (uint32_t*)(uintptr_t)zenith::win_resize(win_id, g_win_w, g_win_h);
pixels = (uint32_t*)(uintptr_t)montauk::win_resize(win_id, g_win_w, g_win_h);
clamp_scroll();
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
continue;
}
@@ -428,7 +428,7 @@ extern "C" void _start() {
if (redraw) {
clamp_scroll();
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
}
continue;
}
@@ -438,12 +438,12 @@ extern "C" void _start() {
g_scroll_y -= ev.mouse.scroll * SCROLL_STEP;
clamp_scroll();
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
}
continue;
}
}
zenith::win_destroy(win_id);
zenith::exit(0);
montauk::win_destroy(win_id);
montauk::exit(0);
}
@@ -1,13 +1,13 @@
/*
* stb_truetype_impl.cpp
* Single compilation unit for stb_truetype in ZenithOS freestanding environment
* Single compilation unit for stb_truetype in MontaukOS freestanding environment
* Copyright (c) 2026 Daniel Hammer
*/
#include <cstdint>
#include <cstddef>
#include <zenith/heap.h>
#include <zenith/string.h>
#include <montauk/heap.h>
#include <montauk/string.h>
#include <gui/stb_math.h>
// Override all stb_truetype dependencies before including the implementation
@@ -21,13 +21,13 @@
#define STBTT_acos(x) stb_acos(x)
#define STBTT_fabs(x) stb_fabs(x)
#define STBTT_malloc(x,u) ((void)(u), zenith::malloc(x))
#define STBTT_free(x,u) ((void)(u), zenith::mfree(x))
#define STBTT_malloc(x,u) ((void)(u), montauk::malloc(x))
#define STBTT_free(x,u) ((void)(u), montauk::mfree(x))
#define STBTT_memcpy(d,s,n) zenith::memcpy(d,s,n)
#define STBTT_memset(d,v,n) zenith::memset(d,v,n)
#define STBTT_memcpy(d,s,n) montauk::memcpy(d,s,n)
#define STBTT_memset(d,v,n) montauk::memset(d,v,n)
#define STBTT_strlen(x) zenith::slen(x)
#define STBTT_strlen(x) montauk::slen(x)
#define STBTT_assert(x) ((void)(x))
+26 -26
View File
@@ -4,8 +4,8 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
static int atoi(const char* s) {
int n = 0;
@@ -20,69 +20,69 @@ static void print_int(int n) {
char buf[16];
int i = 0;
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
while (n > 0 && i < 15) {
buf[i++] = '0' + (n % 10);
n /= 10;
}
while (i > 0) zenith::putchar(buf[--i]);
while (i > 0) montauk::putchar(buf[--i]);
}
extern "C" void _start() {
char args[128];
int len = zenith::getargs(args, sizeof(args));
int len = montauk::getargs(args, sizeof(args));
if (len <= 0 || args[0] == '\0') {
// No args: show current scale
int sx, sy;
zenith::get_termscale(&sx, &sy);
montauk::get_termscale(&sx, &sy);
int cols, rows;
zenith::termsize(&cols, &rows);
montauk::termsize(&cols, &rows);
zenith::print("Font scale: ");
montauk::print("Font scale: ");
print_int(sx);
zenith::print("x");
montauk::print("x");
print_int(sy);
zenith::print(" Terminal: ");
montauk::print(" Terminal: ");
print_int(cols);
zenith::print("x");
montauk::print("x");
print_int(rows);
zenith::putchar('\n');
zenith::exit(0);
montauk::putchar('\n');
montauk::exit(0);
}
// Parse arguments
const char* p = zenith::skip_spaces(args);
const char* p = montauk::skip_spaces(args);
int scale_x = atoi(p);
// Skip past first number to find optional second
while (*p >= '0' && *p <= '9') p++;
p = zenith::skip_spaces(p);
p = montauk::skip_spaces(p);
int scale_y = (*p >= '1' && *p <= '8') ? atoi(p) : scale_x;
if (scale_x < 1 || scale_x > 8 || scale_y < 1 || scale_y > 8) {
zenith::print("fontscale: scale must be 1-8\n");
zenith::exit(1);
montauk::print("fontscale: scale must be 1-8\n");
montauk::exit(1);
}
zenith::termscale(scale_x, scale_y);
montauk::termscale(scale_x, scale_y);
// Clear and show result
zenith::print("\033[2J\033[H");
montauk::print("\033[2J\033[H");
int cols, rows;
zenith::termsize(&cols, &rows);
zenith::print("Font scale set to ");
montauk::termsize(&cols, &rows);
montauk::print("Font scale set to ");
print_int(scale_x);
zenith::print("x");
montauk::print("x");
print_int(scale_y);
zenith::print(" (");
montauk::print(" (");
print_int(cols);
zenith::print("x");
montauk::print("x");
print_int(rows);
zenith::print(")\n");
montauk::print(")\n");
zenith::exit(0);
montauk::exit(0);
}
+4 -4
View File
@@ -1,18 +1,18 @@
/*
* main.cpp
* Hello world program for ZenithOS
* Hello world program for MontaukOS
* Copyright (c) 2025 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
extern "C" void _start() {
zenith::print("Hello from userspace!\n");
montauk::print("Hello from userspace!\n");
// while(true) {
// zenith::print("ab");
// montauk::print("ab");
// }
}
+71 -71
View File
@@ -1,18 +1,18 @@
/*
* main.cpp
* HTTP/1.0 server for ZenithOS
* HTTP/1.0 server for MontaukOS
* Usage: httpd [port] (default: 80)
* Serves a built-in index page and files from the VFS
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
using zenith::slen;
using zenith::streq;
using zenith::starts_with;
using zenith::skip_spaces;
using montauk::slen;
using montauk::streq;
using montauk::starts_with;
using montauk::skip_spaces;
// ---- Minimal snprintf (no libc available) ----
@@ -153,22 +153,22 @@ static void send_response(int clientFd, int statusCode, const char* statusText,
"Content-Type: %s\r\n"
"Content-Length: %d\r\n"
"Connection: close\r\n"
"Server: ZenithOS/1.0\r\n"
"Server: MontaukOS/1.0\r\n"
"\r\n",
statusCode, statusText, contentType, bodyLen);
zenith::send(clientFd, header, hlen);
montauk::send(clientFd, header, hlen);
if (bodyLen > 0) {
zenith::send(clientFd, body, bodyLen);
montauk::send(clientFd, body, bodyLen);
}
}
// Send a file from the VFS
static int send_file_response(int clientFd, const char* vfsPath, const char* urlPath) {
int handle = zenith::open(vfsPath);
int handle = montauk::open(vfsPath);
if (handle < 0) return -1;
uint64_t size = zenith::getsize(handle);
uint64_t size = montauk::getsize(handle);
const char* ctype = content_type_for(urlPath);
// Send header
@@ -178,10 +178,10 @@ static int send_file_response(int clientFd, const char* vfsPath, const char* url
"Content-Type: %s\r\n"
"Content-Length: %u\r\n"
"Connection: close\r\n"
"Server: ZenithOS/1.0\r\n"
"Server: MontaukOS/1.0\r\n"
"\r\n",
ctype, (unsigned)size);
zenith::send(clientFd, header, hlen);
montauk::send(clientFd, header, hlen);
// Send file body in chunks
uint8_t buf[512];
@@ -189,13 +189,13 @@ static int send_file_response(int clientFd, const char* vfsPath, const char* url
while (offset < size) {
uint64_t chunk = size - offset;
if (chunk > sizeof(buf)) chunk = sizeof(buf);
int bytesRead = zenith::read(handle, buf, offset, chunk);
int bytesRead = montauk::read(handle, buf, offset, chunk);
if (bytesRead <= 0) break;
zenith::send(clientFd, buf, bytesRead);
montauk::send(clientFd, buf, bytesRead);
offset += bytesRead;
}
zenith::close(handle);
montauk::close(handle);
return (int)size;
}
@@ -223,23 +223,23 @@ static int parse_request_path(const char* req, int reqLen, char* pathOut, int pa
static void log_request(const char* method, const char* path, int status, int bodyLen) {
// Get timestamp
Zenith::DateTime dt;
zenith::gettime(&dt);
Montauk::DateTime dt;
montauk::gettime(&dt);
char msg[256];
snprintf(msg, sizeof(msg), "[%02d:%02d:%02d] %s %s -> %d (%d bytes)\n",
(int)dt.Hour, (int)dt.Minute, (int)dt.Second,
method, path, status, bodyLen);
zenith::print(msg);
montauk::print(msg);
}
// ---- Page generators ----
static int generate_index_page(char* buf, int bufSize) {
Zenith::SysInfo info;
zenith::get_info(&info);
Montauk::SysInfo info;
montauk::get_info(&info);
uint64_t ms = zenith::get_milliseconds();
uint64_t ms = montauk::get_milliseconds();
uint64_t secs = ms / 1000;
uint64_t mins = secs / 60;
uint64_t hours = mins / 60;
@@ -249,10 +249,10 @@ static int generate_index_page(char* buf, int bufSize) {
return snprintf(buf, bufSize,
"<!DOCTYPE html>\n"
"<html>\n"
"<head><title>ZenithOS Web Server</title></head>\n"
"<head><title>MontaukOS Web Server</title></head>\n"
"<body>\n"
"<h1>ZenithOS Web Server</h1>\n"
"<p>Welcome! This page is being served by <b>httpd</b> running on ZenithOS.</p>\n"
"<h1>MontaukOS Web Server</h1>\n"
"<p>Welcome! This page is being served by <b>httpd</b> running on MontaukOS.</p>\n"
"<h2>System Information</h2>\n"
"<table>\n"
"<tr><td><b>OS:</b></td><td>%s</td></tr>\n"
@@ -302,7 +302,7 @@ static int generate_dir_listing(char* buf, int bufSize, const char* urlPath, con
// List directory entries
const char* entries[64];
int count = zenith::readdir(vfsDir, entries, 64);
int count = montauk::readdir(vfsDir, entries, 64);
// Find the prefix to strip from entry names
// vfsDir is like "0:/" or "0:/subdir"
@@ -331,7 +331,7 @@ static int generate_dir_listing(char* buf, int bufSize, const char* urlPath, con
pos += snprintf(buf + pos, bufSize - pos,
"</ul>\n"
"<hr>\n"
"<p><i>ZenithOS httpd</i></p>\n"
"<p><i>MontaukOS httpd</i></p>\n"
"</body>\n"
"</html>\n");
@@ -348,7 +348,7 @@ static void handle_client(int clientFd) {
// Read until we get the full header (ends with \r\n\r\n)
while (reqLen < (int)sizeof(reqBuf) - 1) {
int r = zenith::recv(clientFd, reqBuf + reqLen, sizeof(reqBuf) - 1 - reqLen);
int r = montauk::recv(clientFd, reqBuf + reqLen, sizeof(reqBuf) - 1 - reqLen);
if (r > 0) {
reqLen += r;
idleCount = 0;
@@ -367,13 +367,13 @@ static void handle_client(int clientFd) {
} else {
idleCount++;
if (idleCount > 500) break; // Timeout
zenith::yield();
montauk::yield();
}
}
reqBuf[reqLen] = '\0';
if (reqLen == 0) {
zenith::closesocket(clientFd);
montauk::closesocket(clientFd);
return;
}
@@ -384,7 +384,7 @@ static void handle_client(int clientFd) {
static char body[] = "<!DOCTYPE html><html><body><h1>400 Bad Request</h1></body></html>";
send_response(clientFd, 400, "Bad Request", "text/html", body, slen(body));
log_request("???", "???", 400, slen(body));
zenith::closesocket(clientFd);
montauk::closesocket(clientFd);
return;
}
@@ -393,9 +393,9 @@ static void handle_client(int clientFd) {
if (streq(path, "/")) {
// Try to serve 0:/www/index.html from disk first
int handle = zenith::open("0:/www/index.html");
int handle = montauk::open("0:/www/index.html");
if (handle >= 0) {
zenith::close(handle);
montauk::close(handle);
int bodyLen = send_file_response(clientFd, "0:/www/index.html", "/index.html");
log_request("GET", path, 200, bodyLen);
} else {
@@ -428,10 +428,10 @@ static void handle_client(int clientFd) {
vfsPath[pi] = '\0';
// Try to open as file first
int handle = zenith::open(vfsPath);
int handle = montauk::open(vfsPath);
if (handle >= 0) {
// It's a file — serve it
zenith::close(handle);
montauk::close(handle);
int bodyLen = send_file_response(clientFd, vfsPath, path);
if (bodyLen >= 0) {
log_request("GET", path, 200, bodyLen);
@@ -443,7 +443,7 @@ static void handle_client(int clientFd) {
} else {
// Try as directory
const char* entries[64];
int count = zenith::readdir(vfsPath, entries, 64);
int count = montauk::readdir(vfsPath, entries, 64);
if (count >= 0) {
// Make sure urlPath ends with /
char urlPath[256];
@@ -471,7 +471,7 @@ static void handle_client(int clientFd) {
log_request("GET", path, 404, bodyLen);
}
zenith::closesocket(clientFd);
montauk::closesocket(clientFd);
}
// ---- Entry point ----
@@ -479,55 +479,55 @@ static void handle_client(int clientFd) {
extern "C" void _start() {
// Parse arguments: [port]
char argbuf[64];
zenith::getargs(argbuf, sizeof(argbuf));
montauk::getargs(argbuf, sizeof(argbuf));
const char* arg = skip_spaces(argbuf);
uint16_t port = 80;
if (*arg) {
if (!parse_uint16(arg, &port)) {
zenith::print("Invalid port: ");
zenith::print(arg);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Invalid port: ");
montauk::print(arg);
montauk::putchar('\n');
montauk::exit(1);
}
}
// Create server socket
int listenFd = zenith::socket(Zenith::SOCK_TCP);
int listenFd = montauk::socket(Montauk::SOCK_TCP);
if (listenFd < 0) {
zenith::print("Error: failed to create socket\n");
zenith::exit(1);
montauk::print("Error: failed to create socket\n");
montauk::exit(1);
}
// Bind
if (zenith::bind(listenFd, port) < 0) {
zenith::print("Error: failed to bind to port ");
if (montauk::bind(listenFd, port) < 0) {
montauk::print("Error: failed to bind to port ");
char tmp[8];
snprintf(tmp, sizeof(tmp), "%d", (int)port);
zenith::print(tmp);
zenith::putchar('\n');
zenith::closesocket(listenFd);
zenith::exit(1);
montauk::print(tmp);
montauk::putchar('\n');
montauk::closesocket(listenFd);
montauk::exit(1);
}
// Listen
if (zenith::listen(listenFd) < 0) {
zenith::print("Error: failed to listen\n");
zenith::closesocket(listenFd);
zenith::exit(1);
if (montauk::listen(listenFd) < 0) {
montauk::print("Error: failed to listen\n");
montauk::closesocket(listenFd);
montauk::exit(1);
}
char msg[128];
snprintf(msg, sizeof(msg), "ZenithOS httpd listening on port %d\n", (int)port);
zenith::print(msg);
zenith::print("Press Ctrl+Q between requests to stop.\n\n");
snprintf(msg, sizeof(msg), "MontaukOS httpd listening on port %d\n", (int)port);
montauk::print(msg);
montauk::print("Press Ctrl+Q between requests to stop.\n\n");
bool running = true;
while (running) {
// Check for Ctrl+Q before blocking on accept
while (zenith::is_key_available()) {
Zenith::KeyEvent ev;
zenith::getkey(&ev);
while (montauk::is_key_available()) {
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (ev.pressed && ev.ctrl && ev.ascii == 'q') {
running = false;
break;
@@ -536,19 +536,19 @@ extern "C" void _start() {
if (!running) break;
// Accept next client (blocks until a connection arrives)
int clientFd = zenith::accept(listenFd);
int clientFd = montauk::accept(listenFd);
if (clientFd < 0) {
zenith::print("Warning: accept failed\n");
zenith::yield();
montauk::print("Warning: accept failed\n");
montauk::yield();
continue;
}
handle_client(clientFd);
// After serving, check for Ctrl+Q
while (zenith::is_key_available()) {
Zenith::KeyEvent ev;
zenith::getkey(&ev);
while (montauk::is_key_available()) {
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (ev.pressed && ev.ctrl && ev.ascii == 'q') {
running = false;
break;
@@ -556,7 +556,7 @@ extern "C" void _start() {
}
}
zenith::print("\nShutting down httpd...\n");
zenith::closesocket(listenFd);
zenith::exit(0);
montauk::print("\nShutting down httpd...\n");
montauk::closesocket(listenFd);
montauk::exit(0);
}
+45 -45
View File
@@ -4,15 +4,15 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
using zenith::starts_with;
using zenith::skip_spaces;
using montauk::starts_with;
using montauk::skip_spaces;
static void print_int(uint64_t n) {
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
char buf[20];
@@ -22,17 +22,17 @@ static void print_int(uint64_t n) {
n /= 10;
}
for (int j = i - 1; j >= 0; j--) {
zenith::putchar(buf[j]);
montauk::putchar(buf[j]);
}
}
static void print_ip(uint32_t ip) {
print_int(ip & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 8) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 16) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 24) & 0xFF);
}
@@ -66,31 +66,31 @@ static bool parse_ip(const char* s, uint32_t* out) {
extern "C" void _start() {
char args[256];
int len = zenith::getargs(args, sizeof(args));
int len = montauk::getargs(args, sizeof(args));
if (len <= 0 || args[0] == '\0') {
// Show current network configuration
Zenith::NetCfg cfg;
zenith::get_netcfg(&cfg);
zenith::print(" IP Address: ");
Montauk::NetCfg cfg;
montauk::get_netcfg(&cfg);
montauk::print(" IP Address: ");
print_ip(cfg.ipAddress);
zenith::putchar('\n');
zenith::print(" Subnet Mask: ");
montauk::putchar('\n');
montauk::print(" Subnet Mask: ");
print_ip(cfg.subnetMask);
zenith::putchar('\n');
zenith::print(" Gateway: ");
montauk::putchar('\n');
montauk::print(" Gateway: ");
print_ip(cfg.gateway);
zenith::putchar('\n');
zenith::print(" DNS Server: ");
montauk::putchar('\n');
montauk::print(" DNS Server: ");
print_ip(cfg.dnsServer);
zenith::putchar('\n');
zenith::exit(0);
montauk::putchar('\n');
montauk::exit(0);
}
if (!starts_with(args, "set ")) {
zenith::print("Usage: ifconfig Show network config\n");
zenith::print(" ifconfig set <ip> <mask> <gateway>\n");
zenith::exit(1);
montauk::print("Usage: ifconfig Show network config\n");
montauk::print(" ifconfig set <ip> <mask> <gateway>\n");
montauk::exit(1);
}
// Parse: set <ip> <mask> <gateway>
@@ -103,10 +103,10 @@ extern "C" void _start() {
tok[i] = '\0';
uint32_t ip;
if (!parse_ip(tok, &ip)) {
zenith::print("Invalid IP address: ");
zenith::print(tok);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Invalid IP address: ");
montauk::print(tok);
montauk::putchar('\n');
montauk::exit(1);
}
p = skip_spaces(p + i);
@@ -116,10 +116,10 @@ extern "C" void _start() {
tok[i] = '\0';
uint32_t mask;
if (!parse_ip(tok, &mask)) {
zenith::print("Invalid subnet mask: ");
zenith::print(tok);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Invalid subnet mask: ");
montauk::print(tok);
montauk::putchar('\n');
montauk::exit(1);
}
p = skip_spaces(p + i);
@@ -129,24 +129,24 @@ extern "C" void _start() {
tok[i] = '\0';
uint32_t gw;
if (!parse_ip(tok, &gw)) {
zenith::print("Invalid gateway: ");
zenith::print(tok);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Invalid gateway: ");
montauk::print(tok);
montauk::putchar('\n');
montauk::exit(1);
}
Zenith::NetCfg cfg;
Montauk::NetCfg cfg;
cfg.ipAddress = ip;
cfg.subnetMask = mask;
cfg.gateway = gw;
if (zenith::set_netcfg(&cfg) < 0) {
zenith::print("Error: failed to set network config\n");
zenith::exit(1);
if (montauk::set_netcfg(&cfg) < 0) {
montauk::print("Error: failed to set network config\n");
montauk::exit(1);
}
zenith::print("Network config updated:\n");
zenith::print(" IP Address: "); print_ip(ip); zenith::putchar('\n');
zenith::print(" Subnet Mask: "); print_ip(mask); zenith::putchar('\n');
zenith::print(" Gateway: "); print_ip(gw); zenith::putchar('\n');
zenith::exit(0);
montauk::print("Network config updated:\n");
montauk::print(" IP Address: "); print_ip(ip); montauk::putchar('\n');
montauk::print(" Subnet Mask: "); print_ip(mask); montauk::putchar('\n');
montauk::print(" Gateway: "); print_ip(gw); montauk::putchar('\n');
montauk::exit(0);
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Makefile for imageviewer (standalone JPEG viewer) on ZenithOS
# Makefile for imageviewer (standalone JPEG viewer) on MontaukOS
# Copyright (c) 2026 Daniel Hammer
MAKEFLAGS += -rR
+44 -44
View File
@@ -1,13 +1,13 @@
/*
* main.cpp
* ZenithOS Image Viewer - standalone Window Server process
* MontaukOS Image Viewer - standalone Window Server process
* Displays JPEG images with pan via mouse drag, scroll wheel, and arrow keys
* Copyright (c) 2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <zenith/heap.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <gui/gui.hpp>
#include <gui/truetype.hpp>
@@ -107,7 +107,7 @@ static void int_to_str(char* buf, int val) {
}
static void str_append(char* dst, const char* src, int maxlen) {
int len = zenith::slen(dst);
int len = montauk::slen(dst);
int i = 0;
while (src[i] && len + i < maxlen - 1) {
dst[len + i] = src[i];
@@ -121,41 +121,41 @@ static void str_append(char* dst, const char* src, int maxlen) {
// ============================================================================
static bool load_image(const char* path) {
int fd = zenith::open(path);
int fd = montauk::open(path);
if (fd < 0) {
zenith::strcpy(g_status, "Error: could not open file");
montauk::strcpy(g_status, "Error: could not open file");
return false;
}
uint64_t size = zenith::getsize(fd);
uint64_t size = montauk::getsize(fd);
if (size == 0 || size > 16 * 1024 * 1024) {
zenith::close(fd);
zenith::strcpy(g_status, "Error: file too large or empty");
montauk::close(fd);
montauk::strcpy(g_status, "Error: file too large or empty");
return false;
}
uint8_t* filedata = (uint8_t*)zenith::malloc(size);
uint8_t* filedata = (uint8_t*)montauk::malloc(size);
if (!filedata) {
zenith::close(fd);
zenith::strcpy(g_status, "Error: out of memory");
montauk::close(fd);
montauk::strcpy(g_status, "Error: out of memory");
return false;
}
int bytes_read = zenith::read(fd, filedata, 0, size);
zenith::close(fd);
int bytes_read = montauk::read(fd, filedata, 0, size);
montauk::close(fd);
if (bytes_read <= 0) {
zenith::mfree(filedata);
zenith::strcpy(g_status, "Error: could not read file");
montauk::mfree(filedata);
montauk::strcpy(g_status, "Error: could not read file");
return false;
}
int w, h, channels;
unsigned char* rgb = stbi_load_from_memory(filedata, bytes_read, &w, &h, &channels, 3);
zenith::mfree(filedata);
montauk::mfree(filedata);
if (!rgb) {
zenith::strcpy(g_status, "Error: ");
montauk::strcpy(g_status, "Error: ");
const char* reason = stbi_failure_reason();
if (reason) str_append(g_status, reason, 256);
else str_append(g_status, "unknown decode error", 256);
@@ -163,10 +163,10 @@ static bool load_image(const char* path) {
}
// Convert RGB to ARGB
g_image = (uint32_t*)zenith::malloc((uint64_t)w * h * 4);
g_image = (uint32_t*)montauk::malloc((uint64_t)w * h * 4);
if (!g_image) {
stbi_image_free(rgb);
zenith::strcpy(g_status, "Error: out of memory for image");
montauk::strcpy(g_status, "Error: out of memory for image");
return false;
}
@@ -184,9 +184,9 @@ static bool load_image(const char* path) {
// Build status string: "filename.jpg (1920 x 1080)"
const char* name = basename(path);
zenith::strncpy(g_filename, name, 127);
montauk::strncpy(g_filename, name, 127);
zenith::strcpy(g_status, g_filename);
montauk::strcpy(g_status, g_filename);
str_append(g_status, " (", 256);
char num[16];
int_to_str(num, w);
@@ -272,17 +272,17 @@ static void render(uint32_t* pixels) {
extern "C" void _start() {
// Get file path from arguments
char filepath[512] = {};
int arglen = zenith::getargs(filepath, sizeof(filepath));
int arglen = montauk::getargs(filepath, sizeof(filepath));
if (arglen <= 0) {
zenith::strcpy(filepath, "");
montauk::strcpy(filepath, "");
}
// Load font
auto load_font = [](const char* path) -> TrueTypeFont* {
TrueTypeFont* f = (TrueTypeFont*)zenith::malloc(sizeof(TrueTypeFont));
TrueTypeFont* f = (TrueTypeFont*)montauk::malloc(sizeof(TrueTypeFont));
if (!f) return nullptr;
zenith::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { zenith::mfree(f); return nullptr; }
montauk::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { montauk::mfree(f); return nullptr; }
return f;
};
g_font = load_font("0:/fonts/Roboto-Medium.ttf");
@@ -291,13 +291,13 @@ extern "C" void _start() {
char title[64] = "Image Viewer";
if (filepath[0]) {
const char* name = basename(filepath);
if (name[0]) zenith::strncpy(title, name, 63);
if (name[0]) montauk::strncpy(title, name, 63);
}
// Create window
Zenith::WinCreateResult wres;
if (zenith::win_create(title, INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
zenith::exit(1);
Montauk::WinCreateResult wres;
if (montauk::win_create(title, INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
montauk::exit(1);
int win_id = wres.id;
uint32_t* pixels = (uint32_t*)(uintptr_t)wres.pixelVa;
@@ -306,7 +306,7 @@ extern "C" void _start() {
if (filepath[0]) {
g_load_ok = load_image(filepath);
} else {
zenith::strcpy(g_status, "No file specified");
montauk::strcpy(g_status, "No file specified");
g_load_ok = false;
}
@@ -315,17 +315,17 @@ extern "C" void _start() {
// Initial render
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
// Event loop
while (true) {
Zenith::WinEvent ev;
int r = zenith::win_poll(win_id, &ev);
Montauk::WinEvent ev;
int r = montauk::win_poll(win_id, &ev);
if (r < 0) break;
if (r == 0) {
zenith::sleep_ms(16);
montauk::sleep_ms(16);
continue;
}
@@ -336,10 +336,10 @@ extern "C" void _start() {
if (ev.type == 2) {
g_win_w = ev.resize.w;
g_win_h = ev.resize.h;
pixels = (uint32_t*)(uintptr_t)zenith::win_resize(win_id, g_win_w, g_win_h);
pixels = (uint32_t*)(uintptr_t)montauk::win_resize(win_id, g_win_w, g_win_h);
if (g_load_ok) clamp_pan();
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
continue;
}
@@ -364,7 +364,7 @@ extern "C" void _start() {
if (redraw && g_load_ok) {
clamp_pan();
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
}
continue;
}
@@ -405,14 +405,14 @@ extern "C" void _start() {
if (redraw && g_load_ok) {
clamp_pan();
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
}
continue;
}
}
// Cleanup
if (g_image) zenith::mfree(g_image);
zenith::win_destroy(win_id);
zenith::exit(0);
if (g_image) montauk::mfree(g_image);
montauk::win_destroy(win_id);
montauk::exit(0);
}
@@ -1,13 +1,13 @@
/*
* stb_truetype_impl.cpp
* Single compilation unit for stb_truetype in ZenithOS freestanding environment
* Single compilation unit for stb_truetype in MontaukOS freestanding environment
* Copyright (c) 2026 Daniel Hammer
*/
#include <cstdint>
#include <cstddef>
#include <zenith/heap.h>
#include <zenith/string.h>
#include <montauk/heap.h>
#include <montauk/string.h>
#include <gui/stb_math.h>
// Override all stb_truetype dependencies before including the implementation
@@ -21,13 +21,13 @@
#define STBTT_acos(x) stb_acos(x)
#define STBTT_fabs(x) stb_fabs(x)
#define STBTT_malloc(x,u) ((void)(u), zenith::malloc(x))
#define STBTT_free(x,u) ((void)(u), zenith::mfree(x))
#define STBTT_malloc(x,u) ((void)(u), montauk::malloc(x))
#define STBTT_free(x,u) ((void)(u), montauk::mfree(x))
#define STBTT_memcpy(d,s,n) zenith::memcpy(d,s,n)
#define STBTT_memset(d,v,n) zenith::memset(d,v,n)
#define STBTT_memcpy(d,s,n) montauk::memcpy(d,s,n)
#define STBTT_memset(d,v,n) montauk::memset(d,v,n)
#define STBTT_strlen(x) zenith::slen(x)
#define STBTT_strlen(x) montauk::slen(x)
#define STBTT_assert(x) ((void)(x))
+12 -12
View File
@@ -4,11 +4,11 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
static void print_int(uint64_t n) {
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
char buf[20];
@@ -18,19 +18,19 @@ static void print_int(uint64_t n) {
n /= 10;
}
for (int j = i - 1; j >= 0; j--) {
zenith::putchar(buf[j]);
montauk::putchar(buf[j]);
}
}
extern "C" void _start() {
Zenith::SysInfo info;
zenith::get_info(&info);
zenith::print(info.osName);
zenith::print(" v");
zenith::print(info.osVersion);
zenith::putchar('\n');
zenith::print("Syscall API version: ");
Montauk::SysInfo info;
montauk::get_info(&info);
montauk::print(info.osName);
montauk::print(" v");
montauk::print(info.osVersion);
montauk::putchar('\n');
montauk::print("Syscall API version: ");
print_int(info.apiVersion);
zenith::putchar('\n');
zenith::exit(0);
montauk::putchar('\n');
montauk::exit(0);
}
+9 -9
View File
@@ -1,11 +1,11 @@
/*
* main.cpp
* Init system for ZenithOS (PID 0)
* Init system for MontaukOS (PID 0)
* Chains system services then launches the shell.
* Copyright (c) 2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
// ---- Minimal snprintf ----
@@ -90,8 +90,8 @@ static int snprintf(char* buf, int size, const char* fmt, ...) {
// ---- Logging ----
static void log_timestamp(char* buf, int size) {
Zenith::DateTime dt;
zenith::gettime(&dt);
Montauk::DateTime dt;
montauk::gettime(&dt);
snprintf(buf, size, "%02d:%02d:%02d", dt.Hour, dt.Minute, dt.Second);
}
@@ -114,7 +114,7 @@ static void log(LogLevel level, const char* msg) {
snprintf(line, sizeof(line),
C_DIM "%s" C_RESET " %s%s" C_RESET " " C_BOLD "init" C_RESET " %s\n",
ts, color, tag, msg);
zenith::print(line);
montauk::print(line);
}
static void log_ok(const char* msg) { log(LOG_OK, msg); }
@@ -130,14 +130,14 @@ static bool run_service(const char* path, const char* name) {
snprintf(msg, sizeof(msg), "Starting %s", name);
log_info(msg);
int pid = zenith::spawn(path);
int pid = montauk::spawn(path);
if (pid < 0) {
snprintf(msg, sizeof(msg), "Failed to start %s", name);
log_err(msg);
return false;
}
zenith::waitpid(pid);
montauk::waitpid(pid);
snprintf(msg, sizeof(msg), "%s finished (pid %d)", name, pid);
log_ok(msg);
@@ -148,7 +148,7 @@ static bool run_service(const char* path, const char* name) {
extern "C" void _start() {
log_info("The ZenithOS Operating System");
log_info("The MontaukOS Operating System");
// ---- Stage 1: Network configuration ----
run_service("0:/os/dhcp.elf", "dhcp");
@@ -162,6 +162,6 @@ extern "C" void _start() {
log_warn("All services exited");
for (;;) {
zenith::yield();
montauk::yield();
}
}
+41 -41
View File
@@ -1,21 +1,21 @@
/*
* main.cpp
* IRC client for ZenithOS
* IRC client for MontaukOS
* Split-screen terminal UI with ANSI escape codes
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
using zenith::slen;
using zenith::streq;
using zenith::starts_with;
using zenith::skip_spaces;
using zenith::strcpy;
using zenith::strncpy;
using zenith::memcpy;
using zenith::memmove;
using montauk::slen;
using montauk::streq;
using montauk::starts_with;
using montauk::skip_spaces;
using montauk::strcpy;
using montauk::strncpy;
using montauk::memcpy;
using montauk::memmove;
// ---- Minimal snprintf (no libc available) ----
@@ -241,7 +241,7 @@ static void sb_cursor_to(int row, int col) {
static void sb_flush() {
screen.buf[screen.pos] = '\0';
zenith::print(screen.buf);
montauk::print(screen.buf);
}
// ---- Globals ----
@@ -308,7 +308,7 @@ static void irc_send(const char* fmt, ...) {
buf[len] = '\r';
buf[len + 1] = '\n';
buf[len + 2] = '\0';
zenith::send(irc.fd, buf, len + 2);
montauk::send(irc.fd, buf, len + 2);
}
// ---- Sanitize incoming text (strip control chars) ----
@@ -603,7 +603,7 @@ static void irc_process_line(char* line) {
static void recv_process() {
char tmp[512];
int r = zenith::recv(irc.fd, tmp, sizeof(tmp));
int r = montauk::recv(irc.fd, tmp, sizeof(tmp));
if (r < 0) {
irc.connected = false;
msg_add("\033[31m*** Connection lost\033[0m");
@@ -832,12 +832,12 @@ static void handle_user_input() {
extern "C" void _start() {
// Parse arguments: <server_ip> <port> <nickname> [#channel]
char argbuf[256];
zenith::getargs(argbuf, sizeof(argbuf));
montauk::getargs(argbuf, sizeof(argbuf));
const char* arg = skip_spaces(argbuf);
if (*arg == '\0') {
zenith::print("Usage: irc <server> <port> <nickname> [#channel]\n");
zenith::print("Example: irc irc.libera.chat 6667 ZenithUser #general\n");
montauk::print("Usage: irc <server> <port> <nickname> [#channel]\n");
montauk::print("Example: irc irc.libera.chat 6667 MontaukUser #general\n");
return;
}
@@ -849,11 +849,11 @@ extern "C" void _start() {
arg = skip_spaces(arg + i);
if (!parse_ip(hostStr, &irc.serverIp)) {
irc.serverIp = zenith::resolve(hostStr);
irc.serverIp = montauk::resolve(hostStr);
if (irc.serverIp == 0) {
zenith::print("Could not resolve: ");
zenith::print(hostStr);
zenith::putchar('\n');
montauk::print("Could not resolve: ");
montauk::print(hostStr);
montauk::putchar('\n');
return;
}
}
@@ -866,9 +866,9 @@ extern "C" void _start() {
arg = skip_spaces(arg + i);
if (!parse_uint16(portStr, &irc.serverPort)) {
zenith::print("Invalid port: ");
zenith::print(portStr);
zenith::putchar('\n');
montauk::print("Invalid port: ");
montauk::print(portStr);
montauk::putchar('\n');
return;
}
@@ -879,7 +879,7 @@ extern "C" void _start() {
arg = skip_spaces(arg + i);
if (!irc.nick[0]) {
zenith::print("Missing nickname\n");
montauk::print("Missing nickname\n");
return;
}
@@ -903,35 +903,35 @@ extern "C" void _start() {
running = true;
// Get terminal size
zenith::termsize(&term.cols, &term.rows);
montauk::termsize(&term.cols, &term.rows);
term.msgAreaRows = term.rows - 3;
if (term.msgAreaRows < 1) term.msgAreaRows = 1;
// Enter alternate screen buffer, hide cursor
zenith::print("\033[?1049h");
zenith::print("\033[?25l");
montauk::print("\033[?1049h");
montauk::print("\033[?25l");
// Initial draw
msg_add("\033[1m*** ZenithOS IRC Client\033[0m");
msg_add("\033[1m*** MontaukOS IRC Client\033[0m");
msg_add_fmt("*** Connecting to %s:%d as %s...", hostStr, (int)irc.serverPort, irc.nick);
ui_render();
// Create socket and connect
irc.fd = zenith::socket(Zenith::SOCK_TCP);
irc.fd = montauk::socket(Montauk::SOCK_TCP);
if (irc.fd < 0) {
msg_add("\033[31m*** Failed to create socket\033[0m");
ui_render();
// Wait for keypress then exit
while (!zenith::is_key_available()) zenith::yield();
while (!montauk::is_key_available()) montauk::yield();
goto cleanup;
}
if (zenith::connect(irc.fd, irc.serverIp, irc.serverPort) < 0) {
if (montauk::connect(irc.fd, irc.serverIp, irc.serverPort) < 0) {
msg_add("\033[31m*** Connection failed\033[0m");
ui_render();
zenith::closesocket(irc.fd);
montauk::closesocket(irc.fd);
irc.fd = -1;
while (!zenith::is_key_available()) zenith::yield();
while (!montauk::is_key_available()) montauk::yield();
goto cleanup;
}
@@ -954,9 +954,9 @@ extern "C" void _start() {
if (msgBuf.count != prevCount) dirty = true;
// Poll keyboard
if (zenith::is_key_available()) {
Zenith::KeyEvent ev;
zenith::getkey(&ev);
if (montauk::is_key_available()) {
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (!ev.pressed) {
if (dirty) ui_render();
@@ -1028,7 +1028,7 @@ extern "C" void _start() {
}
} else {
if (!dirty) {
zenith::yield();
montauk::yield();
continue;
}
}
@@ -1037,11 +1037,11 @@ extern "C" void _start() {
}
if (irc.fd >= 0) {
zenith::closesocket(irc.fd);
montauk::closesocket(irc.fd);
}
cleanup:
// Restore terminal
zenith::print("\033[?25h");
zenith::print("\033[?1049l");
montauk::print("\033[?25h");
montauk::print("\033[?1049l");
}
+58 -58
View File
@@ -1,21 +1,21 @@
/*
* main.cpp
* Manual page viewer for ZenithOS
* Manual page viewer for MontaukOS
* Fullscreen pager with ANSI formatting and keyboard navigation
* Copyright (c) 2025 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/heap.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/heap.h>
#include <montauk/string.h>
using zenith::slen;
using zenith::starts_with;
using zenith::skip_spaces;
using montauk::slen;
using montauk::starts_with;
using montauk::skip_spaces;
static void print_int(uint64_t n) {
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
char buf[20];
@@ -25,7 +25,7 @@ static void print_int(uint64_t n) {
n /= 10;
}
for (int j = i - 1; j >= 0; j--) {
zenith::putchar(buf[j]);
montauk::putchar(buf[j]);
}
}
@@ -50,7 +50,7 @@ static void cursor_to(int row, int col) {
p += int_to_buf(seq + p, col);
seq[p++] = 'H';
seq[p] = '\0';
zenith::print(seq);
montauk::print(seq);
}
struct ManLine {
@@ -68,7 +68,7 @@ static void man_render(ManLine* lines, int totalLines, int scroll, int rows, int
for (int r = 0; r < contentRows; r++) {
cursor_to(r + 1, 1);
zenith::print("\033[2K");
montauk::print("\033[2K");
int idx = scroll + r;
if (idx < 0 || idx >= totalLines) continue;
@@ -77,11 +77,11 @@ static void man_render(ManLine* lines, int totalLines, int scroll, int rows, int
if (ln.isTH) continue;
if (ln.isSH || ln.isSS || ln.isBold) {
zenith::print("\033[1m");
montauk::print("\033[1m");
}
if (ln.isSS) {
zenith::print(" ");
montauk::print(" ");
}
int maxW = cols;
@@ -89,31 +89,31 @@ static void man_render(ManLine* lines, int totalLines, int scroll, int rows, int
int printLen = ln.len;
if (printLen > maxW) printLen = maxW;
for (int c = 0; c < printLen; c++) {
zenith::putchar(ln.text[c]);
montauk::putchar(ln.text[c]);
}
if (ln.isSH || ln.isSS || ln.isBold) {
zenith::print("\033[0m");
montauk::print("\033[0m");
}
}
// Status bar
cursor_to(rows, 1);
zenith::print("\033[7m");
zenith::print(" Manual page ");
zenith::print(name);
zenith::putchar('(');
montauk::print("\033[7m");
montauk::print(" Manual page ");
montauk::print(name);
montauk::putchar('(');
print_int((uint64_t)section);
zenith::putchar(')');
zenith::print(" line ");
montauk::putchar(')');
montauk::print(" line ");
print_int((uint64_t)(scroll + 1));
zenith::putchar('/');
montauk::putchar('/');
print_int((uint64_t)totalLines);
int padCount = cols - 30 - slen(name);
for (int i = 0; i < padCount; i++) zenith::putchar(' ');
for (int i = 0; i < padCount; i++) montauk::putchar(' ');
zenith::print("\033[0m");
montauk::print("\033[0m");
}
// ---- Main ----
@@ -121,13 +121,13 @@ static void man_render(ManLine* lines, int totalLines, int scroll, int rows, int
extern "C" void _start() {
// Get arguments passed by the shell (e.g. "intro" or "2 syscalls")
char argbuf[256];
zenith::getargs(argbuf, sizeof(argbuf));
montauk::getargs(argbuf, sizeof(argbuf));
const char* arg = skip_spaces(argbuf);
if (*arg == '\0') {
zenith::print("Usage: man <topic>\n");
zenith::print(" man <section> <topic>\n");
zenith::print("Try: man intro\n");
montauk::print("Usage: man <topic>\n");
montauk::print(" man <section> <topic>\n");
montauk::print("Try: man intro\n");
return;
}
@@ -155,7 +155,7 @@ extern "C" void _start() {
path[p++] = '0' + section;
path[p] = '\0';
handle = zenith::open(path);
handle = montauk::open(path);
if (handle >= 0) foundSection = section;
} else {
for (int s = 1; s <= 9; s++) {
@@ -168,7 +168,7 @@ extern "C" void _start() {
path[p++] = '0' + s;
path[p] = '\0';
handle = zenith::open(path);
handle = montauk::open(path);
if (handle >= 0) {
foundSection = s;
break;
@@ -177,24 +177,24 @@ extern "C" void _start() {
}
if (handle < 0) {
zenith::print("No manual entry for ");
zenith::print(topic);
zenith::putchar('\n');
montauk::print("No manual entry for ");
montauk::print(topic);
montauk::putchar('\n');
return;
}
// Load entire file into heap
uint64_t fileSize = zenith::getsize(handle);
uint64_t fileSize = montauk::getsize(handle);
if (fileSize == 0) {
zenith::close(handle);
zenith::print("Empty manual page.\n");
montauk::close(handle);
montauk::print("Empty manual page.\n");
return;
}
char* fileData = (char*)zenith::malloc(fileSize + 1);
char* fileData = (char*)montauk::malloc(fileSize + 1);
if (fileData == nullptr) {
zenith::close(handle);
zenith::print("Out of memory.\n");
montauk::close(handle);
montauk::print("Out of memory.\n");
return;
}
@@ -202,18 +202,18 @@ extern "C" void _start() {
while (offset < fileSize) {
uint64_t chunk = fileSize - offset;
if (chunk > 4096) chunk = 4096;
int bytesRead = zenith::read(handle, (uint8_t*)fileData + offset, offset, chunk);
int bytesRead = montauk::read(handle, (uint8_t*)fileData + offset, offset, chunk);
if (bytesRead <= 0) break;
offset += bytesRead;
}
fileData[offset] = '\0';
zenith::close(handle);
montauk::close(handle);
// Parse into lines
ManLine* lines = (ManLine*)zenith::malloc(MAN_MAX_LINES * sizeof(ManLine));
ManLine* lines = (ManLine*)montauk::malloc(MAN_MAX_LINES * sizeof(ManLine));
if (lines == nullptr) {
zenith::mfree(fileData);
zenith::print("Out of memory.\n");
montauk::mfree(fileData);
montauk::print("Out of memory.\n");
return;
}
@@ -260,19 +260,19 @@ extern "C" void _start() {
}
if (totalLines == 0) {
zenith::mfree(lines);
zenith::mfree(fileData);
zenith::print("Empty manual page.\n");
montauk::mfree(lines);
montauk::mfree(fileData);
montauk::print("Empty manual page.\n");
return;
}
// Get terminal dimensions
int cols = 80, rows = 25;
zenith::termsize(&cols, &rows);
montauk::termsize(&cols, &rows);
// Enter alternate screen, hide cursor
zenith::print("\033[?1049h");
zenith::print("\033[?25l");
montauk::print("\033[?1049h");
montauk::print("\033[?25l");
int scroll = 0;
int maxScroll = totalLines - (rows - 1);
@@ -283,12 +283,12 @@ extern "C" void _start() {
// Event loop — yield while waiting for key input
bool running = true;
while (running) {
while (!zenith::is_key_available()) {
zenith::yield();
while (!montauk::is_key_available()) {
montauk::yield();
}
Zenith::KeyEvent ev;
zenith::getkey(&ev);
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (!ev.pressed) continue;
int contentRows = rows - 1;
@@ -350,9 +350,9 @@ extern "C" void _start() {
}
// Restore screen
zenith::print("\033[?25h");
zenith::print("\033[?1049l");
montauk::print("\033[?25h");
montauk::print("\033[?1049l");
zenith::mfree(lines);
zenith::mfree(fileData);
montauk::mfree(lines);
montauk::mfree(fileData);
}
+36 -36
View File
@@ -1,83 +1,83 @@
/*
* main.cpp
* DNS lookup utility for ZenithOS
* DNS lookup utility for MontaukOS
* Usage: nslookup <hostname>
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
using zenith::skip_spaces;
using montauk::skip_spaces;
static void print_ip(uint32_t ip) {
auto print_int = [](uint32_t n) {
if (n == 0) { zenith::putchar('0'); return; }
if (n == 0) { montauk::putchar('0'); return; }
char buf[4];
int i = 0;
while (n > 0) { buf[i++] = '0' + (n % 10); n /= 10; }
for (int j = i - 1; j >= 0; j--) zenith::putchar(buf[j]);
for (int j = i - 1; j >= 0; j--) montauk::putchar(buf[j]);
};
print_int(ip & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 8) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 16) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 24) & 0xFF);
}
extern "C" void _start() {
char args[256];
int len = zenith::getargs(args, sizeof(args));
int len = montauk::getargs(args, sizeof(args));
const char* hostname = skip_spaces(args);
if (len <= 0 || hostname[0] == '\0') {
zenith::print("Usage: nslookup <hostname>\n");
zenith::print("Example: nslookup example.com\n");
zenith::exit(0);
montauk::print("Usage: nslookup <hostname>\n");
montauk::print("Example: nslookup example.com\n");
montauk::exit(0);
}
// Show DNS server
Zenith::NetCfg cfg;
zenith::get_netcfg(&cfg);
Montauk::NetCfg cfg;
montauk::get_netcfg(&cfg);
zenith::print("Server: ");
montauk::print("Server: ");
print_ip(cfg.dnsServer);
zenith::putchar('\n');
montauk::putchar('\n');
zenith::print("Querying ");
zenith::print(hostname);
zenith::print("...\n");
montauk::print("Querying ");
montauk::print(hostname);
montauk::print("...\n");
uint64_t start = zenith::get_milliseconds();
uint32_t ip = zenith::resolve(hostname);
uint64_t elapsed = zenith::get_milliseconds() - start;
uint64_t start = montauk::get_milliseconds();
uint32_t ip = montauk::resolve(hostname);
uint64_t elapsed = montauk::get_milliseconds() - start;
if (ip == 0) {
zenith::print("Error: could not resolve ");
zenith::print(hostname);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Error: could not resolve ");
montauk::print(hostname);
montauk::putchar('\n');
montauk::exit(1);
}
zenith::print("Name: ");
zenith::print(hostname);
zenith::putchar('\n');
zenith::print("Address: ");
montauk::print("Name: ");
montauk::print(hostname);
montauk::putchar('\n');
montauk::print("Address: ");
print_ip(ip);
zenith::putchar('\n');
montauk::putchar('\n');
// Print timing
zenith::print("Time: ");
montauk::print("Time: ");
char buf[20];
int i = 0;
uint64_t ms = elapsed;
if (ms == 0) { buf[i++] = '0'; }
else { while (ms > 0) { buf[i++] = '0' + (ms % 10); ms /= 10; } }
for (int j = i - 1; j >= 0; j--) zenith::putchar(buf[j]);
zenith::print(" ms\n");
for (int j = i - 1; j >= 0; j--) montauk::putchar(buf[j]);
montauk::print(" ms\n");
zenith::exit(0);
montauk::exit(0);
}
+25 -25
View File
@@ -4,11 +4,11 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
static void print_int(uint64_t n) {
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
char buf[20];
@@ -18,7 +18,7 @@ static void print_int(uint64_t n) {
n /= 10;
}
for (int j = i - 1; j >= 0; j--) {
zenith::putchar(buf[j]);
montauk::putchar(buf[j]);
}
}
@@ -52,55 +52,55 @@ static bool parse_ip(const char* s, uint32_t* out) {
static void print_ip(uint32_t ip) {
print_int(ip & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 8) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 16) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 24) & 0xFF);
}
extern "C" void _start() {
char args[256];
int len = zenith::getargs(args, sizeof(args));
int len = montauk::getargs(args, sizeof(args));
if (len <= 0 || args[0] == '\0') {
zenith::print("Usage: ping <host>\n");
zenith::exit(1);
montauk::print("Usage: ping <host>\n");
montauk::exit(1);
}
uint32_t ip;
if (!parse_ip(args, &ip)) {
ip = zenith::resolve(args);
ip = montauk::resolve(args);
if (ip == 0) {
zenith::print("Could not resolve: ");
zenith::print(args);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Could not resolve: ");
montauk::print(args);
montauk::putchar('\n');
montauk::exit(1);
}
}
zenith::print("PING ");
zenith::print(args);
zenith::print(" (");
montauk::print("PING ");
montauk::print(args);
montauk::print(" (");
print_ip(ip);
zenith::print(")\n");
montauk::print(")\n");
for (int i = 0; i < 4; i++) {
int32_t rtt = zenith::ping(ip, 3000);
int32_t rtt = montauk::ping(ip, 3000);
if (rtt < 0) {
zenith::print(" Request timed out\n");
montauk::print(" Request timed out\n");
} else {
zenith::print(" Reply from ");
montauk::print(" Reply from ");
print_ip(ip);
zenith::print(": time=");
montauk::print(": time=");
print_int((uint64_t)rtt);
zenith::print("ms\n");
montauk::print("ms\n");
}
if (i < 3) {
zenith::sleep_ms(1000);
montauk::sleep_ms(1000);
}
}
zenith::exit(0);
montauk::exit(0);
}
+3 -3
View File
@@ -4,9 +4,9 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
extern "C" void _start() {
zenith::print("Rebooting...\n");
zenith::reset();
montauk::print("Rebooting...\n");
montauk::reset();
}
+95 -95
View File
@@ -1,16 +1,16 @@
/*
* main.cpp
* Interactive shell for ZenithOS
* Interactive shell for MontaukOS
* Copyright (c) 2025 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
using zenith::slen;
using zenith::streq;
using zenith::starts_with;
using zenith::skip_spaces;
using montauk::slen;
using montauk::streq;
using montauk::starts_with;
using montauk::skip_spaces;
static void scopy(char* dst, const char* src, int maxLen) {
int i = 0;
@@ -72,18 +72,18 @@ static const char* history_get(int idx) {
// ---- Prompt ----
static void prompt() {
zenith::print("0:/");
if (cwd[0]) zenith::print(cwd);
zenith::print("> ");
montauk::print("0:/");
if (cwd[0]) montauk::print(cwd);
montauk::print("> ");
}
// ---- Erase current input line on screen ----
static void erase_input(int len) {
// Move cursor to start of input and overwrite with spaces
for (int i = 0; i < len; i++) zenith::putchar('\b');
for (int i = 0; i < len; i++) zenith::putchar(' ');
for (int i = 0; i < len; i++) zenith::putchar('\b');
for (int i = 0; i < len; i++) montauk::putchar('\b');
for (int i = 0; i < len; i++) montauk::putchar(' ');
for (int i = 0; i < len; i++) montauk::putchar('\b');
}
// ---- Replace visible line with new content ----
@@ -95,7 +95,7 @@ static void replace_line(char* line, int* pos, const char* newContent) {
if (newLen > 255) newLen = 255;
for (int i = 0; i < newLen; i++) {
line[i] = newContent[i];
zenith::putchar(newContent[i]);
montauk::putchar(newContent[i]);
}
line[newLen] = '\0';
*pos = newLen;
@@ -104,38 +104,38 @@ static void replace_line(char* line, int* pos, const char* newContent) {
// ---- Builtin: help ----
static void cmd_help() {
zenith::print("Shell builtins:\n");
zenith::print(" help Show this help message\n");
zenith::print(" ls [dir] List files in directory\n");
zenith::print(" cd [dir] Change working directory\n");
zenith::print(" exit Exit the shell\n");
zenith::print("\n");
zenith::print("System commands:\n");
zenith::print(" man <topic> View manual pages\n");
zenith::print(" cat <file> Display file contents\n");
zenith::print(" edit [file] Text editor\n");
zenith::print(" info Show system information\n");
zenith::print(" date Show current date and time\n");
zenith::print(" uptime Show uptime\n");
zenith::print(" clear Clear the screen\n");
zenith::print(" fontscale [n] Set terminal font scale (1-8)\n");
zenith::print(" reset Reboot the system\n");
zenith::print(" shutdown Shut down the system\n");
zenith::print("\n");
zenith::print("Network commands:\n");
zenith::print(" ping <ip> Send ICMP echo requests\n");
zenith::print(" nslookup DNS lookup\n");
zenith::print(" ifconfig Show/set network configuration\n");
zenith::print(" tcpconnect Connect to a TCP server\n");
zenith::print(" irc IRC client\n");
zenith::print(" dhcp DHCP client\n");
zenith::print(" fetch <url> HTTP client\n");
zenith::print(" httpd HTTP server\n");
zenith::print("\n");
zenith::print("Games:\n");
zenith::print(" doom DOOM\n");
zenith::print("\n");
zenith::print("Any .elf on the ramdisk is executable.\n");
montauk::print("Shell builtins:\n");
montauk::print(" help Show this help message\n");
montauk::print(" ls [dir] List files in directory\n");
montauk::print(" cd [dir] Change working directory\n");
montauk::print(" exit Exit the shell\n");
montauk::print("\n");
montauk::print("System commands:\n");
montauk::print(" man <topic> View manual pages\n");
montauk::print(" cat <file> Display file contents\n");
montauk::print(" edit [file] Text editor\n");
montauk::print(" info Show system information\n");
montauk::print(" date Show current date and time\n");
montauk::print(" uptime Show uptime\n");
montauk::print(" clear Clear the screen\n");
montauk::print(" fontscale [n] Set terminal font scale (1-8)\n");
montauk::print(" reset Reboot the system\n");
montauk::print(" shutdown Shut down the system\n");
montauk::print("\n");
montauk::print("Network commands:\n");
montauk::print(" ping <ip> Send ICMP echo requests\n");
montauk::print(" nslookup DNS lookup\n");
montauk::print(" ifconfig Show/set network configuration\n");
montauk::print(" tcpconnect Connect to a TCP server\n");
montauk::print(" irc IRC client\n");
montauk::print(" dhcp DHCP client\n");
montauk::print(" fetch <url> HTTP client\n");
montauk::print(" httpd HTTP server\n");
montauk::print("\n");
montauk::print("Games:\n");
montauk::print(" doom DOOM\n");
montauk::print("\n");
montauk::print("Any .elf on the ramdisk is executable.\n");
}
// Check if a string already has a VFS drive prefix (e.g. "0:/")
@@ -175,9 +175,9 @@ static void cmd_ls(const char* arg) {
build_dir_path(dir, path, sizeof(path));
const char* entries[64];
int count = zenith::readdir(path, entries, 64);
int count = montauk::readdir(path, entries, 64);
if (count <= 0) {
zenith::print("(empty)\n");
montauk::print("(empty)\n");
return;
}
@@ -186,13 +186,13 @@ static void cmd_ls(const char* arg) {
if (dir[0]) prefixLen = slen(dir) + 1;
for (int i = 0; i < count; i++) {
zenith::print(" ");
montauk::print(" ");
if (prefixLen > 0 && starts_with(entries[i], dir)) {
zenith::print(entries[i] + prefixLen);
montauk::print(entries[i] + prefixLen);
} else {
zenith::print(entries[i]);
montauk::print(entries[i]);
}
zenith::putchar('\n');
montauk::putchar('\n');
}
}
@@ -237,10 +237,10 @@ static void cmd_cd(const char* arg) {
char path[128];
build_dir_path(arg, path, sizeof(path));
const char* entries[1];
if (zenith::readdir(path, entries, 1) < 0) {
zenith::print("cd: no such directory: ");
zenith::print(arg);
zenith::putchar('\n');
if (montauk::readdir(path, entries, 1) < 0) {
montauk::print("cd: no such directory: ");
montauk::print(arg);
montauk::putchar('\n');
return;
}
scopy(cwd, arg, sizeof(cwd));
@@ -254,10 +254,10 @@ static void cmd_cd(const char* arg) {
char path[128];
build_dir_path(rel, path, sizeof(path));
const char* entries[1];
if (zenith::readdir(path, entries, 1) < 0) {
zenith::print("cd: no such directory: ");
zenith::print(arg);
zenith::putchar('\n');
if (montauk::readdir(path, entries, 1) < 0) {
montauk::print("cd: no such directory: ");
montauk::print(arg);
montauk::putchar('\n');
return;
}
scopy(cwd, rel, sizeof(cwd));
@@ -278,11 +278,11 @@ static void cmd_cd(const char* arg) {
char path[128];
build_dir_path(target, path, sizeof(path));
const char* entries[1];
int count = zenith::readdir(path, entries, 1);
int count = montauk::readdir(path, entries, 1);
if (count < 0) {
zenith::print("cd: no such directory: ");
zenith::print(arg);
zenith::putchar('\n');
montauk::print("cd: no such directory: ");
montauk::print(arg);
montauk::putchar('\n');
return;
}
@@ -295,17 +295,17 @@ static void cmd_cd(const char* arg) {
static void cmd_man(const char* arg) {
arg = skip_spaces(arg);
if (*arg == '\0') {
zenith::print("Usage: man <topic>\n");
zenith::print(" man <section> <topic>\n");
zenith::print("Try: man intro\n");
montauk::print("Usage: man <topic>\n");
montauk::print(" man <section> <topic>\n");
montauk::print("Try: man intro\n");
return;
}
int pid = zenith::spawn("0:/os/man.elf", arg);
int pid = montauk::spawn("0:/os/man.elf", arg);
if (pid < 0) {
zenith::print("Error: failed to start man viewer\n");
montauk::print("Error: failed to start man viewer\n");
} else {
zenith::waitpid(pid);
montauk::waitpid(pid);
}
}
@@ -314,13 +314,13 @@ static void cmd_man(const char* arg) {
// Try to spawn an ELF at the given path. Returns true on success.
static bool try_exec(const char* path, const char* args) {
// Check if the file exists before asking the kernel to load it
int h = zenith::open(path);
int h = montauk::open(path);
if (h < 0) return false;
zenith::close(h);
montauk::close(h);
int pid = zenith::spawn(path, args);
int pid = montauk::spawn(path, args);
if (pid < 0) return false;
zenith::waitpid(pid);
montauk::waitpid(pid);
return true;
}
@@ -362,9 +362,9 @@ static void resolve_args(const char* args, char* out, int outMax) {
// Only use the resolved path if the file actually exists;
// otherwise pass the argument through unchanged (it may be
// a hostname, IP address, URL, or other non-path argument).
int h = zenith::open(candidate);
int h = montauk::open(candidate);
if (h >= 0) {
zenith::close(h);
montauk::close(h);
for (int k = 0; k < r && o < outMax - 1; k++) out[o++] = candidate[k];
} else {
for (int k = 0; k < tokLen && o < outMax - 1; k++) out[o++] = tokStart[k];
@@ -415,8 +415,8 @@ static void exec_external(const char* cmd, const char* args) {
if (try_exec(path, finalArgs)) return;
// Not found
zenith::print(cmd);
zenith::print(": command not found\n");
montauk::print(cmd);
montauk::print(": command not found\n");
}
// ---- Command dispatch ----
@@ -450,8 +450,8 @@ static void process_command(const char* line) {
} else if (streq(cmd, "man")) {
cmd_man(args ? args : "");
} else if (streq(cmd, "exit")) {
zenith::print("Goodbye.\n");
zenith::exit(0);
montauk::print("Goodbye.\n");
montauk::exit(0);
} else {
// External command -- pass full argument string
exec_external(cmd, args);
@@ -468,13 +468,13 @@ static constexpr uint8_t SC_RIGHT = 0x4D;
// ---- Entry point ----
extern "C" void _start() {
zenith::print("\n");
zenith::print(" ZenithOS\n");
zenith::print(" Copyright (c) 2025-2026 Daniel Hammer\n");
zenith::print("\n");
montauk::print("\n");
montauk::print(" MontaukOS\n");
montauk::print(" Copyright (c) 2025-2026 Daniel Hammer\n");
montauk::print("\n");
zenith::print(" Type 'help' for available commands.\n");
zenith::print("\n");
montauk::print(" Type 'help' for available commands.\n");
montauk::print("\n");
char line[256];
int pos = 0;
@@ -483,13 +483,13 @@ extern "C" void _start() {
prompt();
while (true) {
if (!zenith::is_key_available()) {
zenith::yield();
if (!montauk::is_key_available()) {
montauk::yield();
continue;
}
Zenith::KeyEvent ev;
zenith::getkey(&ev);
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (!ev.pressed) continue;
@@ -524,7 +524,7 @@ extern "C" void _start() {
}
if (ev.ascii == '\n') {
zenith::putchar('\n');
montauk::putchar('\n');
line[pos] = '\0';
history_add(line);
process_command(line);
@@ -534,13 +534,13 @@ extern "C" void _start() {
} else if (ev.ascii == '\b') {
if (pos > 0) {
pos--;
zenith::putchar('\b');
zenith::putchar(' ');
zenith::putchar('\b');
montauk::putchar('\b');
montauk::putchar(' ');
montauk::putchar('\b');
}
} else if (ev.ascii >= ' ' && pos < 255) {
line[pos++] = ev.ascii;
zenith::putchar(ev.ascii);
montauk::putchar(ev.ascii);
}
}
}
+3 -3
View File
@@ -4,9 +4,9 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
extern "C" void _start() {
zenith::print("Shutting down...\n");
zenith::shutdown();
montauk::print("Shutting down...\n");
montauk::shutdown();
}
+49 -49
View File
@@ -4,14 +4,14 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
using zenith::skip_spaces;
using montauk::skip_spaces;
static void print_int(uint64_t n) {
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
char buf[20];
@@ -21,7 +21,7 @@ static void print_int(uint64_t n) {
n /= 10;
}
for (int j = i - 1; j >= 0; j--) {
zenith::putchar(buf[j]);
montauk::putchar(buf[j]);
}
}
@@ -55,11 +55,11 @@ static bool parse_ip(const char* s, uint32_t* out) {
static void print_ip(uint32_t ip) {
print_int(ip & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 8) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 16) & 0xFF);
zenith::putchar('.');
montauk::putchar('.');
print_int((ip >> 24) & 0xFF);
}
@@ -78,11 +78,11 @@ static bool parse_uint16(const char* s, uint16_t* out) {
extern "C" void _start() {
char args[256];
int len = zenith::getargs(args, sizeof(args));
int len = montauk::getargs(args, sizeof(args));
if (len <= 0 || args[0] == '\0') {
zenith::print("Usage: tcpconnect <host> <port>\n");
zenith::exit(1);
montauk::print("Usage: tcpconnect <host> <port>\n");
montauk::exit(1);
}
// Parse host (IP or hostname)
@@ -96,49 +96,49 @@ extern "C" void _start() {
uint32_t ip;
if (!parse_ip(hostStr, &ip)) {
ip = zenith::resolve(hostStr);
ip = montauk::resolve(hostStr);
if (ip == 0) {
zenith::print("Could not resolve: ");
zenith::print(hostStr);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Could not resolve: ");
montauk::print(hostStr);
montauk::putchar('\n');
montauk::exit(1);
}
}
// Parse port
const char* portStr = skip_spaces(args + i);
if (*portStr == '\0') {
zenith::print("Usage: tcpconnect <ip> <port>\n");
zenith::exit(1);
montauk::print("Usage: tcpconnect <ip> <port>\n");
montauk::exit(1);
}
uint16_t port;
if (!parse_uint16(portStr, &port)) {
zenith::print("Invalid port: ");
zenith::print(portStr);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("Invalid port: ");
montauk::print(portStr);
montauk::putchar('\n');
montauk::exit(1);
}
// Create socket
int fd = zenith::socket(Zenith::SOCK_TCP);
int fd = montauk::socket(Montauk::SOCK_TCP);
if (fd < 0) {
zenith::print("Error: failed to create socket\n");
zenith::exit(1);
montauk::print("Error: failed to create socket\n");
montauk::exit(1);
}
zenith::print("Connecting to ");
montauk::print("Connecting to ");
print_ip(ip);
zenith::putchar(':');
montauk::putchar(':');
print_int(port);
zenith::print("...\n");
montauk::print("...\n");
if (zenith::connect(fd, ip, port) < 0) {
zenith::print("Error: connection failed\n");
zenith::closesocket(fd);
zenith::exit(1);
if (montauk::connect(fd, ip, port) < 0) {
montauk::print("Error: connection failed\n");
montauk::closesocket(fd);
montauk::exit(1);
}
zenith::print("Connected! Type to send, Ctrl+Q to disconnect.\n");
montauk::print("Connected! Type to send, Ctrl+Q to disconnect.\n");
// Interactive send/receive loop
char sendBuf[256];
@@ -147,51 +147,51 @@ extern "C" void _start() {
while (true) {
// Poll for received data (non-blocking)
int r = zenith::recv(fd, recvBuf, sizeof(recvBuf) - 1);
int r = montauk::recv(fd, recvBuf, sizeof(recvBuf) - 1);
if (r < 0) {
zenith::print("\nConnection closed by remote.\n");
montauk::print("\nConnection closed by remote.\n");
break;
}
if (r > 0) {
recvBuf[r] = '\0';
zenith::print((const char*)recvBuf);
montauk::print((const char*)recvBuf);
}
// Poll keyboard
if (zenith::is_key_available()) {
Zenith::KeyEvent ev;
zenith::getkey(&ev);
if (montauk::is_key_available()) {
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (!ev.pressed) continue;
// Ctrl+Q to quit
if (ev.ctrl && (ev.ascii == 'q' || ev.ascii == 'Q')) {
zenith::print("\nDisconnecting...\n");
montauk::print("\nDisconnecting...\n");
break;
}
if (ev.ascii == '\n') {
sendBuf[sendPos++] = '\n';
zenith::putchar('\n');
zenith::send(fd, sendBuf, sendPos);
montauk::putchar('\n');
montauk::send(fd, sendBuf, sendPos);
sendPos = 0;
} else if (ev.ascii == '\b') {
if (sendPos > 0) {
sendPos--;
zenith::putchar('\b');
zenith::putchar(' ');
zenith::putchar('\b');
montauk::putchar('\b');
montauk::putchar(' ');
montauk::putchar('\b');
}
} else if (ev.ascii >= ' ' && sendPos < 254) {
sendBuf[sendPos++] = ev.ascii;
zenith::putchar(ev.ascii);
montauk::putchar(ev.ascii);
}
} else {
// No key and no data -- yield to avoid busy-spinning
zenith::yield();
montauk::yield();
}
}
zenith::closesocket(fd);
zenith::exit(0);
montauk::closesocket(fd);
montauk::exit(0);
}
+9 -9
View File
@@ -4,11 +4,11 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <montauk/syscall.h>
static void print_int(uint64_t n) {
if (n == 0) {
zenith::putchar('0');
montauk::putchar('0');
return;
}
char buf[20];
@@ -18,23 +18,23 @@ static void print_int(uint64_t n) {
n /= 10;
}
for (int j = i - 1; j >= 0; j--) {
zenith::putchar(buf[j]);
montauk::putchar(buf[j]);
}
}
extern "C" void _start() {
uint64_t ms = zenith::get_milliseconds();
uint64_t ms = montauk::get_milliseconds();
uint64_t secs = ms / 1000;
uint64_t mins = secs / 60;
secs %= 60;
ms %= 1000;
zenith::print("Uptime: ");
montauk::print("Uptime: ");
print_int(mins);
zenith::print("m ");
montauk::print("m ");
print_int(secs);
zenith::print("s ");
montauk::print("s ");
print_int(ms);
zenith::print("ms\n");
zenith::exit(0);
montauk::print("ms\n");
montauk::exit(0);
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Makefile for weather (standalone Weather GUI client) on ZenithOS
# Makefile for weather (standalone Weather GUI client) on MontaukOS
# Copyright (c) 2026 Daniel Hammer
MAKEFLAGS += -rR
+24 -24
View File
@@ -1,14 +1,14 @@
/*
* main.cpp
* ZenithOS Weather app - standalone Window Server process
* MontaukOS Weather app - standalone Window Server process
* Fetches current weather from wttr.in via HTTPS (BearSSL)
* Displays temperature, description, feels like, and location
* Copyright (c) 2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <zenith/heap.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <gui/gui.hpp>
#include <gui/svg.hpp>
#include <gui/truetype.hpp>
@@ -316,7 +316,7 @@ static void apply_scale(int scale) {
static void do_fetch() {
// Lazy init: resolve DNS and load CA certificates once
if (!g_tls_ready) {
g_server_ip = zenith::resolve(WTTR_HOST);
g_server_ip = montauk::resolve(WTTR_HOST);
if (g_server_ip == 0) {
snprintf(g_status, sizeof(g_status),
"Error: could not resolve %s", WTTR_HOST);
@@ -334,7 +334,7 @@ static void do_fetch() {
int reqLen = snprintf(request, sizeof(request),
"GET /?format=j1 HTTP/1.0\r\n"
"Host: %s\r\n"
"User-Agent: ZenithOS/1.0 weather\r\n"
"User-Agent: MontaukOS/1.0 weather\r\n"
"Accept: application/json\r\n"
"Connection: close\r\n"
"\r\n",
@@ -498,26 +498,26 @@ static void render(uint32_t* pixels) {
extern "C" void _start() {
// Allocate response buffer from heap
g_resp_buf = (char*)malloc(RESP_MAX + 1);
if (!g_resp_buf) zenith::exit(1);
if (!g_resp_buf) montauk::exit(1);
// Load fonts
auto load_font = [](const char* path) -> TrueTypeFont* {
TrueTypeFont* f = (TrueTypeFont*)zenith::malloc(sizeof(TrueTypeFont));
TrueTypeFont* f = (TrueTypeFont*)montauk::malloc(sizeof(TrueTypeFont));
if (!f) return nullptr;
zenith::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { zenith::mfree(f); return nullptr; }
montauk::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { montauk::mfree(f); return nullptr; }
return f;
};
g_font = load_font("0:/fonts/Roboto-Medium.ttf");
g_font_bold = load_font("0:/fonts/Roboto-Bold.ttf");
if (!g_font) zenith::exit(1);
if (!g_font) montauk::exit(1);
apply_scale(zenith::win_getscale());
apply_scale(montauk::win_getscale());
// Create window
Zenith::WinCreateResult wres;
if (zenith::win_create("Weather", INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
zenith::exit(1);
Montauk::WinCreateResult wres;
if (montauk::win_create("Weather", INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
montauk::exit(1);
int win_id = wres.id;
uint32_t* pixels = (uint32_t*)(uintptr_t)wres.pixelVa;
@@ -525,20 +525,20 @@ extern "C" void _start() {
// Initial fetch on startup
g_phase = AppPhase::LOADING;
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
do_fetch();
// Event loop
while (true) {
Zenith::WinEvent ev;
int r = zenith::win_poll(win_id, &ev);
Montauk::WinEvent ev;
int r = montauk::win_poll(win_id, &ev);
if (r < 0) break;
if (r == 0) {
zenith::sleep_ms(16);
montauk::sleep_ms(16);
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
continue;
}
@@ -559,17 +559,17 @@ extern "C" void _start() {
my >= btn_y && my < btn_y + BTN_H) {
g_phase = AppPhase::LOADING;
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
do_fetch();
}
}
}
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
}
if (g_icon.pixels) svg_free(g_icon);
zenith::win_destroy(win_id);
zenith::exit(0);
montauk::win_destroy(win_id);
montauk::exit(0);
}
+8 -8
View File
@@ -1,13 +1,13 @@
/*
* stb_truetype_impl.cpp
* Single compilation unit for stb_truetype in ZenithOS freestanding environment
* Single compilation unit for stb_truetype in MontaukOS freestanding environment
* Copyright (c) 2026 Daniel Hammer
*/
#include <cstdint>
#include <cstddef>
#include <zenith/heap.h>
#include <zenith/string.h>
#include <montauk/heap.h>
#include <montauk/string.h>
#include <gui/stb_math.h>
// Override all stb_truetype dependencies before including the implementation
@@ -21,13 +21,13 @@
#define STBTT_acos(x) stb_acos(x)
#define STBTT_fabs(x) stb_fabs(x)
#define STBTT_malloc(x,u) ((void)(u), zenith::malloc(x))
#define STBTT_free(x,u) ((void)(u), zenith::mfree(x))
#define STBTT_malloc(x,u) ((void)(u), montauk::malloc(x))
#define STBTT_free(x,u) ((void)(u), montauk::mfree(x))
#define STBTT_memcpy(d,s,n) zenith::memcpy(d,s,n)
#define STBTT_memset(d,v,n) zenith::memset(d,v,n)
#define STBTT_memcpy(d,s,n) montauk::memcpy(d,s,n)
#define STBTT_memset(d,v,n) montauk::memset(d,v,n)
#define STBTT_strlen(x) zenith::slen(x)
#define STBTT_strlen(x) montauk::slen(x)
#define STBTT_assert(x) ((void)(x))
+1 -1
View File
@@ -1,4 +1,4 @@
# Makefile for wiki (Wikipedia client) on ZenithOS
# Makefile for wiki (Wikipedia client) on MontaukOS
# Copyright (c) 2025-2026 Daniel Hammer
MAKEFLAGS += -rR
+87 -87
View File
@@ -1,6 +1,6 @@
/*
* main.cpp
* Wikipedia client for ZenithOS (TLS 1.2 via BearSSL)
* Wikipedia client for MontaukOS (TLS 1.2 via BearSSL)
* Interactive fullscreen pager with colored output
* Usage: wiki <title> Show article summary
* wiki -f <title> Show full article
@@ -8,8 +8,8 @@
* Copyright (c) 2025-2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <tls/tls.hpp>
extern "C" {
@@ -18,7 +18,7 @@ extern "C" {
#include <stdio.h>
}
using zenith::skip_spaces;
using montauk::skip_spaces;
static constexpr int RESP_MAX = 131072; // 128 KB
static const char WIKI_HOST[] = "en.wikipedia.org";
@@ -49,7 +49,7 @@ static int g_sbPos = 0;
static void sb_reset() { g_sbPos = 0; }
static void sb_putc(char c) { if (g_sbPos < SB_SIZE - 1) g_sb[g_sbPos++] = c; }
static void sb_puts(const char* s) { while (*s && g_sbPos < SB_SIZE - 1) g_sb[g_sbPos++] = *s++; }
static void sb_flush() { g_sb[g_sbPos] = '\0'; zenith::print(g_sb); }
static void sb_flush() { g_sb[g_sbPos] = '\0'; montauk::print(g_sb); }
static int int_to_buf(char* buf, int n) {
if (n <= 0) { buf[0] = '0'; return 1; }
@@ -72,9 +72,9 @@ static void sb_cursor_to(int row, int col) {
// ---- Keyboard abort check for TLS ----
static bool check_keyboard_abort() {
if (zenith::is_key_available()) {
Zenith::KeyEvent ev;
zenith::getkey(&ev);
if (montauk::is_key_available()) {
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (ev.pressed && ev.ctrl && ev.ascii == 'q') return true;
}
return false;
@@ -87,7 +87,7 @@ static int wiki_fetch(const char* path, char* respBuf, int respMax) {
int reqLen = snprintf(request, sizeof(request),
"GET %s HTTP/1.0\r\n"
"Host: %s\r\n"
"User-Agent: ZenithOS/1.0 wiki\r\n"
"User-Agent: MontaukOS/1.0 wiki\r\n"
"Accept: application/json\r\n"
"Connection: close\r\n"
"\r\n",
@@ -451,11 +451,11 @@ static void render_pager(WikiLine* lines, int totalLines, int scroll,
static void run_pager(WikiLine* lines, int totalLines, const char* title,
const char* modeLabel, bool useAltScreen) {
int cols = 80, rows = 25;
zenith::termsize(&cols, &rows);
montauk::termsize(&cols, &rows);
if (useAltScreen) {
zenith::print("\033[?1049h");
zenith::print("\033[?25l");
montauk::print("\033[?1049h");
montauk::print("\033[?25l");
}
int scroll = 0;
@@ -466,10 +466,10 @@ static void run_pager(WikiLine* lines, int totalLines, const char* title,
bool running = true;
while (running) {
while (!zenith::is_key_available()) zenith::yield();
while (!montauk::is_key_available()) montauk::yield();
Zenith::KeyEvent ev;
zenith::getkey(&ev);
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (!ev.pressed) continue;
int contentRows = rows - 1;
@@ -503,8 +503,8 @@ static void run_pager(WikiLine* lines, int totalLines, const char* title,
}
if (useAltScreen) {
zenith::print("\033[?25h");
zenith::print("\033[?1049l");
montauk::print("\033[?25h");
montauk::print("\033[?1049l");
}
}
@@ -629,10 +629,10 @@ static int run_search(char titles[][256], int count, const char* query,
render_search(titles, count, query, rows, cols);
while (true) {
while (!zenith::is_key_available()) zenith::yield();
while (!montauk::is_key_available()) montauk::yield();
Zenith::KeyEvent ev;
zenith::getkey(&ev);
Montauk::KeyEvent ev;
montauk::getkey(&ev);
if (!ev.pressed) continue;
if (ev.ascii == 'q' || (ev.ctrl && ev.ascii == 'q'))
@@ -650,19 +650,19 @@ static int run_search(char titles[][256], int count, const char* query,
extern "C" void _start() {
static char argbuf[1024]; // keep off stack (16KB limit)
zenith::getargs(argbuf, sizeof(argbuf));
montauk::getargs(argbuf, sizeof(argbuf));
const char* arg = skip_spaces(argbuf);
if (*arg == '\0') {
zenith::print("\033[1;36mwiki\033[0m - Wikipedia article viewer\n\n");
zenith::print("Usage: wiki <title> Show article summary\n");
zenith::print(" wiki -f <title> Show full article\n");
zenith::print(" wiki -s <query> Search for articles\n");
zenith::print("\nExamples:\n");
zenith::print(" wiki Linux\n");
zenith::print(" wiki -f C programming language\n");
zenith::print(" wiki -s operating system\n");
zenith::exit(0);
montauk::print("\033[1;36mwiki\033[0m - Wikipedia article viewer\n\n");
montauk::print("Usage: wiki <title> Show article summary\n");
montauk::print(" wiki -f <title> Show full article\n");
montauk::print(" wiki -s <query> Search for articles\n");
montauk::print("\nExamples:\n");
montauk::print(" wiki Linux\n");
montauk::print(" wiki -f C programming language\n");
montauk::print(" wiki -s operating system\n");
montauk::exit(0);
}
// Parse mode flag
@@ -679,8 +679,8 @@ extern "C" void _start() {
}
if (*arg == '\0') {
zenith::print("\033[1;31mError:\033[0m no article title or search query\n");
zenith::exit(1);
montauk::print("\033[1;31mError:\033[0m no article title or search query\n");
montauk::exit(1);
}
// Trim trailing spaces from query
@@ -692,20 +692,20 @@ extern "C" void _start() {
// Initialize: resolve DNS and load certs
if (mode != MODE_DUMP)
zenith::print("\033[1;33mConnecting to Wikipedia...\033[0m\n");
montauk::print("\033[1;33mConnecting to Wikipedia...\033[0m\n");
g_serverIp = zenith::resolve(WIKI_HOST);
g_serverIp = montauk::resolve(WIKI_HOST);
if (g_serverIp == 0) {
if (mode == MODE_DUMP) { zenith::print("\x01"); zenith::sleep_ms(100); zenith::exit(1); }
zenith::print("\033[1;31mError:\033[0m could not resolve en.wikipedia.org\n");
zenith::exit(1);
if (mode == MODE_DUMP) { montauk::print("\x01"); montauk::sleep_ms(100); montauk::exit(1); }
montauk::print("\033[1;31mError:\033[0m could not resolve en.wikipedia.org\n");
montauk::exit(1);
}
g_tas = tls::load_trust_anchors();
if (g_tas.count == 0) {
if (mode == MODE_DUMP) { zenith::print("\x01"); zenith::sleep_ms(100); zenith::exit(1); }
zenith::print("\033[1;31mError:\033[0m no CA certificates loaded\n");
zenith::exit(1);
if (mode == MODE_DUMP) { montauk::print("\x01"); montauk::sleep_ms(100); montauk::exit(1); }
montauk::print("\033[1;31mError:\033[0m no CA certificates loaded\n");
montauk::exit(1);
}
// Allocate shared buffers
@@ -713,8 +713,8 @@ extern "C" void _start() {
WikiLine* lines = (WikiLine*)malloc(MAX_LINES * sizeof(WikiLine));
char* extractBuf = (char*)malloc(RESP_MAX);
if (!respBuf || !lines || !extractBuf) {
zenith::print("\033[1;31mError:\033[0m out of memory\n");
zenith::exit(1);
montauk::print("\033[1;31mError:\033[0m out of memory\n");
montauk::exit(1);
}
if (mode == MODE_DUMP) {
@@ -727,24 +727,24 @@ extern "C" void _start() {
int respLen = wiki_fetch(path, respBuf, RESP_MAX);
if (respLen <= 0) {
zenith::print("\x01"); // error sentinel
zenith::sleep_ms(100);
zenith::exit(1);
montauk::print("\x01"); // error sentinel
montauk::sleep_ms(100);
montauk::exit(1);
}
respBuf[respLen] = '\0';
int headerEnd = find_header_end(respBuf, respLen);
if (headerEnd < 0) {
zenith::print("\x01");
zenith::sleep_ms(100);
zenith::exit(1);
montauk::print("\x01");
montauk::sleep_ms(100);
montauk::exit(1);
}
int statusCode = parse_status_code(respBuf, headerEnd);
if (statusCode == 404) {
zenith::print("\x01");
zenith::sleep_ms(100);
zenith::exit(1);
montauk::print("\x01");
montauk::sleep_ms(100);
montauk::exit(1);
}
// Output raw JSON body in chunks to avoid overflowing
@@ -758,14 +758,14 @@ extern "C" void _start() {
if (n > 2048) n = 2048;
for (int ci = 0; ci < n; ci++) chunk[ci] = body[sent + ci];
chunk[n] = '\0';
zenith::print(chunk);
montauk::print(chunk);
sent += n;
if (sent < bodyLen) zenith::sleep_ms(20);
if (sent < bodyLen) montauk::sleep_ms(20);
}
zenith::putchar('\x04'); // EOT sentinel
montauk::putchar('\x04'); // EOT sentinel
// Brief delay so parent can drain the ring buffer before we exit
zenith::sleep_ms(100);
zenith::exit(0);
montauk::sleep_ms(100);
montauk::exit(0);
} else if (mode == MODE_SEARCH) {
// ---- Search mode ----
static char path[2048], encoded[1024];
@@ -776,15 +776,15 @@ extern "C" void _start() {
int respLen = wiki_fetch(path, respBuf, RESP_MAX);
if (respLen <= 0) {
zenith::print("\033[1;31mError:\033[0m no response from Wikipedia\n");
zenith::exit(1);
montauk::print("\033[1;31mError:\033[0m no response from Wikipedia\n");
montauk::exit(1);
}
respBuf[respLen] = '\0';
int headerEnd = find_header_end(respBuf, respLen);
if (headerEnd < 0) {
zenith::print("\033[1;31mError:\033[0m malformed response\n");
zenith::exit(1);
montauk::print("\033[1;31mError:\033[0m malformed response\n");
montauk::exit(1);
}
const char* body = respBuf + headerEnd;
@@ -794,18 +794,18 @@ extern "C" void _start() {
int titleCount = parse_search_titles(body, bodyLen, titles, MAX_SEARCH_RESULTS);
if (titleCount == 0) {
zenith::print("\033[33mNo results found for \"");
zenith::print(query);
zenith::print("\"\033[0m\n");
zenith::exit(0);
montauk::print("\033[33mNo results found for \"");
montauk::print(query);
montauk::print("\"\033[0m\n");
montauk::exit(0);
}
int cols = 80, rows = 25;
zenith::termsize(&cols, &rows);
montauk::termsize(&cols, &rows);
// Enter alternate screen for interactive search
zenith::print("\033[?1049h");
zenith::print("\033[?25l");
montauk::print("\033[?1049h");
montauk::print("\033[?25l");
bool searchRunning = true;
while (searchRunning) {
@@ -837,8 +837,8 @@ extern "C" void _start() {
sb_cursor_to(infoRow, 3);
sb_puts("\033[2K\033[1;31mFetch failed. Press any key.\033[0m");
sb_flush();
while (!zenith::is_key_available()) zenith::yield();
Zenith::KeyEvent ev; zenith::getkey(&ev);
while (!montauk::is_key_available()) montauk::yield();
Montauk::KeyEvent ev; montauk::getkey(&ev);
continue;
}
respBuf[respLen] = '\0';
@@ -855,8 +855,8 @@ extern "C" void _start() {
sb_cursor_to(infoRow, 3);
sb_puts("\033[2K\033[1;31mArticle not found. Press any key.\033[0m");
sb_flush();
while (!zenith::is_key_available()) zenith::yield();
Zenith::KeyEvent ev; zenith::getkey(&ev);
while (!montauk::is_key_available()) montauk::yield();
Montauk::KeyEvent ev; montauk::getkey(&ev);
continue;
}
@@ -876,8 +876,8 @@ extern "C" void _start() {
}
// Exit alternate screen
zenith::print("\033[?25h");
zenith::print("\033[?1049l");
montauk::print("\033[?25h");
montauk::print("\033[?1049l");
} else {
// ---- Summary or Full Article mode ----
@@ -895,15 +895,15 @@ extern "C" void _start() {
int respLen = wiki_fetch(path, respBuf, RESP_MAX);
if (respLen <= 0) {
zenith::print("\033[1;31mError:\033[0m no response from Wikipedia\n");
zenith::exit(1);
montauk::print("\033[1;31mError:\033[0m no response from Wikipedia\n");
montauk::exit(1);
}
respBuf[respLen] = '\0';
int headerEnd = find_header_end(respBuf, respLen);
if (headerEnd < 0) {
zenith::print("\033[1;31mError:\033[0m malformed response\n");
zenith::exit(1);
montauk::print("\033[1;31mError:\033[0m malformed response\n");
montauk::exit(1);
}
int statusCode = parse_status_code(respBuf, headerEnd);
@@ -911,10 +911,10 @@ extern "C" void _start() {
int bodyLen = respLen - headerEnd;
if (statusCode == 404) {
zenith::print("\033[1;31mArticle not found:\033[0m ");
zenith::print(query);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("\033[1;31mArticle not found:\033[0m ");
montauk::print(query);
montauk::putchar('\n');
montauk::exit(1);
}
static char title[512], description[512];
@@ -928,14 +928,14 @@ extern "C" void _start() {
extractBuf, RESP_MAX - 1);
if (extractLen == 0) {
zenith::print("\033[1;31mArticle not found:\033[0m ");
zenith::print(query);
zenith::putchar('\n');
zenith::exit(1);
montauk::print("\033[1;31mArticle not found:\033[0m ");
montauk::print(query);
montauk::putchar('\n');
montauk::exit(1);
}
int cols = 80;
zenith::termsize(&cols, nullptr);
montauk::termsize(&cols, nullptr);
int totalLines = build_lines(lines, MAX_LINES,
title, description, extractBuf, extractLen,
@@ -945,5 +945,5 @@ extern "C" void _start() {
run_pager(lines, totalLines, title, modeLabel, true);
}
zenith::exit(0);
montauk::exit(0);
}
+1 -1
View File
@@ -1,4 +1,4 @@
# Makefile for wikipedia (standalone Wikipedia GUI client) on ZenithOS
# Makefile for wikipedia (standalone Wikipedia GUI client) on MontaukOS
# Copyright (c) 2026 Daniel Hammer
MAKEFLAGS += -rR
+26 -26
View File
@@ -1,13 +1,13 @@
/*
* main.cpp
* ZenithOS Wikipedia GUI client - standalone Window Server process
* MontaukOS Wikipedia GUI client - standalone Window Server process
* Fetches articles via TLS (BearSSL), renders with Roboto TTF
* Copyright (c) 2026 Daniel Hammer
*/
#include <zenith/syscall.h>
#include <zenith/string.h>
#include <zenith/heap.h>
#include <montauk/syscall.h>
#include <montauk/string.h>
#include <montauk/heap.h>
#include <gui/gui.hpp>
#include <gui/truetype.hpp>
#include <tls/tls.hpp>
@@ -139,7 +139,7 @@ static int wiki_fetch(const char* path, char* respBuf, int respMax) {
int reqLen = snprintf(request, sizeof(request),
"GET %s HTTP/1.0\r\n"
"Host: %s\r\n"
"User-Agent: ZenithOS/1.0 wikipedia\r\n"
"User-Agent: MontaukOS/1.0 wikipedia\r\n"
"Accept: application/json\r\n"
"Connection: close\r\n"
"\r\n",
@@ -381,7 +381,7 @@ static void build_display_lines(const char* title, const char* extract, int extr
static void do_search(const char* query) {
// Lazy TLS/DNS init
if (!g_tls_ready) {
g_server_ip = zenith::resolve(WIKI_HOST);
g_server_ip = montauk::resolve(WIKI_HOST);
if (g_server_ip == 0) {
snprintf(g_status, sizeof(g_status),
"Error: could not resolve en.wikipedia.org");
@@ -536,52 +536,52 @@ static void render(uint32_t* pixels) {
extern "C" void _start() {
// Allocate large buffers from heap
g_lines = (WikiLine*)zenith::malloc(MAX_LINES * sizeof(WikiLine));
g_lines = (WikiLine*)montauk::malloc(MAX_LINES * sizeof(WikiLine));
g_resp_buf = (char*)malloc(RESP_MAX + 1);
g_extract_buf = (char*)malloc(RESP_MAX + 1);
if (!g_lines || !g_resp_buf || !g_extract_buf) zenith::exit(1);
if (!g_lines || !g_resp_buf || !g_extract_buf) montauk::exit(1);
// Load fonts
auto load_font = [](const char* path) -> TrueTypeFont* {
TrueTypeFont* f = (TrueTypeFont*)zenith::malloc(sizeof(TrueTypeFont));
TrueTypeFont* f = (TrueTypeFont*)montauk::malloc(sizeof(TrueTypeFont));
if (!f) return nullptr;
zenith::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { zenith::mfree(f); return nullptr; }
montauk::memset(f, 0, sizeof(TrueTypeFont));
if (!f->init(path)) { montauk::mfree(f); return nullptr; }
return f;
};
g_font = load_font("0:/fonts/Roboto-Medium.ttf");
g_font_bold = load_font("0:/fonts/Roboto-Bold.ttf");
g_font_serif = load_font("0:/fonts/NotoSerif-SemiBold.ttf");
if (!g_font) zenith::exit(1);
if (!g_font) montauk::exit(1);
g_line_h = g_font->get_line_height(FONT_SIZE) + 4;
apply_scale(zenith::win_getscale());
apply_scale(montauk::win_getscale());
// Create window
Zenith::WinCreateResult wres;
if (zenith::win_create("Wikipedia", INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
zenith::exit(1);
Montauk::WinCreateResult wres;
if (montauk::win_create("Wikipedia", INIT_W, INIT_H, &wres) < 0 || wres.id < 0)
montauk::exit(1);
int win_id = wres.id;
uint32_t* pixels = (uint32_t*)(uintptr_t)wres.pixelVa;
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
bool search_pending = false;
while (true) {
Zenith::WinEvent ev;
int r = zenith::win_poll(win_id, &ev);
Montauk::WinEvent ev;
int r = montauk::win_poll(win_id, &ev);
if (r < 0) break; // window closed / error
if (r == 0) {
// No event — idle at ~60 fps
zenith::sleep_ms(16);
montauk::sleep_ms(16);
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
continue;
}
@@ -599,7 +599,7 @@ extern "C" void _start() {
int new_w = ev.resize.w;
int new_h = ev.resize.h;
if (new_w > 0 && new_h > 0 && (new_w != g_win_w || new_h != g_win_h)) {
uint64_t new_va = zenith::win_resize(win_id, new_w, new_h);
uint64_t new_va = montauk::win_resize(win_id, new_w, new_h);
if (new_va != 0) {
pixels = (uint32_t*)(uintptr_t)new_va;
g_win_w = new_w;
@@ -667,14 +667,14 @@ extern "C" void _start() {
search_pending = false;
g_phase = AppPhase::LOADING;
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
do_search(g_query); // blocking
}
render(pixels);
zenith::win_present(win_id);
montauk::win_present(win_id);
}
zenith::win_destroy(win_id);
zenith::exit(0);
montauk::win_destroy(win_id);
montauk::exit(0);
}
+8 -8
View File
@@ -1,13 +1,13 @@
/*
* stb_truetype_impl.cpp
* Single compilation unit for stb_truetype in ZenithOS freestanding environment
* Single compilation unit for stb_truetype in MontaukOS freestanding environment
* Copyright (c) 2026 Daniel Hammer
*/
#include <cstdint>
#include <cstddef>
#include <zenith/heap.h>
#include <zenith/string.h>
#include <montauk/heap.h>
#include <montauk/string.h>
#include <gui/stb_math.h>
// Override all stb_truetype dependencies before including the implementation
@@ -21,13 +21,13 @@
#define STBTT_acos(x) stb_acos(x)
#define STBTT_fabs(x) stb_fabs(x)
#define STBTT_malloc(x,u) ((void)(u), zenith::malloc(x))
#define STBTT_free(x,u) ((void)(u), zenith::mfree(x))
#define STBTT_malloc(x,u) ((void)(u), montauk::malloc(x))
#define STBTT_free(x,u) ((void)(u), montauk::mfree(x))
#define STBTT_memcpy(d,s,n) zenith::memcpy(d,s,n)
#define STBTT_memset(d,v,n) zenith::memset(d,v,n)
#define STBTT_memcpy(d,s,n) montauk::memcpy(d,s,n)
#define STBTT_memset(d,v,n) montauk::memset(d,v,n)
#define STBTT_strlen(x) zenith::slen(x)
#define STBTT_strlen(x) montauk::slen(x)
#define STBTT_assert(x) ((void)(x))