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:
parent
cd20d8d6d0
commit
2304d664bb
|
@ -164,7 +164,7 @@ subsystem has been initialized."
|
||||||
(let ((err (current-error-port)))
|
(let ((err (current-error-port)))
|
||||||
(cond
|
(cond
|
||||||
((or (not *args*) (null? *args*) (> (length *args*) 1))
|
((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*))
|
((and *pseudonym* (not *id*))
|
||||||
(display "Option `-t' is required when using option `-P'.\n" err))
|
(display "Option `-t' is required when using option `-P'.\n" err))
|
||||||
((and (not *pseudonym*) *id*)
|
((and (not *pseudonym*) *id*)
|
||||||
|
@ -187,7 +187,6 @@ subsystem has been initialized."
|
||||||
|
|
||||||
(define (main args)
|
(define (main args)
|
||||||
"The main function to publish content to GNUnet."
|
"The main function to publish content to GNUnet."
|
||||||
(setup-log "publish.scm" #:debug)
|
|
||||||
(set! *config* (load-configuration "~/.gnunet/gnunet.conf"))
|
(set! *config* (load-configuration "~/.gnunet/gnunet.conf"))
|
||||||
(let* ((options (getopt-long args %options)))
|
(let* ((options (getopt-long args %options)))
|
||||||
(set! *simulate?* (option-ref options 'simulate #f))
|
(set! *simulate?* (option-ref options 'simulate #f))
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
(set! *config* (load-configuration *config-file*))
|
(set! *config* (load-configuration *config-file*))
|
||||||
(set! *binary-name* (car args))
|
(set! *binary-name* (car args))
|
||||||
(cond ((not (= (length args) 3))
|
(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
|
(else
|
||||||
(set! *ns-name* (cadr args))
|
(set! *ns-name* (cadr args))
|
||||||
(set! *identifier* (caddr args))
|
(set! *identifier* (caddr args))
|
||||||
|
|
|
@ -32,12 +32,14 @@
|
||||||
(define *config* (load-configuration *config-file*))
|
(define *config* (load-configuration *config-file*))
|
||||||
|
|
||||||
(define *fs-handle* #f)
|
(define *fs-handle* #f)
|
||||||
(define *search-handle* #f)
|
|
||||||
(define *search-uri* #f)
|
(define *search-uri* #f)
|
||||||
|
(define *search-handle* #f)
|
||||||
|
|
||||||
|
|
||||||
(define (main args)
|
(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)
|
(define (first-task args)
|
||||||
(lambda (_)
|
(lambda (_)
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
string->pointer*
|
string->pointer*
|
||||||
pointer->string*
|
pointer->string*
|
||||||
make-c-struct*
|
make-c-struct*
|
||||||
or%))
|
or%
|
||||||
|
and=>%))
|
||||||
|
|
||||||
(define (getf plist value)
|
(define (getf plist value)
|
||||||
(let ((entry (member value plist)))
|
(let ((entry (member value plist)))
|
||||||
|
@ -95,6 +96,13 @@ if STRING is empty (\"\")."
|
||||||
(if (eq? %null-pointer x*)
|
(if (eq? %null-pointer x*)
|
||||||
(or% y ...)
|
(or% y ...)
|
||||||
x*)))))
|
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
|
;;; Utilities
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,7 @@ two keywords. If status is unknown, raises an error."
|
||||||
((#:completed)
|
((#:completed)
|
||||||
(destructuring-bind (%chk-uri %sks-uri) specs
|
(destructuring-bind (%chk-uri %sks-uri) specs
|
||||||
(list (wrap-uri %chk-uri)
|
(list (wrap-uri %chk-uri)
|
||||||
(wrap-uri %sks-uri)
|
(and=>% %sks-uri wrap-uri)
|
||||||
#f)))
|
#f)))
|
||||||
((#:error)
|
((#:error)
|
||||||
(list #f #f (pointer->string* (car specs))))
|
(list #f #f (pointer->string* (car specs))))
|
||||||
|
|
Loading…
Reference in New Issue