| ︙ | | | ︙ | |
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must specify either file name or prefix", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOLIBRARY",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
* Figure out which interpreter we're going to load the library into.
*/
|
|
<
|
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must specify either file name or prefix", -1));
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOLIBRARY");
code = TCL_ERROR;
goto done;
}
/*
* Figure out which interpreter we're going to load the library into.
*/
|
| ︙ | | | ︙ | |
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
/*
* Can't have two different libraries loaded from the same file.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" is already loaded for prefix \"%s\"",
fullFileName, libraryPtr->prefix));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD",
"SPLITPERSONALITY", (char *)NULL);
code = TCL_ERROR;
Tcl_MutexUnlock(&libraryMutex);
goto done;
}
}
Tcl_MutexUnlock(&libraryMutex);
if (libraryPtr == NULL) {
|
|
|
|
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
/*
* Can't have two different libraries loaded from the same file.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" is already loaded for prefix \"%s\"",
fullFileName, libraryPtr->prefix));
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD",
"SPLITPERSONALITY");
code = TCL_ERROR;
Tcl_MutexUnlock(&libraryMutex);
goto done;
}
}
Tcl_MutexUnlock(&libraryMutex);
if (libraryPtr == NULL) {
|
| ︙ | | | ︙ | |
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
* The desired file isn't currently loaded, so load it. It's an error
* if the desired library is a static one.
*/
if (fullFileName[0] == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no library with prefix \"%s\" is loaded statically", prefix));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOTSTATIC",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
* Figure out the prefix if it wasn't provided explicitly.
*/
|
|
<
|
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
* The desired file isn't currently loaded, so load it. It's an error
* if the desired library is a static one.
*/
if (fullFileName[0] == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no library with prefix \"%s\" is loaded statically", prefix));
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOTSTATIC");
code = TCL_ERROR;
goto done;
}
/*
* Figure out the prefix if it wasn't provided explicitly.
*/
|
| ︙ | | | ︙ | |
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
}
}
if (p == pkgGuess) {
Tcl_DecrRefCount(splitPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot figure out prefix for %s",
fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD",
"WHATLIBRARY", (char *)NULL);
code = TCL_ERROR;
goto done;
}
Tcl_DStringAppend(&pfx, pkgGuess, p - pkgGuess);
Tcl_DecrRefCount(splitPtr);
/*
|
|
|
|
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
}
}
if (p == pkgGuess) {
Tcl_DecrRefCount(splitPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot figure out prefix for %s",
fullFileName));
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD",
"WHATLIBRARY");
code = TCL_ERROR;
goto done;
}
Tcl_DStringAppend(&pfx, pkgGuess, p - pkgGuess);
Tcl_DecrRefCount(splitPtr);
/*
|
| ︙ | | | ︙ | |
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
|
*/
if (Tcl_IsSafe(target)) {
if (libraryPtr->safeInitProc == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot use library in a safe interpreter: no"
" %s_SafeInit procedure", libraryPtr->prefix));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "UNSAFE",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
code = libraryPtr->safeInitProc(target);
} else {
if (libraryPtr->initProc == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot attach library to interpreter: no %s_Init procedure",
libraryPtr->prefix));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "ENTRYPOINT",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
code = libraryPtr->initProc(target);
}
/*
|
|
<
|
<
|
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
*/
if (Tcl_IsSafe(target)) {
if (libraryPtr->safeInitProc == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot use library in a safe interpreter: no"
" %s_SafeInit procedure", libraryPtr->prefix));
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD", "UNSAFE");
code = TCL_ERROR;
goto done;
}
code = libraryPtr->safeInitProc(target);
} else {
if (libraryPtr->initProc == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot attach library to interpreter: no %s_Init procedure",
libraryPtr->prefix));
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD", "ENTRYPOINT");
code = TCL_ERROR;
goto done;
}
code = libraryPtr->initProc(target);
}
/*
|
| ︙ | | | ︙ | |
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must specify either file name or prefix", -1));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NOLIBRARY",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
* Figure out which interpreter we're going to load the library into.
*/
|
|
<
|
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
|
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"must specify either file name or prefix", -1));
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NOLIBRARY");
code = TCL_ERROR;
goto done;
}
/*
* Figure out which interpreter we're going to load the library into.
*/
|
| ︙ | | | ︙ | |
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
|
/*
* It's an error to try unload a static library.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"library with prefix \"%s\" is loaded statically and cannot be unloaded",
prefix));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "STATIC",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
if (libraryPtr == NULL) {
/*
* The DLL pointed by the provided filename has never been loaded.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" has never been loaded", fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NEVERLOADED",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
* Scan through the list of libraries already loaded in the target
* interpreter. If the library we want is already loaded there, then we
|
|
<
|
<
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
|
/*
* It's an error to try unload a static library.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"library with prefix \"%s\" is loaded statically and cannot be unloaded",
prefix));
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "STATIC");
code = TCL_ERROR;
goto done;
}
if (libraryPtr == NULL) {
/*
* The DLL pointed by the provided filename has never been loaded.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" has never been loaded", fullFileName));
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NEVERLOADED");
code = TCL_ERROR;
goto done;
}
/*
* Scan through the list of libraries already loaded in the target
* interpreter. If the library we want is already loaded there, then we
|
| ︙ | | | ︙ | |
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
|
/*
* The library has not been loaded in this interpreter.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" has never been loaded in this interpreter",
fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NEVERLOADED",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
code = UnloadLibrary(interp, target, libraryPtr, keepLibrary, fullFileName, 0);
done:
|
|
<
|
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
|
/*
* The library has not been loaded in this interpreter.
*/
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" has never been loaded in this interpreter",
fullFileName));
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NEVERLOADED");
code = TCL_ERROR;
goto done;
}
code = UnloadLibrary(interp, target, libraryPtr, keepLibrary, fullFileName, 0);
done:
|
| ︙ | | | ︙ | |
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
|
if (Tcl_IsSafe(target)) {
if (libraryPtr->safeUnloadProc == NULL) {
if (!interpExiting) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" cannot be unloaded under a safe interpreter",
fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "CANNOT",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
}
unloadProc = libraryPtr->safeUnloadProc;
} else {
if (libraryPtr->unloadProc == NULL) {
if (!interpExiting) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" cannot be unloaded under a trusted interpreter",
fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "CANNOT",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
}
unloadProc = libraryPtr->unloadProc;
}
|
|
<
|
<
|
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
|
if (Tcl_IsSafe(target)) {
if (libraryPtr->safeUnloadProc == NULL) {
if (!interpExiting) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" cannot be unloaded under a safe interpreter",
fullFileName));
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "CANNOT");
code = TCL_ERROR;
goto done;
}
}
unloadProc = libraryPtr->safeUnloadProc;
} else {
if (libraryPtr->unloadProc == NULL) {
if (!interpExiting) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" cannot be unloaded under a trusted interpreter",
fullFileName));
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "CANNOT");
code = TCL_ERROR;
goto done;
}
}
unloadProc = libraryPtr->unloadProc;
}
|
| ︙ | | | ︙ | |
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
|
code = TCL_ERROR;
}
}
#else
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" cannot be unloaded: unloading disabled",
fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "DISABLED",
NULL);
code = TCL_ERROR;
#endif
}
done:
return code;
}
|
|
<
|
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
|
code = TCL_ERROR;
}
}
#else
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" cannot be unloaded: unloading disabled",
fullFileName));
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "DISABLED");
code = TCL_ERROR;
#endif
}
done:
return code;
}
|
| ︙ | | | ︙ | |