summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/IFR_Service/be_init.cpp
blob: 8327a82601fe291678928257d174f2d448618e31 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// $Id$

#include "global_extern.h"
#include "be_extern.h"
#include "../../tao/Version.h"

int
BE_save_orb_args (int &argc, char *argv[])
{
  int i = 1;
  ACE_CString holder;

  while (i < argc)
    {
      if (ACE_OS::strncmp (argv[i], "-ORB", 4) == 0)
        {
          holder += ACE_CString (argv[i]);
          holder += " ";

          // Could be another -ORBxxx arg or an IDL compiler arg.
          if (*argv[i + 1] == '-')
            {
              ++i;
              continue;
            }

          // No-copy constructor.
          ACE_CString tmp (argv[i + 1],
                           0,
                           0);

          // If the arg ends with either .idl or .pidl, we're done.

          size_t len = tmp.length ();
          ssize_t pos = tmp.find (".idl");

          if (len - pos == 4)
            {
              return 0;
            }

          pos = tmp.find (".pidl");

          if (len - pos == 5)
            {
              return 0;
            }

          // If we're here, the next arg goes with the preceding -ORBxxx.
          holder += tmp;
          holder += " ";
          i += 2;
        }
      else
        {
          ++i;
        }
    }

  be_global->orb_args (holder);

  return 0;
}

// 'ac' must be passed in by reference, because it is also
// passed by reference to ORB_init, which may modify it.
// After BE_ifr_init returns to main() the modified argc
// must be passed to DRV_parse_args().
int
BE_ifr_orb_init (int &ac, char *av[])
{
  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      be_global->orb (CORBA::ORB_init (ac,
                                       av,
                                       0
                                       ACE_ENV_ARG_PARAMETER));
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           ACE_TEXT ("BE_ifr_orb_init"));

      return 1;
    }
  ACE_ENDTRY;

  return 0;
}

TAO_IFR_BE_Export void
BE_version (void)
{
  ACE_DEBUG ((LM_DEBUG,
              "%s %s\n",
              ACE_TEXT ("TAO_IFR_BE, version"),
              ACE_TEXT (TAO_VERSION)));
}

TAO_IFR_BE_Export int
BE_init (int &argc, char *argv[])
{
  // Initialize BE global data object.
  ACE_NEW_RETURN (be_global,
                  BE_GlobalData,
                  -1);

  int status = BE_save_orb_args (argc, argv);

  if (status != 0)
    {
      return status;
    }

  idl_global->using_ifr_backend (true);

  return BE_ifr_orb_init (argc, argv);
}

TAO_IFR_BE_Export void
BE_post_init (char *[], long)
{
}