/*******************************************************************

Copyright (c) 2004 Open Mobile Alliance, Ltd.  All Rights Reserved.

This software is made available under the usage and distribution terms 
covered by the Common Public License 1.0 and by using this software you
are bound by the terms and conditions of the same.

EXCEPT AS EXPRESSLY SET FORTH IN THE COMMON PUBLIC LICENSE,
THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 
ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
   
Each recipient is solely responsible for determining the 
appropriateness of using and distributing this program and assumes 
all risks associated with its exercise of rights under the Common 
Public License, including but not limited to the risks and 
costs of program errors, compliance with applicable laws, 
damage to or loss of data, programs or equipment, and 
unavailability or interruption of operations.

********************************************************************/
#include <transport.h>

#include <constants.h>
#include <iConstants.h>
#include <error.h>

#include <irTransport.h>
#include <inetTransport.h>
#include <stdlib.h>
#include <stdio.h>

/*
** Return the predefined transport as specified in the 'id'.
*/
ObxTransport *iobxTransportGet( short preDefinedTransportId ) {
   ObxTransport *transport = NULL;

   OBXDBGFLOW(("iobxTransportGet() entry, id=%d.\n", preDefinedTransportId ));
   if ( (transport = (ObxTransport *)malloc( sizeof( ObxTransport ) )) ) {
      OBXDBGBUF(("iobxTransportGet() malloc, addr=0x%08x, len=%d.\n", transport, sizeof(ObxTransport) ));
      switch ( preDefinedTransportId ) {
      case DEFINED_TRANSPORT_IRDA:
         transport->initialize        = iobxIrTransportInitialize;
         transport->terminate         = iobxIrTransportTerminate;
         transport->open              = iobxIrTransportOpen;
         transport->listen            = iobxIrTransportListen;
         transport->accept            = iobxIrTransportAccept;
         transport->connect           = iobxIrTransportConnect;
         transport->send              = iobxIrTransportSend;
         transport->recv              = iobxIrTransportRecv;
         transport->close             = iobxIrTransportClose;
         break;
      case DEFINED_TRANSPORT_INET:
         transport->initialize        = iobxInetTransportInitialize;
         transport->terminate         = iobxInetTransportTerminate;
         transport->open              = iobxInetTransportOpen;
         transport->listen            = iobxInetTransportListen;
         transport->accept            = iobxInetTransportAccept;
         transport->connect           = iobxInetTransportConnect;
         transport->send              = iobxInetTransportSend;
         transport->recv              = iobxInetTransportRecv;
         transport->close             = iobxInetTransportClose;
         break;
      }
   }
   return transport;
}

/*
** Free the passed transport
*/
void iobxTransportFree( ObxTransport *transport ) {
   OBXDBGFLOW(("iobxTransportFree() entry, transport=0x%08x.\n", transport ));
   if ( transport ) {
      free( transport );
   }
}

