diff options
Diffstat (limited to 'vboxshfl.h')
| -rw-r--r-- | vboxshfl.h | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -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); |
