2
0
Fork 0
forked from zynk/zynk

0.41.2 Move yt_url_encode() docs, document signal globals in zynk.c.

- Moved doc comment block for yt_url_encode() from top of cmd_yt.h
  to immediately before the function definition for better readability.
- Added doc comments to volatile sig_atomic_t running variable describing
  its purpose as main loop control flag and async-signal-safety.
- Added doc comments to start_time variable explaining its role in
  uptime calculation.
- Updated CHANGELOG.md to reflect yt_url_encode() doc comment move.
This commit is contained in:
Johannes Findeisen 2026-07-25 20:16:51 +02:00
commit 11bf7e624d
3 changed files with 29 additions and 14 deletions

View file

@ -3,6 +3,7 @@
- Added a welcome message when users join a channel: `handle_join()` now sends `"Welcome, <nick>!"` 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)

View file

@ -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;

14
zynk.c
View file

@ -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;
/*