/*
 * cleanup.c
 *
 * Author: Tomi Ollila <too@cs.hut.fi>
 *
 * 	Copyright (c) 1993 Tomi Ollila
 * 	    All rights reserved
 *
 * Created: Thu Nov  4 21:17:14 1993 too
 * Last modified: Sun Nov 14 17:42:26 1993 too
 *
 * HISTORY
 * $Log: cleanup.c,v $
 * Revision 1.1  1993/11/17  11:47:44  too
 * Initial revision
 *
 * Revision 1.1  1993/11/17  11:47:44  too
 * Initial revision
 *
 */

#if 0 && (__GNUC__ < 2) && (__SASC < 6) || !defined (AMIGA)
#error this program compiles only with amiga, gcc v2.x or sas/c version 6.x
#endif

#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/ports.h>
#include <dos/dos.h>
#include <dos/dosextens.h>

#include "global.h"

#define BSDSOCKET_H /* defining BSDSOCKET_H inhibitis automatic inline incl.*/
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>

#include "system_includes.h"
#include "applport.h"
#include "handler.h"
#include "cleanup.h"

#define RFI ->

int clean(struct CleanUp * CU, int retval)
{
  if (SocketBase)
    CloseLibrary(SocketBase);
  
  CloseLibrary((struct Library *)DOSBase);

  if (applsigbit != -1)
    FreeSignal(applsigbit);

  if (timermsgport)
    DeleteMsgPort(timermsgport);

  /*
   * itr structure holds information of timer.device.
   */
  if (itr) {
    CloseDevice(itr);
    FreeMem(itr, sizeof *itr);
  }
  return retval;
}
