File: owtclInitScript.h

package info (click to toggle)
owfs 3.2p4%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 8,144 kB
  • sloc: ansic: 66,801; pascal: 5,957; tcl: 2,688; makefile: 1,348; python: 1,114; sh: 715; cs: 623; php: 600; perl: 587; java: 404; ruby: 289; cpp: 105; asm: 102; xml: 53
file content (73 lines) | stat: -rw-r--r-- 2,178 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// -*- C++ -*-
// File: owtclInitScript.h
//
// Created: Mon Jan 10 22:53:33 2005
//

/*
 * The following string is the startup script executed when the ow is
 * loaded.  It looks on disk in several different directories for a script
 * "ow.tcl" that is compatible with this version of owtcl.
 */

static char owtclInitScript[] = "if {[info proc owtclInit]==\"\"} {\n\
  proc owtclInit {} {\n\
    global tcl_pkgPath errorInfo env\n\
    rename owtclInit {}\n\
    set errors {}\n\
    if {![info exists env(OWTCL_LIBRARY_FILE)]} {\n\
	set env(OWTCL_LIBRARY_FILE) ow.tcl\n\
    }\n\
    if {[info exists env(OWTCL_LIBRARY)]} {\n\
	lappend dirs $env(OWTCL_LIBRARY)\n\
    }\n\
    lappend dirs " OWTCL_PACKAGE_PATH "\n\
    if {[info exists tcl_pkgPath]} {\n\
	foreach i $tcl_pkgPath {\n\
	    lappend dirs [file join $i owtcl-" OWTCL_VERSION "] \\\n\
		[file join $i owtcl] $i\n\
	}\n\
    }\n\
    lappend dirs [pwd]\n\
    foreach i $dirs {\n\
	set try [file join $i $env(OWTCL_LIBRARY_FILE)]\n\
	if {[file exists $try]} {\n\
	    if {![catch {uplevel #0 [list source $try]} msg]} {\n\
		set env(OWTCL_LIBRARY) $i\n\
		return\n\
	    } else {\n\
		append errors \"$try: $msg\n$errorInfo\n\"\n\
	    }\n\
	}\n\
    }\n"
#ifdef NO_EMBEDDED_RUNTIME
	"    set msg \"Can't find a $env(OWTCL_LIBRARY_FILE) in the following directories: \n\"\n\
    append msg \"    $dirs\n\n$errors\n\n\"\n\
    append msg \"This probably means that owtcl wasn't installed properly.\"\n\
    return -code error $msg\n"
#else
	"    set env(OWTCL_LIBRARY) EMBEDDED_RUNTIME\n" "    uplevel #0 {"
#	include "ow.tcl.h"
	"    }\n"
#endif
	"  }\n\
}\n\
owtclInit";

/*
 * The init script can't make certain calls in a safe interpreter,
 * so we always have to use the embedded runtime for it
 */
static char owtclSafeInitScript[] = "if {[info proc owtclInit]==\"\"} {\n\
  proc owtclInit {} {\n\
    set env(OWTCL_LIBRARY) EMBEDDED_RUNTIME\n"
#ifdef NO_EMBEDDED_RUNTIME
	"    append msg \"owtcl requires embedded runtime to be compiled for\"\n\
    append msg \" use in safe interpreters\"\n\
    return -code error $msg\n"
#endif
	"    uplevel #0 {"
#	include "ow.tcl.h"
	"    }" "  }\n\
}\n\
owtclInit";