summaryrefslogtreecommitdiff
path: root/TAO/utils
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2002-01-15 17:55:21 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2002-01-15 17:55:21 +0000
commit7a065e5960b437543565cad08bcb630092eeba8d (patch)
tree5588d29b7907ef4e1d5b5b1ea2b6a8ae7b504d15 /TAO/utils
parentd5600758d43429716726bcd82be5bdb9a7aed65b (diff)
downloadATCD-7a065e5960b437543565cad08bcb630092eeba8d.tar.gz
ChangeLogTag:Tue Jan 15 10:52:12 2002 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/utils')
-rw-r--r--TAO/utils/nslist/nsdel.cpp66
1 files changed, 58 insertions, 8 deletions
diff --git a/TAO/utils/nslist/nsdel.cpp b/TAO/utils/nslist/nsdel.cpp
index e3723150f87..538190dc7ad 100644
--- a/TAO/utils/nslist/nsdel.cpp
+++ b/TAO/utils/nslist/nsdel.cpp
@@ -12,7 +12,8 @@
// Naming Service del utility
//
// = AUTHOR
-// Carlos O'Ryan
+// Carlos O'Ryan <coryan@uci.edu>
+// enhanced Jan 15, 2001 Paul Caffrey <denginere@hotmail.com>
//
// ================================================================
@@ -33,11 +34,11 @@ main (int argc, char *argv[])
ACE_TRY_CHECK;
char *pname = argv[0];
+ const char *name = 0;
- const char * name = 0;
while (argc > 0)
{
- if (strcmp(*argv, "--name") == 0)
+ if (strcmp (*argv, "--name") == 0)
{
if (argc == 1)
{
@@ -58,12 +59,53 @@ main (int argc, char *argv[])
argc--;
argv++;
}
+
if (name == 0)
{
ACE_DEBUG ((LM_DEBUG,
"Usage: %s [ --name <name> ]\n", pname));
return 1;
}
+ // make a copy
+
+ char buf[BUFSIZ];
+ strcpy (buf, name);
+ char *bp = &buf[0];
+ char *cp = 0;
+ int ntoks = 0;
+ char *toks[20];
+
+ while ((cp = strtok (bp, "/")) != 0)
+ {
+ toks[ntoks] = cp;
+ ntoks++;
+ if (cp == NULL)
+ {
+ printf ("break, null token\n");
+ break;
+ }
+ bp = 0; // way strtok works
+ }
+
+ for (int i=0; i<ntoks; i++)
+ printf ("%s\n", toks[i]);
+
+ // now assign name = toks[ntoks]
+ char lastname[BUFSIZ];
+ strcpy (lastname, toks[ntoks - 1]);
+
+ // search for '.' in name; if exists then the part after '.' is the kind
+ char *kind = strchr (lastname, '.');
+
+ if (kind != 0)
+ {
+ *kind = 0;
+ kind++;
+ printf ("name='%s'\n", lastname);
+ printf ( "kind='%s'\n" , kind );
+ }
+ else
+ printf ("name=%s\n", lastname );
CORBA::Object_var nc_obj =
orb->resolve_initial_references ("NameService" TAO_ENV_ARG_PARAMETER);
@@ -72,6 +114,7 @@ main (int argc, char *argv[])
CosNaming::NamingContext_var root_nc =
CosNaming::NamingContext::_narrow (nc_obj.in () TAO_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
+
if (CORBA::is_nil (root_nc.in ()))
{
ACE_DEBUG ((LM_DEBUG,
@@ -79,10 +122,15 @@ main (int argc, char *argv[])
return 1;
}
- CosNaming::Name the_name (1);
- the_name.length (1);
- the_name[0].id = CORBA::string_dup (name);
- root_nc->unbind (the_name TAO_ENV_ARG_PARAMETER);
+ CosNaming::Name the_name (ntoks);
+ the_name.length (ntoks);
+ for (int i=0; i<(ntoks - 1); i++) // up to last directory entry
+ the_name[i].id = CORBA::string_dup (toks[i]);
+
+ the_name[ntoks - 1].id = CORBA::string_dup (lastname);
+ if (kind != 0)
+ the_name[ntoks - 1].kind = CORBA::string_dup (kind);
+ root_nc->unbind (the_name, ACE_TRY_ENV);
ACE_TRY_CHECK;
}
ACE_CATCHANY
@@ -92,6 +140,8 @@ main (int argc, char *argv[])
return 1;
}
ACE_ENDTRY;
-
+
return 0;
}
+
+