home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 230.lha / PopCli_IV / popcli.h < prev    next >
C/C++ Source or Header  |  1989-04-06  |  5KB  |  166 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2. /* |_o_o|\\ Copyright (c) 1986 The Software Distillery.  All Rights Reserved */
  3. /* |. o.| || This program may not be distributed without the permission of   */
  4. /* | .  | || the authors.                                                    */
  5. /* | o  | ||    Dave Baker     Ed Burnette  Stan Chow    Jay Denebeim        */
  6. /* |  . |//     Gordon Keener  Jack Rouse   John Toebes  Doug Walker         */
  7. /* ======          BBS:(919)-471-6436      VOICE:(919)-469-4210              */ 
  8. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  9. /*
  10.  * VERY loosely based on the input.device example by Rob Peck, 12/1/85
  11.  */
  12.  
  13. /* * * * * * * * * INCLUDE FILES * * * * * * * * * * * */
  14. #include <exec/types.h>
  15. #include <exec/nodes.h>
  16. #include <exec/lists.h>
  17. #include <exec/memory.h>
  18. #include <exec/interrupts.h>
  19. #include <exec/ports.h>
  20. #include <exec/libraries.h>
  21. #include <exec/io.h>
  22. #include <exec/tasks.h>
  23. #include <exec/execbase.h>
  24. #include <exec/devices.h>
  25. #include <devices/timer.h>
  26. #include <devices/input.h>
  27. #include <devices/inputevent.h>
  28. #include <intuition/intuition.h>
  29. #include <intuition/intuitionbase.h>
  30. #include <libraries/dos.h>
  31. #include <graphics/gfxmacros.h>
  32. #include <hardware/custom.h>
  33. #include <hardware/dmabits.h>
  34. #include <proto/dos.h>
  35. #include <proto/exec.h>
  36. #include <proto/intuition.h>
  37. #include <proto/graphics.h>
  38. #include <string.h>
  39.  
  40. /* too bad "#include <#?/#?.h>" doesn't work.... */
  41.  
  42.  
  43.  
  44. /* #defines and declarations for POPCLI */
  45.  
  46. /* * * * * * * * * * * CONSTANTS * * * * * * * * * * * * */
  47. #define PORTNAME     "POPCLI4"
  48. #define TIMEINTERVAL 1L      /* in seconds */
  49. #define DEFTIME      300     /* five minute timeout */
  50. #define MAXCMD       207     /* Might as well fill up a COMMAND_BLOCK */
  51. #define DEFKEY       0x45    /* ESC */
  52. #define DEFCMD       "NEWCLI"
  53.  
  54.  
  55. /* * * * * * * * * * * GLOBAL VARIABLES * * * * * * * * * */
  56.  
  57. typedef struct COMMAND_BLOCK
  58.    {
  59.    short                   minmem;
  60.    short                   minchip;
  61.    unsigned char           cmdflags;
  62.    char                    command[MAXCMD];
  63.    } CommandBlock;
  64.  
  65. /* Two kludges to get around naming problems with #defines */
  66. typedef struct GfxBase        *GBasePtr;
  67. typedef struct IntuitionBase    *IBasePtr;
  68.  
  69. typedef struct
  70.    {
  71.    struct Task            *buddy;
  72.    ULONG                   unblanksig;
  73.    ULONG                   noevents;
  74.    short                   blanksignum;
  75.    struct MsgPort         *execport;
  76.    struct Screen          *blankscreen;
  77.    IBasePtr           IBase;
  78.    GBasePtr           GBase;
  79.    struct DosLibrary      *DosBase;
  80.    struct Custom          *customptr;
  81.    struct NewScreen        newscreen;
  82.    CommandBlock           *keytab[256];
  83.    BPTR                   stdout;
  84.    } GLOBAL_DATA;
  85.  
  86. /* #defines for the global pointer. In _main, we #undef "global" */
  87.  
  88. #define global        (*gptr)
  89. #define DOSBase        global.DosBase
  90. #define IntuitionBase    global.IBase
  91. #define GfxBase        global.GBase
  92.  
  93. /* KLUDGE!!! KLUDGE!!! KLUDGE!!! */
  94. #define custom (*((struct Custom *)0xdff000))
  95.  
  96. struct OURMSG {
  97.    struct Message          msgpart;
  98.    char                    type;
  99.    unsigned char           key;
  100.    short                   interval;
  101.    short                   minmem;
  102.    short                   minchip;
  103.    unsigned char           cmdflags;
  104.    char                    command[MAXCMD];
  105. };
  106.  
  107. #define OURMSGHDRSZ          6
  108.  
  109. void        _main(void);
  110. int         popparse( GLOBAL_DATA *, char *, struct OURMSG * );
  111. void        popbanner( GLOBAL_DATA * );
  112. void        poptrailer( GLOBAL_DATA * );
  113.  
  114. void  __far copyproc( GLOBAL_DATA *, struct Process *, struct Process * );
  115. void        termproc( GLOBAL_DATA *, struct Process * );
  116.  
  117. void        DeleteIOReq(GLOBAL_DATA *, struct IOStdReq *);
  118. void        QueueTimer( GLOBAL_DATA *, struct timerequest *, ULONG);
  119. struct IOStdReq *CreateIOReq(GLOBAL_DATA *, struct MsgPort *, int);
  120. void        MyDeletePort( GLOBAL_DATA *, struct MsgPort * );
  121. struct MsgPort *MyCreatePort( GLOBAL_DATA *, char * );
  122. struct InputEvent *
  123. __asm
  124. myhandler(
  125.   register __a0 struct InputEvent *ev,  /* pointer to a list of events */
  126.   register __a1 GLOBAL_DATA *gptr);     /* Everything we need to know  */
  127.  
  128.  
  129. struct CDIR {        /* Structure for process path chain */
  130.     BPTR    next;    /* I hate BPTRs */
  131.     BPTR    lock;    /* LOCK for this path component */
  132. };
  133.  
  134. /*-------------------------------------------------------------------------*/
  135. /* POPCLI internal constants                                               */
  136.  
  137. /*- Message types -*/
  138.  
  139. #define   MSG_NONE    0   /* Used only by parser */
  140. #define   MSG_ADDKEY    1
  141. #define   MSG_DELKEY    2
  142. #define   MSG_EXECUTE   3
  143. #define   MSG_SHUTDOWN  4
  144. #define   MSG_BLANK     5
  145. #define   MSG_UNBLANK   6
  146. #define   MSG_SETTIME   7
  147.  
  148. /*- Flags in cmdflags (8 bits) -*/
  149.  
  150. #define   FLAG_NOWB2F   0x80   /* Don't WBenchToFront() before command   */
  151.  
  152. /*- Return codes from the parser -*/
  153.  
  154. #define   OK            0
  155. #define   LEAVE         1
  156. #define   SHUTDOWN      2
  157.  
  158. /*-------------------------------------------------------------------------*/
  159. /* Structure for CBACK */
  160.  
  161. typedef struct {
  162.    BPTR         Backstdout;     /* standard output when run in background */
  163.    long         SyncSignal;    /* signal to terminate resident portion   */
  164.    struct Task  *SyncProcess;   /* Task to terminate                      */
  165. } CBACK_DATA;
  166.