home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 568a.lha / OwnDevUnit.library / source / tester.c < prev    next >
C/C++ Source or Header  |  1991-10-28  |  950b  |  52 lines

  1. /* tester */
  2.  
  3. #include <exec/lists.h>
  4. #include <proto/exec.h>
  5. #include "OwnDevUnit.h"
  6. #include <dos/dosextens.h>
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. struct Library *OwnDevUnitBase;
  11.  
  12. main(int argc, char *argv[])
  13. {
  14.     UBYTE *RetVal;
  15.     ULONG NotifyBit;
  16.     ULONG Signal;
  17.  
  18.     if ((NotifyBit = AllocSignal(-1)) == -1) {
  19.         printf("couldn't get signal bit\n");
  20.         exit(0);
  21.     }
  22.  
  23.     if (!(OwnDevUnitBase = OpenLibrary(ODU_NAME, 0))) {
  24.         printf("couldn't open ODU.\n");
  25.         exit(0);
  26.     }
  27.  
  28.     RetVal = AttemptDevUnit(argv[1], atol(argv[2]), "Tester", NotifyBit);
  29.  
  30.     if (RetVal)
  31.         printf("returned \"%s\"\n", RetVal);
  32.     else
  33.         printf("obtained the lock!\n");
  34.  
  35.     if (!RetVal)
  36.         for (;;) {
  37.             Signal = Wait(SIGBREAKF_CTRL_F | (1L << NotifyBit));
  38.  
  39.             if (Signal & (1L << NotifyBit))
  40.                 printf("NotifyBit triggered\n");
  41.  
  42.             if (Signal & SIGBREAKF_CTRL_F)
  43.                 break;
  44.         }
  45.  
  46.     if (!RetVal)
  47.         FreeDevUnit(argv[1], atol(argv[2]));
  48.  
  49.     FreeSignal(NotifyBit);
  50.     CloseLibrary(OwnDevUnitBase);
  51. }
  52.