예제 #1
0
static void
MateCORBA_initial_references_by_user (CORBA_ORB          orb,
				  gchar             *naming_ref,
				  GSList            *initref_list,
				  CORBA_Environment *ev)
{
	GSList *l;
	CORBA_Object objref;

	if (ev->_major != CORBA_NO_EXCEPTION)
		return;

	if (naming_ref) {
		objref = CORBA_ORB_string_to_object (orb, naming_ref, ev);

		/* FIXME, should abort if invalid option, don't forget
		 * to free resources allocated by ORB */
		if (ev->_major != CORBA_NO_EXCEPTION) {
			g_warning ("Option ORBNamingIOR has invalid object reference: %s",
				   naming_ref);
			CORBA_exception_free (ev);
		} else {
			/* FIXME, test type of object for
			 * IDL:omg.org/CosNaming/NamingContext using _is_a()
			 * operation */
			MateCORBA_set_initial_reference (orb, "NameService", objref);
			MateCORBA_RootObject_release (objref);
		}
	}

	for (l = initref_list; l; l = l->next) {
		MateCORBA_OptionKeyValue *tuple = l->data;

		g_assert (tuple != NULL);
		g_assert (tuple->key   != (gchar*)NULL);
		g_assert (tuple->value != (gchar*)NULL);

		objref = CORBA_ORB_string_to_object (orb, tuple->value, ev);

		/* FIXME, should abort if invalid option,
		 * don't forget to free resources allocated by
		 * ORB */
		if (ev->_major != CORBA_NO_EXCEPTION) {
			g_warning ("Option ORBInitRef has invalid object reference: %s=%s",
				   tuple->key, tuple->value);
			CORBA_exception_free (ev);
		} else {
			if (MateCORBA_initial_reference_protected_id(tuple->key)) {
				g_warning ("Option ORBInitRef permission denied: %s=%s",
					   tuple->key, tuple->value);
			} else {
				MateCORBA_set_initial_reference (orb, tuple->key, objref);
			}

			MateCORBA_RootObject_release (objref);
		}
	}

}
JNIEXPORT jstring JNICALL
Java_jp_ac_utsunomiya_is_SS2012FPGA_initialize( JNIEnv* env,
        jobject thiz,
        jstring ior)
{
    //printf("Hello from JNI");

    char *bytes = (*env)->GetStringUTFChars(env, ior, NULL);

    int argc = 1;
    char* argv_word = "";
    char** argv;
    argv[0] = argv_word;

    orb = (CORBA_ORB)CORBA_ORB_init(&argc, argv, 0, &corba_env);
    ev = &corba_env;

    _obj = (CORBA_jp_ac_utsunomiya_is_SS2012FPGA) CORBA_ORB_string_to_object
           (orb, bytes, &corba_env);


    //char objname[256];
    //sprintf(objname, "%x", &_obj);
    jstring strj = (*env)->NewStringUTF(env, "motor");

    (*env)->ReleaseStringUTFChars(env, ior, bytes);
    return strj;
}
예제 #3
0
static CORBA_Object
BasicServer_getObject (PortableServer_Servant  servant,
		       const CORBA_long        which,
		       CORBA_Environment      *ev)
{
	if (which < G_N_ELEMENTS (iorstrings))
		return CORBA_ORB_string_to_object (global_orb, iorstrings[which], ev);
	else
		return CORBA_OBJECT_NIL;
}
예제 #4
0
static void
do_query_server_info(void)
{
	Bonobo_ActivationContext ac;
	Bonobo_ServerInfoList *slist;
	Bonobo_StringList reqs = { 0 };

	if (acior) {
                ac = CORBA_ORB_string_to_object (orb, acior, &ev);
                if (ev._major != CORBA_NO_EXCEPTION)
                        g_print ("Error doing string_to_object(%s)\n", acior);
        } else
                ac = bonobo_activation_activation_context_get ();

	slist = Bonobo_ActivationContext_query (
                                        ac, specs, &reqs,
                                        bonobo_activation_context_get (), &ev);
	switch (ev._major) {
        case CORBA_NO_EXCEPTION:
		od_dump_list (slist);
		CORBA_free (slist);
		break;
	case CORBA_USER_EXCEPTION:
		{
			char *id;
			id = CORBA_exception_id (&ev);
			g_print ("User exception \"%s\" resulted from query\n", id);
			if (!strcmp (id, "IDL:Bonobo/ActivationContext/ParseFailed:1.0")) {
				Bonobo_Activation_ParseFailed
						* exdata = CORBA_exception_value (&ev);
				if (exdata)
					g_print ("Description: %s\n", exdata->description);
			}
		}
		break;
	case CORBA_SYSTEM_EXCEPTION:
		{
			char *id;
			id = CORBA_exception_id (&ev);
			g_print ("System exception \"%s\" resulted from query\n", id);	
        	}
		break;
        }	
	return;	
}
예제 #5
0
Bonobo_Unknown
bonobo_moniker_ior_resolve (BonoboMoniker               *moniker,
			    const Bonobo_ResolveOptions *options,
			    const CORBA_char            *requested_interface,
			    CORBA_Environment           *ev)
{
	const char    *ior;
	CORBA_Object   object;
	Bonobo_Unknown retval;
	gboolean       is_unknown, is_correct;

	ior = bonobo_moniker_get_name (moniker);
	
	object = CORBA_ORB_string_to_object (bonobo_orb (), ior, ev);
	BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);

	is_unknown = CORBA_Object_is_a (object, "IDL:Bonobo/Unknown:1.0", ev);
	BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);

	if (!is_unknown) {
		is_correct = CORBA_Object_is_a (object, requested_interface, ev);
		BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);

		if (is_correct)
			return object;
		else {
			CORBA_exception_set (
				ev, CORBA_USER_EXCEPTION,
				ex_Bonobo_Moniker_InterfaceNotFound, NULL);
			return CORBA_OBJECT_NIL;
		}
	}

	retval = Bonobo_Unknown_queryInterface (
		object, requested_interface, ev);
	BONOBO_RET_VAL_EX (ev, CORBA_OBJECT_NIL);
	
	if (retval == CORBA_OBJECT_NIL)
		CORBA_exception_set (
			ev, CORBA_USER_EXCEPTION,
			ex_Bonobo_Moniker_InterfaceNotFound, NULL);

	return retval;
}
예제 #6
0
static PyObject *
pycorba_orb_string_to_object(PyCORBA_ORB *self, PyObject *args)
{
    CORBA_Object objref;
    CORBA_Environment ev;
    gchar *ior;
    PyObject *py_objref;

    if (!PyArg_ParseTuple(args, "s:CORBA.ORB.string_to_object", &ior))
	return NULL;
    
    CORBA_exception_init(&ev);
    objref = CORBA_ORB_string_to_object(self->orb, ior, &ev);
    if (pymatecorba_check_ex(&ev))
	return NULL;
    py_objref = pycorba_object_new(objref);
    CORBA_Object_release(objref, NULL);
    return py_objref;
}
예제 #7
0
static int
register_activate_server(void)
{
	Bonobo_RegistrationResult res;
	CORBA_Object r_obj = CORBA_OBJECT_NIL;

	if (registerior) {
		r_obj = CORBA_ORB_string_to_object (orb, registerior, &ev);
		if (ev._major != CORBA_NO_EXCEPTION)
			return 1;
	}

	if (r_obj) {
		res = bonobo_activation_active_server_register(registeriid, r_obj);
		if (res == Bonobo_ACTIVATION_REG_SUCCESS || res == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE)
			return 0;
	}

	return 1;
}
예제 #8
0
파일: phonebook.c 프로젝트: berkus/flick
int main(int argc, char **argv) 
{
	CORBA_ORB orb = 0;
	CORBA_Environment ev;
	data_phonebook obj;
	int sel, done;
	
	if (argc != 2) {
		fprintf(stderr,
			"Usage: %s <phone obj reference>\n", argv[0]);
		exit(1);
	}
	
	orb = CORBA_ORB_init(&argc, argv, 0, &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		printf("Can't initialize the ORB.\n");
		exit(1);
	}
	
	obj = CORBA_ORB_string_to_object(orb, argv[1], &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		printf("Can't convert `%s' into an object reference.\n",
		       argv[1]);
		exit(1);
	}
	
	done = 0;
	while (!done) {
		read_integer(("\n(1) Add an entry (2) Remove an entry "
			      "(3) Find a phone number (4) Exit: "),
			     &sel);
		switch(sel) {
		case 1:  add_entry(obj); break;
		case 2:  remove_entry(obj); break;
		case 3:  find_entry(obj); break;
		case 4:  done = 1; break;
		default: printf("Please enter 1, 2, 3, or 4.\n");
		}
	}
	return 0;
}
CORBA_Object
matecomponent_activation_base_service_check (const MateComponentActivationBaseService *base_service,
                                      CORBA_Environment                 *ev)
{
	GSList *link;
	CORBA_Object retval = CORBA_OBJECT_NIL;
	int dist = INT_MAX;
	char *ior = NULL;

	for (link = registries; link; link = link->next) {
		RegistryInfo *ri;
		char *new_ior;
		int new_dist = dist;

		ri = link->data;

		if (!ri->registry->check)
			continue;

		new_ior = ri->registry->check (ri->registry, base_service, 
                                             &new_dist, ri->user_data);
		if (new_ior && (new_dist < dist)) {
			g_free (ior);
			ior = new_ior;
		} else if (new_ior) {
			g_free (new_ior);
		}
	}

	if (ior) {
		retval = CORBA_ORB_string_to_object (matecomponent_activation_orb_get (), ior, ev);
		if (ev->_major != CORBA_NO_EXCEPTION)
			retval = CORBA_OBJECT_NIL;

		g_free (ior);
	}

	return retval;
}
예제 #10
0
CORBA_Object
etk_import_object_from_stream (CORBA_ORB          orb,
			       FILE              *stream,
			       CORBA_Environment *ev)
{
	CORBA_Object obj = CORBA_OBJECT_NIL;
	gchar *objref=etk_read_string_from_stream (stream);

	if (!objref || strlen (objref)==0) {
		g_warning ("empty object reference");
		if (objref) 
			g_free (objref);
		return CORBA_OBJECT_NIL;		
	}

	obj = (CORBA_Object) CORBA_ORB_string_to_object (orb,
							 objref, 
							 ev);
	free (objref);
	
	return obj;
}
예제 #11
0
int
main (int argc, char *argv[]) {
	CORBA_Environment ev;
	CORBA_ORB orb;
	CORBA_double rv;
	char buf[30];
	int i;

	int niters = 1000;

	CORBA_exception_init(&ev);
	orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);

	/* read IOR from command line as first argument */
	if(argc < 2) {
		g_print ("ERROR, usage: %s <ior> [<#iterations>]\n", argv[0]);
		return 1;
	}

	if (argv[1][0] == '$')
	  argv[1] = getenv (argv[1]+1);

	/* read (optional) number of iterations from command line as
	 * second argument (100) */    
	if(argc == 3)
		niters = atoi(argv[2]);
    
	/* bind to object */
	echo_client = CORBA_ORB_string_to_object(orb, argv[1], &ev);
	ABORT_IF_EXCEPTION (&ev, "cannot bind to object");
	g_assert (echo_client!=NULL);

	/* Iterate various times.  Each time the client invokes
	 * 'echoString(..)'  a new reference to service is returned which
	 * is used for next loop. At end of each loop the old
	 * obj. reference is released. */
	for(i = 0; i < niters; i++) {
		/* Method call without any argument, usefull to tell
		 * lifeness */
		Echo_doNothing(echo_client, &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* Ask echo-service to print string 'buf' on console. The
		 * service returns random double float value in 'vr' */
		g_snprintf(buf, sizeof(buf), "Hello, world [%d]", i);
		bec = Echo_echoString(echo_client, buf, &rv, &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* print random value generated by echo-service */
		if ( !echo_opt_quiet )
			g_message("[client] %g", rv);

		/* Asynchronous/oneway method call, the function returns
		 * immediately.  Usefull for log-message transfer */
		Echo_doOneWay(echo_client, "log message ", &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* release first object reference and use the new one for
		 * next loop */
		CORBA_Object_release(echo_client, &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* swap object references */ 
		echo_client = bec; bec = CORBA_OBJECT_NIL;
	}
    
	/* release initial object reference */
	CORBA_Object_release(echo_client, &ev);
	ABORT_IF_EXCEPTION (&ev, "service raised exception ");

	/* shutdown ORB, shutdown IO channels */
	CORBA_ORB_shutdown (orb, FALSE, &ev);
	ABORT_IF_EXCEPTION(&ev, "ORB shutdown ...");

	/* destroy local ORB */
	CORBA_ORB_destroy(orb, &ev);
	ABORT_IF_EXCEPTION (&ev, "destroying local ORB raised exception");

	return 0;
}
예제 #12
0
파일: test1-use.c 프로젝트: berkus/flick
int main(int argc, char **argv)
{
	CORBA_ORB orb = 0;
	CORBA_Object obj;
#define C_DECLV(type) CORBA_##type	ret##type, in##type, out##type, inout##type
#define T_DECLV(type) test1_##type	ret##type, in##type, out##type, inout##type
	C_DECLV(short);
	C_DECLV(long);
	T_DECLV(ushort);
	T_DECLV(ulong);
	C_DECLV(float);
	C_DECLV(double);
	C_DECLV(char);
	C_DECLV(boolean);
	C_DECLV(octet);
	C_DECLV(Object);
	
	CORBA_char *instring, *outstring, *inoutstring, *retstring;
	CORBA_long case_num;
	CORBA_Environment ev;
	
	orb = CORBA_ORB_init(&argc, argv, 0 /* use default ORBid */, &ev);
	obj = CORBA_ORB_string_to_object(orb, argv[1], &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		printf("Problem converting `%s' to an object.\n", argv[1]);
		exit(1);
	}
	printf("Beginning communication...\n");
#define SHOWPARMS(prn, type)						    \
	if (ev._major != CORBA_NO_EXCEPTION)				    \
		printf("Exception: `%s' EXCEPTION RAISED FOR " #type "!\n", \
		       CORBA_exception_id(&ev));			    \
	else								    \
		printf("Exception: no\n");				    \
	printf("In:       " #prn"\n", in##type);			    \
	printf("Inout:    " #prn"\n", inout##type);			    \
	printf("Out:      " #prn"\n", out##type);			    \
	printf("Result:   " #prn"\n", ret##type);
#define RUNTEST(type, inval, inoutval, otherval, prn)			\
	in##type = inval;						\
	inout##type = inoutval;						\
	ret##type = out##type = otherval;				\
	ev._major = CORBA_NO_EXCEPTION;					\
	printf("Testing " #type" Before Call:\n");			\
	SHOWPARMS(##prn, ##type);					\
	printf("Calling Server...\n");					\
	ret##type = test1_test_##type(obj, in##type, &out##type,	\
				      &inout##type, &ev);		\
	printf("After Call:\n");					\
	SHOWPARMS(##prn, ##type);
	
	RUNTEST(short, 1234, 4321, 7, %d);
	RUNTEST(ushort, 65500, 33000, 6, %d);
	RUNTEST(long, 12341234, 43214321, 2, %d);
	RUNTEST(ulong, 3000000000U, 4000000000U, 5, %u);
	RUNTEST(float, 1.234, 2.345, 3.1415, %f);
	RUNTEST(double, 1.2345678901, 2.3456789012, 2.71828, %f);
	RUNTEST(boolean, 0, 1, 2, %d);
	RUNTEST(octet, 12, 23, 34, %d);
	RUNTEST(char, 'a', 'b', 'c', %c);
	
	/* Must allocate the `inout' string with the CORBA allocator. */
	inoutstring = (char *) CORBA_alloc(sizeof("Howdy"));
	(void)strcpy(inoutstring, "Howdy");
	RUNTEST(string, "Hello", inoutstring, "Ugh", %s);
	
	/* Now run the object passing test */
        inObject = CORBA_Object_duplicate(obj, &ev);
        inoutObject = CORBA_Object_duplicate(obj, &ev);
	/* check for exception */
        retObject = outObject = 0;
        printf("Testing Object Before Call:\n");
	if (ev._major != CORBA_NO_EXCEPTION)
		printf("Exception: `%s' EXCEPTION RAISED FOR Object!\n",
		       CORBA_exception_id(&ev));
	else
		printf("Exception: no\n");
        printf("In:       %p\nURL:\t%s\nIOR:\t%s\n", inObject,
	       CORBA_ORB_object_to_readable_string(orb, inObject, &ev),
	       CORBA_ORB_object_to_string(orb, inObject, &ev));
        printf("Inout:    %p\nURL:\t%s\nIOR:\t%s\n", (void *)inoutObject,
	       CORBA_ORB_object_to_readable_string(orb, inoutObject, &ev),
	       CORBA_ORB_object_to_string(orb, inoutObject, &ev));
        printf("Out:      %p\nURL:\t%s\nIOR:\t%s\n", (void *)outObject,
	       CORBA_ORB_object_to_readable_string(orb, outObject, &ev),
	       CORBA_ORB_object_to_string(orb, outObject, &ev));
        printf("Result:   %p\nURL:\t%s\nIOR:\t%s\n", (void *)retObject,
	       CORBA_ORB_object_to_readable_string(orb, retObject, &ev),
	       CORBA_ORB_object_to_string(orb, retObject, &ev));
        printf("Calling Server...\n");
        retObject = test1_test_Object(obj, inObject, &outObject, &inoutObject,
				      &ev);
        printf("After Call:\n");
	if (ev._major != CORBA_NO_EXCEPTION) 
		printf("Exception: `%s' EXCEPTION RAISED FOR Object!\n",
		       CORBA_exception_id(&ev));
	else
		printf("Exception: no\n");
        printf("In:       %p\nURL:\t%s\nIOR:\t%s\n", inObject,
	       CORBA_ORB_object_to_readable_string(orb, inObject, &ev),
	       CORBA_ORB_object_to_string(orb, inObject, &ev));
        printf("Inout:    %p\nURL:\t%s\nIOR:\t%s\n", inoutObject,
	       CORBA_ORB_object_to_readable_string(orb, inoutObject, &ev),
	       CORBA_ORB_object_to_string(orb, inoutObject, &ev));
        printf("Out:      %p\nURL:\t%s\nIOR:\t%s\n", outObject,
	       CORBA_ORB_object_to_readable_string(orb, outObject, &ev),
	       CORBA_ORB_object_to_string(orb, outObject, &ev));
        printf("Result:   %p\nURL:\t%s\nIOR:\t%s\n", retObject,
	       CORBA_ORB_object_to_readable_string(orb, retObject, &ev),
	       CORBA_ORB_object_to_string(orb, retObject, &ev));
	
	for (case_num = -1; case_num <= 5; case_num++) {
		ev._major = CORBA_NO_EXCEPTION;
		printf("Testing test_throw Before Call:\n"); 	
		if (ev._major != CORBA_NO_EXCEPTION) 
			printf("Exception: `%s' EXCEPTION RAISED FOR throw!\n",
			       CORBA_exception_id(&ev));	       
		else
			printf("Exception: no\n");
		printf("In:       %d\n", case_num);
		printf("Calling Server...\n");
		test1_test_throw(obj, case_num, &ev);
		printf("After Call:\n");
		switch (ev._major) {
		case CORBA_USER_EXCEPTION:
			if (!strcmp(CORBA_exception_id(&ev), ex_test1_x1))
				printf("Caught exception test1_x1!  "
				       "Case_Num: %d\n",
				       ((test1_x1 *)
					CORBA_exception_value(&ev))
				       ->case_num);
			else if (!strcmp(CORBA_exception_id(&ev),
					 ex_test1_x2))
				printf("Caught exception test1_x2!  "
				       "Obj URL: %s,  value: %d\n",
				       CORBA_ORB_object_to_readable_string(
					       orb,
					       ((test1_x2 *)
						CORBA_exception_value(&ev))->
					       obj,
					       &ev),
				       ((test1_x2 *)
					CORBA_exception_value(&ev))->value);
			else
				printf("Unknown User Exception Raised: `%s' "
				       "for throw!\n",
				       CORBA_exception_id(&ev));
			break;
		case CORBA_SYSTEM_EXCEPTION:
			printf("Exception: `%s' EXCEPTION RAISED FOR throw!\n",
			       CORBA_exception_id(&ev));
			break;
		default:
			printf("Exception: no\n");
			printf("In:       %d\n", case_num);
		}
	}
	
	printf("About to tell the server to exit...\n");
	test1_please_exit(obj, &ev);
	printf("Server should be exiting any moment...\n");
	return 0;
}
예제 #13
0
static int
do_activating(void)
{
	Bonobo_ActivationEnvironment environment;
	Bonobo_ActivationResult *a_res;
	Bonobo_ActivationContext ac;	
	Bonobo_StringList reqs = { 0 };
	char *resior;
	int res = 1;

	if (acior) {
                ac = CORBA_ORB_string_to_object (orb, acior, &ev);
                if (ev._major != CORBA_NO_EXCEPTION)
        	return 1;
	} else
                ac = bonobo_activation_activation_context_get ();

	memset (&environment, 0, sizeof (Bonobo_ActivationEnvironment));
                                                                                                                             
	a_res = Bonobo_ActivationContext_activateMatchingFull (
 				ac, specs, &reqs, &environment, 0,
                                bonobo_activation_client_get (),
				bonobo_activation_context_get (), &ev);
	switch (ev._major) {
	case CORBA_NO_EXCEPTION:
		g_print ("Activation ID \"%s\" ", a_res->aid);
		switch (a_res->res._d) {
		case Bonobo_ACTIVATION_RESULT_OBJECT:
			g_print ("RESULT_OBJECT\n");
			resior = CORBA_ORB_object_to_string (orb,
							     a_res->
							     res._u.res_object,
							     &ev);
			g_print ("%s\n", resior);
			break;
		case Bonobo_ACTIVATION_RESULT_SHLIB:
			g_print ("RESULT_SHLIB\n");
      			break;
		case Bonobo_ACTIVATION_RESULT_NONE:
			g_print ("RESULT_NONE\n");
			break;
		}
		res = 0;	
		break;
	case CORBA_USER_EXCEPTION:
		{
			char *id;
			id = CORBA_exception_id (&ev);
			g_print ("User exception \"%s\" resulted from query\n",
				 id);
			if (!strcmp (id,"IDL:Bonobo/ActivationContext/ParseFailed:1.0")) {
				Bonobo_Activation_ParseFailed
					* exdata = CORBA_exception_value (&ev);
                                if (exdata)
					g_print ("Description: %s\n",
						 exdata->description);
			} else if (!strcmp (id,"IDL:Bonobo/GeneralError:1.0")) {
				Bonobo_GeneralError *exdata;
                                                                                                                             
				exdata = CORBA_exception_value (&ev);
                                                                                                                             
				if (exdata)
					g_print ("Description: %s\n",
						 exdata->description);
			}
			res = 1;
		}
		break;
	case CORBA_SYSTEM_EXCEPTION:
		{
			char *id;
			id = CORBA_exception_id (&ev);
			g_print ("System exception \"%s\" resulted from query\n",
				 id);
			res = 1;
		}
		break;
	}
	return res;
}
예제 #14
0
파일: tpztest-use.c 프로젝트: berkus/flick
int main(int argc, char **argv)
{
	int ntimes = 0;
	tpztest_payload_slice *pld;
	enum WHATTODO whattodo = NOTHING;
	
	CORBA_ORB orb = 0;
	CORBA_Environment ev;
	CORBA_Object obj;
	
	int i;
	for (i = 1; i < argc; i++) {
		switch (argv[i][0]) {
		case '-':
			switch (argv[i][1]) {
			case 'b':
				if (whattodo != NOTHING) {
					fprintf(stderr, ("Specify only one: "
							 "-r or -b.\n"));
					return 1;
				}
				whattodo = BANDWIDTH;
				break;
			case 'r':
				if (whattodo != NOTHING) {
					fprintf(stderr, ("Specify only one: "
							 "-r or -b.\n"));
					return 1;
				}
				whattodo = RQST_RSPN;
				break;
			case 'h':
			  printhelp:
			  printf("%s [-h] {-b|-r} -n num obj\n"
				 "  -h:\tPrint this help.\n"
				 "  -b:\tBandwidth test (cannot specify -r).\n"
				 "  -r:\tRequest/response test "
				         "(cannot specify -b).\n"
				 "  -n:\tPerform test num times.\n"
				 "  obj:\tServer object reference.\n",
				 argv[0]);
			  return 0;
			case 'n':
				++i;
				if (i >= argc) goto printhelp;
				ntimes = atoi(argv[i]);
				break;
			default:
				fprintf(stderr, "Invalid switch '-%c'.\n",
					argv[i][1]);
				goto printhelp;
			}
			break;
			
		default:
			if (i == argc - 1)
				break; /* Last parameter -- object ref */
			fprintf(stderr, "Invalid parameter '%s'.\n", argv[i]);
			goto printhelp;
		}
	}

	/* Make sure `ntimes' is a valid value! */
	if (ntimes <=0) {
		fprintf(stderr, "Must specify number of tests > 0.\n");
		return 1;
	}
	
	/* Create the object reference. */
	obj = CORBA_ORB_string_to_object(orb, argv[argc-1], &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		printf("Problem in string to object conversion...\n");
		handle_exception(&ev);
		return 1;
	}
	
	if (whattodo == BANDWIDTH) {
		struct timeval start, end;
		
		printf("** BANDWIDTH **\n");
		gettimeofday(&start, 0);
		ntimes--;
		pld = flick_trapeze_client_array__alloc();
		for (i = 0; i < ntimes; i++) {
			tpztest_bandwidth(obj, pld, &ev);
			assert(ev._major == CORBA_NO_EXCEPTION);
		}
		tpztest_bandwidth_pingback(obj, pld, &ev);
		assert(ev._major == CORBA_NO_EXCEPTION);
		flick_trapeze_client_array__free(pld);
		gettimeofday(&end, 0);
		
		/* Print the results: */
		print_stats(sizeof(tpztest_payload), start, end, ntimes + 1);
	} else if (whattodo == RQST_RSPN) {
		struct timeval start, end;
		
		printf("** REQUEST-RESPONSE **\n");
		gettimeofday(&start, 0);
		for (i = 0; i < ntimes; i++) {
			pld = tpztest_rqst_rspn(obj, &ev);
			assert(ev._major == CORBA_NO_EXCEPTION);
			flick_trapeze_client_array__free(pld);
		}
		gettimeofday(&end, 0);
		
		/* Print the results: */
		print_stats(sizeof(tpztest_payload), start, end, ntimes + 1);
	} else {
		fprintf(stderr, "Nothing to do!\n");
		return 2;
	}
	
	return 0;
}