diff --git a/CHANGELOG.md b/CHANGELOG.md index 59e9a9d..78443f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Added a welcome message when users join a channel: `handle_join()` now sends `"Welcome, !"` to the channel for non-bot users. The bot's own joins are silently ignored to avoid echo loops. - Added `src_nick` parameter to `handle_join()` to identify the joining user; the call site in `irc_handle()` was updated to pass `src_nick`. - Added doc comments to `chans[]` (global channel tracking array) and `nchans` (count of tracked channels) in `irc.h`. +- Added doc comments to `yt_url_encode()` in `cmd_yt.h` describing percent-encoding behavior, parameters, and return value. 2026.07.25 - Decode Unicode escapes in !yt responses. (0.41.1) diff --git a/cmd_yt.h b/cmd_yt.h index 815dbf2..e830cc9 100644 --- a/cmd_yt.h +++ b/cmd_yt.h @@ -3,20 +3,6 @@ #include "zynk.h" -/* - * yt_url_encode - Percent-encode a string for safe use in a URL query parameter. - * - * Encodes all characters except unreserved characters (alphanumerics, '-', '_', - * '.', '~') using RFC 3986 percent-encoding. Used to encode the YouTube video - * URL before embedding it in the oEmbed API request. - * - * Parameters: - * src - The input string to encode. - * dst - Output buffer for the encoded string. - * dstsz - Size of the output buffer. - * - * Returns: void (output is written to dst, NUL-terminated). - */ /* * yt_hex_digit - Convert a hexadecimal character to its numeric value. * @@ -81,6 +67,20 @@ static void yt_decode_unicode_escapes(char *s) { *w = '\0'; } +/* + * yt_url_encode - Percent-encode a string for safe use in a URL query parameter. + * + * Encodes all characters except unreserved characters (alphanumerics, '-', '_', + * '.', '~') using RFC 3986 percent-encoding. Used to encode the YouTube video + * URL before embedding it in the oEmbed API request. + * + * Parameters: + * src - The input string to encode. + * dst - Output buffer for the encoded string. + * dstsz - Size of the output buffer. + * + * Returns: void (output is written to dst, NUL-terminated). + */ static void yt_url_encode(const char *src, char *dst, size_t dstsz) { static const char hex[] = "0123456789ABCDEF"; size_t di = 0; diff --git a/zynk.c b/zynk.c index cacefa5..ebd2be4 100644 --- a/zynk.c +++ b/zynk.c @@ -259,7 +259,21 @@ void reload_do(Session *s, const char *reply_target, int exec_new) { /* ---- signal handling ---- */ +/* + * running - Main loop control flag, set to 0 by signal handlers. + * + * Checked by the main poll loop to determine when to shut down. + * Declared volatile sig_atomic_t for async-signal-safety: SIGINT and + * SIGTERM handlers set it to 0, causing the loop to exit gracefully. + */ volatile sig_atomic_t running = 1; + +/* + * start_time - Timestamp when the bot process started. + * + * Set once during initialization, used by the !uptime command to + * calculate and display the bot's running time. + */ time_t start_time; /*