1/* 2 * itclStubLib.c -- 3 * 4 * Stub object that will be statically linked into extensions that wish 5 * to access Itcl. 6 * 7 * Copyright (c) 1998 Paul Duffin. 8 * 9 * See the file "license.terms" for information on usage and redistribution 10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 11 * 12 * RCS: $Id: itclStubLib.c,v 1.9 2003/12/24 03:38:02 davygrvy Exp $ 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 Tcl_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/* 28 * This ensures that the Itcl_InitStubs has a prototype in 29 * itcl.h and is not the macro that turns it into Tcl_PkgRequire 30 */ 31 32#ifndef USE_ITCL_STUBS 33#define USE_ITCL_STUBS 34#endif 35 36#include "itclInt.h" 37 38ItclStubs *itclStubsPtr; 39ItclIntStubs *itclIntStubsPtr; 40 41/* 42 *---------------------------------------------------------------------- 43 * 44 * Itcl_InitStubs -- 45 * 46 * Tries to initialize the stub table pointers and ensures that 47 * the correct version of Itcl is loaded. 48 * 49 * Results: 50 * The actual version of Itcl 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 Itcl_InitStubs 60#undef Itcl_InitStubs 61#endif 62 63CONST char * 64Itcl_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, "Itcl", (CONST84 char *)version, exact, 72 (ClientData *) &itclStubsPtr); 73 74 if (actualVersion == NULL) { 75 itclStubsPtr = NULL; 76 return NULL; 77 } 78 79 if (itclStubsPtr->hooks) { 80 itclIntStubsPtr = itclStubsPtr->hooks->itclIntStubs; 81 } else { 82 itclIntStubsPtr = NULL; 83 } 84 85 return actualVersion; 86} 87