From c7291ead23083a3a38fc8831ce22418fb8b4c211 Mon Sep 17 00:00:00 2001 From: snarmph Date: Fri, 24 Oct 2025 10:58:09 +0200 Subject: [PATCH] . --- colla.c | 9 +++++---- colla.h | 2 +- colla_win32.c | 16 +++++++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/colla.c b/colla.c index 22a63d0..b8dee09 100644 --- a/colla.c +++ b/colla.c @@ -1263,7 +1263,7 @@ os_log_colour_e os_log_level_colours[LOG_COL__COUNT] = { [LOG_DEBUG] = LOG_COL_BLUE, [LOG_INFO] = LOG_COL_GREEN, [LOG_WARN] = LOG_COL_YELLOW, - [LOG_ERR] = LOG_COL_MAGENTA, + [LOG_ERR] = LOG_COL_RED, [LOG_FATAL] = LOG_COL_RED, }; @@ -1283,20 +1283,21 @@ void os_log__stdout(log_event_t *ev) { ev->time->tm_min, ev->time->tm_sec ); + os_log_set_colour(LOG_COL_RESET); } - os_log_set_colour(os_log_level_colours[ev->level]); if (ev->level != LOG_BASIC) { + os_log_set_colour(os_log_level_colours[ev->level]); fmt_print("%-8s ", os_log_level_strings[ev->level]); + os_log_set_colour(LOG_COL_RESET); } if (!nofile) { os_log_set_colour(LOG_COL_DARK_GREY); fmt_print("%s:%d ", ev->file, ev->line); + os_log_set_colour(LOG_COL_RESET); } - os_log_set_colour(LOG_COL_RESET); - fmt_printv(ev->fmt, ev->args); fmt_print("\n"); } diff --git a/colla.h b/colla.h index ba74684..65cff07 100644 --- a/colla.h +++ b/colla.h @@ -1319,7 +1319,7 @@ typedef struct { strview_t body; } http_request_desc_t; -typedef void (*http_request_callback_fn)(strview_t chunk, void *udata); +typedef void (*http_request_callback_fn)(http_header_t *headers, strview_t chunk, void *udata); // arena_t *arena, strview_t url, [ http_header_t *headers, int header_count, strview_t body ] #define http_get(arena, url, ...) http_request(&(http_request_desc_t){ arena, url, .request_type = HTTP_GET, .version = { 1, 1 }, __VA_ARGS__ }) diff --git a/colla_win32.c b/colla_win32.c index f64e598..129d664 100644 --- a/colla_win32.c +++ b/colla_win32.c @@ -184,6 +184,16 @@ void os__win_free_entity(os_entity_t *entity) { list_push(w32_data.entity_free, entity); } +HANDLE os__win_get_handle(oshandle_t handle) { + os_entity_t *e = (os_entity_t *)handle.data; + switch (e->kind) { + case OS_KIND_THREAD: + return e->thread.handle; + default: + return e; + } +} + void os_init(void) { SetConsoleOutputCP(CP_UTF8); @@ -288,7 +298,7 @@ os_wait_t os_wait_on_handles(oshandle_t *handles, int count, bool wait_all, u32 colla_assert(count < COLLA_OS_MAX_WAITABLE_HANDLES); for (int i = 0; i < count; ++i) { - win_handles[i] = (HANDLE)(handles[i].data); + win_handles[i] = os__win_get_handle(handles[i]); } DWORD result = WaitForMultipleObjects(count, win_handles, wait_all, milliseconds); @@ -720,7 +730,7 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op for (int i = 0; i < cur->count; ++i) { strview_t arg = cur->items[i]; if (strv_contains(arg, ' ')) { - ostr_print(&cmdline, "%v", arg); + ostr_print(&cmdline, "\"%v\"", arg); } else { ostr_puts(&cmdline, arg); @@ -1195,7 +1205,7 @@ http_res_t http_request_cb(http_request_desc_t *req, http_request_callback_fn ca strview_t chunk = strv(read_buffer, read); if (callback) { - callback(chunk, userdata); + callback(res.headers, chunk, userdata); } ostr_puts(&body, chunk); }