48 lines
1.7 KiB
Scheme
48 lines
1.7 KiB
Scheme
#!/usr/bin/guile \
|
||
-e main -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-search)
|
||
#:use-module (ice-9 match)
|
||
#:use-module (system foreign)
|
||
#:use-module (gnu gnunet container metadata)
|
||
#:use-module (gnu gnunet fs)
|
||
#:use-module (gnu gnunet fs uri)
|
||
#:use-module (gnu gnunet fs progress-info)
|
||
#:use-module (gnu gnunet configuration)
|
||
#:use-module (gnu gnunet scheduler))
|
||
|
||
(define config-file "~/.gnunet/gnunet.conf")
|
||
(define count-limit 10)
|
||
|
||
|
||
(define (result-cb info)
|
||
(simple-format #t "RESULT! ~a\n" info))
|
||
|
||
(define (main args)
|
||
(let ((config (load-configuration config-file)))
|
||
(define (first-task _)
|
||
(let ((search-service
|
||
(search-service-open config #:result result-cb)))
|
||
(simple-format #t "Search service opened (~a)\n" search-service)
|
||
(let ((current-search (start-ksk-search search-service args)))
|
||
;; adds a timeout in 5 seconds
|
||
(add-task! (lambda (_)
|
||
(stop-search current-search))
|
||
#:delay (* 5 1000 1000)))))
|
||
(call-with-scheduler config first-task)))
|