Pull upstream changes from TELY UI

This commit is contained in:
doylet committed 2026-11-26 15:10:16 +11:00
1 parent 7147ad52a2
commit d5c98d5288
20 files changed
+17900 -10682

No files matched your search

+24 -26
View File
@@ -33,24 +33,20 @@ DN_Str8 DN_SH_CLIOptionsStr8()
return result;
}
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, int arg_count)
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, DN_ArgvIterator *it)
{
DN_SHCLIEatArgResult result = {};
result.arg_ptr = arg_ptr;
result.arg_count = arg_count;
DN_Str8 arg = {};
if (arg_count)
arg = DN_Str8FromCStr8(*result.arg_ptr);
DN_Str8 arg = it->arg;
// NOTE: Try handling the argument if we recognise it
{
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-exe-path"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->exe_path = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->exe_path = value;
if (DN_OS_PathInfo(args->exe_path).type != DN_OSPathInfoType_File) {
if (DN_Os_PathInfo(args->exe_path).type != DN_OsPathInfoType_File) {
result.error_msg = DN_Str8Lit("Seshc executable path does not point to a file");
result.error_arg = args->exe_path;
args->exe_path = {};
@@ -58,11 +54,12 @@ DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, i
}
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-ini-path"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->ini_path = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->ini_path = value;
if (DN_OS_PathInfo(args->ini_path).type != DN_OSPathInfoType_File) {
if (DN_Os_PathInfo(args->ini_path).type != DN_OsPathInfoType_File) {
result.error_msg = DN_Str8Lit("Seshc ini path does not point to a file");
result.error_arg = args->ini_path;
args->ini_path = {};
@@ -70,9 +67,10 @@ DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, i
}
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-seed-node"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->seed_node_url = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->seed_node_url = value;
}
}
@@ -124,7 +122,7 @@ bool DN_SH_MsgSendBlockingFmt(DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, cha
DN_Str8Slice cmd_line = {};
cmd_line.data = cmds;
cmd_line.count = cmds_count;
DN_OSExecResult exec = DN_OS_Exec(cmd_line, DN_OS_ExecArgsDefault(), &scratch.arena, nullptr);
DN_OsExecResult exec = DN_Os_Exec(cmd_line, DN_Os_ExecArgsDefault(), &scratch.arena, nullptr);
result = exec.os_error_code == 0 && exec.exit_code == 0;
if (!result) {
DN_LogErrorF("Error sending message to %.*s (exit code: %d, os: %d): %.*s",
@@ -139,7 +137,7 @@ bool DN_SH_MsgSendBlockingFmt(DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, cha
return result;
}
static int DN_SH_MsgSendDetachedFmtThreadFunc_(DN_OSThread *thread)
static int DN_SH_MsgSendDetachedFmtThreadFunc_(DN_OsThread *thread)
{
DN_SHMsgSendAsyncContext_ *context = DN_Cast(DN_SHMsgSendAsyncContext_ *) thread->user_context;
context->send_success = DN_SH_MsgSendBlockingFmt(context->send, &context->args, "%.*s", DN_Str8PrintFmt(context->msg));
@@ -163,17 +161,17 @@ static DN_SHMsgSendAsyncHandle DN_SH_MsgSendAsyncFmtVMaybeDetached_(DN_SHMsgSend
context->detached = detached;
// NOTE: Execute and forget
DN_OSThreadInitArgs thread_args = DN_OS_ThreadInitArgsDefault();
DN_OsThreadInitArgs thread_args = DN_Os_ThreadInitArgsDefault();
if (detached)
thread_args.flags |= DN_OSThreadFlags_Detached;
thread_args.flags |= DN_OsThreadFlags_Detached;
DN_OS_ThreadInit(&result.thread, DN_SH_MsgSendDetachedFmtThreadFunc_, thread_args, context);
DN_Os_ThreadInit(&result.thread, DN_SH_MsgSendDetachedFmtThreadFunc_, thread_args, context);
return result;
}
void DN_SH_MsgSendDetachedFmt(DN_SHMsgSendData send, DN_SHCLIArgs *cli_args, char const *fmt, ...)
{
DN_Arena arena_stack = DN_OS_ArenaFromHeapVirtual(0, 0, DN_MemFlags_Nil);
DN_Arena arena_stack = DN_Os_ArenaFromHeapVirtual(0, 0, DN_MemListFlags_Nil);
DN_Arena *arena = DN_ArenaNewZ(&arena_stack, DN_Arena);
*arena = arena_stack;
@@ -196,7 +194,7 @@ DN_SHMsgSendAsyncStatus DN_SH_MsgSendAsyncWait(DN_SHMsgSendAsyncHandle *handle,
{
DN_SHMsgSendAsyncStatus result = DN_SHMsgSendAsyncStatus_Success;
if (handle && handle->thread.user_context) {
bool joined = DN_OS_ThreadJoin(&handle->thread, timeout_ms, DN_TcDeinitArenas_Yes);
bool joined = DN_Os_ThreadJoin(&handle->thread, timeout_ms, DN_TcDeinitArenas_Yes);
if (joined) {
DN_SHMsgSendAsyncContext_ *context = DN_Cast(DN_SHMsgSendAsyncContext_ *) handle->thread.user_context;
result = context->send_success ? DN_SHMsgSendAsyncStatus_Success : DN_SHMsgSendAsyncStatus_Failed;
@@ -222,7 +220,7 @@ void DN_SH_LogBroadcastFmtV(DN_SHLogMode mode, DN_LogType type, DN_SHMsgSendData
}
DN_LogF(type, "%.*s%.*s. %.*s", DN_Str8PrintFmt(prefix), DN_Str8PrintFmt(short_desc), DN_Str8PrintFmt(msg));
DN_Date date = DN_OS_DateLocalTimeNow();
DN_Date date = DN_Os_DateLocalTimeNow();
// NOTE: 12-hour conversion
DN_U8 hour12 = date.hour % 12;