+proc ensure_globalsecret {} {
+ global globalsecret
+
+ if {[info exists globalsecret]} return
+ set gsfile [open /dev/urandom r]
+ fconfigure $gsfile -translation binary
+ set globalsecret [read $gsfile 32]
+ binary scan $globalsecret H* globalsecret
+ close $gsfile
+ unset gsfile
+}
+
+proc ensure_outqueue {} {
+ out__vars
+ if {[info exists out_queue]} return
+ set out_creditms [expr {$out_maxburst*$out_interval}]
+ set out_creditat [clock seconds]
+ set out_queue {}
+ set out_lag_reported 0
+ set out_lag_reportwhen $out_creditat
+}
+
+proc fail {msg} {
+ logerror "failing: $msg"
+ exit 1
+}
+
+proc ensure_connecting {} {
+ global sock ownfullname host port nick
+ global musthaveping_ms musthaveping_after
+
+ if {[info exists sock]} return