root/tk-8.0/tags/rat_4_2_6/unix/tkUnixInit.c @ 1291

Revision 1291, 4.8 KB (checked in by anonymous, 14 years ago)

This commit was manufactured by cvs2svn to create tag 'rat_4_2_6'.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2 * tkUnixInit.c --
3 *
4 *      This file contains Unix-specific interpreter initialization
5 *      functions.
6 *
7 * Copyright (c) 1995-1997 Sun Microsystems, Inc.
8 *
9 * See the file "license.terms" for information on usage and redistribution
10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 *
12 * SCCS: @(#) tkUnixInit.c 1.24 97/07/24 14:46:09
13 */
14
15#include "tkInt.h"
16#include "tkUnixInt.h"
17
18/*
19 * The Init script (common to Windows and Unix platforms) is
20 * defined in tkInitScript.h
21 */
22#include "tkInitScript.h"
23
24
25/*
26 *----------------------------------------------------------------------
27 *
28 * TkpInit --
29 *
30 *      Performs Unix-specific interpreter initialization related to the
31 *      tk_library variable.
32 *
33 * Results:
34 *      Returns a standard Tcl result.  Leaves an error message or result
35 *      in interp->result.
36 *
37 * Side effects:
38 *      Sets "tk_library" Tcl variable, runs "tk.tcl" script.
39 *
40 *----------------------------------------------------------------------
41 */
42
43extern char lib_tk[];
44extern char lib_button[];
45extern char lib_entry[];
46extern char lib_listbox[];
47extern char lib_menu[];
48extern char lib_scale[];
49extern char lib_scrlbar[];
50extern char lib_text[];
51
52extern char lib_bgerror[];
53extern char lib_clrpick[];
54extern char lib_comdlg[];
55extern char lib_dialog[];
56extern char lib_focus[];
57extern char lib_msgbox[];
58extern char lib_obsolete[];
59extern char lib_optMenu[];
60extern char lib_palette[];
61extern char lib_safetk[];
62extern char lib_tearoff[];
63extern char lib_tkfbox[];
64extern char lib_xmfbox[];
65
66int
67TkpInit(interp)
68    Tcl_Interp *interp;
69{
70    TkCreateXEventSource();
71    if (Tcl_Eval(interp, lib_bgerror) != TCL_OK) {
72        return TCL_ERROR;
73    }
74    if (Tcl_Eval(interp, lib_clrpick) != TCL_OK) {
75        return TCL_ERROR;
76    }
77    if (Tcl_Eval(interp, lib_comdlg) != TCL_OK) {
78        return TCL_ERROR;
79    }
80    if (Tcl_Eval(interp, lib_dialog) != TCL_OK) {
81        return TCL_ERROR;
82    }
83    if (Tcl_Eval(interp, lib_focus) != TCL_OK) {
84        return TCL_ERROR;
85    }
86    if (Tcl_Eval(interp, lib_msgbox) != TCL_OK) {
87        return TCL_ERROR;
88    }
89    if (Tcl_Eval(interp, lib_obsolete) != TCL_OK) {
90        return TCL_ERROR;
91    }
92    if (Tcl_Eval(interp, lib_optMenu) != TCL_OK) {
93        return TCL_ERROR;
94    }
95    if (Tcl_Eval(interp, lib_palette) != TCL_OK) {
96        return TCL_ERROR;
97    }
98    if (Tcl_Eval(interp, lib_safetk) != TCL_OK) {
99        return TCL_ERROR;
100    }
101    if (Tcl_Eval(interp, lib_tearoff) != TCL_OK) {
102        return TCL_ERROR;
103    }
104    if (Tcl_Eval(interp, lib_tkfbox) != TCL_OK) {
105        return TCL_ERROR;
106    }
107    if (Tcl_Eval(interp, lib_xmfbox) != TCL_OK) {
108        return TCL_ERROR;
109    }
110
111    if (Tcl_Eval(interp, initScript) != TCL_OK) {
112        return TCL_ERROR;
113    }
114    if (Tcl_Eval(interp, lib_tk) != TCL_OK) {
115        return TCL_ERROR;
116    }
117    if (Tcl_Eval(interp, lib_button) != TCL_OK) {
118        return TCL_ERROR;
119    }
120    if (Tcl_Eval(interp, lib_entry) != TCL_OK) {
121        return TCL_ERROR;
122    }
123    if (Tcl_Eval(interp, lib_listbox) != TCL_OK) {
124        return TCL_ERROR;
125    }
126    if (Tcl_Eval(interp, lib_menu) != TCL_OK) {
127        return TCL_ERROR;
128    }
129    if (Tcl_Eval(interp, lib_scale) != TCL_OK) {
130        return TCL_ERROR;
131    }
132    if (Tcl_Eval(interp, lib_scrlbar) != TCL_OK) {
133        return TCL_ERROR;
134    }
135    if (Tcl_Eval(interp, lib_text) != TCL_OK) {
136        return TCL_ERROR;
137    }
138
139    return TCL_OK;
140}
141
142/*
143 *----------------------------------------------------------------------
144 *
145 * TkpGetAppName --
146 *
147 *      Retrieves the name of the current application from a platform
148 *      specific location.  For Unix, the application name is the tail
149 *      of the path contained in the tcl variable argv0.
150 *
151 * Results:
152 *      Returns the application name in the given Tcl_DString.
153 *
154 * Side effects:
155 *      None.
156 *
157 *----------------------------------------------------------------------
158 */
159
160void
161TkpGetAppName(interp, namePtr)
162    Tcl_Interp *interp;
163    Tcl_DString *namePtr;       /* A previously initialized Tcl_DString. */
164{
165    char *p, *name;
166
167    name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
168    if ((name == NULL) || (*name == 0)) {
169        name = "tk";
170    } else {
171        p = strrchr(name, '/');
172        if (p != NULL) {
173            name = p+1;
174        }
175    }
176    Tcl_DStringAppend(namePtr, name, -1);
177}
178
179/*
180 *----------------------------------------------------------------------
181 *
182 * TkpDisplayWarning --
183 *
184 *      This routines is called from Tk_Main to display warning
185 *      messages that occur during startup.
186 *
187 * Results:
188 *      None.
189 *
190 * Side effects:
191 *      Generates messages on stdout.
192 *
193 *----------------------------------------------------------------------
194 */
195
196void
197TkpDisplayWarning(msg, title)
198    char *msg;                  /* Message to be displayed. */
199    char *title;                /* Title of warning. */
200{
201    Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR);
202    if (errChannel) {
203        Tcl_Write(errChannel, title, -1);
204        Tcl_Write(errChannel, ": ", 2);
205        Tcl_Write(errChannel, msg, -1);
206        Tcl_Write(errChannel, "\n", 1);
207    }
208}
Note: See TracBrowser for help on using the browser.