示例#1
0
static GNOME_C_IDList *
impl_get_files (PortableServer_Servant servant, CORBA_Environment *ev)
{
	KncCDir *d = KNC_C_DIR (bonobo_object (servant));
	KncStatus s;
	KncCamRes cam_res;
	KncCntrlRes cntrl_res;
	unsigned int i;
	KncImageInfo info;
	GNOME_C_IDList *l;

	cntrl_res = knc_get_status (d->priv->c, &cam_res, &s);
	CNIL (cntrl_res, cam_res, ev);
	l = GNOME_C_IDList__alloc ();
	l->_length = 0;
	l->_buffer = CORBA_sequence_CORBA_unsigned_long_allocbuf (s.pictures);
	for (i = 0; i < s.pictures; i++) {
		cntrl_res = knc_get_image_info (d->priv->c, &cam_res, i, &info);
		if (cntrl_res || cam_res)
			continue;
		l->_buffer[l->_length] = info.id;
		l->_length++;
	}
	CORBA_sequence_set_release (l, CORBA_TRUE);
	return l;
}
示例#2
0
static GNOME_GnoCam_PortList *
impl_GNOME_GnoCam_getPortList (PortableServer_Servant servant,
				       CORBA_Environment *ev)
{
	GnoCamMain *gm;
	GNOME_GnoCam_PortList *list;
	GPPortInfoList *il = NULL;
	GPPortInfo info;
	int n, i;

	gm = GNOCAM_MAIN (bonobo_object_from_servant (servant));

	gp_port_info_list_new (&il);
	gp_port_info_list_load (il);
	n = MAX (0, gp_port_info_list_count (il));

	list = GNOME_GnoCam_PortList__alloc ();
	list->_buffer = CORBA_sequence_CORBA_string_allocbuf (n);
	for (i = 0; i < n; i++) {
		if (gp_port_info_list_get_info (il, i, &info) >= 0) {
			list->_buffer[list->_length] =
				CORBA_string_dup (info.name);
			list->_length++;
		}
	}
	CORBA_sequence_set_release (list, TRUE);
	gp_port_info_list_free (il);

	return (list);
}
示例#3
0
文件: accessible.c 项目: GNOME/at-spi
/*
 * CORBA Accessibility::Accessible::getRelationSet method implementation
 */
static Accessibility_RelationSet *
impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant,
						CORBA_Environment     *ev)
{
  Accessibility_RelationSet *retval;
  gint n_relations = 0;
  gint i;
  AtkRelationSet *relation_set;
  AtkObject      *object = get_atkobject_from_servant (servant);

  bonobo_return_val_if_fail (object != NULL, NULL, ev);

  relation_set = atk_object_ref_relation_set (object);

  if (relation_set)
    n_relations = atk_relation_set_get_n_relations (relation_set);

  retval = CORBA_sequence_Accessibility_Relation__alloc ();
  retval->_length = retval->_maximum = n_relations;
  retval->_buffer = CORBA_sequence_Accessibility_Relation_allocbuf (n_relations);
  CORBA_sequence_set_release (retval, CORBA_TRUE);
	  
  for (i = 0; i < n_relations; ++i)
    {
      retval->_buffer[i] =
        CORBA_Object_duplicate (
          BONOBO_OBJREF (
            spi_relation_new (atk_relation_set_get_relation (relation_set, i))),
	  NULL);
    }
  
  return retval;
}
示例#4
0
static GNOME_GnoCam_ModelList *
impl_GNOME_GnoCam_getModelList (PortableServer_Servant servant,
					CORBA_Environment *ev)
{
	GnoCamMain *gm;
	GNOME_GnoCam_ModelList *list;
	CameraAbilitiesList *al = NULL;
	int n, i;
	CameraAbilities a;

	gm = GNOCAM_MAIN (bonobo_object_from_servant (servant));

	gp_abilities_list_new (&al);
	gp_abilities_list_load (al, NULL);
	n = MAX (0, gp_abilities_list_count (al));
	list = GNOME_GnoCam_ModelList__alloc ();
	list->_buffer = CORBA_sequence_CORBA_string_allocbuf (n);
	for (i = 0; i < n; i++) {
		if (gp_abilities_list_get_abilities (al, i, &a) >= 0) {
			list->_buffer[list->_length] =
				CORBA_string_dup (a.model);
			list->_length++;
		}
	}
	CORBA_sequence_set_release (list, TRUE);
	gp_abilities_list_free (al);

	return (list);
}
示例#5
0
void register_objects(CORBA_ORB orb, CORBA_BOA boa, int argc, char **argv,
		      CORBA_Environment *ev) 
{
	int i;
	CORBA_ReferenceData key;
	
	for (i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-I") && (i + 1 < argc)) {
			++i;
			key._maximum = strlen(argv[i]);
			key._length  = key._maximum;
			key._buffer  = (CORBA_octet *) argv[i];
			CORBA_sequence_set_release(&key, 0);
			
			/* XXX should save returned object! */
			CORBA_BOA_create(boa,
					 &key,
					 "onewaytest",
					 &onewaytest_server,
					 ev);
			if (ev->_major != CORBA_NO_EXCEPTION)
				return;
		}
	}
	CORBA_BOA_set_exception(boa, ev, CORBA_NO_EXCEPTION, 0, 0);
}
示例#6
0
static GNOME_Evolution_CreatableItemTypeList *
impl__get_userCreatableItems (PortableServer_Servant servant, CORBA_Environment *ev)
{
	GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc ();

	list->_length  = 2;
	list->_maximum = list->_length;
	list->_buffer  = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length);

	CORBA_sequence_set_release (list, FALSE);

	list->_buffer[0].id = "message";
	list->_buffer[0].description = _("New Mail Message");
	list->_buffer[0].menuDescription = _("_Mail Message");
	list->_buffer[0].tooltip = _("Compose a new mail message");
	list->_buffer[0].menuShortcut = 'm';
	list->_buffer[0].iconName = "mail-message-new";
	list->_buffer[0].type = GNOME_Evolution_CREATABLE_OBJECT;

	list->_buffer[1].id = "folder";
	list->_buffer[1].description = _("New Mail Folder");
	list->_buffer[1].menuDescription = _("Mail _Folder");
	list->_buffer[1].tooltip = _("Create a new mail folder");
	list->_buffer[1].menuShortcut = '\0';
	list->_buffer[1].iconName = "folder-new";
	list->_buffer[1].type = GNOME_Evolution_CREATABLE_FOLDER;

	return list;
}
示例#7
0
static GNOME_C_IDList *
impl_get_dirs (PortableServer_Servant servant, CORBA_Environment *ev)
{
	GNOME_C_IDList *l = GNOME_C_IDList__alloc ();

	l->_length = 0;
	CORBA_sequence_set_release (l, CORBA_TRUE);
	return l;
}
示例#8
0
static GNOME_C_Mngr_ManufacturerList *
impl_get_devices (PortableServer_Servant servant, CORBA_Environment *ev)
{
	KncCMngr *m = KNC_C_MNGR (bonobo_object (servant));
	GNOME_C_Mngr_ManufacturerList *l;
	unsigned int i, j, k, n, o;
	GPPortInfo info;
	int c;

	l = GNOME_C_Mngr_ManufacturerList__alloc ();

	/* List all manufacturers */
	l->_buffer = GNOME_C_Mngr_ManufacturerList_allocbuf (
						knc_count_devices ());
	l->_length = 0;
	for (i = 0; i < knc_count_devices (); i++) {
	    for (j = 0; j < l->_length; j++)
		if (!strcmp (l->_buffer[j].manufacturer,
			     knc_get_device_manufacturer (i))) break;
	    if (j == l->_length) {
		l->_length++;
		l->_buffer[j].manufacturer = CORBA_string_dup (
				knc_get_device_manufacturer (i));
		l->_buffer[j].models._length = 0;
		l->_buffer[j].models._buffer =
			GNOME_C_Mngr_ModelList_allocbuf (knc_count_devices ());

		/* List all models */
		for (k = 0; k < knc_count_devices (); k++) {
		    if (strcmp (l->_buffer[j].manufacturer,
			        knc_get_device_manufacturer (k))) continue;
		    n = l->_buffer[j].models._length;
		    l->_buffer[j].models._length++;
		    l->_buffer[j].models._buffer[n].model =
			    CORBA_string_dup (knc_get_device_model (k));

		    /* List all serial ports */
		    c = gp_port_info_list_count (m->priv->il);
		    l->_buffer[j].models._buffer[n].ports._length = 0;
		    l->_buffer[j].models._buffer[n].ports._buffer =
			    CORBA_sequence_CORBA_string_allocbuf (MAX (c, 0));
		    for (o = 0; o < MAX (c, 0); o++) {
			gp_port_info_list_get_info (m->priv->il, o, &info);
			if (info.type == GP_PORT_SERIAL) {
			    l->_buffer[j].models._buffer[n].ports._buffer[
				l->_buffer[j].models._buffer[n].ports._length] =
					CORBA_string_dup (info.name);
			    l->_buffer[j].models._buffer[n].ports._length++;
			}
		    }
		}
	    }
	}
	CORBA_sequence_set_release (l, CORBA_TRUE);

	return l;
}
PortableServer_POA
server_create_multi_threaded_poa (CORBA_ORB                  orb, 
				  PortableServer_POA         poa,
				  PortableServer_POAManager  poa_mgr,
				  CORBA_Environment         *ev)
{
	const static        MAX_POLICIES  = 1;
	PortableServer_POA  child_poa     = CORBA_OBJECT_NIL;
	CORBA_PolicyList   *poa_policies;

	poa_policies           = CORBA_PolicyList__alloc ();
        poa_policies->_maximum = MAX_POLICIES;
        poa_policies->_length  = MAX_POLICIES;
        poa_policies->_buffer  = CORBA_PolicyList_allocbuf (MAX_POLICIES);
        CORBA_sequence_set_release (poa_policies, CORBA_TRUE);
                                                                                
        poa_policies->_buffer[0] = (CORBA_Policy)
		PortableServer_POA_create_thread_policy (
			poa,
			PortableServer_ORB_CTRL_MODEL,
			ev);

	child_poa = PortableServer_POA_create_POA (poa,
                                                   "Thread Per Request POA",
                                                   poa_mgr,
                                                   poa_policies,
                                                   ev);
	if (etk_raised_exception(ev)) 
		goto failed_create_poa;

	ORBit_ObjectAdaptor_set_thread_hint ((ORBit_ObjectAdaptor) child_poa, 
					     ORBIT_THREAD_HINT_PER_REQUEST);

	
        CORBA_Policy_destroy (poa_policies->_buffer[0], ev); 
	if (etk_raised_exception(ev)) 
		goto failed;
        CORBA_free (poa_policies);	
	
	return child_poa;
	
 failed_create_poa:
	/* FIXME, in case of error, ev is set, but destructor should not
	 * return except anyway */
        CORBA_Policy_destroy (poa_policies->_buffer[0], ev); 
        CORBA_free (poa_policies);	
 failed:
	return CORBA_OBJECT_NIL;
}
static void
impl_MateComponent_Canvas_Component_render (PortableServer_Servant servant,
				     MateComponent_Canvas_Buf     *buf,
				     CORBA_Environment     *ev)
{
	Gcc *gcc = GCC (matecomponent_object_from_servant (servant));
	MateCanvasItem *item = MATE_CANVAS_ITEM (gcc->priv->item);
	MateCanvasBuf canvas_buf;

	if (!(buf->flags & MateComponent_Canvas_IS_BUF)) {
		buf->rgb_buf._length = buf->row_stride * (buf->rect.y1 - buf->rect.y0);
		buf->rgb_buf._maximum = buf->rgb_buf._length;
		
		buf->rgb_buf._buffer = CORBA_sequence_CORBA_octet_allocbuf (
			buf->rgb_buf._length);
		CORBA_sequence_set_release (&buf->rgb_buf, TRUE);

		if (buf->rgb_buf._buffer == NULL) {
			CORBA_exception_set_system (
				ev, ex_CORBA_NO_MEMORY, CORBA_COMPLETED_NO);
			return;
		}
	}

	canvas_buf.buf = buf->rgb_buf._buffer;
	
	canvas_buf.buf_rowstride = buf->row_stride;
	canvas_buf.rect.x0 = buf->rect.x0;
	canvas_buf.rect.x1 = buf->rect.x1;
	canvas_buf.rect.y0 = buf->rect.y0;
	canvas_buf.rect.y1 = buf->rect.y1;
	canvas_buf.bg_color = buf->bg_color;
	if (buf->flags & MateComponent_Canvas_IS_BG)
		canvas_buf.is_bg = 1;
	else
		canvas_buf.is_bg = 0;

	if (buf->flags & MateComponent_Canvas_IS_BUF)
		canvas_buf.is_buf = 1;
	else
		canvas_buf.is_buf = 0;

	ICLASS (item)->render (item, &canvas_buf);

	/* return */
	buf->flags =
		(canvas_buf.is_bg ? MateComponent_Canvas_IS_BG : 0) |
		(canvas_buf.is_buf ? MateComponent_Canvas_IS_BUF : 0);
}
static void
CORBA_sequence_CORBA_string_copy (CORBA_sequence_CORBA_string       *copy,
                                  const CORBA_sequence_CORBA_string *original)
{
	int i;

	copy->_maximum = original->_length;
	copy->_length = original->_length;
	copy->_buffer = CORBA_sequence_CORBA_string_allocbuf (original->_length);

	for (i = 0; i < original->_length; i++) {
		copy->_buffer[i] = CORBA_string_dup (original->_buffer[i]);
	}

	CORBA_sequence_set_release (copy, TRUE);
}
void
CORBA_sequence_MateComponent_ActivationProperty_copy (
        CORBA_sequence_MateComponent_ActivationProperty       *copy,
        const CORBA_sequence_MateComponent_ActivationProperty *original)
{
	int i;

	copy->_maximum = original->_length;
	copy->_length = original->_length;
	copy->_buffer = CORBA_sequence_MateComponent_ActivationProperty_allocbuf (original->_length);

	for (i = 0; i < original->_length; i++) {
		MateComponent_ActivationProperty_copy (&copy->_buffer[i], &original->_buffer[i]);
	}

	CORBA_sequence_set_release (copy, TRUE);
}
示例#13
0
static void
BasicServer_opException (PortableServer_Servant  servant,
			 CORBA_Environment      *ev)
{
	test_TestException *ex = test_TestException__alloc ();

	ex->reason           = CORBA_string_dup (constants_STRING_IN);
	ex->number           = constants_LONG_IN;
	ex->aseq._buffer     = CORBA_sequence_CORBA_long_allocbuf (1);
	ex->aseq._length     = 1;
	ex->aseq._buffer [0] = constants_LONG_IN;
	ex->factory          = getFactoryInstance(ev);

	CORBA_sequence_set_release (&ex->aseq, CORBA_TRUE);

	CORBA_exception_set (
		ev, CORBA_USER_EXCEPTION, ex_test_TestException,ex);
}
CORBA_Object 
etk_name_service_resolve (CosNaming_NamingContext  name_service,
			  gchar                   *id_vec[], 
			  CORBA_Environment       *ev)
{
	CORBA_Object retval = CORBA_OBJECT_NIL;
	gint i = 0;
	gint len = id_vec_len (id_vec);

	/* Allocate a CosNaming::Name (sequence of CosNaming::NameComponent) */
	CosNaming_Name *name = CosNaming_Name__alloc();

	g_assert (id_vec_len (id_vec) > 0);

	name->_buffer = CORBA_sequence_CosNaming_NameComponent_allocbuf(len);
	name->_maximum = len;
	name->_length  = 0;
	
	/* Relinquish ownership of the NameComponent to the
         * sequence. When CORBA_free is called on it later, the
         * NameComponent will be freed */	
	CORBA_sequence_set_release (name, TRUE);

	/* iterate components of name and create sub-context
	 * (directory) if needed */ 
	for (i = 0; i < len; ++i) {
		name->_length = i+1;
		name->_buffer[i].id   = CORBA_string_dup(id_vec[i]);
		name->_buffer[i].kind = CORBA_string_dup(""); 
		/* don't know what 'kind' shall be good for */ 
	}
	
	retval = CosNaming_NamingContext_resolve (name_service, 
						  name, 
						  ev);
	
	if (etk_raised_exception (ev)) { 
		CORBA_free (name);
		return CORBA_OBJECT_NIL;
	}
	
	return retval;
}
示例#15
0
static void
mem_read (PortableServer_Servant servant, CORBA_long count,
	  Bonobo_Stream_iobuf ** buffer,
	  CORBA_Environment *ev)
{
	BonoboStreamMem *smem = BONOBO_STREAM_MEM (
		bonobo_object (servant));

	if (smem->pos + count > smem->size)
		count = smem->size - smem->pos;
	    
	*buffer = Bonobo_Stream_iobuf__alloc ();
	CORBA_sequence_set_release (*buffer, TRUE);
	(*buffer)->_buffer = CORBA_sequence_CORBA_octet_allocbuf (count);
	(*buffer)->_length = count;
	
	memcpy ((*buffer)->_buffer, smem->buffer + smem->pos, count);

	smem->pos += count;
}
static void
cache_read (PortableServer_Servant servant, 
	    CORBA_long             count,
	    MateComponent_Stream_iobuf  **buffer, 
	    CORBA_Environment     *ev)
{
	MateComponentStreamCache *stream_cache = MATECOMPONENT_STREAM_CACHE (
		matecomponent_object (servant));
	CORBA_octet *data;

	if (count < 0) {
		matecomponent_exception_set (ev, ex_MateComponent_Stream_IOError);
		return;
	}

	*buffer = MateComponent_Stream_iobuf__alloc ();
	CORBA_sequence_set_release (*buffer, TRUE);
	data = CORBA_sequence_CORBA_octet_allocbuf (count);
	(*buffer)->_buffer = data;
	(*buffer)->_length = matecomponent_stream_cache_read (stream_cache, count, 
						       data, ev);
}
static PortableServer_POA
create_mult_id_poa (CORBA_Environment *ev)
{
	PortableServer_POA  rootpoa;
	PortableServer_POA  retval;
	CORBA_PolicyList   *policies;

	rootpoa = (PortableServer_POA)
		CORBA_ORB_resolve_initial_references (orb, "RootPOA", ev);
	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	policies           = CORBA_PolicyList__alloc ();
	policies->_maximum = 1;
	policies->_length  = 1;
	policies->_buffer  = CORBA_PolicyList_allocbuf (1);
	CORBA_sequence_set_release (policies, CORBA_TRUE);

	policies->_buffer[0] = (CORBA_Policy)
					PortableServer_POA_create_id_uniqueness_policy (
							rootpoa,
							PortableServer_MULTIPLE_ID,
							ev);
	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	retval = PortableServer_POA_create_POA (rootpoa, "Multiple Id POA",
					        NULL, policies, ev);
	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	CORBA_Policy_destroy (policies->_buffer[0], ev);
	CORBA_free (policies);

	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	CORBA_Object_release ((CORBA_Object) rootpoa, ev);

	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	return retval;
}
MateComponent_ServerInfoList *
MateComponent_ServerInfoList_duplicate (const MateComponent_ServerInfoList *original)
{
        int i;
        MateComponent_ServerInfoList *list;

        if (!original)
                return NULL;

        list = MateComponent_ServerInfoList__alloc ();

        list->_length = original->_length;
        list->_maximum = list->_length;
        list->_buffer = MateComponent_ServerInfoList_allocbuf (list->_length);

        for (i = 0; i < list->_length; i++)
                MateComponent_ServerInfo_copy (&list->_buffer [i], &original->_buffer [i]);

        CORBA_sequence_set_release (list, TRUE);

        return list;
}
示例#19
0
文件: document.c 项目: GNOME/at-spi
static Accessibility_AttributeSet*
impl_getAttributes (PortableServer_Servant servant,
		    CORBA_Environment *ev){
  
  AtkDocument *document = get_document_from_servant (servant);
  AtkAttributeSet *attributes = NULL;
  AtkAttribute *attr = NULL;
  Accessibility_AttributeSet *retval;
  gint n_attributes = 0;
  gint i;
  gchar *concat_str;
  
  g_return_val_if_fail (document != NULL, NULL);
  
  attributes = atk_document_get_attributes (document);

  /* according to atkobject.h, AtkAttributeSet is a GSList */
  if (attributes)
    n_attributes = g_slist_length (attributes);
    
  retval = CORBA_sequence_CORBA_string__alloc ();
  retval->_length = retval->_maximum = n_attributes;
  retval->_buffer = CORBA_sequence_CORBA_string_allocbuf (n_attributes);
  CORBA_sequence_set_release (retval, CORBA_TRUE);
  
  for (i = 0; i < n_attributes; ++i)
  {
      attr = g_slist_nth_data (attributes, i);
      concat_str = g_strconcat (attr->name, ":", attr->value, NULL);
      retval->_buffer [i] = CORBA_string_dup (concat_str);
      g_free (concat_str);
  }
    
  atk_attribute_set_free (attributes);

  return retval;
  
}
/**
 * matecomponent_persist_generate_content_types:
 * @num: the number of content types specified
 * @...: the content types (as strings)
 *
 * Returns: a ContentTypeList containing the given ContentTypes
 **/
MateComponent_Persist_ContentTypeList *
matecomponent_persist_generate_content_types (int num, ...)
{
	MateComponent_Persist_ContentTypeList *types;
	va_list ap;
	char *type;
	int i;

	types = MateComponent_Persist_ContentTypeList__alloc ();
	CORBA_sequence_set_release (types, TRUE);
	types->_length = types->_maximum = num;
	types->_buffer = CORBA_sequence_MateComponent_Persist_ContentType_allocbuf (num);

	va_start (ap, num);
	for (i = 0; i < num; i++) {
		type = va_arg (ap, char *);
		types->_buffer[i] = CORBA_string_alloc (strlen (type) + 1);
		strcpy (types->_buffer[i], type);
	}
	va_end (ap);

	return types;
}
poatest
poatest_run (PortableServer_POA        rootpoa,
             PortableServer_POAManager rootpoa_mgr)
{
	CORBA_Environment       ev;
	poatest                 poatest_obj1, poatest_obj2;
	CORBA_PolicyList       *poa_policies;

	CORBA_exception_init( &ev );
 
	/*
	 * Create child POA with MULTIPLE_ID Object Id Uniqueness policy and
	 * IMPLICIT_ACTIVATION Implicit Activation policy.
	 */
	poa_policies           = CORBA_PolicyList__alloc ();
	poa_policies->_maximum = 2;
	poa_policies->_length  = 2;
	poa_policies->_buffer  = CORBA_PolicyList_allocbuf (2);
	CORBA_sequence_set_release (poa_policies, CORBA_TRUE);

	poa_policies->_buffer[0] = (CORBA_Policy)
					PortableServer_POA_create_id_uniqueness_policy (
							rootpoa,
							PortableServer_MULTIPLE_ID,
							&ev);

	poa_policies->_buffer[1] = (CORBA_Policy)
					PortableServer_POA_create_implicit_activation_policy (
							rootpoa,
							PortableServer_IMPLICIT_ACTIVATION,
							&ev);

	child_poa = PortableServer_POA_create_POA (rootpoa,
						   "Multiple Id POA",
						   rootpoa_mgr,
						   poa_policies,
						   &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("create_POA : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
	CORBA_Policy_destroy (poa_policies->_buffer[1], &ev);
	CORBA_free (poa_policies);

	/*
	 * Initialise the servant.
	 */
	POA_poatest__init (&poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Implicitly activate two objects.
	 */
	poatest_obj1 = PortableServer_POA_servant_to_reference (child_poa, 
								&poatest_servant, 
								&ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("servant_to_reference : ", &ev);
		return CORBA_OBJECT_NIL;
	}
	CORBA_Object_release (poatest_obj1, &ev);

	poatest_obj2 = PortableServer_POA_servant_to_reference (child_poa, 
								&poatest_servant, 
								&ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("servant_to_reference : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Activate the POAManager. POA will now accept requests
	 */
	PortableServer_POAManager_activate (rootpoa_mgr, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("POAManager_activate : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	return poatest_obj2;
}
poatest
poatest_run (PortableServer_POA        rootpoa,
             PortableServer_POAManager rootpoa_mgr )
{
    CORBA_Environment        ev;
    poatest                  poatest_obj;
    CORBA_PolicyList        *poa_policies;
    PortableServer_ObjectId *objid;

    CORBA_exception_init (&ev);

    /*
     * Create child POA with RETAIN servant retention policy, USE_DEFAULT_SERVANT
     * request processing policy and MULTIPLE_ID id uniqueness policy.
     */
    poa_policies           = CORBA_PolicyList__alloc ();
    poa_policies->_maximum = 3;
    poa_policies->_length  = 3;
    poa_policies->_buffer  = CORBA_PolicyList_allocbuf (3);
    CORBA_sequence_set_release (poa_policies, CORBA_TRUE);

    poa_policies->_buffer[0] = (CORBA_Policy)
                               PortableServer_POA_create_id_uniqueness_policy (
                                   rootpoa,
                                   PortableServer_MULTIPLE_ID,
                                   &ev);

    poa_policies->_buffer[1] = (CORBA_Policy)
                               PortableServer_POA_create_request_processing_policy (
                                   rootpoa,
                                   PortableServer_USE_DEFAULT_SERVANT,
                                   &ev);

    poa_policies->_buffer[2] = (CORBA_Policy)
                               PortableServer_POA_create_servant_retention_policy (
                                   rootpoa,
                                   PortableServer_RETAIN,
                                   &ev);

    child_poa = PortableServer_POA_create_POA (rootpoa,
                "Default Servant POA",
                rootpoa_mgr,
                poa_policies,
                &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("create_POA : ", &ev);
        return CORBA_OBJECT_NIL;
    }

    CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
    CORBA_Policy_destroy (poa_policies->_buffer[1], &ev);
    CORBA_Policy_destroy (poa_policies->_buffer[2], &ev);
    CORBA_free (poa_policies);

    /*
     * Initialise the servant.
     */
    POA_poatest__init (&poatest_servant, &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
        return CORBA_OBJECT_NIL;
    }

    /*
     * Register the default servant.
     */
    PortableServer_POA_set_servant (child_poa, &poatest_servant, &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("set_servant : ", &ev);
        return CORBA_OBJECT_NIL;
    }

    /*
     * Activate an object.
     */
    objid = PortableServer_POA_activate_object (child_poa, &poatest_servant, &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("activate_object : ", &ev);
        return CORBA_OBJECT_NIL;
    }
    CORBA_free (objid);

    /*
     * Create a reference for an inactive object.
     */
    poatest_obj = PortableServer_POA_create_reference (child_poa, "IDL:poatest:1.0", &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("create_reference : ", &ev);
        return CORBA_OBJECT_NIL;
    }

    /*
     * Activate the POAManager. POA will now accept requests
     */
    PortableServer_POAManager_activate (rootpoa_mgr, &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("POAManager_activate : ", &ev);
        return CORBA_OBJECT_NIL;
    }

    return poatest_obj;
}
poatest
poatest_run (PortableServer_POA        rootpoa,
             PortableServer_POAManager rootpoa_mgr)
{
	CORBA_Environment        ev;
	poatest                  poatest_obj;
	CORBA_PolicyList        *poa_policies;
	PortableServer_ObjectId *objid;

	CORBA_exception_init (&ev);
 
	/*
	 * Create child POA with USER_ID Id Assignment and PERSISTENT lifespan policy.
	 */
	poa_policies           = CORBA_PolicyList__alloc ();
	poa_policies->_maximum = 2;
	poa_policies->_length  = 2;
	poa_policies->_buffer  = CORBA_PolicyList_allocbuf (2);
	CORBA_sequence_set_release (poa_policies, CORBA_TRUE);

	poa_policies->_buffer[0] = (CORBA_Policy)
					PortableServer_POA_create_id_assignment_policy (
							rootpoa,
							PortableServer_USER_ID,
							&ev);

	poa_policies->_buffer[1] = (CORBA_Policy)
					PortableServer_POA_create_lifespan_policy (
							rootpoa,
							PortableServer_PERSISTENT,
							&ev);

	child_poa = PortableServer_POA_create_POA (rootpoa,
						   "User Id and Persistent POA",
						   rootpoa_mgr,
						   poa_policies,
						   &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("create_POA : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Initialise the servant.
	 */
	POA_poatest__init (&poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Set up the ObjectId.
	 */
	objid = PortableServer_string_to_ObjectId ("Test Id", &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("string_to_ObjectId : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Activate object with user assigned Id.
	 */
	PortableServer_POA_activate_object_with_id (child_poa, objid, &poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("activate_object_with_id : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Get reference for object.
	 */
	poatest_obj = PortableServer_POA_servant_to_reference (child_poa, &poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("servant_to_reference : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Deactivate object and destroy POA
	 */
	PortableServer_POA_deactivate_object(child_poa, objid, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("deactivate_object : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	PortableServer_POA_destroy (child_poa, CORBA_FALSE, CORBA_FALSE, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("POA_destroy : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Re-create POA and re-activate the object.
	 */
	child_poa = PortableServer_POA_create_POA (rootpoa,
						   "User Id and Persistent POA",
						   rootpoa_mgr,
						   poa_policies,
						   &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("create_POA : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	PortableServer_POA_activate_object_with_id (child_poa, objid, &poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("activate_object_with_id : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Reference should still be valid.
	 */

	CORBA_free (objid);

	CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
	CORBA_Policy_destroy (poa_policies->_buffer[1], &ev);
	CORBA_free (poa_policies);

	/*
	 * Activate the POAManager. POA will now accept requests
	 */
	PortableServer_POAManager_activate( rootpoa_mgr, &ev );
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("POAManager_activate : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	return poatest_obj;
}
poatest
poatest_run (PortableServer_POA        rootpoa,
             PortableServer_POAManager rootpoa_mgr)
{
	CORBA_Environment        ev;
	poatest                  poatest_obj;
	CORBA_PolicyList        *poa_policies;
	PortableServer_ObjectId *objid;

	CORBA_exception_init (&ev);
 
	/*
	 * Create child POA with USER_ID Id Assignment policy.
	 */
	poa_policies           = CORBA_PolicyList__alloc ();
	poa_policies->_maximum = 1;
	poa_policies->_length  = 1;
	poa_policies->_buffer  = CORBA_PolicyList_allocbuf (1);
	CORBA_sequence_set_release (poa_policies, CORBA_TRUE);

	poa_policies->_buffer[0] = (CORBA_Policy)
					PortableServer_POA_create_id_assignment_policy (
							rootpoa,
							PortableServer_USER_ID,
							&ev);

	child_poa = PortableServer_POA_create_POA (rootpoa,
						   "User Id POA",
						   rootpoa_mgr,
						   poa_policies,
						   &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("create_POA : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
	CORBA_free (poa_policies);

	/*
	 * Initialise the servant.
	 */
	POA_poatest__init (&poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Set up the ObjectId.
	 */
	objid = PortableServer_string_to_ObjectId ("Test Id", &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("string_to_ObjectId : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Activate object with user assigned Id.
	 */
	PortableServer_POA_activate_object_with_id (child_poa, objid, &poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("activate_object_with_id : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	CORBA_free (objid);

	poatest_obj = PortableServer_POA_servant_to_reference (child_poa, &poatest_servant, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("servant_to_reference : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	/*
	 * Activate the POAManager. POA will now accept requests
	 */
	PortableServer_POAManager_activate (rootpoa_mgr, &ev);
	if (POATEST_EX (&ev)) {
		POATEST_PRINT_EX ("POAManager_activate : ", &ev);
		return CORBA_OBJECT_NIL;
	}

	return poatest_obj;
}
/* binds @servant object reference to unique @name at
 * @name_service. If error occures @ev points to exception object on
 * return.
 */
void 
etk_name_service_bind (CosNaming_NamingContext  name_service,
		       CORBA_Object             servant,
		       gchar                   *id_vec[], 
		       CORBA_Environment       *ev)
{
	gint i = 0;
	gint len = id_vec_len (id_vec);

	/* Allocate a CosNaming::Name (sequence of CosNaming::NameComponent) */
	CosNaming_Name *name = CosNaming_Name__alloc();

	name->_buffer = CORBA_sequence_CosNaming_NameComponent_allocbuf(len);
	name->_maximum = len;
	name->_length  = 0;
	
	/* Relinquish ownership of the NameComponent to the
         * sequence. When CORBA_free is called on it later, the
         * NameComponent will be freed */	
	CORBA_sequence_set_release (name, TRUE);

	/* iterate components of name and create sub-context
	 * (directory) if needed */ 
	for (i = 0; i < len; ++i) {
		name->_length = i+1;
		name->_buffer[i].id   = CORBA_string_dup(id_vec[i]);
		name->_buffer[i].kind = CORBA_string_dup(""); 
		/* don't know what 'kind' shall be good for */ 

		if (name->_length < len) 
		{
			/* create a sub-context */ 
			CosNaming_NamingContext nc = 
				CosNaming_NamingContext_bind_new_context (name_service, 
									  name, 
									  ev);	
			if (etk_raised_exception_is_a (ev, 
						       ex_CosNaming_NamingContext_AlreadyBound))
			{
				/* ignore - ctx allread exists, this
				 * is not dramatic */
				CORBA_exception_free (ev);
			}
			else if (etk_raised_exception (ev)) 
			{
				/* critical - unexpected exception  */ 
				CORBA_free (name); 
				return;
			}
		}
		else
		{
			/* Bind object to last context - use 'rebind'
			 * operation in case the name has been
			 * registered allready in context - note, this
			 * might interfere with other service choosing
			 * same name */ 
			CosNaming_NamingContext_rebind (name_service, 
							name, 
							servant,
							ev);
			if (etk_raised_exception(ev)) {
				/* critical - can not bind object */ 
				CORBA_free (name);
				return;
			}
		}
	}

	CORBA_free (name);
	return;
}