Initial revision
[ir-tcl-moved-to-github.git] / tclmain.c
1 /*
2  * IR toolkit for tcl/tk
3  * (c) Index Data 1995
4  *
5  * $Id: tclmain.c,v 1.1 1995-03-06 17:05:34 adam Exp $
6  */
7
8 #include <tcl.h>
9
10 #include "ir-tcl.h"
11
12 static char *fileName = NULL;
13
14 int Tcl_AppInit (Tcl_Interp *interp)
15 {
16     if (Tcl_Init(interp) == TCL_ERROR)
17         return TCL_ERROR;
18     if (ir_tcl_init(interp) == TCL_ERROR)
19         return TCL_ERROR;
20     return TCL_OK;
21 }
22
23 int main (int argc, char **argv)
24 {
25     Tcl_Interp *interp;
26     int code;
27
28     interp = Tcl_CreateInterp();
29
30     if (argc != 2)
31     {
32         fprintf (stderr, "Script file expected\n");
33         exit (1);
34     }
35     fileName = argv[1];
36     if (fileName == NULL)
37     {
38         fprintf (stderr, "No filename specified\n");
39         exit (1);
40     }
41     if (Tcl_AppInit(interp) != TCL_OK) {
42         fprintf(stderr, "Tcl_AppInit failed: %s\n", interp->result);
43     }    
44     code = Tcl_EvalFile (interp, fileName);
45     if (*interp->result != 0)
46         printf ("%s\n", interp->result);
47     if (code != TCL_OK)
48         exit (1);
49     exit (0);
50 }
51