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