Advertisement
vinifr

tclAppInit.c

Aug 7th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.12 KB | None | 0 0
  1. /*
  2.  * tclAppInit.c --
  3.  *
  4.  *  Provides a default version of the main program and Tcl_AppInit
  5.  *  function for Tcl applications (without Tk).
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * Copyright (c) 1994-1997 Sun Microsystems, Inc.
  9.  * Copyright (c) 1998-1999 by Scriptics Corporation.
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution of
  12.  * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  */
  14.  
  15. #include "tcl.h"
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <pthread.h>
  20.  
  21. void *erase_nodes( void *ptr );
  22.  
  23. #ifdef TCL_TEST
  24.  
  25. #include "tclInt.h"
  26.  
  27. extern Tcl_PackageInitProc  Procbodytest_Init;
  28. extern Tcl_PackageInitProc  Procbodytest_SafeInit;
  29. extern Tcl_PackageInitProc  TclObjTest_Init;
  30. extern Tcl_PackageInitProc  Tcltest_Init;
  31.  
  32. #endif /* TCL_TEST */
  33.  
  34. #ifdef TCL_XT_TEST
  35. extern void     XtToolkitInitialize _ANSI_ARGS_((void));
  36. extern int      Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  37. #endif
  38. /*
  39.  *----------------------------------------------------------------------
  40.  *
  41.  * main --
  42.  *
  43.  *  This is the main program for the application.
  44.  *
  45.  * Results:
  46.  *  None: Tcl_Main never returns here, so this function never returns
  47.  *  either.
  48.  *
  49.  * Side effects:
  50.  *  Whatever the application does.
  51.  *
  52.  *----------------------------------------------------------------------
  53.  */
  54.  
  55. int
  56. main(
  57.     int argc,           /* Number of command-line arguments. */
  58.     char **argv)        /* Values of command-line arguments. */
  59. {
  60.     /*
  61.      * The following #if block allows you to change the AppInit function by
  62.      * using a #define of TCL_LOCAL_APPINIT instead of rewriting this entire
  63.      * file. The #if checks for that #define and uses Tcl_AppInit if it does
  64.      * not exist.
  65.      */
  66.  
  67. #ifndef TCL_LOCAL_APPINIT
  68. #define TCL_LOCAL_APPINIT Tcl_AppInit
  69. #endif
  70.     extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
  71.  
  72.     /*
  73.      * The following #if block allows you to change how Tcl finds the startup
  74.      * script, prime the library or encoding paths, fiddle with the argv,
  75.      * etc., without needing to rewrite Tcl_Main()
  76.      */
  77.  
  78. #ifdef TCL_LOCAL_MAIN_HOOK
  79.     extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
  80. #endif
  81.  
  82. #ifdef TCL_XT_TEST
  83.     XtToolkitInitialize();
  84. #endif
  85.  
  86. #ifdef TCL_LOCAL_MAIN_HOOK
  87.     TCL_LOCAL_MAIN_HOOK(&argc, &argv);
  88. #endif
  89.  
  90.     Tcl_Main(argc, argv, TCL_LOCAL_APPINIT);
  91.  
  92.     return 0;           /* Needed only to prevent compiler warning. */
  93. }
  94. /*
  95.  *----------------------------------------------------------------------
  96.  *
  97.  * Tcl_AppInit --
  98.  *
  99.  *  This function performs application-specific initialization. Most
  100.  *  applications, especially those that incorporate additional packages,
  101.  *  will have their own version of this function.
  102.  *
  103.  * Results:
  104.  *  Returns a standard Tcl completion code, and leaves an error message in
  105.  *  the interp's result if an error occurs.
  106.  *
  107.  * Side effects:
  108.  *  Depends on the startup script.
  109.  *
  110.  *----------------------------------------------------------------------
  111.  */
  112.  
  113. int
  114. Tcl_AppInit(
  115.     Tcl_Interp *interp)     /* Interpreter for application. */
  116. {
  117.     if (Tcl_Init(interp) == TCL_ERROR) {
  118.     return TCL_ERROR;
  119.     }
  120.  
  121. #ifdef TCL_TEST
  122. #ifdef TCL_XT_TEST
  123.     if (Tclxttest_Init(interp) == TCL_ERROR) {
  124.     return TCL_ERROR;
  125.     }
  126. #endif
  127.     if (Tcltest_Init(interp) == TCL_ERROR) {
  128.     return TCL_ERROR;
  129.     }
  130.     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
  131.         (Tcl_PackageInitProc *) NULL);
  132.     if (TclObjTest_Init(interp) == TCL_ERROR) {
  133.     return TCL_ERROR;
  134.     }
  135.     if (Procbodytest_Init(interp) == TCL_ERROR) {
  136.     return TCL_ERROR;
  137.     }
  138.     Tcl_StaticPackage(interp, "procbodytest", Procbodytest_Init,
  139.         Procbodytest_SafeInit);
  140. #endif /* TCL_TEST */
  141.  
  142.     /*
  143.      * Call the init functions for included packages. Each call should look
  144.      * like this:
  145.      *
  146.      * if (Mod_Init(interp) == TCL_ERROR) {
  147.      *     return TCL_ERROR;
  148.      * }
  149.      *
  150.      * where "Mod" is the name of the module. (Dynamically-loadable packages
  151.      * should have the same entry-point name.)
  152.      */
  153.  
  154.     /*
  155.      * Call Tcl_CreateCommand for application-specific commands, if they
  156.      * weren't already created by the init functions called above.
  157.      */
  158.  
  159.     /*
  160.      * Specify a user-specific startup file to invoke if the application is
  161.      * run interactively. Typically the startup file is "~/.apprc" where "app"
  162.      * is the name of the application. If this line is deleted then no user-
  163.      * specific startup file will be run under any conditions.
  164.      */
  165.  
  166. #ifdef DJGPP
  167.     Tcl_SetVar(interp, "tcl_rcFileName", "~/tclsh.rc", TCL_GLOBAL_ONLY);
  168. #else
  169.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
  170. #endif
  171.    
  172.     pthread_t thread1;
  173.     const char *message1 = "Thread 1";
  174.     int iret1;
  175.    
  176.     iret1 = pthread_create( &thread1, NULL, erase_nodes, (void*) message1);
  177.     if(iret1) {
  178.         fprintf(stderr,"Error - pthread_create() return code: %d\n",iret1);
  179.     }      
  180.    
  181.     printf("INIT erase_nodes()\n");
  182.  
  183.     return TCL_OK;
  184. }
  185. /*
  186.  * Local Variables:
  187.  * mode: c
  188.  * c-basic-offset: 4
  189.  * fill-column: 78
  190.  * End:
  191.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement