| ︙ | | |
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
-
+
-
|
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",
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOLIBRARY");
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
* Figure out which interpreter we're going to load the library into.
*/
|
| ︙ | | |
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
-
-
+
+
|
/*
* 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);
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD",
"SPLITPERSONALITY");
code = TCL_ERROR;
Tcl_MutexUnlock(&libraryMutex);
goto done;
}
}
Tcl_MutexUnlock(&libraryMutex);
if (libraryPtr == NULL) {
|
| ︙ | | |
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
-
+
-
|
* 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",
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOTSTATIC");
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
* Figure out the prefix if it wasn't provided explicitly.
*/
|
| ︙ | | |
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
|
-
-
+
+
|
}
}
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);
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD",
"WHATLIBRARY");
code = TCL_ERROR;
goto done;
}
Tcl_DStringAppend(&pfx, pkgGuess, p - pkgGuess);
Tcl_DecrRefCount(splitPtr);
/*
|
| ︙ | | |
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
|
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
|
-
+
-
-
+
-
|
*/
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",
TclSetErrorCode(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",
TclSetErrorCode(interp, "TCL", "OPERATION", "LOAD", "ENTRYPOINT");
(char *)NULL);
code = TCL_ERROR;
goto done;
}
code = libraryPtr->initProc(target);
}
/*
|
| ︙ | | |
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
|
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
-
+
-
|
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",
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NOLIBRARY");
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
* Figure out which interpreter we're going to load the library into.
*/
|
| ︙ | | |
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
|
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
|
-
+
-
-
+
-
|
/*
* 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",
TclSetErrorCode(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",
TclSetErrorCode(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
|
| ︙ | | |
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
|
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
|
-
+
-
|
/*
* 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",
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NEVERLOADED");
(char *)NULL);
code = TCL_ERROR;
goto done;
}
code = UnloadLibrary(interp, target, libraryPtr, keepLibrary, fullFileName, 0);
done:
|
| ︙ | | |
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
|
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",
TclSetErrorCode(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",
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "CANNOT");
(char *)NULL);
code = TCL_ERROR;
goto done;
}
}
unloadProc = libraryPtr->unloadProc;
}
|
| ︙ | | |
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
|
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
|
-
+
-
|
code = TCL_ERROR;
}
}
#else
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"file \"%s\" cannot be unloaded: unloading disabled",
fullFileName));
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "DISABLED",
TclSetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "DISABLED");
NULL);
code = TCL_ERROR;
#endif
}
done:
return code;
}
|
| ︙ | | |