/
driver3.2@242/autoconf/
driver3.2@242/doc/LPC/
driver3.2@242/hosts/
driver3.2@242/hosts/amiga/NetIncl/
driver3.2@242/hosts/amiga/NetIncl/netinet/
driver3.2@242/hosts/amiga/NetIncl/sys/
driver3.2@242/hosts/atari/
driver3.2@242/hosts/fcrypt/
driver3.2@242/mudlib/
driver3.2@242/mudlib/sys/
driver3.2@242/util/
driver3.2@242/util/indent/hosts/next/
driver3.2@242/util/make_docs/
/* hosts/amiga/socket_tcp.c
**
** Implement the extra framework to use either the Commodore socket.library
** or the AmiTCP package for LPMud.
**
** Commodore support written by Martin Brenner.
**
**   13-Jan-93 [lars]  Merged.
**   17-Jun-93 [lars]  Added support for AmiTCP.
**   02-Aug-93 [lars]  Adapted for AmiTCP-2.0
*/

/*-----------------------------------------------------------------------*/

#ifdef AS225

#include <clib/exec_protos.h>

#include <sys/types.h>
#include <sys/socket.h>

struct Library *SockBase = NULL;

/* int socket_error; */

/* this is the maximum number of sockets that you want */

#define MAXSOCKS 50

/* required for Initialization of socket.library */

void amiga_sockinit ( void ) {
  if ((SockBase = OpenLibrary ("socket.library", 1L)) == NULL)
    printf ("  Can't open 'socket.library' - using simulated sockets instead.\n");
  else {
    setup_sockets (MAXSOCKS, &errno);
    printf ("  socket.library found and accessed.\n");
  }
}

/* exit in a clean way (close remaining sockets */

void amiga_sockexit ( void ) {
  if (SockBase != NULL) {
    cleanup_sockets();
    CloseLibrary (SockBase);
    SockBase = NULL;
  }
}

#endif /* AS225 */


/*-----------------------------------------------------------------------*/

#ifdef AMITCP

#include <exec/types.h>
#include <clib/socket_protos.h>
#include <stdio.h>

struct Library *SocketBase = NULL;  /* This prevents linking of autocode */

void amiga_sockinit (void) {
  int rc;

  if (rc = _openSockets()) {
    printf ("  Can't access AmiTCP-2 because ");
    switch (rc) {
      case 1: printf ("of wrong OS version"); break;
      case 2: printf ("outdated net.lib was used."); break;
      case 3: printf ("OpenLibrary() failed"); break;
      default: printf ("of an unknown failure"); break;
    }
    printf (".\n  Socket simulation is used instead.\n");
  }
  else
    printf ("  AmiTCP found and accessed.\n");
}

void amiga_sockexit (void) {
  _closeSockets();
}

#endif /* AMITCP */

/*-----------------------------------------------------------------------*/

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