aboutsummaryrefslogtreecommitdiff
path: root/src/string.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-09-08 15:27:45 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-09-08 16:14:35 +0200
commitc1f8b38b7817383cd06413f4c0e9ddf1414e8597 (patch)
treed9e4e37a33ec000a282bfc571dc80193dae050fd /src/string.c
parent5581323c2c81bee79e34b7cfeac625c8eca344ce (diff)
downloadlibssh-c1f8b38b7817383cd06413f4c0e9ddf1414e8597.tar.gz
libssh-c1f8b38b7817383cd06413f4c0e9ddf1414e8597.tar.xz
libssh-c1f8b38b7817383cd06413f4c0e9ddf1414e8597.zip
string: Add ssh_string_get_char().
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
index 70764a59..37fe42e6 100644
--- a/src/string.c
+++ b/src/string.c
@@ -131,6 +131,25 @@ size_t ssh_string_len(struct ssh_string_struct *s) {
}
/**
+ * @brief Get the the string as a C nul-terminated string.
+ *
+ * This is only available as long as the SSH string exists.
+ *
+ * @param[in] s The SSH string to get the C string from.
+ *
+ * @return The char pointer, NULL on error.
+ */
+const char *ssh_string_get_char(struct ssh_string_struct *s)
+{
+ if (s == NULL) {
+ return NULL;
+ }
+ s->data[ssh_string_len(s)] = '\0';
+
+ return (const char *) s->data;
+}
+
+/**
* @brief Convert a SSH string to a C nul-terminated string.
*
* @param[in] s The SSH input string.