summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-06-07 13:06:51 +0000
committerStef Walter <stefw@collabora.co.uk>2011-06-07 13:06:51 +0000
commitcab38f1cb262e7922098fdb03c2c5828f5f003a1 (patch)
tree7aa07126ecf1db4eadfb7fb6c625ec6b33a6cf1d
parentb9a8a140cf09780671402e872130a51ec4f4b014 (diff)
downloadp11-kit-cab38f1cb262e7922098fdb03c2c5828f5f003a1.tar.gz
Fix up documentation
-rw-r--r--doc/p11-kit-sections.txt5
-rw-r--r--p11-kit/util.c41
2 files changed, 45 insertions, 1 deletions
diff --git a/doc/p11-kit-sections.txt b/doc/p11-kit-sections.txt
index c82d6e3..db1f4f7 100644
--- a/doc/p11-kit-sections.txt
+++ b/doc/p11-kit-sections.txt
@@ -43,7 +43,8 @@ p11_kit_finalize_module
<SECTION>
<FILE>p11-kit-util</FILE>
p11_kit_strerror
-p11_kit_uri_space_strlen
+p11_kit_space_strdup
+p11_kit_space_strlen
<SUBSECTION Private>
CK_FUNCTION_LIST_PTR
CK_RV
@@ -52,4 +53,6 @@ CK_ATTRIBUTE_TYPE
CK_INFO_PTR
CK_TOKEN_INFO_PTR
CK_ULONG
+p11_kit_uri_result_t
+p11_kit_uri_type_t
</SECTION>
diff --git a/p11-kit/util.c b/p11-kit/util.c
index ead18cc..e4b0f49 100644
--- a/p11-kit/util.c
+++ b/p11-kit/util.c
@@ -52,6 +52,27 @@ xrealloc (void *memory, size_t length)
return allocated;
}
+/**
+ * p11_kit_space_strlen:
+ * @string: Pointer to string block
+ * @max_length: Maximum length of string block
+ *
+ * In PKCS\#11 structures many strings are encoded in a strange way. The string
+ * is placed in a fixed length buffer and then padded with spaces.
+ *
+ * This function determines the actual length of the string. Since the string
+ * is not null-terminated you need to pass in the size of buffer as max_length.
+ * The string will never be longer than this buffer.
+ *
+ * <informalexample><programlisting>
+ * CK_INFO info;
+ * size_t length;
+ * ...
+ * length = p11_kit_space_strlen (info->libraryDescription, sizeof (info->libraryDescription));
+ * </programlisting></informalexample>
+ *
+ * Returns: The length of the space padded string.
+ */
size_t
p11_kit_space_strlen (const unsigned char *string, size_t max_length)
{
@@ -64,6 +85,26 @@ p11_kit_space_strlen (const unsigned char *string, size_t max_length)
return i + 1;
}
+/**
+ * p11_kit_space_strdup:
+ * @string: Pointer to string block
+ * @max_length: Maximum length of string block
+ *
+ * In PKCS\#11 structures many strings are encoded in a strange way. The string
+ * is placed in a fixed length buffer and then padded with spaces.
+ *
+ * This function copies the space padded string into a normal null-terminated
+ * string. The result is owned by the caller.
+ *
+ * <informalexample><programlisting>
+ * CK_INFO info;
+ * char *description;
+ * ...
+ * description = p11_kit_space_strdup (info->libraryDescription, sizeof (info->libraryDescription));
+ * </programlisting></informalexample>
+ *
+ * Returns: The newly allocated string, or %NULL if memory could not be allocated.
+ */
char*
p11_kit_space_strdup (const unsigned char *string, size_t max_length)
{