[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 17/17: Minor modifications to get all examples working. * bind
From: |
Rémi 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))))
- [gnunet] 06/17: Bind GNUNET_FS_IDENTITY_* functions and add support for publishing in namespaces. * identity.scm: complete bindings of GNUNET_FS_IDENTITY * fs.scm: add support for egos/namespaces to `start-publish` * binding-utils: remove the useless import of `assert`, (continued)
- [gnunet] 06/17: Bind GNUNET_FS_IDENTITY_* functions and add support for publishing in namespaces. * identity.scm: complete bindings of GNUNET_FS_IDENTITY * fs.scm: add support for egos/namespaces to `start-publish` * binding-utils: remove the useless import of `assert`, Rémi Birot-Delrue, 2015/08/12
- [gnunet] 05/17: Add draft support for indexing/publication. * fs.scm: - add a `<file-information>` type and associated functions (`wrap-file-information`, `unwrap-file-information`, and `make-file-information`); - add incomplete bindings to `GNUNET_FS_directory_scan_*` functions (`start-directory-scan`, `stop-directory-scan`, `directory-scanner-result`) - add `share-tree->file-information` - add `start-publish` and `stop-publish` * examples/publish.scm: a very simple and ugly `gnunet-publish` clone., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 12/17: Complete the container/metadata bindings., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 13/17: Remove `set-next-task!`, as the corresponding functions have been removed from GNUnet., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 07/17: Small bug fixes and add publishing in namespaces for examples/publish.scm * common.scm: add `gnunet-id-ffi` (FFI for libgnunetidentity). * identity.scm: replace `define-gnunet-fs` with `define-gnunet-id`. * fs.scm: corrects a bug in `start-publish` (gave `GNUNET_FS_publish_start` a pointer to the ego in place of a pointer to its private key). * examples/publish.scm: add handling of namespaces and replace simple global variables with parameters., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 08/17: Add `examples/identity.scm`, `examples/identity-bis.scm`, `examples/search-ns.scm`, and a few minor modifications. * examples/search-ns.scm: a basic tool to search namespaces. * examples/identity.scm: a basic tool to list egos. * examples/identity-bis.scm: idem, but using `start-identity-lookup`. * fs/uri.scm: `wrap-uri` throws an `invalid-arg` exception when given a null pointer. * tests/uri.scm: c.f. ↑ * configuration.scm: add `configuration-value-set?`. * identity.scm: add `ecdsa-public-key->string`., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 09/17: Rewrite of examples/publish.scm, small bug fixes and typos. * examples/publish.scm: rewritten to correctly handle namespaces. * gnu/gnunet/binding-utils.scm: add `or%`. * gnu/gnunet/fs.scm: bug fix: `start-*` function throw an error instead of returning %null-pointer. * gnu/gnunet/identity.scm: typo., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 14/17: Code cleaning: various improvements and bug fixes. * identity.scm: `open-identity-service` now throws an exception on failure. * binding-utils.scm: just add `destructuring-bind`. * common.scm: `time-rel` now throws an exception instead of returning a meaningless negative result; add `setup-log`. * container/metadata.scm: `metadata-set!` now throws an exception on error. * tests/container-metadata.scm: add tests for `metadata-copy`, `metadata-clear`, `metadata-equal?` and `add-publication-date!`, Rémi Birot-Delrue, 2015/08/12
- [gnunet] 11/17: Add `close-filesharing-service` and dynamic allocation in `open-filesharing-handle`., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 10/17: Add `time-rel` to replace all ad-hoc time calculations., Rémi Birot-Delrue, 2015/08/12
- [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.,
Rémi Birot-Delrue <=
- [gnunet] 15/17: Small typo and improvements (add a few time management functions). * common.scm: - add `bool->int` and `int->bool`; - add `time-rel`, `current-time`, `time-absolute->string`, and `time-relative->absolute`. * uri.scm: minor typo and add LOC URIs to `uri-file-size`., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 16/17: Add a record type for GNUNET_FS_ProgressInfo and a few tests. * progress-info.scm: add a record type for `GNUNET_FS_ProgressInfo` and alter `parse-c-progress-info` to handle it. * fs.scm: - correct `make-file-information`; - deprecate directory-scan (too many bugs to fix, `make-file-information will` do for now); - replace `*block-options*` with `make-block-options`; - update `procedure->*` functions to use `parse-c-progress-info`. * examples/*.scm: follow modifications on fs.scm. * tests/progress-info.scm: add a fake progress-info to test `parse-c-progress-info`. * tests/fs.scm: add a small test for `make-file-information`., Rémi Birot-Delrue, 2015/08/12