* Print out module info in p11-kit tool.
const char* p11_kit_strerror (CK_RV rv);
+size_t p11_kit_space_strlen (const unsigned char *string,
+ size_t max_length);
+
+char* p11_kit_space_strdup (const unsigned char *string,
+ size_t max_length);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
#define DEBUG_FLAG DEBUG_URI
#include "debug.h"
#include "pkcs11.h"
+#include "p11-kit.h"
#include "uri.h"
#include "util.h"
return uri;
}
-size_t
-p11_kit_uri_space_strlen (const unsigned char *string, size_t max_length)
-{
- size_t i = max_length - 1;
-
- assert (string);
-
- while (i > 0 && string[i] == ' ')
- --i;
- return i + 1;
-}
-
static int
format_raw_string (char **string, size_t *length, int *is_first,
const char *name, const char *value)
if (!value[0])
return 1;
- len = p11_kit_uri_space_strlen (value, value_max);
+ len = p11_kit_space_strlen (value, value_max);
return format_encode_string (string, length, is_first, name, value, len);
}
const char* p11_kit_uri_message (int code);
-size_t p11_kit_uri_space_strlen (const unsigned char *string,
- size_t max_length);
-
#ifdef __cplusplus
} /* extern "C" */
#endif
#include "config.h"
+#include "p11-kit.h"
#include "util.h"
+#include <assert.h>
#include <stdlib.h>
+#include <string.h>
void*
xrealloc (void *memory, size_t length)
free (memory);
return allocated;
}
+
+size_t
+p11_kit_space_strlen (const unsigned char *string, size_t max_length)
+{
+ size_t i = max_length - 1;
+
+ assert (string);
+
+ while (i > 0 && string[i] == ' ')
+ --i;
+ return i + 1;
+}
+
+char*
+p11_kit_space_strdup (const unsigned char *string, size_t max_length)
+{
+ size_t length;
+ char *result;
+
+ assert (string);
+
+ length = p11_kit_space_strlen (string, max_length);
+
+ result = malloc (length + 1);
+ if (!result)
+ return NULL;
+
+ memcpy (result, string, length);
+ result[length] = 0;
+ return result;
+}
#include <stdlib.h>
#include <unistd.h>
-#include "p11-kit.h"
+#include "p11-kit/p11-kit.h"
+#include "p11-kit/uri.h"
typedef int (*operation) (int argc, char *argv[]);
int verbose = 0;
exit (2);
}
+static void
+print_module_info (CK_FUNCTION_LIST_PTR module)
+{
+ CK_INFO info;
+ char *value;
+ CK_RV rv;
+
+ rv = (module->C_GetInfo) (&info);
+ if (rv != CKR_OK) {
+ warnx ("couldn't load module info: %s", p11_kit_strerror (rv));
+ return;
+ }
+
+ value = p11_kit_space_strdup (info.libraryDescription,
+ sizeof (info.libraryDescription));
+ printf ("\tlibrary-description: %s\n", value);
+ free (value);
+
+ value = p11_kit_space_strdup (info.manufacturerID,
+ sizeof (info.manufacturerID));
+ printf ("\tlibrary-manufacturer: %s\n", value);
+ free (value);
+}
+
static int
list_modules (int argc, char *argv[])
{
printf ("%s: %s\n",
name ? name : "(null)",
path ? path : "(null)");
+ print_module_info (module_list[i]);
free (name);
free (path);