From bc437f9709a7a48865bae2a4aa40536bfc80ebbc Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 22 Nov 2026 19:02:35 +0100 Subject: vbsf: when resolving lfn, list only files starting with the same prefix as the short filename --- vboxshfl.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'vboxshfl.h') diff --git a/vboxshfl.h b/vboxshfl.h index 412709a..276add4 100644 --- a/vboxshfl.h +++ b/vboxshfl.h @@ -43,18 +43,21 @@ static inline unsigned shflstring_size_with_buf(const SHFLSTRING *str) static inline unsigned shflstring_size_optional_in(const SHFLSTRING *str) { - if (str->u16Length > 0) { + if (str && str->u16Length > 0) { return sizeof(SHFLSTRING) + str->u16Size; } else { return 0; } } +/** Set str to the empty string. */ static inline void shflstring_clear(SHFLSTRING *str) { str->u16Length = 0; + str->ach[str->u16Length] = '\0'; } +/** Initialize str by copying src. */ static void shflstring_strcpy(SHFLSTRING *str, const char __far *src) { str->u16Length = MIN(_fstrlen(src), str->u16Size - 1); @@ -62,6 +65,7 @@ static void shflstring_strcpy(SHFLSTRING *str, const char __far *src) str->ach[str->u16Length] = '\0'; } +/** Initialize str by copying len first characters of src. */ static void shflstring_strncpy(SHFLSTRING *str, const char __far *src, unsigned len) { str->u16Length = MIN(len, str->u16Size - 1); @@ -69,6 +73,24 @@ static void shflstring_strncpy(SHFLSTRING *str, const char __far *src, unsigned str->ach[str->u16Length] = '\0'; } +/** Append single character to str (if space) */ +static void shflstring_append(SHFLSTRING *str, char c) +{ + if (str->u16Length < str->u16Size - 1) { + str->ach[str->u16Length++] = c; + str->ach[str->u16Length] = '\0'; + } +} + +/** Append len characters of src to str. */ +static void shflstring_strncat(SHFLSTRING *str, const char __far *src, unsigned len) +{ + len = MIN(len, (str->u16Size - 1) - str->u16Length); + _fmemcpy(&str->ach[str->u16Length], src, len); + str->u16Length += len; + str->ach[str->u16Length] = '\0'; +} + static inline void vbox_hgcm_set_parameter_shflroot(VMMDevHGCMCall __far *req, unsigned arg, SHFLROOT root) { vbox_hgcm_set_parameter_uint32(req, arg, root); -- cgit v1.2.3