/usr/share/linsmith/conv0809 is in linsmith 0.99.21-1.
This file is owned by root:root, with mode 0o755.
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 | #!/usr/bin/tclsh
set el_filt {<([a-zA-Z0-9]+)>([^<]+)</([a-zA-Z0-9]+)>}
proc save_comp {} {
global outf elem
if {$elem(element) == 0} { ;# 'Discrete'
if {$elem(iscap) == 0} { ;# Inductance
puts $outf " <element>0</element>"
puts $outf " <val2>$elem(val)</val2>"
} else { ;# Capacitor
puts $outf " <element>1</element>"
puts $outf " <val1>$elem(val)</val1>"
}
} else {
puts $outf " <element>[expr $elem(element)+3]</element>"
puts $outf " <val1>$elem(val)</val1>"
}
puts $outf " <connection>[expr $elem(connection) % 256]</connection>"
foreach typ {useloss z0 vf loss1 mhz1 loss2 mhz2} {
puts $outf " <$typ>$elem($typ)</$typ>"
}
}
if {$argc != 2} {
puts "Converts old (0.8.x) circuit files into the new (0.9.x) format."
puts "Usage:"
puts " conv0809 oldfile newfile"
puts ""
exit
}
set infn [lindex $argv 0]
set outfn [lindex $argv 1]
set inf [open $infn r]
set outf [open $outfn w]
set mode COPY
while {![eof $inf]} {
set line [gets $inf]
switch $mode {
COPY {
puts $outf $line
if {[regexp "<element>" $line]} {
set mode ELEM
}
}
ELEM {
if {[regexp $el_filt $line dummy entry val exit]} {
if {$entry == $exit} {
set elem($entry) $val
}
} else {
if {[regexp "</element>" $line]} {
save_comp
puts $outf $line
set mode COPY
}
}
}
}
}
close $inf
close $outf
|