gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 01/03: pass ctx as argument


From: gnunet
Subject: [taler-anastasis] 01/03: pass ctx as argument
Date: Sun, 18 Oct 2020 20:49:48 +0200

This is an automated email from the git hooks/post-receive script.

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit b011c677b80693d143f6d407bc1df9c992a26ebb
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Sat Oct 17 18:33:15 2020 +0200

    pass ctx as argument
---
 src/cli/anastasis-cli-redux.c          | 48 +++++++++++++++++-----------------
 src/lib/anastasis_api_backup_redux.c   |  7 +++++
 src/lib/anastasis_api_recovery_redux.c | 11 +++++---
 src/lib/anastasis_api_redux.c          | 17 +++++++-----
 src/lib/anastasis_api_redux.h          |  1 +
 5 files changed, 49 insertions(+), 35 deletions(-)

diff --git a/src/cli/anastasis-cli-redux.c b/src/cli/anastasis-cli-redux.c
index 57a76e4..a1ca33d 100644
--- a/src/cli/anastasis-cli-redux.c
+++ b/src/cli/anastasis-cli-redux.c
@@ -80,7 +80,7 @@ static char *action;
 
 /**
  * Persist a json state.
- * 
+ *
  * @param state to persist
  * @return 0 if operation failed
  */
@@ -105,15 +105,15 @@ action_cb (void *cls,
            json_t *result_state)
 {
   new_state = result_state;
-  
+
   if (NULL != new_state)
   {
     if (! isatty (STDOUT_FILENO))
     {
-      fprintf (stdout, 
-              "%s",
-              json_dumps (new_state,
-                          JSON_COMPACT));
+      fprintf (stdout,
+               "%s",
+               json_dumps (new_state,
+                           JSON_COMPACT));
     }
     else
     {
@@ -180,8 +180,8 @@ run (void *cls,
                  GNUNET_log_setup ("anastasis-reducer",
                                    "WARNING",
                                    NULL));
-  
-  
+
+
   if (r_flag ^ b_flag)
   {
     json_t *init_state;
@@ -230,9 +230,9 @@ run (void *cls,
       else
       {
         fprintf (stderr,
-          "Please give a path to store initial json state!\n");
+                 "Please give a path to store initial json state!\n");
         fprintf (stderr,
-          "Example: anastasis-reducer -b init_state.json\n");
+                 "Example: anastasis-reducer -b init_state.json\n");
         GNUNET_SCHEDULER_shutdown ();
         return;
       }
@@ -240,9 +240,9 @@ run (void *cls,
     else
     {
       fprintf (stdout,
-                "%s",
-                json_dumps (init_state,
-                            JSON_COMPACT));
+               "%s",
+               json_dumps (init_state,
+                           JSON_COMPACT));
       return; // success!
     }
   }
@@ -293,7 +293,7 @@ run (void *cls,
           GNUNET_SCHEDULER_shutdown ();
           return;
         }
-        char *prev_state_str = NULL; 
+        char *prev_state_str = NULL;
         size_t size;
         if (getline (&prev_state_str,
                      &size,
@@ -319,9 +319,9 @@ run (void *cls,
       else
       {
         fprintf (stderr,
-                   "Please give arguments!\n");
+                 "Please give arguments!\n");
         fprintf (stderr,
-                  "Example: anastasis-reducer -a '{\"continent\":\"Europe\"}' 
select-continent < prev_state.json > new_state.json\n");
+                 "Example: anastasis-reducer -a '{\"continent\":\"Europe\"}' 
select-continent < prev_state.json > new_state.json\n");
         GNUNET_SCHEDULER_shutdown ();
         return;
       }
@@ -333,9 +333,9 @@ run (void *cls,
       else
       {
         fprintf (stderr,
-          "Please give path for json containing previous state!\n");
+                 "Please give path for json containing previous state!\n");
         fprintf (stderr,
-          "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
+                 "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
         GNUNET_SCHEDULER_shutdown ();
         return;
       }
@@ -345,9 +345,9 @@ run (void *cls,
       else
       {
         fprintf (stderr,
-          "Please give an action!\n");
+                 "Please give an action!\n");
         fprintf (stderr,
-          "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
+                 "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
         GNUNET_SCHEDULER_shutdown ();
         return;
       }
@@ -357,9 +357,9 @@ run (void *cls,
       else
       {
         fprintf (stderr,
-          "Please give path for json containing arguments for action!\n");
+                 "Please give path for json containing arguments for 
action!\n");
         fprintf (stderr,
-          "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
+                 "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
         GNUNET_SCHEDULER_shutdown ();
         return;
       }
@@ -369,9 +369,9 @@ run (void *cls,
       else
       {
         fprintf (stderr,
-          "Please give path for json containing new state!\n");
+                 "Please give path for json containing new state!\n");
         fprintf (stderr,
-          "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
+                 "Example: anastasis-reducer prev.json action arguments.json 
new.json\n");
         GNUNET_SCHEDULER_shutdown ();
         return;
       }
diff --git a/src/lib/anastasis_api_backup_redux.c 
b/src/lib/anastasis_api_backup_redux.c
index 203d39f..b882bbc 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -68,12 +68,14 @@ ANASTASIS_backup_state_to_string (enum 
ANASTASIS_BackupState bs)
  *
  *  @param state FIXME: Description
  *  @param arguments FIXME: Description
+ *  @param ctx Curl context
  *  @param cb FIXME: Description
  *  @param cb_cls FIXME: Description
  */
 typedef struct ANASTASIS_ReduxAction *
 (*DispatchHandler)(json_t *state,
                    const json_t *arguments,
+                   struct GNUNET_CURL_Context *ctx,
                    ANASTASIS_ActionCallback cb,
                    void *cb_cls);
 
@@ -153,6 +155,7 @@ ANASTASIS_backup_start (const struct 
GNUNET_CONFIGURATION_Handle *cfg)
 static struct ANASTASIS_ReduxAction *
 add_authentication (json_t *state,
                     const json_t *arguments,
+                    struct GNUNET_CURL_Context *ctx,
                     ANASTASIS_ActionCallback cb,
                     void *cb_cls)
 {
@@ -401,6 +404,7 @@ method_candidate (struct PolicyBuilder *pb,
 static struct ANASTASIS_ReduxAction *
 done_authentication (json_t *state,
                      const json_t *arguments,
+                     struct GNUNET_CURL_Context *ctx,
                      ANASTASIS_ActionCallback cb,
                      void *cb_cls)
 {
@@ -455,6 +459,7 @@ done_authentication (json_t *state,
 static struct ANASTASIS_ReduxAction *
 del_authentication (json_t *state,
                     const json_t *arguments,
+                    struct GNUNET_CURL_Context *ctx,
                     ANASTASIS_ActionCallback cb,
                     void *cb_cls)
 {
@@ -502,6 +507,7 @@ del_authentication (json_t *state,
 static struct ANASTASIS_ReduxAction *
 add_policy (json_t *state,
             const json_t *arguments,
+            struct GNUNET_CURL_Context *ctx,
             ANASTASIS_ActionCallback cb,
             void *cb_cls)
 {
@@ -586,6 +592,7 @@ ANASTASIS_backup_action_ (struct GNUNET_CURL_Context *ctx,
     {
       return dispatchers[i].fun (state,
                                  arguments,
+                                 ctx,
                                  cb,
                                  cb_cls);
     }
diff --git a/src/lib/anastasis_api_recovery_redux.c 
b/src/lib/anastasis_api_recovery_redux.c
index 8a31adc..143ef2b 100644
--- a/src/lib/anastasis_api_recovery_redux.c
+++ b/src/lib/anastasis_api_recovery_redux.c
@@ -64,14 +64,16 @@ ANASTASIS_recovery_state_to_string (enum 
ANASTASIS_RecoveryState rs)
 /**
  * Callback function FIXME: Description.
  *
- *  @param state FIXME: Description
- *  @param arguments FIXME: Description
- *  @param cb FIXME: Description
- *  @param cb_cls FIXME: Description
+ * @param state FIXME: Description
+ * @param arguments FIXME: Description
+ * @param ctx Curl context
+ * @param cb FIXME: Description
+ * @param cb_cls FIXME: Description
  */
 typedef struct ANASTASIS_ReduxAction *
 (*DispatchHandler)(json_t *state,
                    const json_t *arguments,
+                   struct GNUNET_CURL_Context *ctx,
                    ANASTASIS_ActionCallback cb,
                    void *cb_cls);
 
@@ -192,6 +194,7 @@ ANASTASIS_recovery_action_ (struct GNUNET_CURL_Context *ctx,
     {
       return dispatchers[i].fun (state,
                                  arguments,
+                                 ctx,
                                  cb,
                                  cb_cls);
     }
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index dc0358a..e3adffe 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -154,11 +154,6 @@ struct SelectCountryHandle
 };
 
 
-/**
- * Curl context for communication with taler backend
- */
-struct GNUNET_CURL_Context *curl_ctx;
-
 /**
  * JSON containing country specific identity attributes to ask the user for.
  */
@@ -170,12 +165,14 @@ const json_t *redux_id_attr;
  *
  * @param state FIXME: Description
  * @param arguments FIXME: Description
+ * @param ctx Curl context
  * @param cb FIXME: Description
  * @param cb_cls FIXME: Description
  */
 typedef struct ANASTASIS_ReduxAction *
 (*DispatchHandler)(json_t *state,
                    const json_t *arguments,
+                   struct GNUNET_CURL_Context *ctx,
                    ANASTASIS_ActionCallback cb,
                    void *cb_cls);
 
@@ -454,6 +451,7 @@ redux_id_attr_init (const char *country_code)
 static struct ANASTASIS_ReduxAction *
 select_continent (json_t *state,
                   const json_t *arguments,
+                  struct GNUNET_CURL_Context *ctx,
                   ANASTASIS_ActionCallback cb,
                   void *cb_cls)
 {
@@ -508,6 +506,7 @@ select_continent (json_t *state,
 static struct ANASTASIS_ReduxAction *
 select_country (json_t *state,
                 const json_t *arguments,
+                struct GNUNET_CURL_Context *ctx,
                 ANASTASIS_ActionCallback cb,
                 void *cb_cls)
 {
@@ -611,7 +610,7 @@ select_country (json_t *state,
       GNUNET_CONTAINER_DLL_insert (sch->cr_head,
                                    sch->cr_tail,
                                    cr);
-      cr->co = ANASTASIS_get_config (curl_ctx, // FIXME: pass as argument!
+      cr->co = ANASTASIS_get_config (ctx,
                                      cr->backend_url,
                                      &config_cb,
                                      cr);
@@ -642,6 +641,7 @@ select_country (json_t *state,
 static struct ANASTASIS_ReduxAction *
 unselect_country (json_t *state,
                   const json_t *arguments,
+                  struct GNUNET_CURL_Context *ctx,
                   ANASTASIS_ActionCallback cb,
                   void *cb_cls)
 {
@@ -664,6 +664,7 @@ unselect_country (json_t *state,
 static struct ANASTASIS_ReduxAction *
 unselect_continent (json_t *state,
                     const json_t *arguments,
+                    struct GNUNET_CURL_Context *ctx,
                     ANASTASIS_ActionCallback cb,
                     void *cb_cls)
 {
@@ -687,6 +688,7 @@ unselect_continent (json_t *state,
 static struct ANASTASIS_ReduxAction *
 enter_user_attributes (json_t *state,
                        const json_t *arguments,
+                       struct GNUNET_CURL_Context *ctx,
                        ANASTASIS_ActionCallback cb,
                        void *cb_cls)
 {
@@ -724,6 +726,7 @@ enter_user_attributes (json_t *state,
 struct ANASTASIS_ReduxAction *
 ANASTASIS_back_generic_decrement_ (json_t *state,
                                    const json_t *arguments,
+                                   struct GNUNET_CURL_Context *ctx,
                                    ANASTASIS_ActionCallback cb,
                                    void *cb_cls)
 {
@@ -841,7 +844,6 @@ ANASTASIS_redux_action (const json_t *state,
                                                       "backup_state"));
   enum ANASTASIS_GenericState gs;
 
-  curl_ctx = ctx; // FIXME: pass as argument instead of as global
   if (NULL == s)
   {
     s = json_string_value (json_object_get (state,
@@ -878,6 +880,7 @@ ANASTASIS_redux_action (const json_t *state,
       {
         ret = dispatchers[i].fun (new_state,
                                   arguments,
+                                  ctx,
                                   cb,
                                   cb_cls);
         json_decref (new_state);
diff --git a/src/lib/anastasis_api_redux.h b/src/lib/anastasis_api_redux.h
index f2de11e..c3cd309 100644
--- a/src/lib/anastasis_api_redux.h
+++ b/src/lib/anastasis_api_redux.h
@@ -4,6 +4,7 @@
 struct ANASTASIS_ReduxAction *
 ANASTASIS_back_generic_decrement_ (json_t *state,
                                    const json_t *arguments,
+                                   struct GNUNET_CURL_Context *ctx,
                                    ANASTASIS_ActionCallback cb,
                                    void *cb_cls);
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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