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