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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tk/] [unix/] [tkUnixInit.c] - Blame information for rev 1770

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

Line No. Rev Author Line
1 578 markom
/*
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
 * RCS: @(#) $Id: tkUnixInit.c,v 1.1.1.1 2002-01-16 10:26:01 markom Exp $
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
 
43
int
44
TkpInit(interp)
45
    Tcl_Interp *interp;
46
{
47
    TkCreateXEventSource();
48
    return Tcl_Eval(interp, initScript);
49
}
50
 
51
/*
52
 *----------------------------------------------------------------------
53
 *
54
 * TkpGetAppName --
55
 *
56
 *      Retrieves the name of the current application from a platform
57
 *      specific location.  For Unix, the application name is the tail
58
 *      of the path contained in the tcl variable argv0.
59
 *
60
 * Results:
61
 *      Returns the application name in the given Tcl_DString.
62
 *
63
 * Side effects:
64
 *      None.
65
 *
66
 *----------------------------------------------------------------------
67
 */
68
 
69
void
70
TkpGetAppName(interp, namePtr)
71
    Tcl_Interp *interp;
72
    Tcl_DString *namePtr;       /* A previously initialized Tcl_DString. */
73
{
74
    char *p, *name;
75
 
76
    name = Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY);
77
    if ((name == NULL) || (*name == 0)) {
78
        name = "tk";
79
    } else {
80
        p = strrchr(name, '/');
81
        if (p != NULL) {
82
            name = p+1;
83
        }
84
    }
85
    Tcl_DStringAppend(namePtr, name, -1);
86
}
87
 
88
/*
89
 *----------------------------------------------------------------------
90
 *
91
 * TkpDisplayWarning --
92
 *
93
 *      This routines is called from Tk_Main to display warning
94
 *      messages that occur during startup.
95
 *
96
 * Results:
97
 *      None.
98
 *
99
 * Side effects:
100
 *      Generates messages on stdout.
101
 *
102
 *----------------------------------------------------------------------
103
 */
104
 
105
void
106
TkpDisplayWarning(msg, title)
107
    char *msg;                  /* Message to be displayed. */
108
    char *title;                /* Title of warning. */
109
{
110
    Tcl_Channel errChannel = Tcl_GetStdChannel(TCL_STDERR);
111
    if (errChannel) {
112
        Tcl_Write(errChannel, title, -1);
113
        Tcl_Write(errChannel, ": ", 2);
114
        Tcl_Write(errChannel, msg, -1);
115
        Tcl_Write(errChannel, "\n", 1);
116
    }
117
}

powered by: WebSVN 2.1.0

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