Beispiel #1
0
/**
 * SPIException_getDescription:
 * @err: the #SPIException being queried.
 *
 * Get a text description of the exception that has been thrown.
 * Unfortunately these descriptions tend to be terse and limited in
 * the detail which they can provide.
 *
 * Returns: a brief character string describing the exception.
 **/
char* SPIException_getDescription (SPIException *err)
{
  /* TODO: friendlier error messages? */
  if (err->ev)
    return CORBA_exception_id (err->ev);
  return NULL;
}
/**
 * guignome_corba_activate_server:
 * @void:
 *
 * Activates the POA manager and thus makes the services available to the
 * outside world.
 **/
void
guignome_corba_activate_server (void)
{
  CORBA_Environment ev;
  PortableServer_POAManager poa_manager;
  
  g_message("In guignome_corba_activate_server (1)\n");

  /* Do nothing if the server is already running */
  if (guignome_corba_have_server)
    return;
   
  g_message("In guignome_corba_activate_server (2)\n");
  CORBA_exception_init (&ev);
    
  poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev);
  if (ev._major != CORBA_NO_EXCEPTION)
    goto out;

  g_message("In guignome_corba_activate_server (3)\n");
  PortableServer_POAManager_activate (poa_manager, &ev);
  if (ev._major != CORBA_NO_EXCEPTION)
    goto out;

  g_message("In guignome_corba_activate_server (4)\n");
 out:
  { CORBA_char *str=CORBA_exception_id(&ev);;
  g_message("In guignome_corba_activate_server (4a) exception=%d - %s\n",
    ev._major,str==NULL? "<NULL>" : str);
  CORBA_exception_free (&ev);
  g_message("In guignome_corba_activate_server (5)\n");
  }
}
/**
 * matecomponent_property_control_changed:
 * @property_control: The MateComponentPropertyControl that has changed.
 * @opt_ev: An optional CORBA_Environment for exception handling. 
 *
 * Tells the server that a value in the property control has been changed,
 * and that it should indicate this somehow.
 */
void
matecomponent_property_control_changed (MateComponentPropertyControl *property_control,
				 CORBA_Environment     *opt_ev)
{
	MateComponentPropertyControlPrivate *priv;
	CORBA_Environment ev;
	CORBA_any any;
	CORBA_short s;

	g_return_if_fail (property_control != NULL);
	g_return_if_fail (MATECOMPONENT_IS_PROPERTY_CONTROL (property_control));

	priv = property_control->priv;

	if (opt_ev == NULL)
		CORBA_exception_init (&ev);
	else
		ev = *opt_ev;

	s = 0;
	any._type = (CORBA_TypeCode) TC_CORBA_short;
	any._value = &s;

	matecomponent_event_source_notify_listeners (priv->event_source,
					      MATECOMPONENT_PROPERTY_CONTROL_CHANGED,
					      &any, &ev);
	if (opt_ev == NULL && MATECOMPONENT_EX (&ev)) {
		g_warning ("ERROR: %s", CORBA_exception_id (&ev));
	}

	if (opt_ev == NULL)
		CORBA_exception_free (&ev);
}
/**
 * e_get_activation_failure_msg:
 * @ev: An exception returned by an oaf_activate call.
 *
 * Get a descriptive error message from @ev.
 *
 * Return value: A newly allocated string with the printable error message.
 **/
char *
e_get_activation_failure_msg (CORBA_Environment *ev)
{
	g_return_val_if_fail (ev != NULL, NULL);

	if (CORBA_exception_id (ev) == NULL)
		return NULL;

	if (strcmp (CORBA_exception_id (ev), ex_Bonobo_GeneralError) != 0) {
		return bonobo_exception_get_text (ev);
	} else {
		const Bonobo_GeneralError *oaf_general_error;

		oaf_general_error = CORBA_exception_value (ev);
		return g_strdup (oaf_general_error->description);
	}
}
void 
etk_ignore_if_exception (CORBA_Environment *ev, const char* mesg) 
{
	if (etk_raised_exception (ev)) {
		g_warning ("%s %s", mesg, CORBA_exception_id (ev));
		CORBA_exception_free (ev); 
	}
}
Beispiel #6
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;	
}
void 
etk_abort_if_exception (CORBA_Environment *ev, const char* mesg) 
{
	if (etk_raised_exception (ev)) {
		g_error ("%s %s", mesg, CORBA_exception_id (ev));
		CORBA_exception_free (ev); 
		abort(); 
	}
}
static gint
invitation_double_clicked_cb (ETable *et, int row, int col, GdkEvent *event, gpointer data)
{
	SunOneInvitationList *list = SUNONE_INVITATION_LIST (data);
	SunOneInvitationListPrivate *priv = list->priv;
	ECalComponent *comp, *clone;
	GNOME_Evolution_Calendar_CompEditorFactory factory;
	const char *uid;
	CORBA_Environment ev;

	comp = sunone_invitation_list_model_get_comp (priv->model, row);
	if (!comp)
		return FALSE;

	clone = e_cal_component_clone (comp);	
	sunone_util_mangle_uid (clone);
	e_cal_component_get_uid (clone, &uid);

	/* Get the factory */
	CORBA_exception_init (&ev);
	factory = bonobo_activation_activate_from_id (COMPEDITORFACTORY, 0, NULL, &ev);
	if (BONOBO_EX (&ev)) {
		g_message ("%s: Could not activate the component editor factory (%s)", G_GNUC_FUNCTION,
			   CORBA_exception_id (&ev));
		CORBA_exception_free (&ev);
		return FALSE;
	}

	GNOME_Evolution_Calendar_CompEditorFactory_editExisting (factory, priv->model->uri, (char *)uid, GNOME_Evolution_Calendar_CompEditorFactory_EDITOR_MODE_EVENT, &ev);

	if (BONOBO_EX (&ev)) {
		g_message ("%s: Execption while editing the component (%s)", G_GNUC_FUNCTION, 
			   CORBA_exception_id (&ev));
	}

	g_object_unref (G_OBJECT (clone));
	
	CORBA_exception_free (&ev);
	bonobo_object_release_unref (factory, NULL);	

	return FALSE;
}
Beispiel #9
0
Datei: at.c Projekt: GNOME/at-spi
void
check_ev (CORBA_Environment *ev, char *desc)
{
        if (ev->_major != CORBA_NO_EXCEPTION) {
                fprintf(stderr,
                ("Accessibility app error: exception during CORBA call %s (%s)\n"),
                        CORBA_exception_id(ev), desc);
                CORBA_exception_free(ev);
                exit(-1);
        }
}
Beispiel #10
0
void CORBA_BOA_impl_is_ready(CORBA_BOA ths, CORBA_Environment *ev)
{
	trapeze_mcp_init(1 /* yes, I'm the server */);
	
	/* Accept new clients, read client requests & send replies forever. */
	while (1) {
		FLICK_TARGET obj;
		FLICK_BUFFER msg;
		void *buffer;
		
		flick_trapeze_server_get_request(&msg);
		buffer = tpz_mtod(msg);
		
		obj = find_implementation(
			ths, buffer, ev);
		if (ev->_major != CORBA_NO_EXCEPTION) {
			/* Error finding object. */
			flick_trapeze_server_send_corba_exception(
				msg,
				CORBA_exception_id(ev));
			ev->_major = CORBA_NO_EXCEPTION;
		} else {
			switch ((*obj->server_func)(msg, buffer, obj)) {
			case FLICK_OPERATION_SUCCESS:
				/* end_encode already sent reply */
				break;
				
			case FLICK_OPERATION_SUCCESS_NOREPLY:
				break;
				
			default:
				/* FLICK_OPERATION_FAILURE */
				/*
				 * XXX --- The server dispatch function may
				 * have already encoded an exception
				 * `..._decode_error'.  We should send it, or
				 * the dispatch func should return FLICK_
				 * OPERATION_SUCCESS in that case.
				 */
				flick_trapeze_server_send_corba_exception(
					msg,
					ex_CORBA_NO_IMPLEMENT);
				break;
			}
		}
		if (!CORBA_Object_is_nil(obj, ev))
			CORBA_Object_release(obj, ev);
	}
	
	/* Should never be reached. */
	flick_set_exception(ths, ev, ex_CORBA_INTERNAL,
			    0, CORBA_COMPLETED_YES);
}
Beispiel #11
0
void handle_exception(CORBA_Environment *ev)
{
	switch (ev->_major) {
	case CORBA_NO_EXCEPTION:
		return; /* don't abort the program */
	case CORBA_SYSTEM_EXCEPTION:
		fprintf(stderr, "%s ERROR %d.%d\n",
			CORBA_exception_id(ev),
			((CORBA_UNKNOWN *)CORBA_exception_value(ev))->minor,
			((CORBA_UNKNOWN *)CORBA_exception_value(
				ev))->completed);		
		break;
	case CORBA_USER_EXCEPTION:
		fprintf(stderr, "UNKNOWN USER EXCEPTION %s!\n",
			CORBA_exception_id(ev));
		break;
	default:
		fprintf(stderr, "Unknown exception type\n");
	}
	
	CORBA_exception_free(ev);
}
Beispiel #12
0
int
call_client(mach_port_t right)
{
    int result;
    arrays_arr8k a;
    int i;
    CORBA_Environment env;

    for (i = 0; i < 8192; i++)
        a[i] = rand() % 2000 - 1000;

    result = arrays_test8k(right, a, &env);
    if (env._major != CORBA_NO_EXCEPTION)
        printf("Exception raised: `%s' raised!\n",
               CORBA_exception_id(&env));

    result = (result != arrays_server_test8k(right, a, &env));
    if (env._major != CORBA_NO_EXCEPTION)
        printf("Exception raised: `%s' raised!\n",
               CORBA_exception_id(&env));
    CORBA_exception_free(&env);
    return result;
}
/* Creates and registers the CORBA servers.  Returns TRUE on success, FALSE
 * otherwise.
 */
static int
register_servers (void)
{
  CORBA_Environment ev;
  int retval;
  int v;
  
  g_message("In register_servers (1)\n");

  retval = FALSE;
  CORBA_exception_init (&ev);

  /* Register our private server and see if it was already there */
  ElvisPrivate_server = ElvisPrivateServer_create (poa, &ev);
  if (ev._major != CORBA_NO_EXCEPTION)
    goto out;

  g_message("In register_servers (2)\n");
  v = goad_server_register (CORBA_OBJECT_NIL, ElvisPrivate_server,
          "IDL:Elvis:ElvisPrivate:1.0", "object", &ev);
  g_message("In register_servers (3) v=%d\n",v);
  if (ev._major != CORBA_NO_EXCEPTION)
    goto out;
  g_message("In register_servers (3b) v=%d\n",v);

  switch (v) {
  case 0:
    guignome_corba_have_server = FALSE;
    break;
  
  case -2:
    guignome_corba_have_server = FALSE;
    break;
  }

  retval = TRUE;

  /* Done */
 out:
  { CORBA_char *str=CORBA_exception_id(&ev);
  g_message("In register_servers (4) %s\n", str==NULL? "<NULL>" : str);
  CORBA_exception_free (&ev);
  }
  
  return retval;
}
Beispiel #14
0
static bool hermes_capability(L4_ThreadId_t tid, HpfCapability *cap)
{
    CORBA_Environment env = idl4_default_environment;

//    printf("getting root capability from hermes\n");
    bool retval = DirectoryService_GetRootCapability(tid, (Capability_t *) cap, &env);

    switch (env._major) {
    case CORBA_SYSTEM_EXCEPTION:
        printf("IPC failed, code %d\n", CORBA_exception_id(&env));
        CORBA_exception_free(&env);
        return false;
    }

//    if (retval) printf("got it!\n"); else printf("hermes refused us\n");

    return retval;
}
static char *
matecomponent_activation_exception_id (CORBA_Environment *ev)
{
        if (ev->_major == CORBA_USER_EXCEPTION) {
                if (!strcmp (ev->_id, "IDL:MateComponent/GeneralError:1.0")) {
                        MateComponent_GeneralError *err = CORBA_exception_value (ev);
                        
                        if (!err || !err->description) {
                                return "No general exception error message";
                        } else {
                                return err->description;
                        }
                } else {
                        return ev->_id;
                }
        } else {
                return CORBA_exception_id (ev);
        }
}
Beispiel #16
0
void CORBA_BOA_impl_is_ready(CORBA_BOA ths, CORBA_Environment *ev)
{
	int maxconn = -1;
	fd_set fds;
	struct sockaddr_in server;
	int sock, i;
	int len = sizeof(struct sockaddr_in);
	FLICK_BUFFER the_buf, return_buf;
	int *clients = 0;
	int client_cur = 0;
	int client_max = 0;
	
	/* allocate our own buffers.  This is in preparation for being
           thread-safe. */
	the_buf.real_buf_start = the_buf.buf_read = the_buf.buf_start =
	         the_buf.buf_current = t_calloc(char, 8192);
	the_buf.real_buf_end = the_buf.buf_end = (((char *) the_buf.buf_start)
						  + 8192);
	
	return_buf.real_buf_start = return_buf.real_buf_end =
	      return_buf.buf_read = 0;
	return_buf.buf_start  = return_buf.buf_current = t_calloc(char, 8192);
	return_buf.buf_end = ((char *) return_buf.buf_start) + 8192;
	
	if(!the_buf.buf_start || !return_buf.buf_start) {
		flick_set_exception(ths, ev, ex_CORBA_NO_MEMORY,
				    0, CORBA_COMPLETED_NO);
		perror("Insufficient memory for server buffers"); 
		return;
	}
	
	FD_ZERO(&fds);
	
	/* Get the listening socket & port for this machine */
	sock = ths->socket_fd;
	memset((char *)&server, 0, sizeof(server));
	server.sin_family = AF_INET;
	
	/* Bind a port for this skelecton function */
	server.sin_port = htons(ths->hostport);
	if (bind(sock, (struct sockaddr *)&server, len) != 0) {
		perror("cannot `bind' to socket");
		flick_set_exception(ths, ev, ex_CORBA_COMM_FAILURE,
				    0, CORBA_COMPLETED_NO);
		return;
	}
	
	if ((getsockname(sock, (struct sockaddr *)&server, &len) != 0)
	    || (listen(sock, 8) != 0)) {
		perror("cannot `getsockname' or `listen', port may be in use");
		flick_set_exception(ths, ev, ex_CORBA_COMM_FAILURE,
				    0, CORBA_COMPLETED_NO);
		return;
	}
	
	FD_SET(sock, &fds);
	
	if (sock > maxconn)
		maxconn = sock;
	
	/* Accept new clients, read client requests & send replies forever. */
	while (1) {
		FLICK_TARGET obj;
		unsigned int request_id;
		
		int qty = select(maxconn + 1, &fds, 0, 0, 0);
		
		for (i = 0; i < client_cur && qty; i++) {
			if ((clients[i] >= 0)
			    && FD_ISSET(clients[i], &fds)) {
				do {
					obj = 0;
					request_id = 0;
					
					if (!flick_server_get_request(
						clients[i],
						&the_buf)) {
						/*
						 * Error receiving the mesg.
						 * Client FD is closed by
						 * `flick_server_get_request'.
						 */
						clients[i] = -1;
					} else {
						obj = find_implementation(
							ths, &the_buf,
							&request_id, ev);
						if (ev->_major
						    != CORBA_NO_EXCEPTION) {
							/* Error finding
							   object. */
							flick_server_send_exception(
								clients[i],
								request_id,
								CORBA_exception_id(ev));
							ev->_major = CORBA_NO_EXCEPTION;
						} else {
							switch ((*obj->
								 server_func)(
									 &the_buf,
									 &return_buf,
									 request_id,
									 obj)) {
							case FLICK_OPERATION_SUCCESS:
								flick_server_send_reply(
									clients[i],
									&return_buf);
								break;
								
							case FLICK_OPERATION_SUCCESS_NOREPLY:
								break;
								
							default:
								/* FLICK_OPERATION_FAILURE */
								/*
								 * XXX --- The server
								 * dispatch function
								 * may have already
								 * encoded an exception
								 * `..._decode_error'.
								 * We should send it,
								 * or the dispatch func
								 * should return FLICK_
								 * OPERATION_SUCCESS in
								 * that case.
								 */
								flick_server_send_exception(
									clients[i],
									request_id,
									ex_CORBA_NO_IMPLEMENT);
								break;
							}
						}
					}
					if (!CORBA_Object_is_nil(obj, ev))
						CORBA_Object_release(obj, ev);
					
				} while (flick_buffer_contains_more(&the_buf));
				qty--;
			}
		}
		
		if (FD_ISSET(sock, &fds)) {
			int pos = -1;
			qty--;
			for (i = 0; i < client_cur; i++)
				if (clients[i] < 0)
					break;
			if (i < client_cur)
				pos = i;
			else {
				pos = client_cur++;
				if (client_cur > client_max) {
					client_max += 10;
					clients = t_realloc(clients, int, client_max);
					if (!clients) {			
						flick_set_exception(
							ths, ev,
							ex_CORBA_NO_MEMORY,
							0, CORBA_COMPLETED_NO);
						return;
					}
				}
			}
			clients[pos] = accept(sock, 0, 0);
			if (clients[pos] > maxconn)
				maxconn = clients[pos];
		}
Beispiel #17
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;
}
Beispiel #18
0
Datei: at.c Projekt: GNOME/at-spi
int
main(int argc, char **argv)
{
        CORBA_Environment ev;
        CORBA_Object oclient;
        char *obj_id;
        CORBA_long i;
        CORBA_short n_desktops;
        CORBA_long j;
        CORBA_long n_apps;
	CORBA_string s;
        Accessibility_Desktop desktop;
        Accessibility_Application app;
        Accessibility_Registry registry;
        SpiListener *listener;

        CORBA_exception_init(&ev);

        if (!bonobo_init (&argc, argv))
          {
            g_error ("Could not initialize Bonobo");
          }

        obj_id = "OAFIID:Accessibility_Registry:1.0";

        oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev);
        if (ev._major != CORBA_NO_EXCEPTION) {
                fprintf(stderr,
                ("Accessibility app error: exception during registry activation from id: %s\n"),
                        CORBA_exception_id(&ev));
                CORBA_exception_free(&ev);
                exit(-1);
        }

        if (CORBA_Object_is_nil (oclient, &ev))
          {
            g_error ("Could not locate registry");
          }

        bonobo_activate ();

        listener = spi_listener_new ();

        registry = (Accessibility_Registry) oclient;

        Accessibility_Registry_registerGlobalEventListener
                                   (registry,
                                    (Accessibility_EventListener)
                                         bonobo_object_corba_objref (bonobo_object (listener)),
                                    "focus:",
                                    &ev);
        check_ev (&ev, "register:focus");
        Accessibility_Registry_registerGlobalEventListener
                                   (registry,
                                    (Accessibility_EventListener)
                                         bonobo_object_corba_objref (bonobo_object (listener)),
                                    "Gtk:GtkWidget:button-press-event",
                                    &ev);
        check_ev (&ev, "register:button_press");
        fprintf (stderr, "AT callback registered.\n");

            n_desktops = Accessibility_Registry_getDesktopCount (registry, &ev);

            for (i=0; i<n_desktops; ++i)
              {
                desktop = Accessibility_Registry_getDesktop (registry, i, &ev);
		s = Accessibility_Desktop__get_name (desktop, &ev);
                fprintf (stderr, "desktop %d name: %s\n", i, s);
	        CORBA_free (s);	 
                check_ev (&ev, "desktop:name");
                n_apps = Accessibility_Desktop__get_childCount (desktop, &ev);
                check_ev (&ev, "desktop:childCount");
                fprintf (stderr, "desktop has %d apps:\n", n_apps);
                for (j=0; j<n_apps; ++j)
                  {
                    app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop, j, &ev);
                    check_ev (&ev, "desktop:getChildAtIndex");
                    s = Accessibility_Application__get_name (app, &ev);
		    fprintf (stderr, "app %d name: %s\n", j, s);
		    CORBA_free (s);
                    check_ev (&ev, "app:getName");
                  }
              }

            fprintf (stderr, "finished querying desktop(s).\n");
            bonobo_main ();
               /* needed by at because it is a server ? */
        exit(0);
}
/** 
 * test @ev for exception 
 */
gboolean 
etk_raised_exception_is_a (CORBA_Environment *ev, CORBA_char* id) 
{
	return ((ev)->_major != CORBA_NO_EXCEPTION)  &&                 
		strcmp(id, CORBA_exception_id(ev)) == 0;
}
Beispiel #20
0
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;
}