Utility Procedures
This section presents three utility procedures that simplify the type mapping process for this type:
The read_store Utility Procedure
The read_store procedure parses the output of the CLI's dprint command, and then stores and returns a value. This procedure reads a value from an absolute address.
proc read_store {address {type void}} {
set res [capture dprint "*($type *)$address"]
# Strip out just the value
regexp {^.*= ([^ ]*)} $res {} res
return $res
}
The regular expression uses the {} empty string to indicate that the CLI should ignore the entire string that matches. The portion of the regular expression within the parentheses (that is, the value) is assigned to res, which is the function's return value.