1 /*
2 * snackStubLib.c --
3 *
4 * Stub object that will be statically linked into extensions that wish
5 * to access Snack.
6 *
7 * Copyright (c) 1998-1999 by Scriptics Corporation.
8 * Copyright (c) 1998 Paul Duffin.
9 *
10 * See the file "license.terms" for information on usage and redistribution
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 *
13 */
14
15 /*
16 * We need to ensure that we use the stub macros so that this file contains
17 * no references to any of the stub functions. This will make it possible
18 * to build an extension that references Snack_InitStubs but doesn't end up
19 * including the rest of the stub functions.
20 */
21
22 #ifndef USE_TCL_STUBS
23 #define USE_TCL_STUBS
24 #endif
25 #undef USE_TCL_STUB_PROCS
26
27 #ifndef USE_TK_STUBS
28 #define USE_TK_STUBS
29 #endif
30 #undef USE_TK_STUB_PROCS
31
32 #include "snack.h"
33 #include "snackDecls.h"
34
35 /*
36 * Ensure that Snack_InitStubs is built as an exported symbol. The other stub
37 * functions should be built as non-exported symbols.
38 */
39
40 #undef TCL_STORAGE_CLASS
41 #define TCL_STORAGE_CLASS DLLEXPORT
42
43 SnackStubs *snackStubsPtr;
44
45 /*
46 *----------------------------------------------------------------------
47 *
48 * Snack_InitStubs --
49 *
50 * Checks that the correct version of Snack is loaded and that it
51 * supports stubs. It then initialises the stub table pointers.
52 *
53 * Results:
54 * The actual version of Snack that satisfies the request, or
55 * NULL to indicate that an error occurred.
56 *
57 * Side effects:
58 * Sets the stub table pointers.
59 *
60 *----------------------------------------------------------------------
61 */
62
63 CONST84 char *
Snack_InitStubs(Tcl_Interp * interp,char * version,int exact)64 Snack_InitStubs (Tcl_Interp *interp, char *version, int exact)
65 {
66 CONST84 char *actualVersion;
67
68 actualVersion = Tcl_PkgRequireEx(interp, "snack", version, exact,
69 (ClientData *) &snackStubsPtr);
70 if (!actualVersion) {
71 return NULL;
72 }
73
74 if (!snackStubsPtr) {
75 Tcl_SetResult(interp,
76 "This implementation of Snack does not support stubs",
77 TCL_STATIC);
78 return NULL;
79 }
80
81 return actualVersion;
82 }
83