autoreconf
[moonshot-ui.git] / examples / service-selection.c
index 1a08cfc..48122be 100644 (file)
@@ -1,10 +1,11 @@
-#include <glib.h>
-#include "libmoonshot.h"
+#include <libmoonshot.h>
+
+#include <stdio.h>
 
 int main (int argc, char *argv[])
 {
-    MoonshotError *error;
-    gboolean        success;
+    MoonshotError *error = NULL;
+    int success;
 
     char *nai,
          *password,
@@ -13,9 +14,9 @@ int main (int argc, char *argv[])
          *subject_name_constraint,
          *subject_alt_name_constraint;
 
-    success = moonshot_get_identity ("user1@foo.baz",
-                                     "",
+    success = moonshot_get_identity ("",
                                      "",
+                                     "email@project-moonshot.org",
                                      &nai,
                                      &password,
                                      &server_certificate_hash,
@@ -24,13 +25,19 @@ int main (int argc, char *argv[])
                                      &subject_alt_name_constraint,
                                      &error);
 
-    if (success)
-        g_debug ("Got id: %s %s\n", nai, password);
+    if (success) {
+        printf ("Got identity: %s %s %s\n", nai, password, server_certificate_hash);
+
+        moonshot_free (nai);
+        moonshot_free (password);
+        moonshot_free (server_certificate_hash);
+        moonshot_free (ca_certificate);
+        moonshot_free (subject_name_constraint);
+        moonshot_free (subject_alt_name_constraint);
 
-    moonshot_free (nai);
-    moonshot_free (password);
-    moonshot_free (server_certificate_hash);
-    moonshot_free (ca_certificate);
-    moonshot_free (subject_name_constraint);
-    moonshot_free (subject_alt_name_constraint);
+        return 0;
+    } else {
+        printf ("Error: %s\n", error->message);
+        return 1;
+    }
 }