os/ossrv/ofdbus/dbus/tsrc/testapps/dbus_test_cases/spawn-test.c
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /* Portion Copyright © 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.*/
     2 #include <dbus/dbus.h>
     3 
     4 #define DBUS_COMPILATION /* cheat and use dbus-sysdeps */
     5 #ifndef __SYMBIAN32__
     6 #include <dbus/dbus-sysdeps.h>
     7 #include <dbus/dbus-spawn.h>
     8 #else
     9 #include "dbus-sysdeps.h"
    10 #include "dbus-spawn.h"
    11 #endif //__SYMBIAN32__
    12 #undef DBUS_COMPILATION
    13 #include <stdio.h>
    14 
    15 static void
    16 setup_func (void *data)
    17 {
    18   printf ("entering setup func.\n");
    19 }
    20 
    21 int
    22 main (int argc, char **argv)
    23 {
    24   char **argv_copy;
    25   int i;
    26   DBusError error;
    27   
    28   if (argc < 2)
    29     {
    30       fprintf (stderr, "You need to specify a program to launch.\n");
    31 
    32       return -1;
    33     }
    34 
    35   argv_copy = dbus_new (char *, argc);
    36   for (i = 0; i < argc - 1; i++)
    37     argv_copy [i] = argv[i + 1];
    38   argv_copy[argc - 1] = NULL;
    39   
    40   if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy, setup_func, NULL, &error))
    41     {
    42       fprintf (stderr, "Could not launch application: \"%s\"\n",
    43 	       error.message);
    44     }
    45   
    46   return 0;
    47 }