summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2021-11-10 16:20:04 +0000
committerVivien Kraus <vivien@planete-kraus.eu>2021-11-11 10:17:12 +0000
commit39c92cc3f96ead3c9033ccd549cc4dce59ea3485 (patch)
tree0068c648f241fe2f6cb416505f88e06789b0c4cf
parenta3af69fc2eadaa452fe068316c74e87443fa3eb1 (diff)
Client API: make it more vala-friendly
-rw-r--r--src/client/Disfluid-0.h35
-rw-r--r--src/client/Disfluid-0.metadata1
-rw-r--r--src/client/Makefile.am6
-rw-r--r--src/client/libwebidoidc-client.c22
4 files changed, 33 insertions, 31 deletions
diff --git a/src/client/Disfluid-0.h b/src/client/Disfluid-0.h
index 52afe0c..05ce0c4 100644
--- a/src/client/Disfluid-0.h
+++ b/src/client/Disfluid-0.h
@@ -35,7 +35,7 @@ typedef struct DisfluidApi DisfluidApi;
*
* The type of function that is called with the API loaded.
*/
-typedef void *(*DisfluidUser) (const struct DisfluidApi * api, void *data);
+typedef void *(*DisfluidUser) (const DisfluidApi * api, void *data);
/**
* disfluid_api_init:
@@ -60,20 +60,19 @@ struct DisfluidClient;
typedef struct DisfluidClient DisfluidClient;
/**
- * disfluid_client_make:
+ * disfluid_api_make_client:
* @api: the context loaded with @disfluid_init.
+ * @client: (out) (transfer full): where to store the allocated client.
* @client_id: the URI serving a client manifest on the web.
* @redirect_uri: the URI where we can get back an authorization code.
* @jwk: the JWK encoding of the key pair used by the client.
*
* Create a new client.
- *
- * Returns: (transfer full): the allocated client.
*/
-struct DisfluidClient *disfluid_client_make (const struct DisfluidApi *api,
- const char *client_id,
- const char *redirect_uri,
- const char *jwk);
+void disfluid_api_make_client (const DisfluidApi * api,
+ DisfluidClient ** client,
+ const char *client_id,
+ const char *redirect_uri, const char *jwk);
/**
* disfluid_client_free:
@@ -81,46 +80,46 @@ struct DisfluidClient *disfluid_client_make (const struct DisfluidApi *api,
*
* Delete @client.
*/
-void disfluid_client_free (struct DisfluidClient *client);
+void disfluid_client_free (DisfluidClient * client);
/**
* disfluid_client_get_id:
- * @api: the context API.
* @client: the client whose ID to lookup.
+ * @api: the context API.
* @start: how many URL prefix bytes to skip.
* @max: how many URL bytes to copy after the skipped prefix.
* @id: (array length=max) (element-type char): where to copy the URL bytes.
* Returns: the total number of bytes in the URL.
*/
-size_t disfluid_client_get_id (const struct DisfluidApi *api,
- const struct DisfluidClient *client,
+size_t disfluid_client_get_id (const DisfluidClient * client,
+ const DisfluidApi * api,
size_t start, size_t max, char *id);
/**
* disfluid_client_get_redirect_uri:
- * @api: the context API.
* @client: the client whose redirection URI to lookup.
+ * @api: the context API.
* @start: how many URL prefix bytes to skip.
* @max: how many URL bytes to copy after the skipped prefix.
* @redirect_uri: (array length=max) (element-type char): where to copy the URL bytes.
* Returns: the total number of bytes in the URL.
*/
-size_t disfluid_client_get_redirect_uri (const struct DisfluidApi *api,
- const struct DisfluidClient *client,
+size_t disfluid_client_get_redirect_uri (const DisfluidClient * client,
+ const DisfluidApi * api,
size_t start, size_t max,
char *redirect_uri);
/**
* disfluid_client_get_key_pair:
- * @api: the context API.
* @client: the client whose key pair to dump.
+ * @api: the context API.
* @start: how many JWK prefix bytes to skip.
* @max: how many JWK bytes to copy after the skipped prefix.
* @jwk: (array length=max) (element-type char): where to copy the JWK bytes.
* Returns: the total number of bytes in the JWK.
*/
-size_t disfluid_client_get_key_pair (const struct DisfluidApi *api,
- const struct DisfluidClient *client,
+size_t disfluid_client_get_key_pair (const DisfluidClient * client,
+ const DisfluidApi * api,
size_t start, size_t max, char *jwk);
#endif
diff --git a/src/client/Disfluid-0.metadata b/src/client/Disfluid-0.metadata
new file mode 100644
index 0000000..f407c61
--- /dev/null
+++ b/src/client/Disfluid-0.metadata
@@ -0,0 +1 @@
+// Add vapi metadata here \ No newline at end of file
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index 1892cdc..aad9fbc 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -36,6 +36,8 @@ vapidir = $(datadir)/vala/vapi
dist_vapi_DATA = %reldir%/disfluid-0.vapi
+EXTRA_DIST += %reldir%/Disfluid-0.metadata
+
CLEANFILES += %reldir%/vapi-generation
%reldir%/Disfluid-0.gir: %reldir%/Disfluid-0.h
@@ -46,10 +48,10 @@ CLEANFILES += %reldir%/vapi-generation
$(AM_V_GEN) $(G_IR_COMPILER) -o $@-t --shared-library=libwebidoidc $(srcdir)/$<
@mv $@-t $(srcdir)/$@
-%reldir%/disfluid-0.vapi: %reldir%/Disfluid-0.gir
+%reldir%/disfluid-0.vapi: %reldir%/Disfluid-0.gir %reldir%/Disfluid-0.metadata
@rm -rf %reldir%/vapi-generation
@mkdir %reldir%/vapi-generation
- $(AM_V_GEN) $(VAPIGEN) --library disfluid-0 -d %reldir%/vapi-generation $(srcdir)/$<
+ $(AM_V_GEN) $(VAPIGEN) --library disfluid-0 -d %reldir%/vapi-generation $(srcdir)/$< --metadatadir=$(srcdir)/%reldir%
@mv %reldir%/vapi-generation/disfluid-0.vapi $@-t
@rmdir %reldir%/vapi-generation
@mv $@-t $(srcdir)/$@
diff --git a/src/client/libwebidoidc-client.c b/src/client/libwebidoidc-client.c
index 8c22cc6..836ff69 100644
--- a/src/client/libwebidoidc-client.c
+++ b/src/client/libwebidoidc-client.c
@@ -62,8 +62,9 @@ struct DisfluidClient
SCM object;
};
-struct DisfluidClient *
+void
disfluid_client_make (const struct DisfluidApi *api,
+ struct DisfluidClient **client,
const char *client_id,
const char *redirect_uri, const char *jwk)
{
@@ -78,11 +79,10 @@ disfluid_client_make (const struct DisfluidApi *api,
scm_call_3 (api->scm_make_client, scm_client_id, scm_redirect_uri,
scm_jwk);
scm_dynwind_begin (0);
- struct DisfluidClient *ret = scm_malloc (sizeof (struct DisfluidClient));
- scm_dynwind_unwind_handler (free, ret, 0);
- ret->object = scm_gc_protect_object (object);
+ *client = scm_malloc (sizeof (struct DisfluidClient));
+ scm_dynwind_unwind_handler (free, *client, 0);
+ (*client)->object = scm_gc_protect_object (object);
scm_dynwind_end ();
- return ret;
}
void
@@ -116,8 +116,8 @@ copy_scm_string (SCM string, size_t start, size_t max, char *dest)
}
size_t
-disfluid_client_get_id (const struct DisfluidApi *api,
- const struct DisfluidClient *client,
+disfluid_client_get_id (const struct DisfluidClient *client,
+ const struct DisfluidApi *api,
size_t start, size_t max, char *id)
{
SCM scm_id = scm_call_1 (api->scm_get_client_id, client->object);
@@ -125,8 +125,8 @@ disfluid_client_get_id (const struct DisfluidApi *api,
}
size_t
-disfluid_client_get_key_pair (const struct DisfluidApi *api,
- const struct DisfluidClient *client,
+disfluid_client_get_key_pair (const struct DisfluidClient *client,
+ const struct DisfluidApi *api,
size_t start, size_t max, char *jwk)
{
SCM scm_jwk = scm_call_1 (api->scm_get_key_pair, client->object);
@@ -134,8 +134,8 @@ disfluid_client_get_key_pair (const struct DisfluidApi *api,
}
size_t
-disfluid_client_get_redirect_uri (const struct DisfluidApi *api,
- const struct DisfluidClient *client,
+disfluid_client_get_redirect_uri (const struct DisfluidClient *client,
+ const struct DisfluidApi *api,
size_t start, size_t max,
char *redirect_uri)
{