From 6adcd2884ee48ec0b1c8b7486e42b2eeffc48159 Mon Sep 17 00:00:00 2001 From: Aylur Date: Sun, 1 Sep 2024 03:19:31 +0200 Subject: move to monorepo --- auth/examples/simple_example.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 auth/examples/simple_example.c (limited to 'auth/examples/simple_example.c') diff --git a/auth/examples/simple_example.c b/auth/examples/simple_example.c new file mode 100644 index 0000000..d00bad2 --- /dev/null +++ b/auth/examples/simple_example.c @@ -0,0 +1,31 @@ +#include + +#include "astal-auth.h" + +GMainLoop *loop; + +void ready_callback(AstalAuthPam *pam, GAsyncResult *res, gpointer user_data) { + GError *error = NULL; + astal_auth_pam_authenticate_finish(res, &error); + if (error == NULL) { + g_print("success\n"); + } else { + g_print("failure: %s\n", error->message); + g_error_free(error); + } + + g_main_loop_quit(loop); +} + +int main(void) { + GMainContext *loopctx = NULL; + loop = g_main_loop_new(loopctx, FALSE); + + gchar *passbuf = calloc(1024, sizeof(gchar)); + readpassphrase("Password: ", passbuf, 1024, RPP_ECHO_OFF); + astal_auth_pam_authenticate(passbuf, (GAsyncReadyCallback)ready_callback, NULL); + g_free(passbuf); + + g_main_loop_run(loop); + exit(EXIT_SUCCESS); +} -- cgit v1.2.3