Artifact
3a8a75fb6fab26b693d50606082a7ba3b2d37e5d002ffe7ac49fb55797d94223:
Attachment "onexit.c" to
ticket [3d768414de]
added by
sbron
2020-07-14 15:28:53.
(unpublished)
0000: 23 69 6e 63 6c 75 64 65 20 3c 74 63 6c 2e 68 3e #include <tcl.h>
0010: 0a 0a 76 6f 69 64 20 6f 6e 65 78 69 74 28 43 6c ..void onexit(Cl
0020: 69 65 6e 74 44 61 74 61 20 63 6c 69 65 6e 74 44 ientData clientD
0030: 61 74 61 2c 20 54 63 6c 5f 49 6e 74 65 72 70 20 ata, Tcl_Interp
0040: 2a 69 6e 74 65 72 70 29 0a 7b 0a 20 20 20 20 66 *interp).{. f
0050: 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 printf(stderr, "
0060: 4f 6e 45 78 69 74 48 61 6e 64 6c 65 72 20 66 6f OnExitHandler fo
0070: 72 20 69 6e 74 65 72 70 20 25 70 5c 6e 22 2c 20 r interp %p\n",
0080: 69 6e 74 65 72 70 29 3b 0a 7d 0a 09 20 20 20 20 interp);.}..
0090: 0a 69 6e 74 20 4f 6e 65 78 69 74 5f 49 6e 69 74 .int Onexit_Init
00a0: 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 (Tcl_Interp *int
00b0: 65 72 70 29 0a 7b 0a 23 69 66 64 65 66 20 55 53 erp).{.#ifdef US
00c0: 45 5f 54 43 4c 5f 53 54 55 42 53 0a 20 20 20 20 E_TCL_STUBS.
00d0: 69 66 20 28 54 63 6c 5f 49 6e 69 74 53 74 75 62 if (Tcl_InitStub
00e0: 73 28 69 6e 74 65 72 70 2c 20 22 38 2e 35 22 2c s(interp, "8.5",
00f0: 20 30 29 20 3d 3d 20 4e 55 4c 4c 29 0a 20 20 20 0) == NULL).
0100: 20 20 20 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 return TCL_ER
0110: 52 4f 52 3b 0a 23 65 6c 73 65 0a 20 20 20 20 69 ROR;.#else. i
0120: 66 20 28 54 63 6c 5f 50 6b 67 52 65 71 75 69 72 f (Tcl_PkgRequir
0130: 65 28 69 6e 74 65 72 70 2c 20 22 54 63 6c 22 2c e(interp, "Tcl",
0140: 20 22 38 2e 35 22 2c 20 30 29 20 3d 3d 20 4e 55 "8.5", 0) == NU
0150: 4c 4c 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e LL). return
0160: 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 23 65 6e 64 TCL_ERROR;.#end
0170: 69 66 0a 20 20 20 20 54 63 6c 5f 43 61 6c 6c 57 if. Tcl_CallW
0180: 68 65 6e 44 65 6c 65 74 65 64 28 69 6e 74 65 72 henDeleted(inter
0190: 70 2c 20 6f 6e 65 78 69 74 2c 20 4e 55 4c 4c 29 p, onexit, NULL)
01a0: 3b 0a 20 20 20 20 72 65 74 75 72 6e 20 54 63 6c ;. return Tcl
01b0: 5f 50 6b 67 50 72 6f 76 69 64 65 28 69 6e 74 65 _PkgProvide(inte
01c0: 72 70 2c 20 22 6f 6e 65 78 69 74 22 2c 20 22 31 rp, "onexit", "1
01d0: 2e 30 22 29 3b 0a 7d 0a .0");.}.