]> git.saurik.com Git - apple/launchd.git/blobdiff - launchd/testing/vproc_swap_complex.c
launchd-257.tar.gz
[apple/launchd.git] / launchd / testing / vproc_swap_complex.c
diff --git a/launchd/testing/vproc_swap_complex.c b/launchd/testing/vproc_swap_complex.c
new file mode 100644 (file)
index 0000000..6ff8d53
--- /dev/null
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <assert.h>
+#include <vproc.h>
+#include <vproc_priv.h>
+
+static void my_callback(const launch_data_t obj, const char *key, void *context);
+
+int main(void)
+{
+       launch_data_t output_obj = NULL;
+
+       assert(vproc_swap_complex(NULL, VPROC_GSK_ENVIRONMENT, NULL, &output_obj) == 0);
+
+       assert(launch_data_get_type(output_obj) == LAUNCH_DATA_DICTIONARY);
+
+       launch_data_dict_iterate(output_obj, my_callback, stdout);
+
+       return 0;
+}
+
+void
+my_callback(const launch_data_t obj, const char *key, void *context)
+{
+       fprintf(context, "%s == %s\n", key, launch_data_get_string(obj));
+}