예제 #1
0
void
_ORBIT_skel_Freeamp_Quit(POA_Freeamp * _ORBIT_servant,
			 GIOPRecvBuffer * _ORBIT_recv_buffer,
			 CORBA_Environment * ev,
			 void (*_impl_Quit) (PortableServer_Servant _servant,
					     CORBA_Environment * ev))
{
   _impl_Quit(_ORBIT_servant, ev);
   {				/* marshalling */
      register GIOPSendBuffer *_ORBIT_send_buffer;

      _ORBIT_send_buffer =
	 giop_send_reply_buffer_use(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer)->
				    connection, NULL,
				    _ORBIT_recv_buffer->message.u.request.
				    request_id, ev->_major);
      if (_ORBIT_send_buffer) {
	 if (ev->_major == CORBA_NO_EXCEPTION) {
	 } else
	    ORBit_send_system_exception(_ORBIT_send_buffer, ev);
	 giop_send_buffer_write(_ORBIT_send_buffer);
	 giop_send_buffer_unuse(_ORBIT_send_buffer);
      }
   }
}
예제 #2
0
void
ORBit_handle_system_exception (CORBA_Environment *ev,
			       const CORBA_char *nom,
			       CORBA_completion_status status,
			       GIOPRecvBuffer *buf,
			       GIOPSendBuffer *sendbuf)
{
	CORBA_exception_set_system (ev, nom, status);
	giop_recv_buffer_unuse (buf);
	giop_send_buffer_unuse (sendbuf);
}
예제 #3
0
void
_ORBIT_skel_Freeamp_PlayNumber(POA_Freeamp * _ORBIT_servant,
			       GIOPRecvBuffer * _ORBIT_recv_buffer,
			       CORBA_Environment * ev,
			       void (*_impl_PlayNumber)
			       (PortableServer_Servant _servant,
				const CORBA_char * number,
				CORBA_Environment * ev))
{
   CORBA_char *number;

   {				/* demarshalling */
      guchar *_ORBIT_curptr;
      register CORBA_unsigned_long _ORBIT_tmpvar_2;
      CORBA_unsigned_long _ORBIT_tmpvar_3;

      _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur;
      if (giop_msg_conversion_needed(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer))) {
	 _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4);
	 
	    (*((guint32 *) & (_ORBIT_tmpvar_3))) =
	    GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr));
	 _ORBIT_curptr += 4;
	 number = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(number[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3;
      } else {
	 _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4);
	 _ORBIT_tmpvar_3 = *((CORBA_unsigned_long *) _ORBIT_curptr);
	 _ORBIT_curptr += 4;
	 number = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(number[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3;
      }
   }
   _impl_PlayNumber(_ORBIT_servant, number, ev);
   {				/* marshalling */
      register GIOPSendBuffer *_ORBIT_send_buffer;

      _ORBIT_send_buffer =
	 giop_send_reply_buffer_use(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer)->
				    connection, NULL,
				    _ORBIT_recv_buffer->message.u.request.
				    request_id, ev->_major);
      if (_ORBIT_send_buffer) {
	 if (ev->_major == CORBA_NO_EXCEPTION) {
	 } else
	    ORBit_send_system_exception(_ORBIT_send_buffer, ev);
	 giop_send_buffer_write(_ORBIT_send_buffer);
	 giop_send_buffer_unuse(_ORBIT_send_buffer);
      }
   }
}
예제 #4
0
void
_ORBIT_skel_Freeamp_GetNumber(POA_Freeamp * _ORBIT_servant,
			      GIOPRecvBuffer * _ORBIT_recv_buffer,
			      CORBA_Environment * ev,
			      CORBA_long(*_impl_GetNumber)
			      (PortableServer_Servant _servant,
			       CORBA_Environment * ev))
{
   CORBA_long _ORBIT_retval;

   _ORBIT_retval = _impl_GetNumber(_ORBIT_servant, ev);
   {				/* marshalling */
      register GIOPSendBuffer *_ORBIT_send_buffer;

      _ORBIT_send_buffer =
	 giop_send_reply_buffer_use(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer)->
				    connection, NULL,
				    _ORBIT_recv_buffer->message.u.request.
				    request_id, ev->_major);
      if (_ORBIT_send_buffer) {
	 if (ev->_major == CORBA_NO_EXCEPTION) {
	    giop_message_buffer_do_alignment(GIOP_MESSAGE_BUFFER
					     (_ORBIT_send_buffer), 4);
	    {
	       guchar *_ORBIT_t;

	       _ORBIT_t = alloca(sizeof(_ORBIT_retval));
	       memcpy(_ORBIT_t, &(_ORBIT_retval), sizeof(_ORBIT_retval));
	       giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER
					      (_ORBIT_send_buffer),
					      (_ORBIT_t),
					      sizeof(_ORBIT_retval));
	    }
	 } else
	    ORBit_send_system_exception(_ORBIT_send_buffer, ev);
	 giop_send_buffer_write(_ORBIT_send_buffer);
	 giop_send_buffer_unuse(_ORBIT_send_buffer);
      }
   }
}
예제 #5
0
CORBA_char *
CORBA_ORB_object_to_string (CORBA_ORB          orb,
			    const CORBA_Object obj,
			    CORBA_Environment *ev)
{
	GIOPSendBuffer *buf;
	CORBA_octet     endianness = GIOP_FLAG_ENDIANNESS;
	CORBA_char     *out;
	int             i, j, k;

	g_return_val_if_fail (ev != NULL, NULL);

	if(!orb || !obj || MATECORBA_ROOT_OBJECT_TYPE (obj) != MATECORBA_ROT_OBJREF) {
		CORBA_exception_set_system (
				ev, ex_CORBA_BAD_PARAM, CORBA_COMPLETED_NO);

		return NULL;
	}

	if (matecorba_use_corbaloc) {
		out = MateCORBA_object_to_corbaloc (obj, ev);
		if (ev->_major == CORBA_NO_EXCEPTION)
			return out;

		CORBA_exception_free (ev);
		/* fall thru, common marshalling */
	}

	buf = giop_send_buffer_use (orb->default_giop_version);

	g_assert (buf->num_used == 1);

	buf->header_size             = 0;
	buf->lastptr                 = NULL;
	buf->num_used                = 0; /* we don't want the header in there */
	buf->msg.header.message_size = 0;

	giop_send_buffer_append (buf, &endianness, 1);

	MateCORBA_marshal_object (buf, obj);
	out = CORBA_string_alloc (4 + (buf->msg.header.message_size * 2) + 1);

	strcpy (out, "IOR:");

	for (i = 0, k = 4; i < buf->num_used; i++) {
		struct iovec *curvec;
		guchar       *ptr;

		curvec = &buf->iovecs [i];
		ptr    = curvec->iov_base;

		for (j = 0; j < curvec->iov_len; j++, ptr++) {
			int n1, n2;

			n1 = (*ptr & 0xF0) >> 4;
			n2 = (*ptr & 0xF);

			out [k++] = num2hexdigit (n1);
			out [k++] = num2hexdigit (n2);
		}
	}

	out [k++] = '\0';

	giop_send_buffer_unuse (buf);

	return out;
}
예제 #6
0
void
_ORBIT_skel_Freeamp_GetPlaylist(POA_Freeamp * _ORBIT_servant,
				GIOPRecvBuffer * _ORBIT_recv_buffer,
				CORBA_Environment * ev,
				void (*_impl_GetPlaylist)
				(PortableServer_Servant _servant,
				 Freeamp_StringList ** list,
				 CORBA_Environment * ev))
{
   Freeamp_StringList *list;

   {				/* demarshalling */
      guchar *_ORBIT_curptr;

      _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur;
      if (giop_msg_conversion_needed(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer))) {
      } else {
      }
   }
   _impl_GetPlaylist(_ORBIT_servant, &(list), ev);
   {				/* marshalling */
      register GIOPSendBuffer *_ORBIT_send_buffer;

      _ORBIT_send_buffer =
	 giop_send_reply_buffer_use(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer)->
				    connection, NULL,
				    _ORBIT_recv_buffer->message.u.request.
				    request_id, ev->_major);
      if (_ORBIT_send_buffer) {
	 if (ev->_major == CORBA_NO_EXCEPTION) {
	    register CORBA_unsigned_long _ORBIT_tmpvar_0;
	    register CORBA_unsigned_long _ORBIT_tmpvar_1;
	    CORBA_unsigned_long _ORBIT_tmpvar_2;

	    giop_message_buffer_do_alignment(GIOP_MESSAGE_BUFFER
					     (_ORBIT_send_buffer), 4);
	    {
	       guchar *_ORBIT_t;

	       _ORBIT_t = alloca(sizeof((*list)._length));
	       memcpy(_ORBIT_t, &((*list)._length), sizeof((*list)._length));
	       giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER
					      (_ORBIT_send_buffer),
					      (_ORBIT_t),
					      sizeof((*list)._length));
	    }
	    for (_ORBIT_tmpvar_0 = 0; _ORBIT_tmpvar_0 < (*list)._length;
		 _ORBIT_tmpvar_0++) {
	       _ORBIT_tmpvar_2 = strlen((*list)._buffer[_ORBIT_tmpvar_0]) + 1;
	       giop_message_buffer_do_alignment(GIOP_MESSAGE_BUFFER
						(_ORBIT_send_buffer), 4);
	       {
		  guchar *_ORBIT_t;

		  _ORBIT_t = alloca(sizeof(_ORBIT_tmpvar_2));
		  memcpy(_ORBIT_t, &(_ORBIT_tmpvar_2),
			 sizeof(_ORBIT_tmpvar_2));
		  giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER
						 (_ORBIT_send_buffer),
						 (_ORBIT_t),
						 sizeof(_ORBIT_tmpvar_2));
	       }
	       {
		  guchar *_ORBIT_t;

		  _ORBIT_t =
		     alloca(sizeof
			    ((*list).
			     _buffer[_ORBIT_tmpvar_0][_ORBIT_tmpvar_1]) *
			    _ORBIT_tmpvar_2);
		     memcpy(_ORBIT_t, ((*list)._buffer[_ORBIT_tmpvar_0]),
			    sizeof((*list).
				   _buffer[_ORBIT_tmpvar_0][_ORBIT_tmpvar_1])
			    * _ORBIT_tmpvar_2);
		  giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER
						 (_ORBIT_send_buffer),
						 (_ORBIT_t),
						 sizeof((*list).
							_buffer
							[_ORBIT_tmpvar_0]
							[_ORBIT_tmpvar_1]) *
						 _ORBIT_tmpvar_2);
	       }
	    }

	 } else
	    ORBit_send_system_exception(_ORBIT_send_buffer, ev);
	 giop_send_buffer_write(_ORBIT_send_buffer);
	 giop_send_buffer_unuse(_ORBIT_send_buffer);
      }
      if (ev->_major == CORBA_NO_EXCEPTION)
	 CORBA_free(list);
   }
}
예제 #7
0
파일: client.c 프로젝트: gitpan/CORBA-ORBit
static GPtrArray *
do_marshal (CV *cv, I32 ax, I32 items,
	    CORBA_InterfaceDef_FullInterfaceDescription *desc, I32 index,
	    CORBA_Object obj, GIOPConnection *connection, GIOP_unsigned_long request_id)
{
    OpNameData *operation_name_data;
    static struct iovec operation_vec;
    char *name = NULL;
    GIOPSendBuffer *send_buffer = NULL;
    SV *error_sv = NULL;
    GPtrArray *return_types = NULL;
    dTHR;
    
    /* Determine the operation name used over GIOP
     */
    if (index >= PORBIT_OPERATION_BASE && index < PORBIT_GETTER_BASE) {
	name = g_strdup (desc->operations._buffer[index-PORBIT_OPERATION_BASE].name);
    } else if (index >= PORBIT_GETTER_BASE && index < PORBIT_SETTER_BASE) {
	name = g_strconcat ("_get_", desc->attributes._buffer[index-PORBIT_GETTER_BASE].name, NULL);
    } else if (index >= PORBIT_SETTER_BASE) {
	name = g_strconcat ("_set_", desc->attributes._buffer[index-PORBIT_SETTER_BASE].name, NULL);
    }

    /* Create a SendBuffer for the result
     */
    operation_name_data = (OpNameData *)g_malloc (sizeof (OpNameData) + strlen(name));
    operation_name_data->len = strlen(name) + 1;
    strcpy (operation_name_data->opname, name);
    
    operation_vec.iov_base = operation_name_data;
    operation_vec.iov_len = sizeof(CORBA_unsigned_long) + operation_name_data->len;
    
    send_buffer =
	giop_send_request_buffer_use(connection, NULL, request_id,
				     !IS_ONEWAY(desc,index),
				     &(obj->active_profile->object_key_vec),
				     &operation_vec, &ORBit_default_principal_iovec);
    
    if (!send_buffer) {
	error_sv =
	    porbit_system_except ("IDL:omg.org/CORBA/COMM_FAILURE:1.0",
				  0, CORBA_COMPLETED_NO);
	goto exception;
    }

    /* Do the marshalling. We accumulate the return types into an array for
     * use while demarshalling.
     */

    return_types = g_ptr_array_new();
    
    if (index >= PORBIT_OPERATION_BASE && index < PORBIT_GETTER_BASE) {
        CORBA_OperationDescription *opr = &desc->operations._buffer[index-PORBIT_OPERATION_BASE];
	CORBA_unsigned_long i, st_index;

	if (opr->result->kind != CORBA_tk_void)
	    g_ptr_array_add (return_types, opr->result);
	
	st_index = 1;
	for (i = 0 ; i<opr->parameters._length; i++) {
	    SV *arg = (st_index<(CORBA_unsigned_long)items) ? ST(st_index) : &PL_sv_undef;

	    switch (opr->parameters._buffer[i].mode) {
	    case CORBA_PARAM_IN:
		if (!porbit_put_sv (send_buffer, opr->parameters._buffer[i].type, arg)) {
		    warn ("Error marshalling parameter '%s'",
			  opr->parameters._buffer[i].name);
		    error_sv =
			porbit_system_except ("IDL:omg.org/CORBA/MARSHAL:1.0",
					      0, CORBA_COMPLETED_NO);
		    goto exception;
		}
		st_index++;
		break;
	    case CORBA_PARAM_INOUT:
		if (!SvROK(arg) ||
		    !porbit_put_sv (send_buffer, opr->parameters._buffer[i].type, SvRV (arg))) {
		    
		    if (!SvROK (arg))
			warn ("INOUT parameter must be a reference");
		    else
			warn ("Error marshalling parameter '%s'", opr->parameters._buffer[i].name);
		    
		    error_sv =
			porbit_system_except ("IDL:omg.org/CORBA/MARSHAL:1.0",
					      0, CORBA_COMPLETED_NO);

		    goto exception;
		}
		st_index++;
		/* Fall through */
	    case CORBA_PARAM_OUT:
		g_ptr_array_add (return_types, opr->parameters._buffer[i].type);
		break;
	    }
	}

    } else if (index >= PORBIT_GETTER_BASE && index < PORBIT_SETTER_BASE) {
	g_ptr_array_add (return_types, desc->attributes._buffer[index-PORBIT_GETTER_BASE].type);

    } else if (index >= PORBIT_SETTER_BASE) {
        if (items < 2) {
	    warn("%s::%s called without second argument", HvNAME(CvSTASH(cv)), name);
	    error_sv =
		porbit_system_except ("IDL:omg.org/CORBA/MARSHAL:1.0",
				      0, CORBA_COMPLETED_NO);
	    goto exception;
	}

	if (!porbit_put_sv (send_buffer, 
			    desc->attributes._buffer[index-PORBIT_SETTER_BASE].type, 
			    ST(1))) {
	    warn ("Error marshalling attribute value");
	    error_sv =
		porbit_system_except ("IDL:omg.org/CORBA/MARSHAL:1.0",
				      0, CORBA_COMPLETED_NO);
	    goto exception;
	}
    }

    /* Invoke the operation
     */
    giop_send_buffer_write(send_buffer);

 exception:
    giop_send_buffer_unuse(send_buffer);
    g_free (operation_name_data);
    g_free (name);

    if (error_sv) {
	if (return_types)
	    g_ptr_array_free (return_types, TRUE);
	porbit_throw (error_sv);
    }

    return return_types;
}
예제 #8
0
Account
factory_newAccount(factory _obj, const CORBA_unsigned_long balance,
		   CORBA_Environment * ev)
{
   register GIOP_unsigned_long _ORBIT_request_id,
    _ORBIT_system_exception_minor;
   register CORBA_completion_status _ORBIT_completion_status;
   register GIOPSendBuffer *_ORBIT_send_buffer;
   register GIOPRecvBuffer *_ORBIT_recv_buffer;
   register GIOPConnection *_cnx;
   Account _ORBIT_retval;

   if (_obj->servant && _obj->vepv && factory__classid) {
      _ORBIT_retval =
	 ((POA_factory__epv *) _obj->vepv[factory__classid])->
	 newAccount(_obj->servant, balance, ev);
      return _ORBIT_retval;
   }
   _cnx = ORBit_object_get_connection(_obj);
 _ORBIT_retry_request:
   _ORBIT_send_buffer = NULL;
   _ORBIT_recv_buffer = NULL;
   _ORBIT_completion_status = CORBA_COMPLETED_NO;
   _ORBIT_request_id = GPOINTER_TO_UINT(alloca(0));
   {				/* marshalling */
      static const struct
      {
	 CORBA_unsigned_long len;
	 char opname[11];
      }
      _ORBIT_operation_name_data =
      {
      11, "newAccount"};
      static const struct iovec _ORBIT_operation_vec =
	 { (gpointer) & _ORBIT_operation_name_data, 15 };

      _ORBIT_send_buffer =
	 giop_send_request_buffer_use(_cnx, NULL, _ORBIT_request_id,
				      CORBA_TRUE,
				      &(_obj->active_profile->object_key_vec),
				      &_ORBIT_operation_vec,
				      &ORBit_default_principal_iovec);

      _ORBIT_system_exception_minor = ex_CORBA_COMM_FAILURE;
      if (!_ORBIT_send_buffer)
	 goto _ORBIT_system_exception;
      giop_message_buffer_do_alignment(GIOP_MESSAGE_BUFFER
				       (_ORBIT_send_buffer), 4);
      giop_message_buffer_append_mem(GIOP_MESSAGE_BUFFER(_ORBIT_send_buffer),
				     &(balance), sizeof(balance));
      giop_send_buffer_write(_ORBIT_send_buffer);
      _ORBIT_completion_status = CORBA_COMPLETED_MAYBE;
      giop_send_buffer_unuse(_ORBIT_send_buffer);
      _ORBIT_send_buffer = NULL;
   }
   {				/* demarshalling */
      register guchar *_ORBIT_curptr;

      _ORBIT_recv_buffer =
	 giop_recv_reply_buffer_use_2(_cnx, _ORBIT_request_id, TRUE);
      if (!_ORBIT_recv_buffer)
	 goto _ORBIT_system_exception;
      _ORBIT_completion_status = CORBA_COMPLETED_YES;
      if (_ORBIT_recv_buffer->message.u.reply.reply_status !=
	  GIOP_NO_EXCEPTION) goto _ORBIT_msg_exception;
      _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur;
      if (giop_msg_conversion_needed(GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer))) {
	 GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur = _ORBIT_curptr;
	 _ORBIT_retval =
	    ORBit_demarshal_object(_ORBIT_recv_buffer,
				   GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer)->
				   connection->orb_data);
	 _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur;
      } else {
	 GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur = _ORBIT_curptr;
	 _ORBIT_retval =
	    ORBit_demarshal_object(_ORBIT_recv_buffer,
				   GIOP_MESSAGE_BUFFER(_ORBIT_recv_buffer)->
				   connection->orb_data);
	 _ORBIT_curptr = GIOP_RECV_BUFFER(_ORBIT_recv_buffer)->cur;
      }
      giop_recv_buffer_unuse(_ORBIT_recv_buffer);
      return _ORBIT_retval;
    _ORBIT_system_exception:
      CORBA_exception_set_system(ev, _ORBIT_system_exception_minor,
				 _ORBIT_completion_status);
      giop_recv_buffer_unuse(_ORBIT_recv_buffer);
      giop_send_buffer_unuse(_ORBIT_send_buffer);
      return _ORBIT_retval;
    _ORBIT_msg_exception:
      if (_ORBIT_recv_buffer->message.u.reply.reply_status ==
	  GIOP_LOCATION_FORWARD) {
	 if (_obj->forward_locations != NULL)
	    ORBit_delete_profiles(_obj->forward_locations);
	 _obj->forward_locations = ORBit_demarshal_IOR(_ORBIT_recv_buffer);
	 _cnx = ORBit_object_get_forwarded_connection(_obj);
	 giop_recv_buffer_unuse(_ORBIT_recv_buffer);

	 goto _ORBIT_retry_request;
      } else {
	 ORBit_handle_exception(_ORBIT_recv_buffer, ev, NULL, _obj->orb);
	 giop_recv_buffer_unuse(_ORBIT_recv_buffer);
	 return _ORBIT_retval;
      }
   }
}