#define USE_TCL_STUBS
#include "tcl.h"
#include <fossil-scm/fossil.h>

/*
 * This block of code forms the "private stubs" mechanism, a way
 * to build Tcl extensions without linking with the Tcl stubs library.
 */
#undef Tcl_InitStubs
#define Tcl_InitStubs staticTclInitStubs
#define tclStubsPtr staticTclStubsPtr
static const TclStubs *tclStubsPtr = NULL;
typedef struct {
  char *result;
  Tcl_FreeProc *freeProc;
  int errorLine;
  const struct TclStubs *stubTable;
} PrivateTclInterp;
static const char *Tcl_InitStubs(Tcl_Interp *interp, const char *version, int exact) {
  tclStubsPtr = ((PrivateTclInterp *)interp)->stubTable;
  return Tcl_PkgRequireEx(interp, "Tcl", version, 0, (void *)&tclStubsPtr);
}
/* End of "private stubs" section */

DLLEXPORT int
Fossil_Init(
    Tcl_Interp *interp)		/* Interpreter in which the package is to be
				 * made available. */
{
    int code;

    if (Tcl_InitStubs(interp, "8.4", 0) == NULL) {
	return TCL_ERROR;
    }
    code = Tcl_PkgProvideEx(interp, "fossil", "0.1", NULL);
    if (code != TCL_OK) {
	return code;
    }
    return TCL_OK;
}
