/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* |_o_o|\\ Copyright (c) 1989 The Software Distillery.                    *
* |. o.| ||          All Rights Reserved                                  *
* | .  | ||          Written by John Toebes and Doug Walker               *
* | o  | ||          The Software Distillery                              *
* |  . |//           235 Trillingham Lane                                 *
* ======             Cary, NC 27513                                       *
*                    BBS:(919)-471-6436                                   *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <graphics/gfxmacros.h>
#include <graphics/rastport.h>
#include <libraries/dos.h>
#include <workbench/startup.h>
#include <proto/intuition.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/graphics.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#ifdef DEBUG
#undef DEBUG
#endif

#if 0
#define DEBUG 1
extern int debug;
#define BUG(n,a) if(debug>=(n)){printf a ; fflush(stdout);}
#else
#define BUG(n,a) ;
#endif

/* my version of BADDR() has no problems with casting */
#undef  BADDR
#define BADDR(x)        ((APTR)((long)x << 2))
#define MKBADDR(x)      ((BPTR)((long)x >> 2))

#define GAD_UNKNOWN        1   /* The PW default */
#define GAD_ARG1           2
#define GAD_ARG2           3
#define GAD_ARG3           4
#define GAD_ARG4           5
#define GAD_STR1           6
#define GAD_STR2           7
#define GAD_STR3           8
#define GAD_STR4           9
#define GAD_DEVICE        10
#define GAD_SEND          11
#define GAD_PREV          12
#define GAD_NEXT          13
#define GAD_HANDLE        14
#define GAD_FILEINFO      15
#define GAD_INFODATA      16
#define GAD_BUFFER        17
#define GAD_DEBUG         18
#define GAD_BUFLEN        19
#define GAD_BLOK          20
#define GAD_BLCAN         21
#define GAD_DOWN          22  
#define GAD_SLIDER        23  /* THis must be the middle of GAD_DOWN/GAD_UP */
#define GAD_UP            24  /* To do a subtraction to get the direction   */

#define SEL_OPENINPUT      1
#define SEL_OPENOUTPUT     2
#define SEL_OPENUPDATE     3
#define SEL_READ           4
#define SEL_WRITE          5
#define SEL_SEEK           6
#define SEL_CLOSE          7
#define SEL_TRUNCATE       8
#define SEL_LOCK           9
#define SEL_DUPLOCK       10
#define SEL_UNLOCK        11
#define SEL_EXAMINE       12
#define SEL_EXNEXT        13
#define SEL_CREATEDIR     14
#define SEL_DELETE        15
#define SEL_RENAME        16
#define SEL_PARENT        17
#define SEL_SETPROTECT    18
#define SEL_SETCOMMENT    19
#define SEL_SETDATE       20
#define SEL_CURRENTVOL    21
#define SEL_INFO          22
#define SEL_DISKINFO      23
#define SEL_RENAMEDISK    24
#define SEL_DIE           25
#define SEL_FLUSH         26
#define SEL_MORECACHE     27
#define SEL_INHIBIT       28
#define SEL_WRITE_PROTECT 29
#define SEL_NETWORKHELLO  30
#define SEL_DEBUG         31
#define SEL_SETTRANS      32

#define SEL_LASTPACKET    32
#define SEL_HANDLE        (SEL_LASTPACKET+1)
#define SEL_FILEINFO      (SEL_LASTPACKET+2)
#define SEL_INFODATA      (SEL_LASTPACKET+3)
#define SEL_BUFFER        (SEL_LASTPACKET+4)
#define SEL_PURGE         (SEL_LASTPACKET+5)
#define SEL_QUIT          (SEL_LASTPACKET+6)
#define SEL_HELP          (SEL_LASTPACKET+7)
#define SEL_SEND          (SEL_LASTPACKET+8)
#define SEL_MIN2          (SEL_LASTPACKET+9)
#define SEL_MIN1          (SEL_LASTPACKET+10)
#define SEL_ZERO          (SEL_LASTPACKET+11)
#define SEL_ONE           (SEL_LASTPACKET+12)

#ifndef ACTION_NETWORK_HELLO
#define ACTION_NETWORK_HELLO 2012
#endif

#ifndef ACTION_HANDLER_DEBUG
#define ACTION_HANDLER_DEBUG 2010
#endif

#ifndef ACTION_SET_TRANS
#define ACTION_SET_TRANS 2011
#endif

extern struct Menu Menu1;
extern struct TextAttr TOPAZ80;

/* Types for the Arg1-4 and Res1-2 fields */
#define STR 1      /* Text string                                        */
#define FLG 2      /* Boolean flag                                       */
#define LCK 3      /* BPTR to a struct FileLock                          */
#define HAN 4      /* BPTR to a struct FileHandle                        */
#define FIB 5      /* BPTR to a struct FileInfoBlock                     */
#define AG1 6      /* Arg1 from a struct FileHandle                      */
#define INF 7      /* BPTR to a struct InfoData                          */
#define NUM 8      /* Integer                                            */
#define VOL 9      /* BPTR to a volume node                              */
#define RCNUM 10   /* Return code value                                  */
#define BUF 11     /* BPTR to a data buffer                              */

/* return codes */
#define RC_OK             0  /* Normal completion                        */
#define RC_ERRNOMEM      -1  /* Out of memory                            */
#define RC_ERRNOWIND     -2  /* Couldn't open window                     */
#define RC_ERRBADTYPE    -3  /* Bad struct TYPE code specified           */
#define RC_ERRNOTINLIST  -4  /* Supplied struct is not in struct list    */
#define RC_UNLINKED      -5  /* Tried to act on an unlinked window       */
#define RC_ERRBADPACKET  -6  /* Bad packet type specified                */
#define RC_ERRNODEVICE   -7  /* DeviceProc returned NULL                 */
#define RC_ERRBADDATA    -8  /* Bad data value in Argn field             */

/* The following are struct types to be passed to the struct routines    */
#define ST_UNLINKED -1   /* Struct has been unlinked, don't use it       */

#define ST_DATA      0   /* Data buffer                                  */
#define ST_VIEW      1   /* File viewer                                  */
#define ST_INTER     2   /* One bigger than the last interactive one     */

#define ST_FIB       2   /* struct FileInfoBlock                         */
#define ST_HANDLE    3   /* struct FileHandle                            */
#define ST_LOCK      4   /* struct FileLock                              */
#define ST_INFO      5   /* struct InfoData                              */
#define ST_NUM       6   /* One bigger than last one defined above       */

#define HELPFILE "PickPack.Doc"

extern struct Window *Window;

/* The following are defined in struct.c */
int InitST(struct MsgPort *);
int TermST(void);
struct Window *AllocST(int, APTR, int);
int DisplayST(struct Window *);
void MoveWind(struct Window *, int);
int UnlinkST(struct Window *);
int PurgeST(void);
int NameST(struct Window *, char *, struct MsgPort *);
int WindSize(struct Window *);
APTR WindToST(struct Window *);
struct Window *STToWind(APTR);
APTR FindST(char *, int);

/* The following is from sendpkt.c */
LONG sendpkt(struct MsgPort *, long, long*, long, long*);

/* The following is from pickpack.c */
void status(char *);

/* The following is from request.c */
int reqinit(void);
int reqkill(void);

/* The following is from help.c */
int GetHelp(char **, int *);
int CountLines(char *, int);

/* The following is from date.c */
void FormatDate(struct DateStamp *, char *);
