/*
 * This file was generated by orbit-idl - DO NOT EDIT!
 */

#include <string.h>
#include "balsa.h"

void
_ORBIT_skel_balsa_mail_send_to(POA_balsa_mail_send * _ORBIT_servant,
			       GIOPRecvBuffer * _ORBIT_recv_buffer,
			       CORBA_Environment * ev,
			       CORBA_boolean(*_impl_to)
			       (PortableServer_Servant _servant,
				CORBA_char * to, CORBA_Environment * ev))
{
   CORBA_boolean _ORBIT_retval;
   CORBA_char *to;

   {				/* 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);
	 _ORBIT_tmpvar_3 =
	    (CORBA_unsigned_long)
	    GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr));
	    _ORBIT_curptr += 4;
	 to = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(to[_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;
	 to = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(to[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3;
      }
   }
   _ORBIT_retval = _impl_to(_ORBIT_servant, to, 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 (ev->_major == CORBA_NO_EXCEPTION) {
	 {
	    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);
   }
}
void
_ORBIT_skel_balsa_mail_send_attachment(POA_balsa_mail_send * _ORBIT_servant,
				       GIOPRecvBuffer * _ORBIT_recv_buffer,
				       CORBA_Environment * ev,
				       CORBA_boolean(*_impl_attachment)
				       (PortableServer_Servant _servant,
					CORBA_char * to,
					CORBA_char * filename,
					CORBA_Environment * ev))
{
   CORBA_boolean _ORBIT_retval;
   CORBA_char *to;
   CORBA_char *filename;

   {				/* demarshalling */
      guchar *_ORBIT_curptr;
      register CORBA_unsigned_long _ORBIT_tmpvar_4;
      CORBA_unsigned_long _ORBIT_tmpvar_5;
      register CORBA_unsigned_long _ORBIT_tmpvar_6;
      CORBA_unsigned_long _ORBIT_tmpvar_7;

      _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);
	 _ORBIT_tmpvar_5 =
	    (CORBA_unsigned_long)
	    GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr));
	    _ORBIT_curptr += 4;
	 to = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(to[_ORBIT_tmpvar_4]) * _ORBIT_tmpvar_5;
	 _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4);
	 _ORBIT_tmpvar_7 =
	    (CORBA_unsigned_long)
	    GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr));
	    _ORBIT_curptr += 4;
	 filename = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(filename[_ORBIT_tmpvar_6]) * _ORBIT_tmpvar_7;
      } else {
	 _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4);
	 _ORBIT_tmpvar_5 = *((CORBA_unsigned_long *) _ORBIT_curptr);
	 _ORBIT_curptr += 4;
	 to = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(to[_ORBIT_tmpvar_4]) * _ORBIT_tmpvar_5;
	 _ORBIT_curptr = ALIGN_ADDRESS(_ORBIT_curptr, 4);
	 _ORBIT_tmpvar_7 = *((CORBA_unsigned_long *) _ORBIT_curptr);
	 _ORBIT_curptr += 4;
	 filename = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(filename[_ORBIT_tmpvar_6]) * _ORBIT_tmpvar_7;
      }
   }
   _ORBIT_retval = _impl_attachment(_ORBIT_servant, to, filename, 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 (ev->_major == CORBA_NO_EXCEPTION) {
	 {
	    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);
   }
}
void
_ORBIT_skel_balsa_mailbox_info_newmail(POA_balsa_mailbox_info *
				       _ORBIT_servant,
				       GIOPRecvBuffer * _ORBIT_recv_buffer,
				       CORBA_Environment * ev,
				       CORBA_boolean(*_impl_newmail)
				       (PortableServer_Servant _servant,
					CORBA_char * path,
					CORBA_Environment * ev))
{
   CORBA_boolean _ORBIT_retval;
   CORBA_char *path;

   {				/* 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);
	 _ORBIT_tmpvar_3 =
	    (CORBA_unsigned_long)
	    GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr));
	    _ORBIT_curptr += 4;
	 path = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(path[_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;
	 path = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(path[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3;
      }
   }
   _ORBIT_retval = _impl_newmail(_ORBIT_servant, path, 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 (ev->_major == CORBA_NO_EXCEPTION) {
	 {
	    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);
   }
}
void
_ORBIT_skel_balsa_mailbox_info_num_msgs(POA_balsa_mailbox_info *
					_ORBIT_servant,
					GIOPRecvBuffer * _ORBIT_recv_buffer,
					CORBA_Environment * ev,
					CORBA_long(*_impl_num_msgs)
					(PortableServer_Servant _servant,
					 CORBA_char * path,
					 CORBA_Environment * ev))
{
   CORBA_long _ORBIT_retval;
   CORBA_char *path;

   {				/* 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);
	 _ORBIT_tmpvar_3 =
	    (CORBA_unsigned_long)
	    GUINT32_SWAP_LE_BE(*((guint32 *) _ORBIT_curptr));
	    _ORBIT_curptr += 4;
	 path = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(path[_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;
	 path = (void *) _ORBIT_curptr;
	 _ORBIT_curptr += sizeof(path[_ORBIT_tmpvar_2]) * _ORBIT_tmpvar_3;
      }
   }
   _ORBIT_retval = _impl_num_msgs(_ORBIT_servant, path, 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 (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);
   }
}
static ORBitSkeleton
get_skel_balsa_mail_send(POA_balsa_mail_send * servant,
			 GIOPRecvBuffer * _ORBIT_recv_buffer, gpointer * impl)
{
   gchar *opname = _ORBIT_recv_buffer->message.u.request.operation;

   switch (opname[0]) {
     case 'a':
      if (strcmp((opname + 1), "ttachment"))
	 break;
      *impl = (gpointer) servant->vepv->balsa_mail_send_epv->attachment;
      return (ORBitSkeleton) _ORBIT_skel_balsa_mail_send_attachment;
      break;
     case 't':
      if (strcmp((opname + 1), "o"))
	 break;
      *impl = (gpointer) servant->vepv->balsa_mail_send_epv->to;
      return (ORBitSkeleton) _ORBIT_skel_balsa_mail_send_to;
      break;
     default:
      break;
   }
   return NULL;
}

static void
init_local_objref_balsa_mail_send(CORBA_Object obj,
				  POA_balsa_mail_send * servant)
{
   obj->vepv[balsa_mail_send__classid] = servant->vepv->balsa_mail_send_epv;
}

void
POA_balsa_mail_send__init(PortableServer_Servant servant,
			  CORBA_Environment * env)
{
   static const PortableServer_ClassInfo class_info =
      { (ORBit_impl_finder) & get_skel_balsa_mail_send,
	 "IDL:balsa/mail_send:1.0",
	 (ORBit_local_objref_init) & init_local_objref_balsa_mail_send };

   PortableServer_ServantBase__init(((PortableServer_ServantBase *) servant),
				    env);
   ORBIT_OBJECT_KEY(((PortableServer_ServantBase *) servant)->_private)->
      class_info = (PortableServer_ClassInfo *) & class_info;
   if (!balsa_mail_send__classid)
      balsa_mail_send__classid = ORBit_register_class(&class_info);
}

void
POA_balsa_mail_send__fini(PortableServer_Servant servant,
			  CORBA_Environment * env)
{
   PortableServer_ServantBase__fini(servant, env);
}

static ORBitSkeleton
get_skel_balsa_mailbox_info(POA_balsa_mailbox_info * servant,
			    GIOPRecvBuffer * _ORBIT_recv_buffer,
			    gpointer * impl)
{
   gchar *opname = _ORBIT_recv_buffer->message.u.request.operation;

   switch (opname[0]) {
     case 'n':
      switch (opname[1]) {
	case 'e':
	 if (strcmp((opname + 2), "wmail"))
	    break;
	 *impl = (gpointer) servant->vepv->balsa_mailbox_info_epv->newmail;
	 return (ORBitSkeleton) _ORBIT_skel_balsa_mailbox_info_newmail;
	 break;
	case 'u':
	 if (strcmp((opname + 2), "m_msgs"))
	    break;
	 *impl = (gpointer) servant->vepv->balsa_mailbox_info_epv->num_msgs;
	 return (ORBitSkeleton) _ORBIT_skel_balsa_mailbox_info_num_msgs;
	 break;
	default:
	 break;
      }
      break;
     default:
      break;
   }
   return NULL;
}

static void
init_local_objref_balsa_mailbox_info(CORBA_Object obj,
				     POA_balsa_mailbox_info * servant)
{
   obj->vepv[balsa_mailbox_info__classid] =
      servant->vepv->balsa_mailbox_info_epv;
}

void
POA_balsa_mailbox_info__init(PortableServer_Servant servant,
			     CORBA_Environment * env)
{
   static const PortableServer_ClassInfo class_info =
      { (ORBit_impl_finder) & get_skel_balsa_mailbox_info,
	 "IDL:balsa/mailbox_info:1.0",
	 (ORBit_local_objref_init) & init_local_objref_balsa_mailbox_info };

   PortableServer_ServantBase__init(((PortableServer_ServantBase *) servant),
				    env);
   ORBIT_OBJECT_KEY(((PortableServer_ServantBase *) servant)->_private)->
      class_info = (PortableServer_ClassInfo *) & class_info;
   if (!balsa_mailbox_info__classid)
      balsa_mailbox_info__classid = ORBit_register_class(&class_info);
}

void
POA_balsa_mailbox_info__fini(PortableServer_Servant servant,
			     CORBA_Environment * env)
{
   PortableServer_ServantBase__fini(servant, env);
}
