Posted to tcl by hypnotoad at Wed Apr 10 20:43:30 GMT 2019view raw

  1. /*
  2. ** This file is generated by the ../sobyk/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 "sobyk.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 Thread_Init;
  42. extern Tcl_PackageInitProc Sqlite3_Init;
  43. extern Tcl_PackageInitProc Udp_Init;
  44. extern Tcl_PackageInitProc Tdom_Init;
  45. extern Tcl_PackageInitProc Tls_Init;
  46. extern Tcl_PackageInitProc KitCrypt_Init;
  47. /* END generate-cfile-header */
  48. /* BEGIN generate-cfile-functions */
  49. /* Tclkit_MainHook */
  50. int Tclkit_MainHook(int *argc, char ***argv){
  51. /*
  52. * Tclkit_MainHook --
  53. * Performs the argument munging for the shell
  54. */
  55.  
  56. CONST char *archive;
  57. Tcl_FindExecutable(*argv[0]);
  58. archive=Tcl_GetNameOfExecutable();
  59. TclZipfs_Init(NULL);
  60. if(!TclZipfs_Mount(NULL, "app", archive, NULL)) {
  61. Tcl_Obj *vfsinitscript;
  62. vfsinitscript=Tcl_NewStringObj("zipfs:/app/main.tcl",-1);
  63. Tcl_IncrRefCount(vfsinitscript);
  64. if(Tcl_FSAccess(vfsinitscript,F_OK)==0) {
  65. /* Startup script should be set before calling Tcl_AppInit */
  66. Tcl_SetStartupScript(vfsinitscript,NULL);
  67. }
  68.  
  69. TclSetPreInitScript(
  70. "\n" \
  71. "set ::odie(boot_vfs) zipfs:/app\n" \
  72. "set ::SRCDIR $::odie(boot_vfs)\n" \
  73. "namespace eval ::starkit {}\n" \
  74. "set ::starkit::topdir zipfs:/app\n" \
  75. "if {[file exists [file join zipfs:/app tcl_library init.tcl]]} {\n" \
  76. " set ::tcl_library [file join zipfs:/app tcl_library]\n" \
  77. " set ::auto_path {}\n" \
  78. "}\n" \
  79. "if {[file exists [file join zipfs:/app tk_library tk.tcl]]} {\n" \
  80. " set ::tk_library [file join zipfs:/app tk_library]\n" \
  81. "}\n" \
  82. "\n" );
  83. } else {
  84. TclSetPreInitScript(
  85. "\n" \
  86. "foreach path {../tcl} {\n" \
  87. " set p [file join $path library init.tcl]\n" \
  88. " if {[file exists [file join $path library init.tcl]]} {\n" \
  89. " set ::tcl_library [file normalize [file join $path library]]\n" \
  90. " break\n" \
  91. " }\n" \
  92. "}\n" \
  93. "foreach path {\n" \
  94. " ../tk\n" \
  95. "} {\n" \
  96. " if {[file exists [file join $path library tk.tcl]]} {\n" \
  97. " set ::tk_library [file normalize [file join $path library]]\n" \
  98. " break\n" \
  99. " }\n" \
  100. "}\n" \
  101. "\n" );
  102. }
  103. return TCL_OK;}
  104. /* Tclkit_AppInit */
  105. int Tclkit_AppInit(Tcl_Interp *interp){
  106. if ((Tcl_Init)(interp) == TCL_ERROR) {
  107. return TCL_ERROR;
  108. }
  109.  
  110. TclZipfs_Init(interp);
  111. Tcl_StaticPackage(NULL,"Thread",Thread_Init,NULL);
  112. if(Sqlite3_Init(interp)) return TCL_ERROR;
  113. Tcl_StaticPackage(interp,"sqlite3",Sqlite3_Init,NULL);
  114. Tcl_StaticPackage(NULL,"udp",Udp_Init,NULL);
  115. Tcl_StaticPackage(NULL,"tdom",Tdom_Init,NULL);
  116. Tcl_StaticPackage(NULL,"tls",Tls_Init,NULL);
  117. if(KitCrypt_Init(interp)) return TCL_ERROR;
  118. Tcl_StaticPackage(interp,"kitcrypt",KitCrypt_Init,NULL);
  119. Tcl_Eval(interp,
  120. "namespace eval ::starkit {}\n" \
  121. "set ::starkit::topdir zipfs:/app\n" \
  122. "set ::kitpkg(Thread) {package ifneeded Thread 2.9a1 {::load {} Thread}}\n" \
  123. "package ifneeded Thread 2.9a1 {::load {} Thread}\n" \
  124. "set ::kitpkg(sqlite3) {package ifneeded sqlite3 3.20.1 {::load {} sqlite3}}\n" \
  125. "set ::kitpkg(udp) {package ifneeded udp 1.0.10 {::load {} udp}}\n" \
  126. "package ifneeded udp 1.0.10 {::load {} udp}\n" \
  127. "set ::kitpkg(tdom) {package ifneeded tdom 0.9.2 {::load {} tdom}}\n" \
  128. "package ifneeded tdom 0.9.2 {::load {} tdom}\n" \
  129. "set ::kitpkg(tls) {package ifneeded tls 1.8.0 {::load {} tls}}\n" \
  130. "package ifneeded tls 1.8.0 {::load {} tls}\n" \
  131. "set ::kitpkg(kitcrypt) {package ifneeded kitcrypt 1.0 {::load {} kitcrypt}}\n" \
  132. "\n" \
  133. "if {[file exists [file join $::starkit::topdir pkgIndex.tcl]]} {\n" \
  134. " #In a wrapped exe, we don't go out to the environment\n" \
  135. " set dir $::starkit::topdir\n" \
  136. " source [file join $::starkit::topdir pkgIndex.tcl]\n" \
  137. "}\n" \
  138. "set ::starkit::thread_init {namespace eval ::starkit {}\n" \
  139. "set ::starkit::topdir zipfs:/app\n" \
  140. "set ::kitpkg(Thread) {package ifneeded Thread 2.9a1 {::load {} Thread}}\n" \
  141. "package ifneeded Thread 2.9a1 {::load {} Thread}\n" \
  142. "set ::kitpkg(sqlite3) {package ifneeded sqlite3 3.20.1 {::load {} sqlite3}}\n" \
  143. "set ::kitpkg(udp) {package ifneeded udp 1.0.10 {::load {} udp}}\n" \
  144. "package ifneeded udp 1.0.10 {::load {} udp}\n" \
  145. "set ::kitpkg(tdom) {package ifneeded tdom 0.9.2 {::load {} tdom}}\n" \
  146. "package ifneeded tdom 0.9.2 {::load {} tdom}\n" \
  147. "set ::kitpkg(tls) {package ifneeded tls 1.8.0 {::load {} tls}}\n" \
  148. "package ifneeded tls 1.8.0 {::load {} tls}\n" \
  149. "set ::kitpkg(kitcrypt) {package ifneeded kitcrypt 1.0 {::load {} kitcrypt}}\n" \
  150. "\n" \
  151. "if {[file exists [file join $::starkit::topdir pkgIndex.tcl]]} {\n" \
  152. " #In a wrapped exe, we don't go out to the environment\n" \
  153. " set dir $::starkit::topdir\n" \
  154. " source [file join $::starkit::topdir pkgIndex.tcl]\n" \
  155. "}}\n" );
  156. return TCL_OK;}
  157. /* END generate-cfile-functions */
  158.  
  159. extern int DLLEXPORT Sobyk_Init( Tcl_Interp *interp ) {
  160. /* Initialise the stubs tables. */
  161. #ifdef USE_TCL_STUBS
  162. if (Tcl_InitStubs(interp, "8.6", 0)==NULL) return TCL_ERROR;
  163. if (TclOOInitializeStubs(interp, "1.0") == NULL) return TCL_ERROR;
  164. #endif
  165. if(KitCrypt_Init(interp)) return TCL_ERROR;
  166. if(KitCrypt_Init(interp)) return TCL_ERROR;
  167. return TCL_OK;
  168. }
  169.