#!/tvbin/tivosh
## dbobj.tcl
## Run this program with a list of arguments that specify an object in 1 of 3 ways:
## 1) Full path ("/Setup")
## 2) FSID (3249)
## 3) Construction (3249/10)
proc testdbobj {obj} {
puts "type: [dbobj $obj type]"
puts "fsid: [dbobj $obj fsid]"
puts "subobjid: [dbobj $obj subobjid]"
puts "construction: [dbobj $obj construction]"
puts "primary: [dbobj $obj primary]"
puts "Attributes:"
foreach attr [dbobj $obj attrs] {
set attrtype [dbobj $obj attrtype $attr]
if {$attrtype == "object"} {
puts "[dbobj $obj attrtype $attr] $attr ([dbobj $obj gettarget $attr])"
} else {
puts "[dbobj $obj attrtype $attr] $attr ([dbobj $obj get $attr])"
}
}
}
set db [dbopen]
foreach obj $argv {
RetryTransaction {
if {[regexp {^/} $obj]} {
puts "--------Path: $obj"
testdbobj [db $db open $obj]
} elseif {[regexp {^([0-9]+)/([-0-9]+)$} $obj junk fsid subobjid]} {
puts "--------FSID/SubID: $fsid/$subobjid"
testdbobj [db $db openidconstruction $fsid $subobjid]
} elseif {[regexp {^([0-9]+)$} $obj junk fsid]} {
puts "--------FSID: $fsid"
testdbobj [db $db openid $fsid]
} else {
puts "--------unknown: $obj"
}
}
}