3 package require ossltest
5 proc getConfigLine {var {section ""}} {
7 if {[string length $section]} {
8 if {[regexp -indices "\n\\s*\\\[\\s*$section\\s*\\\]\\s*\n" $config start]} {
9 set start [lindex $start 1]
11 return -code error "Section $section is not found"
16 if {[regexp -indices "\n\\s*\\\[\[^\n\]+\\\]\\s*\n" [string range $config $start end] end]} {
17 set end [expr $start+[lindex $end 0]]
21 if {![regexp "\n\\s*$var\\s*=\\s*(\\S\[^\n\]+?)\\s*\n" "\n[string range $config $start $end]" => value]} {
22 return -code error "No variable $var in section $section"
27 set config [getConfig]
29 set openssl_def [getConfigLine openssl_conf]
31 set engine_section [getConfigLine {[^#]+} [getConfigLine engines $openssl_def ]]
33 puts [getConfigLine engine_id $engine_section]