281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
-
+
|
break;
}
}
return(outbufidx);
}
/* PKCS#11 CreateMutex implementation that use Tcl Mutexes */
/* PKCS#11 Mutex functions implementation that use Tcl Mutexes */
static CK_RV tclpkcs11_create_mutex(void **mutex) {
Tcl_Mutex *retval;
if (!mutex) {
return(CKR_GENERAL_ERROR);
}
|
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
|
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
-
+
-
+
-
+
+
+
+
+
-
+
-
+
-
+
+
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
|
return(CKR_OK);
}
/*
* Platform Specific Functions
*/
static void *tclpkcs11_int_load_module(const char *pathname) {
#ifdef TCL_INCLUDES_LOADFILE
#if defined(TCL_INCLUDES_LOADFILE)
int tcl_rv;
Tcl_LoadHandle *new_handle;
new_handle = (Tcl_LoadHandle *) ckalloc(sizeof(*new_handle));
tcl_rv = Tcl_LoadFile(NULL, Tcl_NewStringObj(pathname, -1), NULL, 0, NULL, new_handle);
if (tcl_rv != TCL_OK) {
return(NULL);
}
return(new_handle);
#else
#elif defined(HAVE_DLOPEN)
/* XXX: TODO: Replace this with Tcl_Load() in 8.6 or otherwise a system-specific loading mechanism */
return(dlopen(pathname, RTLD_LAZY | RTLD_LOCAL));
#elif defined(HAVE_SHL_LOAD)
return(shl_load(pathname, BIND_DEFERRED, 0L));
#elif defined(_WIN32)
return(LoadLibrary(pathname));
#endif
return(NULL);
}
static void tclpkcs11_int_unload_module(void *handle) {
#ifdef TCL_INCLUDES_LOADFILE
#if defined(TCL_INCLUDES_LOADFILE)
Tcl_LoadHandle *tcl_handle;
tcl_handle = handle;
Tcl_FSUnloadFile(NULL, *tcl_handle);
ckfree(handle);
#else
#elif defined(HAVE_DLOPEN)
/* XXX: TODO: Replace this with Tcl_Unload() in 8.6 or otherwise a system-specific unloading mechanism */
dlclose(handle);
#elif defined(HAVE_SHL_LOAD)
shl_unload(handle);
#elif defined(_WIN32)
FreeLibrary(handle);
#endif
return;
}
static void *tclpkcs11_int_lookup_sym(void *handle, const char *sym) {
#ifdef TCL_INCLUDES_LOADFILE
#if defined(TCL_INCLUDES_LOADFILE)
Tcl_LoadHandle *tcl_handle;
void *retval;
tcl_handle = handle;
retval = Tcl_FindSymbol(NULL, *tcl_handle, sym);
return(retval);
#else
#elif defined(HAVE_DLOPEN)
/* XXX: TODO: Replace this with ... ? in 8.6 or otherwise a system-specific symbol lookup mechanism */
return(dlsym(handle, sym));
#elif defined(HAVE_SHL_LOAD)
void *retval;
int shl_findsym_ret;
shl_findsym_ret = shl_findsym(handle, sym, TYPE_PROCEDURE, &retval);
if (shl_findsym_ret != 0) {
return(NULL);
}
return(retval);
#elif defined(_WIN32)
return(GetProcAddress(handle, sym));
#endif
return(NULL);
}
/*
* Tcl Commands
*/
static int tclpkcs11_load_module(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
struct tclpkcs11_interpdata *interpdata;
|