[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 25/70: -forgot the .c...
From: |
gnunet |
Subject: |
[gnunet] 25/70: -forgot the .c... |
Date: |
Wed, 31 Aug 2022 18:00:19 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit d83d7be67a89e5a1e8a801c20468e50aa8256c89
Author: Tristan Schwieren <tristan.schwieren@tum.de>
AuthorDate: Fri Nov 26 13:59:59 2021 +0100
-forgot the .c...
---
src/did/gnunet-did.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 97 insertions(+), 1 deletion(-)
diff --git a/src/did/gnunet-did.c b/src/did/gnunet-did.c
index c5d83976d..b9fe25f4a 100644
--- a/src/did/gnunet-did.c
+++ b/src/did/gnunet-did.c
@@ -25,19 +25,100 @@
*/
#include "platform.h"
#include "gnunet_util_lib.h"
+#include "gnunet_namestore_service.h"
+#include "gnunet_gns_service.h"
+
+/**
+ * Attribute Add
+ */
+static char *attr_add;
+
+/**
+ * Attribute delete
+ */
+static char *attr_delete;
+
+/**
+ * Attribute get
+ */
+static char *attr_value;
+
+static struct GNUNET_NAMESTORE_Handle *nc;
+static struct GNUNET_GNS_Handle *gns_handle;
+static struct GNUNET_DHT_Handle *dht;
+static struct GNUNET_CONFIGURATRION_Handle *c;
+static unsigned long long max_bg_queries = 100;
/**
* return value
*/
static int ret;
+static void cleanup(void * cls){
+ GNUNET_GNS_disconnect(gns_handle);
+ GNUNET_NAMESTORE_disconnect(nc);
+ GNUNET_SCHEDULER_shutdown();
+}
+
+static void did_print(
+ void *cls,
+ uint32_t rd_count,
+ const struct GNUNET_GNSRECORD_Data *rd){
+ int i;
+ for(i = 0; i < rd_count; i++){
+ // rd is not always a string
+ printf("%s\n", rd[i].data);
+ }
+ GNUNET_SCHEDULER_add_now(cleanup, NULL);
+ }
+
+static void
+resolve_didd()
+{
+ char * id_str;
+ struct GNUNET_IDENTITY_PublicKey pkey;
+ if ((1 != (sscanf (attr_value, "did:reclaim:%68s", id_str))) ||
+ (GNUNET_OK !=
+ GNUNET_IDENTITY_public_key_from_string (id_str, &pkey)))
+ {
+ fprintf (stderr, _ ("Invalid DID `%s'\n"), id_str);
+ GNUNET_SCHEDULER_shutdown ();
+ ret = 1;
+ return;
+ }
+
+ // Check the type of retured records
+ GNUNET_GNS_lookup(gns_handle, "didd", &pkey, GNUNET_DNSPARSER_TYPE_TXT,
GNUNET_GNS_LO_DEFAULT, &did_print, NULL);
+}
+
static void
run (void *cls,
char *const *args,
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *c)
{
- printf("Hello World!\n");
+ nc = GNUNET_NAMESTORE_connect(c);
+
+ if(nc == NULL){
+ ret = 1;
+ return;
+ }
+
+ gns_handle = GNUNET_GNS_connect(c);
+
+ if(gns_handle == NULL){
+ ret = 1;
+ return;
+ }
+
+ if (NULL != attr_value){
+ resolve_didd();
+ return;
+ }
+ else {
+ GNUNET_SCHEDULER_add_now(&cleanup, NULL);
+ }
+
ret = 0;
}
@@ -45,6 +126,21 @@ int
main (int argc, char *const argv[])
{
struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_string ('a',
+ "add",
+ "VALUE",
+ gettext_noop ("Add an DID Document"),
+ &attr_add),
+ GNUNET_GETOPT_option_string ('d',
+ "delete",
+ "ID",
+ gettext_noop ("Delete the DID Document with
DID"),
+ &attr_delete),
+ GNUNET_GETOPT_option_string ('g',
+ "value",
+ "VALUE",
+ gettext_noop ("Get the DID Document with
DID"),
+ &attr_value),
GNUNET_GETOPT_OPTION_END
};
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 53/70: - more tests, (continued)
- [gnunet] 53/70: - more tests, gnunet, 2022/08/31
- [gnunet] 61/70: - non working DID lib create func, gnunet, 2022/08/31
- [gnunet] 57/70: - changed did_core header, gnunet, 2022/08/31
- [gnunet] 59/70: - DID resolve using DID lib, gnunet, 2022/08/31
- [gnunet] 67/70: - DID lib; formatting, gnunet, 2022/08/31
- [gnunet] 51/70: - trying to make did_helper a lib, gnunet, 2022/08/31
- [gnunet] 64/70: - didlib; use expire value, gnunet, 2022/08/31
- [gnunet] 69/70: - added gitignores, gnunet, 2022/08/31
- [gnunet] 65/70: -m DID lib; added check for existing DID document, gnunet, 2022/08/31
- [gnunet] 22/70: -did mulitbase key and assert method for VCs, gnunet, 2022/08/31
- [gnunet] 25/70: -forgot the .c...,
gnunet <=