commit 57535d3ed1847ec3335ab2b86a313a972da54688
parent 2e947cccfc3f7b9b496906051a7ed300c01aefdf
Author: Florian Dold <florian@dold.me>
Date: Wed, 4 Jan 2023 11:23:39 +0100
implement Marc's naming suggestions
Diffstat:
3 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/taler_wallet_core_lib.c b/taler_wallet_core_lib.c
@@ -35,7 +35,7 @@ struct HostMessage {
char *data;
};
-struct TALER_WALLET_Handle
+struct TALER_WALLET_Instance
{
// Mutex that is locked while initializing the handle
pthread_mutex_t handle_mutex;
@@ -80,7 +80,7 @@ static JSContext *JS_NewCustomContext(JSRuntime *rt)
}
void
-TALER_WALLET_set_handler(struct TALER_WALLET_Handle *h,
+TALER_WALLET_set_message_handler(struct TALER_WALLET_Instance *h,
TALER_WALLET_MessageHandlerFn handler_f,
void *handler_cls)
{
@@ -89,7 +89,7 @@ TALER_WALLET_set_handler(struct TALER_WALLET_Handle *h,
}
int
-TALER_WALLET_send_message (struct TALER_WALLET_Handle *h,
+TALER_WALLET_send_request (struct TALER_WALLET_Instance *h,
const char *msg)
{
int ret;
@@ -101,17 +101,17 @@ TALER_WALLET_send_message (struct TALER_WALLET_Handle *h,
static void
wallet_host_message_handler(void *cls, const char *msg)
{
- struct TALER_WALLET_Handle *wh = cls;
+ struct TALER_WALLET_Instance *wh = cls;
if (wh->handler_f) {
wh->handler_f(wh->handler_cls, msg);
}
}
-struct TALER_WALLET_Handle *
+struct TALER_WALLET_Instance *
TALER_WALLET_create(void)
{
- struct TALER_WALLET_Handle *wh;
+ struct TALER_WALLET_Instance *wh;
wh = malloc(sizeof (*wh));
memset(wh, 0, sizeof *wh);
if (0 != pthread_mutex_init(&wh->handle_mutex, NULL)) {
@@ -124,7 +124,7 @@ TALER_WALLET_create(void)
static void *
run(void *cls)
{
- struct TALER_WALLET_Handle *wh = cls;
+ struct TALER_WALLET_Instance *wh = cls;
wh->rt = JS_NewRuntime();
@@ -162,7 +162,7 @@ run(void *cls)
}
void
-TALER_WALLET_run (struct TALER_WALLET_Handle *wh)
+TALER_WALLET_run (struct TALER_WALLET_Instance *wh)
{
pthread_t wallet_thread;
char *line;
@@ -175,7 +175,7 @@ TALER_WALLET_run (struct TALER_WALLET_Handle *wh)
wh->wallet_thread = wallet_thread;
}
-void TALER_WALLET_join(struct TALER_WALLET_Handle *wh)
+void TALER_WALLET_join(struct TALER_WALLET_Instance *wh)
{
pthread_join(wh->wallet_thread, NULL);
}
diff --git a/taler_wallet_core_lib.h b/taler_wallet_core_lib.h
@@ -28,7 +28,7 @@
/**
* Opaque handle to a Taler wallet-core.
*/
-struct TALER_WALLET_Handle;
+struct TALER_WALLET_Instance;
/**
* Handler for messages from the wallet.
@@ -39,9 +39,9 @@ struct TALER_WALLET_Handle;
typedef void (*TALER_WALLET_MessageHandlerFn)(void *handler_p, const char *message);
/**
- * Create a new wallet-core handle.
+ * Create a new wallet-core instance..
*/
-struct TALER_WALLET_Handle *
+struct TALER_WALLET_Instance *
TALER_WALLET_create(void);
/**
@@ -51,9 +51,9 @@ TALER_WALLET_create(void);
* Caution: The handler will be called from a different thread.
*/
void
-TALER_WALLET_set_handler(struct TALER_WALLET_Handle *h,
- TALER_WALLET_MessageHandlerFn handler_f,
- void *handler_p);
+TALER_WALLET_set_message_handler(struct TALER_WALLET_Instance *h,
+ TALER_WALLET_MessageHandlerFn handler_f,
+ void *handler_p);
/**
@@ -62,17 +62,17 @@ TALER_WALLET_set_handler(struct TALER_WALLET_Handle *h,
*/
// FIXME: Not implemented!
//void
-//TALER_WALLET_set_jsfile(struct TALER_WALLET_Handle *h,
+//TALER_WALLET_set_jsfile(struct TALER_WALLET_Instance *h,
// const char *filename);
/**
* Send a message to wallet-core.
*
* Responses will be sent asynchronously to the message handler
- * set with #TALER_WALLET_set_handler.
+ * set with #TALER_WALLET_set_message_handler.
*/
int
-TALER_WALLET_send_message(struct TALER_WALLET_Handle *h,
+TALER_WALLET_send_request(struct TALER_WALLET_Instance *h,
const char *msg);
/**
@@ -81,13 +81,13 @@ TALER_WALLET_send_message(struct TALER_WALLET_Handle *h,
* This function creates a new thread and returns immediately.
*/
void
-TALER_WALLET_run(struct TALER_WALLET_Handle *h);
+TALER_WALLET_run(struct TALER_WALLET_Instance *h);
/**
* Block until the wallet returns.
*/
void
-TALER_WALLET_join(struct TALER_WALLET_Handle *wh);
+TALER_WALLET_join(struct TALER_WALLET_Instance *wh);
/**
* Destroy the wallet handle and free resources associated with it.
@@ -98,6 +98,6 @@ TALER_WALLET_join(struct TALER_WALLET_Handle *wh);
* sent a response to the shutdown message.
*/
void
-TALER_WALLET_destroy(struct TALER_WALLET_Handle *h);
+TALER_WALLET_destroy(struct TALER_WALLET_Instance *h);
#endif /*_TALER_WALLET_LIB_H */
diff --git a/wallet-client-example.c b/wallet-client-example.c
@@ -16,7 +16,7 @@
/**
- * Sample client for a TALER_WALLET_Handle.
+ * Sample client for a TALER_WALLET_Instance.
*/
#include <stdlib.h>
#include <stdio.h>
@@ -32,17 +32,17 @@ my_handler(void *cls, const char *message)
int main(int argc, char **argv)
{
- struct TALER_WALLET_Handle *wh = TALER_WALLET_create();
+ struct TALER_WALLET_Instance *wh = TALER_WALLET_create();
- TALER_WALLET_set_handler(wh, &my_handler, NULL);
+ TALER_WALLET_set_message_handler(wh, &my_handler, NULL);
TALER_WALLET_run(wh);
- TALER_WALLET_send_message(wh, "{\"operation\": \"init\", \"payload\": {\"skipDefaults\": true}}");
+ TALER_WALLET_send_request(wh, "{\"operation\": \"init\", \"payload\": {\"skipDefaults\": true}}");
- TALER_WALLET_send_message(wh, "{\"operation\": \"getVersion\"}");
+ TALER_WALLET_send_request(wh, "{\"operation\": \"getVersion\"}");
- //TALER_WALLET_send_message(wh, "{}");
+ //TALER_WALLET_send_request(wh, "{}");
// Wait for wallet thread to finish.
// If we don't call this, main() exits