Subversion Repositories Vertical

Rev

Rev 2 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /* This code is automatically generated by "mktclapp" version 3.9 */
  2. /* DO NOT EDIT */
  3. #include <tcl.h>
  4. #define INTERFACE 1
  5. #if INTERFACE
  6. #define ET_TCLARGS ClientData clientData,Tcl_Interp*interp,int argc,char**argv
  7. #define ET_OBJARGS ClientData clientData,Tcl_Interp*interp,int objc,Tcl_Obj*CONST objv[]
  8. #endif
  9. #define ET_ENABLE_OBJ 0
  10. #define ET_ENABLE_TK 1
  11. #define ET_AUTO_FORK 0
  12. #define ET_STANDALONE 0
  13. #define ET_N_BUILTIN_SCRIPT 2
  14. #define ET_VERSION "3.9"
  15. #define ET_HAVE_APPINIT 0
  16. #define ET_HAVE_PREINIT 0
  17. #define ET_HAVE_MAIN 1
  18. #define ET_HAVE_CUSTOM_MAINLOOP 0
  19. #define ET_TCL_LIBRARY "C:/cygwin/usr/share/tcl8.0"
  20. #define ET_TK_LIBRARY "C:/cygwin/usr/share/tk8.0"
  21. #define ET_MAIN_SCRIPT "C:/cygwin/home/vertical/scripts/trial.tcl"
  22. #define ET_EXTENSION 0
  23. #define ET_SHROUD_KEY 0
  24. #define ET_READ_STDIN 1
  25. #define ET_CONSOLE 0
  26. extern int ET_COMMAND_vertical(ET_TCLARGS);
  27. extern int ET_COMMAND_wossat(ET_TCLARGS);
  28. static struct {
  29.   char *zName;
  30.   int (*xProc)(ET_TCLARGS);
  31. } Et_CmdSet[] = {
  32.  { "vertical", ET_COMMAND_vertical },
  33.  { "wossat", ET_COMMAND_wossat },
  34. {0, 0}};
  35. static char Et_zFile0[] =
  36. "# Tcl autoload index file, version 2.0\n"
  37. "# This file is generated by the \"auto_mkindex\" command\n"
  38. "# and sourced to set up indexing information for one or\n"
  39. "# more commands.  Typically each line is a command that\n"
  40. "# sets an element in the auto_index array, where the\n"
  41. "# element name is the name of a command and the value is\n"
  42. "# a script that loads the command.\n"
  43. "\n"
  44. "set auto_index(history) [list source [file join $dir history.tcl]]\n"
  45. "set auto_index(tclLdAout) [list source [file join $dir ldAout.tcl]]\n"
  46. "set auto_index(parray) [list source [file join $dir parray.tcl]]\n"
  47. "set auto_index(::safe::interpCreate) [list source [file join $dir safe.tcl]]\n"
  48. "set auto_index(::safe::interpInit) [list source [file join $dir safe.tcl]]\n"
  49. "set auto_index(::safe::interpConfigure) [list source [file join $dir safe.tcl]]\n"
  50. "set auto_index(::safe::interpFindInAccessPath) [list source [file join $dir safe.tcl]]\n"
  51. "set auto_index(::safe::interpAddToAccessPath) [list source [file join $dir safe.tcl]]\n"
  52. "set auto_index(::safe::interpDelete) [list source [file join $dir safe.tcl]]\n"
  53. "set auto_index(::safe::setLogCmd) [list source [file join $dir safe.tcl]]\n"
  54. "set auto_index(tcl_wordBreakAfter) [list source [file join $dir word.tcl]]\n"
  55. "set auto_index(tcl_wordBreakBefore) [list source [file join $dir word.tcl]]\n"
  56. "set auto_index(tcl_endOfWord) [list source [file join $dir word.tcl]]\n"
  57. "set auto_index(tcl_startOfNextWord) [list source [file join $dir word.tcl]]\n"
  58. "set auto_index(tcl_startOfPreviousWord) [list source [file join $dir word.tcl]]\n"
  59. ;
  60. static char Et_zFile1[] =
  61. "# Tcl autoload index file, version 2.0\n"
  62. "# This file is generated by the \"auto_mkindex\" command\n"
  63. "# and sourced to set up indexing information for one or\n"
  64. "# more commands.  Typically each line is a command that\n"
  65. "# sets an element in the auto_index array, where the\n"
  66. "# element name is the name of a command and the value is\n"
  67. "# a script that loads the command.\n"
  68. "\n"
  69. "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n"
  70. "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n"
  71. "set auto_index(tkCheckRadioEnter) [list source [file join $dir button.tcl]]\n"
  72. "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n"
  73. "set auto_index(tkCheckRadioDown) [list source [file join $dir button.tcl]]\n"
  74. "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n"
  75. "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n"
  76. "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n"
  77. "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n"
  78. "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n"
  79. "set auto_index(tkButtonEnter) [list source [file join $dir button.tcl]]\n"
  80. "set auto_index(tkButtonLeave) [list source [file join $dir button.tcl]]\n"
  81. "set auto_index(tkButtonDown) [list source [file join $dir button.tcl]]\n"
  82. "set auto_index(tkButtonUp) [list source [file join $dir button.tcl]]\n"
  83. "set auto_index(tkButtonInvoke) [list source [file join $dir button.tcl]]\n"
  84. "set auto_index(tkCheckRadioInvoke) [list source [file join $dir button.tcl]]\n"
  85. "set auto_index(tk_dialog) [list source [file join $dir dialog.tcl]]\n"
  86. "set auto_index(tkEntryClosestGap) [list source [file join $dir entry.tcl]]\n"
  87. "set auto_index(tkEntryButton1) [list source [file join $dir entry.tcl]]\n"
  88. "set auto_index(tkEntryMouseSelect) [list source [file join $dir entry.tcl]]\n"
  89. "set auto_index(tkEntryPaste) [list source [file join $dir entry.tcl]]\n"
  90. "set auto_index(tkEntryAutoScan) [list source [file join $dir entry.tcl]]\n"
  91. "set auto_index(tkEntryKeySelect) [list source [file join $dir entry.tcl]]\n"
  92. "set auto_index(tkEntryInsert) [list source [file join $dir entry.tcl]]\n"
  93. "set auto_index(tkEntryBackspace) [list source [file join $dir entry.tcl]]\n"
  94. "set auto_index(tkEntrySeeInsert) [list source [file join $dir entry.tcl]]\n"
  95. "set auto_index(tkEntrySetCursor) [list source [file join $dir entry.tcl]]\n"
  96. "set auto_index(tkEntryTranspose) [list source [file join $dir entry.tcl]]\n"
  97. "set auto_index(tkEntryPreviousWord) [list source [file join $dir entry.tcl]]\n"
  98. "set auto_index(tkListboxBeginSelect) [list source [file join $dir listbox.tcl]]\n"
  99. "set auto_index(tkListboxMotion) [list source [file join $dir listbox.tcl]]\n"
  100. "set auto_index(tkListboxBeginExtend) [list source [file join $dir listbox.tcl]]\n"
  101. "set auto_index(tkListboxBeginToggle) [list source [file join $dir listbox.tcl]]\n"
  102. "set auto_index(tkListboxAutoScan) [list source [file join $dir listbox.tcl]]\n"
  103. "set auto_index(tkListboxUpDown) [list source [file join $dir listbox.tcl]]\n"
  104. "set auto_index(tkListboxExtendUpDown) [list source [file join $dir listbox.tcl]]\n"
  105. "set auto_index(tkListboxDataExtend) [list source [file join $dir listbox.tcl]]\n"
  106. "set auto_index(tkListboxCancel) [list source [file join $dir listbox.tcl]]\n"
  107. "set auto_index(tkListboxSelectAll) [list source [file join $dir listbox.tcl]]\n"
  108. "set auto_index(tkMbEnter) [list source [file join $dir menu.tcl]]\n"
  109. "set auto_index(tkMbLeave) [list source [file join $dir menu.tcl]]\n"
  110. "set auto_index(tkMbPost) [list source [file join $dir menu.tcl]]\n"
  111. "set auto_index(tkMenuUnpost) [list source [file join $dir menu.tcl]]\n"
  112. "set auto_index(tkMbMotion) [list source [file join $dir menu.tcl]]\n"
  113. "set auto_index(tkMbButtonUp) [list source [file join $dir menu.tcl]]\n"
  114. "set auto_index(tkMenuMotion) [list source [file join $dir menu.tcl]]\n"
  115. "set auto_index(tkMenuButtonDown) [list source [file join $dir menu.tcl]]\n"
  116. "set auto_index(tkMenuLeave) [list source [file join $dir menu.tcl]]\n"
  117. "set auto_index(tkMenuInvoke) [list source [file join $dir menu.tcl]]\n"
  118. "set auto_index(tkMenuEscape) [list source [file join $dir menu.tcl]]\n"
  119. "set auto_index(tkMenuUpArrow) [list source [file join $dir menu.tcl]]\n"
  120. "set auto_index(tkMenuDownArrow) [list source [file join $dir menu.tcl]]\n"
  121. "set auto_index(tkMenuLeftArrow) [list source [file join $dir menu.tcl]]\n"
  122. "set auto_index(tkMenuRightArrow) [list source [file join $dir menu.tcl]]\n"
  123. "set auto_index(tkMenuNextMenu) [list source [file join $dir menu.tcl]]\n"
  124. "set auto_index(tkMenuNextEntry) [list source [file join $dir menu.tcl]]\n"
  125. "set auto_index(tkMenuFind) [list source [file join $dir menu.tcl]]\n"
  126. "set auto_index(tkTraverseToMenu) [list source [file join $dir menu.tcl]]\n"
  127. "set auto_index(tkFirstMenu) [list source [file join $dir menu.tcl]]\n"
  128. "set auto_index(tkTraverseWithinMenu) [list source [file join $dir menu.tcl]]\n"
  129. "set auto_index(tkMenuFirstEntry) [list source [file join $dir menu.tcl]]\n"
  130. "set auto_index(tkMenuFindName) [list source [file join $dir menu.tcl]]\n"
  131. "set auto_index(tkPostOverPoint) [list source [file join $dir menu.tcl]]\n"
  132. "set auto_index(tkSaveGrabInfo) [list source [file join $dir menu.tcl]]\n"
  133. "set auto_index(tkRestoreOldGrab) [list source [file join $dir menu.tcl]]\n"
  134. "set auto_index(tk_menuSetFocus) [list source [file join $dir menu.tcl]]\n"
  135. "set auto_index(tkGenerateMenuSelect) [list source [file join $dir menu.tcl]]\n"
  136. "set auto_index(tk_popup) [list source [file join $dir menu.tcl]]\n"
  137. "set auto_index(tkScrollButtonDown) [list source [file join $dir scrlbar.tcl]]\n"
  138. "set auto_index(tkScrollButtonUp) [list source [file join $dir scrlbar.tcl]]\n"
  139. "set auto_index(tkScrollSelect) [list source [file join $dir scrlbar.tcl]]\n"
  140. "set auto_index(tkScrollStartDrag) [list source [file join $dir scrlbar.tcl]]\n"
  141. "set auto_index(tkScrollDrag) [list source [file join $dir scrlbar.tcl]]\n"
  142. "set auto_index(tkScrollEndDrag) [list source [file join $dir scrlbar.tcl]]\n"
  143. "set auto_index(tkScrollByUnits) [list source [file join $dir scrlbar.tcl]]\n"
  144. "set auto_index(tkScrollByPages) [list source [file join $dir scrlbar.tcl]]\n"
  145. "set auto_index(tkScrollToPos) [list source [file join $dir scrlbar.tcl]]\n"
  146. "set auto_index(tkScrollTopBottom) [list source [file join $dir scrlbar.tcl]]\n"
  147. "set auto_index(tkScrollButton2Down) [list source [file join $dir scrlbar.tcl]]\n"
  148. "set auto_index(tkTextClosestGap) [list source [file join $dir text.tcl]]\n"
  149. "set auto_index(tkTextButton1) [list source [file join $dir text.tcl]]\n"
  150. "set auto_index(tkTextSelectTo) [list source [file join $dir text.tcl]]\n"
  151. "set auto_index(tkTextKeyExtend) [list source [file join $dir text.tcl]]\n"
  152. "set auto_index(tkTextPaste) [list source [file join $dir text.tcl]]\n"
  153. "set auto_index(tkTextAutoScan) [list source [file join $dir text.tcl]]\n"
  154. "set auto_index(tkTextSetCursor) [list source [file join $dir text.tcl]]\n"
  155. "set auto_index(tkTextKeySelect) [list source [file join $dir text.tcl]]\n"
  156. "set auto_index(tkTextResetAnchor) [list source [file join $dir text.tcl]]\n"
  157. "set auto_index(tkTextInsert) [list source [file join $dir text.tcl]]\n"
  158. "set auto_index(tkTextUpDownLine) [list source [file join $dir text.tcl]]\n"
  159. "set auto_index(tkTextPrevPara) [list source [file join $dir text.tcl]]\n"
  160. "set auto_index(tkTextNextPara) [list source [file join $dir text.tcl]]\n"
  161. "set auto_index(tkTextScrollPages) [list source [file join $dir text.tcl]]\n"
  162. "set auto_index(tkTextTranspose) [list source [file join $dir text.tcl]]\n"
  163. "set auto_index(tk_textCopy) [list source [file join $dir text.tcl]]\n"
  164. "set auto_index(tk_textCut) [list source [file join $dir text.tcl]]\n"
  165. "set auto_index(tk_textPaste) [list source [file join $dir text.tcl]]\n"
  166. "set auto_index(tkTextNextPos) [list source [file join $dir text.tcl]]\n"
  167. "set auto_index(tkTextPrevPos) [list source [file join $dir text.tcl]]\n"
  168. "set auto_index(tkScreenChanged) [list source [file join $dir tk.tcl]]\n"
  169. "set auto_index(tkEventMotifBindings) [list source [file join $dir tk.tcl]]\n"
  170. "set auto_index(tkCancelRepeat) [list source [file join $dir tk.tcl]]\n"
  171. "set auto_index(tkTabToWindow) [list source [file join $dir tk.tcl]]\n"
  172. "set auto_index(bgerror) [list source [file join $dir bgerror.tcl]]\n"
  173. "set auto_index(tkScaleActivate) [list source [file join $dir scale.tcl]]\n"
  174. "set auto_index(tkScaleButtonDown) [list source [file join $dir scale.tcl]]\n"
  175. "set auto_index(tkScaleDrag) [list source [file join $dir scale.tcl]]\n"
  176. "set auto_index(tkScaleEndDrag) [list source [file join $dir scale.tcl]]\n"
  177. "set auto_index(tkScaleIncrement) [list source [file join $dir scale.tcl]]\n"
  178. "set auto_index(tkScaleControlPress) [list source [file join $dir scale.tcl]]\n"
  179. "set auto_index(tkScaleButton2Down) [list source [file join $dir scale.tcl]]\n"
  180. "set auto_index(tk_optionMenu) [list source [file join $dir optMenu.tcl]]\n"
  181. "set auto_index(tkTearOffMenu) [list source [file join $dir tearoff.tcl]]\n"
  182. "set auto_index(tkMenuDup) [list source [file join $dir tearoff.tcl]]\n"
  183. "set auto_index(tk_menuBar) [list source [file join $dir obsolete.tcl]]\n"
  184. "set auto_index(tk_bindForTraversal) [list source [file join $dir obsolete.tcl]]\n"
  185. "set auto_index(tk_focusNext) [list source [file join $dir focus.tcl]]\n"
  186. "set auto_index(tk_focusPrev) [list source [file join $dir focus.tcl]]\n"
  187. "set auto_index(tkFocusOK) [list source [file join $dir focus.tcl]]\n"
  188. "set auto_index(tk_focusFollowsMouse) [list source [file join $dir focus.tcl]]\n"
  189. "set auto_index(tkConsoleInit) [list source [file join $dir console.tcl]]\n"
  190. "set auto_index(tkConsoleSource) [list source [file join $dir console.tcl]]\n"
  191. "set auto_index(tkConsoleInvoke) [list source [file join $dir console.tcl]]\n"
  192. "set auto_index(tkConsoleHistory) [list source [file join $dir console.tcl]]\n"
  193. "set auto_index(tkConsolePrompt) [list source [file join $dir console.tcl]]\n"
  194. "set auto_index(tkConsoleBind) [list source [file join $dir console.tcl]]\n"
  195. "set auto_index(tkConsoleInsert) [list source [file join $dir console.tcl]]\n"
  196. "set auto_index(tkConsoleOutput) [list source [file join $dir console.tcl]]\n"
  197. "set auto_index(tkConsoleExit) [list source [file join $dir console.tcl]]\n"
  198. "set auto_index(tkConsoleAbout) [list source [file join $dir console.tcl]]\n"
  199. "set auto_index(tk_setPalette) [list source [file join $dir palette.tcl]]\n"
  200. "set auto_index(tkRecolorTree) [list source [file join $dir palette.tcl]]\n"
  201. "set auto_index(tkDarken) [list source [file join $dir palette.tcl]]\n"
  202. "set auto_index(tk_bisque) [list source [file join $dir palette.tcl]]\n"
  203. "set auto_index(tkColorDialog) [list source [file join $dir clrpick.tcl]]\n"
  204. "set auto_index(tkColorDialog_InitValues) [list source [file join $dir clrpick.tcl]]\n"
  205. "set auto_index(tkColorDialog_Config) [list source [file join $dir clrpick.tcl]]\n"
  206. "set auto_index(tkColorDialog_BuildDialog) [list source [file join $dir clrpick.tcl]]\n"
  207. "set auto_index(tkColorDialog_SetRGBValue) [list source [file join $dir clrpick.tcl]]\n"
  208. "set auto_index(tkColorDialog_XToRgb) [list source [file join $dir clrpick.tcl]]\n"
  209. "set auto_index(tkColorDialog_RgbToX) [list source [file join $dir clrpick.tcl]]\n"
  210. "set auto_index(tkColorDialog_DrawColorScale) [list source [file join $dir clrpick.tcl]]\n"
  211. "set auto_index(tkColorDialog_CreateSelector) [list source [file join $dir clrpick.tcl]]\n"
  212. "set auto_index(tkColorDialog_RedrawFinalColor) [list source [file join $dir clrpick.tcl]]\n"
  213. "set auto_index(tkColorDialog_RedrawColorBars) [list source [file join $dir clrpick.tcl]]\n"
  214. "set auto_index(tkColorDialog_StartMove) [list source [file join $dir clrpick.tcl]]\n"
  215. "set auto_index(tkColorDialog_MoveSelector) [list source [file join $dir clrpick.tcl]]\n"
  216. "set auto_index(tkColorDialog_ReleaseMouse) [list source [file join $dir clrpick.tcl]]\n"
  217. "set auto_index(tkColorDialog_ResizeColorBars) [list source [file join $dir clrpick.tcl]]\n"
  218. "set auto_index(tkColorDialog_HandleSelEntry) [list source [file join $dir clrpick.tcl]]\n"
  219. "set auto_index(tkColorDialog_HandleRGBEntry) [list source [file join $dir clrpick.tcl]]\n"
  220. "set auto_index(tkColorDialog_EnterColorBar) [list source [file join $dir clrpick.tcl]]\n"
  221. "set auto_index(tkColorDialog_LeaveColorBar) [list source [file join $dir clrpick.tcl]]\n"
  222. "set auto_index(tkColorDialog_OkCmd) [list source [file join $dir clrpick.tcl]]\n"
  223. "set auto_index(tkColorDialog_CancelCmd) [list source [file join $dir clrpick.tcl]]\n"
  224. "set auto_index(tclParseConfigSpec) [list source [file join $dir comdlg.tcl]]\n"
  225. "set auto_index(tclListValidFlags) [list source [file join $dir comdlg.tcl]]\n"
  226. "set auto_index(tclSortNoCase) [list source [file join $dir comdlg.tcl]]\n"
  227. "set auto_index(tclVerifyInteger) [list source [file join $dir comdlg.tcl]]\n"
  228. "set auto_index(tkFocusGroup_Create) [list source [file join $dir comdlg.tcl]]\n"
  229. "set auto_index(tkFocusGroup_BindIn) [list source [file join $dir comdlg.tcl]]\n"
  230. "set auto_index(tkFocusGroup_BindOut) [list source [file join $dir comdlg.tcl]]\n"
  231. "set auto_index(tkFocusGroup_Destroy) [list source [file join $dir comdlg.tcl]]\n"
  232. "set auto_index(tkFocusGroup_In) [list source [file join $dir comdlg.tcl]]\n"
  233. "set auto_index(tkFocusGroup_Out) [list source [file join $dir comdlg.tcl]]\n"
  234. "set auto_index(tkFDGetFileTypes) [list source [file join $dir comdlg.tcl]]\n"
  235. "set auto_index(::safe::loadTk) [list source [file join $dir safetk.tcl]]\n"
  236. "set auto_index(::safe::TkInit) [list source [file join $dir safetk.tcl]]\n"
  237. "set auto_index(::safe::allowTk) [list source [file join $dir safetk.tcl]]\n"
  238. "set auto_index(::safe::tkTopLevel) [list source [file join $dir safetk.tcl]]\n"
  239. "set auto_index(tkMessageBox) [list source [file join $dir msgbox.tcl]]\n"
  240. "set auto_index(tkIconList) [list source [file join $dir tkfbox.tcl]]\n"
  241. "set auto_index(tkIconList_Config) [list source [file join $dir tkfbox.tcl]]\n"
  242. "set auto_index(tkIconList_Create) [list source [file join $dir tkfbox.tcl]]\n"
  243. "set auto_index(tkIconList_AutoScan) [list source [file join $dir tkfbox.tcl]]\n"
  244. "set auto_index(tkIconList_DeleteAll) [list source [file join $dir tkfbox.tcl]]\n"
  245. "set auto_index(tkIconList_Add) [list source [file join $dir tkfbox.tcl]]\n"
  246. "set auto_index(tkIconList_Arrange) [list source [file join $dir tkfbox.tcl]]\n"
  247. "set auto_index(tkIconList_Invoke) [list source [file join $dir tkfbox.tcl]]\n"
  248. "set auto_index(tkIconList_See) [list source [file join $dir tkfbox.tcl]]\n"
  249. "set auto_index(tkIconList_SelectAtXY) [list source [file join $dir tkfbox.tcl]]\n"
  250. "set auto_index(tkIconList_Select) [list source [file join $dir tkfbox.tcl]]\n"
  251. "set auto_index(tkIconList_Unselect) [list source [file join $dir tkfbox.tcl]]\n"
  252. "set auto_index(tkIconList_Get) [list source [file join $dir tkfbox.tcl]]\n"
  253. "set auto_index(tkIconList_Btn1) [list source [file join $dir tkfbox.tcl]]\n"
  254. "set auto_index(tkIconList_Motion1) [list source [file join $dir tkfbox.tcl]]\n"
  255. "set auto_index(tkIconList_Double1) [list source [file join $dir tkfbox.tcl]]\n"
  256. "set auto_index(tkIconList_ReturnKey) [list source [file join $dir tkfbox.tcl]]\n"
  257. "set auto_index(tkIconList_Leave1) [list source [file join $dir tkfbox.tcl]]\n"
  258. "set auto_index(tkIconList_FocusIn) [list source [file join $dir tkfbox.tcl]]\n"
  259. "set auto_index(tkIconList_UpDown) [list source [file join $dir tkfbox.tcl]]\n"
  260. "set auto_index(tkIconList_LeftRight) [list source [file join $dir tkfbox.tcl]]\n"
  261. "set auto_index(tkIconList_KeyPress) [list source [file join $dir tkfbox.tcl]]\n"
  262. "set auto_index(tkIconList_Goto) [list source [file join $dir tkfbox.tcl]]\n"
  263. "set auto_index(tkIconList_Reset) [list source [file join $dir tkfbox.tcl]]\n"
  264. "set auto_index(tkFDialog) [list source [file join $dir tkfbox.tcl]]\n"
  265. "set auto_index(tkFDialog_Config) [list source [file join $dir tkfbox.tcl]]\n"
  266. "set auto_index(tkFDialog_Create) [list source [file join $dir tkfbox.tcl]]\n"
  267. "set auto_index(tkFDialog_UpdateWhenIdle) [list source [file join $dir tkfbox.tcl]]\n"
  268. "set auto_index(tkFDialog_Update) [list source [file join $dir tkfbox.tcl]]\n"
  269. "set auto_index(tkFDialog_SetPathSilently) [list source [file join $dir tkfbox.tcl]]\n"
  270. "set auto_index(tkFDialog_SetPath) [list source [file join $dir tkfbox.tcl]]\n"
  271. "set auto_index(tkFDialog_SetFilter) [list source [file join $dir tkfbox.tcl]]\n"
  272. "set auto_index(tkFDialogResolveFile) [list source [file join $dir tkfbox.tcl]]\n"
  273. "set auto_index(tkFDialog_EntFocusIn) [list source [file join $dir tkfbox.tcl]]\n"
  274. "set auto_index(tkFDialog_EntFocusOut) [list source [file join $dir tkfbox.tcl]]\n"
  275. "set auto_index(tkFDialog_ActivateEnt) [list source [file join $dir tkfbox.tcl]]\n"
  276. "set auto_index(tkFDialog_InvokeBtn) [list source [file join $dir tkfbox.tcl]]\n"
  277. "set auto_index(tkFDialog_UpDirCmd) [list source [file join $dir tkfbox.tcl]]\n"
  278. "set auto_index(tkFDialog_JoinFile) [list source [file join $dir tkfbox.tcl]]\n"
  279. "set auto_index(tkFDialog_OkCmd) [list source [file join $dir tkfbox.tcl]]\n"
  280. "set auto_index(tkFDialog_CancelCmd) [list source [file join $dir tkfbox.tcl]]\n"
  281. "set auto_index(tkFDialog_ListBrowse) [list source [file join $dir tkfbox.tcl]]\n"
  282. "set auto_index(tkFDialog_ListInvoke) [list source [file join $dir tkfbox.tcl]]\n"
  283. "set auto_index(tkFDialog_Done) [list source [file join $dir tkfbox.tcl]]\n"
  284. "set auto_index(tkMotifFDialog) [list source [file join $dir xmfbox.tcl]]\n"
  285. "set auto_index(tkMotifFDialog_Config) [list source [file join $dir xmfbox.tcl]]\n"
  286. "set auto_index(tkMotifFDialog_Create) [list source [file join $dir xmfbox.tcl]]\n"
  287. "set auto_index(tkMotifFDialog_MakeSList) [list source [file join $dir xmfbox.tcl]]\n"
  288. "set auto_index(tkMotifFDialog_BrowseDList) [list source [file join $dir xmfbox.tcl]]\n"
  289. "set auto_index(tkMotifFDialog_ActivateDList) [list source [file join $dir xmfbox.tcl]]\n"
  290. "set auto_index(tkMotifFDialog_BrowseFList) [list source [file join $dir xmfbox.tcl]]\n"
  291. "set auto_index(tkMotifFDialog_ActivateFList) [list source [file join $dir xmfbox.tcl]]\n"
  292. "set auto_index(tkMotifFDialog_ActivateFEnt) [list source [file join $dir xmfbox.tcl]]\n"
  293. "set auto_index(tkMotifFDialog_InterpFilter) [list source [file join $dir xmfbox.tcl]]\n"
  294. "set auto_index(tkMotifFDialog_ActivateSEnt) [list source [file join $dir xmfbox.tcl]]\n"
  295. "set auto_index(tkMotifFDialog_OkCmd) [list source [file join $dir xmfbox.tcl]]\n"
  296. "set auto_index(tkMotifFDialog_FilterCmd) [list source [file join $dir xmfbox.tcl]]\n"
  297. "set auto_index(tkMotifFDialog_CancelCmd) [list source [file join $dir xmfbox.tcl]]\n"
  298. "set auto_index(tkMotifFDialog_Update) [list source [file join $dir xmfbox.tcl]]\n"
  299. "set auto_index(tkMotifFDialog_LoadFiles) [list source [file join $dir xmfbox.tcl]]\n"
  300. "set auto_index(tkListBoxKeyAccel_Set) [list source [file join $dir xmfbox.tcl]]\n"
  301. "set auto_index(tkListBoxKeyAccel_Unset) [list source [file join $dir xmfbox.tcl]]\n"
  302. "set auto_index(tkListBoxKeyAccel_Key) [list source [file join $dir xmfbox.tcl]]\n"
  303. "set auto_index(tkListBoxKeyAccel_Goto) [list source [file join $dir xmfbox.tcl]]\n"
  304. "set auto_index(tkListBoxKeyAccel_Reset) [list source [file join $dir xmfbox.tcl]]\n"
  305. ;
  306. struct EtFile {
  307.   char *zName;
  308.   char *zData;
  309.   int nData;
  310.   int shrouded;
  311.   struct EtFile *pNext;
  312. };
  313. static struct EtFile Et_FileSet[] = {
  314.   { "C:/cygwin/usr/share/tcl8.0/tclIndex", Et_zFile0, sizeof(Et_zFile0)-1, 0, 0 },
  315.   { "C:/cygwin/usr/share/tk8.0/tclIndex", Et_zFile1, sizeof(Et_zFile1)-1, 0, 0 },
  316. {0, 0}};
  317. static struct EtFile *Et_FileHashTable[71];
  318. /* The following copyright notice applies to code generated by
  319. ** "mktclapp".  The "mktclapp" program itself is covered by the
  320. ** GNU Public License.
  321. **
  322. ** Copyright (c) 1998 D. Richard Hipp
  323. **
  324. ** The author hereby grants permission to use, copy, modify, distribute,
  325. ** and license this software and its documentation for any purpose, provided
  326. ** that existing copyright notices are retained in all copies and that this
  327. ** notice is included verbatim in any distributions. No written agreement,
  328. ** license, or royalty fee is required for any of the authorized uses.
  329. ** Modifications to this software may be copyrighted by their authors
  330. ** and need not follow the licensing terms described here, provided that
  331. ** the new terms are clearly indicated on the first page of each file where
  332. ** they apply.
  333. **
  334. ** In no event shall the author or the distributors be liable to any party
  335. ** for direct, indirect, special, incidental, or consequential damages
  336. ** arising out of the use of this software, its documentation, or any
  337. ** derivatives thereof, even if the author has been advised of the
  338. ** possibility of such damage.  The author and distributors specifically
  339. ** disclaim any warranties, including but not limited to the implied
  340. ** warranties of merchantability, fitness for a particular purpose, and
  341. ** non-infringment.  This software is provided at no fee on an
  342. ** "as is" basis.  The author and/or distritutors have no obligation
  343. ** to provide maintenance, support, updates, enhancements and/or
  344. ** modifications.
  345. **
  346. ** GOVERNMENT USE: If you are acquiring this software on behalf of the
  347. ** U.S. government, the Government shall have only "Restricted Rights"
  348. ** in the software and related documentation as defined in the Federal
  349. ** Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
  350. ** are acquiring the software on behalf of the Department of Defense, the
  351. ** software shall be classified as "Commercial Computer Software" and the
  352. ** Government shall have only "Restricted Rights" as defined in Clause
  353. ** 252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
  354. ** author grants the U.S. Government and others acting in its behalf
  355. ** permission to use and distribute the software in accordance with the
  356. ** terms specified in this license.
  357. */
  358. #include <ctype.h>
  359. #include <string.h>
  360. #include <stdarg.h>
  361. #include <stdio.h>
  362. #include <stdlib.h>
  363. #include <sys/types.h>
  364. #include <sys/stat.h>
  365. #include <fcntl.h>
  366.  
  367. /* Include either the Tcl or the Tk header file.  Use the "Internal"
  368. ** version of the header file if and only if we are generating an
  369. ** extension  that is linking against the Stub library.
  370. ** Many installations do not have the internal header files
  371. ** available, so using the internal headers only when absolutely
  372. ** necessary will help to reduce compilation problems.
  373. */
  374. #if ET_EXTENSION && defined(TCL_USE_STUBS)
  375. # if ET_ENABLE_TK
  376. #   include <tkInt.h>
  377. # else
  378. #   include <tclInt.h>
  379. # endif
  380. #else
  381. # if ET_ENABLE_TK
  382. #   include <tk.h>
  383. # else
  384. #   include <tcl.h>
  385. # endif
  386. #endif
  387.  
  388. /*
  389. ** ET_WIN32 is true if we are running Tk under windows.  The
  390. ** <tcl.h> module will define __WIN32__ for us if we are compiling
  391. ** for windows.
  392. */
  393. #if defined(__WIN32__) && ET_ENABLE_TK
  394. # define ET_WIN32 1
  395. # include <windows.h>
  396. #else
  397. # define ET_WIN32 0
  398. #endif
  399.  
  400. /*
  401. ** Always disable ET_AUTO_FORK under windows.  Windows doesn't
  402. ** fork well.
  403. */
  404. #if defined(__WIN32__)
  405. # undef ET_AUTO_FORK
  406. # define ET_AUTO_FORK 0
  407. #endif
  408.  
  409. /*
  410. ** Omit <unistd.h> under windows.  But we need it for Unix.
  411. */
  412. #if !defined(__WIN32__)
  413. # include <unistd.h>
  414. #endif
  415.  
  416. /*
  417. ** The Tcl*InsertProc functions allow the system calls "stat",
  418. ** "access" and "open" to be overloaded.  This in turns allows us
  419. ** to substituted compiled-in strings for files in the filesystem.
  420. ** But the Tcl*InsertProc functions are only available in Tcl8.0.3
  421. ** and later.
  422. **
  423. ** Define the ET_HAVE_INSERTPROC macro if and only if we are dealing
  424. ** with Tcl8.0.3 or later.
  425. */
  426. #if TCL_MAJOR_VERSION==8 && (TCL_MINOR_VERSION>0 || TCL_RELEASE_SERIAL>=3)
  427. # define ET_HAVE_INSERTPROC
  428. #endif
  429.  
  430. /*
  431. ** If we are using the Tcl*InsertProc() functions, we should provide
  432. ** prototypes for them.  But the prototypes are in the tclInt.h include
  433. ** file, which we don't want to require the user to have on hand.  So
  434. ** we provide our own prototypes here.
  435. **
  436. ** Note that if TCL_USE_STUBS is defined, then the tclInt.h is required
  437. ** anyway, so these prototypes are not included if TCL_USE_STUBS is
  438. ** defined.  
  439. */
  440. #if defined(ET_HAVE_INSERTPROC) && !defined(TCL_USE_STUBS)
  441. #ifdef __cplusplus
  442.   extern "C" int TclStatInsertProc(int (*)(char*, struct stat *));
  443.   extern "C" int TclAccessInsertProc(int (*)(char*, int));
  444.   extern "C" int TclOpenFileChannelInsertProc(Tcl_Channel (*)(Tcl_Interp*,char*,
  445.                                                           char*,int));
  446. #else
  447.   extern int TclStatInsertProc(int (*)(char*, struct stat *));
  448.   extern int TclAccessInsertProc(int (*)(char*, int));
  449.   extern int TclOpenFileChannelInsertProc(Tcl_Channel (*)(Tcl_Interp*,char*,
  450.                                                           char*,int));
  451. #endif
  452. #endif
  453.  
  454.  
  455. /*
  456. ** Don't allow Win32 applications to read from stdin.  Nor
  457. ** programs that automatically go into the background.  Force
  458. ** the use of a console in these cases.
  459. */
  460. #if (ET_WIN32 || ET_AUTO_FORK) && ET_READ_STDIN
  461. # undef ET_READ_STDIN
  462. # undef ET_CONSOLE
  463. # define ET_READ_STDIN 0
  464. # define ET_CONSOLE 1
  465. #endif
  466.  
  467. /*
  468. ** The console won't work without Tk.
  469. */
  470. #if ET_ENABLE_TK==0 && ET_CONSOLE
  471. # undef ET_CONSOLE
  472. # define ET_CONSOLE 0
  473. # undef ET_READ_STDIN
  474. # define ET_READ_STDIN 1
  475. #endif
  476.  
  477. /*
  478. ** Set ET_HAVE_OBJ to true if we are able to link against the
  479. ** new Tcl_Obj interface.  This is only the case for Tcl version
  480. ** 8.0 and later.
  481. */
  482. #if ET_ENABLE_OBJ || TCL_MAJOR_VERSION>=8
  483. # define ET_HAVE_OBJ 1
  484. #else
  485. # define ET_HAVE_OBJ 0
  486. #endif
  487.  
  488. /*
  489. ** The Tcl_GetByteArrayFromObj() only appears in Tcl version 8.1
  490. ** and later.  Substitute Tcl_GetStringFromObj() in Tcl version 8.0.X
  491. */
  492. #if ET_HAVE_OBJ && TCL_MINOR_VERSION==0
  493. # define Tcl_GetByteArrayFromObj Tcl_GetStringFromObj
  494. #endif
  495.  
  496. /*
  497. ** Tcl code to implement the console.
  498. **
  499. ** This code is written and tested separately, then run through
  500. ** "mktclapp -stringify" and then pasted in here.
  501. */
  502. #if ET_ENABLE_TK && !ET_EXTENSION
  503. static char zEtConsole[] =
  504. "proc console:create {w prompt title} {\n"
  505. "upvar #0 $w.t v\n"
  506. "if {[winfo exists $w]} {destroy $w}\n"
  507. "catch {unset v}\n"
  508. "toplevel $w\n"
  509. "wm title $w $title\n"
  510. "wm iconname $w $title\n"
  511. "frame $w.mb -bd 2 -relief raised\n"
  512. "pack $w.mb -side top -fill x\n"
  513. "menubutton $w.mb.file -text File -menu $w.mb.file.m\n"
  514. "menubutton $w.mb.edit -text Edit -menu $w.mb.edit.m\n"
  515. "pack $w.mb.file $w.mb.edit -side left -padx 8 -pady 1\n"
  516. "set m [menu $w.mb.file.m]\n"
  517. "$m add command -label {Source...} -command \"console:SourceFile $w.t\"\n"
  518. "$m add command -label {Save As...} -command \"console:SaveFile $w.t\"\n"
  519. "$m add separator\n"
  520. "$m add command -label {Close} -command \"destroy $w\"\n"
  521. "$m add command -label {Exit} -command exit\n"
  522. "set m [menu $w.mb.edit.m]\n"
  523. "$m add command -label Cut -command \"console:Cut $w.t\"\n"
  524. "$m add command -label Copy -command \"console:Copy $w.t\"\n"
  525. "$m add command -label Paste -command \"console:Paste $w.t\"\n"
  526. "$m add command -label {Clear Screen} -command \"console:Clear $w.t\"\n"
  527. "catch {$m config -postcommand \"console:EnableEditMenu $w\"}\n"
  528. "scrollbar $w.sb -orient vertical -command \"$w.t yview\"\n"
  529. "pack $w.sb -side right -fill y\n"
  530. "text $w.t -font fixed -yscrollcommand \"$w.sb set\"\n"
  531. "pack $w.t -side right -fill both -expand 1\n"
  532. "bindtags $w.t Console\n"
  533. "set v(text) $w.t\n"
  534. "set v(history) 0\n"
  535. "set v(historycnt) 0\n"
  536. "set v(current) -1\n"
  537. "set v(prompt) $prompt\n"
  538. "set v(prior) {}\n"
  539. "set v(plength) [string length $v(prompt)]\n"
  540. "set v(x) 0\n"
  541. "set v(y) 0\n"
  542. "$w.t mark set insert end\n"
  543. "$w.t tag config ok -foreground blue\n"
  544. "$w.t tag config err -foreground red\n"
  545. "$w.t insert end $v(prompt)\n"
  546. "$w.t mark set out 1.0\n"
  547. "catch {rename puts console:oldputs$w}\n"
  548. "proc puts args [format {\n"
  549. "if {![winfo exists %s]} {\n"
  550. "rename puts {}\n"
  551. "rename console:oldputs%s puts\n"
  552. "return [uplevel #0 puts $args]\n"
  553. "}\n"
  554. "switch -glob -- \"[llength $args] $args\" {\n"
  555. "{1 *} {\n"
  556. "set msg [lindex $args 0]\\n\n"
  557. "set tag ok\n"
  558. "}\n"
  559. "{2 stdout *} {\n"
  560. "set msg [lindex $args 1]\\n\n"
  561. "set tag ok\n"
  562. "}\n"
  563. "{2 stderr *} {\n"
  564. "set msg [lindex $args 1]\\n\n"
  565. "set tag err\n"
  566. "}\n"
  567. "{2 -nonewline *} {\n"
  568. "set msg [lindex $args 1]\n"
  569. "set tag ok\n"
  570. "}\n"
  571. "{3 -nonewline stdout *} {\n"
  572. "set msg [lindex $args 2]\n"
  573. "set tag ok\n"
  574. "}\n"
  575. "{3 -nonewline stderr *} {\n"
  576. "set msg [lindex $args 2]\n"
  577. "set tag err\n"
  578. "}\n"
  579. "default {\n"
  580. "uplevel #0 console:oldputs%s $args\n"
  581. "return\n"
  582. "}\n"
  583. "}\n"
  584. "console:Puts %s $msg $tag\n"
  585. "} $w $w $w $w.t]\n"
  586. "after idle \"focus $w.t\"\n"
  587. "}\n"
  588. "bind Console <1> {console:Button1 %W %x %y}\n"
  589. "bind Console <B1-Motion> {console:B1Motion %W %x %y}\n"
  590. "bind Console <B1-Leave> {console:B1Leave %W %x %y}\n"
  591. "bind Console <B1-Enter> {console:cancelMotor %W}\n"
  592. "bind Console <ButtonRelease-1> {console:cancelMotor %W}\n"
  593. "bind Console <KeyPress> {console:Insert %W %A}\n"
  594. "bind Console <Left> {console:Left %W}\n"
  595. "bind Console <Control-b> {console:Left %W}\n"
  596. "bind Console <Right> {console:Right %W}\n"
  597. "bind Console <Control-f> {console:Right %W}\n"
  598. "bind Console <BackSpace> {console:Backspace %W}\n"
  599. "bind Console <Control-h> {console:Backspace %W}\n"
  600. "bind Console <Delete> {console:Delete %W}\n"
  601. "bind Console <Control-d> {console:Delete %W}\n"
  602. "bind Console <Home> {console:Home %W}\n"
  603. "bind Console <Control-a> {console:Home %W}\n"
  604. "bind Console <End> {console:End %W}\n"
  605. "bind Console <Control-e> {console:End %W}\n"
  606. "bind Console <Return> {console:Enter %W}\n"
  607. "bind Console <KP_Enter> {console:Enter %W}\n"
  608. "bind Console <Up> {console:Prior %W}\n"
  609. "bind Console <Control-p> {console:Prior %W}\n"
  610. "bind Console <Down> {console:Next %W}\n"
  611. "bind Console <Control-n> {console:Next %W}\n"
  612. "bind Console <Control-k> {console:EraseEOL %W}\n"
  613. "bind Console <<Cut>> {console:Cut %W}\n"
  614. "bind Console <<Copy>> {console:Copy %W}\n"
  615. "bind Console <<Paste>> {console:Paste %W}\n"
  616. "bind Console <<Clear>> {console:Clear %W}\n"
  617. "proc console:Puts {w t tag} {\n"
  618. "set nc [string length $t]\n"
  619. "set endc [string index $t [expr $nc-1]]\n"
  620. "if {$endc==\"\\n\"} {\n"
  621. "if {[$w index out]<[$w index {insert linestart}]} {\n"
  622. "$w insert out [string range $t 0 [expr $nc-2]] $tag\n"
  623. "$w mark set out {out linestart +1 lines}\n"
  624. "} else {\n"
  625. "$w insert out $t $tag\n"
  626. "}\n"
  627. "} else {\n"
  628. "if {[$w index out]<[$w index {insert linestart}]} {\n"
  629. "$w insert out $t $tag\n"
  630. "} else {\n"
  631. "$w insert out $t\\n $tag\n"
  632. "$w mark set out {out -1 char}\n"
  633. "}\n"
  634. "}\n"
  635. "$w yview insert\n"
  636. "}\n"
  637. "proc console:Insert {w a} {\n"
  638. "$w insert insert $a\n"
  639. "$w yview insert\n"
  640. "}\n"
  641. "proc console:Left {w} {\n"
  642. "upvar #0 $w v\n"
  643. "scan [$w index insert] %d.%d row col\n"
  644. "if {$col>$v(plength)} {\n"
  645. "$w mark set insert \"insert -1c\"\n"
  646. "}\n"
  647. "}\n"
  648. "proc console:Backspace {w} {\n"
  649. "upvar #0 $w v\n"
  650. "scan [$w index insert] %d.%d row col\n"
  651. "if {$col>$v(plength)} {\n"
  652. "$w delete {insert -1c}\n"
  653. "}\n"
  654. "}\n"
  655. "proc console:EraseEOL {w} {\n"
  656. "upvar #0 $w v\n"
  657. "scan [$w index insert] %d.%d row col\n"
  658. "if {$col>=$v(plength)} {\n"
  659. "$w delete insert {insert lineend}\n"
  660. "}\n"
  661. "}\n"
  662. "proc console:Right {w} {\n"
  663. "$w mark set insert \"insert +1c\"\n"
  664. "}\n"
  665. "proc console:Delete w {\n"
  666. "$w delete insert\n"
  667. "}\n"
  668. "proc console:Home w {\n"
  669. "upvar #0 $w v\n"
  670. "scan [$w index insert] %d.%d row col\n"
  671. "$w mark set insert $row.$v(plength)\n"
  672. "}\n"
  673. "proc console:End w {\n"
  674. "$w mark set insert {insert lineend}\n"
  675. "}\n"
  676. "proc console:Enter w {\n"
  677. "upvar #0 $w v\n"
  678. "scan [$w index insert] %d.%d row col\n"
  679. "set start $row.$v(plength)\n"
  680. "set line [$w get $start \"$start lineend\"]\n"
  681. "if {$v(historycnt)>0} {\n"
  682. "set last [lindex $v(history) [expr $v(historycnt)-1]]\n"
  683. "if {[string compare $last $line]} {\n"
  684. "lappend v(history) $line\n"
  685. "incr v(historycnt)\n"
  686. "}\n"
  687. "} else {\n"
  688. "set v(history) [list $line]\n"
  689. "set v(historycnt) 1\n"
  690. "}\n"
  691. "set v(current) $v(historycnt)\n"
  692. "$w insert end \\n\n"
  693. "$w mark set out end\n"
  694. "if {$v(prior)==\"\"} {\n"
  695. "set cmd $line\n"
  696. "} else {\n"
  697. "set cmd $v(prior)\\n$line\n"
  698. "}\n"
  699. "if {[info complete $cmd]} {\n"
  700. "set rc [catch {uplevel #0 $cmd} res]\n"
  701. "if {![winfo exists $w]} return\n"
  702. "if {$rc} {\n"
  703. "$w insert end $res\\n err\n"
  704. "} elseif {[string length $res]>0} {\n"
  705. "$w insert end $res\\n ok\n"
  706. "}\n"
  707. "set v(prior) {}\n"
  708. "$w insert end $v(prompt)\n"
  709. "} else {\n"
  710. "set v(prior) $cmd\n"
  711. "regsub -all {[^ ]} $v(prompt) . x\n"
  712. "$w insert end $x\n"
  713. "}\n"
  714. "$w mark set insert end\n"
  715. "$w mark set out {insert linestart}\n"
  716. "$w yview insert\n"
  717. "}\n"
  718. "proc console:Prior w {\n"
  719. "upvar #0 $w v\n"
  720. "if {$v(current)<=0} return\n"
  721. "incr v(current) -1\n"
  722. "set line [lindex $v(history) $v(current)]\n"
  723. "console:SetLine $w $line\n"
  724. "}\n"
  725. "proc console:Next w {\n"
  726. "upvar #0 $w v\n"
  727. "if {$v(current)>=$v(historycnt)} return\n"
  728. "incr v(current) 1\n"
  729. "set line [lindex $v(history) $v(current)]\n"
  730. "console:SetLine $w $line\n"
  731. "}\n"
  732. "proc console:SetLine {w line} {\n"
  733. "upvar #0 $w v\n"
  734. "scan [$w index insert] %d.%d row col\n"
  735. "set start $row.$v(plength)\n"
  736. "$w delete $start end\n"
  737. "$w insert end $line\n"
  738. "$w mark set insert end\n"
  739. "$w yview insert\n"
  740. "}\n"
  741. "proc console:Button1 {w x y} {\n"
  742. "global tkPriv\n"
  743. "upvar #0 $w v\n"
  744. "set v(mouseMoved) 0\n"
  745. "set v(pressX) $x\n"
  746. "set p [console:nearestBoundry $w $x $y]\n"
  747. "scan [$w index insert] %d.%d ix iy\n"
  748. "scan $p %d.%d px py\n"
  749. "if {$px==$ix} {\n"
  750. "$w mark set insert $p\n"
  751. "}\n"
  752. "$w mark set anchor $p\n"
  753. "focus $w\n"
  754. "}\n"
  755. "proc console:nearestBoundry {w x y} {\n"
  756. "set p [$w index @$x,$y]\n"
  757. "set bb [$w bbox $p]\n"
  758. "if {![string compare $bb \"\"]} {return $p}\n"
  759. "if {($x-[lindex $bb 0])<([lindex $bb 2]/2)} {return $p}\n"
  760. "$w index \"$p + 1 char\"\n"
  761. "}\n"
  762. "proc console:SelectTo {w x y} {\n"
  763. "upvar #0 $w v\n"
  764. "set cur [console:nearestBoundry $w $x $y]\n"
  765. "if {[catch {$w index anchor}]} {\n"
  766. "$w mark set anchor $cur\n"
  767. "}\n"
  768. "set anchor [$w index anchor]\n"
  769. "if {[$w compare $cur != $anchor] || (abs($v(pressX) - $x) >= 3)} {\n"
  770. "if {$v(mouseMoved)==0} {\n"
  771. "$w tag remove sel 0.0 end\n"
  772. "}\n"
  773. "set v(mouseMoved) 1\n"
  774. "}\n"
  775. "if {[$w compare $cur < anchor]} {\n"
  776. "set first $cur\n"
  777. "set last anchor\n"
  778. "} else {\n"
  779. "set first anchor\n"
  780. "set last $cur\n"
  781. "}\n"
  782. "if {$v(mouseMoved)} {\n"
  783. "$w tag remove sel 0.0 $first\n"
  784. "$w tag add sel $first $last\n"
  785. "$w tag remove sel $last end\n"
  786. "update idletasks\n"
  787. "}\n"
  788. "}\n"
  789. "proc console:B1Motion {w x y} {\n"
  790. "upvar #0 $w v\n"
  791. "set v(y) $y\n"
  792. "set v(x) $x\n"
  793. "console:SelectTo $w $x $y\n"
  794. "}\n"
  795. "proc console:B1Leave {w x y} {\n"
  796. "upvar #0 $w v\n"
  797. "set v(y) $y\n"
  798. "set v(x) $x\n"
  799. "console:motor $w\n"
  800. "}\n"
  801. "proc console:motor w {\n"
  802. "upvar #0 $w v\n"
  803. "if {![winfo exists $w]} return\n"
  804. "if {$v(y)>=[winfo height $w]} {\n"
  805. "$w yview scroll 1 units\n"
  806. "} elseif {$v(y)<0} {\n"
  807. "$w yview scroll -1 units\n"
  808. "} else {\n"
  809. "return\n"
  810. "}\n"
  811. "console:SelectTo $w $v(x) $v(y)\n"
  812. "set v(timer) [after 50 console:motor $w]\n"
  813. "}\n"
  814. "proc console:cancelMotor w {\n"
  815. "upvar #0 $w v\n"
  816. "catch {after cancel $v(timer)}\n"
  817. "catch {unset v(timer)}\n"
  818. "}\n"
  819. "proc console:Copy w {\n"
  820. "if {![catch {set text [$w get sel.first sel.last]}]} {\n"
  821. "clipboard clear -displayof $w\n"
  822. "clipboard append -displayof $w $text\n"
  823. "}\n"
  824. "}\n"
  825. "proc console:canCut w {\n"
  826. "set r [catch {\n"
  827. "scan [$w index sel.first] %d.%d s1x s1y\n"
  828. "scan [$w index sel.last] %d.%d s2x s2y\n"
  829. "scan [$w index insert] %d.%d ix iy\n"
  830. "}]\n"
  831. "if {$r==1} {return 0}\n"
  832. "if {$s1x==$ix && $s2x==$ix} {return 1}\n"
  833. "return 2\n"
  834. "}\n"
  835. "proc console:Cut w {\n"
  836. "if {[console:canCut $w]==1} {\n"
  837. "console:Copy $w\n"
  838. "$w delete sel.first sel.last\n"
  839. "}\n"
  840. "}\n"
  841. "proc console:Paste w {\n"
  842. "if {[console:canCut $w]==1} {\n"
  843. "$w delete sel.first sel.last\n"
  844. "}\n"
  845. "if {[catch {selection get -displayof $w -selection CLIPBOARD} topaste]} {\n"
  846. "return\n"
  847. "}\n"
  848. "set prior 0\n"
  849. "foreach line [split $topaste \\n] {\n"
  850. "if {$prior} {\n"
  851. "console:Enter $w\n"
  852. "update\n"
  853. "}\n"
  854. "set prior 1\n"
  855. "$w insert insert $line\n"
  856. "}\n"
  857. "}\n"
  858. "proc console:EnableEditMenu w {\n"
  859. "set m $w.mb.edit.m\n"
  860. "switch [console:canCut $w.t] {\n"
  861. "0 {\n"
  862. "$m entryconf Copy -state disabled\n"
  863. "$m entryconf Cut -state disabled\n"
  864. "}\n"
  865. "1 {\n"
  866. "$m entryconf Copy -state normal\n"
  867. "$m entryconf Cut -state normal\n"
  868. "}\n"
  869. "2 {\n"
  870. "$m entryconf Copy -state normal\n"
  871. "$m entryconf Cut -state disabled\n"
  872. "}\n"
  873. "}\n"
  874. "}\n"
  875. "proc console:SourceFile w {\n"
  876. "set types {\n"
  877. "{{TCL Scripts}  {.tcl}}\n"
  878. "{{All Files}    *}\n"
  879. "}\n"
  880. "set f [tk_getOpenFile -filetypes $types -title \"TCL Script To Source...\"]\n"
  881. "if {$f!=\"\"} {\n"
  882. "uplevel #0 source $f\n"
  883. "}\n"
  884. "}\n"
  885. "proc console:SaveFile w {\n"
  886. "set types {\n"
  887. "{{Text Files}  {.txt}}\n"
  888. "{{All Files}    *}\n"
  889. "}\n"
  890. "set f [tk_getSaveFile -filetypes $types -title \"Write Screen To...\"]\n"
  891. "if {$f!=\"\"} {\n"
  892. "if {[catch {open $f w} fd]} {\n"
  893. "tk_messageBox -type ok -icon error -message $fd\n"
  894. "} else {\n"
  895. "puts $fd [string trimright [$w get 1.0 end] \\n]\n"
  896. "close $fd\n"
  897. "}\n"
  898. "}\n"
  899. "}\n"
  900. "proc console:Clear w {\n"
  901. "$w delete 1.0 {insert linestart}\n"
  902. "}\n"
  903. ;  /* End of the console code */
  904. #endif /* ET_ENABLE_TK */
  905.  
  906. /*
  907. ** The "printf" code that follows dates from the 1980's.  It is in
  908. ** the public domain.  The original comments are included here for
  909. ** completeness.  They are slightly out-of-date.
  910. **
  911. ** The following modules is an enhanced replacement for the "printf" programs
  912. ** found in the standard library.  The following enhancements are
  913. ** supported:
  914. **
  915. **      +  Additional functions.  The standard set of "printf" functions
  916. **         includes printf, fprintf, sprintf, vprintf, vfprintf, and
  917. **         vsprintf.  This module adds the following:
  918. **
  919. **           *  snprintf -- Works like sprintf, but has an extra argument
  920. **                          which is the size of the buffer written to.
  921. **
  922. **           *  mprintf --  Similar to sprintf.  Writes output to memory
  923. **                          obtained from malloc.
  924. **
  925. **           *  xprintf --  Calls a function to dispose of output.
  926. **
  927. **           *  nprintf --  No output, but returns the number of characters
  928. **                          that would have been output by printf.
  929. **
  930. **           *  A v- version (ex: vsnprintf) of every function is also
  931. **              supplied.
  932. **
  933. **      +  A few extensions to the formatting notation are supported:
  934. **
  935. **           *  The "=" flag (similar to "-") causes the output to be
  936. **              be centered in the appropriately sized field.
  937. **
  938. **           *  The %b field outputs an integer in binary notation.
  939. **
  940. **           *  The %c field now accepts a precision.  The character output
  941. **              is repeated by the number of times the precision specifies.
  942. **
  943. **           *  The %' field works like %c, but takes as its character the
  944. **              next character of the format string, instead of the next
  945. **              argument.  For example,  printf("%.78'-")  prints 78 minus
  946. **              signs, the same as  printf("%.78c",'-').
  947. **
  948. **      +  When compiled using GCC on a SPARC, this version of printf is
  949. **         faster than the library printf for SUN OS 4.1.
  950. **
  951. **      +  All functions are fully reentrant.
  952. **
  953. */
  954. /*
  955. ** Undefine COMPATIBILITY to make some slight changes in the way things
  956. ** work.  I think the changes are an improvement, but they are not
  957. ** backwards compatible.
  958. */
  959. /* #define COMPATIBILITY       / * Compatible with SUN OS 4.1 */
  960.  
  961. /*
  962. ** Characters that need to be escaped inside a TCL string.
  963. */
  964. static char NeedEsc[] = {
  965.   1,   1,   1,   1,   1,   1,   1,   1, 'b', 't', 'n',   1, 'f', 'r',   1,   1,
  966.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  967.   0,   0, '"',   0, '$',   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  968.   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  969.   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  970.   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, '[','\\', ']',   0,   0,
  971.   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  972.   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   1,   0,   1,   0,   1,
  973.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  974.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  975.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  976.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  977.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  978.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  979.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  980.   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  981. };
  982.  
  983. /*
  984. ** Conversion types fall into various categories as defined by the
  985. ** following enumeration.
  986. */
  987. enum et_type {    /* The type of the format field */
  988.    etRADIX,            /* Integer types.  %d, %x, %o, and so forth */
  989.    etFLOAT,            /* Floating point.  %f */
  990.    etEXP,              /* Exponentional notation. %e and %E */
  991.    etGENERIC,          /* Floating or exponential, depending on exponent. %g */
  992.    etSIZE,             /* Return number of characters processed so far. %n */
  993.    etSTRING,           /* Strings. %s */
  994.    etPERCENT,          /* Percent symbol. %% */
  995.    etCHARX,            /* Characters. %c */
  996.    etERROR,            /* Used to indicate no such conversion type */
  997. /* The rest are extensions, not normally found in printf() */
  998.    etCHARLIT,          /* Literal characters.  %' */
  999.    etTCLESCAPE,        /* Strings with special characters escaped.  %q */
  1000.    etMEMSTRING,        /* A string which should be deleted after use. %z */
  1001.    etORDINAL           /* 1st, 2nd, 3rd and so forth */
  1002. };
  1003.  
  1004. /*
  1005. ** Each builtin conversion character (ex: the 'd' in "%d") is described
  1006. ** by an instance of the following structure
  1007. */
  1008. typedef struct et_info {   /* Information about each format field */
  1009.   int  fmttype;              /* The format field code letter */
  1010.   int  base;                 /* The base for radix conversion */
  1011.   char *charset;             /* The character set for conversion */
  1012.   int  flag_signed;          /* Is the quantity signed? */
  1013.   char *prefix;              /* Prefix on non-zero values in alt format */
  1014.   enum et_type type;          /* Conversion paradigm */
  1015. } et_info;
  1016.  
  1017. /*
  1018. ** The following table is searched linearly, so it is good to put the
  1019. ** most frequently used conversion types first.
  1020. */
  1021. static et_info fmtinfo[] = {
  1022.   { 'd',  10,  "0123456789",       1,    0, etRADIX,      },
  1023.   { 's',   0,  0,                  0,    0, etSTRING,     },
  1024.   { 'q',   0,  0,                  0,    0, etTCLESCAPE,  },
  1025.   { 'z',   0,  0,                  0,    0, etMEMSTRING, },
  1026.   { 'c',   0,  0,                  0,    0, etCHARX,      },
  1027.   { 'o',   8,  "01234567",         0,  "0", etRADIX,      },
  1028.   { 'u',  10,  "0123456789",       0,    0, etRADIX,      },
  1029.   { 'x',  16,  "0123456789abcdef", 0, "x0", etRADIX,      },
  1030.   { 'X',  16,  "0123456789ABCDEF", 0, "X0", etRADIX,      },
  1031.   { 'r',  10,  "0123456789",       0,    0, etORDINAL,    },
  1032.   { 'f',   0,  0,                  1,    0, etFLOAT,      },
  1033.   { 'e',   0,  "e",                1,    0, etEXP,        },
  1034.   { 'E',   0,  "E",                1,    0, etEXP,        },
  1035.   { 'g',   0,  "e",                1,    0, etGENERIC,    },
  1036.   { 'G',   0,  "E",                1,    0, etGENERIC,    },
  1037.   { 'i',  10,  "0123456789",       1,    0, etRADIX,      },
  1038.   { 'n',   0,  0,                  0,    0, etSIZE,       },
  1039.   { '%',   0,  0,                  0,    0, etPERCENT,    },
  1040.   { 'b',   2,  "01",               0, "b0", etRADIX,      }, /* Binary */
  1041.   { 'p',  10,  "0123456789",       0,    0, etRADIX,      }, /* Pointers */
  1042.   { '\'',  0,  0,                  0,    0, etCHARLIT,    }, /* Literal char */
  1043. };
  1044. #define etNINFO  (sizeof(fmtinfo)/sizeof(fmtinfo[0]))
  1045.  
  1046. /*
  1047. ** If NOFLOATINGPOINT is defined, then none of the floating point
  1048. ** conversions will work.
  1049. */
  1050. #ifndef etNOFLOATINGPOINT
  1051. /*
  1052. ** "*val" is a double such that 0.1 <= *val < 10.0
  1053. ** Return the ascii code for the leading digit of *val, then
  1054. ** multiply "*val" by 10.0 to renormalize.
  1055. **
  1056. ** Example:
  1057. **     input:     *val = 3.14159
  1058. **     output:    *val = 1.4159    function return = '3'
  1059. **
  1060. ** The counter *cnt is incremented each time.  After counter exceeds
  1061. ** 16 (the number of significant digits in a 64-bit float) '0' is
  1062. ** always returned.
  1063. */
  1064. static int et_getdigit(double *val, int *cnt){
  1065.   int digit;
  1066.   double d;
  1067.   if( (*cnt)++ >= 16 ) return '0';
  1068.   digit = (int)*val;
  1069.   d = digit;
  1070.   digit += '0';
  1071.   *val = (*val - d)*10.0;
  1072.   return digit;
  1073. }
  1074. #endif
  1075.  
  1076. #define etBUFSIZE 1000  /* Size of the output buffer */
  1077.  
  1078. /*
  1079. ** The root program.  All variations call this core.
  1080. **
  1081. ** INPUTS:
  1082. **   func   This is a pointer to a function taking three arguments
  1083. **            1. A pointer to anything.  Same as the "arg" parameter.
  1084. **            2. A pointer to the list of characters to be output
  1085. **               (Note, this list is NOT null terminated.)
  1086. **            3. An integer number of characters to be output.
  1087. **               (Note: This number might be zero.)
  1088. **
  1089. **   arg    This is the pointer to anything which will be passed as the
  1090. **          first argument to "func".  Use it for whatever you like.
  1091. **
  1092. **   fmt    This is the format string, as in the usual print.
  1093. **
  1094. **   ap     This is a pointer to a list of arguments.  Same as in
  1095. **          vfprint.
  1096. **
  1097. ** OUTPUTS:
  1098. **          The return value is the total number of characters sent to
  1099. **          the function "func".  Returns -1 on a error.
  1100. **
  1101. ** Note that the order in which automatic variables are declared below
  1102. ** seems to make a big difference in determining how fast this beast
  1103. ** will run.
  1104. */
  1105. int vxprintf(
  1106.   void (*func)(void*,char*,int),
  1107.   void *arg,
  1108.   const char *format,
  1109.   va_list ap
  1110. ){
  1111.   register const char *fmt; /* The format string. */
  1112.   register int c;           /* Next character in the format string */
  1113.   register char *bufpt;     /* Pointer to the conversion buffer */
  1114.   register int  precision;  /* Precision of the current field */
  1115.   register int  length;     /* Length of the field */
  1116.   register int  idx;        /* A general purpose loop counter */
  1117.   int count;                /* Total number of characters output */
  1118.   int width;                /* Width of the current field */
  1119.   int flag_leftjustify;     /* True if "-" flag is present */
  1120.   int flag_plussign;        /* True if "+" flag is present */
  1121.   int flag_blanksign;       /* True if " " flag is present */
  1122.   int flag_alternateform;   /* True if "#" flag is present */
  1123.   int flag_zeropad;         /* True if field width constant starts with zero */
  1124.   int flag_long;            /* True if "l" flag is present */
  1125.   int flag_center;          /* True if "=" flag is present */
  1126.   unsigned long longvalue;  /* Value for integer types */
  1127.   double realvalue;         /* Value for real types */
  1128.   et_info *infop;           /* Pointer to the appropriate info structure */
  1129.   char buf[etBUFSIZE];      /* Conversion buffer */
  1130.   char prefix;              /* Prefix character.  "+" or "-" or " " or '\0'. */
  1131.   int  errorflag = 0;       /* True if an error is encountered */
  1132.   enum et_type xtype;       /* Conversion paradigm */
  1133.   char *zMem;               /* String to be freed */
  1134.   char *zExtra;             /* Extra memory used for etTCLESCAPE conversions */
  1135.   static char spaces[] = "                                                  "
  1136.      "                                                                      ";
  1137. #define etSPACESIZE (sizeof(spaces)-1)
  1138. #ifndef etNOFLOATINGPOINT
  1139.   int  exp;                 /* exponent of real numbers */
  1140.   double rounder;           /* Used for rounding floating point values */
  1141.   int flag_dp;              /* True if decimal point should be shown */
  1142.   int flag_rtz;             /* True if trailing zeros should be removed */
  1143.   int flag_exp;             /* True to force display of the exponent */
  1144.   int nsd;                  /* Number of significant digits returned */
  1145. #endif
  1146.  
  1147.   fmt = format;                     /* Put in a register for speed */
  1148.   count = length = 0;
  1149.   bufpt = 0;
  1150.   for(; (c=(*fmt))!=0; ++fmt){
  1151.     if( c!='%' ){
  1152.       register int amt;
  1153.       bufpt = (char *)fmt;
  1154.       amt = 1;
  1155.       while( (c=(*++fmt))!='%' && c!=0 ) amt++;
  1156.       (*func)(arg,bufpt,amt);
  1157.       count += amt;
  1158.       if( c==0 ) break;
  1159.     }
  1160.     if( (c=(*++fmt))==0 ){
  1161.       errorflag = 1;
  1162.       (*func)(arg,"%",1);
  1163.       count++;
  1164.       break;
  1165.     }
  1166.     /* Find out what flags are present */
  1167.     flag_leftjustify = flag_plussign = flag_blanksign =
  1168.      flag_alternateform = flag_zeropad = flag_center = 0;
  1169.     do{
  1170.       switch( c ){
  1171.         case '-':   flag_leftjustify = 1;     c = 0;   break;
  1172.         case '+':   flag_plussign = 1;        c = 0;   break;
  1173.         case ' ':   flag_blanksign = 1;       c = 0;   break;
  1174.         case '#':   flag_alternateform = 1;   c = 0;   break;
  1175.         case '0':   flag_zeropad = 1;         c = 0;   break;
  1176.         case '=':   flag_center = 1;          c = 0;   break;
  1177.         default:                                       break;
  1178.       }
  1179.     }while( c==0 && (c=(*++fmt))!=0 );
  1180.     if( flag_center ) flag_leftjustify = 0;
  1181.     /* Get the field width */
  1182.     width = 0;
  1183.     if( c=='*' ){
  1184.       width = va_arg(ap,int);
  1185.       if( width<0 ){
  1186.         flag_leftjustify = 1;
  1187.         width = -width;
  1188.       }
  1189.       c = *++fmt;
  1190.     }else{
  1191.       while( isdigit(c) ){
  1192.         width = width*10 + c - '0';
  1193.         c = *++fmt;
  1194.       }
  1195.     }
  1196.     if( width > etBUFSIZE-10 ){
  1197.       width = etBUFSIZE-10;
  1198.     }
  1199.     /* Get the precision */
  1200.     if( c=='.' ){
  1201.       precision = 0;
  1202.       c = *++fmt;
  1203.       if( c=='*' ){
  1204.         precision = va_arg(ap,int);
  1205. #ifndef etCOMPATIBILITY
  1206.         /* This is sensible, but SUN OS 4.1 doesn't do it. */
  1207.         if( precision<0 ) precision = -precision;
  1208. #endif
  1209.         c = *++fmt;
  1210.       }else{
  1211.         while( isdigit(c) ){
  1212.           precision = precision*10 + c - '0';
  1213.           c = *++fmt;
  1214.         }
  1215.       }
  1216.       /* Limit the precision to prevent overflowing buf[] during conversion */
  1217.       if( precision>etBUFSIZE-40 ) precision = etBUFSIZE-40;
  1218.     }else{
  1219.       precision = -1;
  1220.     }
  1221.     /* Get the conversion type modifier */
  1222.     if( c=='l' ){
  1223.       flag_long = 1;
  1224.       c = *++fmt;
  1225.     }else{
  1226.       flag_long = 0;
  1227.     }
  1228.     /* Fetch the info entry for the field */
  1229.     infop = 0;
  1230.     for(idx=0; idx<etNINFO; idx++){
  1231.       if( c==fmtinfo[idx].fmttype ){
  1232.         infop = &fmtinfo[idx];
  1233.         break;
  1234.       }
  1235.     }
  1236.     /* No info entry found.  It must be an error. */
  1237.     if( infop==0 ){
  1238.       xtype = etERROR;
  1239.     }else{
  1240.       xtype = infop->type;
  1241.     }
  1242.     zExtra = 0;
  1243.  
  1244.     /*
  1245.     ** At this point, variables are initialized as follows:
  1246.     **
  1247.     **   flag_alternateform          TRUE if a '#' is present.
  1248.     **   flag_plussign               TRUE if a '+' is present.
  1249.     **   flag_leftjustify            TRUE if a '-' is present or if the
  1250.     **                               field width was negative.
  1251.     **   flag_zeropad                TRUE if the width began with 0.
  1252.     **   flag_long                   TRUE if the letter 'l' (ell) prefixed
  1253.     **                               the conversion character.
  1254.     **   flag_blanksign              TRUE if a ' ' is present.
  1255.     **   width                       The specified field width.  This is
  1256.     **                               always non-negative.  Zero is the default.
  1257.     **   precision                   The specified precision.  The default
  1258.     **                               is -1.
  1259.     **   xtype                       The class of the conversion.
  1260.     **   infop                       Pointer to the appropriate info struct.
  1261.     */
  1262.     switch( xtype ){
  1263.       case etORDINAL:
  1264.       case etRADIX:
  1265.         if( flag_long )  longvalue = va_arg(ap,long);
  1266.         else             longvalue = va_arg(ap,int);
  1267. #ifdef etCOMPATIBILITY
  1268.         /* For the format %#x, the value zero is printed "0" not "0x0".
  1269.         ** I think this is stupid. */
  1270.         if( longvalue==0 ) flag_alternateform = 0;
  1271. #else
  1272.         /* More sensible: turn off the prefix for octal (to prevent "00"),
  1273.         ** but leave the prefix for hex. */
  1274.         if( longvalue==0 && infop->base==8 ) flag_alternateform = 0;
  1275. #endif
  1276.         if( infop->flag_signed ){
  1277.           if( *(long*)&longvalue<0 ){
  1278.             longvalue = -*(long*)&longvalue;
  1279.             prefix = '-';
  1280.           }else if( flag_plussign )  prefix = '+';
  1281.           else if( flag_blanksign )  prefix = ' ';
  1282.           else                       prefix = 0;
  1283.         }else                        prefix = 0;
  1284.         if( flag_zeropad && precision<width-(prefix!=0) ){
  1285.           precision = width-(prefix!=0);
  1286.         }
  1287.         bufpt = &buf[etBUFSIZE];
  1288.         if( xtype==etORDINAL ){
  1289.           long a,b;
  1290.           a = longvalue%10;
  1291.           b = longvalue%100;
  1292.           bufpt -= 2;
  1293.           if( a==0 || a>3 || (b>10 && b<14) ){
  1294.             bufpt[0] = 't';
  1295.             bufpt[1] = 'h';
  1296.           }else if( a==1 ){
  1297.             bufpt[0] = 's';
  1298.             bufpt[1] = 't';
  1299.           }else if( a==2 ){
  1300.             bufpt[0] = 'n';
  1301.             bufpt[1] = 'd';
  1302.           }else if( a==3 ){
  1303.             bufpt[0] = 'r';
  1304.             bufpt[1] = 'd';
  1305.           }
  1306.         }
  1307.         {
  1308.           register char *cset;      /* Use registers for speed */
  1309.           register int base;
  1310.           cset = infop->charset;
  1311.           base = infop->base;
  1312.           do{                                           /* Convert to ascii */
  1313.             *(--bufpt) = cset[longvalue%base];
  1314.             longvalue = longvalue/base;
  1315.           }while( longvalue>0 );
  1316.         }
  1317.         length = (long)&buf[etBUFSIZE]-(long)bufpt;
  1318.         for(idx=precision-length; idx>0; idx--){
  1319.           *(--bufpt) = '0';                             /* Zero pad */
  1320.         }
  1321.         if( prefix ) *(--bufpt) = prefix;               /* Add sign */
  1322.         if( flag_alternateform && infop->prefix ){      /* Add "0" or "0x" */
  1323.           char *pre, x;
  1324.           pre = infop->prefix;
  1325.           if( *bufpt!=pre[0] ){
  1326.             for(pre=infop->prefix; (x=(*pre))!=0; pre++) *(--bufpt) = x;
  1327.           }
  1328.         }
  1329.         length = (long)&buf[etBUFSIZE]-(long)bufpt;
  1330.         break;
  1331.       case etFLOAT:
  1332.       case etEXP:
  1333.       case etGENERIC:
  1334.         realvalue = va_arg(ap,double);
  1335. #ifndef etNOFLOATINGPOINT
  1336.         if( precision<0 ) precision = 6;         /* Set default precision */
  1337.         if( precision>etBUFSIZE-10 ) precision = etBUFSIZE-10;
  1338.         if( realvalue<0.0 ){
  1339.           realvalue = -realvalue;
  1340.           prefix = '-';
  1341.         }else{
  1342.           if( flag_plussign )          prefix = '+';
  1343.           else if( flag_blanksign )    prefix = ' ';
  1344.           else                         prefix = 0;
  1345.         }
  1346.         if( infop->type==etGENERIC && precision>0 ) precision--;
  1347.         rounder = 0.0;
  1348. #ifdef COMPATIBILITY
  1349.         /* Rounding works like BSD when the constant 0.4999 is used.  Wierd! */
  1350.         for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1);
  1351. #else
  1352.         /* It makes more sense to use 0.5 */
  1353.         for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1);
  1354. #endif
  1355.         if( infop->type==etFLOAT ) realvalue += rounder;
  1356.         /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
  1357.         exp = 0;
  1358.         if( realvalue>0.0 ){
  1359.           int k = 0;
  1360.           while( realvalue>=1e8 && k++<100 ){ realvalue *= 1e-8; exp+=8; }
  1361.           while( realvalue>=10.0 && k++<100 ){ realvalue *= 0.1; exp++; }
  1362.           while( realvalue<1e-8 && k++<100 ){ realvalue *= 1e8; exp-=8; }
  1363.           while( realvalue<1.0 && k++<100 ){ realvalue *= 10.0; exp--; }
  1364.           if( k>=100 ){
  1365.             bufpt = "NaN";
  1366.             length = 3;
  1367.             break;
  1368.           }
  1369.         }
  1370.         bufpt = buf;
  1371.         /*
  1372.         ** If the field type is etGENERIC, then convert to either etEXP
  1373.         ** or etFLOAT, as appropriate.
  1374.         */
  1375.         flag_exp = xtype==etEXP;
  1376.         if( xtype!=etFLOAT ){
  1377.           realvalue += rounder;
  1378.           if( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }
  1379.         }
  1380.         if( xtype==etGENERIC ){
  1381.           flag_rtz = !flag_alternateform;
  1382.           if( exp<-4 || exp>precision ){
  1383.             xtype = etEXP;
  1384.           }else{
  1385.             precision = precision - exp;
  1386.             xtype = etFLOAT;
  1387.           }
  1388.         }else{
  1389.           flag_rtz = 0;
  1390.         }
  1391.         /*
  1392.         ** The "exp+precision" test causes output to be of type etEXP if
  1393.         ** the precision is too large to fit in buf[].
  1394.         */
  1395.         nsd = 0;
  1396.         if( xtype==etFLOAT && exp+precision<etBUFSIZE-30 ){
  1397.           flag_dp = (precision>0 || flag_alternateform);
  1398.           if( prefix ) *(bufpt++) = prefix;         /* Sign */
  1399.           if( exp<0 )  *(bufpt++) = '0';            /* Digits before "." */
  1400.           else for(; exp>=0; exp--) *(bufpt++) = et_getdigit(&realvalue,&nsd);
  1401.           if( flag_dp ) *(bufpt++) = '.';           /* The decimal point */
  1402.           for(exp++; exp<0 && precision>0; precision--, exp++){
  1403.             *(bufpt++) = '0';
  1404.           }
  1405.           while( (precision--)>0 ) *(bufpt++) = et_getdigit(&realvalue,&nsd);
  1406.           *(bufpt--) = 0;                           /* Null terminate */
  1407.           if( flag_rtz && flag_dp ){     /* Remove trailing zeros and "." */
  1408.             while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0;
  1409.             if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0;
  1410.           }
  1411.           bufpt++;                            /* point to next free slot */
  1412.         }else{    /* etEXP or etGENERIC */
  1413.           flag_dp = (precision>0 || flag_alternateform);
  1414.           if( prefix ) *(bufpt++) = prefix;   /* Sign */
  1415.           *(bufpt++) = et_getdigit(&realvalue,&nsd);  /* First digit */
  1416.           if( flag_dp ) *(bufpt++) = '.';     /* Decimal point */
  1417.           while( (precision--)>0 ) *(bufpt++) = et_getdigit(&realvalue,&nsd);
  1418.           bufpt--;                            /* point to last digit */
  1419.           if( flag_rtz && flag_dp ){          /* Remove tail zeros */
  1420.             while( bufpt>=buf && *bufpt=='0' ) *(bufpt--) = 0;
  1421.             if( bufpt>=buf && *bufpt=='.' ) *(bufpt--) = 0;
  1422.           }
  1423.           bufpt++;                            /* point to next free slot */
  1424.           if( exp || flag_exp ){
  1425.             *(bufpt++) = infop->charset[0];
  1426.             if( exp<0 ){ *(bufpt++) = '-'; exp = -exp; } /* sign of exp */
  1427.             else       { *(bufpt++) = '+'; }
  1428.             if( exp>=100 ){
  1429.               *(bufpt++) = (exp/100)+'0';                /* 100's digit */
  1430.               exp %= 100;
  1431.             }
  1432.             *(bufpt++) = exp/10+'0';                     /* 10's digit */
  1433.             *(bufpt++) = exp%10+'0';                     /* 1's digit */
  1434.           }
  1435.         }
  1436.         /* The converted number is in buf[] and zero terminated. Output it.
  1437.         ** Note that the number is in the usual order, not reversed as with
  1438.         ** integer conversions. */
  1439.         length = (long)bufpt-(long)buf;
  1440.         bufpt = buf;
  1441.  
  1442.         /* Special case:  Add leading zeros if the flag_zeropad flag is
  1443.         ** set and we are not left justified */
  1444.         if( flag_zeropad && !flag_leftjustify && length < width){
  1445.           int i;
  1446.           int nPad = width - length;
  1447.           for(i=width; i>=nPad; i--){
  1448.             bufpt[i] = bufpt[i-nPad];
  1449.           }
  1450.           i = prefix!=0;
  1451.           while( nPad-- ) bufpt[i++] = '0';
  1452.           length = width;
  1453.         }
  1454. #endif
  1455.         break;
  1456.       case etSIZE:
  1457.         *(va_arg(ap,int*)) = count;
  1458.         length = width = 0;
  1459.         break;
  1460.       case etPERCENT:
  1461.         buf[0] = '%';
  1462.         bufpt = buf;
  1463.         length = 1;
  1464.         break;
  1465.       case etCHARLIT:
  1466.       case etCHARX:
  1467.         c = buf[0] = (xtype==etCHARX ? va_arg(ap,int) : *++fmt);
  1468.         if( precision>=0 ){
  1469.           for(idx=1; idx<precision; idx++) buf[idx] = c;
  1470.           length = precision;
  1471.         }else{
  1472.           length =1;
  1473.         }
  1474.         bufpt = buf;
  1475.         break;
  1476.       case etSTRING:
  1477.       case etMEMSTRING:
  1478.         zMem = bufpt = va_arg(ap,char*);
  1479.         if( bufpt==0 ) bufpt = "(null)";
  1480.         length = strlen(bufpt);
  1481.         if( precision>=0 && precision<length ) length = precision;
  1482.         break;
  1483.       case etTCLESCAPE:
  1484.         {
  1485.           int i, j, n, c, k;
  1486.           char *arg = va_arg(ap,char*);
  1487.           if( arg==0 ) arg = "(NULL)";
  1488.           for(i=n=0; (c=arg[i])!=0; i++){
  1489.             k = NeedEsc[c&0xff];
  1490.             if( k==0 ){
  1491.               n++;
  1492.             }else if( k==1 ){
  1493.               n+=4;
  1494.             }else{
  1495.               n+=2;
  1496.             }
  1497.           }
  1498.           n++;
  1499.           if( n>etBUFSIZE ){
  1500.             bufpt = zExtra = Tcl_Alloc( n );
  1501.           }else{
  1502.             bufpt = buf;
  1503.           }
  1504.           for(i=j=0; (c=arg[i])!=0; i++){
  1505.             k = NeedEsc[c&0xff];
  1506.             if( k==0 ){
  1507.               bufpt[j++] = c;
  1508.             }else if( k==1 ){
  1509.               bufpt[j++] = '\\';
  1510.               bufpt[j++] = ((c>>6) & 3) + '0';
  1511.               bufpt[j++] = ((c>>3) & 7) + '0';
  1512.               bufpt[j++] = (c & 7) + '0';
  1513.             }else{
  1514.               bufpt[j++] = '\\';
  1515.               bufpt[j++] = k;
  1516.             }
  1517.           }
  1518.           bufpt[j] = 0;
  1519.           length = j;
  1520.           if( precision>=0 && precision<length ) length = precision;
  1521.         }
  1522.         break;
  1523.       case etERROR:
  1524.         buf[0] = '%';
  1525.         buf[1] = c;
  1526.         errorflag = 0;
  1527.         idx = 1+(c!=0);
  1528.         (*func)(arg,"%",idx);
  1529.         count += idx;
  1530.         if( c==0 ) fmt--;
  1531.         break;
  1532.     }/* End switch over the format type */
  1533.     /*
  1534.     ** The text of the conversion is pointed to by "bufpt" and is
  1535.     ** "length" characters long.  The field width is "width".  Do
  1536.     ** the output.
  1537.     */
  1538.     if( !flag_leftjustify ){
  1539.       register int nspace;
  1540.       nspace = width-length;
  1541.       if( nspace>0 ){
  1542.         if( flag_center ){
  1543.           nspace = nspace/2;
  1544.           width -= nspace;
  1545.           flag_leftjustify = 1;
  1546.         }
  1547.         count += nspace;
  1548.         while( nspace>=etSPACESIZE ){
  1549.           (*func)(arg,spaces,etSPACESIZE);
  1550.           nspace -= etSPACESIZE;
  1551.         }
  1552.         if( nspace>0 ) (*func)(arg,spaces,nspace);
  1553.       }
  1554.     }
  1555.     if( length>0 ){
  1556.       (*func)(arg,bufpt,length);
  1557.       count += length;
  1558.     }
  1559.     if( xtype==etMEMSTRING && zMem ){
  1560.       Tcl_Free(zMem);
  1561.     }
  1562.     if( flag_leftjustify ){
  1563.       register int nspace;
  1564.       nspace = width-length;
  1565.       if( nspace>0 ){
  1566.         count += nspace;
  1567.         while( nspace>=etSPACESIZE ){
  1568.           (*func)(arg,spaces,etSPACESIZE);
  1569.           nspace -= etSPACESIZE;
  1570.         }
  1571.         if( nspace>0 ) (*func)(arg,spaces,nspace);
  1572.       }
  1573.     }
  1574.     if( zExtra ){
  1575.       Tcl_Free(zExtra);
  1576.     }
  1577.   }/* End for loop over the format string */
  1578.   return errorflag ? -1 : count;
  1579. } /* End of function */
  1580.  
  1581. /*
  1582. ** The following section of code handles the mprintf routine, that
  1583. ** writes to memory obtained from malloc().
  1584. */
  1585.  
  1586. /* This structure is used to store state information about the
  1587. ** write to memory that is currently in progress.
  1588. */
  1589. struct sgMprintf {
  1590.   char *zBase;     /* A base allocation */
  1591.   char *zText;     /* The string collected so far */
  1592.   int  nChar;      /* Length of the string so far */
  1593.   int  nAlloc;     /* Amount of space allocated in zText */
  1594. };
  1595.  
  1596. /*
  1597. ** The xprintf callback function.
  1598. **
  1599. ** This routine add nNewChar characters of text in zNewText to
  1600. ** the sgMprintf structure pointed to by "arg".
  1601. */
  1602. static void mout(void *arg, char *zNewText, int nNewChar){
  1603.   struct sgMprintf *pM = (struct sgMprintf*)arg;
  1604.   if( pM->nChar + nNewChar + 1 > pM->nAlloc ){
  1605.     pM->nAlloc = pM->nChar + nNewChar*2 + 1;
  1606.     if( pM->zText==pM->zBase ){
  1607.       pM->zText = Tcl_Alloc(pM->nAlloc);
  1608.       if( pM->zText && pM->nChar ) memcpy(pM->zText,pM->zBase,pM->nChar);
  1609.     }else{
  1610.       pM->zText = Tcl_Realloc(pM->zText, pM->nAlloc);
  1611.     }
  1612.   }
  1613.   if( pM->zText ){
  1614.     memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);
  1615.     pM->nChar += nNewChar;
  1616.     pM->zText[pM->nChar] = 0;
  1617.   }
  1618. }
  1619.  
  1620. /*
  1621. ** mprintf() works like printf(), but allocations memory to hold the
  1622. ** resulting string and returns a pointer to the allocated memory.
  1623. */
  1624. char *mprintf(const char *zFormat, ...){
  1625.   va_list ap;
  1626.   struct sgMprintf sMprintf;
  1627.   char *zNew;
  1628.   char zBuf[200];
  1629.  
  1630.   sMprintf.nChar = 0;
  1631.   sMprintf.nAlloc = sizeof(zBuf);
  1632.   sMprintf.zText = zBuf;
  1633.   sMprintf.zBase = zBuf;
  1634.   va_start(ap,zFormat);
  1635.   vxprintf(mout,&sMprintf,zFormat,ap);
  1636.   va_end(ap);
  1637.   sMprintf.zText[sMprintf.nChar] = 0;
  1638.   if( sMprintf.zText==sMprintf.zBase ){
  1639.     zNew = Tcl_Alloc( sMprintf.nChar+1 );
  1640.     if( zNew ) strcpy(zNew,zBuf);
  1641.   }else{
  1642.     zNew = Tcl_Realloc(sMprintf.zText,sMprintf.nChar+1);
  1643.   }
  1644.   return zNew;
  1645. }
  1646.  
  1647. /* This is the varargs version of mprintf.  
  1648. */
  1649. char *vmprintf(const char *zFormat, va_list ap){
  1650.   struct sgMprintf sMprintf;
  1651.   char zBuf[200];
  1652.   sMprintf.nChar = 0;
  1653.   sMprintf.zText = zBuf;
  1654.   sMprintf.nAlloc = sizeof(zBuf);
  1655.   sMprintf.zBase = zBuf;
  1656.   vxprintf(mout,&sMprintf,zFormat,ap);
  1657.   sMprintf.zText[sMprintf.nChar] = 0;
  1658.   if( sMprintf.zText==sMprintf.zBase ){
  1659.     sMprintf.zText = Tcl_Alloc( strlen(zBuf)+1 );
  1660.     if( sMprintf.zText ) strcpy(sMprintf.zText,zBuf);
  1661.   }else{
  1662.     sMprintf.zText = Tcl_Realloc(sMprintf.zText,sMprintf.nChar+1);
  1663.   }
  1664.   return sMprintf.zText;
  1665. }
  1666.  
  1667. /*
  1668. ** Add text output to a Tcl_DString.
  1669. **
  1670. ** This routine is called by vxprintf().  It's job is to add
  1671. ** nNewChar characters of text from zNewText to the Tcl_DString
  1672. ** that "arg" is pointing to.
  1673. */
  1674. static void dstringout(void *arg, char *zNewText, int nNewChar){
  1675.   Tcl_DString *str = (Tcl_DString*)arg;
  1676.   Tcl_DStringAppend(str,zNewText,nNewChar);
  1677. }
  1678.  
  1679. /*
  1680. ** Append formatted output to a DString.
  1681. */
  1682. char *Et_DStringAppendF(Tcl_DString *str, const char *zFormat, ...){
  1683.   va_list ap;
  1684.   va_start(ap,zFormat);
  1685.   vxprintf(dstringout,str,zFormat,ap);
  1686.   va_end(ap);
  1687.   return Tcl_DStringValue(str);
  1688. }
  1689.  
  1690. /*
  1691. ** Make this variable true to trace all calls to EvalF
  1692. */
  1693. int Et_EvalTrace = 0;
  1694.  
  1695. /*
  1696. ** Eval the results of a string.
  1697. */
  1698. int Et_EvalF(Tcl_Interp *interp, const char *zFormat, ...){
  1699.   char *zCmd;
  1700.   va_list ap;
  1701.   int result;
  1702.   va_start(ap,zFormat);
  1703.   zCmd = vmprintf(zFormat,ap);
  1704.   if( Et_EvalTrace ) printf("%s\n",zCmd);
  1705.   result = Tcl_Eval(interp,zCmd);
  1706.   if( Et_EvalTrace ) printf("%d %s\n",result,interp->result);
  1707.   Tcl_Free(zCmd);
  1708.   return result;
  1709. }
  1710. int Et_GlobalEvalF(Tcl_Interp *interp, const char *zFormat, ...){
  1711.   char *zCmd;
  1712.   va_list ap;
  1713.   int result;
  1714.   va_start(ap,zFormat);
  1715.   zCmd = vmprintf(zFormat,ap);
  1716.   if( Et_EvalTrace ) printf("%s\n",zCmd);
  1717.   result = Tcl_GlobalEval(interp,zCmd);
  1718.   if( Et_EvalTrace ) printf("%d %s\n",result,interp->result);
  1719.   Tcl_Free(zCmd);
  1720.   return result;
  1721. }
  1722.  
  1723. /*
  1724. ** Set the result of an interpreter using printf-like arguments.
  1725. */
  1726. void Et_ResultF(Tcl_Interp *interp, const char *zFormat, ...){
  1727.   Tcl_DString str;
  1728.   va_list ap;
  1729.  
  1730.   Tcl_DStringInit(&str);
  1731.   va_start(ap,zFormat);
  1732.   vxprintf(dstringout,&str,zFormat,ap);
  1733.   va_end(ap);
  1734.   Tcl_DStringResult(interp,&str);  
  1735. }
  1736.  
  1737. #if ET_HAVE_OBJ
  1738. /*
  1739. ** Append text to a string object.
  1740. */
  1741. int Et_AppendObjF(Tcl_Obj *pObj, const char *zFormat, ...){
  1742.   va_list ap;
  1743.   int rc;
  1744.  
  1745.   va_start(ap,zFormat);
  1746.   rc = vxprintf((void(*)(void*,char*,int))Tcl_AppendToObj, pObj, zFormat, ap);
  1747.   va_end(ap);
  1748.   return rc;
  1749. }
  1750. #endif
  1751.  
  1752.  
  1753. #if ET_WIN32
  1754. /*
  1755. ** This array translates all characters into themselves.  Except
  1756. ** for the \ which gets translated into /.  And all upper-case
  1757. ** characters are translated into lower case.  This is used for
  1758. ** hashing and comparing filenames, to work around the Windows
  1759. ** bug of ignoring filename case and using the wrong separator
  1760. ** character for directories.
  1761. **
  1762. ** The array is initialized by FilenameHashInit().
  1763. **
  1764. ** We also define a macro ET_TRANS() that actually does
  1765. ** the character translation.  ET_TRANS() is a no-op under
  1766. ** unix.
  1767. */
  1768. static char charTrans[256];
  1769. #define ET_TRANS(X) (charTrans[0xff&(int)(X)])
  1770. #else
  1771. #define ET_TRANS(X) (X)
  1772. #endif
  1773.  
  1774. /*
  1775. ** Hash a filename.  The value returned is appropriate for
  1776. ** indexing into the Et_FileHashTable[] array.
  1777. */
  1778. static int FilenameHash(char *zName){
  1779.   int h = 0;
  1780.   while( *zName ){
  1781.     h = h ^ (h<<5) ^ ET_TRANS(*(zName++));
  1782.   }
  1783.   if( h<0 ) h = -h;
  1784.   return h % (sizeof(Et_FileHashTable)/sizeof(Et_FileHashTable[0]));
  1785. }
  1786.  
  1787. /*
  1788. ** Compare two filenames.  Return 0 if they are the same and
  1789. ** non-zero if they are different.
  1790. */
  1791. static int FilenameCmp(char *z1, char *z2){
  1792.   int diff;
  1793.   while( (diff = ET_TRANS(*z1)-ET_TRANS(*z2))==0 && *z1!=0){
  1794.     z1++;
  1795.     z2++;
  1796.   }
  1797.   return diff;
  1798. }
  1799.  
  1800. /*
  1801. ** Initialize the file hash table
  1802. */
  1803. static void FilenameHashInit(void){
  1804.   int i;
  1805. #if ET_WIN32
  1806.   for(i=0; i<sizeof(charTrans); i++){
  1807.     charTrans[i] = i;
  1808.   }
  1809.   for(i='A'; i<='Z'; i++){
  1810.     charTrans[i] = i + 'a' - 'A';
  1811.   }
  1812.   charTrans['\\'] = '/';
  1813. #endif
  1814.   for(i=0; i<sizeof(Et_FileSet)/sizeof(Et_FileSet[0]) - 1; i++){
  1815.     struct EtFile *p;
  1816.     int h;
  1817.     p = &Et_FileSet[i];
  1818.     h = FilenameHash(p->zName);
  1819.     p->pNext = Et_FileHashTable[h];
  1820.     Et_FileHashTable[h] = p;
  1821.   }
  1822. }
  1823.  
  1824. /*
  1825. ** Locate the text of a built-in file given its name.  
  1826. ** Return 0 if not found.  Return this size of the file (not
  1827. ** counting the null-terminator) in *pSize if pSize!=NULL.
  1828. **
  1829. ** If deshroud==1 and the file is shrouded, then descramble
  1830. ** the text.
  1831. */
  1832. static char *FindBuiltinFile(char *zName, int deshroud, int *pSize){
  1833.   int h;
  1834.   struct EtFile *p;
  1835.  
  1836.   h = FilenameHash(zName);
  1837.   p = Et_FileHashTable[h];
  1838.   while( p && FilenameCmp(p->zName,zName)!=0 ){ p = p->pNext; }
  1839. #if ET_SHROUD_KEY>0
  1840.   if( p && p->shrouded && deshroud ){
  1841.     char *z;
  1842.     int xor = ET_SHROUD_KEY;
  1843.     for(z=p->zData; *z; z++){
  1844.       if( *z>=0x20 ){ *z ^= xor; xor = (xor+1)&0x1f; }
  1845.     }
  1846.     p->shrouded = 0;
  1847.   }
  1848. #endif
  1849.   if( p && pSize ){
  1850.     *pSize = p->nData;
  1851.   }
  1852.   return p ? p->zData : 0;
  1853. }
  1854.  
  1855. /*
  1856. ** Add a new file to the list of built-in files.
  1857. **
  1858. ** This routine makes a copy of zFilename.  But it does NOT make
  1859. ** a copy of zData.  It just holds a pointer to zData and uses
  1860. ** that for all file access.  So after calling this routine,
  1861. ** you should never change zData!
  1862. */
  1863. void Et_NewBuiltinFile(
  1864.   char *zFilename,  /* Name of the new file */
  1865.   char *zData,      /* Data for the new file */
  1866.   int nData         /* Number of bytes in the new file */
  1867. ){
  1868.   int h;
  1869.   struct EtFile *p;
  1870.  
  1871.   p = (struct EtFile*)Tcl_Alloc( sizeof(struct EtFile) + strlen(zFilename) + 1);
  1872.   if( p==0 ) return;
  1873.   p->zName = (char*)&p[1];
  1874.   strcpy(p->zName, zFilename);
  1875.   p->zData = zData;
  1876.   p->nData = nData;
  1877.   p->shrouded = 0;
  1878.   h = FilenameHash(zFilename);
  1879.   p->pNext = Et_FileHashTable[h];
  1880.   Et_FileHashTable[h] = p;
  1881. }
  1882.  
  1883. /*
  1884. ** A TCL interface to the Et_NewBuiltinFile function.  For Tcl8.0
  1885. ** and later, we make this an Obj command so that it can deal with
  1886. ** binary data.
  1887. */
  1888. #if ET_HAVE_OBJ
  1889. static int Et_NewBuiltinFileCmd(ET_OBJARGS){
  1890.   char *zData, *zNew;
  1891.   int nData;
  1892.   if( objc!=3 ){
  1893.     Tcl_WrongNumArgs(interp, 1, objv, "filename data");
  1894.     return TCL_ERROR;
  1895.   }
  1896.   zData = (char*)Tcl_GetByteArrayFromObj(objv[2], &nData);
  1897.   zNew = Tcl_Alloc( nData + 1 );
  1898.   if( zNew ){
  1899.     memcpy(zNew, zData, nData);
  1900.     zNew[nData] = 0;
  1901.     Et_NewBuiltinFile(Tcl_GetStringFromObj(objv[1], 0), zNew, nData);
  1902.   }
  1903.   return TCL_OK;
  1904. }
  1905. #else
  1906. static int Et_NewBuiltinFileCmd(ET_TCLARGS){
  1907.   char *zData;
  1908.   int nData;
  1909.   if( argc!=3 ){
  1910.     Et_ResultF(interp,"wrong # args: should be \"%s FILENAME DATA\"", argv[0]);
  1911.     return TCL_ERROR;
  1912.   }
  1913.   nData = strlen(argv[2]) + 1;
  1914.   zData = Tcl_Alloc( nData );
  1915.   if( zData ){
  1916.     strcpy(zData, argv[2]);
  1917.     Et_NewBuiltinFile(argv[1], zData, nData);
  1918.   }
  1919.   return TCL_OK;
  1920. }
  1921. #endif
  1922.  
  1923. /*
  1924. ** The following section implements the InsertProc functionality.  The
  1925. ** new InsertProc feature of Tcl8.0.3 and later allows us to overload
  1926. ** the usual system call commands for file I/O and replace them with
  1927. ** commands that operate on the built-in files.
  1928. */
  1929. #ifdef ET_HAVE_INSERTPROC
  1930.  
  1931. /*
  1932. ** Each open channel to a built-in file is an instance of the
  1933. ** following structure.
  1934. */
  1935. typedef struct Et_FileStruct {
  1936.   char *zData;     /* All of the data */
  1937.   int nData;       /* Bytes of data, not counting the null terminator */
  1938.   int cursor;      /* How much of the data has been read so far */
  1939. } Et_FileStruct;
  1940.  
  1941. /*
  1942. ** Close a previously opened built-in file.
  1943. */
  1944. static int Et_FileClose(ClientData instanceData, Tcl_Interp *interp){
  1945.   Et_FileStruct *p = (Et_FileStruct*)instanceData;
  1946.   Tcl_Free((char*)p);
  1947.   return 0;
  1948. }
  1949.  
  1950. /*
  1951. ** Read from a built-in file.
  1952. */
  1953. static int Et_FileInput(
  1954.   ClientData instanceData,    /* The file structure */
  1955.   char *buf,                  /* Write the data read here */
  1956.   int bufSize,                /* Read this much data */
  1957.   int *pErrorCode             /* Write the error code here */
  1958. ){
  1959.   Et_FileStruct *p = (Et_FileStruct*)instanceData;
  1960.   *pErrorCode = 0;
  1961.   if( p->cursor+bufSize>p->nData ){
  1962.     bufSize = p->nData - p->cursor;
  1963.   }
  1964.   memcpy(buf, &p->zData[p->cursor], bufSize);
  1965.   p->cursor += bufSize;
  1966.   return bufSize;
  1967. }
  1968.  
  1969. /*
  1970. ** Writes to a built-in file always return EOF.
  1971. */
  1972. static int Et_FileOutput(
  1973.   ClientData instanceData,    /* The file structure */
  1974.   char *buf,                  /* Read the data from here */
  1975.   int toWrite,                /* Write this much data */
  1976.   int *pErrorCode             /* Write the error code here */
  1977. ){
  1978.   *pErrorCode = 0;
  1979.   return 0;
  1980. }
  1981.  
  1982. /*
  1983. ** Move the cursor around within the built-in file.
  1984. */
  1985. static int Et_FileSeek(
  1986.   ClientData instanceData,    /* The file structure */
  1987.   long offset,                /* Offset to seek to */
  1988.   int mode,                   /* One of SEEK_CUR, SEEK_SET or SEEK_END */
  1989.   int *pErrorCode             /* Write the error code here */
  1990. ){
  1991.   Et_FileStruct *p = (Et_FileStruct*)instanceData;
  1992.   switch( mode ){
  1993.     case SEEK_CUR:     offset += p->cursor;   break;
  1994.     case SEEK_END:     offset += p->nData;    break;
  1995.     default:           break;
  1996.   }
  1997.   if( offset<0 ) offset = 0;
  1998.   if( offset>p->nData ) offset = p->nData;
  1999.   p->cursor = offset;
  2000.   return offset;
  2001. }
  2002.  
  2003. /*
  2004. ** The Watch method is a no-op
  2005. */
  2006. static void Et_FileWatch(ClientData instanceData, int mask){
  2007. }
  2008.  
  2009. /*
  2010. ** The Handle method always returns an error.
  2011. */
  2012. static int Et_FileHandle(ClientData notUsed, int dir, ClientData *handlePtr){
  2013.   return TCL_ERROR;
  2014. }
  2015.  
  2016. /*
  2017. ** This is the channel type that will access the built-in files.
  2018. */
  2019. static Tcl_ChannelType builtinChannelType = {
  2020.     "builtin",                  /* Type name. */
  2021.     NULL,                       /* Always non-blocking.*/
  2022.     Et_FileClose,               /* Close proc. */
  2023.     Et_FileInput,               /* Input proc. */
  2024.     Et_FileOutput,              /* Output proc. */
  2025.     Et_FileSeek,                /* Seek proc. */
  2026.     NULL,                       /* Set option proc. */
  2027.     NULL,                       /* Get option proc. */
  2028.     Et_FileWatch,               /* Watch for events on console. */
  2029.     Et_FileHandle,              /* Get a handle from the device. */
  2030. };
  2031.  
  2032. /*
  2033. ** This routine attempts to do an open of a built-in file.
  2034. */
  2035. static Tcl_Channel Et_FileOpen(
  2036.   Tcl_Interp *interp,     /* The TCL interpreter doing the open */
  2037.   char *zFilename,        /* Name of the file to open */
  2038.   char *modeString,       /* Mode string for the open (ignored) */
  2039.   int permissions         /* Permissions for a newly created file (ignored) */
  2040. ){
  2041.   char *zData;
  2042.   Et_FileStruct *p;
  2043.   int nData;
  2044.   char zName[50];
  2045.   Tcl_Channel chan;
  2046.   static int count = 1;
  2047.  
  2048.   zData = FindBuiltinFile(zFilename, 1, &nData);
  2049.   if( zData==0 ) return NULL;
  2050.   p = (Et_FileStruct*)Tcl_Alloc( sizeof(Et_FileStruct) );
  2051.   if( p==0 ) return NULL;
  2052.   p->zData = zData;
  2053.   p->nData = nData;
  2054.   p->cursor = 0;
  2055.   sprintf(zName,"etbi_%x_%x",((int)Et_FileOpen)>>12,count++);
  2056.   chan = Tcl_CreateChannel(&builtinChannelType, zName,
  2057.                            (ClientData)p, TCL_READABLE);
  2058.   return chan;
  2059. }
  2060.  
  2061. /*
  2062. ** This routine does a stat() system call for a built-in file.
  2063. */
  2064. static int Et_FileStat(char *path, struct stat *buf){
  2065.   char *zData;
  2066.   int nData;
  2067.  
  2068.   zData = FindBuiltinFile(path, 0, &nData);
  2069.   if( zData==0 ){
  2070.     return -1;
  2071.   }
  2072.   memset(buf, 0, sizeof(*buf));
  2073.   buf->st_mode = 0400;
  2074.   buf->st_size = nData;
  2075.   return 0;
  2076. }
  2077.  
  2078. /*
  2079. ** This routien does an access() system call for a built-in file.
  2080. */
  2081. static int Et_FileAccess(char *path, int mode){
  2082.   char *zData;
  2083.  
  2084.   if( mode & 3 ){
  2085.     return -1;
  2086.   }
  2087.   zData = FindBuiltinFile(path, 0, 0);
  2088.   if( zData==0 ){
  2089.     return -1;
  2090.   }
  2091.   return 0;
  2092. }
  2093. #endif  /* ET_HAVE_INSERTPROC */
  2094.  
  2095. /*
  2096. ** An overloaded version of "source".  First check for the file
  2097. ** is one of the built-ins.  If it isn't a built-in, then check the
  2098. ** disk.  But if ET_STANDALONE is set (which corresponds to the
  2099. ** "Strict" option in the user interface) then never check the disk.
  2100. ** This gives us a quick way to check for the common error of
  2101. ** sourcing a file that exists on the development by mistake,
  2102. ** and only discovering the mistake when you move the program
  2103. ** to your customer's machine.
  2104. */
  2105. static int Et_Source(ET_TCLARGS){
  2106.   char *z;
  2107.  
  2108.   if( argc!=2 ){
  2109.     Et_ResultF(interp,"wrong # args: should be \"%s FILENAME\"", argv[0]);
  2110.     return TCL_ERROR;
  2111.   }
  2112.   z = FindBuiltinFile(argv[1], 1, 0);
  2113.   if( z ){
  2114.     int rc;
  2115.     rc = Tcl_Eval(interp,z);
  2116.     if (rc == TCL_ERROR) {
  2117.       char msg[200];
  2118.       sprintf(msg, "\n    (file \"%.150s\" line %d)", argv[1],
  2119.         interp->errorLine);
  2120.       Tcl_AddErrorInfo(interp, msg);
  2121.     } else {
  2122.       rc = TCL_OK;
  2123.     }
  2124.     return rc;
  2125.   }
  2126. #if ET_STANDALONE
  2127.   Et_ResultF(interp,"no such file: \"%s\"", argv[1]);
  2128.   return TCL_ERROR;
  2129. #else
  2130.   return Tcl_EvalFile(interp,argv[1]);
  2131. #endif
  2132. }
  2133.  
  2134. #ifndef ET_HAVE_INSERTPROC
  2135. /*
  2136. ** An overloaded version of "file exists".  First check for the file
  2137. ** in the file table, then go to disk.
  2138. **
  2139. ** We only overload "file exists" if we don't have InsertProc()
  2140. ** procedures.  If we do have InsertProc() procedures, they will
  2141. ** handle this more efficiently.
  2142. */
  2143. static int Et_FileExists(ET_TCLARGS){
  2144.   int i, rc;
  2145.   Tcl_DString str;
  2146.   if( argc==3 && strncmp(argv[1],"exis",4)==0 ){
  2147.     if( FindBuiltinFile(argv[2], 0, 0)!=0 ){
  2148.       interp->result = "1";
  2149.       return TCL_OK;
  2150.     }
  2151.   }
  2152.   Tcl_DStringInit(&str);
  2153.   Tcl_DStringAppendElement(&str,"Et_FileCmd");
  2154.   for(i=1; i<argc; i++){
  2155.     Tcl_DStringAppendElement(&str, argv[i]);
  2156.   }
  2157.   rc = Tcl_Eval(interp, Tcl_DStringValue(&str));
  2158.   Tcl_DStringFree(&str);
  2159.   return rc;
  2160. }
  2161. #endif
  2162.  
  2163. /*
  2164. ** This is the main Tcl interpreter.  It's a global variable so it
  2165. ** can be accessed easily from C code.
  2166. */
  2167. Tcl_Interp *Et_Interp = 0;
  2168.  
  2169.  
  2170. #if ET_WIN32
  2171. /*
  2172. ** Implement the Et_MessageBox command on Windows platforms.  We
  2173. ** use the MessageBox() function from the Win32 API so that the
  2174. ** error message will be displayed as a dialog box.  Writing to
  2175. ** standard error doesn't do anything on windows.
  2176. */
  2177. int Et_MessageBox(ET_TCLARGS){
  2178.   char *zMsg = "(Empty Message)";
  2179.   char *zTitle = "Message...";
  2180.  
  2181.   if( argc>1 ){
  2182.     zTitle = argv[1];
  2183.   }
  2184.   if( argc>2 ){
  2185.     zMsg = argv[2];
  2186.   }
  2187.   MessageBox(0, zMsg, zTitle, MB_ICONSTOP | MB_OK);
  2188.   return TCL_OK;
  2189. }
  2190. #endif
  2191.  
  2192. /*
  2193. ** A default implementation for "bgerror"
  2194. */
  2195. static char zBgerror[] =
  2196.   "proc Et_Bgerror err {\n"
  2197.   "  global errorInfo tk_library\n"
  2198.   "  if {[info exists errorInfo]} {\n"
  2199.   "    set ei $errorInfo\n"
  2200.   "  } else {\n"
  2201.   "    set ei {}\n"
  2202.   "  }\n"
  2203.   "  if {[catch {bgerror $err}]==0} return\n"
  2204.   "  if {[string length $ei]>0} {\n"
  2205.   "    set err $ei\n"
  2206.   "  }\n"
  2207.   "  if {[catch {Et_MessageBox {Error} $err}]} {\n"
  2208.   "    puts stderr $err\n"
  2209.   "  }\n"
  2210.   "  exit\n"
  2211.   "}\n"
  2212. ;
  2213.  
  2214. /*
  2215. ** Do the initialization.
  2216. **
  2217. ** This routine is called after the interpreter is created, but
  2218. ** before Et_PreInit() or Et_AppInit() have been run.
  2219. */
  2220. static int Et_DoInit(Tcl_Interp *interp){
  2221.   int i;
  2222.   extern int Et_PreInit(Tcl_Interp*);
  2223.   extern int Et_AppInit(Tcl_Interp*);
  2224.  
  2225.   /* Insert our alternative stat(), access() and open() procedures
  2226.   ** so that any attempt to work with a file will check our built-in
  2227.   ** scripts first.
  2228.   */
  2229. #ifdef ET_HAVE_INSERTPROC
  2230.   TclStatInsertProc(Et_FileStat);
  2231.   TclAccessInsertProc(Et_FileAccess);
  2232.   TclOpenFileChannelInsertProc(Et_FileOpen);
  2233. #endif
  2234.  
  2235.   /* Initialize the hash-table for built-in scripts
  2236.   */
  2237.   FilenameHashInit();
  2238.  
  2239.   /* The Et_NewBuiltFile command is inserted for use by FreeWrap
  2240.   ** and similar tools.
  2241.   */
  2242. #if ET_HAVE_OBJ
  2243.   Tcl_CreateObjCommand(interp,"Et_NewBuiltinFile",Et_NewBuiltinFileCmd,0,0);
  2244. #else
  2245.   Tcl_CreateCommand(interp,"Et_NewBuiltinFile",Et_NewBuiltinFileCmd,0,0);
  2246. #endif
  2247.  
  2248.   /* Overload the "file" and "source" commands
  2249.   */
  2250. #ifndef ET_HAVE_INSERTPROC
  2251.   {
  2252.     static char zRename[] = "rename file Et_FileCmd";
  2253.     Tcl_Eval(interp,zRename);
  2254.     Tcl_CreateCommand(interp,"file",Et_FileExists,0,0);
  2255.   }
  2256. #endif
  2257.   Tcl_CreateCommand(interp,"source",Et_Source,0,0);
  2258.  
  2259.   Et_Interp = interp;
  2260. #ifdef ET_TCL_LIBRARY
  2261.   Tcl_SetVar(interp,"tcl_library",ET_TCL_LIBRARY,TCL_GLOBAL_ONLY);
  2262.   Tcl_SetVar(interp,"tcl_libPath",ET_TCL_LIBRARY,TCL_GLOBAL_ONLY);
  2263.   Tcl_SetVar2(interp,"env","TCL_LIBRARY",ET_TCL_LIBRARY,TCL_GLOBAL_ONLY);
  2264. #endif
  2265. #ifdef ET_TK_LIBRARY
  2266.   Tcl_SetVar(interp,"tk_library",ET_TK_LIBRARY,TCL_GLOBAL_ONLY);
  2267.   Tcl_SetVar2(interp,"env","TK_LIBRARY",ET_TK_LIBRARY,TCL_GLOBAL_ONLY);
  2268. #endif
  2269. #if ET_WIN32
  2270.   Tcl_CreateCommand(interp,"Et_MessageBox",Et_MessageBox, 0, 0);
  2271. #endif  
  2272.   Tcl_Eval(interp,zBgerror);
  2273. #if ET_HAVE_PREINIT
  2274.   if( Et_PreInit(interp) == TCL_ERROR ){
  2275.     goto initerr;
  2276.   }
  2277. #endif
  2278.   if( Tcl_Init(interp) == TCL_ERROR ){
  2279.     goto initerr;
  2280.   }
  2281.   Et_GlobalEvalF(interp,"set dir $tcl_library;source $dir/tclIndex;unset dir");
  2282. #if ET_ENABLE_TK
  2283.   if( Tk_Init(interp) == TCL_ERROR ){
  2284.     goto initerr;
  2285.   }
  2286.   Tcl_StaticPackage(interp,"Tk", Tk_Init, 0);
  2287.   Et_GlobalEvalF(interp,"set dir $tk_library;source $dir/tclIndex;unset dir");
  2288. #endif
  2289.   /* Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); */
  2290.   for(i=0; i<sizeof(Et_CmdSet)/sizeof(Et_CmdSet[0]) - 1; i++){
  2291.     Tcl_CreateCommand(interp, Et_CmdSet[i].zName, Et_CmdSet[i].xProc, 0, 0);
  2292.   }
  2293. #if ET_ENABLE_OBJ
  2294.   for(i=0; i<sizeof(Et_ObjSet)/sizeof(Et_ObjSet[0]) - 1; i++){
  2295.     Tcl_CreateObjCommand(interp, Et_ObjSet[i].zName, Et_ObjSet[i].xProc, 0, 0);
  2296.   }
  2297. #endif
  2298.   Tcl_LinkVar(interp,"Et_EvalTrace",(char*)&Et_EvalTrace,TCL_LINK_BOOLEAN);
  2299.   Tcl_SetVar(interp,"et_version",ET_VERSION,TCL_GLOBAL_ONLY);
  2300. #if ET_HAVE_APPINIT
  2301.   if( Et_AppInit(interp) == TCL_ERROR ){
  2302.     goto initerr;
  2303.   }
  2304. #endif
  2305. #if ET_ENABLE_TK && !ET_EXTENSION
  2306.   Et_NewBuiltinFile("builtin:/console.tcl", zEtConsole, sizeof(zEtConsole));
  2307. #if ET_CONSOLE
  2308.   Tcl_Eval(interp,
  2309.     "source builtin:/console.tcl\n"
  2310.     "console:create {.@console} {% } {Tcl/Tk Console}\n"
  2311.   );
  2312. #endif
  2313. #endif
  2314. #ifdef ET_MAIN_SCRIPT
  2315.   if( Et_EvalF(interp,"source \"%q\"", ET_MAIN_SCRIPT)!=TCL_OK ){
  2316.     goto initerr;
  2317.   }
  2318. #endif
  2319.   return TCL_OK;
  2320.  
  2321. initerr:
  2322.   Et_EvalF(interp,"Et_Bgerror \"%q\"", interp->result);
  2323.   return TCL_ERROR;
  2324. }
  2325.  
  2326. #if ET_READ_STDIN==0 || ET_AUTO_FORK!=0
  2327. /*
  2328. ** Initialize everything.
  2329. */
  2330. static int Et_Local_Init(int argc, char **argv){
  2331.   Tcl_Interp *interp;
  2332.   char *args;
  2333.   char buf[100];
  2334. #if !ET_HAVE_CUSTOM_MAINLOOP
  2335.   static char zWaitForever[] =
  2336. #if ET_ENABLE_TK
  2337.     "bind . <Destroy> {if {![winfo exists .]} exit}\n"
  2338. #endif
  2339.     "while 1 {vwait forever}";
  2340. #endif
  2341.  
  2342.   Tcl_FindExecutable(argv[0]);
  2343.   interp = Tcl_CreateInterp();
  2344.   args = Tcl_Merge(argc-1, argv+1);
  2345.   Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY);
  2346.   ckfree(args);
  2347.   sprintf(buf, "%d", argc-1);
  2348.   Tcl_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY);
  2349.   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
  2350.   Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
  2351.   Et_DoInit(interp);
  2352. #if ET_HAVE_CUSTOM_MAINLOOP
  2353.   Et_CustomMainLoop(interp);
  2354. #else
  2355.   Tcl_Eval(interp,zWaitForever);
  2356. #endif
  2357.   return 0;
  2358. }
  2359. #endif
  2360.  
  2361. /*
  2362. ** This routine is called to do the complete initialization.
  2363. */
  2364. int Et_Init(int argc, char **argv){
  2365. #ifdef ET_TCL_LIBRARY
  2366.   putenv("TCL_LIBRARY=" ET_TCL_LIBRARY);
  2367. #endif
  2368. #ifdef ET_TK_LIBRARY
  2369.   putenv("TK_LIBRARY=" ET_TK_LIBRARY);
  2370. #endif
  2371. #if ET_CONSOLE || !ET_READ_STDIN
  2372.   Et_Local_Init(argc, argv);
  2373. #else
  2374. # if ET_ENABLE_TK
  2375.   Tk_Main(argc,argv,Et_DoInit);
  2376. # else
  2377.   Tcl_Main(argc, argv, Et_DoInit);
  2378. # endif
  2379. #endif
  2380.   return 0;
  2381. }
  2382.  
  2383. #if !ET_HAVE_MAIN && !ET_EXTENSION
  2384. /*
  2385. ** Main routine for UNIX programs.  If the user has supplied
  2386. ** their own main() routine in a C module, then the ET_HAVE_MAIN
  2387. ** macro will be set to 1 and this code will be skipped.
  2388. */
  2389. int main(int argc, char **argv){
  2390. #if ET_AUTO_FORK
  2391.   int rc = fork();
  2392.   if( rc<0 ){
  2393.     perror("can't fork");
  2394.     exit(1);
  2395.   }
  2396.   if( rc>0 ) return 0;
  2397.   close(0);
  2398.   open("/dev/null",O_RDONLY);
  2399.   close(1);
  2400.   open("/dev/null",O_WRONLY);
  2401. #endif
  2402.   return Et_Init(argc,argv)!=TCL_OK;
  2403. }
  2404. #endif
  2405.  
  2406. #if ET_EXTENSION
  2407. /*
  2408. ** If the -extension flag is used, then generate code that will be
  2409. ** turned into a loadable shared library or DLL, not a standalone
  2410. ** executable.
  2411. */
  2412. int ET_EXTENSION_NAME(Tcl_Interp *interp){
  2413.   int i;
  2414. #ifndef ET_HAVE_INSERTPROC
  2415.   Tcl_AppendResult(interp,
  2416.        "mktclapp can only generate extensions for Tcl/Tk version "
  2417.        "8.0.3 and later. This is version "
  2418.        TCL_MAJOR_VERSION "." TCL_MINOR_VERSION "." TCL_RELEASE_SERIAL, 0);
  2419.   return TCL_ERROR;
  2420. #endif
  2421. #ifdef ET_HAVE_INSERTPROC
  2422. #ifdef USE_TCL_STUBS
  2423.   if( Tcl_InitStubs(interp,"8.0",0)==0 ){
  2424.     return TCL_ERROR;
  2425.   }
  2426.   if( Tk_InitStubs(interp,"8.0",0)==0 ){
  2427.     return TCL_ERROR;
  2428.   }
  2429. #endif
  2430.   Et_Interp = interp;
  2431.   TclStatInsertProc(Et_FileStat);
  2432.   TclAccessInsertProc(Et_FileAccess);
  2433.   TclOpenFileChannelInsertProc(Et_FileOpen);
  2434.   FilenameHashInit();
  2435.   for(i=0; i<sizeof(Et_CmdSet)/sizeof(Et_CmdSet[0]) - 1; i++){
  2436.     Tcl_CreateCommand(interp, Et_CmdSet[i].zName, Et_CmdSet[i].xProc, 0, 0);
  2437.   }
  2438. #if ET_ENABLE_OBJ
  2439.   for(i=0; i<sizeof(Et_ObjSet)/sizeof(Et_ObjSet[0]) - 1; i++){
  2440.     Tcl_CreateObjCommand(interp, Et_ObjSet[i].zName, Et_ObjSet[i].xProc, 0, 0);
  2441.   }
  2442. #endif
  2443.   Tcl_LinkVar(interp,"Et_EvalTrace",(char*)&Et_EvalTrace,TCL_LINK_BOOLEAN);
  2444.   Tcl_SetVar(interp,"et_version",ET_VERSION,TCL_GLOBAL_ONLY);
  2445. #if ET_HAVE_APPINIT
  2446.   if( Et_AppInit(interp) == TCL_ERROR ){
  2447.     return TCL_ERROR;
  2448.   }
  2449. #endif
  2450. #ifdef ET_MAIN_SCRIPT
  2451.   if( Et_EvalF(interp,"source \"%q\"", ET_MAIN_SCRIPT)!=TCL_OK ){
  2452.     return TCL_ERROR;
  2453.   }
  2454. #endif
  2455.   return TCL_OK;
  2456. #endif  /* ET_HAVE_INSERTPROC */
  2457. }
  2458. int ET_SAFE_EXTENSION_NAME(Tcl_Interp *interp){
  2459.   return ET_EXTENSION_NAME(interp);
  2460. }
  2461. #endif
  2462.