OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tix/] [unix/] [samAppInit.c] - Blame information for rev 1780

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
/*
2
 * samAppInit.c --
3
 *
4
 *      Provides a default version of the Tcl_AppInit procedure for
5
 *      use in stand-alone Tcl, Tk or Tix applications.
6
 *
7
 * Copyright (c) 1996, Expert Interface Technologies
8
 * Copyright (c) 1995 Ioi K Lam
9
 * Copyright (c) 1993 The Regents of the University of California.
10
 * Copyright (c) 1994 Sun Microsystems, Inc.
11
 *
12
 * See the file "license.terms" for information on usage and redistribution
13
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14
 */
15
 
16
#include <tcl.h>
17
 
18
#ifdef USE_TIX
19
#  ifndef USE_TK
20
#  define USE_TK
21
#  endif
22
#endif
23
 
24
#ifdef USE_TK
25
#include <tk.h>
26
#endif
27
 
28
#ifdef USE_TIX
29
#  include <tix.h>
30
#else
31
#  if (TCL_MAJOR_VERSION > 7)
32
#    define TCL_7_5_OR_LATER
33
#  else
34
#    if ((TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION >= 5))
35
#      define TCL_7_5_OR_LATER
36
#    endif
37
#  endif
38
#endif
39
 
40
EXTERN int              Tclsam_Init _ANSI_ARGS_((Tcl_Interp *interp));
41
EXTERN int              Tksam_Init _ANSI_ARGS_((Tcl_Interp *interp));
42
EXTERN int              Tixsam_Init _ANSI_ARGS_((Tcl_Interp *interp));
43
 
44
/*
45
 * The following variable is a special hack that is needed in order for
46
 * Sun shared libraries to be used for Tcl.
47
 */
48
 
49
extern int matherr();
50
int *tclDummyMathPtr = (int *) matherr;
51
 
52
/*
53
 *----------------------------------------------------------------------
54
 *
55
 * main --
56
 *
57
 *      This is the main program for the application.
58
 *
59
 * Results:
60
 *      None: Tk_Main never returns here, so this procedure never
61
 *      returns either.
62
 *
63
 * Side effects:
64
 *      Whatever the application does.
65
 *
66
 *----------------------------------------------------------------------
67
 */
68
 
69
int
70
main(argc, argv)
71
    int argc;                   /* Number of command-line arguments. */
72
    char **argv;                /* Values of command-line arguments. */
73
{
74
#ifdef USE_TK
75
    Tk_Main(argc, argv, Tcl_AppInit);
76
#else
77
    Tcl_Main(argc, argv, Tcl_AppInit);
78
#endif
79
 
80
    return 0;                    /* Needed only to prevent compiler warning. */
81
}
82
 
83
/*
84
 *----------------------------------------------------------------------
85
 *
86
 * Tcl_AppInit --
87
 *
88
 *      This procedure performs application-specific initialization.
89
 *      Most applications, especially those that incorporate additional
90
 *      packages, will have their own version of this procedure.
91
 *
92
 * Results:
93
 *      Returns a standard Tcl completion code, and leaves an error
94
 *      message in interp->result if an error occurs.
95
 *
96
 * Side effects:
97
 *      Depends on the startup script.
98
 *
99
 *----------------------------------------------------------------------
100
 */
101
 
102
int
103
Tcl_AppInit(interp)
104
    Tcl_Interp *interp;         /* Interpreter for application. */
105
{
106
    if (Tclsam_Init(interp) == TCL_ERROR) {
107
        return TCL_ERROR;
108
    }
109
#ifdef USE_TK
110
    if (Tksam_Init(interp) == TCL_ERROR) {
111
        return TCL_ERROR;
112
    }
113
#endif
114
 
115
#ifdef USE_TIX
116
    if (Tixsam_Init(interp) == TCL_ERROR) {
117
        return TCL_ERROR;
118
    }
119
#endif
120
 
121
#ifdef TCL_7_5_OR_LATER
122
    Tcl_StaticPackage(interp, "Tclsam", Tclsam_Init, NULL);
123
#ifdef USE_TK
124
    Tcl_StaticPackage(interp, "Tk",     Tk_Init,     NULL);
125
    Tcl_StaticPackage(interp, "Tksam",  Tksam_Init,  NULL);
126
#endif
127
#ifdef USE_TIX
128
    Tcl_StaticPackage(interp, "Tix",    Tix_Init,    NULL);
129
    Tcl_StaticPackage(interp, "Tixsam", Tixsam_Init, NULL);
130
#endif
131
#endif
132
 
133
    /*
134
     * Call the init procedures for included packages.  Each call should
135
     * look like this:
136
     *
137
     * if (Mod_Init(interp) == TCL_ERROR) {
138
     *     return TCL_ERROR;
139
     * }
140
     *
141
     * where "Mod" is the name of the module.
142
     */
143
 
144
    /*
145
     * Call Tcl_CreateCommand for application-specific commands, if
146
     * they weren't already created by the init procedures called above.
147
     */
148
 
149
    /*
150
     * Specify a user-specific startup file to invoke if the application
151
     * is run interactively.  Typically the startup file is "~/.apprc"
152
     * where "app" is the name of the application.  If this line is deleted
153
     * then no user-specific startup file will be run under any conditions.
154
     */
155
#if defined(USE_TIX)
156
#  define RC_FILENAME "~/.tixwishrc"
157
#else
158
#  if defined(USE_TK)
159
#    define RC_FILENAME "~/.wishrc"
160
#  else
161
#    define RC_FILENAME "~/.tclshrc"
162
#  endif
163
#endif
164
 
165
#ifdef TCL_7_5_OR_LATER
166
    /*
167
     * Starting from TCL 7.5, the symbol tcl_rcFileName is no longer
168
     * exported by libtcl.a. Instead, this variable must be set using
169
     * a TCL global variable
170
     */
171
    Tcl_SetVar(interp, "tcl_rcFileName", RC_FILENAME, TCL_GLOBAL_ONLY);
172
#else
173
    tcl_RcFileName = RC_FILENAME;
174
#endif
175
 
176
    return TCL_OK;
177
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.