]> granicus.if.org Git - p11-kit/commitdiff
Add uri function for listing which attribute types are present.
authorStef Walter <stefw@collabora.co.uk>
Mon, 21 Feb 2011 19:44:42 +0000 (20:44 +0100)
committerStef Walter <stefw@collabora.co.uk>
Mon, 21 Feb 2011 19:44:42 +0000 (20:44 +0100)
module/p11-kit-uri.c
module/p11-kit-uri.h

index 8c65301c382ffd1e28cfda3652fdd95ff67eb1da..7fdb33d646bbe28f395cfa6d777bb49597f96c47 100644 (file)
@@ -127,7 +127,7 @@ url_encode (const unsigned char *value, const unsigned char *end, size_t *length
        while (value != end) {
 
                /* These characters we let through verbatim */
-               if (isalnum (*value) || strchr ("_-.", *value) != NULL) {
+               if (*value && (isalnum (*value) || strchr ("_-.", *value) != NULL)) {
                        *(p++) = *(value++);
 
                /* All others get encoded */
@@ -256,6 +256,28 @@ p11_kit_uri_match_token_info (P11KitUri *uri, CK_TOKEN_INFO_PTR token_info)
                                     sizeof (token_info->serialNumber)));
 }
 
+CK_ATTRIBUTE_TYPE*
+p11_kit_uri_get_attribute_types (P11KitUri *uri, int *n_types)
+{
+       CK_ATTRIBUTE_TYPE *result;
+       int i, j;
+
+       assert (uri);
+       assert (n_types);
+
+       result = calloc (NUM_ATTRS, sizeof (CK_ATTRIBUTE_TYPE));
+       if (result == NULL)
+               return NULL;
+
+       for (i = 0, j = 0; i < NUM_ATTRS; ++i) {
+               if (uri->attrs[i].ulValueLen != (CK_ULONG)-1)
+                       result[j++] = uri->attrs[i].type;
+       }
+
+       *n_types = j;
+       return result;
+}
+
 CK_ATTRIBUTE_PTR
 p11_kit_uri_get_attribute (P11KitUri *uri, CK_ATTRIBUTE_TYPE type)
 {
index c5e86bb1f16eaee4963d3b6c5538b2f5e1e9dd86..209f3d6195152d71f0566f79644cd4fafd7bd9ec 100644 (file)
@@ -69,6 +69,9 @@ CK_TOKEN_INFO_PTR   p11_kit_uri_get_token_info              (P11KitUri *uri);
 int                 p11_kit_uri_match_token_info            (P11KitUri *uri,
                                                              CK_TOKEN_INFO_PTR token_info);
 
+CK_ATTRIBUTE_TYPE*  p11_kit_uri_get_attribute_types         (P11KitUri *uri,
+                                                             int *n_types);
+
 CK_ATTRIBUTE_PTR    p11_kit_uri_get_attribute               (P11KitUri *uri,
                                                              CK_ATTRIBUTE_TYPE type);