Merge branch 'master' into jwi-bcc64xsingletonwarning
[ACE_TAO.git] / ACE / examples / Naming / test_multiple_contexts.cpp
blob1884810758ddc42d3a0d308ea56bdfc4b91e9f2b
1 #include "ace/OS_main.h"
2 #include "ace/Naming_Context.h"
3 #include "ace/Log_Msg.h"
4 #include "ace/OS_NS_stdio.h"
6 int ACE_TMAIN (int, ACE_TCHAR *[])
8 static u_long ACE_DEFAULT_BASE_ADDR_1 = (1 * 64 * 1024 * 1024);
9 static u_long ACE_DEFAULT_BASE_ADDR_2 = (2 * 64 * 1024 * 1024);
11 int i;
13 ACE_STATIC_SVC_REGISTER(ACE_Naming_Context);
15 ACE_Naming_Context *ns_ptr;
16 ACE_NEW_RETURN (ns_ptr,
17 ACE_Naming_Context,
18 1);
19 ACE_Name_Options *name_options =
20 ns_ptr->name_options ();
22 ACE_Naming_Context *ns_ptr1;
23 ACE_NEW_RETURN (ns_ptr1,
24 ACE_Naming_Context,
25 1);
26 ACE_Name_Options *name_options1 =
27 ns_ptr1->name_options ();
29 ACE_TCHAR address_arg1[BUFSIZ];
30 ACE_TCHAR address_arg2[BUFSIZ];
31 ACE_OS::sprintf (address_arg1,
32 ACE_TEXT("-b%ld"),
33 ACE_DEFAULT_BASE_ADDR_1);
35 const ACE_TCHAR *m_argv[] =
37 ACE_TEXT("MyName1"),
38 ACE_TEXT("-cNODE_LOCAL"),
39 address_arg1,
42 int m_argc =
43 sizeof (m_argv) / sizeof (ACE_TCHAR *) -1;
45 ACE_OS::sprintf (address_arg2,
46 ACE_TEXT("-b%ld"),
47 ACE_DEFAULT_BASE_ADDR_2);
48 const ACE_TCHAR *n_argv[] =
50 ACE_TEXT("MyName2"),
51 ACE_TEXT("-cNODE_LOCAL"),
52 address_arg2,
56 int n_argc =
57 sizeof (n_argv) / sizeof (ACE_TCHAR *) -1;
59 name_options->parse_args (m_argc,
60 (ACE_TCHAR **) m_argv);
61 i = ns_ptr->open (ACE_Naming_Context::NODE_LOCAL);
63 ACE_DEBUG ((LM_DEBUG,
64 "(%P) opened with %d\n",
65 i));
67 if (i != 0)
68 return -1;
70 name_options1->parse_args (n_argc,
71 (ACE_TCHAR **) n_argv);
73 i = ns_ptr1->open (ACE_Naming_Context::NODE_LOCAL);
75 ACE_DEBUG ((LM_DEBUG,
76 "(%P) 1 opened with %d\n",
77 i));
78 if (i != 0)
79 return -1;
81 return 0;