[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 12/17: Complete the container/metadata bindings.
From: |
Rémi Birot-Delrue |
Subject: |
[gnunet] 12/17: Complete the container/metadata bindings. |
Date: |
Wed, 12 Aug 2015 18:24:41 +0000 |
remibd pushed a commit to branch master
in repository gnunet.
commit cb2028f885fe06d18cc531502281842519320ab5
Author: RĂ©mi Birot-Delrue <address@hidden>
Date: Thu Aug 6 16:44:52 2015 +0200
Complete the container/metadata bindings.
---
gnu/gnunet/container/metadata.scm | 68 +++++++++++++++++++++++++++++++++----
1 files changed, 61 insertions(+), 7 deletions(-)
diff --git a/gnu/gnunet/container/metadata.scm
b/gnu/gnunet/container/metadata.scm
index 8ea34ba..e9a31e5 100644
--- a/gnu/gnunet/container/metadata.scm
+++ b/gnu/gnunet/container/metadata.scm
@@ -43,7 +43,13 @@
metadata-set!
metadata-ref
metadata-iterate
- metadata-map))
+ metadata-map
+
+ metadata-copy
+ metadata-equal?
+ metadata-clear!
+ metadata-add-publication-date!
+ ))
(define-record-type <metadata>
@@ -68,7 +74,8 @@
#:unknown)))
(define metadata-type-alist
- '((#:unknown . 45)
+ '((#:publication-date . 24)
+ (#:unknown . 45)
(#:original-filename . 180)))
(define (metadata-type->integer type)
@@ -83,6 +90,9 @@
(define-gnunet %metadata-create
"GNUNET_CONTAINER_meta_data_create" : '() -> '*)
+(define-gnunet %metadata-duplicate
+ "GNUNET_CONTAINER_meta_data_duplicate" : '(*) -> '*)
+
(define %metadata-destroy
(dynamic-func "GNUNET_CONTAINER_meta_data_destroy" gnunet-util-ffi))
@@ -90,11 +100,26 @@
"GNUNET_CONTAINER_meta_data_insert" :
(list '* '* unsigned-int unsigned-int '* '* size_t) -> int)
-(define-gnunet %metadata-get-by-type
- "GNUNET_CONTAINER_meta_data_get_by_type" : (list '* unsigned-int) -> '*)
+(define-gnunet %metadata-test-equal
+ "GNUNET_CONTAINER_meta_data_test_equal" : '(* *) -> int)
+
+(define-gnunet %metadata-merge
+ "GNUNET_CONTAINER_meta_data_merge" : '(* *) -> void)
+
+(define-gnunet %metadata-delete
+ "GNUNET_CONTAINER_meta_data_delete" : (list '* unsigned-int '* size_t) ->
int)
+
+(define-gnunet %metadata-clear
+ "GNUNET_CONTAINER_meta_data_clear" : '(*) -> void)
+
+(define-gnunet %metadata-add-publication-date
+ "GNUNET_CONTAINER_meta_data_add_publication_date" : '(*) -> void)
(define-gnunet %metadata-iterate
- "GNUNET_CONTAINER_meta_data_iterate" : (list '* '* '*) -> int)
+ "GNUNET_CONTAINER_meta_data_iterate" : '(* * *) -> int)
+
+(define-gnunet %metadata-get-by-type
+ "GNUNET_CONTAINER_meta_data_get_by_type" : (list '* unsigned-int) -> '*)
(define* (wrap-metadata pointer #:key (finalize #f))
@@ -102,8 +127,8 @@
(set-pointer-finalizer! pointer %metadata-destroy))
(%wrap-metadata pointer))
-(define (make-metadata)
- (wrap-metadata (%metadata-create)))
+(define* (make-metadata #:key (finalize #t))
+ (wrap-metadata (%metadata-create) #:finalize finalize))
(define-record-type <metadata-item>
(make-metadata-item name type format mime-type data)
@@ -161,3 +186,32 @@ where plugin-name is a string,
0)
metadata)
(reverse result)))
+
+;;; utility functions
+
+(define* (metadata-copy meta #:key (finalize #t))
+ "Return a newly created copy of META."
+ (let ((ptr (%metadata-duplicate (unwrap-metadata meta))))
+ (when (eq? %null-pointer ptr)
+ (throw 'invalid-result "metadata-copy" "%metadata-duplicate"
%null-pointer))
+ (wrap-metadata ptr #:finalize finalize)))
+
+(define (metadata-equal? m n)
+ "Test if to metadata are equal: two metadata are considered equal if the
+meta-types, formats and content match (mime-types and plugin names aren’t
+considered)."
+ (int->bool (%metadata-test-equal (unwrap-metadata m) (unwrap-metadata n))))
+
+;;+TODO: metadata-merge
+
+;;+TODO: metadata-delete
+
+(define (metadata-clear! m)
+ "Remove all items in the metadata."
+ (%metadata-clear (unwrap-metadata m)))
+
+(define (metadata-add-publication-date! m)
+ "Add the current time as the publication date to the metadata."
+ (%metadata-add-publication-date (unwrap-metadata m)))
+
+
- [gnunet] branch master updated (c40fcac -> 2304d66), Rémi Birot-Delrue, 2015/08/12
- [gnunet] 01/17: Corrects a small bug., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 04/17: Add a few utility functions. * binding-utils.scm: add `pointer->string*`. * common.scm: add `bool->int` and `int->bool`, two functions to easily convert `gnunet-ok`, `gnunet-no`, `gnunet-syserror` values to booleans. * fs/uri.scm: export `keyword-list->string`. * tests/uri.scm: test `keyword-list->string`. * scheduler.scm: add `cancel-task!`., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 02/17: API cleanup: separates search and URI, adds sks URIs. * examples/search.scm: echo changes in the API; * gnu/gnunet/common.scm: add ecdsa-public-key? and string->data-pointer; * gnu/gnunet/fs.scm: replace search-service-open with open-filesharing-service, replace start-ksk-search with start-search; * gnu/gnunet/fs/uri.scm: add make-sks-uri-pointer and make-sks-uri; * tests/uri.scm: add tests for make-sks-uri-pointer and make-sks-uri., Rémi Birot-Delrue, 2015/08/12
- [gnunet] 03/17: Bind basic download functionalities * examples/download.scm: a loose `gnunet-download' clone. * system/foreign/unions.scm: add the possibility to specify #f as a union variant to get a padding of the size of the union. * gnu/gnunet/fs/progress-info.scm: just adapted to the modification to unions.scm. * gnu/gnunet/fs/uri.scm: add a few utility functions: `parse-uri' and `uri-file-size'. * gnu/gnunet/fs/fs.scm: add `start-download` and `stop-download`., Rémi Birot-Delrue, 2015/08/12
- [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 <=
- [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, 2015/08/12
- [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
- Prev by Date:
[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.
- Next by Date:
[gnunet] 13/17: Remove `set-next-task!`, as the corresponding functions have been removed from GNUnet.
- Previous by thread:
[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.
- Next by thread:
[gnunet] 13/17: Remove `set-next-task!`, as the corresponding functions have been removed from GNUnet.
- Index(es):