226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
slots = malloc(sizeof(*slots) * numSlots);
chk_rv = C_GetSlotList(FALSE, slots, &numSlots);
if (chk_rv != CKR_OK) {
return(1);
}
/* Test waiting for slot events */
currSlot = 0;
printf("Please insert a card now.\n");
/* Initially, every slot has changed state (but probably should not) */
chk_rv = C_WaitForSlotEvent(0, &currSlot, NULL);
/* This actually waits */
chk_rv = C_WaitForSlotEvent(0, &currSlot, NULL);
if (chk_rv != CKR_OK) {
printf("Failed to wait for slot event.\n");
}
/* This just ensures DONT_BLOCK works */
chk_rv = C_WaitForSlotEvent(CKF_DONT_BLOCK, &currSlot, NULL);
for (currSlot = 0; currSlot < numSlots; currSlot++) {
printf(" Slot %lu:\n", currSlot);
chk_rv = C_GetSlotInfo(slots[currSlot], &slotInfo);
if (chk_rv != CKR_OK) {
return(1);
}
|