feat: rename 'ZenithOS' => 'MontaukOS' and fix build system issues
This commit is contained in:
+12
-3
@@ -9,8 +9,10 @@ ARCH := x86_64
|
||||
TOOLCHAIN_PREFIX := $(shell cd .. && pwd)/toolchain/local/bin/x86_64-elf-
|
||||
ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
|
||||
CXX := $(TOOLCHAIN_PREFIX)g++
|
||||
CC := $(TOOLCHAIN_PREFIX)gcc
|
||||
else
|
||||
CXX := g++
|
||||
CC := gcc
|
||||
endif
|
||||
|
||||
# Compiler flags: freestanding, no stdlib, kernel-mode compatible.
|
||||
@@ -86,9 +88,16 @@ HOMEKEEP := $(BINDIR)/home/.keep
|
||||
|
||||
all: bearssl libc libjpeg tls $(TARGETS) fetch wiki wikipedia weather imageviewer fontpreview doom desktop icons fonts $(GAME_DATA) $(MANDST) $(WWWDST) $(CA_CERTS) $(HOMEKEEP)
|
||||
|
||||
# Build BearSSL static library.
|
||||
bearssl:
|
||||
$(MAKE) -C lib/bearssl
|
||||
# Build BearSSL static library (cross-compiled for freestanding x86_64).
|
||||
BEARSSL_INCLUDES := -isystem $(shell cd .. && pwd)/kernel/freestnd-c-hdrs/x86_64/include -isystem $(abspath include/libc)
|
||||
|
||||
lib/bearssl/build/libbearssl.a:
|
||||
$(MAKE) -C lib/bearssl CONF=MontaukOS \
|
||||
BEARSSL_CC="$(CC)" \
|
||||
BEARSSL_AR="$(TOOLCHAIN_PREFIX)ar" \
|
||||
BEARSSL_INCLUDES="$(BEARSSL_INCLUDES)"
|
||||
|
||||
bearssl: lib/bearssl/build/libbearssl.a
|
||||
|
||||
# Build shared libc static library.
|
||||
libc:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Syscall.hpp
|
||||
* ZenithOS syscall definitions for userspace programs
|
||||
* MontaukOS syscall definitions for userspace programs
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Zenith {
|
||||
namespace Montauk {
|
||||
|
||||
// Syscall numbers
|
||||
static constexpr uint64_t SYS_EXIT = 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* canvas.hpp
|
||||
* ZenithOS Canvas — drawing primitives for pixel buffer (uint32_t*) targets
|
||||
* MontaukOS Canvas — drawing primitives for pixel buffer (uint32_t*) targets
|
||||
* Mirrors Framebuffer API but operates directly on app content buffers.
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* desktop.hpp
|
||||
* ZenithOS desktop state and compositor declarations
|
||||
* MontaukOS desktop state and compositor declarations
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -50,7 +50,7 @@ struct DesktopState {
|
||||
int window_count;
|
||||
int focused_window;
|
||||
|
||||
Zenith::MouseState mouse;
|
||||
Montauk::MouseState mouse;
|
||||
uint8_t prev_buttons;
|
||||
|
||||
bool app_menu_open;
|
||||
@@ -92,7 +92,7 @@ struct DesktopState {
|
||||
int ctx_menu_x, ctx_menu_y;
|
||||
|
||||
bool net_popup_open;
|
||||
Zenith::NetCfg cached_net_cfg;
|
||||
Montauk::NetCfg cached_net_cfg;
|
||||
uint64_t net_cfg_last_poll;
|
||||
Rect net_icon_rect;
|
||||
|
||||
@@ -111,6 +111,6 @@ void desktop_raise_window(DesktopState* ds, int idx);
|
||||
void desktop_draw_panel(DesktopState* ds);
|
||||
void desktop_draw_window(DesktopState* ds, int idx);
|
||||
void desktop_handle_mouse(DesktopState* ds);
|
||||
void desktop_handle_keyboard(DesktopState* ds, const Zenith::KeyEvent& key);
|
||||
void desktop_handle_keyboard(DesktopState* ds, const Montauk::KeyEvent& key);
|
||||
|
||||
} // namespace gui
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* draw.hpp
|
||||
* ZenithOS drawing primitives (lines, circles, rounded rects, cursor)
|
||||
* MontaukOS drawing primitives (lines, circles, rounded rects, cursor)
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* font.hpp
|
||||
* ZenithOS text rendering — TrueType with bitmap fallback
|
||||
* MontaukOS text rendering — TrueType with bitmap fallback
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* framebuffer.hpp
|
||||
* ZenithOS double-buffered framebuffer abstraction
|
||||
* MontaukOS double-buffered framebuffer abstraction
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <zenith/syscall.h>
|
||||
#include <montauk/syscall.h>
|
||||
#include "gui/gui.hpp"
|
||||
|
||||
namespace gui {
|
||||
@@ -20,15 +20,15 @@ class Framebuffer {
|
||||
|
||||
public:
|
||||
Framebuffer() : hw_fb(nullptr), back_buf(nullptr), fb_width(0), fb_height(0), fb_pitch(0) {
|
||||
Zenith::FbInfo info;
|
||||
zenith::fb_info(&info);
|
||||
Montauk::FbInfo info;
|
||||
montauk::fb_info(&info);
|
||||
|
||||
fb_width = (int)info.width;
|
||||
fb_height = (int)info.height;
|
||||
fb_pitch = (int)info.pitch;
|
||||
|
||||
hw_fb = (uint32_t*)zenith::fb_map();
|
||||
back_buf = (uint32_t*)zenith::alloc((uint64_t)fb_height * fb_pitch);
|
||||
hw_fb = (uint32_t*)montauk::fb_map();
|
||||
back_buf = (uint32_t*)montauk::alloc((uint64_t)fb_height * fb_pitch);
|
||||
}
|
||||
|
||||
int width() const { return fb_width; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* gui.hpp
|
||||
* ZenithOS core GUI types and utilities
|
||||
* MontaukOS core GUI types and utilities
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* svg.hpp
|
||||
* ZenithOS SVG icon parser and scanline rasterizer
|
||||
* MontaukOS SVG icon parser and scanline rasterizer
|
||||
* Handles the Flat-Remix symbolic icon subset (path, circle, rect)
|
||||
* All math uses 16.16 fixed-point -- NO floating point.
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "gui/gui.hpp"
|
||||
#include <zenith/syscall.h>
|
||||
#include <montauk/syscall.h>
|
||||
|
||||
namespace gui {
|
||||
|
||||
@@ -321,7 +321,7 @@ struct SvgEdgeList {
|
||||
int capacity;
|
||||
|
||||
void init(int cap) {
|
||||
edges = (SvgEdge*)zenith::alloc(cap * sizeof(SvgEdge));
|
||||
edges = (SvgEdge*)montauk::alloc(cap * sizeof(SvgEdge));
|
||||
count = 0;
|
||||
capacity = cap;
|
||||
}
|
||||
@@ -800,7 +800,7 @@ inline void svg_rasterize(const SvgEdgeList& el, uint32_t* pixels, int w, int h,
|
||||
// Temporary array for x-intersections on each scanline
|
||||
// Allocate enough for all edges (each edge can intersect at most once per scanline)
|
||||
int maxIsect = el.count + 16;
|
||||
fixed_t* isect = (fixed_t*)zenith::alloc(maxIsect * sizeof(fixed_t));
|
||||
fixed_t* isect = (fixed_t*)montauk::alloc(maxIsect * sizeof(fixed_t));
|
||||
|
||||
for (int y = 0; y < h; ++y) {
|
||||
// Scanline center in fixed-point
|
||||
@@ -858,7 +858,7 @@ inline void svg_rasterize(const SvgEdgeList& el, uint32_t* pixels, int w, int h,
|
||||
}
|
||||
}
|
||||
|
||||
zenith::free(isect);
|
||||
montauk::free(isect);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1018,7 +1018,7 @@ inline void svg_rasterize_blend(const SvgEdgeList& el, uint32_t* pixels, int w,
|
||||
if (el.count == 0) return;
|
||||
|
||||
int maxIsect = el.count + 16;
|
||||
fixed_t* isect = (fixed_t*)zenith::alloc(maxIsect * sizeof(fixed_t));
|
||||
fixed_t* isect = (fixed_t*)montauk::alloc(maxIsect * sizeof(fixed_t));
|
||||
|
||||
uint32_t fr = (fill >> 16) & 0xFF;
|
||||
uint32_t fg = (fill >> 8) & 0xFF;
|
||||
@@ -1081,7 +1081,7 @@ inline void svg_rasterize_blend(const SvgEdgeList& el, uint32_t* pixels, int w,
|
||||
}
|
||||
}
|
||||
|
||||
zenith::free(isect);
|
||||
montauk::free(isect);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1091,7 +1091,7 @@ inline SvgIcon svg_render(const char* svg_data, int svg_len, int target_w, int t
|
||||
SvgIcon icon;
|
||||
icon.width = target_w;
|
||||
icon.height = target_h;
|
||||
icon.pixels = (uint32_t*)zenith::alloc(target_w * target_h * sizeof(uint32_t));
|
||||
icon.pixels = (uint32_t*)montauk::alloc(target_w * target_h * sizeof(uint32_t));
|
||||
// Clear to transparent
|
||||
svg_memset(icon.pixels, 0, target_w * target_h * sizeof(uint32_t));
|
||||
|
||||
@@ -1359,7 +1359,7 @@ inline SvgIcon svg_render(const char* svg_data, int svg_len, int target_w, int t
|
||||
++p;
|
||||
}
|
||||
|
||||
zenith::free(el.edges);
|
||||
montauk::free(el.edges);
|
||||
return icon;
|
||||
}
|
||||
|
||||
@@ -1367,20 +1367,20 @@ inline SvgIcon svg_render(const char* svg_data, int svg_len, int target_w, int t
|
||||
// Load SVG from VFS and render
|
||||
// ---------------------------------------------------------------------------
|
||||
inline SvgIcon svg_load(const char* vfs_path, int target_w, int target_h, Color fill_color) {
|
||||
int fd = zenith::open(vfs_path);
|
||||
int fd = montauk::open(vfs_path);
|
||||
if (fd < 0) {
|
||||
return {nullptr, 0, 0};
|
||||
}
|
||||
|
||||
uint64_t size = zenith::getsize(fd);
|
||||
uint64_t size = montauk::getsize(fd);
|
||||
if (size == 0 || size > SVG_MAX_FILE_SIZE) {
|
||||
zenith::close(fd);
|
||||
montauk::close(fd);
|
||||
return {nullptr, 0, 0};
|
||||
}
|
||||
|
||||
char* buf = (char*)zenith::alloc(size + 1);
|
||||
zenith::read(fd, (uint8_t*)buf, 0, size);
|
||||
zenith::close(fd);
|
||||
char* buf = (char*)montauk::alloc(size + 1);
|
||||
montauk::read(fd, (uint8_t*)buf, 0, size);
|
||||
montauk::close(fd);
|
||||
buf[size] = '\0';
|
||||
|
||||
// 4x supersampling: render at 4x resolution, then downsample with box filter
|
||||
@@ -1389,12 +1389,12 @@ inline SvgIcon svg_load(const char* vfs_path, int target_w, int target_h, Color
|
||||
int hi_h = target_h * SS;
|
||||
|
||||
SvgIcon hi = svg_render(buf, (int)size, hi_w, hi_h, fill_color);
|
||||
zenith::free(buf);
|
||||
montauk::free(buf);
|
||||
|
||||
if (!hi.pixels) return {nullptr, 0, 0};
|
||||
|
||||
// Allocate final icon at target resolution
|
||||
uint32_t* out = (uint32_t*)zenith::alloc(target_w * target_h * 4);
|
||||
uint32_t* out = (uint32_t*)montauk::alloc(target_w * target_h * 4);
|
||||
for (int i = 0; i < target_w * target_h; i++) out[i] = 0;
|
||||
|
||||
// Downsample: average each SSxSS block using premultiplied alpha
|
||||
@@ -1432,7 +1432,7 @@ inline SvgIcon svg_load(const char* vfs_path, int target_w, int target_h, Color
|
||||
}
|
||||
}
|
||||
|
||||
zenith::free(hi.pixels);
|
||||
montauk::free(hi.pixels);
|
||||
return {out, target_w, target_h};
|
||||
}
|
||||
|
||||
@@ -1440,7 +1440,7 @@ inline SvgIcon svg_load(const char* vfs_path, int target_w, int target_h, Color
|
||||
// Free icon pixel data
|
||||
// ---------------------------------------------------------------------------
|
||||
inline void svg_free(SvgIcon& icon) {
|
||||
if (icon.pixels) zenith::free(icon.pixels);
|
||||
if (icon.pixels) montauk::free(icon.pixels);
|
||||
icon.pixels = nullptr;
|
||||
icon.width = 0;
|
||||
icon.height = 0;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* terminal.hpp
|
||||
* ZenithOS terminal emulator with ANSI escape sequence support
|
||||
* MontaukOS terminal emulator with ANSI escape sequence support
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "gui/gui.hpp"
|
||||
#include "gui/font.hpp"
|
||||
#include <zenith/syscall.h>
|
||||
#include <zenith/string.h>
|
||||
#include <montauk/syscall.h>
|
||||
#include <montauk/string.h>
|
||||
#include <Api/Syscall.hpp>
|
||||
|
||||
namespace gui {
|
||||
@@ -102,8 +102,8 @@ static inline void terminal_init_cells(TerminalState* t, int cols, int rows) {
|
||||
t->child_pid = 0;
|
||||
|
||||
int total_cells = cols * rows;
|
||||
t->cells = (TermCell*)zenith::alloc(total_cells * sizeof(TermCell));
|
||||
t->alt_cells = (TermCell*)zenith::alloc(total_cells * sizeof(TermCell));
|
||||
t->cells = (TermCell*)montauk::alloc(total_cells * sizeof(TermCell));
|
||||
t->alt_cells = (TermCell*)montauk::alloc(total_cells * sizeof(TermCell));
|
||||
for (int i = 0; i < total_cells; i++) {
|
||||
t->cells[i] = {' ', colors::TERM_FG, colors::TERM_BG};
|
||||
t->alt_cells[i] = {' ', colors::TERM_FG, colors::TERM_BG};
|
||||
@@ -114,8 +114,8 @@ static inline void terminal_init(TerminalState* t, int cols, int rows) {
|
||||
terminal_init_cells(t, cols, rows);
|
||||
t->cursor_visible = true;
|
||||
|
||||
t->child_pid = zenith::spawn_redir("0:/os/shell.elf");
|
||||
zenith::childio_settermsz(t->child_pid, cols, rows);
|
||||
t->child_pid = montauk::spawn_redir("0:/os/shell.elf");
|
||||
montauk::childio_settermsz(t->child_pid, cols, rows);
|
||||
}
|
||||
|
||||
static inline void terminal_put_char(TerminalState* t, char ch) {
|
||||
@@ -537,8 +537,8 @@ static inline void terminal_resize(TerminalState* t, int new_cols, int new_rows)
|
||||
if (new_cols < 1 || new_rows < 1) return;
|
||||
|
||||
int new_total = new_cols * new_rows;
|
||||
TermCell* new_cells = (TermCell*)zenith::alloc(new_total * sizeof(TermCell));
|
||||
TermCell* new_alt = (TermCell*)zenith::alloc(new_total * sizeof(TermCell));
|
||||
TermCell* new_cells = (TermCell*)montauk::alloc(new_total * sizeof(TermCell));
|
||||
TermCell* new_alt = (TermCell*)montauk::alloc(new_total * sizeof(TermCell));
|
||||
|
||||
// Clear new buffers
|
||||
for (int i = 0; i < new_total; i++) {
|
||||
@@ -562,8 +562,8 @@ static inline void terminal_resize(TerminalState* t, int new_cols, int new_rows)
|
||||
}
|
||||
}
|
||||
|
||||
if (t->cells) zenith::mfree(t->cells);
|
||||
if (t->alt_cells) zenith::mfree(t->alt_cells);
|
||||
if (t->cells) montauk::mfree(t->cells);
|
||||
if (t->alt_cells) montauk::mfree(t->alt_cells);
|
||||
|
||||
t->cells = new_cells;
|
||||
t->alt_cells = new_alt;
|
||||
@@ -580,20 +580,20 @@ static inline void terminal_resize(TerminalState* t, int new_cols, int new_rows)
|
||||
|
||||
// Notify child process of new terminal size
|
||||
if (t->child_pid > 0) {
|
||||
zenith::childio_settermsz(t->child_pid, new_cols, new_rows);
|
||||
montauk::childio_settermsz(t->child_pid, new_cols, new_rows);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void terminal_handle_key(TerminalState* t, const Zenith::KeyEvent& key) {
|
||||
static inline void terminal_handle_key(TerminalState* t, const Montauk::KeyEvent& key) {
|
||||
if (t->child_pid > 0) {
|
||||
zenith::childio_writekey(t->child_pid, &key);
|
||||
montauk::childio_writekey(t->child_pid, &key);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void terminal_poll(TerminalState* t) {
|
||||
if (t->child_pid <= 0) return;
|
||||
char buf[512];
|
||||
int n = zenith::childio_read(t->child_pid, buf, sizeof(buf));
|
||||
int n = montauk::childio_read(t->child_pid, buf, sizeof(buf));
|
||||
if (n > 0) {
|
||||
terminal_feed(t, buf, n);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* truetype.hpp
|
||||
* ZenithOS TrueType font rendering via stb_truetype
|
||||
* MontaukOS TrueType font rendering via stb_truetype
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <zenith/syscall.h>
|
||||
#include <zenith/heap.h>
|
||||
#include <zenith/string.h>
|
||||
#include <montauk/syscall.h>
|
||||
#include <montauk/heap.h>
|
||||
#include <montauk/string.h>
|
||||
#include "gui/gui.hpp"
|
||||
#include "gui/framebuffer.hpp"
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
#define STBTT_cos(x) stb_cos(x)
|
||||
#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_memcpy(d,s,n) zenith::memcpy(d,s,n)
|
||||
#define STBTT_memset(d,v,n) zenith::memset(d,v,n)
|
||||
#define STBTT_strlen(x) zenith::slen(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) montauk::memcpy(d,s,n)
|
||||
#define STBTT_memset(d,v,n) montauk::memset(d,v,n)
|
||||
#define STBTT_strlen(x) montauk::slen(x)
|
||||
#define STBTT_assert(x) ((void)(x))
|
||||
#endif
|
||||
|
||||
@@ -69,26 +69,26 @@ struct TrueTypeFont {
|
||||
data = nullptr;
|
||||
cache_count = 0;
|
||||
|
||||
int fd = zenith::open(vfs_path);
|
||||
int fd = montauk::open(vfs_path);
|
||||
if (fd < 0) return false;
|
||||
|
||||
uint64_t size = zenith::getsize(fd);
|
||||
uint64_t size = montauk::getsize(fd);
|
||||
if (size == 0 || size > 1024 * 1024) {
|
||||
zenith::close(fd);
|
||||
montauk::close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
data = (uint8_t*)zenith::alloc(size);
|
||||
data = (uint8_t*)montauk::alloc(size);
|
||||
if (!data) {
|
||||
zenith::close(fd);
|
||||
montauk::close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
zenith::read(fd, data, 0, size);
|
||||
zenith::close(fd);
|
||||
montauk::read(fd, data, 0, size);
|
||||
montauk::close(fd);
|
||||
|
||||
if (!stbtt_InitFont(&info, data, stbtt_GetFontOffsetForIndex(data, 0))) {
|
||||
zenith::free(data);
|
||||
montauk::free(data);
|
||||
data = nullptr;
|
||||
return false;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ struct TrueTypeFont {
|
||||
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);
|
||||
stbtt_MakeCodepointBitmap(&info, g->bitmap, g->width, g->height,
|
||||
g->width, gc->scale, gc->scale, codepoint);
|
||||
}
|
||||
@@ -314,10 +314,10 @@ namespace fonts {
|
||||
|
||||
inline bool init() {
|
||||
auto load = [](const char* path) -> TrueTypeFont* {
|
||||
TrueTypeFont* f = (TrueTypeFont*)zenith::malloc(sizeof(TrueTypeFont));
|
||||
zenith::memset(f, 0, sizeof(TrueTypeFont));
|
||||
TrueTypeFont* f = (TrueTypeFont*)montauk::malloc(sizeof(TrueTypeFont));
|
||||
montauk::memset(f, 0, sizeof(TrueTypeFont));
|
||||
if (!f->init(path)) {
|
||||
zenith::mfree(f);
|
||||
montauk::mfree(f);
|
||||
return nullptr;
|
||||
}
|
||||
return f;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* widgets.hpp
|
||||
* ZenithOS GUI widget toolkit (Label, Button, TextBox, Scrollbar)
|
||||
* MontaukOS GUI widget toolkit (Label, Button, TextBox, Scrollbar)
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -227,7 +227,7 @@ struct TextBox {
|
||||
}
|
||||
}
|
||||
|
||||
void handle_key(const Zenith::KeyEvent& key) {
|
||||
void handle_key(const Montauk::KeyEvent& key) {
|
||||
if (!focused || !key.pressed) return;
|
||||
|
||||
if (key.ascii == '\b' || key.scancode == 0x0E) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* window.hpp
|
||||
* ZenithOS window management types
|
||||
* MontaukOS window management types
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ static constexpr int MIN_WINDOW_H = 80;
|
||||
struct Window;
|
||||
using WindowDrawCallback = void (*)(Window* win, Framebuffer& fb);
|
||||
using WindowMouseCallback = void (*)(Window* win, MouseEvent& ev);
|
||||
using WindowKeyCallback = void (*)(Window* win, const Zenith::KeyEvent& key);
|
||||
using WindowKeyCallback = void (*)(Window* win, const Montauk::KeyEvent& key);
|
||||
using WindowCloseCallback = void (*)(Window* win);
|
||||
using WindowPollCallback = void (*)(Window* win);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _LIBC_SYS_TIME_H
|
||||
#define _LIBC_SYS_TIME_H
|
||||
|
||||
/* Stub header for ZenithOS */
|
||||
/* Stub header for MontaukOS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/*
|
||||
* heap.h
|
||||
* Userspace heap allocator for ZenithOS programs
|
||||
* Userspace heap allocator for MontaukOS programs
|
||||
* Free-list allocator backed by SYS_ALLOC page requests.
|
||||
* Adapted from the kernel HeapAllocator.
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <zenith/syscall.h>
|
||||
#include <montauk/syscall.h>
|
||||
|
||||
namespace zenith {
|
||||
namespace montauk {
|
||||
namespace heap_detail {
|
||||
|
||||
static constexpr uint64_t HEADER_MAGIC = 0x5A484541; // "ZHEA"
|
||||
@@ -43,7 +43,7 @@ namespace heap_detail {
|
||||
uint64_t pages = (bytes + 0xFFF) / 0x1000;
|
||||
if (pages < 4) pages = 4; // grow at least 16 KiB at a time
|
||||
|
||||
void* mem = zenith::alloc(pages * 0x1000);
|
||||
void* mem = montauk::alloc(pages * 0x1000);
|
||||
if (mem == nullptr) return false;
|
||||
insert_free(mem, pages * 0x1000);
|
||||
return true;
|
||||
@@ -132,4 +132,4 @@ namespace heap_detail {
|
||||
return newBlock;
|
||||
}
|
||||
|
||||
} // namespace zenith
|
||||
} // namespace montauk
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* string.h
|
||||
* Common string and memory utility functions for ZenithOS programs
|
||||
* Common string and memory utility functions for MontaukOS programs
|
||||
* Copyright (c) 2025-2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace zenith {
|
||||
namespace montauk {
|
||||
|
||||
inline int slen(const char* s) {
|
||||
int n = 0;
|
||||
@@ -1,13 +1,13 @@
|
||||
/*
|
||||
* syscall.h
|
||||
* ZenithOS program-side syscall wrappers using SYSCALL instruction
|
||||
* MontaukOS program-side syscall wrappers using SYSCALL instruction
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <Api/Syscall.hpp>
|
||||
|
||||
namespace zenith {
|
||||
namespace montauk {
|
||||
|
||||
// ---- Raw SYSCALL wrappers ----
|
||||
|
||||
@@ -110,224 +110,224 @@ namespace zenith {
|
||||
|
||||
// Process
|
||||
[[noreturn]] inline void exit(int code = 0) {
|
||||
syscall1(Zenith::SYS_EXIT, (uint64_t)code);
|
||||
syscall1(Montauk::SYS_EXIT, (uint64_t)code);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
inline void yield() { syscall0(Zenith::SYS_YIELD); }
|
||||
inline void sleep_ms(uint64_t ms) { syscall1(Zenith::SYS_SLEEP_MS, ms); }
|
||||
inline int getpid() { return (int)syscall0(Zenith::SYS_GETPID); }
|
||||
inline void yield() { syscall0(Montauk::SYS_YIELD); }
|
||||
inline void sleep_ms(uint64_t ms) { syscall1(Montauk::SYS_SLEEP_MS, ms); }
|
||||
inline int getpid() { return (int)syscall0(Montauk::SYS_GETPID); }
|
||||
inline int spawn(const char* path, const char* args = nullptr) {
|
||||
return (int)syscall2(Zenith::SYS_SPAWN, (uint64_t)path, (uint64_t)args);
|
||||
return (int)syscall2(Montauk::SYS_SPAWN, (uint64_t)path, (uint64_t)args);
|
||||
}
|
||||
|
||||
// Console
|
||||
inline void print(const char* text) { syscall1(Zenith::SYS_PRINT, (uint64_t)text); }
|
||||
inline void putchar(char c) { syscall1(Zenith::SYS_PUTCHAR, (uint64_t)c); }
|
||||
inline void print(const char* text) { syscall1(Montauk::SYS_PRINT, (uint64_t)text); }
|
||||
inline void putchar(char c) { syscall1(Montauk::SYS_PUTCHAR, (uint64_t)c); }
|
||||
|
||||
// File I/O
|
||||
inline int open(const char* path) { return (int)syscall1(Zenith::SYS_OPEN, (uint64_t)path); }
|
||||
inline int open(const char* path) { return (int)syscall1(Montauk::SYS_OPEN, (uint64_t)path); }
|
||||
inline int read(int handle, uint8_t* buf, uint64_t off, uint64_t size) {
|
||||
return (int)syscall4(Zenith::SYS_READ, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
return (int)syscall4(Montauk::SYS_READ, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
}
|
||||
inline uint64_t getsize(int handle) { return (uint64_t)syscall1(Zenith::SYS_GETSIZE, (uint64_t)handle); }
|
||||
inline void close(int handle) { syscall1(Zenith::SYS_CLOSE, (uint64_t)handle); }
|
||||
inline uint64_t getsize(int handle) { return (uint64_t)syscall1(Montauk::SYS_GETSIZE, (uint64_t)handle); }
|
||||
inline void close(int handle) { syscall1(Montauk::SYS_CLOSE, (uint64_t)handle); }
|
||||
inline int readdir(const char* path, const char** names, int max) {
|
||||
return (int)syscall3(Zenith::SYS_READDIR, (uint64_t)path, (uint64_t)names, (uint64_t)max);
|
||||
return (int)syscall3(Montauk::SYS_READDIR, (uint64_t)path, (uint64_t)names, (uint64_t)max);
|
||||
}
|
||||
|
||||
// File write/create
|
||||
inline int fwrite(int handle, const uint8_t* buf, uint64_t off, uint64_t size) {
|
||||
return (int)syscall4(Zenith::SYS_FWRITE, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
return (int)syscall4(Montauk::SYS_FWRITE, (uint64_t)handle, (uint64_t)buf, off, size);
|
||||
}
|
||||
inline int fcreate(const char* path) {
|
||||
return (int)syscall1(Zenith::SYS_FCREATE, (uint64_t)path);
|
||||
return (int)syscall1(Montauk::SYS_FCREATE, (uint64_t)path);
|
||||
}
|
||||
|
||||
// Memory
|
||||
inline void* alloc(uint64_t size) { return (void*)syscall1(Zenith::SYS_ALLOC, size); }
|
||||
inline void free(void* ptr) { syscall1(Zenith::SYS_FREE, (uint64_t)ptr); }
|
||||
inline void* alloc(uint64_t size) { return (void*)syscall1(Montauk::SYS_ALLOC, size); }
|
||||
inline void free(void* ptr) { syscall1(Montauk::SYS_FREE, (uint64_t)ptr); }
|
||||
|
||||
// Timekeeping
|
||||
inline uint64_t get_ticks() { return (uint64_t)syscall0(Zenith::SYS_GETTICKS); }
|
||||
inline uint64_t get_milliseconds() { return (uint64_t)syscall0(Zenith::SYS_GETMILLISECONDS); }
|
||||
inline uint64_t get_ticks() { return (uint64_t)syscall0(Montauk::SYS_GETTICKS); }
|
||||
inline uint64_t get_milliseconds() { return (uint64_t)syscall0(Montauk::SYS_GETMILLISECONDS); }
|
||||
|
||||
// System
|
||||
inline void get_info(Zenith::SysInfo* info) { syscall1(Zenith::SYS_GETINFO, (uint64_t)info); }
|
||||
inline void get_info(Montauk::SysInfo* info) { syscall1(Montauk::SYS_GETINFO, (uint64_t)info); }
|
||||
|
||||
// Keyboard
|
||||
inline bool is_key_available() { return (bool)syscall0(Zenith::SYS_ISKEYAVAILABLE); }
|
||||
inline void getkey(Zenith::KeyEvent* out) { syscall1(Zenith::SYS_GETKEY, (uint64_t)out); }
|
||||
inline char getchar() { return (char)syscall0(Zenith::SYS_GETCHAR); }
|
||||
inline bool is_key_available() { return (bool)syscall0(Montauk::SYS_ISKEYAVAILABLE); }
|
||||
inline void getkey(Montauk::KeyEvent* out) { syscall1(Montauk::SYS_GETKEY, (uint64_t)out); }
|
||||
inline char getchar() { return (char)syscall0(Montauk::SYS_GETCHAR); }
|
||||
|
||||
// Networking
|
||||
inline int32_t ping(uint32_t ip, uint32_t timeoutMs = 3000) {
|
||||
return (int32_t)syscall2(Zenith::SYS_PING, (uint64_t)ip, (uint64_t)timeoutMs);
|
||||
return (int32_t)syscall2(Montauk::SYS_PING, (uint64_t)ip, (uint64_t)timeoutMs);
|
||||
}
|
||||
|
||||
// DNS resolve: returns IP in network byte order, or 0 on failure
|
||||
inline uint32_t resolve(const char* hostname) {
|
||||
return (uint32_t)syscall1(Zenith::SYS_RESOLVE, (uint64_t)hostname);
|
||||
return (uint32_t)syscall1(Montauk::SYS_RESOLVE, (uint64_t)hostname);
|
||||
}
|
||||
|
||||
// Network configuration
|
||||
inline void get_netcfg(Zenith::NetCfg* out) { syscall1(Zenith::SYS_GETNETCFG, (uint64_t)out); }
|
||||
inline int set_netcfg(const Zenith::NetCfg* cfg) { return (int)syscall1(Zenith::SYS_SETNETCFG, (uint64_t)cfg); }
|
||||
inline void get_netcfg(Montauk::NetCfg* out) { syscall1(Montauk::SYS_GETNETCFG, (uint64_t)out); }
|
||||
inline int set_netcfg(const Montauk::NetCfg* cfg) { return (int)syscall1(Montauk::SYS_SETNETCFG, (uint64_t)cfg); }
|
||||
|
||||
// Sockets
|
||||
inline int socket(int type) {
|
||||
return (int)syscall1(Zenith::SYS_SOCKET, (uint64_t)type);
|
||||
return (int)syscall1(Montauk::SYS_SOCKET, (uint64_t)type);
|
||||
}
|
||||
inline int connect(int fd, uint32_t ip, uint16_t port) {
|
||||
return (int)syscall3(Zenith::SYS_CONNECT, (uint64_t)fd, (uint64_t)ip, (uint64_t)port);
|
||||
return (int)syscall3(Montauk::SYS_CONNECT, (uint64_t)fd, (uint64_t)ip, (uint64_t)port);
|
||||
}
|
||||
inline int bind(int fd, uint16_t port) {
|
||||
return (int)syscall2(Zenith::SYS_BIND, (uint64_t)fd, (uint64_t)port);
|
||||
return (int)syscall2(Montauk::SYS_BIND, (uint64_t)fd, (uint64_t)port);
|
||||
}
|
||||
inline int listen(int fd) {
|
||||
return (int)syscall1(Zenith::SYS_LISTEN, (uint64_t)fd);
|
||||
return (int)syscall1(Montauk::SYS_LISTEN, (uint64_t)fd);
|
||||
}
|
||||
inline int accept(int fd) {
|
||||
return (int)syscall1(Zenith::SYS_ACCEPT, (uint64_t)fd);
|
||||
return (int)syscall1(Montauk::SYS_ACCEPT, (uint64_t)fd);
|
||||
}
|
||||
inline int send(int fd, const void* data, uint32_t len) {
|
||||
return (int)syscall3(Zenith::SYS_SEND, (uint64_t)fd, (uint64_t)data, (uint64_t)len);
|
||||
return (int)syscall3(Montauk::SYS_SEND, (uint64_t)fd, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int recv(int fd, void* buf, uint32_t maxLen) {
|
||||
return (int)syscall3(Zenith::SYS_RECV, (uint64_t)fd, (uint64_t)buf, (uint64_t)maxLen);
|
||||
return (int)syscall3(Montauk::SYS_RECV, (uint64_t)fd, (uint64_t)buf, (uint64_t)maxLen);
|
||||
}
|
||||
inline int closesocket(int fd) {
|
||||
return (int)syscall1(Zenith::SYS_CLOSESOCK, (uint64_t)fd);
|
||||
return (int)syscall1(Montauk::SYS_CLOSESOCK, (uint64_t)fd);
|
||||
}
|
||||
inline int sendto(int fd, const void* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
||||
return (int)syscall5(Zenith::SYS_SENDTO, (uint64_t)fd, (uint64_t)data,
|
||||
return (int)syscall5(Montauk::SYS_SENDTO, (uint64_t)fd, (uint64_t)data,
|
||||
(uint64_t)len, (uint64_t)destIp, (uint64_t)destPort);
|
||||
}
|
||||
inline int recvfrom(int fd, void* buf, uint32_t maxLen, uint32_t* srcIp, uint16_t* srcPort) {
|
||||
return (int)syscall5(Zenith::SYS_RECVFROM, (uint64_t)fd, (uint64_t)buf,
|
||||
return (int)syscall5(Montauk::SYS_RECVFROM, (uint64_t)fd, (uint64_t)buf,
|
||||
(uint64_t)maxLen, (uint64_t)srcIp, (uint64_t)srcPort);
|
||||
}
|
||||
|
||||
// Process management
|
||||
inline void waitpid(int pid) { syscall1(Zenith::SYS_WAITPID, (uint64_t)pid); }
|
||||
inline void waitpid(int pid) { syscall1(Montauk::SYS_WAITPID, (uint64_t)pid); }
|
||||
|
||||
// Framebuffer
|
||||
inline void fb_info(Zenith::FbInfo* info) { syscall1(Zenith::SYS_FBINFO, (uint64_t)info); }
|
||||
inline void* fb_map() { return (void*)syscall0(Zenith::SYS_FBMAP); }
|
||||
inline void fb_info(Montauk::FbInfo* info) { syscall1(Montauk::SYS_FBINFO, (uint64_t)info); }
|
||||
inline void* fb_map() { return (void*)syscall0(Montauk::SYS_FBMAP); }
|
||||
|
||||
// Arguments
|
||||
inline int getargs(char* buf, uint64_t maxLen) {
|
||||
return (int)syscall2(Zenith::SYS_GETARGS, (uint64_t)buf, maxLen);
|
||||
return (int)syscall2(Montauk::SYS_GETARGS, (uint64_t)buf, maxLen);
|
||||
}
|
||||
|
||||
// Terminal
|
||||
inline void termsize(int* cols, int* rows) {
|
||||
uint64_t r = (uint64_t)syscall0(Zenith::SYS_TERMSIZE);
|
||||
uint64_t r = (uint64_t)syscall0(Montauk::SYS_TERMSIZE);
|
||||
if (cols) *cols = (int)(r & 0xFFFFFFFF);
|
||||
if (rows) *rows = (int)(r >> 32);
|
||||
}
|
||||
|
||||
inline void termscale(int scale_x, int scale_y) {
|
||||
syscall2(Zenith::SYS_TERMSCALE, (uint64_t)scale_x, (uint64_t)scale_y);
|
||||
syscall2(Montauk::SYS_TERMSCALE, (uint64_t)scale_x, (uint64_t)scale_y);
|
||||
}
|
||||
|
||||
inline void get_termscale(int* scale_x, int* scale_y) {
|
||||
uint64_t r = (uint64_t)syscall2(Zenith::SYS_TERMSCALE, 0, 0);
|
||||
uint64_t r = (uint64_t)syscall2(Montauk::SYS_TERMSCALE, 0, 0);
|
||||
if (scale_x) *scale_x = (int)(r & 0xFFFFFFFF);
|
||||
if (scale_y) *scale_y = (int)(r >> 32);
|
||||
}
|
||||
|
||||
// Timekeeping (wall-clock)
|
||||
inline void gettime(Zenith::DateTime* out) { syscall1(Zenith::SYS_GETTIME, (uint64_t)out); }
|
||||
inline void gettime(Montauk::DateTime* out) { syscall1(Montauk::SYS_GETTIME, (uint64_t)out); }
|
||||
|
||||
// Random number generation
|
||||
inline int64_t getrandom(void* buf, uint32_t len) {
|
||||
return syscall2(Zenith::SYS_GETRANDOM, (uint64_t)buf, (uint64_t)len);
|
||||
return syscall2(Montauk::SYS_GETRANDOM, (uint64_t)buf, (uint64_t)len);
|
||||
}
|
||||
|
||||
// Power management
|
||||
[[noreturn]] inline void reset() {
|
||||
syscall0(Zenith::SYS_RESET);
|
||||
syscall0(Montauk::SYS_RESET);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
[[noreturn]] inline void shutdown() {
|
||||
syscall0(Zenith::SYS_SHUTDOWN);
|
||||
syscall0(Montauk::SYS_SHUTDOWN);
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
// Mouse
|
||||
inline void mouse_state(Zenith::MouseState* out) { syscall1(Zenith::SYS_MOUSESTATE, (uint64_t)out); }
|
||||
inline void mouse_state(Montauk::MouseState* out) { syscall1(Montauk::SYS_MOUSESTATE, (uint64_t)out); }
|
||||
inline void set_mouse_bounds(int32_t maxX, int32_t maxY) {
|
||||
syscall2(Zenith::SYS_SETMOUSEBOUNDS, (uint64_t)maxX, (uint64_t)maxY);
|
||||
syscall2(Montauk::SYS_SETMOUSEBOUNDS, (uint64_t)maxX, (uint64_t)maxY);
|
||||
}
|
||||
|
||||
// Kernel log
|
||||
inline int64_t read_klog(char* buf, uint64_t size) {
|
||||
return syscall2(Zenith::SYS_KLOG, (uint64_t)buf, size);
|
||||
return syscall2(Montauk::SYS_KLOG, (uint64_t)buf, size);
|
||||
}
|
||||
|
||||
// I/O redirection
|
||||
inline int spawn_redir(const char* path, const char* args = nullptr) {
|
||||
return (int)syscall2(Zenith::SYS_SPAWN_REDIR, (uint64_t)path, (uint64_t)args);
|
||||
return (int)syscall2(Montauk::SYS_SPAWN_REDIR, (uint64_t)path, (uint64_t)args);
|
||||
}
|
||||
inline int childio_read(int childPid, char* buf, int maxLen) {
|
||||
return (int)syscall3(Zenith::SYS_CHILDIO_READ, (uint64_t)childPid, (uint64_t)buf, (uint64_t)maxLen);
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_READ, (uint64_t)childPid, (uint64_t)buf, (uint64_t)maxLen);
|
||||
}
|
||||
inline int childio_write(int childPid, const char* data, int len) {
|
||||
return (int)syscall3(Zenith::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_WRITE, (uint64_t)childPid, (uint64_t)data, (uint64_t)len);
|
||||
}
|
||||
inline int childio_writekey(int childPid, const Zenith::KeyEvent* key) {
|
||||
return (int)syscall2(Zenith::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
||||
inline int childio_writekey(int childPid, const Montauk::KeyEvent* key) {
|
||||
return (int)syscall2(Montauk::SYS_CHILDIO_WRITEKEY, (uint64_t)childPid, (uint64_t)key);
|
||||
}
|
||||
inline int childio_settermsz(int childPid, int cols, int rows) {
|
||||
return (int)syscall3(Zenith::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
||||
return (int)syscall3(Montauk::SYS_CHILDIO_SETTERMSZ, (uint64_t)childPid, (uint64_t)cols, (uint64_t)rows);
|
||||
}
|
||||
|
||||
// Process listing / kill
|
||||
inline int proclist(Zenith::ProcInfo* buf, int max) {
|
||||
return (int)syscall2(Zenith::SYS_PROCLIST, (uint64_t)buf, (uint64_t)max);
|
||||
inline int proclist(Montauk::ProcInfo* buf, int max) {
|
||||
return (int)syscall2(Montauk::SYS_PROCLIST, (uint64_t)buf, (uint64_t)max);
|
||||
}
|
||||
inline int kill(int pid) {
|
||||
return (int)syscall1(Zenith::SYS_KILL, (uint64_t)pid);
|
||||
return (int)syscall1(Montauk::SYS_KILL, (uint64_t)pid);
|
||||
}
|
||||
inline int devlist(Zenith::DevInfo* buf, int max) {
|
||||
return (int)syscall2(Zenith::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
|
||||
inline int devlist(Montauk::DevInfo* buf, int max) {
|
||||
return (int)syscall2(Montauk::SYS_DEVLIST, (uint64_t)buf, (uint64_t)max);
|
||||
}
|
||||
|
||||
// Kernel introspection
|
||||
inline void memstats(Zenith::MemStats* out) { syscall1(Zenith::SYS_MEMSTATS, (uint64_t)out); }
|
||||
inline void memstats(Montauk::MemStats* out) { syscall1(Montauk::SYS_MEMSTATS, (uint64_t)out); }
|
||||
|
||||
// Window server
|
||||
inline int win_create(const char* title, int w, int h, Zenith::WinCreateResult* result) {
|
||||
return (int)syscall4(Zenith::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
||||
inline int win_create(const char* title, int w, int h, Montauk::WinCreateResult* result) {
|
||||
return (int)syscall4(Montauk::SYS_WINCREATE, (uint64_t)title, (uint64_t)w, (uint64_t)h, (uint64_t)result);
|
||||
}
|
||||
inline int win_destroy(int id) {
|
||||
return (int)syscall1(Zenith::SYS_WINDESTROY, (uint64_t)id);
|
||||
return (int)syscall1(Montauk::SYS_WINDESTROY, (uint64_t)id);
|
||||
}
|
||||
inline uint64_t win_present(int id) {
|
||||
return (uint64_t)syscall1(Zenith::SYS_WINPRESENT, (uint64_t)id);
|
||||
return (uint64_t)syscall1(Montauk::SYS_WINPRESENT, (uint64_t)id);
|
||||
}
|
||||
inline int win_poll(int id, Zenith::WinEvent* event) {
|
||||
return (int)syscall2(Zenith::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
|
||||
inline int win_poll(int id, Montauk::WinEvent* event) {
|
||||
return (int)syscall2(Montauk::SYS_WINPOLL, (uint64_t)id, (uint64_t)event);
|
||||
}
|
||||
inline int win_enumerate(Zenith::WinInfo* info, int max) {
|
||||
return (int)syscall2(Zenith::SYS_WINENUM, (uint64_t)info, (uint64_t)max);
|
||||
inline int win_enumerate(Montauk::WinInfo* info, int max) {
|
||||
return (int)syscall2(Montauk::SYS_WINENUM, (uint64_t)info, (uint64_t)max);
|
||||
}
|
||||
inline uint64_t win_map(int id) {
|
||||
return (uint64_t)syscall1(Zenith::SYS_WINMAP, (uint64_t)id);
|
||||
return (uint64_t)syscall1(Montauk::SYS_WINMAP, (uint64_t)id);
|
||||
}
|
||||
inline int win_sendevent(int id, const Zenith::WinEvent* event) {
|
||||
return (int)syscall2(Zenith::SYS_WINSENDEVENT, (uint64_t)id, (uint64_t)event);
|
||||
inline int win_sendevent(int id, const Montauk::WinEvent* event) {
|
||||
return (int)syscall2(Montauk::SYS_WINSENDEVENT, (uint64_t)id, (uint64_t)event);
|
||||
}
|
||||
inline uint64_t win_resize(int id, int w, int h) {
|
||||
return (uint64_t)syscall3(Zenith::SYS_WINRESIZE, (uint64_t)id, (uint64_t)w, (uint64_t)h);
|
||||
return (uint64_t)syscall3(Montauk::SYS_WINRESIZE, (uint64_t)id, (uint64_t)w, (uint64_t)h);
|
||||
}
|
||||
inline int win_setscale(int scale) {
|
||||
return (int)syscall1(Zenith::SYS_WINSETSCALE, (uint64_t)scale);
|
||||
return (int)syscall1(Montauk::SYS_WINSETSCALE, (uint64_t)scale);
|
||||
}
|
||||
inline int win_getscale() {
|
||||
return (int)syscall0(Zenith::SYS_WINGETSCALE);
|
||||
return (int)syscall0(Montauk::SYS_WINGETSCALE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* tls.hpp
|
||||
* Shared TLS helper library for ZenithOS
|
||||
* Shared TLS helper library for MontaukOS
|
||||
* Trust anchor loading, BearSSL time, TLS I/O, HTTPS fetch
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Makefile for shared libc static library on ZenithOS
|
||||
# Makefile for shared libc static library on MontaukOS
|
||||
# Copyright (c) 2025-2026 Daniel Hammer
|
||||
|
||||
MAKEFLAGS += -rR
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* libc.c
|
||||
* Minimal C standard library for ZenithOS userspace programs
|
||||
* Minimal C standard library for MontaukOS userspace programs
|
||||
* Based on the proven libc from the DOOM port.
|
||||
* Copyright (c) 2025-2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
# Makefile for libjpeg (JPEG decoding via stb_image) on ZenithOS
|
||||
# Makefile for libjpeg (JPEG decoding via stb_image) on MontaukOS
|
||||
# Copyright (c) 2026 Daniel Hammer
|
||||
|
||||
MAKEFLAGS += -rR
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* stb_image_impl.c
|
||||
* Single compilation unit for stb_image JPEG decoder on ZenithOS
|
||||
* Single compilation unit for stb_image JPEG decoder on MontaukOS
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#define STBI_NO_STDIO
|
||||
#define STBI_NO_THREAD_LOCALS
|
||||
|
||||
/* Route allocations through libc (which uses ZenithOS heap). */
|
||||
/* Route allocations through libc (which uses MontaukOS heap). */
|
||||
#define STBI_MALLOC(sz) malloc(sz)
|
||||
#define STBI_FREE(p) free(p)
|
||||
#define STBI_REALLOC(p, newsz) realloc(p, newsz)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Makefile for shared TLS helper library on ZenithOS
|
||||
# Makefile for shared TLS helper library on MontaukOS
|
||||
# Copyright (c) 2026 Daniel Hammer
|
||||
|
||||
MAKEFLAGS += -rR
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+31
-31
@@ -1,12 +1,12 @@
|
||||
/*
|
||||
* tls.cpp
|
||||
* Shared TLS helper library for ZenithOS
|
||||
* Shared TLS helper library for MontaukOS
|
||||
* Extracted from fetch, wiki, wikipedia, and weather apps
|
||||
* Copyright (c) 2025-2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#include <tls/tls.hpp>
|
||||
#include <zenith/syscall.h>
|
||||
#include <montauk/syscall.h>
|
||||
|
||||
extern "C" {
|
||||
#include <string.h>
|
||||
@@ -109,15 +109,15 @@ namespace tls {
|
||||
|
||||
TrustAnchors load_trust_anchors() {
|
||||
TrustAnchors tas = {nullptr, 0, 0};
|
||||
int fh = zenith::open("0:/etc/ca-certificates.crt");
|
||||
int fh = montauk::open("0:/etc/ca-certificates.crt");
|
||||
if (fh < 0) return tas;
|
||||
uint64_t fsize = zenith::getsize(fh);
|
||||
if (fsize == 0 || fsize > 512 * 1024) { zenith::close(fh); return tas; }
|
||||
uint64_t fsize = montauk::getsize(fh);
|
||||
if (fsize == 0 || fsize > 512 * 1024) { montauk::close(fh); return tas; }
|
||||
|
||||
unsigned char* pem = (unsigned char*)malloc(fsize + 1);
|
||||
if (!pem) { zenith::close(fh); return tas; }
|
||||
zenith::read(fh, pem, 0, fsize);
|
||||
zenith::close(fh);
|
||||
if (!pem) { montauk::close(fh); return tas; }
|
||||
montauk::read(fh, pem, 0, fsize);
|
||||
montauk::close(fh);
|
||||
pem[fsize] = 0;
|
||||
|
||||
static br_pem_decoder_context pc; // keep off stack
|
||||
@@ -147,8 +147,8 @@ TrustAnchors load_trust_anchors() {
|
||||
}
|
||||
|
||||
void get_bearssl_time(uint32_t* days, uint32_t* seconds) {
|
||||
Zenith::DateTime dt;
|
||||
zenith::gettime(&dt);
|
||||
Montauk::DateTime dt;
|
||||
montauk::gettime(&dt);
|
||||
int y = dt.Year, m = dt.Month, d = dt.Day;
|
||||
uint32_t total = 365u * (uint32_t)y
|
||||
+ (uint32_t)(y/4) - (uint32_t)(y/100) + (uint32_t)(y/400);
|
||||
@@ -162,24 +162,24 @@ void get_bearssl_time(uint32_t* days, uint32_t* seconds) {
|
||||
|
||||
int tls_send_all(int fd, const unsigned char* data, size_t len) {
|
||||
size_t sent = 0;
|
||||
uint64_t deadline = zenith::get_milliseconds() + 15000;
|
||||
uint64_t deadline = montauk::get_milliseconds() + 15000;
|
||||
while (sent < len) {
|
||||
int r = zenith::send(fd, data + sent, (uint32_t)(len - sent));
|
||||
if (r > 0) { sent += r; deadline = zenith::get_milliseconds() + 15000; }
|
||||
int r = montauk::send(fd, data + sent, (uint32_t)(len - 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); }
|
||||
else { if (montauk::get_milliseconds() >= deadline) return -1; montauk::sleep_ms(1); }
|
||||
}
|
||||
return (int)sent;
|
||||
}
|
||||
|
||||
int tls_recv_some(int fd, unsigned char* buf, size_t maxlen) {
|
||||
uint64_t deadline = zenith::get_milliseconds() + 15000;
|
||||
uint64_t deadline = montauk::get_milliseconds() + 15000;
|
||||
while (true) {
|
||||
int r = zenith::recv(fd, buf, (uint32_t)maxlen);
|
||||
int r = montauk::recv(fd, buf, (uint32_t)maxlen);
|
||||
if (r > 0) return r;
|
||||
if (r < 0) return -1;
|
||||
if (zenith::get_milliseconds() >= deadline) return -1;
|
||||
zenith::sleep_ms(1);
|
||||
if (montauk::get_milliseconds() >= deadline) return -1;
|
||||
montauk::sleep_ms(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ int tls_exchange(int fd, br_ssl_engine_context* eng,
|
||||
AbortCheckFn abort_check) {
|
||||
bool requestSent = false;
|
||||
int respLen = 0;
|
||||
uint64_t deadline = zenith::get_milliseconds() + 30000;
|
||||
uint64_t deadline = montauk::get_milliseconds() + 30000;
|
||||
|
||||
while (true) {
|
||||
unsigned state = br_ssl_engine_current_state(eng);
|
||||
@@ -207,7 +207,7 @@ int tls_exchange(int fd, br_ssl_engine_context* eng,
|
||||
int sent = tls_send_all(fd, buf, len);
|
||||
if (sent < 0) { br_ssl_engine_close(eng); return respLen > 0 ? respLen : -1; }
|
||||
br_ssl_engine_sendrec_ack(eng, len);
|
||||
deadline = zenith::get_milliseconds() + 30000; continue;
|
||||
deadline = montauk::get_milliseconds() + 30000; continue;
|
||||
}
|
||||
if (state & BR_SSL_RECVAPP) {
|
||||
size_t len; unsigned char* buf = br_ssl_engine_recvapp_buf(eng, &len);
|
||||
@@ -215,7 +215,7 @@ int tls_exchange(int fd, br_ssl_engine_context* eng,
|
||||
if (respLen + (int)toCopy > respMax - 1) toCopy = respMax - 1 - respLen;
|
||||
if (toCopy > 0) { memcpy(respBuf + respLen, buf, toCopy); respLen += toCopy; }
|
||||
br_ssl_engine_recvapp_ack(eng, len);
|
||||
deadline = zenith::get_milliseconds() + 30000; continue;
|
||||
deadline = montauk::get_milliseconds() + 30000; continue;
|
||||
}
|
||||
if ((state & BR_SSL_SENDAPP) && !requestSent) {
|
||||
size_t len; unsigned char* buf = br_ssl_engine_sendapp_buf(eng, &len);
|
||||
@@ -225,17 +225,17 @@ int tls_exchange(int fd, br_ssl_engine_context* eng,
|
||||
br_ssl_engine_sendapp_ack(eng, toWrite);
|
||||
br_ssl_engine_flush(eng, 0);
|
||||
requestSent = true;
|
||||
deadline = zenith::get_milliseconds() + 30000; continue;
|
||||
deadline = montauk::get_milliseconds() + 30000; continue;
|
||||
}
|
||||
if (state & BR_SSL_RECVREC) {
|
||||
size_t len; unsigned char* buf = br_ssl_engine_recvrec_buf(eng, &len);
|
||||
int got = tls_recv_some(fd, buf, len);
|
||||
if (got < 0) { br_ssl_engine_close(eng); return respLen > 0 ? respLen : -1; }
|
||||
br_ssl_engine_recvrec_ack(eng, got);
|
||||
deadline = zenith::get_milliseconds() + 30000; continue;
|
||||
deadline = montauk::get_milliseconds() + 30000; continue;
|
||||
}
|
||||
if (zenith::get_milliseconds() >= deadline) return respLen > 0 ? respLen : -1;
|
||||
zenith::sleep_ms(1);
|
||||
if (montauk::get_milliseconds() >= deadline) return respLen > 0 ? respLen : -1;
|
||||
montauk::sleep_ms(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,16 +244,16 @@ int https_fetch(const char* host, uint32_t ip, uint16_t port,
|
||||
const TrustAnchors& tas,
|
||||
char* respBuf, int respMax,
|
||||
AbortCheckFn abort_check) {
|
||||
int fd = zenith::socket(Zenith::SOCK_TCP);
|
||||
int fd = montauk::socket(Montauk::SOCK_TCP);
|
||||
if (fd < 0) return -1;
|
||||
if (zenith::connect(fd, ip, port) < 0) { zenith::closesocket(fd); return -1; }
|
||||
if (montauk::connect(fd, ip, port) < 0) { montauk::closesocket(fd); return -1; }
|
||||
|
||||
br_ssl_client_context* cc = (br_ssl_client_context*)malloc(sizeof(*cc));
|
||||
br_x509_minimal_context* xc = (br_x509_minimal_context*)malloc(sizeof(*xc));
|
||||
void* iobuf = malloc(BR_SSL_BUFSIZE_BIDI);
|
||||
if (!cc || !xc || !iobuf) {
|
||||
free(cc); free(xc); free(iobuf);
|
||||
zenith::closesocket(fd); return -1;
|
||||
montauk::closesocket(fd); return -1;
|
||||
}
|
||||
|
||||
br_ssl_client_init_full(cc, xc, tas.anchors, tas.count);
|
||||
@@ -262,16 +262,16 @@ int https_fetch(const char* host, uint32_t ip, uint16_t port,
|
||||
br_x509_minimal_set_time(xc, days, secs);
|
||||
|
||||
unsigned char seed[32];
|
||||
zenith::getrandom(seed, sizeof(seed));
|
||||
montauk::getrandom(seed, sizeof(seed));
|
||||
br_ssl_engine_set_buffer(&cc->eng, iobuf, BR_SSL_BUFSIZE_BIDI, 1);
|
||||
br_ssl_engine_inject_entropy(&cc->eng, seed, sizeof(seed));
|
||||
|
||||
if (!br_ssl_client_reset(cc, host, 0)) {
|
||||
zenith::closesocket(fd); free(cc); free(xc); free(iobuf); return -1;
|
||||
montauk::closesocket(fd); free(cc); free(xc); free(iobuf); return -1;
|
||||
}
|
||||
|
||||
int respLen = tls_exchange(fd, &cc->eng, request, reqLen, respBuf, respMax, abort_check);
|
||||
zenith::closesocket(fd);
|
||||
montauk::closesocket(fd);
|
||||
free(cc); free(xc); free(iobuf);
|
||||
return respLen;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* link.ld
|
||||
* Linker script for ZenithOS userspace programs
|
||||
* Linker script for MontaukOS userspace programs
|
||||
* Copyright (c) 2025 Daniel Hammer
|
||||
*
|
||||
* Programs are loaded at a standard user-space address.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
.TH EDIT 1
|
||||
.SH NAME
|
||||
edit - text editor for ZenithOS
|
||||
edit - text editor for MontaukOS
|
||||
|
||||
.SH SYNOPSIS
|
||||
edit [filename]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH FETCH 1
|
||||
.SH NAME
|
||||
fetch - HTTP/HTTPS client for ZenithOS
|
||||
fetch - HTTP/HTTPS client for MontaukOS
|
||||
|
||||
.SH SYNOPSIS
|
||||
fetch [-v] <url>
|
||||
|
||||
+18
-18
@@ -3,14 +3,14 @@
|
||||
open, read, getsize, close, readdir - file I/O system calls
|
||||
|
||||
.SH SYNOPSIS
|
||||
.BI int zenith::open(const char* path);
|
||||
.BI int zenith::read(int handle, uint8_t* buf, uint64_t offset, uint64_t size);
|
||||
.BI uint64_t zenith::getsize(int handle);
|
||||
.BI void zenith::close(int handle);
|
||||
.BI int zenith::readdir(const char* path, const char** names, int max);
|
||||
.BI int montauk::open(const char* path);
|
||||
.BI int montauk::read(int handle, uint8_t* buf, uint64_t offset, uint64_t size);
|
||||
.BI uint64_t montauk::getsize(int handle);
|
||||
.BI void montauk::close(int handle);
|
||||
.BI int montauk::readdir(const char* path, const char** names, int max);
|
||||
|
||||
.SH DESCRIPTION
|
||||
ZenithOS provides a simple read-only Virtual File System (VFS)
|
||||
MontaukOS provides a simple read-only Virtual File System (VFS)
|
||||
backed by the boot ramdisk. Files are accessed via paths in the
|
||||
format "<drive>:/<path>", where drive 0 is the ramdisk.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
Opens a file and returns a non-negative handle on success, or a
|
||||
negative value on error (file not found, no free handles).
|
||||
|
||||
int h = zenith::open("0:/os/hello.elf");
|
||||
int h = montauk::open("0:/os/hello.elf");
|
||||
|
||||
.SS read
|
||||
Reads up to 'size' bytes starting at 'offset' into 'buf'.
|
||||
@@ -27,17 +27,17 @@
|
||||
every call.
|
||||
|
||||
uint8_t buf[512];
|
||||
int n = zenith::read(h, buf, 0, 512);
|
||||
int n = montauk::read(h, buf, 0, 512);
|
||||
|
||||
.SS getsize
|
||||
Returns the total size in bytes of the file.
|
||||
|
||||
uint64_t sz = zenith::getsize(h);
|
||||
uint64_t sz = montauk::getsize(h);
|
||||
|
||||
.SS close
|
||||
Closes the file handle and frees kernel resources.
|
||||
|
||||
zenith::close(h);
|
||||
montauk::close(h);
|
||||
|
||||
.SS readdir
|
||||
Lists entries in a directory. Up to 'max' entry names (max 64)
|
||||
@@ -46,32 +46,32 @@
|
||||
entries are returned with a trailing slash.
|
||||
|
||||
const char* entries[64];
|
||||
int count = zenith::readdir("0:/", entries, 64);
|
||||
int count = montauk::readdir("0:/", entries, 64);
|
||||
// entries: "os/", "games/", "man/", "www/", "home/"
|
||||
|
||||
.SH READING PATTERN
|
||||
The standard pattern for reading a file:
|
||||
|
||||
int h = zenith::open("0:/man/intro.1");
|
||||
uint64_t size = zenith::getsize(h);
|
||||
int h = montauk::open("0:/man/intro.1");
|
||||
uint64_t size = montauk::getsize(h);
|
||||
uint8_t buf[512];
|
||||
uint64_t off = 0;
|
||||
while (off < size) {
|
||||
uint64_t chunk = size - off;
|
||||
if (chunk > 511) chunk = 511;
|
||||
int n = zenith::read(h, buf, off, chunk);
|
||||
int n = montauk::read(h, buf, off, chunk);
|
||||
if (n <= 0) break;
|
||||
buf[n] = '\0';
|
||||
zenith::print((const char*)buf);
|
||||
montauk::print((const char*)buf);
|
||||
off += n;
|
||||
}
|
||||
zenith::close(h);
|
||||
montauk::close(h);
|
||||
|
||||
.SH WRITING FILES
|
||||
Files can be created and written on the ramdisk:
|
||||
|
||||
.BI int zenith::fcreate(const char* path);
|
||||
.BI int zenith::fwrite(int handle, const uint8_t* buf, uint64_t offset, uint64_t size);
|
||||
.BI int montauk::fcreate(const char* path);
|
||||
.BI int montauk::fwrite(int handle, const uint8_t* buf, uint64_t offset, uint64_t size);
|
||||
|
||||
fcreate creates a new file and returns a handle. fwrite writes
|
||||
bytes at the given offset. Changes persist only until reboot --
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
fb_info, fb_map - direct framebuffer access
|
||||
|
||||
.SH SYNOPSIS
|
||||
.BI void zenith::fb_info(Zenith::FbInfo* info);
|
||||
.BI void* zenith::fb_map();
|
||||
.BI void montauk::fb_info(Montauk::FbInfo* info);
|
||||
.BI void* montauk::fb_map();
|
||||
|
||||
.SH DESCRIPTION
|
||||
These syscalls allow userspace programs to access the linear
|
||||
@@ -13,8 +13,8 @@
|
||||
.SS fb_info
|
||||
Fills in an FbInfo structure with the framebuffer geometry:
|
||||
|
||||
Zenith::FbInfo fb;
|
||||
zenith::fb_info(&fb);
|
||||
Montauk::FbInfo fb;
|
||||
montauk::fb_info(&fb);
|
||||
// fb.width, fb.height, fb.pitch, fb.bpp
|
||||
|
||||
The pitch is the number of bytes per scanline (may be larger
|
||||
@@ -24,7 +24,7 @@
|
||||
Maps the physical framebuffer into the process address space at
|
||||
a fixed virtual address (0x50000000) and returns that address.
|
||||
|
||||
uint32_t* pixels = (uint32_t*)zenith::fb_map();
|
||||
uint32_t* pixels = (uint32_t*)montauk::fb_map();
|
||||
|
||||
Each pixel is a 32-bit value in 0xAARRGGBB format (blue in the
|
||||
low byte). Writing to this memory directly updates the screen.
|
||||
@@ -40,9 +40,9 @@
|
||||
.SH EXAMPLE
|
||||
Fill the screen with blue:
|
||||
|
||||
Zenith::FbInfo fb;
|
||||
zenith::fb_info(&fb);
|
||||
uint32_t* pixels = (uint32_t*)zenith::fb_map();
|
||||
Montauk::FbInfo fb;
|
||||
montauk::fb_info(&fb);
|
||||
uint32_t* pixels = (uint32_t*)montauk::fb_map();
|
||||
|
||||
for (uint64_t y = 0; y < fb.height; y++) {
|
||||
uint32_t* row = (uint32_t*)((uint8_t*)pixels + y * fb.pitch);
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
.TH INIT 1
|
||||
.SH NAME
|
||||
init - ZenithOS init system
|
||||
init - MontaukOS init system
|
||||
|
||||
.SH SYNOPSIS
|
||||
Spawned automatically by the kernel as PID 0.
|
||||
|
||||
.SH DESCRIPTION
|
||||
init is the first userspace process started by the ZenithOS
|
||||
init is the first userspace process started by the MontaukOS
|
||||
kernel. It chains system services in sequence, then launches
|
||||
the interactive shell.
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.TH INTRO 1
|
||||
.SH NAME
|
||||
intro - introduction to ZenithOS userspace
|
||||
intro - introduction to MontaukOS userspace
|
||||
|
||||
.SH DESCRIPTION
|
||||
ZenithOS is a hobbyist 64-bit operating system written in C++20.
|
||||
MontaukOS is a hobbyist 64-bit operating system written in C++20.
|
||||
Userspace programs run in Ring 3, are loaded as static ELF64
|
||||
binaries, and communicate with the kernel through the x86-64
|
||||
SYSCALL/SYSRET mechanism.
|
||||
@@ -11,7 +11,7 @@
|
||||
Programs are compiled with a freestanding cross-compiler and
|
||||
linked at virtual address 0x400000. There is no standard C
|
||||
library for C++ programs -- all system interaction goes through
|
||||
the zenith:: syscall wrappers.
|
||||
the montauk:: syscall wrappers.
|
||||
|
||||
.SH GETTING STARTED
|
||||
To write a new program, create a directory under programs/src/
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
extern "C" void _start() { ... }
|
||||
|
||||
There is no argc/argv. Use zenith::getargs() to retrieve any
|
||||
arguments passed by the parent process. Include <zenith/syscall.h>
|
||||
There is no argc/argv. Use montauk::getargs() to retrieve any
|
||||
arguments passed by the parent process. Include <montauk/syscall.h>
|
||||
for the full typed syscall API.
|
||||
|
||||
Build with:
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
.SH SHELL
|
||||
The interactive shell is the primary way to interact with
|
||||
ZenithOS. Commands are resolved by searching the PATH
|
||||
MontaukOS. Commands are resolved by searching the PATH
|
||||
directories (0:/os/, 0:/games/) for matching .elf binaries.
|
||||
Type 'help' at the shell prompt for a list of commands.
|
||||
Use 'man shell' for detailed shell documentation.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.TH LEGAL 7
|
||||
.SH NAME
|
||||
ZenithOS legal/copyright information
|
||||
MontaukOS legal/copyright information
|
||||
|
||||
.SH DESCRIPTION
|
||||
Copyright (c) 2025-2026 Daniel Hammer, et al. All rights reserved.
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
malloc, mfree, realloc - userspace heap allocation
|
||||
|
||||
.SH SYNOPSIS
|
||||
.BI void* zenith::malloc(uint64_t size);
|
||||
.BI void zenith::mfree(void* ptr);
|
||||
.BI void* zenith::realloc(void* ptr, uint64_t size);
|
||||
.BI void* montauk::malloc(uint64_t size);
|
||||
.BI void montauk::mfree(void* ptr);
|
||||
.BI void* montauk::realloc(void* ptr, uint64_t size);
|
||||
|
||||
.SH DESCRIPTION
|
||||
The userspace heap provides dynamic memory allocation on top of
|
||||
the kernel's page-mapping syscall (SYS_ALLOC). Include the
|
||||
header <zenith/heap.h> to use these functions.
|
||||
header <montauk/heap.h> to use these functions.
|
||||
|
||||
.SS malloc
|
||||
Allocates 'size' bytes from the free list. Returns a 16-byte
|
||||
@@ -18,21 +18,21 @@
|
||||
empty, it requests more pages from the kernel via SYS_ALLOC
|
||||
(minimum 16 KiB growth, initial seed of 64 KiB).
|
||||
|
||||
char* buf = (char*)zenith::malloc(1024);
|
||||
char* buf = (char*)montauk::malloc(1024);
|
||||
|
||||
.SS mfree
|
||||
Returns the block to the userspace free list. No syscall is
|
||||
made -- the memory stays mapped and is immediately reusable.
|
||||
Passing nullptr is a safe no-op.
|
||||
|
||||
zenith::mfree(buf);
|
||||
montauk::mfree(buf);
|
||||
|
||||
.SS realloc
|
||||
Resizes the allocation to 'size' bytes. Allocates a new block,
|
||||
copies the smaller of old/new sizes, and frees the old block.
|
||||
If ptr is nullptr, behaves like malloc.
|
||||
|
||||
buf = (char*)zenith::realloc(buf, 2048);
|
||||
buf = (char*)montauk::realloc(buf, 2048);
|
||||
|
||||
.SH IMPLEMENTATION
|
||||
The allocator uses a linked free-list with first-fit search.
|
||||
@@ -47,8 +47,8 @@
|
||||
.SH LOW-LEVEL PAGE API
|
||||
For large allocations or when direct page control is needed:
|
||||
|
||||
void* zenith::alloc(uint64_t size); // SYS_ALLOC
|
||||
void zenith::free(void* ptr); // SYS_FREE (no-op)
|
||||
void* montauk::alloc(uint64_t size); // SYS_ALLOC
|
||||
void montauk::free(void* ptr); // SYS_FREE (no-op)
|
||||
|
||||
alloc() maps zeroed pages starting at 0x40000000 and growing
|
||||
upward. Size is rounded up to 4 KiB page boundaries.
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
.TH SHELL 1
|
||||
.SH NAME
|
||||
shell - ZenithOS interactive command shell
|
||||
shell - MontaukOS interactive command shell
|
||||
|
||||
.SH DESCRIPTION
|
||||
The ZenithOS shell is a command interpreter launched by init
|
||||
The MontaukOS shell is a command interpreter launched by init
|
||||
after system services have started. It provides command
|
||||
execution, file navigation, and command history.
|
||||
|
||||
|
||||
+11
-11
@@ -3,9 +3,9 @@
|
||||
spawn, waitpid - create and wait for processes
|
||||
|
||||
.SH SYNOPSIS
|
||||
.BI int zenith::spawn(const char* path, const char* args = nullptr);
|
||||
.BI void zenith::waitpid(int pid);
|
||||
.BI int zenith::getargs(char* buf, uint64_t maxLen);
|
||||
.BI int montauk::spawn(const char* path, const char* args = nullptr);
|
||||
.BI void montauk::waitpid(int pid);
|
||||
.BI int montauk::getargs(char* buf, uint64_t maxLen);
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
Loads the ELF64 binary at the given VFS path and creates a new
|
||||
process. The path must include the drive prefix, for example:
|
||||
|
||||
int pid = zenith::spawn("0:/os/hello.elf");
|
||||
int pid = montauk::spawn("0:/os/hello.elf");
|
||||
|
||||
An optional second argument passes a string to the child:
|
||||
|
||||
int pid = zenith::spawn("0:/os/man.elf", "intro");
|
||||
int pid = montauk::spawn("0:/os/man.elf", "intro");
|
||||
|
||||
The new process gets its own PML4 page table, a 16 KiB stack
|
||||
(at 0x7FFFFEF000-0x7FFFFFF000), and begins executing at the
|
||||
@@ -31,7 +31,7 @@
|
||||
Blocks the calling process until the process with the given PID
|
||||
has exited. Internally, this yields the CPU in a loop:
|
||||
|
||||
zenith::waitpid(pid);
|
||||
montauk::waitpid(pid);
|
||||
|
||||
This is how the shell implements foreground process execution --
|
||||
it spawns a child and waits for it to complete before showing
|
||||
@@ -40,12 +40,12 @@
|
||||
.SH EXAMPLES
|
||||
Spawn a program and wait for it:
|
||||
|
||||
int pid = zenith::spawn("0:/os/hello.elf");
|
||||
int pid = montauk::spawn("0:/os/hello.elf");
|
||||
if (pid < 0) {
|
||||
zenith::print("spawn failed\n");
|
||||
montauk::print("spawn failed\n");
|
||||
} else {
|
||||
zenith::waitpid(pid);
|
||||
zenith::print("child exited\n");
|
||||
montauk::waitpid(pid);
|
||||
montauk::print("child exited\n");
|
||||
}
|
||||
|
||||
.SS getargs
|
||||
@@ -54,7 +54,7 @@
|
||||
-1 on error.
|
||||
|
||||
char args[256];
|
||||
zenith::getargs(args, sizeof(args));
|
||||
montauk::getargs(args, sizeof(args));
|
||||
|
||||
The argument string is set by the parent when calling spawn().
|
||||
If no arguments were provided, the buffer will be empty.
|
||||
|
||||
+51
-51
@@ -1,9 +1,9 @@
|
||||
.TH SYSCALLS 2
|
||||
.SH NAME
|
||||
syscalls - overview of ZenithOS system calls
|
||||
syscalls - overview of MontaukOS system calls
|
||||
|
||||
.SH DESCRIPTION
|
||||
ZenithOS provides 46 system calls (numbers 0-45) for userspace
|
||||
MontaukOS provides 46 system calls (numbers 0-45) for userspace
|
||||
programs. Syscalls use the x86-64 SYSCALL instruction with the
|
||||
following register convention:
|
||||
|
||||
@@ -15,119 +15,119 @@
|
||||
R8 Argument 5
|
||||
R9 Argument 6
|
||||
|
||||
Include <zenith/syscall.h> for typed wrappers in the zenith::
|
||||
Include <montauk/syscall.h> for typed wrappers in the montauk::
|
||||
namespace.
|
||||
|
||||
.SH PROCESS MANAGEMENT
|
||||
.B SYS_EXIT (0)
|
||||
Terminate the calling process.
|
||||
void zenith::exit(int code = 0);
|
||||
void montauk::exit(int code = 0);
|
||||
|
||||
.B SYS_YIELD (1)
|
||||
Yield the remainder of the time slice.
|
||||
void zenith::yield();
|
||||
void montauk::yield();
|
||||
|
||||
.B SYS_SLEEP_MS (2)
|
||||
Sleep for at least the given number of milliseconds.
|
||||
void zenith::sleep_ms(uint64_t ms);
|
||||
void montauk::sleep_ms(uint64_t ms);
|
||||
|
||||
.B SYS_GETPID (3)
|
||||
Return the PID of the calling process.
|
||||
int zenith::getpid();
|
||||
int montauk::getpid();
|
||||
|
||||
.B SYS_SPAWN (20)
|
||||
Spawn a new process from an ELF binary on the VFS.
|
||||
int zenith::spawn(const char* path, const char* args = nullptr);
|
||||
int montauk::spawn(const char* path, const char* args = nullptr);
|
||||
|
||||
.B SYS_WAITPID (23)
|
||||
Block until the given process has exited.
|
||||
void zenith::waitpid(int pid);
|
||||
void montauk::waitpid(int pid);
|
||||
|
||||
.SH CONSOLE I/O
|
||||
.B SYS_PRINT (4)
|
||||
Write a null-terminated string to the terminal.
|
||||
void zenith::print(const char* text);
|
||||
void montauk::print(const char* text);
|
||||
|
||||
.B SYS_PUTCHAR (5)
|
||||
Write a single character to the terminal.
|
||||
void zenith::putchar(char c);
|
||||
void montauk::putchar(char c);
|
||||
|
||||
.SH FILE I/O
|
||||
.B SYS_OPEN (6)
|
||||
Open a file. Returns a handle or negative on error.
|
||||
int zenith::open(const char* path);
|
||||
int montauk::open(const char* path);
|
||||
|
||||
.B SYS_READ (7)
|
||||
Read bytes from a file at a given offset.
|
||||
int zenith::read(int h, uint8_t* buf, uint64_t off, uint64_t sz);
|
||||
int montauk::read(int h, uint8_t* buf, uint64_t off, uint64_t sz);
|
||||
|
||||
.B SYS_GETSIZE (8)
|
||||
Get the size of an open file in bytes.
|
||||
uint64_t zenith::getsize(int handle);
|
||||
uint64_t montauk::getsize(int handle);
|
||||
|
||||
.B SYS_CLOSE (9)
|
||||
Close a file handle.
|
||||
void zenith::close(int handle);
|
||||
void montauk::close(int handle);
|
||||
|
||||
.B SYS_READDIR (10)
|
||||
List directory entries (max 64 per call).
|
||||
int zenith::readdir(const char* path, const char** names, int max);
|
||||
int montauk::readdir(const char* path, const char** names, int max);
|
||||
|
||||
.SH MEMORY
|
||||
.B SYS_ALLOC (11)
|
||||
Map zeroed pages into the process address space.
|
||||
void* zenith::alloc(uint64_t size);
|
||||
void* montauk::alloc(uint64_t size);
|
||||
|
||||
.B SYS_FREE (12)
|
||||
Reserved (currently a no-op).
|
||||
void zenith::free(void* ptr);
|
||||
void montauk::free(void* ptr);
|
||||
|
||||
.SH TIMEKEEPING
|
||||
.B SYS_GETTICKS (13)
|
||||
Get APIC timer ticks since boot.
|
||||
uint64_t zenith::get_ticks();
|
||||
uint64_t montauk::get_ticks();
|
||||
|
||||
.B SYS_GETMILLISECONDS (14)
|
||||
Get milliseconds elapsed since boot.
|
||||
uint64_t zenith::get_milliseconds();
|
||||
uint64_t montauk::get_milliseconds();
|
||||
|
||||
.B SYS_GETTIME (28)
|
||||
Get the current wall-clock date and time (UTC).
|
||||
Fills a Zenith::DateTime struct with Year, Month, Day,
|
||||
Fills a Montauk::DateTime struct with Year, Month, Day,
|
||||
Hour, Minute, and Second fields.
|
||||
void zenith::gettime(Zenith::DateTime* out);
|
||||
void montauk::gettime(Montauk::DateTime* out);
|
||||
|
||||
.SH SYSTEM
|
||||
.B SYS_GETINFO (15)
|
||||
Get OS name, version, and configuration.
|
||||
void zenith::get_info(Zenith::SysInfo* info);
|
||||
void montauk::get_info(Montauk::SysInfo* info);
|
||||
|
||||
.SH KEYBOARD
|
||||
.B SYS_ISKEYAVAILABLE (16)
|
||||
Check if a key event is pending (non-blocking).
|
||||
bool zenith::is_key_available();
|
||||
bool montauk::is_key_available();
|
||||
|
||||
.B SYS_GETKEY (17)
|
||||
Get the next key event (press or release).
|
||||
void zenith::getkey(Zenith::KeyEvent* out);
|
||||
void montauk::getkey(Montauk::KeyEvent* out);
|
||||
|
||||
.B SYS_GETCHAR (18)
|
||||
Block until a printable character is typed.
|
||||
char zenith::getchar();
|
||||
char montauk::getchar();
|
||||
|
||||
.SH NETWORKING
|
||||
.B SYS_PING (19)
|
||||
Send an ICMP echo request and wait for reply.
|
||||
int32_t zenith::ping(uint32_t ip, uint32_t timeoutMs);
|
||||
int32_t montauk::ping(uint32_t ip, uint32_t timeoutMs);
|
||||
|
||||
.B SYS_GETNETCFG (37)
|
||||
Get the current network configuration (IP, mask, gateway, MAC,
|
||||
DNS server).
|
||||
void zenith::get_netcfg(Zenith::NetCfg* out);
|
||||
void montauk::get_netcfg(Montauk::NetCfg* out);
|
||||
|
||||
.B SYS_SETNETCFG (38)
|
||||
Set the network configuration (IP, mask, gateway, DNS server).
|
||||
int zenith::set_netcfg(const Zenith::NetCfg* cfg);
|
||||
int montauk::set_netcfg(const Montauk::NetCfg* cfg);
|
||||
|
||||
.B SYS_RESOLVE (44)
|
||||
Resolve a hostname to an IPv4 address via DNS. Sends a UDP
|
||||
@@ -135,106 +135,106 @@
|
||||
for a reply. Returns the IP in network byte order, or 0 on
|
||||
failure. IP address strings (e.g. "10.0.0.1") are detected
|
||||
and returned directly without a DNS query.
|
||||
uint32_t zenith::resolve(const char* hostname);
|
||||
uint32_t montauk::resolve(const char* hostname);
|
||||
|
||||
.SH SOCKETS
|
||||
.B SYS_SOCKET (29)
|
||||
Create a socket. type=SOCK_TCP (1) or SOCK_UDP (2).
|
||||
Returns fd or -1.
|
||||
int zenith::socket(int type);
|
||||
int montauk::socket(int type);
|
||||
|
||||
.B SYS_CONNECT (30)
|
||||
Connect a TCP socket to a remote host.
|
||||
int zenith::connect(int fd, uint32_t ip, uint16_t port);
|
||||
int montauk::connect(int fd, uint32_t ip, uint16_t port);
|
||||
|
||||
.B SYS_BIND (31)
|
||||
Bind a socket to a local port for listening.
|
||||
int zenith::bind(int fd, uint16_t port);
|
||||
int montauk::bind(int fd, uint16_t port);
|
||||
|
||||
.B SYS_LISTEN (32)
|
||||
Start listening for incoming TCP connections.
|
||||
int zenith::listen(int fd);
|
||||
int montauk::listen(int fd);
|
||||
|
||||
.B SYS_ACCEPT (33)
|
||||
Accept an incoming connection on a listening socket.
|
||||
Returns a new socket fd for the client connection.
|
||||
int zenith::accept(int fd);
|
||||
int montauk::accept(int fd);
|
||||
|
||||
.B SYS_SEND (34)
|
||||
Send data on a connected socket. Returns bytes sent.
|
||||
int zenith::send(int fd, const void* data, uint32_t len);
|
||||
int montauk::send(int fd, const void* data, uint32_t len);
|
||||
|
||||
.B SYS_RECV (35)
|
||||
Receive data from a connected socket. Returns bytes
|
||||
received, 0 if no data available, or -1 on close/error.
|
||||
int zenith::recv(int fd, void* buf, uint32_t maxLen);
|
||||
int montauk::recv(int fd, void* buf, uint32_t maxLen);
|
||||
|
||||
.B SYS_CLOSESOCK (36)
|
||||
Close a socket and release its resources.
|
||||
int zenith::closesocket(int fd);
|
||||
int montauk::closesocket(int fd);
|
||||
|
||||
.B SYS_SENDTO (39)
|
||||
Send a UDP datagram to a specific destination.
|
||||
int zenith::sendto(int fd, const void* data, uint32_t len,
|
||||
int montauk::sendto(int fd, const void* data, uint32_t len,
|
||||
uint32_t destIp, uint16_t destPort);
|
||||
|
||||
.B SYS_RECVFROM (40)
|
||||
Receive a UDP datagram. Returns the source address.
|
||||
int zenith::recvfrom(int fd, void* buf, uint32_t maxLen,
|
||||
int montauk::recvfrom(int fd, void* buf, uint32_t maxLen,
|
||||
uint32_t* srcIp, uint16_t* srcPort);
|
||||
|
||||
.SH FILE WRITE
|
||||
.B SYS_FWRITE (41)
|
||||
Write bytes to a file at a given offset.
|
||||
int zenith::fwrite(int handle, const uint8_t* buf,
|
||||
int montauk::fwrite(int handle, const uint8_t* buf,
|
||||
uint64_t offset, uint64_t size);
|
||||
|
||||
.B SYS_FCREATE (42)
|
||||
Create a new file on the ramdisk. Returns a handle or negative
|
||||
on error.
|
||||
int zenith::fcreate(const char* path);
|
||||
int montauk::fcreate(const char* path);
|
||||
|
||||
.SH FRAMEBUFFER
|
||||
.B SYS_FBINFO (21)
|
||||
Get framebuffer dimensions and format.
|
||||
void zenith::fb_info(Zenith::FbInfo* info);
|
||||
void montauk::fb_info(Montauk::FbInfo* info);
|
||||
|
||||
.B SYS_FBMAP (22)
|
||||
Map the framebuffer into process memory at 0x50000000.
|
||||
void* zenith::fb_map();
|
||||
void* montauk::fb_map();
|
||||
|
||||
.SH TERMINAL
|
||||
.B SYS_TERMSIZE (24)
|
||||
Get terminal dimensions (columns and rows).
|
||||
void zenith::termsize(int* cols, int* rows);
|
||||
void montauk::termsize(int* cols, int* rows);
|
||||
|
||||
.B SYS_TERMSCALE (43)
|
||||
Get or set the terminal font scale factor. When scale_x is 0,
|
||||
returns the current scale as (scale_y << 32 | scale_x). When
|
||||
scale_x is non-zero, sets the font scale and returns the new
|
||||
terminal dimensions as (rows << 32 | cols).
|
||||
void zenith::termscale(int scale_x, int scale_y);
|
||||
void zenith::get_termscale(int* scale_x, int* scale_y);
|
||||
void montauk::termscale(int scale_x, int scale_y);
|
||||
void montauk::get_termscale(int* scale_x, int* scale_y);
|
||||
|
||||
.SH ARGUMENTS
|
||||
.B SYS_GETARGS (25)
|
||||
Get the argument string passed to this process at spawn time.
|
||||
int zenith::getargs(char* buf, uint64_t maxLen);
|
||||
int montauk::getargs(char* buf, uint64_t maxLen);
|
||||
|
||||
.SH RANDOM
|
||||
.B SYS_GETRANDOM (45)
|
||||
Fill a buffer with random bytes using RDTSC-seeded entropy.
|
||||
Returns the number of bytes written.
|
||||
int64_t zenith::getrandom(void* buf, uint32_t len);
|
||||
int64_t montauk::getrandom(void* buf, uint32_t len);
|
||||
|
||||
.SH POWER MANAGEMENT
|
||||
.B SYS_RESET (26)
|
||||
Reboot the system.
|
||||
[[noreturn]] void zenith::reset();
|
||||
[[noreturn]] void montauk::reset();
|
||||
|
||||
.B SYS_SHUTDOWN (27)
|
||||
Shut down the system (currently unimplemented).
|
||||
[[noreturn]] void zenith::shutdown();
|
||||
[[noreturn]] void montauk::shutdown();
|
||||
|
||||
.SH SEE ALSO
|
||||
spawn(2), file(2), framebuffer(2), malloc(3)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
tls-errors - BearSSL TLS and X.509 error codes
|
||||
|
||||
.SH DESCRIPTION
|
||||
ZenithOS uses BearSSL for TLS 1.2 connections. When a TLS
|
||||
MontaukOS uses BearSSL for TLS 1.2 connections. When a TLS
|
||||
operation fails, an integer error code is reported. This page
|
||||
lists all possible error codes.
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
.TH WIKI 1
|
||||
.SH NAME
|
||||
wiki - Wikipedia article viewer for ZenithOS
|
||||
wiki - Wikipedia article viewer for MontaukOS
|
||||
|
||||
.SH SYNOPSIS
|
||||
wiki <title>
|
||||
|
||||
+17
-17
@@ -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,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
@@ -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,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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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++];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,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
@@ -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,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
@@ -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,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
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,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
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,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
@@ -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,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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user