gnunet/examples/identity-bis.in

54 lines
1.8 KiB
Plaintext

#!@GUILE@ \
-e (@\ (gnunet-identity)\ main) -L . -s
!#
;;;; Copyright © 2015 Rémi Delrue <asgeir@free.fr>
;;;;
;;;; This program is free software: you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation, either version 3 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(define-module (gnunet-identity)
#:use-module (ice-9 match)
#:use-module (system foreign)
#:use-module (gnu gnunet common)
#:use-module (gnu gnunet configuration)
#:use-module (gnu gnunet scheduler)
#:use-module (gnu gnunet identity)
#:export (main))
(define *config* #f) ; configuration handle
(define *handle* #f) ; operation handle
(define *kill-task* #f)
(define (shutdown-task _)
(when *handle* (stop-ego-lookup! *handle*)))
(define (print-ego ego)
(cancel-task! *kill-task*)
(cond (ego (let ((key (ego-public-key ego)))
(simple-format #t "~a - ~a\n" "testremi"
(ecdsa-public-key->string key))))
((not ego)
(simple-format #t "Undefined error in the identity service\n"))))
(define (first-task _)
(set! *handle* (start-ego-lookup *config* "testremi" print-ego))
(set! *kill-task* (add-task! shutdown-task #:delay (time-rel #:seconds 5))))
(define (main args)
(set! *config* (load-configuration "~/.gnunet/gnunet.conf"))
(call-with-scheduler *config* first-task))
;; Local Variables:
;; mode: scheme
;; End: