~ubuntu-branches/debian/sid/tk-html3/sid

« back to all changes in this revision

Viewing changes to src/main.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2012-03-02 18:45:00 UTC
  • Revision ID: package-import@ubuntu.com-20120302184500-np17d7d6gd1jedj0
Tags: upstream-3.0~fossil20110109
ImportĀ upstreamĀ versionĀ 3.0~fossil20110109

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * tkAppInit.c --
 
3
 *
 
4
 *      Provides a default version of the Tcl_AppInit procedure for
 
5
 *      use in wish and similar Tk-based applications.
 
6
 *
 
7
 *--------------------------------------------------------------------------
 
8
 * Copyright (c) 1993 The Regents of the University of California.
 
9
 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
 
10
 * Copyright (c) 2005 Eolas Technologies Inc.
 
11
 * All rights reserved.
 
12
 *
 
13
 * This Open Source project was made possible through the financial support
 
14
 * of Eolas Technologies Inc.
 
15
 * 
 
16
 * Redistribution and use in source and binary forms, with or without
 
17
 * modification, are permitted provided that the following conditions are met:
 
18
 * 
 
19
 *     * Redistributions of source code must retain the above copyright
 
20
 *       notice, this list of conditions and the following disclaimer.
 
21
 *     * Redistributions in binary form must reproduce the above copyright
 
22
 *       notice, this list of conditions and the following disclaimer in the
 
23
 *       documentation and/or other materials provided with the distribution.
 
24
 *     * Neither the name of the <ORGANIZATION> nor the names of its
 
25
 *       contributors may be used to endorse or promote products derived from
 
26
 *       this software without specific prior written permission.
 
27
 * 
 
28
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
29
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
30
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
31
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
32
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
33
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
34
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
35
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
36
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
37
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
38
 * POSSIBILITY OF SUCH DAMAGE.
 
39
 */
 
40
static const char rcsid[] = "$Id: main.c,v 1.9 2007/09/28 14:14:56 danielk1977 Exp $";
 
41
 
 
42
#undef USE_TCL_STUBS
 
43
#undef USE_TK_STUBS
 
44
 
 
45
#include "tk.h"
 
46
#include "locale.h"
 
47
 
 
48
#ifdef TK_TEST
 
49
extern int              Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
 
50
#endif /* TK_TEST */
 
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
    /*
 
75
     * The following #if block allows you to change the AppInit
 
76
     * function by using a #define of TCL_LOCAL_APPINIT instead
 
77
     * of rewriting this entire file.  The #if checks for that
 
78
     * #define and uses Tcl_AppInit if it doesn't exist.
 
79
     */
 
80
    
 
81
#ifndef TK_LOCAL_APPINIT
 
82
#define TK_LOCAL_APPINIT Tcl_AppInit    
 
83
#endif
 
84
    extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp));
 
85
    
 
86
    /*
 
87
     * The following #if block allows you to change how Tcl finds the startup
 
88
     * script, prime the library or encoding paths, fiddle with the argv,
 
89
     * etc., without needing to rewrite Tk_Main()
 
90
     */
 
91
    
 
92
#ifdef TK_LOCAL_MAIN_HOOK
 
93
    extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
 
94
    TK_LOCAL_MAIN_HOOK(&argc, &argv);
 
95
#endif
 
96
 
 
97
/* Tcl_InitStubs(0, "8.4", 0); */
 
98
/* Tk_InitStubs(0, "8.4", 0);  */
 
99
 
 
100
    Tk_Main(argc, argv, TK_LOCAL_APPINIT);
 
101
    return 0;                   /* Needed only to prevent compiler warning. */
 
102
}
 
103
 
 
104
/*
 
105
 *----------------------------------------------------------------------
 
106
 *
 
107
 * Tcl_AppInit --
 
108
 *
 
109
 *      This procedure performs application-specific initialization.
 
110
 *      Most applications, especially those that incorporate additional
 
111
 *      packages, will have their own version of this procedure.
 
112
 *
 
113
 * Results:
 
114
 *      Returns a standard Tcl completion code, and leaves an error
 
115
 *      message in the interp's result if an error occurs.
 
116
 *
 
117
 * Side effects:
 
118
 *      Depends on the startup script.
 
119
 *
 
120
 *----------------------------------------------------------------------
 
121
 */
 
122
 
 
123
 
 
124
int
 
125
Tcl_AppInit(interp)
 
126
    Tcl_Interp *interp;         /* Interpreter for application. */
 
127
{
 
128
    int Tkhtml_Init(Tcl_Interp *);
 
129
    int Tkhtml_SafeInit(Tcl_Interp *);
 
130
 
 
131
    if (Tcl_Init(interp) == TCL_ERROR) {
 
132
        return TCL_ERROR;
 
133
    }
 
134
    if (Tk_Init(interp) == TCL_ERROR) {
 
135
        return TCL_ERROR;
 
136
    }
 
137
    Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit);
 
138
#ifdef TK_TEST
 
139
    if (Tktest_Init(interp) == TCL_ERROR) {
 
140
        return TCL_ERROR;
 
141
    }
 
142
    Tcl_StaticPackage(interp, "Tktest", Tktest_Init,
 
143
            (Tcl_PackageInitProc *) NULL);
 
144
#endif /* TK_TEST */
 
145
 
 
146
     if (Tkhtml_Init(interp) == TCL_ERROR) {
 
147
         return TCL_ERROR;
 
148
     }
 
149
    Tcl_StaticPackage(interp, "Tkhtml", Tkhtml_Init, Tkhtml_SafeInit);
 
150
 
 
151
    /*
 
152
     * Specify a user-specific startup file to invoke if the application
 
153
     * is run interactively.  Typically the startup file is "~/.apprc"
 
154
     * where "app" is the name of the application.  If this line is deleted
 
155
     * then no user-specific startup file will be run under any conditions.
 
156
     */
 
157
 
 
158
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY);
 
159
    return TCL_OK;
 
160
}