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

  1. /*
  2. ** This file is generated by the ../dirt/make.tcl script
  3. ** any changes will be overwritten the next time it is run
  4. */
  5.  
  6. /* This file was generated by practcl */
  7.  
  8. #include <tcl.h>
  9. #include <tclOO.h>
  10. #include "dirtkit.h"
  11. #include "tclInt.h"
  12. #include "tclFileSystem.h"
  13. #include <assert.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <math.h>
  18. /* BEGIN generate-cfile-header */
  19. #define ZIPFS_VOLUME "zipfs:/"
  20. #ifndef MODULE_SCOPE
  21. # define MODULE_SCOPE extern
  22. #endif
  23.  
  24. /*
  25. ** Provide a dummy Tcl_InitStubs if we are using this as a static
  26. ** library.
  27. */
  28. #ifndef USE_TCL_STUBS
  29. # undef Tcl_InitStubs
  30. # define Tcl_InitStubs(a,b,c) TCL_VERSION
  31. #endif
  32. #define STATIC_BUILD 1
  33. #undef USE_TCL_STUBS
  34.  
  35. /* Make sure the stubbed variants of those are never used. */
  36. #undef Tcl_ObjSetVar2
  37. #undef Tcl_NewStringObj
  38. #undef Tk_Init
  39. #undef Tk_MainEx
  40. #undef Tk_SafeInit
  41. extern Tcl_PackageInitProc Tk_Init;
  42. extern Tcl_PackageInitProc Sqlite3_Init;
  43. extern Tcl_PackageInitProc Tkhtml_Init;
  44. extern Tcl_PackageInitProc Odielibc_Init;
  45. /* END generate-cfile-header */
  46. /* BEGIN generate-cfile-functions */
  47. /* Tclkit_MainHook */
  48. int Tclkit_MainHook(int *argc, char ***argv){
  49. /*
  50. * Tclkit_MainHook --
  51. * Performs the argument munging for the shell
  52. */
  53.  
  54. CONST char *archive;
  55. Tcl_FindExecutable(*argv[0]);
  56. archive=Tcl_GetNameOfExecutable();
  57. TclZipfs_Init(NULL);
  58. if(!TclZipfs_Mount(NULL, "app", archive, NULL)) {
  59. Tcl_Obj *vfsinitscript;
  60. vfsinitscript=Tcl_NewStringObj("zipfs:/app/main.tcl",-1);
  61. Tcl_IncrRefCount(vfsinitscript);
  62. if(Tcl_FSAccess(vfsinitscript,F_OK)==0) {
  63. /* Startup script should be set before calling Tcl_AppInit */
  64. Tcl_SetStartupScript(vfsinitscript,NULL);
  65. }
  66.  
  67. TclSetPreInitScript(
  68. "\n" \
  69. "set ::odie(boot_vfs) zipfs:/app\n" \
  70. "set ::SRCDIR $::odie(boot_vfs)\n" \
  71. "if {[file exists [file join zipfs:/app tcl_library init.tcl]]} {\n" \
  72. " set ::tcl_library [file join zipfs:/app tcl_library]\n" \
  73. " set ::auto_path {}\n" \
  74. "}\n" \
  75. "if {[file exists [file join zipfs:/app tk_library tk.tcl]]} {\n" \
  76. " set ::tk_library [file join zipfs:/app tk_library]\n" \
  77. "}\n" \
  78. "\n" );
  79. } else {
  80. TclSetPreInitScript(
  81. "\n" \
  82. "foreach path {../tcl} {\n" \
  83. " set p [file join $path library init.tcl]\n" \
  84. " if {[file exists [file join $path library init.tcl]]} {\n" \
  85. " set ::tcl_library [file normalize [file join $path library]]\n" \
  86. " break\n" \
  87. " }\n" \
  88. "}\n" \
  89. "foreach path {\n" \
  90. " ../tk\n" \
  91. "} {\n" \
  92. " if {[file exists [file join $path library tk.tcl]]} {\n" \
  93. " set ::tk_library [file normalize [file join $path library]]\n" \
  94. " break\n" \
  95. " }\n" \
  96. "}\n" \
  97. "\n" );
  98. }
  99. return TCL_OK;}
  100. /* Tclkit_AppInit */
  101. int Tclkit_AppInit(Tcl_Interp *interp){
  102. if ((Tcl_Init)(interp) == TCL_ERROR) {
  103. return TCL_ERROR;
  104. }
  105.  
  106. TclZipfs_Init(interp);
  107. if(Tk_Init(interp)) return TCL_ERROR;
  108. Tcl_StaticPackage(interp,"Tk",Tk_Init,NULL);
  109. if(Sqlite3_Init(interp)) return TCL_ERROR;
  110. Tcl_StaticPackage(interp,"sqlite3",Sqlite3_Init,NULL);
  111. Tcl_StaticPackage(NULL,"Tkhtml",Tkhtml_Init,NULL);
  112. if(Odielibc_Init(interp)) return TCL_ERROR;
  113. Tcl_StaticPackage(interp,"odielib",Odielibc_Init,NULL);
  114. Tcl_Eval(interp,
  115. "\n" \
  116. "set ::kitpkg(Tk) {package ifneeded Tk 8.6.8 {::load {} Tk}}\n" \
  117. "set ::kitpkg(sqlite3) {package ifneeded sqlite3 3.20.1 {::load {} sqlite3}}\n" \
  118. "set ::kitpkg(Tkhtml) {package ifneeded Tkhtml 3.0 {::load {} Tkhtml}}\n" \
  119. "package ifneeded Tkhtml 3.0 {::load {} Tkhtml}\n" \
  120. "set ::kitpkg(odielib) {package ifneeded odielib 2.3 {::load {} odielib}}\n" \
  121. "\n" \
  122. "if {[file exists [file join $::SRCDIR packages.tcl]]} {\n" \
  123. " #In a wrapped exe, we don't go out to the environment\n" \
  124. " set dir $::SRCDIR\n" \
  125. " source [file join $::SRCDIR packages.tcl]\n" \
  126. "}\n" \
  127. "# Specify a user-specific startup file to invoke if the application\n" \
  128. "# is run interactively. Typically the startup file is \"~/.apprc\"\n" \
  129. "# where \"app\" is the name of the application. If this line is deleted\n" \
  130. "# then no user-specific startup file will be run under any conditions.\n" \
  131. "\n" \
  132. "set tcl_rcFileName ~/.tclshrc\n" );
  133. return TCL_OK;}
  134. /* END generate-cfile-functions */
  135.  
  136. extern int DLLEXPORT Dirtkit_Init( Tcl_Interp *interp ) {
  137. /* Initialise the stubs tables. */
  138. #ifdef USE_TCL_STUBS
  139. if (Tcl_InitStubs(interp, "8.6", 0)==NULL) return TCL_ERROR;
  140. if (TclOOInitializeStubs(interp, "1.0") == NULL) return TCL_ERROR;
  141. #endif
  142. return TCL_OK;
  143. }
  144.