| ︙ | | | ︙ | |
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
if (objc >= 3) {
prefix = TclGetString(objv[2]);
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;
}
/*
|
<
|
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
if (objc >= 3) {
prefix = TclGetString(objv[2]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
TclSetResult(interp, "must specify either file name or prefix");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOLIBRARY",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | | | ︙ | |
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
defaultPtr = libraryPtr;
}
if (filesMatch && !namesMatch && (fullFileName[0] != 0)) {
/*
* 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;
}
}
|
|
|
|
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
defaultPtr = libraryPtr;
}
if (filesMatch && !namesMatch && (fullFileName[0] != 0)) {
/*
* Can't have two different libraries loaded from the same file.
*/
TclPrintfResult(interp,
"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;
}
}
|
| ︙ | | | ︙ | |
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
if (libraryPtr == NULL) {
/*
* 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;
}
/*
|
|
|
>
|
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
if (libraryPtr == NULL) {
/*
* 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) {
TclPrintfResult(interp,
"no library with prefix \"%s\" is loaded statically",
prefix);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "LOAD", "NOTSTATIC",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | | | ︙ | |
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
if (!Tcl_UniCharIsWordChar(UCHAR(ch))
|| Tcl_UniCharIsDigit(UCHAR(ch))) {
break;
}
}
if (p == pkgGuess) {
Tcl_DecrRefCount(splitPtr);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't 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 (!Tcl_UniCharIsWordChar(UCHAR(ch))
|| Tcl_UniCharIsDigit(UCHAR(ch))) {
break;
}
}
if (p == pkgGuess) {
Tcl_DecrRefCount(splitPtr);
TclPrintfResult(interp,
"couldn't 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);
|
| ︙ | | | ︙ | |
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
473
474
475
|
/*
* Invoke the library's initialization function (either the normal one or
* the safe one, depending on whether or not the interpreter is safe).
*/
if (Tcl_IsSafe(target)) {
if (libraryPtr->safeInitProc == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't 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(
"can't 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);
}
|
|
|
|
|
|
447
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
473
474
|
/*
* Invoke the library's initialization function (either the normal one or
* the safe one, depending on whether or not the interpreter is safe).
*/
if (Tcl_IsSafe(target)) {
if (libraryPtr->safeInitProc == NULL) {
TclPrintfResult(interp,
"can't 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) {
TclPrintfResult(interp,
"can't 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);
}
|
| ︙ | | | ︙ | |
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
Interp *iPtr = (Interp *) target;
if (iPtr->legacyResult && *(iPtr->legacyResult) && !iPtr->legacyFreeProc) {
/*
* A call to Tcl_InitStubs() determined the caller extension and
* this interp are incompatible in their stubs mechanisms, and
* recorded the error in the oldest legacy place we have to do so.
*/
Tcl_SetObjResult(target, Tcl_NewStringObj(iPtr->legacyResult, -1));
iPtr->legacyResult = NULL;
iPtr->legacyFreeProc = (void (*) (void))-1;
}
Tcl_TransferResult(target, code, interp);
goto done;
}
|
|
|
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
Interp *iPtr = (Interp *) target;
if (iPtr->legacyResult && *(iPtr->legacyResult) && !iPtr->legacyFreeProc) {
/*
* A call to Tcl_InitStubs() determined the caller extension and
* this interp are incompatible in their stubs mechanisms, and
* recorded the error in the oldest legacy place we have to do so.
*/
TclSetResult(target, iPtr->legacyResult);
iPtr->legacyResult = NULL;
iPtr->legacyFreeProc = (void (*) (void))-1;
}
Tcl_TransferResult(target, code, interp);
goto done;
}
|
| ︙ | | | ︙ | |
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
|
if (objc - i >= 2) {
prefix = TclGetString(objv[i+1]);
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;
}
/*
|
<
|
|
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
|
if (objc - i >= 2) {
prefix = TclGetString(objv[i+1]);
if (prefix[0] == '\0') {
prefix = NULL;
}
}
if ((fullFileName[0] == 0) && (prefix == NULL)) {
TclSetResult(interp, "must specify either file name or prefix");
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NOLIBRARY",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | | | ︙ | |
687
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
|
}
Tcl_MutexUnlock(&libraryMutex);
if (fullFileName[0] == 0) {
/*
* 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;
}
/*
|
|
|
|
|
|
685
686
687
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
|
}
Tcl_MutexUnlock(&libraryMutex);
if (fullFileName[0] == 0) {
/*
* It's an error to try unload a static library.
*/
TclPrintfResult(interp,
"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.
*/
TclPrintfResult(interp,
"file \"%s\" has never been loaded", fullFileName);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "NEVERLOADED",
(char *)NULL);
code = TCL_ERROR;
goto done;
}
/*
|
| ︙ | | | ︙ | |
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
|
}
}
if (code != TCL_OK) {
/*
* 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);
|
|
|
|
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
|
}
}
if (code != TCL_OK) {
/*
* The library has not been loaded in this interpreter.
*/
TclPrintfResult(interp,
"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);
|
| ︙ | | | ︙ | |
790
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
|
* libraryPtr->unloadProc must not be NULL for the DLL to be unloadable. If
* the interpreter is a safe one, libraryPtr->safeUnloadProc must be non-NULL.
*/
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;
|
|
|
|
|
|
788
789
790
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
|
* libraryPtr->unloadProc must not be NULL for the DLL to be unloadable. If
* the interpreter is a safe one, libraryPtr->safeUnloadProc must be non-NULL.
*/
if (Tcl_IsSafe(target)) {
if (libraryPtr->safeUnloadProc == NULL) {
if (!interpExiting) {
TclPrintfResult(interp,
"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) {
TclPrintfResult(interp,
"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;
|
| ︙ | | | ︙ | |
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
|
Tcl_Free(iterLibraryPtr);
Tcl_MutexUnlock(&libraryMutex);
} else {
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:
|
|
|
|
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
|
Tcl_Free(iterLibraryPtr);
Tcl_MutexUnlock(&libraryMutex);
} else {
code = TCL_ERROR;
}
}
#else
TclPrintfResult(interp,
"file \"%s\" cannot be unloaded: unloading disabled",
fullFileName);
Tcl_SetErrorCode(interp, "TCL", "OPERATION", "UNLOAD", "DISABLED",
NULL);
code = TCL_ERROR;
#endif
}
done:
|
| ︙ | | | ︙ | |