home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / diskutil / tapebios / mt.c < prev    next >
C/C++ Source or Header  |  1993-08-06  |  2KB  |  96 lines

  1. /* MT.TTP, Magnetic Tape functions for TapeBIOS     */
  2. /* This program is part of the TapeBIOS ditribution    */
  3. /* Written by Alan Hourihane 1992            */
  4. /* Needs TapeBIOS driver loaded                */
  5.  
  6. #include <stdio.h>
  7. #include "tapebind.h"
  8.  
  9. extern void exit();
  10. extern void Erase_Tape();
  11. extern void Retension();
  12. extern int Request_Sense();
  13. extern int strcmp();
  14. extern void bzero();
  15. extern long get_cookie();
  16.  
  17. int
  18. main(argc, argv) 
  19. int argc; char *argv[];
  20. {
  21.     if(argc != 2) { 
  22.         printf("Magnetic Tape (MT) Utility. Copyright 1992, A. Hourihane.\r\n");
  23.         printf("Usage: %s { rewind | load | unload | erase | retension }\r\n", argv[0]); 
  24.         exit(1); 
  25.     }
  26.  
  27.     if(!get_cookie("TAPE")) {
  28.         printf("TapeBIOS is not installed.\r\n");
  29.         exit(1);
  30.     }
  31.     
  32.     if (!(strcmp(argv[1], "rewind")))
  33.         (void) Trewind();
  34.     else if(!(strcmp(argv[1], "retension")))
  35.         (void)Retension();
  36.     else if(!(strcmp(argv[1], "erase")))
  37.         (void)Erase_Tape();
  38.     else if(!(strcmp(argv[1], "load")))
  39.         (void)Tload(0L);
  40.     else if(!(strcmp(argv[1], "unload")))
  41.         (void)Tunload(0L);
  42.     
  43.     return(0);
  44. }
  45.  
  46. int
  47. Ready_Tape()
  48. {
  49.     int stat = 0, x = 0;
  50.  
  51.     for(x = 10; x > 0 && stat; x--) {
  52.         stat = Tready();
  53.         if(stat == 2) {
  54.             stat = Request_Sense();
  55.             printf("Tape Drive returned error code: %d\r\n",stat);
  56.             return(stat);
  57.         }
  58.     }
  59.     return(0);
  60. }
  61.  
  62. void
  63. Retension()
  64. {
  65.     int stat = 0;
  66.  
  67.     if(Ready_Tape() == 0) {
  68.         stat = Tload(1L);
  69.         if (stat == 2) {
  70.             stat = Request_Sense();
  71.             printf("Tape Drive returned error code: %d\r\n",stat);
  72.         }
  73.         stat = Tunload(0L);
  74.         if (stat == 2) {
  75.             stat = Request_Sense();
  76.             printf("Tape Drive returned error code: %d\r\n",stat);
  77.         }
  78.     }
  79. }
  80.  
  81. void
  82. Erase_Tape()
  83. {
  84.     int stat = 0;
  85.     
  86.     if(Ready_Tape() == 0) {
  87.         stat = Terase();    
  88.             if(stat) {
  89.                 if(stat == 2) {
  90.                 stat = Request_Sense();
  91.                 printf("Tape Drive returned error code: %d\r\n",stat);
  92.                 }
  93.             }
  94.     }
  95. }
  96.