95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
-
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
-
-
-
-
|
#
# NOTE: This procedure returns non-zero if the specified string value
# looks like a Harpy (script) certificate. The value argument
# is the string to check.
#
# <public>
proc isHarpyCertificate { value } {
if {[string length $value] == 0 || [string first [string trim {
if {[string length $value] == 0 || ([string first [string trim {
<?xml version="1.0" encoding="utf-8"?>
}] $value] == 0 && [string first [string trim {
<Certificate xmlns="https://eagle.to/2011/harpy"
}] $value] != -1} then {
}] $value] != -1)} then {
return true
} else {
return false
}
}
#
# NOTE: This procedure returns non-zero if the specified string value
# looks like a PGP signature. The value argument is the string
# to check.
#
# <public>
proc isPgpSignature { value } {
if {[string length $value] == 0 || [string first [string trim {
-----BEGIN PGP SIGNATURE-----
}] $value] != -1} then {
}] $value] == 0} then {
return true
} else {
return false
}
}
#
# NOTE: This procedure returns the fully qualified name of the directory
# where temporary files should be written. The envVarName argument
# is an optional extra environment variable to check (first).
#
proc getFileTempDirectory { {envVarName ""} } {
global env
if {[string length $envVarName] > 0 && \
[info exists env($envVarName)]} then {
return $env($envVarName)
} elseif {[info exists env(TEMP)]} then {
return $env(TEMP)
} elseif {[info exists env(TMP)]} then {
return $env(TMP)
} else {
error [appendArgs \
"please set " $envVarName \
" (via environment) to temporary directory"]
}
}
#
# NOTE: This procedure returns a unique temporary file name. A script
# error is raised if this task cannot be accomplished. There are
# no arguments.
#
proc getFileTempName {} {
if {[isEagle]} then {
return [file tempname]
} else {
global env
if {[info exists env(PKGR_TEMP)]} then {
set directory $env(PKGD_TEMP)
} elseif {[info exists env(TEMP)]} then {
set directory $env(TEMP)
} elseif {[info exists env(TMP)]} then {
set directory $env(TMP)
set directory [getFileTempDirectory PKGR_TEMP]
} else {
error "please set PKGR_TEMP (via environment) to temporary directory"
}
set counter [expr {[pid] ^ int(rand() * 0xFFFF)}]
while {1} {
set fileNameOnly [format tcl%04X.tmp $counter]
set fileName [file join $directory $fileNameOnly]
if {![file exists $fileName]} then {
|