ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
update_checker.c
Go to the documentation of this file.
1
5
6/* Storage capacities in elements; text buffers include the terminating NUL. */
7#define NETWORK_UPDATE_CHECKER_LINE_BUFFER_SIZE 512
8#define NETWORK_UPDATE_CHECKER_LATEST_TAG_BUFFER_SIZE 64
9#define NETWORK_UPDATE_CHECKER_LINE_SHORT_BUFFER_SIZE 256
10#define NETWORK_UPDATE_CHECKER_SUGGESTION_BUFFER_SIZE 512
11
13#include <recast/defer.h>
16#include <ascii-chat/version.h>
18#include <libplatform/socket.h>
20#include <libplatform/system.h>
21#include <libplatform/filesystem.h>
24#include <ascii-chat/log/log.h>
25#include <ascii-chat/common.h>
26
27#include <yyjson.h>
28
29#include <stdio.h>
30#include <stdatomic.h>
31#include <stdlib.h>
32#include <string.h>
33#include <time.h>
34#include <errno.h>
35
36// Cache file is stored in ~/.config/ascii-chat/last_update_check
37#define UPDATE_CHECK_CACHE_FILENAME "last_update_check"
38
39// Check is fresh if < 7 days old
40#define UPDATE_CHECK_CACHE_MAX_AGE_SECONDS (7 * 24 * 60 * 60)
41
42// DNS timeout for connectivity check
43
44// GitHub API endpoint
45#define GITHUB_API_HOSTNAME "api.github.com"
46#define GITHUB_RELEASES_PATH "/repos/zfogg/ascii-chat/releases/latest"
47
48static void trim_line_ending(char *line) {
49 if (!line) {
50 return;
51 }
52
53 size_t len = strlen(line);
54 while (len > 0 && (line[len - 1] == '\n' || line[len - 1] == '\r')) {
55 line[--len] = '\0';
56 }
57}
58
63static char *get_cache_file_path(void) {
64 // An explicit cache directory is useful for isolated automation and portable
65 // launches; normal installations continue using the platform config path.
66 const char *override_dir = SAFE_GETENV("ASCII_CHAT_UPDATE_CACHE_DIR");
67 char *config_dir = NULL;
68 if (override_dir && override_dir[0]) {
69 SAFE_STRDUP(config_dir, override_dir);
70 } else {
71 /* libplatform returns this string from the platform allocator. Copy it
72 * into ascii-chat-owned storage before the common cleanup path, because
73 * SAFE_FREE may use mimalloc while libplatform deliberately uses the
74 * regular C allocator. */
75 char *platform_config_dir = get_config_dir();
76 if (platform_config_dir) {
77 SAFE_STRDUP(config_dir, platform_config_dir);
78 free(platform_config_dir);
79 }
80 }
81 if (!config_dir) {
82 log_error("Failed to get config directory for update check cache");
83 return NULL;
84 }
85
86 // The config directory may not exist on a first run. Create it before any
87 // caller attempts to open the cache file for writing.
88 if (platform_mkdir_recursive(config_dir, 0700) != ASCIICHAT_OK) {
89 log_warn("Failed to create update check config directory: %s", config_dir);
90 }
91
92 // Build cache file path
93 size_t path_len = strlen(config_dir) + strlen(UPDATE_CHECK_CACHE_FILENAME) + 2;
94 char *cache_path = SAFE_MALLOC(path_len, char *);
95 size_t dir_len = strlen(config_dir);
96 const char *separator = dir_len && (config_dir[dir_len - 1] == '/' || config_dir[dir_len - 1] == '\\') ? "" : "/";
97 snprintf(cache_path, path_len, "%s%s%s", config_dir, separator, UPDATE_CHECK_CACHE_FILENAME);
98 SAFE_FREE(config_dir);
99
100 return cache_path;
101}
102
104 if (!result) {
105 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL result pointer");
106 }
107
108 memset(result, 0, sizeof(*result));
109
110 char *cache_path = get_cache_file_path();
111 if (!cache_path) {
112 return SET_ERRNO(ERROR_FILE_OPERATION, "Could not determine cache file path");
113 }
114 defer(SAFE_FREE(cache_path));
115
116 /* A cache miss is expected on first launch. Check existence through the
117 * platform layer before opening so Windows does not turn the missing file
118 * into a stale errno-stack notification. */
119 if (platform_access(cache_path, PLATFORM_ACCESS_EXISTS) != 0)
120 return ASCIICHAT_OK;
121
122 FILE *f = platform_fopen("file_stream", cache_path, "r");
123 if (!f) {
124 const char *error_msg = file_read_error_message(cache_path);
125 return SET_ERRNO(ERROR_FILE_OPERATION, "%s", error_msg);
126 }
127 defer(SAFE_FCLOSE(f));
128
129 // Read line 1: timestamp
131 if (!fgets(line, sizeof(line), f)) {
132 return SET_ERRNO(ERROR_FILE_OPERATION, "Failed to read timestamp from cache");
133 }
134
135 // Parse timestamp safely with error checking
136 errno = 0;
137 char *endptr = NULL;
138 long long timestamp_ll = strtoll(line, &endptr, 10);
139 if (errno != 0 || endptr == line) {
140 log_error("Failed to parse timestamp from cache: invalid value '%s'", line);
141 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid timestamp in cache file");
142 }
143 result->last_check_time = (time_t)timestamp_ll;
144
145 // Read line 2: latest version (may be empty if check failed)
146 if (fgets(line, sizeof(line), f)) {
147 trim_line_ending(line);
148 SAFE_STRNCPY(result->latest_version, line, sizeof(result->latest_version));
149 }
150
151 // Read line 3: latest SHA (may be empty if check failed)
152 if (fgets(line, sizeof(line), f)) {
153 trim_line_ending(line);
154 SAFE_STRNCPY(result->latest_sha, line, sizeof(result->latest_sha));
155 }
156
157 // Read line 4: release URL. This field is required in the current cache
158 // format; an older or partially-written cache must be refreshed.
159 if (!fgets(line, sizeof(line), f)) {
160 SAFE_FCLOSE(f);
161 // Treat a legacy cache exactly like a missing cache. Close the file before
162 // removing it so this also works on Windows, where open files cannot be
163 // deleted.
164 (void)remove(cache_path);
165 return SET_ERRNO(ERROR_FORMAT, "Update cache format is obsolete");
166 }
167 trim_line_ending(line);
168 SAFE_STRNCPY(result->release_url, line, sizeof(result->release_url));
169
170 // Older four-line cache files remain valid; they simply have no dismissal.
171 if (fgets(line, sizeof(line), f)) {
172 result->dismissed_until = (time_t)strtoll(line, NULL, 10);
173 }
174
175 SAFE_FCLOSE(f);
176
177 // Fill in current version/SHA
178 SAFE_STRNCPY(result->current_version, ASCII_CHAT_VERSION_STRING, sizeof(result->current_version));
179 SAFE_STRNCPY(result->current_sha, ASCII_CHAT_GIT_COMMIT_HASH, sizeof(result->current_sha));
180
181 // Determine if update is available using version comparison (if we have cached data)
182 if (result->latest_version[0] != '\0') {
183 semantic_version_t current_ver = version_parse(result->current_version);
184 semantic_version_t latest_ver = version_parse(result->latest_version);
185
186 if (current_ver.valid && latest_ver.valid) {
187 int cmp = version_compare(latest_ver, current_ver);
188 result->update_available = (cmp > 0); // Update available if latest > current
189 result->check_succeeded = true;
190 } else {
191 // Cache contains invalid version data - delete it
192 log_warn("Update cache contains invalid version data (current:%s, latest:%s) - deleting corrupted cache", result->current_version, result->latest_version);
193 if (remove(cache_path) != 0) {
194 log_warn("Failed to delete corrupted cache file: %s", cache_path);
195 }
196 return SET_ERRNO(ERROR_FORMAT, "Corrupted cache file deleted");
197 }
198 }
199
200 return ASCIICHAT_OK;
201}
202
204 if (!result) {
205 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL result pointer");
206 }
207
208 char *cache_path = get_cache_file_path();
209 if (!cache_path) {
210 return SET_ERRNO(ERROR_FILE_OPERATION, "Could not determine cache file path");
211 }
212 defer(SAFE_FREE(cache_path));
213
214 FILE *f = platform_fopen("file_stream", cache_path, "w");
215 if (!f) {
216 const char *error_msg = file_write_error_message(cache_path);
217 return SET_ERRNO(ERROR_FILE_OPERATION, "%s", error_msg);
218 }
219
220 // Write timestamp
221 fprintf(f, "%lld\n", (long long)result->last_check_time);
222
223 // Write version (may be empty if check failed)
224 fprintf(f, "%s\n", result->latest_version);
225
226 // Write SHA (may be empty if check failed)
227 fprintf(f, "%s\n", result->latest_sha);
228
229 // Write the release URL so cached notifications retain the exact GitHub
230 // source returned by the API.
231 fprintf(f, "%s\n", result->release_url);
232 fprintf(f, "%lld\n", (long long)result->dismissed_until);
233
234 fclose(f);
235 return ASCIICHAT_OK;
236}
237
239 if (!result || result->last_check_time == 0) {
240 return false;
241 }
242
243 time_t now = time(NULL);
244 time_t age = now - result->last_check_time;
245
247}
248
250 if (!result) {
251 return;
252 }
254 (void)update_check_save_cache(result);
255}
256
258 return result && result->dismissed_until > time(NULL);
259}
260
270static bool parse_github_release_json(const char *json, char *tag_name, size_t tag_size, char *html_url, size_t url_size) {
271 if (!json) {
272 return false;
273 }
274
275 yyjson_doc *doc = yyjson_read(json, strlen(json), 0);
276 if (!doc) {
277 log_error("Failed to parse GitHub API response as JSON");
278 return false;
279 }
280
281 yyjson_val *root = yyjson_doc_get_root(doc);
282 yyjson_val *tag = yyjson_obj_get(root, "tag_name");
283 yyjson_val *url = yyjson_obj_get(root, "html_url");
284
285 bool ok = false;
286 if (yyjson_is_str(tag) && yyjson_is_str(url)) {
287 SAFE_STRNCPY(tag_name, yyjson_get_str(tag), tag_size);
288 SAFE_STRNCPY(html_url, yyjson_get_str(url), url_size);
289 ok = true;
290 } else {
291 if (!yyjson_is_str(tag)) {
292 log_error("Failed to parse tag_name from GitHub API response");
293 }
294 if (!yyjson_is_str(url)) {
295 log_error("Failed to parse html_url from GitHub API response");
296 }
297 }
298
299 yyjson_doc_free(doc);
300 return ok;
301}
302
303// A cache miss is resolved by a fresh check and must not cover the update dialog.
304static asciichat_error_t load_optional_cache(update_check_result_t *result) {
306 bool previous = errno_notifications_suppress(true);
310 return error;
311}
312
314 return result && load_optional_cache(result) == ASCIICHAT_OK && update_check_is_cache_fresh(result);
315}
316
318 if (!result) {
319 return SET_ERRNO(ERROR_INVALID_PARAM, "NULL result pointer");
320 }
321
322 update_check_result_t cached = {0};
323 bool have_cached = load_optional_cache(&cached) == ASCIICHAT_OK;
324 memset(result, 0, sizeof(*result));
325
326 // Fill in current version and SHA
327 SAFE_STRNCPY(result->current_version, ASCII_CHAT_VERSION_STRING, sizeof(result->current_version));
328 SAFE_STRNCPY(result->current_sha, ASCII_CHAT_GIT_COMMIT_HASH, sizeof(result->current_sha));
329 result->last_check_time = time(NULL);
330
331#ifndef NDEBUG
332 // Deterministic local seam for PTY smoke coverage. Release builds never
333 // consult it, and ordinary debug runs continue through the network path.
334 const char *test_latest = SAFE_GETENV("ASCII_CHAT_TEST_UPDATE_LATEST_VERSION");
335 if (test_latest && test_latest[0]) {
336 SAFE_STRNCPY(result->latest_version, test_latest, sizeof(result->latest_version));
337 const char *test_slow = SAFE_GETENV("ASCII_CHAT_TEST_UPDATE_SLOW");
338 if (test_slow && strcmp(test_slow, "1") == 0)
339 platform_sleep_ms(1000);
340 const char *test_gate = SAFE_GETENV("ASCII_CHAT_TEST_UPDATE_GATE");
341 if (test_gate && test_gate[0]) {
342 uint64_t deadline = time_get_ns() + 30 * NS_PER_SEC_INT;
343 while (platform_access(test_gate, PLATFORM_ACCESS_EXISTS) != 0 && time_get_ns() < deadline)
344 platform_sleep_ms(10);
345 }
346 SAFE_STRNCPY(result->release_url, "https://github.com/zfogg/ascii-chat/releases/latest", sizeof(result->release_url));
347 result->check_succeeded = true;
348 semantic_version_t current_ver = version_parse(result->current_version);
349 semantic_version_t latest_ver = version_parse(result->latest_version);
350 result->update_available = current_ver.valid && latest_ver.valid && version_compare(latest_ver, current_ver) > 0;
351 if (have_cached && strcmp(cached.latest_version, result->latest_version) == 0) {
352 result->dismissed_until = cached.dismissed_until;
353 }
354 (void)update_check_save_cache(result);
355 return ASCIICHAT_OK;
356 }
357#endif
358
359 // Fetch latest release from GitHub API
360 log_info("Checking for updates from GitHub releases...");
362 if (!response) {
363 log_warn("Failed to fetch GitHub releases API (timeout or network error)");
364 // Don't save cache on network failure — retry next startup
365 result->check_succeeded = false;
366 return SET_ERRNO(ERROR_NETWORK, "Failed to fetch GitHub releases");
367 }
368
369 defer(SAFE_FREE(response));
370
371 // Parse JSON response
374
375 if (!parse_github_release_json(response, latest_tag, sizeof(latest_tag), release_url, sizeof(release_url))) {
376 log_error("Failed to parse GitHub API response");
377 // Don't save cache on parse failure — retry next startup
378 result->check_succeeded = false;
379 return SET_ERRNO(ERROR_FORMAT, "Failed to parse GitHub API JSON");
380 }
381
382 // Fill in result
383 SAFE_STRNCPY(result->latest_version, latest_tag, sizeof(result->latest_version));
384 SAFE_STRNCPY(result->release_url, release_url, sizeof(result->release_url));
385 result->latest_sha[0] = '\0';
386 result->check_succeeded = true;
387 if (have_cached && strcmp(cached.latest_version, result->latest_version) == 0) {
388 result->dismissed_until = cached.dismissed_until;
389 }
390
391 // Compare versions semantically
392 semantic_version_t current_ver = version_parse(result->current_version);
393 semantic_version_t latest_ver = version_parse(result->latest_version);
394
395 if (!current_ver.valid || !latest_ver.valid) {
396 log_warn("Failed to parse version strings for comparison (current: %s, latest: %s)", result->current_version, result->latest_version);
397 result->update_available = false;
398 } else {
399 int cmp = version_compare(latest_ver, current_ver);
400 result->update_available = (cmp > 0); // Update available if latest > current
401 }
402
403 if (result->update_available) {
404 log_info("Update available: %s → %s", result->current_version, result->latest_version);
405 } else {
406 log_info("Already on latest version: %s", result->current_version);
407 }
408
409 // Save to cache
411
412 return ASCIICHAT_OK;
413}
414
418#ifndef _WIN32
419static bool is_homebrew_install(void) {
420 // Check if binary is in Homebrew Cellar directory
421 char exe_path[PLATFORM_MAX_PATH_LENGTH];
422 if (!platform_get_executable_path(exe_path, sizeof(exe_path))) {
423 return false;
424 }
425
426 return (strstr(exe_path, "/Cellar/ascii-chat") != NULL || strstr(exe_path, "/opt/homebrew/") != NULL || strstr(exe_path, "/usr/local/Cellar/") != NULL);
427}
428
432static bool is_arch_linux(void) {
433#ifdef __linux__
434 // Check /etc/os-release for Arch
435 FILE *f = platform_fopen("file_stream", "/etc/os-release", "r");
436 if (!f) {
437 return false;
438 }
439
441 bool is_arch = false;
442 while (fgets(line, sizeof(line), f)) {
443 if (strstr(line, "ID=arch") || strstr(line, "ID=\"arch\"")) {
444 is_arch = true;
445 break;
446 }
447 }
448
449 fclose(f);
450 return is_arch;
451#else
452 return false;
453#endif
454}
455#endif
456
458#if defined(ASCIICHAT_INSTALLED_BY_HOMEBREW)
460#elif defined(ASCIICHAT_INSTALLED_BY_SCOOP)
462#elif defined(ASCIICHAT_INSTALLED_BY_AUR)
464#elif defined(_WIN32)
466#else
467 if (is_homebrew_install()) {
469 }
470
471 if (is_arch_linux()) {
473 }
474
475 // The published Unix installer is the default outside package-managed installs.
477#endif
478}
479
481 static _Atomic int cached_helper = -1;
482 int helper = atomic_load(&cached_helper);
483 if (helper == -1) {
484 const char *paru[] = {"paru", "--version", NULL};
485 const char *yay[] = {"yay", "--version", NULL};
486 helper = platform_execute_subprocess("paru", paru, NULL, 0, NULL, NULL) == 0 ? 1 : platform_execute_subprocess("yay", yay, NULL, 0, NULL, NULL) == 0 ? 2 : 0;
487 atomic_store(&cached_helper, helper);
488 }
489 return helper == 1 ? "paru" : helper == 2 ? "yay" : NULL;
490}
491
492void update_check_get_upgrade_suggestion(install_method_t method, const char *latest_version, char *buffer, size_t buffer_size) {
493 if (!buffer || buffer_size == 0) {
494 return;
495 }
496
497 switch (method) {
499 snprintf(buffer, buffer_size, "brew upgrade ascii-chat");
500 break;
501
503 snprintf(buffer, buffer_size, "scoop update ascii-chat");
504 break;
505
507#ifdef _WIN32
508 snprintf(buffer, buffer_size, "irm https://ascii-chat.com/install.ps1 | iex");
509#else
510 snprintf(buffer, buffer_size, "curl -fsSL https://ascii-chat.com/install.sh | bash");
511#endif
512 break;
513
515 const char *helper = update_check_get_aur_helper();
516 if (helper) {
517 snprintf(buffer, buffer_size, "%s -S ascii-chat", helper);
518 } else {
519 snprintf(buffer, buffer_size, "<your-aur-helper> -Ss ascii-chat");
520 }
521 break;
522 }
523
526 default:
527 snprintf(buffer, buffer_size, "https://github.com/zfogg/ascii-chat/releases/tag/%s", latest_version ? latest_version : "latest");
528 break;
529 }
530}
531
532void update_check_format_notification(const update_check_result_t *result, char *buffer, size_t buffer_size) {
533 if (!result || !buffer || buffer_size == 0) {
534 return;
535 }
536
537 // Get upgrade suggestion
540 update_check_get_upgrade_suggestion(method, result->latest_version, suggestion, sizeof(suggestion));
541
542 // Keep the notification useful even when it is displayed in a log line:
543 // identify the versions, provide an actionable command or download URL, and
544 // point to the exact GitHub release that was returned by the API.
545 snprintf(buffer, buffer_size, "Update available: %s → %s. %s%s. Release notes: %s", result->current_version, result->latest_version,
546 (method == INSTALL_METHOD_GITHUB || method == INSTALL_METHOD_UNKNOWN) ? "Download: " : "Run: ", suggestion, result->release_url);
547}
548
550 update_check_result_t local_result;
551 update_check_result_t *target = result ? result : &local_result;
552
553 // Try to load from cache first
554 asciichat_error_t cache_err = load_optional_cache(target);
555 if (cache_err == ASCIICHAT_OK && update_check_is_cache_fresh(target)) {
556 // Cache is fresh, use it
557 log_debug("Using cached update check result (age: %.1f days)", (time(NULL) - target->last_check_time) / (double)SEC_PER_DAY);
558 return ASCIICHAT_OK;
559 }
560
561 // Cache is stale or missing, perform fresh check
562 log_debug("Performing automatic update check (cache %s)", cache_err == ASCIICHAT_OK ? "stale" : "missing");
563 asciichat_error_t check_err = update_check_perform(target);
564 if (check_err != ASCIICHAT_OK) {
565 // Check failed, but don't fail startup
566 log_debug("Automatic update check failed (continuing startup)");
567 return check_err;
568 }
569
570 return ASCIICHAT_OK;
571}
void errno_scope_end(asciichat_errno_scope_t scope, asciichat_errno_outcome_t outcome)
bool errno_notifications_suppress(bool suppress)
asciichat_errno_scope_t errno_scope_begin(void)
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
#define SET_ERRNO(code,...)
@ ASCIICHAT_ERRNO_HANDLED
🌐 DNS resolution utilities
Dedicated worker for all pending errno stacks and handled history. Signal handlers may only request a...
int platform_mkdir_recursive(const char *path, int mode)
Definition filesystem.c:36
int platform_access(const char *pathname, int mode)
Definition filesystem.c:95
FILE * platform_fopen(const char *name, const char *filename, const char *mode)
Definition filesystem.c:18
int buffer_size
Size of circular buffer.
Definition grep.c:68
#define SAFE_STRNCPY(dst, src, size)
#define SAFE_FREE(ptr)
#define SAFE_MALLOC(size, cast)
#define SAFE_GETENV(name)
#define PLATFORM_MAX_PATH_LENGTH
unsigned long long uint64_t
#define SAFE_STRDUP(dst, src)
#define SAFE_FCLOSE(fp)
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ERROR_NETWORK
Definition error_codes.h:76
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_FILE_OPERATION
@ ERROR_INVALID_PARAM
@ ERROR_FORMAT
#define log_warn(...)
Log a WARN message.
Definition log/log.h:615
#define log_error(...)
Log an ERROR message.
Definition log/log.h:628
#define log_info(...)
Log an INFO message.
Definition log/log.h:602
#define log_debug(...)
Log a DEBUG message.
Definition log/log.h:589
#define NS_PER_SEC_INT
Definition time.h:173
#define SEC_PER_DAY
Definition time.h:185
asciichat_error_t update_check_startup(update_check_result_t *result)
Perform startup update check with caching.
install_method_t
Installation method for suggesting upgrade command.
void update_check_dismiss_for_a_week(update_check_result_t *result)
#define NETWORK_UPDATE_CHECKER_RELEASE_URL_BUFFER_SIZE
char * https_get(const char *hostname, const char *path)
Perform HTTPS GET request.
void update_check_get_upgrade_suggestion(install_method_t method, const char *latest_version, char *buffer, size_t buffer_size)
Get upgrade suggestion string.
bool update_check_is_cache_fresh(const update_check_result_t *result)
Check if cache is fresh (< 7 days old).
const char * update_check_get_aur_helper(void)
asciichat_error_t update_check_perform(update_check_result_t *result)
Check for updates from GitHub releases API.
asciichat_error_t update_check_save_cache(const update_check_result_t *result)
Save update check result to cache.
bool update_check_try_fresh_cache(update_check_result_t *result)
bool update_check_is_dismissed(const update_check_result_t *result)
asciichat_error_t update_check_load_cache(update_check_result_t *result)
Load cached update check result.
install_method_t update_check_detect_install_method(void)
Detect installation method.
void update_check_format_notification(const update_check_result_t *result, char *buffer, size_t buffer_size)
Format update notification message.
@ INSTALL_METHOD_ARCH_AUR
Installed via Arch AUR (paru/yay).
@ INSTALL_METHOD_UNKNOWN
Unknown installation method.
@ INSTALL_METHOD_GITHUB
Manual install from GitHub releases.
@ INSTALL_METHOD_INSTALLER
Installed by ascii-chat.com installer.
@ INSTALL_METHOD_SCOOP
Installed via Scoop.
@ INSTALL_METHOD_HOMEBREW
Installed via Homebrew.
char * get_config_dir(void)
Get configuration directory path with XDG_CONFIG_HOME support.
Definition path.c:279
⚙️ Common definitions, error codes, macros, and types shared throughout the application
Simple HTTPS client for fetching public keys from GitHub/GitLab.
📝 Logging API with multiple log levels and terminal output control
📂 Path Manipulation Utilities
🔤 String Manipulation and Shell Escaping Utilities
When code needs to work with asciichat errno snapshot, it keeps total, copied here instead of scatter...
update check result keeps the values that move through the subsystem: update_available,...
char latest_version[64]
Latest version tag (e.g., "v0.9.0").
char current_sha[41]
Current commit SHA.
time_t dismissed_until
Suppress this available release until this time.
char current_version[64]
Current version string.
time_t last_check_time
Timestamp of last check.
bool update_available
True if newer version exists.
bool check_succeeded
True if check completed (even if no update).
char release_url[512]
GitHub release page URL.
char latest_sha[41]
Latest release commit SHA (full 40 chars + null).
int platform_execute_subprocess(const char *executable, const char **argv, char *output_buffer, size_t output_size, bool(*cancel)(void *), void *data)
Definition system.c:35
⏱️ High-precision timing utilities using sokol_time.h and uthash
#define GITHUB_API_HOSTNAME
#define UPDATE_CHECK_CACHE_FILENAME
#define NETWORK_UPDATE_CHECKER_LINE_SHORT_BUFFER_SIZE
#define GITHUB_RELEASES_PATH
#define NETWORK_UPDATE_CHECKER_LINE_BUFFER_SIZE
#define UPDATE_CHECK_CACHE_MAX_AGE_SECONDS
#define NETWORK_UPDATE_CHECKER_SUGGESTION_BUFFER_SIZE
#define NETWORK_UPDATE_CHECKER_LATEST_TAG_BUFFER_SIZE
🔄 Update checker for GitHub releases with DNS connectivity test and cache
int version_compare(semantic_version_t a, semantic_version_t b)
Definition version.c:110
semantic_version_t version_parse(const char *version_string)
Definition version.c:47