示例#1
0
文件: slot.c 项目: llogar/OpenSC
CK_RV
card_detect_all(void)
{
	unsigned int i;

	sc_log(context, "Detect all cards");
	/* Detect cards in all initialized readers */
	for (i=0; i< sc_ctx_get_reader_count(context); i++) {
		sc_reader_t *reader = sc_ctx_get_reader(context, i);
		if (reader->flags & SC_READER_REMOVED) {
			struct sc_pkcs11_slot *slot;
			card_removed(reader);
			while ((slot = reader_get_slot(reader))) {
				empty_slot(slot);
			}
			_sc_delete_reader(context, reader);
			i--;
		} else {
			if (!reader_get_slot(reader))
				initialize_reader(reader);
			else
				card_detect(sc_ctx_get_reader(context, i));
		}
	}
	sc_log(context, "All cards detected");
	return CKR_OK;
}
示例#2
0
CK_RV card_detect_all(void) {
	 unsigned int i;

	 /* Detect cards in all initialized readers */
	 for (i=0; i< sc_ctx_get_reader_count(context); i++) {
		 sc_reader_t *reader = sc_ctx_get_reader(context, i);
		 if (!reader_get_slot(reader))
			 initialize_reader(reader);
		 card_detect(sc_ctx_get_reader(context, i));
	 }
	 return CKR_OK;			
}
示例#3
0
文件: slot.c 项目: llogar/OpenSC
CK_RV create_slot(sc_reader_t *reader)
{
	/* find unused virtual hotplug slots */
	struct sc_pkcs11_slot *slot = reader_get_slot(NULL);

	/* create a new slot if no empty slot is available */
	if (!slot) {
		if (list_size(&virtual_slots) >= sc_pkcs11_conf.max_virtual_slots)
			return CKR_FUNCTION_FAILED;

		slot = (struct sc_pkcs11_slot *)calloc(1, sizeof(struct sc_pkcs11_slot));
		if (!slot)
			return CKR_HOST_MEMORY;

		list_append(&virtual_slots, slot);
		if (0 != list_init(&slot->objects)) {
			return CKR_HOST_MEMORY;
		}
		list_attributes_seeker(&slot->objects, object_list_seeker);

		if (0 != list_init(&slot->logins)) {
			return CKR_HOST_MEMORY;
		}
	} else {
		/* reuse the old list of logins/objects since they should be empty */
		list_t logins = slot->logins;
		list_t objects = slot->objects;

		memset(slot, 0, sizeof *slot);

		slot->logins = logins;
		slot->objects = objects;
	}

	slot->login_user = -1;
	slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);
	init_slot_info(&slot->slot_info, reader);
	sc_log(context, "Initializing slot with id 0x%lx", slot->id);

	if (reader != NULL) {
		slot->reader = reader;
		strcpy_bp(slot->slot_info.manufacturerID, reader->vendor, 32);
		strcpy_bp(slot->slot_info.slotDescription, reader->name, 64);
		slot->slot_info.hardwareVersion.major = reader->version_major;
		slot->slot_info.hardwareVersion.minor = reader->version_minor;
	}

	return CKR_OK;
}