home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / v2 / killclic.lzh / KillClick2.c next >
Encoding:
C/C++ Source or Header  |  1990-12-14  |  2.0 KB  |  98 lines

  1. /*
  2.  * KillClick2 - by Daniel Martin
  3.  * December 14th, 1990.
  4.  * USENET: martin@IRO.UMontreal.CA
  5.  *
  6.  * Based on KillClick Written by Brian Gontowski
  7.  *
  8.  * Modifications:
  9.  *        - Now turn off all connected drive units
  10.  *        - "#includes" controlled by a switch for compilation with MANX Aztec
  11.  *        - Use TD_NAME instead of "trackdisk.device" for compatibility
  12.  *        - Added prototyping for AINSI C compliance
  13.  *        - Shortened error messages, users don't know much of this stuff anyway.
  14.  *
  15.  * Bugs: 
  16.  *        None.
  17.  *
  18.  * Remarks: 
  19.  *        I'm not sure if we should put forbid()/permit() when modifying the public 
  20.  *        structure TDU_PublicUnit in NoClick procedure.
  21.  */
  22.  
  23.  
  24. #define AZTEC    1
  25.  
  26.  
  27. #include "exec/types.h"
  28. #include "exec/ports.h"
  29. #include "exec/io.h"
  30. #include "devices/trackdisk.h"
  31. #include "libraries/dos.h"
  32. #include "libraries/dosextens.h"
  33. #include "stdio.h"
  34.  
  35.  
  36. #ifdef AZTEC
  37.     #include "clib/exec_protos.h"
  38.     #include "clib/dos_protos.h"
  39. #else
  40.     #include "proto/exec.h"
  41.     #include "proto/dos.h"
  42. #endif
  43.  
  44.  
  45. /*-- Globals --*/
  46. extern struct Library *SysBase;
  47. struct MsgPort *DiskPort=NULL;
  48. struct IOExtTD *DiskReq=NULL;
  49. UBYTE DiskDev=FALSE;
  50. struct TDU_PublicUnit *DiskUnit;
  51. char DeviceName[] = TD_NAME;
  52. ULONG ChangeCount;
  53.  
  54.  
  55.  
  56.  
  57. void Finish (char *msg, int r)
  58. {
  59.     if (DiskReq)
  60.         DeleteIORequest ((struct IORequest *)DiskReq);
  61.     if (DiskPort) 
  62.         DeleteMsgPort (DiskPort);
  63.     if (msg) 
  64.         Write (Output (),(UBYTE *)msg,strlen (msg));
  65.     _exit (r);
  66. }
  67.  
  68.  
  69.  
  70.  
  71. void NoClick(ULONG Unit)
  72. {
  73.     if (!OpenDevice ((STRPTR)DeviceName,Unit,(struct IORequest *)DiskReq,0)) {
  74.         DiskUnit=(struct TDU_PublicUnit *)DiskReq->iotd_Req.io_Unit;
  75.         DiskUnit->tdu_PubFlags|=TDPF_NOCLICK;
  76.         CloseDevice ((struct IORequest *)DiskReq);
  77.     }
  78. }
  79.  
  80.  
  81.  
  82.  
  83. void _main ()
  84. {
  85.     ULONG i = 0;
  86.  
  87.     if (SysBase->lib_Version<36)
  88.         Finish ("ERROR: Need KickStart V36 or higher!\n",RETURN_FAIL);
  89.     if (!(DiskPort=CreateMsgPort ()) || 
  90.         !(DiskReq=(struct IOExtTD *) CreateIORequest (DiskPort,sizeof (struct IOExtTD))))
  91.         Finish ("ERROR: Allocations failed!\n",RETURN_FAIL);
  92.  
  93.     /* For all units */
  94.     do    {NoClick(i);} while (++i < NUMUNITS);
  95.  
  96.     Finish(NULL,RETURN_OK);
  97. }
  98.