#!/usr/physics/gauche/bin/gosh (use srfi-1) (use gauche.process) (use gauche.uvector) (use gauche.net) (define (run-extauth prog) (run-process prog :output :pipe :input :pipe) ) (define (main args) (let ((p (run-extauth (second args)))) (do-protocol (process-input p) (process-output p) (third args)) (process-wait p) ) ) (define (pe . args) (display "Tester: " (standard-error-port)) (for-each (lambda (a) (display a (standard-error-port))) args) (flush (standard-error-port)) ) (define (do-protocol ip op req) (let ((lenbuf (make-u16vector 1)) (buf (string->u8vector req)) (result (make-u16vector 1))) (u16vector-set! lenbuf 0 (sys-htons (string-length req))) (pe "Sending length: " (sys-ntohs (u16vector-ref lenbuf 0)) "\n") (write-block lenbuf ip) (flush ip) (pe "Sending: " buf "\n") (write-block buf ip) (flush ip) (pe "Reading result\n") (read-block! result op) (pe "Got 2? " (sys-ntohs (u16vector-ref result 0)) "\n") (read-block! result op) (pe "Got result: " (sys-ntohs (u16vector-ref result 0)) "\n") ) )