print_module_info (CK_FUNCTION_LIST_PTR module)
{
	CK_SLOT_ID slot_list[256];
	CK_ULONG i, count;
	CK_INFO info;
	char *value;
	CK_RV rv;

	rv = (module->C_GetInfo) (&info);
	if (rv != CKR_OK) {
		p11_message ("couldn't load module info: %s", p11_kit_strerror (rv));
		return;
	}

	value = p11_kit_space_strdup (info.libraryDescription,
	                              sizeof (info.libraryDescription));
	printf ("    library-description: %s\n", value);
	free (value);

	value = p11_kit_space_strdup (info.manufacturerID,
	                              sizeof (info.manufacturerID));
	printf ("    library-manufacturer: %s\n", value);
	free (value);

	printf ("    library-version: %d.%d\n",
	        info.libraryVersion.major,
	        info.libraryVersion.minor);

	count = sizeof (slot_list) / sizeof (slot_list[0]);
	rv = (module->C_GetSlotList) (CK_TRUE, slot_list, &count);
	if (rv != CKR_OK) {
		p11_message ("couldn't load module info: %s", p11_kit_strerror (rv));
		return;
	}

	for (i = 0; i < count; i++)
		print_token_info (module, slot_list[i]);
}
print_module_info (CK_FUNCTION_LIST_PTR module)
{
	CK_SLOT_ID slot_list[256];
	CK_ULONG i, count;
	CK_INFO info;
	char *value;
	CK_RV rv;

	rv = (module->C_GetInfo) (&info);
	if (rv != CKR_OK) {
		p11_message ("couldn't load module info: %s", p11_kit_strerror (rv));
		return;
	}

	value = p11_kit_space_strdup (info.libraryDescription,
	                              sizeof (info.libraryDescription));
	printf ("    library-description: %s\n", value);
	free (value);

	value = p11_kit_space_strdup (info.manufacturerID,
	                              sizeof (info.manufacturerID));
	printf ("    library-manufacturer: %s\n", value);
	free (value);

	printf ("    library-version: %d.%d\n",
	        info.libraryVersion.major,
	        info.libraryVersion.minor);

	count = sizeof (slot_list) / sizeof (slot_list[0]);
	rv = (module->C_GetSlotList) (CK_TRUE, slot_list, &count);
	if (rv != CKR_OK) {
		p11_message ("couldn't load module info: %s", p11_kit_strerror (rv));
		return;
	}

	for (i = 0; i < count; i++)
		print_token_info (module, slot_list[i]);
}