X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=tcl_tests%2Fgetengine.tcl;fp=tcl_tests%2Fgetengine.tcl;h=49176c0c9f83a199b0ec16625d6d87f9b0fae1e9;hb=3b8ddfe2f303b8931842e52bdb5c07c97042f651;hp=0000000000000000000000000000000000000000;hpb=e09d5a86fe1cb876b3c7cf5eb0d890f557b466d0;p=openssl-gost%2Fengine.git diff --git a/tcl_tests/getengine.tcl b/tcl_tests/getengine.tcl new file mode 100644 index 0000000..49176c0 --- /dev/null +++ b/tcl_tests/getengine.tcl @@ -0,0 +1,37 @@ +#!/usr/bin/tclsh +lappend auto_path . +package require ossltest + +proc getConfigLine {var {section ""}} { + global config + if {[string length $section]} { + if {[regexp -indices "\n\\s*\\\[\\s*$section\\s*\\\]\\s*\n" $config start]} { + set start [lindex $start 1] + } else { + return -code error "Section $section is not found" + } + } else { + set start 0 + } + if {[regexp -indices "\n\\s*\\\[\[^\n\]+\\\]\\s*\n" [string range $config $start end] end]} { + set end [expr $start+[lindex $end 0]] + } else { + set end end + } + if {![regexp "\n\\s*$var\\s*=\\s*(\\S\[^\n\]+?)\\s*\n" "\n[string range $config $start $end]" => value]} { + return -code error "No variable $var in section $section" + } + return $value +} + +set config [getConfig] + +set openssl_def [getConfigLine openssl_conf] + +set engine_section [getConfigLine {[^#]+} [getConfigLine engines $openssl_def ]] + +puts [getConfigLine engine_id $engine_section] + + + +