Merge branch 'dbus-1.6'
[platform/upstream/dbus.git] / test / spawn-test.c
1 #include <config.h>
2 #include <dbus/dbus.h>
3
4 #define DBUS_COMPILATION /* cheat and use dbus-sysdeps */
5 #include <dbus/dbus-sysdeps.h>
6 #include <dbus/dbus-spawn.h>
7 #undef DBUS_COMPILATION
8 #include <stdio.h>
9
10 static void
11 setup_func (void *data)
12 {
13   printf ("entering setup func.\n");
14 }
15
16 int
17 main (int argc, char **argv)
18 {
19   char **argv_copy;
20   int i;
21   DBusError error;
22   
23   if (argc < 2)
24     {
25       fprintf (stderr, "You need to specify a program to launch.\n");
26
27       return -1;
28     }
29
30   argv_copy = dbus_new (char *, argc);
31   for (i = 0; i < argc - 1; i++)
32     argv_copy [i] = argv[i + 1];
33   argv_copy[argc - 1] = NULL;
34   
35   if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy, NULL, setup_func, NULL, &error))
36     {
37       fprintf (stderr, "Could not launch application: \"%s\"\n",
38                error.message);
39     }
40
41   dbus_free(argv_copy);
42  
43   return 0;
44 }