File: main.C

package info (click to toggle)
speaker 1.0.1-4
  • links: PTS
  • area: main
  • in suites: woody
  • size: 264 kB
  • ctags: 174
  • sloc: cpp: 1,521; tcl: 786; makefile: 91; sh: 22
file content (65 lines) | stat: -rw-r--r-- 1,506 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/************************************************************
*  Main function for the spk Tk interface
************************************************************/
#include "incall.h"
extern "C" {
#include "tk.h"
}

extern ConfigInfo conf;

int GSPK_Init(Tcl_Interp *interp);

int main(int argc, char** argv)
{
    if (argc == 2)
    {
       Tk_Main(argc, argv, Tcl_AppInit);
    } else
    {
       Tk_Window win;
       Tcl_Interp *interp;

//       Tcl_FindExecutable( argv[0] );

       interp = Tcl_CreateInterp();

       if (Tcl_AppInit(interp) != TCL_OK)
       {
         fprintf(stderr, "Could not init application: %s\n", interp->result);
       }

       win = Tk_MainWindow(interp);

       if (Tcl_EvalFile(interp, conf.GSPKPath) != TCL_OK)
       {
         fprintf(stderr, "Could not execute script: %s\n", interp->result);
       }

       Tk_MainLoop();
    }
    return 0;
}

/************************************************************
 * Tcl_AppInit - initialize tck,tk and spk packages
************************************************************/
int Tcl_AppInit(Tcl_Interp *interp)
{
    if (Tcl_Init(interp) == TCL_ERROR) {
        return TCL_ERROR;
    }
    if (Tk_Init(interp) == TCL_ERROR) {
        return TCL_ERROR;
    }

 //   Tcl_StaticPackage(interp, "Tk", Tk_Init, (Tcl_PackageInitProc *) NULL);

    if (GSPK_Init(interp) == TCL_ERROR) {
        return TCL_ERROR;
    }

    Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
    return TCL_OK;
}