/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* |_o_o|\\ Copyright (c) 1990 The Software Distillery.  All Rights Reserved.*/
/* |. o.| || This program may not be distributed without the permission of   */
/* | .  | || the authors.                                                    */
/* | o  | ||                                                                 */
/* |  . |// Written by Doug Walker                                           */
/* ======          BBS:(919)-471-6436      VOICE:(919)-467-4764              */

/*                 BIX: djwalker           USENET: ...!mcnc!rti!sas!walker   */
/*                 405 B3 Gooseneck Dr, Cary, NC 27513, USA                  */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <exec/types.h>
#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include <exec/interrupts.h>
#include <exec/ports.h>
#include <exec/libraries.h>
#include <exec/io.h>
#include <exec/tasks.h>
#include <exec/execbase.h>
#include <exec/devices.h>
#include <devices/timer.h>
#include <devices/input.h>
#include <devices/inputevent.h>
/*#include <intuition/intuition.h>*/
#include <libraries/dos.h>
/*#include <graphics/gfxmacros.h>*/
#include <hardware/custom.h>
#include <hardware/dmabits.h>
#include <hardware/cia.h>
#include <resources/misc.h>
#include <proto/dos.h>
#include <proto/exec.h>
/*#include <proto/intuition.h>*/
/*#include <proto/graphics.h>*/
#include <string.h>
#include <stdio.h>

#include "dnet.h"

#define PORT_NETKEYS 9494



#define NKMPNAME "NetKeys 1.0"
#define BANNER "\x9B" "1m" NKMPNAME "\x9b" "0m by Doug Walker\n"\
               "Copyright \xA9 1990 The Software Distillery\n"\
               "235 Trillingham Ln, Cary NC 27513 USA\nBBS:(919) 471-6436\n"

#define INSTR  "Left-Amiga-R to toggle machines;  Use 'NetKeys QUIT' to remove\
"\
               "Installing...\n"

#define DEFDOKEY     0x13
#define MAXMSGS      100

#define MSG(fh,st)  if(fh) Write(fh, st, strlen(st))

#define IESZ  (sizeof(struct InputEvent))
#define NKMSZ (sizeof(struct NETKEYMSG))

struct NETKEYMSG
{
   struct Message m;
   short msgtype;
   struct InputEvent ie;   
};

/* Defines for the msgtype field */
#define NKM_IEVENT  0
#define NKM_QUIT    1
#define NKM_CONTROL 2

typedef struct
{
   struct Task *buddy;
   short dokey;
   short state;
   short nmsgs;
   struct MsgPort *nkmp;
   struct MsgPort *rtnp;
   char  work[256];
} GLOBAL_DATA;

/* Defines for the global.state field */
#define EM_SANITY -3  /* Failed sanity check - prolly too many msgs outstanding
*/
#define EM_NOMEM  -2  /* Out of memory                                         
*/
#define EM_QUIT   -1  /* Normal quit                                           
*/
#define EM_DOIT    0  /* Keep on truckin'                                      
*/
#define EM_LURK    1  /* Pass events through                                   
*/

#define NKM_HANDLER 2 /* Parms to InitDevice */
#define NKM_SERVER  1

struct InputEvent * __regargs myhandler(struct InputEvent *ev, GLOBAL_DATA *gpt
);

/* * * * * * * * * * * EXTERNAL ROUTINES * * * * * * * * * */
struct IOStdReq * CreateIOReq(struct MsgPort *, int);
void DeleteIOReq(struct IOStdReq *);
