summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/Daemon/DaemonController.cpp
blob: 1e8be804aff45c1d15ba805923277d119fc1d0a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// $Id$

/// Run with -ORBInifRef CIAODaemon=file://daemon.ior


#include "controller_i.h"
#include "ace/Get_Opt.h"
#include "ace/OS_NS_stdio.h"

int
write_IOR(const char* ior)
{
  FILE* ior_output_file_ =
    ACE_OS::fopen ("hello.ior", "w");

  if (ior_output_file_)
    {
      ACE_OS::fprintf (ior_output_file_,
                       "%s",
                       ior);
      ACE_OS::fclose (ior_output_file_);
    }

  return 0;
}

int
main (int argc, char *argv[])
{
  ACE_TRY_NEW_ENV
    {
      CIAO::Daemon_i::controller control_module;

      int res = control_module.init (argc, argv ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (res != 0)
        return -1;

      res = control_module.run (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (res != 0)
        return -1;

      control_module.fini ();
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "Exception caught:");
      return 1;
    }
  ACE_ENDTRY;

  return 0;
}