/*
 *  SWINDOWS    A program to allow you to open windows on any screen by
 *              supplying the screen name in thw window title
 *
 *              Copyright 1989 by Davide P. Cervone.
 *  You may use this code, provided this copywrite notice is kept intact.
 */

#include "swHandler.h"


struct IntuitionBase *IntuitionBase = NULL;
struct SysBase *SysBase;


/*
 *  These are the assembly code stubs that replace the Intuition Library
 *  vectors.  Thes stubs in turn call the C-language routines that actually
 *  do the work.
 */

extern void aOpenWindow();
extern void aCloseWindow();
extern void aCloseScreen();

/*
 *  These are used by the assembly stubs to call the original routines when
 *  needed.  They also are used to replace the Intution vectors when 
 *  sWindows exits.
 */

long OldOpenWindow;
long OldCloseWindow;
long OldCloseScreen;


static struct swHandlerInfo swHandlerData =
{
   {                                            /* the MsgPort is pre-setup */
      {NULL,NULL, NT_MSGPORT, 0, PORTNAME},     /*  to include the name and */
      PA_IGNORE, 0, NULL,                       /*  type so that it can just */
      {NULL,NULL,NULL, 0,0}                     /*  be added to the port list */
   },                                           /*  so it can be founf later */
   MAJVERS,MINVERS, 0,
   NULL,
   &IntuitionBase,
   &SysBase,
   
   &ScreenList,
   &WindowList,
   
   &aOpenWindow,
   &aCloseWindow,
   &aCloseScreen,
   
   &OldOpenWindow,
   &OldCloseWindow,
   &OldCloseScreen,
};


/*
 *  Setup()
 *
 *  This routine MUST be linked into the sWindows-Handler executable 
 *  as the first routine, so that the loader can find it.
 *  It should check the version number for compatibility with the loader,
 *  and should return NULL for an error, or the pointer to the shared
 *  data structure if everything is OK.
 */

struct swHandlerInfo *Setup(version)
int version;
{
   if (version < MINLOADVER) return(NULL);
   return(&swHandlerData);
}
