Posted to tcl by hypnotoad at Tue Oct 09 23:48:11 GMT 2018view pretty

/*
** This file is generated by the ../dirt/make.tcl script
** any changes will be overwritten the next time it is run
*/

/* This file was generated by practcl */
    
#include <tcl.h>
#include <tclOO.h>
#include "dirtkit.h"
#include "tclInt.h"
#include "tclFileSystem.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
/* BEGIN generate-cfile-header  */
#define ZIPFS_VOLUME "zipfs:/"
#ifndef MODULE_SCOPE
#   define MODULE_SCOPE extern
#endif

/*
** Provide a dummy Tcl_InitStubs if we are using this as a static
** library.
*/
#ifndef USE_TCL_STUBS
# undef  Tcl_InitStubs
# define Tcl_InitStubs(a,b,c) TCL_VERSION
#endif
#define STATIC_BUILD 1
#undef USE_TCL_STUBS

/* Make sure the stubbed variants of those are never used. */
#undef Tcl_ObjSetVar2
#undef Tcl_NewStringObj
#undef Tk_Init
#undef Tk_MainEx
#undef Tk_SafeInit
extern Tcl_PackageInitProc Tk_Init;
extern Tcl_PackageInitProc Sqlite3_Init;
extern Tcl_PackageInitProc Tkhtml_Init;
extern Tcl_PackageInitProc Odielibc_Init;
/* END generate-cfile-header  */
/* BEGIN generate-cfile-functions  */
/* Tclkit_MainHook */
int Tclkit_MainHook(int *argc, char ***argv){
/*
 * Tclkit_MainHook --
 * Performs the argument munging for the shell
 */
  
  CONST char *archive;
  Tcl_FindExecutable(*argv[0]);
  archive=Tcl_GetNameOfExecutable();
  TclZipfs_Init(NULL);
  if(!TclZipfs_Mount(NULL, "app", archive, NULL)) { 
      Tcl_Obj *vfsinitscript;
      vfsinitscript=Tcl_NewStringObj("zipfs:/app/main.tcl",-1);
      Tcl_IncrRefCount(vfsinitscript);
      if(Tcl_FSAccess(vfsinitscript,F_OK)==0) {
        /* Startup script should be set before calling Tcl_AppInit */
        Tcl_SetStartupScript(vfsinitscript,NULL);
      }
    
    TclSetPreInitScript(
        "\n" \
        "set ::odie(boot_vfs) zipfs:/app\n" \
        "set ::SRCDIR $::odie(boot_vfs)\n" \
        "if {[file exists [file join zipfs:/app tcl_library init.tcl]]} {\n" \
        "  set ::tcl_library [file join zipfs:/app tcl_library]\n" \
        "  set ::auto_path {}\n" \
        "}\n" \
        "if {[file exists [file join zipfs:/app tk_library tk.tcl]]} {\n" \
        "  set ::tk_library [file join zipfs:/app tk_library]\n" \
        "}\n" \
        "\n" );
  } else {
    TclSetPreInitScript(
        "\n" \
        "foreach path {../tcl} {\n" \
        "  set p  [file join $path library init.tcl]\n" \
        "  if {[file exists [file join $path library init.tcl]]} {\n" \
        "    set ::tcl_library [file normalize [file join $path library]]\n" \
        "    break\n" \
        "  }\n" \
        "}\n" \
        "foreach path {\n" \
        "  ../tk\n" \
        "} {\n" \
        "  if {[file exists [file join $path library tk.tcl]]} {\n" \
        "    set ::tk_library [file normalize [file join $path library]]\n" \
        "    break\n" \
        "  }\n" \
        "}\n" \
        "\n" );
  }
  return TCL_OK;}
/* Tclkit_AppInit */
int Tclkit_AppInit(Tcl_Interp *interp){
  if ((Tcl_Init)(interp) == TCL_ERROR) {
      return TCL_ERROR;
  }

  TclZipfs_Init(interp);
  if(Tk_Init(interp)) return TCL_ERROR;
  Tcl_StaticPackage(interp,"Tk",Tk_Init,NULL);
  if(Sqlite3_Init(interp)) return TCL_ERROR;
  Tcl_StaticPackage(interp,"sqlite3",Sqlite3_Init,NULL);
  Tcl_StaticPackage(NULL,"Tkhtml",Tkhtml_Init,NULL);
  if(Odielibc_Init(interp)) return TCL_ERROR;
  Tcl_StaticPackage(interp,"odielib",Odielibc_Init,NULL);
  Tcl_Eval(interp,
        "\n" \
        "set ::kitpkg(Tk) {package ifneeded Tk 8.6.8 {::load {} Tk}}\n" \
        "set ::kitpkg(sqlite3) {package ifneeded sqlite3 3.20.1 {::load {} sqlite3}}\n" \
        "set ::kitpkg(Tkhtml) {package ifneeded Tkhtml 3.0 {::load {} Tkhtml}}\n" \
        "package ifneeded Tkhtml 3.0 {::load {} Tkhtml}\n" \
        "set ::kitpkg(odielib) {package ifneeded odielib 2.3 {::load {} odielib}}\n" \
        "\n" \
        "if {[file exists [file join $::SRCDIR packages.tcl]]} {\n" \
        "  #In a wrapped exe, we don't go out to the environment\n" \
        "  set dir $::SRCDIR\n" \
        "  source [file join $::SRCDIR packages.tcl]\n" \
        "}\n" \
        "# Specify a user-specific startup file to invoke if the application\n" \
        "# is run interactively.  Typically the startup file is \"~/.apprc\"\n" \
        "# where \"app\" is the name of the application.  If this line is deleted\n" \
        "# then no user-specific startup file will be run under any conditions.\n" \
        "\n" \
        "set tcl_rcFileName ~/.tclshrc\n" );
  return TCL_OK;}
/* END generate-cfile-functions  */

extern int DLLEXPORT Dirtkit_Init( Tcl_Interp *interp ) {
  /* Initialise the stubs tables. */
  #ifdef USE_TCL_STUBS
    if (Tcl_InitStubs(interp, "8.6", 0)==NULL) return TCL_ERROR;
    if (TclOOInitializeStubs(interp, "1.0") == NULL) return TCL_ERROR;
  #endif
  return TCL_OK;
}