ycl

Artifact [ddbd429ed8]
Login

Artifact [ddbd429ed8]

Artifact ddbd429ed80b302967f52be21e4a32781177ba5f:


#! /bin/env tclsh

package require {ycl crypto sha generic}
[yclprefix] crypto sha generic .spawn [namespace current]

proc digest {_ args} {
	set oldconfig [$_ configure]
	switch [$_ $ read] {
		b - binary {
		}
		t - text {
			return -code error [list {text mode not implemented}]
		}
	}
	try {
		$_ configure {*}$args
		set res [$_ openssl run preargs [list sha[$_ $ algo] -r [$_ $ path]]]
		if {![regexp {^([^\s]*)} $res -> sig]} {
			return -code error [list {error in signature}]
		}
		return $sig 
	} finally {
		$_ configure {*}$oldconfig
	}
}
[namespace current] .method digest

proc init {_ args} {
	package require {ycl programs openssl}
	uplevel 1 [list $_ .switch init {*}$args]
	[[yclprefix] programs openssl .spawn ${_}::openssl_template] init
	$_ .routine openssl_template
	$_ openssl_template find ${_}::openssl
	$_ .routine openssl
	#openssl $ stdout {} 
	#{*}$acquire_sha [namespace current] {*}$args
	return $_
}
[namespace current] .method init

[namespace current] .routine openssl_template
[namespace current] .routine openssl