]> granicus.if.org Git - p11-kit/commitdiff
Rename p11_kit_pin_read_pinfile to p11_kit_pin_retrieve
authorStef Walter <stefw@collabora.co.uk>
Tue, 21 Jun 2011 17:31:15 +0000 (19:31 +0200)
committerStef Walter <stefw@collabora.co.uk>
Wed, 6 Jul 2011 10:49:26 +0000 (12:49 +0200)
 * Fix up duplicate register logic as well.

p11-kit/pin.c
p11-kit/pin.h
tests/pin-test.c

index 328785fe72e6c3b8d2cef3f75ffb3e9d4fafba36..14cb171d13b473028430cc4b3f11bf04c249ad15 100644 (file)
@@ -284,9 +284,9 @@ p11_kit_pin_unregister_callback (const char *pinfile, p11_kit_pin_callback callb
 }
 
 int
-p11_kit_pin_read_pinfile (const char *pinfile, P11KitUri *pin_uri,
-                          const char *pin_description, P11KitPinFlags flags,
-                          char *pin, size_t pin_max)
+p11_kit_pin_retrieve (const char *pinfile, P11KitUri *pin_uri,
+                      const char *pin_description, P11KitPinFlags flags,
+                      char *pin, size_t pin_length)
 {
        PinfileCallback **snapshot = NULL;
        unsigned int snapshot_count = 0;
@@ -317,9 +317,10 @@ p11_kit_pin_read_pinfile (const char *pinfile, P11KitUri *pin_uri,
        if (snapshot == NULL)
                return 0;
 
-       for (i = 0; i < snapshot_count; i++) {
-               ret = (snapshot[i]->func) (pinfile, pin_uri, pin_description, flags,
-                                          snapshot[i]->user_data, pin, pin_max);
+       ret = 0;
+       for (i = snapshot_count; ret == 0 && i > 0; i--) {
+               ret = (snapshot[i - 1]->func) (pinfile, pin_uri, pin_description, flags,
+                                              snapshot[i - 1]->user_data, pin, pin_length);
        }
 
        _p11_lock ();
index 780e72dc8fb7c70061c14fa69432fffd412f8d0a..bb5daae2772c326d52756e72c7256d4ed7890509 100644 (file)
@@ -58,7 +58,7 @@ typedef int         (*p11_kit_pin_callback)                 (const char *pinfile
                                                              P11KitPinFlags pin_flags,
                                                              void *callback_data,
                                                              char *pin,
-                                                             size_t pin_max);
+                                                             size_t pin_length);
 
 typedef void        (*p11_kit_pin_callback_destroy)         (void *callback_data);
 
@@ -71,7 +71,7 @@ void                p11_kit_pin_unregister_callback         (const char *pinfile
                                                              p11_kit_pin_callback callback,
                                                              void *callback_data);
 
-int                 p11_kit_pin_read_pinfile                (const char *pinfile,
+int                 p11_kit_pin_retrieve                    (const char *pinfile,
                                                              P11KitUri *pin_uri,
                                                              const char *pin_description,
                                                              P11KitPinFlags pin_flags,
index 7f1bc084a99d9d94a2dcac9d265b2e78a70d412c..344fe6b18e36966e9552ab5bcb62cf72d002eb04 100644 (file)
@@ -96,9 +96,9 @@ test_pin_read (CuTest *tc)
                                       &data, destroy_data);
 
        uri = p11_kit_uri_new ();
-       ret = p11_kit_pin_read_pinfile ("/the/pinfile", uri, "The token",
-                                       P11_KIT_PIN_FLAGS_USER_LOGIN,
-                                       buffer, sizeof (buffer));
+       ret = p11_kit_pin_retrieve ("/the/pinfile", uri, "The token",
+                                   P11_KIT_PIN_FLAGS_USER_LOGIN,
+                                   buffer, sizeof (buffer));
        p11_kit_uri_free (uri);
 
        CuAssertIntEquals (tc, 1, ret);
@@ -116,9 +116,9 @@ test_pin_read_no_match (CuTest *tc)
        int ret;
 
        uri = p11_kit_uri_new ();
-       ret = p11_kit_pin_read_pinfile ("/the/pinfile", uri, "The token",
-                                       P11_KIT_PIN_FLAGS_USER_LOGIN,
-                                       buffer, sizeof (buffer));
+       ret = p11_kit_pin_retrieve ("/the/pinfile", uri, "The token",
+                                   P11_KIT_PIN_FLAGS_USER_LOGIN,
+                                   buffer, sizeof (buffer));
        p11_kit_uri_free (uri);
 
        CuAssertIntEquals (tc, 0, ret);
@@ -141,9 +141,9 @@ test_pin_register_duplicate (CuTest *tc)
        p11_kit_pin_register_callback ("/the/pinfile", callback_other,
                                       value, NULL);
 
-       ret = p11_kit_pin_read_pinfile ("/the/pinfile", uri, "The token",
-                                       P11_KIT_PIN_FLAGS_USER_LOGIN,
-                                       buffer, sizeof (buffer));
+       ret = p11_kit_pin_retrieve ("/the/pinfile", uri, "The token",
+                                   P11_KIT_PIN_FLAGS_USER_LOGIN,
+                                   buffer, sizeof (buffer));
 
        CuAssertIntEquals (tc, 1, ret);
        CuAssertStrEquals (tc, "secret", buffer);
@@ -151,9 +151,9 @@ test_pin_register_duplicate (CuTest *tc)
        p11_kit_pin_unregister_callback ("/the/pinfile", callback_other,
                                         value);
 
-       ret = p11_kit_pin_read_pinfile ("/the/pinfile", uri, "The token",
-                                       P11_KIT_PIN_FLAGS_USER_LOGIN,
-                                       buffer, sizeof (buffer));
+       ret = p11_kit_pin_retrieve ("/the/pinfile", uri, "The token",
+                                   P11_KIT_PIN_FLAGS_USER_LOGIN,
+                                   buffer, sizeof (buffer));
 
        CuAssertIntEquals (tc, 1, ret);
        CuAssertStrEquals (tc, "one", buffer);
@@ -161,7 +161,7 @@ test_pin_register_duplicate (CuTest *tc)
        p11_kit_pin_unregister_callback ("/the/pinfile", callback_one,
                                         &data);
 
-       ret = p11_kit_pin_read_pinfile ("/the/pinfile", uri, "The token",
+       ret = p11_kit_pin_retrieve ("/the/pinfile", uri, "The token",
                                        P11_KIT_PIN_FLAGS_USER_LOGIN,
                                        buffer, sizeof (buffer));
 
@@ -184,9 +184,9 @@ test_pin_register_fallback (CuTest *tc)
        p11_kit_pin_register_callback (P11_KIT_PIN_FALLBACK, callback_one,
                                       &data, destroy_data);
 
-       ret = p11_kit_pin_read_pinfile ("/the/pinfile", uri, "The token",
-                                       P11_KIT_PIN_FLAGS_USER_LOGIN,
-                                       buffer, sizeof (buffer));
+       ret = p11_kit_pin_retrieve ("/the/pinfile", uri, "The token",
+                                   P11_KIT_PIN_FLAGS_USER_LOGIN,
+                                   buffer, sizeof (buffer));
 
        CuAssertIntEquals (tc, 1, ret);
        CuAssertStrEquals (tc, "one", buffer);
@@ -194,9 +194,9 @@ test_pin_register_fallback (CuTest *tc)
        p11_kit_pin_register_callback ("/the/pinfile", callback_other,
                                       value, NULL);
 
-       ret = p11_kit_pin_read_pinfile ("/the/pinfile", uri, "The token",
-                                       P11_KIT_PIN_FLAGS_USER_LOGIN,
-                                       buffer, sizeof (buffer));
+       ret = p11_kit_pin_retrieve ("/the/pinfile", uri, "The token",
+                                   P11_KIT_PIN_FLAGS_USER_LOGIN,
+                                   buffer, sizeof (buffer));
 
        CuAssertIntEquals (tc, 1, ret);
        CuAssertStrEquals (tc, "secret", buffer);