1/*
2 * xotclStubLib.c --
3 *
4 *      Stub object that will be statically linked into extensions of XOTcl
5 *
6 * Copyright (c) 2001-2008 Gustaf Neumann, Uwe Zdun
7 * Copyright (c) 1998 Paul Duffin.
8 *
9 * See the file "tcl-license.terms" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 *
12 */
13
14/*
15 * We need to ensure that we use the stub macros so that this file contains
16 * no references to any of the stub functions.  This will make it possible
17 * to build an extension that references Tcl_InitStubs but doesn't end up
18 * including the rest of the stub functions.
19 */
20
21#ifndef USE_TCL_STUBS
22#define USE_TCL_STUBS
23#endif
24#undef USE_TCL_STUB_PROCS
25
26/*
27 * This ensures that the Xotcl_InitStubs has a prototype in
28 * xotcl.h and is not the macro that turns it into Tcl_PkgRequire
29 */
30
31#ifndef USE_XOTCL_STUBS
32#define USE_XOTCL_STUBS
33#endif
34
35#include "xotclInt.h"
36
37XotclStubs *xotclStubsPtr = NULL;
38XotclIntStubs *xotclIntStubsPtr = NULL;
39
40/*
41 *----------------------------------------------------------------------
42 *
43 * Xotcl_InitStubs --
44 *
45 *      Tries to initialise the stub table pointers and ensures that
46 *      the correct version of XOTcl is loaded.
47 *
48 * Results:
49 *      The actual version of XOTcl that satisfies the request, or
50 *      NULL to indicate that an error occurred.
51 *
52 * Side effects:
53 *      Sets the stub table pointers.
54 *
55 *----------------------------------------------------------------------
56 */
57
58CONST char *
59Xotcl_InitStubs (interp, version, exact)
60    Tcl_Interp *interp;
61    CONST char *version;
62    int exact;
63{
64    CONST char *actualVersion;
65
66    actualVersion = Tcl_PkgRequireEx(interp, "XOTcl", version, exact,
67        (ClientData *) &xotclStubsPtr);
68
69    if (actualVersion == NULL) {
70        xotclStubsPtr = NULL;
71        return NULL;
72    }
73
74    if (xotclStubsPtr == NULL) {
75        return NULL;
76    }
77
78    if (xotclStubsPtr->hooks) {
79        xotclIntStubsPtr = xotclStubsPtr->hooks->xotclIntStubs;
80    } else {
81        xotclIntStubsPtr = NULL;
82    }
83
84    return actualVersion;
85}
86