This file is indexed.

/usr/share/tkgate/scripts/library.tcl is in tkgate-data 2.0~b10-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#   Copyright (C) 1987-2009 by Jeffery P. Hansen
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Last edit by hansen on Tue Mar 17 05:44:35 2009
#

namespace eval LibraryMgr {
  variable libTitle
  variable libStatus
  variable libReqStatus
  variable leftMargin 8
  variable topMargin 8
  variable boldFont checklistBoldFont
  variable normalFont checklistFont
  variable lineHeight
  variable lineAscent
  variable lineDescent
  variable boxSize
  variable libraryList
  variable yPos

  #############################################################################
  #
  # Called at start-up to load the base libraries
  #
  proc loadBaseLibraries {} {
    global tkg_simVLibNames

    foreach name $tkg_simVLibNames {
      catch { gat_loadLibrary $name }
    }
  }

  #############################################################################
  #
  # Get the title of a library file.
  #
  proc gettitle {name} {
    set f [open $name]
    if { $f == "" } { return "" }

    while {![eof $f]} {
      set s [gets $f]

      if {[regexp "//: *property *title *= *(.*)" $s all title]} {
	close $f
	return $title
      }
    }
    close $f
    return ""
  }

  #############################################################################
  #
  # Scan the library path for the list of available libraries.
  #
  proc scanlibs args {
    global tkg_simVLibPath
    variable libTitle
    variable libStatus
    variable libReqStatus

    set path $tkg_simVLibPath
    if {[llength $args] > 0} {
      set path [lindex $args 0] 
    }

    set L {}

    foreach directory $path {
      set directory [namespace eval :: "eval concat $directory"]
      foreach file [glob -nocomplain $directory/*.v] {
	set lib [file rootname [file tail $file]]
	set title [gettitle $file]
	lappend L $lib
	set libTitle($lib) $title
	set libStatus($lib) [gat_libIsLoaded $lib]
	set libReqStatus($lib) $libStatus($lib)
      }
    }
    return [lsort -dictionary $L]
  }

  proc drawBox {w name} {
    variable libStatus
    variable libReqStatus
    variable boxSize
    variable leftMargin
    variable yPos

    set x $leftMargin
    set y $yPos($name)

    $w delete $name.box

    set x2 [expr $x + $boxSize]
    set y2 [expr $y - $boxSize]

    set tags [list box $name.box]
    $w create rectangle $x $y $x2 $y2 -tags $tags -fill white

    if { $libReqStatus($name) != 0} {
      $w create image [expr $x+1] $y -anchor sw -image [gifI checkon.gif] -tags $tags
    }
  }

  #############################################################################
  #
  #
  #
  proc makeLibLine {w name} {
    variable leftMargin
    variable libTitle
    variable libStatus
    variable libReqStatus
    variable lineDescent
    variable boldFont
    variable normalFont
    variable boxSize
    variable yPos

    set x $leftMargin
    set y $yPos($name)

    $w delete $name

    #
    # Draw the box
    #
    set boxTags [list $name box $name.box]
    set x2 [expr $x + $boxSize]
    set y2 [expr $y - $boxSize]
    $w create rectangle $x $y $x2 $y2 -tags $boxTags -fill white
    if { $libReqStatus($name) != 0} {
      $w create image [expr $x+1] $y -anchor sw -image [gifI checkon.gif] -tags $boxTags
    }
    set x [expr $x + $boxSize + [rescale *8]]
    set y [expr $y + $lineDescent]

    #
    # Draw the library name
    #
    $w create text $x $y -text $name -anchor sw -font $boldFont -tags $name
    set x [expr $x + [font measure $boldFont $name]]

    #
    # Draw load/unload status
    #
    if { $libStatus($name) != $libReqStatus($name) } {
      if { $libReqStatus($name) } {
	set status " \[load\]"
      } else {
	set status " \[unload\]"
      }
      $w create text $x $y -text $status -anchor sw -font $boldFont -fill red -tags $name
      set x [expr $x + [font measure $boldFont $status]]
    }

    #
    # Draw the library description
    #
    $w create text $x $y -text " - $libTitle($name)" -anchor sw -font $normalFont -tags $name
  }

  proc toggleBox {w y args} {
    variable lineHeight
    variable libraryList
    variable libReqStatus
    
    set index [expr int($y/$lineHeight-1)]

   if {$index >= [llength $libraryList]} return

    set name [lindex $libraryList $index]

    set libReqStatus($name) [expr !$libReqStatus($name)]

    makeLibLine $w $name
  }

  #############################################################################
  #
  # Commit library changes
  #
  proc commit {} {
    variable libraryList
    variable libReqStatus
    variable libStatus

    #
    # If variable does not exist, then we have not visited library page
    # and thus there is no reason to update library status
    # 
    if {![info exists libraryList]} return

    foreach name $libraryList {
      if {$libReqStatus($name) != $libStatus($name)} {
	if  { $libReqStatus($name) } {
	  gat_loadLibrary $name
	} else {
	  gat_unloadLibrary $name
	}
      }
    } 

  }

  #############################################################################
  #
  # Dialog for loading and unloading libraries.
  #
  proc create {w} {
    variable topMargin
    variable boldFont
    variable normalFont
    variable lineHeight
    variable lineAscent
    variable lineDescent
    variable boxSize
    variable libraryList
    variable yPos

    set lineAscent [font metrics $boldFont -ascent]
    set lineDescent [font metrics $boldFont -descent]
    set lineHeight [expr $lineAscent + $lineDescent]
    set boxSize 9

    frame $w

    set width [rescale [m @circ.library.width]]
    set height [rescale [m @circ.library.height]]
    canvas $w.c -bg white -bd 1 -relief sunken -yscrollcommand "$w.vb set" -width $width -height $height
    scrollbar $w.vb -command "$w.c yview"
    pack $w.c -fill both -expand 1 -side left
    pack $w.vb -side left -fill y

    $w.c bind box <Button-1> "LibraryMgr::toggleBox %W %y"

    set y [expr $topMargin + $lineHeight]

    set libraryList [scanlibs]

    foreach name $libraryList {
      set yPos($name) $y
      makeLibLine $w.c $name
      incr y $lineHeight
    }

    $w.c configure -scrollregion [list 0 0 0 $y]
  }
}