guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 17/17: Minor modifications to get all examples working. * bind


From: Rmi Birot-Delrue
Subject: [gnunet] 17/17: 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.
Date: Wed, 12 Aug 2015 18:24:43 +0000

remibd pushed a commit to branch master
in repository gnunet.

commit 2304d664bbfd67518c0e7d3fb267392c7bfc3711
Author: Rémi Birot-Delrue <address@hidden>
Date:   Wed Aug 12 20:17:58 2015 +0200

    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.
---
 examples/publish.scm            |    3 +--
 examples/search-ns.scm          |    2 +-
 examples/search.scm             |    6 ++++--
 gnu/gnunet/binding-utils.scm    |   10 +++++++++-
 gnu/gnunet/fs/progress-info.scm |    2 +-
 5 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/examples/publish.scm b/examples/publish.scm
index 25b0aa4..d5a55b2 100755
--- a/examples/publish.scm
+++ b/examples/publish.scm
@@ -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))
diff --git a/examples/search-ns.scm b/examples/search-ns.scm
index e90f1bb..0956d9a 100755
--- a/examples/search-ns.scm
+++ b/examples/search-ns.scm
@@ -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))
diff --git a/examples/search.scm b/examples/search.scm
index 4e07b0b..af4a2ca 100755
--- a/examples/search.scm
+++ b/examples/search.scm
@@ -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 (_)
diff --git a/gnu/gnunet/binding-utils.scm b/gnu/gnunet/binding-utils.scm
index 1dd9d87..9f78def 100644
--- a/gnu/gnunet/binding-utils.scm
+++ b/gnu/gnunet/binding-utils.scm
@@ -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
 
diff --git a/gnu/gnunet/fs/progress-info.scm b/gnu/gnunet/fs/progress-info.scm
index 25cb6ee..0f2c034 100644
--- a/gnu/gnunet/fs/progress-info.scm
+++ b/gnu/gnunet/fs/progress-info.scm
@@ -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))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]