diff options
author | kotontrion <[email protected]> | 2024-05-19 12:04:34 +0200 |
---|---|---|
committer | kotontrion <[email protected]> | 2024-05-19 12:04:34 +0200 |
commit | d8802b1fa2c586d05c73e53fb541e1ef482a527e (patch) | |
tree | 0196108ca63c7e5b7b3a23296aa4508f916b536e /examples/simple_example.c | |
parent | 3fc76b2f36e1bdebf2bd7a91af5469aff18ce852 (diff) |
init 0.1.0
Diffstat (limited to 'examples/simple_example.c')
-rw-r--r-- | examples/simple_example.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/simple_example.c b/examples/simple_example.c new file mode 100644 index 0000000..e48bc78 --- /dev/null +++ b/examples/simple_example.c @@ -0,0 +1,36 @@ +#include <bsd/readpassphrase.h> +#include "pam.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); +} |