Minor modifications to get all examples working.

* binding-utils.scm: add `and=>%` (`and=>` for foreign pointers).
* fs/progress-info.scm: bug fix: on '(#:publish #:complete) do not assert any
                        more there’s a SKS URI (we don’t always publish in a
			namespace).
* examples/search.scm: add a one-line help message.
* examples/search-ns.scm,
  examples/publish.scm: typos.
This commit is contained in:
Rémi Birot-Delrue 2015-08-12 20:17:58 +02:00
parent cd20d8d6d0
commit 2304d664bb
5 changed files with 16 additions and 7 deletions

View File

@ -164,7 +164,7 @@ subsystem has been initialized."
(let ((err (current-error-port)))
(cond
((or (not *args*) (null? *args*) (> (length *args*) 1))
(display "Usage: examples/gnunet-publish.scm [options] filename\n" err))
(display "Usage: examples/publish.scm [options] filename\n" err))
((and *pseudonym* (not *id*))
(display "Option `-t' is required when using option `-P'.\n" err))
((and (not *pseudonym*) *id*)
@ -187,7 +187,6 @@ subsystem has been initialized."
(define (main args)
"The main function to publish content to GNUnet."
(setup-log "publish.scm" #:debug)
(set! *config* (load-configuration "~/.gnunet/gnunet.conf"))
(let* ((options (getopt-long args %options)))
(set! *simulate?* (option-ref options 'simulate #f))

View File

@ -47,7 +47,7 @@
(set! *config* (load-configuration *config-file*))
(set! *binary-name* (car args))
(cond ((not (= (length args) 3))
(simple-format #t "Usage: ~a <namespace> <identifier>\n" (car args)))
(simple-format #t "Usage: ~a NAMESPACE IDENTIFIER\n" (car args)))
(else
(set! *ns-name* (cadr args))
(set! *identifier* (caddr args))

View File

@ -32,12 +32,14 @@
(define *config* (load-configuration *config-file*))
(define *fs-handle* #f)
(define *search-handle* #f)
(define *search-uri* #f)
(define *search-handle* #f)
(define (main args)
(call-with-scheduler *config* (first-task args)))
(if (= 1 (length args))
(simple-format #t "Usage: ~a KEY...\n" (car args))
(call-with-scheduler *config* (first-task args))))
(define (first-task args)
(lambda (_)

View File

@ -35,7 +35,8 @@
string->pointer*
pointer->string*
make-c-struct*
or%))
or%
and=>%))
(define (getf plist value)
(let ((entry (member value plist)))
@ -95,6 +96,13 @@ if STRING is empty (\"\")."
(if (eq? %null-pointer x*)
(or% y ...)
x*)))))
;; a variant of and=> for foreign pointers.
(define-syntax-rule (and=>% x f)
(let ((x* x))
(if (eq? %null-pointer x*)
#f
(f x*))))
;;; Utilities

View File

@ -359,7 +359,7 @@ two keywords. If status is unknown, raises an error."
((#:completed)
(destructuring-bind (%chk-uri %sks-uri) specs
(list (wrap-uri %chk-uri)
(wrap-uri %sks-uri)
(and=>% %sks-uri wrap-uri)
#f)))
((#:error)
(list #f #f (pointer->string* (car specs))))