home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / tcl / extend / src / tclXcreate.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-20  |  14.2 KB  |  452 lines  |  [TEXT/MPS ]

  1. #ifdef MPW
  2. #    pragma segment TCLExtend
  3. #endif
  4. /*
  5.  * tclXcreate.c
  6.  *
  7.  * Contains a routine to create an interpreter and initialize all the Extended
  8.  * Tcl commands.  It is is a seperate file so that an application may create
  9.  * the interpreter and add in only a subset of the Extended Tcl commands.
  10.  *-----------------------------------------------------------------------------
  11.  * Copyright 1991-1993 Karl Lehenbauer and Mark Diekhans.
  12.  *
  13.  * Permission to use, copy, modify, and distribute this software and its
  14.  * documentation for any purpose and without fee is hereby granted, provided
  15.  * that the above copyright notice appear in all copies.  Karl Lehenbauer and
  16.  * Mark Diekhans make no representations about the suitability of this
  17.  * software for any purpose.  It is provided "as is" without express or
  18.  * implied warranty.
  19.  *-----------------------------------------------------------------------------
  20.  * $Id: tclXcreate.c,v 2.6 1993/07/31 03:45:25 markd Exp $
  21.  *-----------------------------------------------------------------------------
  22.  */
  23.  
  24. #include "tclExtdInt.h"
  25.  
  26.  
  27. #ifdef macintosh
  28.  
  29. int
  30. TclX_MacUnImpedOK(clientData, interp, argc, argv)
  31.     ClientData  clientData;
  32.     Tcl_Interp *interp;
  33.     int         argc;
  34.     char      **argv;
  35.     {
  36. #pragma unused (clientData, interp, argc, argv)
  37.  
  38.     return TCL_OK;
  39.     }
  40.  
  41. int
  42. TclX_MacUnImpedErr(clientData, interp, argc, argv)
  43.     ClientData  clientData;
  44.     Tcl_Interp *interp;
  45.     int         argc;
  46.     char      **argv;
  47.     {
  48. #pragma unused (clientData, interp, argc, argv)
  49.  
  50.     Tcl_AppendResult( interp, "\"", argv[0],
  51.                         "\" is not implemented for Macintosh.",
  52.                         NULL);
  53.     return TCL_ERROR;
  54.     }
  55.  
  56. #endif
  57.  
  58.  
  59. /*
  60.  *-----------------------------------------------------------------------------
  61.  *
  62.  * Tcl_AddExtendedCmds --
  63.  *
  64.  *   Add the Extended Tcl commands to the specified interpreter (except for
  65.  * the library commands that override that standard Tcl procedures).
  66.  *-----------------------------------------------------------------------------
  67.  */
  68. void
  69. Tcl_AddExtendedCmds (interp)
  70.     Tcl_Interp *interp;
  71.     {
  72.  
  73.     /*
  74.      * from tclCkalloc.c (now part of the UCB Tcl).
  75.      */
  76. #ifdef TCL_MEM_DEBUG    
  77.     Tcl_InitMemory (interp);
  78. #endif
  79.  
  80.  
  81.     /*
  82.      * from tclXbsearch.c
  83.      */
  84.     Tcl_CreateCommand (interp, "bsearch", Tcl_BsearchCmd, 
  85.                       (ClientData) NULL, (void (*)()) NULL);
  86.  
  87.     /*
  88.      * from tclXchmod.c
  89.      */
  90. #ifdef macintosh
  91.     Tcl_CreateCommand (interp, "chgrp", TclX_MacUnImpedOK,
  92.                        (ClientData) NULL, (void (*)()) NULL);
  93.     Tcl_CreateCommand (interp, "chmod", TclX_MacUnImpedOK,
  94.                        (ClientData) NULL, (void (*)()) NULL);
  95.     Tcl_CreateCommand (interp, "chown", TclX_MacUnImpedOK,
  96.                        (ClientData) NULL, (void (*)()) NULL);
  97. #else
  98.     Tcl_CreateCommand (interp, "chgrp", Tcl_ChgrpCmd,
  99.                        (ClientData) NULL, (void (*)()) NULL);
  100.     Tcl_CreateCommand (interp, "chmod", Tcl_ChmodCmd,
  101.                        (ClientData) NULL, (void (*)()) NULL);
  102.     Tcl_CreateCommand (interp, "chown", Tcl_ChownCmd,
  103.                        (ClientData) NULL, (void (*)()) NULL);
  104. #endif
  105.  
  106.     /*
  107.      * from tclXclock.c
  108.      */
  109.     Tcl_CreateCommand (interp, "getclock", Tcl_GetclockCmd, 
  110.                       (ClientData) NULL, (void (*)()) NULL);
  111.     Tcl_CreateCommand (interp, "fmtclock", Tcl_FmtclockCmd, 
  112.                       (ClientData) NULL, (void (*)()) NULL);
  113.  
  114.  
  115.     /*
  116.      * from tclXcnvdate.c
  117.      */
  118. #ifdef macintosh
  119.     Tcl_CreateCommand (interp, "convertclock", TclX_MacUnImpedErr, 
  120.                       (ClientData) NULL, (void (*)()) NULL);
  121. #else
  122.     Tcl_CreateCommand (interp, "convertclock", Tcl_ConvertclockCmd,
  123.                       (ClientData) NULL, (void (*)()) NULL);
  124. #endif
  125.  
  126.     /*
  127.      * from tclXcmdloop.c
  128.      */
  129. #ifdef macintosh
  130.     Tcl_CreateCommand (interp, "commandloop", TclX_MacUnImpedErr, 
  131.                       (ClientData) NULL, (void (*)()) NULL);
  132. #else
  133.     Tcl_CreateCommand (interp, "commandloop", Tcl_CommandloopCmd, 
  134.                       (ClientData) NULL, (void (*)()) NULL);
  135. #endif
  136.  
  137.     /*
  138.      * from tclXdebug.c
  139.      */
  140.     Tcl_InitDebug (interp);
  141.     
  142.     /*
  143.      * from ndebug.c
  144.      */
  145.     Tcl_InitnDebug (interp);
  146.  
  147.     /*
  148.      * from tclXdup.c
  149.      */
  150. #ifdef macintosh
  151.     Tcl_CreateCommand (interp, "dup", TclX_MacUnImpedErr, 
  152.                       (ClientData) NULL, (void (*)()) NULL);
  153. #else
  154.     Tcl_CreateCommand (interp, "dup",  Tcl_DupCmd, 
  155.                        (ClientData) NULL, (void (*)()) NULL);
  156. #endif
  157.  
  158.     /*
  159.      * from tclXtclXfcntl.c
  160.      */
  161. #ifdef macintosh
  162.     Tcl_CreateCommand (interp, "fcntl", TclX_MacUnImpedErr, 
  163.                       (ClientData) NULL, (void (*)()) NULL);
  164. #else
  165.     Tcl_CreateCommand (interp, "fcntl", Tcl_FcntlCmd,
  166.                        (ClientData) NULL, (void (*)()) NULL);
  167. #endif
  168.  
  169.     /*
  170.      * from tclXfilecmds.c
  171.      */
  172.     Tcl_CreateCommand (interp, "pipe", Tcl_PipeCmd,
  173.                        (ClientData) NULL, (void (*)()) NULL);
  174.     Tcl_CreateCommand (interp, "copyfile", Tcl_CopyfileCmd,
  175.                        (ClientData) NULL, (void (*)()) NULL);
  176.     Tcl_CreateCommand (interp, "lgets", Tcl_LgetsCmd,
  177.                        (ClientData) NULL, (void (*)()) NULL);
  178.  
  179.     /*
  180.      * from tclXfstat.c
  181.      */
  182.     Tcl_CreateCommand (interp, "fstat", Tcl_FstatCmd,
  183.                        (ClientData) NULL, (void (*)()) NULL);
  184.  
  185.     /*
  186.      * from tclXflock.c
  187.      */
  188. #ifdef macintosh
  189.     Tcl_CreateCommand (interp, "flock", TclX_MacUnImpedErr, 
  190.                       (ClientData) NULL, (void (*)()) NULL);
  191.     Tcl_CreateCommand (interp, "funlock", TclX_MacUnImpedErr, 
  192.                       (ClientData) NULL, (void (*)()) NULL);
  193. #else
  194.     Tcl_CreateCommand (interp, "flock", Tcl_FlockCmd,
  195.                        (ClientData) NULL, (void (*)()) NULL);
  196.     Tcl_CreateCommand (interp, "funlock", Tcl_FunlockCmd,
  197.                        (ClientData) NULL, (void (*)()) NULL);
  198. #endif
  199.  
  200.     /*
  201.      * from tclXfilescan.c
  202.      */
  203.     Tcl_InitFilescan (interp);
  204.  
  205.     /*
  206.      * from tclXgeneral.c
  207.      */
  208.     Tcl_CreateCommand(interp, "echo", Tcl_EchoCmd, 
  209.                      (ClientData) NULL, (void (*)()) NULL);
  210.     Tcl_CreateCommand(interp, "infox", Tcl_InfoxCmd, 
  211.                      (ClientData) NULL, (void (*)()) NULL);
  212.     Tcl_CreateCommand(interp, "loop", Tcl_LoopCmd, 
  213.                      (ClientData) NULL, (void (*)()) NULL);
  214.  
  215.     /*
  216.      * from tclXid.c
  217.      */
  218.     Tcl_CreateCommand (interp, "id", Tcl_IdCmd,
  219.                        (ClientData) NULL, (void (*)()) NULL);
  220.  
  221.     /*
  222.      * from tclXkeylist.c
  223.      */
  224.     Tcl_CreateCommand(interp, "keyldel", Tcl_KeyldelCmd,
  225.                      (ClientData) NULL, (void (*)()) NULL);
  226.     Tcl_CreateCommand(interp, "keylget", Tcl_KeylgetCmd,
  227.                      (ClientData) NULL, (void (*)()) NULL);
  228.     Tcl_CreateCommand(interp, "keylkeys", Tcl_KeylkeysCmd,
  229.                      (ClientData) NULL, (void (*)()) NULL);
  230.     Tcl_CreateCommand(interp, "keylset", Tcl_KeylsetCmd,
  231.                      (ClientData) NULL, (void (*)()) NULL);
  232.  
  233.     /*
  234.      * from tclXlist.c
  235.      */
  236.     Tcl_CreateCommand(interp, "lvarcat", Tcl_LvarcatCmd, 
  237.                      (ClientData) NULL, (void (*)()) NULL);
  238.     Tcl_CreateCommand(interp, "lvarpop", Tcl_LvarpopCmd, 
  239.                      (ClientData) NULL, (void (*)()) NULL);
  240.     Tcl_CreateCommand(interp, "lvarpush", Tcl_LvarpushCmd, 
  241.                      (ClientData) NULL, (void (*)()) NULL);
  242.     Tcl_CreateCommand(interp, "lempty", Tcl_LemptyCmd, 
  243.                      (ClientData) NULL, (void (*)()) NULL);
  244.     Tcl_CreateCommand(interp, "lassign", Tcl_LassignCmd, 
  245.                      (ClientData) NULL, (void (*)()) NULL);
  246.     /*
  247.      * from tclXmath.c
  248.      */
  249.     Tcl_CreateCommand (interp, "max", Tcl_MaxCmd,
  250.                        (ClientData) NULL, (void (*)()) NULL);
  251.     Tcl_CreateCommand (interp, "min", Tcl_MinCmd,
  252.                        (ClientData) NULL, (void (*)()) NULL);
  253.     Tcl_CreateCommand (interp, "random", Tcl_RandomCmd,
  254.                        (ClientData) NULL, (void (*)()) NULL);
  255.  
  256.     /*
  257.      * from tclXmsgcat.c
  258.      */
  259. #ifdef macintosh
  260.     Tcl_CreateCommand (interp, "catopen", TclX_MacUnImpedErr, 
  261.                        (ClientData) NULL, (void (*)()) NULL);
  262.     Tcl_CreateCommand (interp, "catgets", TclX_MacUnImpedErr, 
  263.                        (ClientData) NULL, (void (*)()) NULL);
  264.     Tcl_CreateCommand (interp, "catclose", TclX_MacUnImpedErr,
  265.                        (ClientData) NULL, (void (*)()) NULL);
  266. #else
  267.     Tcl_InitMsgCat (interp);
  268. #endif
  269.  
  270.     /*
  271.      * from tclXprocess.c
  272.      */
  273. #ifdef macintosh
  274.     Tcl_CreateCommand (interp, "execl", TclX_MacUnImpedErr, 
  275.                        (ClientData) NULL, (void (*)()) NULL);
  276.     Tcl_CreateCommand (interp, "fork", TclX_MacUnImpedErr, 
  277.                        (ClientData) NULL, (void (*)()) NULL);
  278.     Tcl_CreateCommand (interp, "wait", TclX_MacUnImpedErr,
  279.                        (ClientData) NULL, (void (*)()) NULL);
  280. #else
  281.     Tcl_CreateCommand (interp, "execl", Tcl_ExeclCmd,
  282.                        (ClientData) NULL, (void (*)()) NULL);
  283.     Tcl_CreateCommand (interp, "fork", Tcl_ForkCmd,
  284.                        (ClientData) NULL, (void (*)()) NULL);
  285.     Tcl_CreateCommand (interp, "wait", Tcl_WaitCmd,
  286.                        (ClientData) NULL, (void (*)()) NULL);
  287. #endif
  288.  
  289.     /*
  290.      * from tclXselect.c
  291.      */
  292. #ifdef macintosh
  293.     Tcl_CreateCommand (interp, "select", TclX_MacUnImpedErr, 
  294.                        (ClientData) NULL, (void (*)()) NULL);
  295. #else
  296.     Tcl_CreateCommand (interp, "select", Tcl_SelectCmd,
  297.                        (ClientData) NULL, (void (*)()) NULL);
  298. #endif
  299.  
  300.     /*
  301.      * from tclXsignal.c
  302.      */
  303. #ifdef macintosh
  304.     Tcl_CreateCommand (interp, "kill", TclX_MacUnImpedErr,
  305.                        (ClientData) NULL, (void (*)()) NULL);
  306.     Tcl_CreateCommand (interp, "signal", TclX_MacUnImpedErr,
  307.                        (ClientData) NULL, (void (*)()) NULL);
  308. #else
  309.     Tcl_InitSignalHandling (interp);
  310. #endif
  311.  
  312.     /*
  313.      * from tclXprofile.c
  314.      */
  315.     Tcl_InitProfile (interp);
  316.  
  317.     /*
  318.      * from tclXstring.c
  319.      */
  320.     Tcl_CreateCommand(interp, "cindex", Tcl_CindexCmd, 
  321.                      (ClientData) NULL, (void (*)()) NULL);
  322.     Tcl_CreateCommand(interp, "clength", Tcl_ClengthCmd, 
  323.                      (ClientData) NULL, (void (*)()) NULL);
  324.     Tcl_CreateCommand(interp, "crange", Tcl_CrangeCmd, 
  325.                      (ClientData) NULL, (void (*)()) NULL);
  326.     Tcl_CreateCommand(interp, "csubstr", Tcl_CrangeCmd, 
  327.                      (ClientData) NULL, (void (*)()) NULL);
  328.     Tcl_CreateCommand(interp, "replicate", Tcl_ReplicateCmd, 
  329.                      (ClientData) NULL, (void (*)()) NULL);
  330.     Tcl_CreateCommand (interp, "translit", Tcl_TranslitCmd,
  331.                        (ClientData) NULL, (void (*)()) NULL);
  332.     Tcl_CreateCommand (interp, "ctype", Tcl_CtypeCmd,
  333.                        (ClientData) NULL, (void (*)()) NULL);
  334.     Tcl_CreateCommand (interp, "ctoken", Tcl_CtokenCmd,
  335.                        (ClientData) NULL, (void (*)()) NULL);
  336.  
  337.     /*
  338.      * from tclXunixcmds.c
  339.      */
  340. #ifdef macintosh
  341. {
  342. extern int TclMac_RM();
  343.  
  344.     Tcl_CreateCommand (interp, "system", TclX_MacUnImpedErr, 
  345.                        (ClientData) NULL, (void (*)()) NULL);
  346.     Tcl_CreateCommand (interp, "times", TclX_MacUnImpedErr, 
  347.                        (ClientData) NULL, (void (*)()) NULL);
  348.     Tcl_CreateCommand (interp, "umask", TclX_MacUnImpedOK, 
  349.                        (ClientData) NULL, (void (*)()) NULL);
  350.     Tcl_CreateCommand (interp, "link", TclX_MacUnImpedErr, 
  351.                        (ClientData) NULL, (void (*)()) NULL);
  352.     Tcl_CreateCommand (interp, "unlink", TclMac_RM, 
  353.                        (ClientData) NULL, (void (*)()) NULL);
  354.     Tcl_CreateCommand (interp, "alarm", TclX_MacUnImpedErr, 
  355.                        (ClientData) NULL, (void (*)()) NULL);
  356.     Tcl_CreateCommand (interp, "sleep", TclX_MacUnImpedErr, 
  357.                        (ClientData) NULL, (void (*)()) NULL);
  358. }
  359. #else
  360.     Tcl_CreateCommand (interp, "system", Tcl_SystemCmd,
  361.                        (ClientData) NULL, (void (*)()) NULL);
  362.     Tcl_CreateCommand (interp, "times", Tcl_TimesCmd,
  363.                        (ClientData) NULL, (void (*)()) NULL);
  364.     Tcl_CreateCommand (interp, "umask", Tcl_UmaskCmd,
  365.                        (ClientData) NULL, (void (*)()) NULL);
  366.     Tcl_CreateCommand (interp, "link", Tcl_LinkCmd,
  367.                        (ClientData) NULL, (void (*)()) NULL);
  368.     Tcl_CreateCommand (interp, "unlink", Tcl_UnlinkCmd,
  369.                        (ClientData) NULL, (void (*)()) NULL);
  370.     Tcl_CreateCommand (interp, "mkdir", Tcl_MkdirCmd,
  371.                        (ClientData) NULL, (void (*)()) NULL);
  372.     Tcl_CreateCommand (interp, "rmdir", Tcl_RmdirCmd,
  373.                        (ClientData) NULL, (void (*)()) NULL);
  374.     Tcl_CreateCommand (interp, "alarm", Tcl_AlarmCmd,
  375.                        (ClientData) NULL, (void (*)()) NULL);
  376.     Tcl_CreateCommand (interp, "sleep", Tcl_SleepCmd,
  377.                        (ClientData) NULL,(void (*)()) NULL);
  378. #endif
  379.  
  380.     /*
  381.      * from tclXserver.c
  382.      */
  383. #ifdef macintosh
  384.     Tcl_CreateCommand (interp, "server_open", TclX_MacUnImpedErr, 
  385.                        (ClientData) NULL, (void (*)()) NULL);
  386. #else
  387.     Tcl_CreateCommand (interp, "server_open", Tcl_ServerOpenCmd,
  388.                        (ClientData) NULL, (void (*)()) NULL);
  389. #endif
  390.     }
  391.  
  392. /*
  393.  *-----------------------------------------------------------------------------
  394.  *
  395.  * Tcl_AddExtendedLibCmds --
  396.  *
  397.  *   Add the Extended Tcl library management commands.  These override the
  398.  * standard Tcl procedures.
  399.  *-----------------------------------------------------------------------------
  400.  */
  401. void
  402. Tcl_AddExtendedLibCmds (interp)
  403.     Tcl_Interp *interp;
  404.     {
  405.     /*
  406.      * from tclXlib.c
  407.      */
  408.     Tcl_InitLibrary (interp);
  409.     }
  410.     
  411.  
  412. /*
  413.  *-----------------------------------------------------------------------------
  414.  *
  415.  * Tcl_CreateExtendedInterp --
  416.  *
  417.  *      Create a new TCL command interpreter and initialize all of the
  418.  *      extended Tcl commands..
  419.  *
  420.  * Returns:
  421.  *      The return value is a token for the interpreter.
  422.  *-----------------------------------------------------------------------------
  423.  */
  424.  
  425. int
  426. Tcl_InitExtended (interp)
  427.     Tcl_Interp *interp;
  428.     {
  429.     if (interp != NULL)
  430.         {
  431.         Tcl_AddExtendedCmds (interp);
  432.         Tcl_AddExtendedLibCmds (interp);
  433.         }
  434.     
  435.     return TCL_OK;
  436.     }
  437.  
  438. Tcl_Interp *
  439. Tcl_CreateExtendedInterp ()
  440.     {
  441.     Tcl_Interp *interp;
  442.  
  443.     interp = Tcl_CreateInterp();
  444.  
  445.     if (interp != NULL)
  446.         {
  447.         Tcl_InitExtended(interp);
  448.         }
  449.     
  450.     return interp;
  451.     }
  452.