/*
 * $Id: amiga.c,v 1.1 1994/02/02 17:48:57 too Exp $
 *
 * Author: Tomi Ollila <too@cs.hut.fi>
 *
 * Copyright (c) 1993, 1994  AmiTCP/IP Group, <amitcp-group@hut.fi>
 *                           Helsinki University of Technology, Finland.
 *                           All rights reserved.
 *
 * Created: Tue Aug  3 19:38:51 1993 too
 * Last modified: Wed Mar  2 16:38:23 1994 too
 *
 * HISTORY
 * $Log: amiga.c,v $
 * Revision 1.1  1994/02/02  17:48:57  too
 * Initial revision
 *
 */

#include <exec/types.h>
#include <exec/libraries.h>

#include <dos/dos.h>

#include "amiga.h"

#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/socket.h>

#include <stdlib.h>

#include "amitcp/socketbasetags.h"

struct DosLibrary * DOSBase;

struct Library * SocketBase = NULL;

void _STIstart(void)
{
  if ((DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 36)) == NULL)
    exit(20);

  if ((SocketBase = OpenLibrary("bsdsocket.library", 2)) == NULL) {
    Printf("Can not open bsdsocket.library\n");
    CloseLibrary((struct Library *)DOSBase);
  }
}

void _STDend(void)
{
  CloseLibrary(SocketBase);
  CloseLibrary((struct Library *)DOSBase);
}

void herror(char * banner)
{
  LONG * str;

  (void)SocketBaseTags(SBTM_GETREF(SBTC_HERRNO),	&str,
		       SBTM_GETREF(SBTC_HERRNOSTRPTR),	&str,
		       TAG_DONE,			0);
  
  Printf("%s: %s\n", banner, (char *)str);
}
