summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 17:13:17 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 17:13:17 +0300
commit043781575d90d84eb336ed32749e0ab8588a684c (patch)
tree5dc47f9e4b94343bbcf5d3dec3d7fb43893bc253 /include
parentb7944e4bbfa64a6bb1a1d9e1f172827dde53aed2 (diff)
Decode local paths from drop payloads
Drops arrive as a CRLF-separated text/uri-list of file URLs, so every consumer percent-decodes them; wsap_term does it in its own drop code. yasl_drop_next_path() walks the list and returns one decoded local path at a time. It accepts file:///, file:/, and file://localhost or this machine's name, ends the path at '?' or '#', and skips comments, other schemes, remote hosts, malformed escapes, and escaped NUL bytes. A buffer that is too small leaves the cursor in place, like the other functions that fill a buffer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'include')
-rw-r--r--include/yasl/yasl.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/yasl/yasl.h b/include/yasl/yasl.h
index 5946816..f798304 100644
--- a/include/yasl/yasl.h
+++ b/include/yasl/yasl.h
@@ -777,6 +777,23 @@ YASL_API bool yasl_surface_present(struct yasl_surface *s, const struct yasl_fra
*/
YASL_API bool yasl_surface_poll_event(struct yasl_surface *s, struct yasl_event *ev);
/**
+ * Decode the next local file path from a YASL_EVENT_DROP payload.
+ * @param cursor Required in/out position in the NUL-terminated list. Start it
+ * at event.text.data; a NULL *cursor returns zero.
+ * @param out Output for the NUL-terminated path, or NULL when cap is zero.
+ * @param cap Size of out in bytes.
+ * @return Path length in bytes, excluding the NUL, or zero when no paths remain.
+ * When the result is less than cap, out holds the path and *cursor moves past
+ * it. Otherwise out and *cursor are unchanged; call again with a buffer of at
+ * least the result plus one.
+ * Accepts file:///path, file:/path, and file://host/path when host is
+ * localhost or this machine's name. Percent escapes decode to raw bytes, and
+ * a '?' or '#' ends the path. Skips blank lines, comments, other schemes,
+ * other hosts, and lines with a malformed escape or an escaped NUL. May be
+ * called from any thread.
+ */
+YASL_API size_t yasl_drop_next_path(const char **cursor, char *out, size_t cap);
+/**
* Copy the last frame presented from the surface's CPU target.
* @param s Surface.
* @param out Output for size->x * size->y premultiplied ARGB8888 pixels with