1/*
2 * trfStubLib.c --
3 *
4 *	Stub object that will be statically linked into extensions that wish
5 *	to access Trf.
6 */
7
8
9/*
10 * We need to ensure that we use the stub macros so that this file contains
11 * no references to any of the stub functions.  This will make it possible
12 * to build an extension that references Trf_InitStubs but doesn't end up
13 * including the rest of the stub functions.
14 */
15
16#ifndef USE_TCL_STUBS
17#define USE_TCL_STUBS
18#endif
19#undef  USE_TCL_STUB_PROCS
20
21#ifndef USE_TRF_STUBS
22#define USE_TRF_STUBS
23#endif
24#undef  USE_TRF_STUB_PROCS
25
26#include "transform.h"
27#include "trfIntDecls.h"
28
29/*
30 * Ensure that Trf_InitStubs is built as an exported symbol.  The other stub
31 * functions should be built as non-exported symbols.
32 */
33
34#undef  TCL_STORAGE_CLASS
35#define TCL_STORAGE_CLASS DLLEXPORT
36
37TrfStubs *trfStubsPtr;
38TrfIntStubs *trfIntStubsPtr;
39
40
41/*
42 *----------------------------------------------------------------------
43 *
44 * Trf_InitStubs --
45 *
46 *	Checks that the correct version of Trf is loaded and that it
47 *	supports stubs. It then initialises the stub table pointers.
48 *
49 * Results:
50 *	The actual version of Trf that satisfies the request, or
51 *	NULL to indicate that an error occurred.
52 *
53 * Side effects:
54 *	Sets the stub table pointers.
55 *
56 *----------------------------------------------------------------------
57 */
58
59#ifdef Trf_InitStubs
60#undef Trf_InitStubs
61#endif
62
63char *
64Trf_InitStubs(interp, version, exact)
65    Tcl_Interp *interp;
66    CONST char *version;
67    int exact;
68{
69    CONST char *actualVersion;
70
71    actualVersion = Tcl_PkgRequireEx(interp, "Trf", (char *) version, exact,
72		(ClientData *) &trfStubsPtr);
73
74    if (!actualVersion) {
75	return NULL;
76    }
77
78    if (!trfStubsPtr) {
79	Tcl_SetResult(interp,
80		"This implementation of Trf does not support stubs",
81		TCL_STATIC);
82	return NULL;
83    }
84
85    trfIntStubsPtr = trfStubsPtr->hooks->trfIntStubs;
86
87    return (char*) actualVersion;
88}
89