ofdbus/dbus/tsrc/testapps/dbus_test_cases/spawn-test.c
changeset 31 ce057bb09d0b
child 34 5fae379060a7
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 #include <dbus/dbus.h>
       
    19 
       
    20 #define DBUS_COMPILATION /* cheat and use dbus-sysdeps */
       
    21 #ifndef __SYMBIAN32__
       
    22 #include <dbus/dbus-sysdeps.h>
       
    23 #include <dbus/dbus-spawn.h>
       
    24 #else
       
    25 #include "dbus-sysdeps.h"
       
    26 #include "dbus-spawn.h"
       
    27 #endif //__SYMBIAN32__
       
    28 #undef DBUS_COMPILATION
       
    29 #include <stdio.h>
       
    30 
       
    31 static void
       
    32 setup_func (void *data)
       
    33 {
       
    34   printf ("entering setup func.\n");
       
    35 }
       
    36 
       
    37 int
       
    38 main (int argc, char **argv)
       
    39 {
       
    40   char **argv_copy;
       
    41   int i;
       
    42   DBusError error;
       
    43   
       
    44   if (argc < 2)
       
    45     {
       
    46       fprintf (stderr, "You need to specify a program to launch.\n");
       
    47 
       
    48       return -1;
       
    49     }
       
    50 
       
    51   argv_copy = dbus_new (char *, argc);
       
    52   for (i = 0; i < argc - 1; i++)
       
    53     argv_copy [i] = argv[i + 1];
       
    54   argv_copy[argc - 1] = NULL;
       
    55   
       
    56   if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy, setup_func, NULL, &error))
       
    57     {
       
    58       fprintf (stderr, "Could not launch application: \"%s\"\n",
       
    59 	       error.message);
       
    60     }
       
    61   
       
    62   return 0;
       
    63 }