This file is indexed.

/usr/share/xcrysden/Tcl/xsfOpen.tcl is in xcrysden-data 1.5.53-1.

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
#############################################################################
# Author:                                                                   #
# ------                                                                    #
#  Anton Kokalj                                  Email: Tone.Kokalj@ijs.si  #
#  Department of Physical and Organic Chemistry  Phone: x 386 1 477 3523    #
#  Jozef Stefan Institute                          Fax: x 386 1 477 3811    #
#  Jamova 39, SI-1000 Ljubljana                                             #
#  SLOVENIA                                                                 #
#                                                                           #
# Source: $XCRYSDEN_TOPDIR/Tcl/xsfOpen.tcl
# ------                                                                    #
# Copyright (c) 1996-2003 by Anton Kokalj                                   #
#############################################################################

proc xsfAddBlankLine {filedir} {
    ##########################################
    # add a blank line at the end of XSF file
    set ch [open $filedir a]
    puts $ch ""
    flush $ch
    close $ch
    ##########################################
}

proc gunzipXSF {file} {
    global system

    xcDebug -debug "gunzipXSF: file = $file"

    set name [file tail $file]
    cd $system(SCRDIR)
    # maybe file is already locate in $system(SCRDIR)
    if { [file dirname $file] != $system(SCRDIR) && $file != $name } {
	#file copy -force $file $name
	fileCopy $file $name
	catch {exec -- chmod +rw $name}
    }
    ####################
    set gunzipName $name
    ####################

    if { [string match *.gz $name] } {
	xcDebug -debug "gunzipXSF: string matches"
	catch {exec -- gzip -d $name}	
	set gunzipName [string trimright $name .gz]
	catch {exec -- chmod +rw $gunzipName}
	if { ![file exists $gunzipName] } {
	    ErrorDialog "error when gunzip-ing file $file"
	    uplevel 1 { return }
	}
    }
    set gunzipName $system(SCRDIR)/$gunzipName
    xcDebug -debug "gunzipXSF: gunziped-file = $gunzipName"

    xsfAddBlankLine $gunzipName
    return $gunzipName
}

#
# tis proc is called form menu File->...->(Open XSF File)
#
proc xsfOpenMenu {can {dir {}}} {
    global fileselect

    if { $dir != {} } {
	set fileselect(path) [tk_getOpenFile -defaultextension .xsf \
				  -filetypes { 
				      {{All Files}                  {.*}  }
				      {{XSF Files}                  {.xsf}}
				      {{GZipped XSF Files}          {.xsf.gz}}
				      {{Animated XSF Files}         {.axsf}}
				      {{GZipped Animated XSF Files} {.axsf.gz}}
				  } -initialdir $dir -title "Open XSF File"]
	if { $fileselect(path) == "" } {
	    return
	}
    } else {
	fileselect "Open XSF Structure" 
	if { $fileselect(path) != "" } {
	    set file $fileselect(path)
	} else {
	    puts stderr "WARNING:: \fileselect(path) = \"\""
	    flush stderr
	    return
	}
    }
    xsfOpen $fileselect(path) $can
}


proc xsfOpen {filedir {can .mesa}} {
    global system geng xcMisc periodic radio sInfo periodic xsfAnim working_XSF_file

    set filedir [gunzipXSF $filedir]
    UpdateWMTitle $filedir

    # #
    # # did user specify the "reduce to xD" option
    # #
    # if [info exists xcMisc(reduce_to)] {
    # 	switch -exact -- $xcMisc(reduce_to) {
    # 	    2 { set filedir [xsfReduce3DTo 2 $filedir] }
    # 	    1 { set filedir [xsfReduce3DTo 1 $filedir] }
    # 	    0 { set filedir [xsfReduce3DTo 0 $filedir] }
    # 	}
    # }
    # 
    # #
    # # check if XSF uses atomic symbols instead of atomic numbers
    # #
    # set filedir [xsfAtmSym2Nat $filedir]

    if { ! [info exists xcMisc(reduce_to)] } {
	set xcMisc(reduce_to) {}
    }
    eval {exec $system(BINDIR)/xsf2xsf $filedir $filedir.raw} $xcMisc(reduce_to)
    set filedir $filedir.raw

    #
    # check if xsf is AXSF (Animation XSF)
    #
    set fID  [open $filedir]
    set l1st [gets $fID]
    close $fID
    if { [string match "*ANIMSTEP*" $l1st] } {
	# yes we have AXSF file
	if { $xsfAnim(not_anim) != 1 } {
	    xsfAnimInit $filedir .mesa
	    return
	}
    }

    #
    # the working XSF file
    set working_XSF_file $filedir

    #
    # now open the file
    #
    ResetDispModes
    if { [catch {xc_openstr xcr $filedir $can PL}] } {
	ErrorDialog "An Error occured, while reading XSF file $filedir"
	CloseCase
	return
    }

    #
    # set the proper state
    #
    Get_sInfoArray
    DisplayDefaultMode
    xcAppendState render
    xcUpdateState
    set periodic(dim) $sInfo(dim)
    
    #
    # if the structure is periodic update it according to the "state"
    #
    if { $periodic(dim) > 0 } {
	set geng(M3_ARGUMENT) [GetGengM3Arg ANGS]
	
	# the state should be set as well
	cd $system(SCRDIR)
	GenGeom $geng(M1_INFO) $geng(M2_CELL) $geng(M3_ARGUMENT) \
	    1 1 1 1 xc_gengeom.$system(PID)
	set fileID [open "$system(SCRDIR)/xc_gengeom.$system(PID)" r]
	GetDimGroup periodic(dim) periodic(igroup) $fileID
	close $fileID

	#<new>:  t.k. Mon Jan 27 15:24:44 CET 2003
	CellMode 1
	#/

	#<old>: t.k. Mon Jan 27 15:24:44 CET 2003
	#
	#set radio(cellmode) "prim"
	#set radio(unitrep)  "cell"	
	#GenGeom $geng(M1_PRIM) $geng(M2_CELL) 11 1 1 1 1 \
	#	xc_struc.$system(PID)
	#
	#UpdateStruct .mesa xc_struc.$system(PID)
	#/

	Get_sInfoArray
	xcUpdateState
    }

    CrysFrames

    #DEBUG:
    #.mesa xc_setatomlabel 1 "1st atom" "" {1.0 1.0 0.0 } {0.0 0.0 0.5}	    
    #/
    return
}


########################################################################
# check if XSF uses atomic symbols instead of atomic numbers
# if it does convert to atomic numbers ...
proc xsfAtmSym2Nat {filedir} {
    global system

    
    file copy -force $filedir $system(SCRDIR)/tmp.xsf

    # open existing XSF file ...
    set fID     [open $system(SCRDIR)/tmp.xsf r]

    # create a new file ...
    set newFile $filedir
    set newID   [open $newFile w]

    # search for ATOMS, PRIMCOORD, CONVCOORD section and replace ...
    set read_atoms 0
    while { ! [eof $fID] } {	
	gets $fID line
	
	if { [regexp -- "^ *ATOMS" $line] } {
	    set read_atoms 1
	    
	} elseif { [regexp -- "^ *PRIMCOORD|^ *CONVCOORD" $line] } {
	    puts $newID $line
	    gets $fID line
	    set read_atoms 1
	    
	} elseif { $read_atoms == 1 } {
	    set len [llength $line]
	    if { $len != 4 && $len != 7 } {
		set read_atoms 0
	    } else {
		set line [_xsfAtmSym2Nat $line]
	    } 
	}
	puts $newID $line
    }
    close $fID
    close $newID
    return $newFile
}


proc _xsfAtmSym2Nat {line} {
    set f1 [lindex $line 0]
    if { ! [string is integer $f1] } {
	set f1 [AnameExt2Nat $f1]
    }
    return [concat $f1 [lrange $line 1 end]]
}