home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3438 < prev    next >
Encoding:
Internet Message Format  |  1991-06-04  |  3.1 KB

  1. From: tron1@tronsbox.xei.com (Kenneth Jamieson)
  2. Newsgroups: alt.sources
  3. Subject: ctape.c (ISC SysV386 tape utility)
  4. Message-ID: <1656@tronsbox.xei.com>
  5. Date: 2 Jun 91 21:05:50 GMT
  6.  
  7. /* ctape.c:
  8.    
  9.    NOTE: ctape is PD. Do what you want with it. It has only been tested under
  10.          Interactive Systems 2.0.2 with a Wangtek tape drive.
  11.  
  12.      If it blows up the world, destroys your data, or eats your pets
  13.      it is NOT my responsibility.
  14.  
  15.      Kenneth jamieson
  16.  
  17.    What does it do ? 
  18.  
  19.    ctape allows you to control tape drives in the most basic way. It is NOT
  20.    a general purpose tape manager, it just REWINDS, RETENSIONS, and ERASES.
  21.  
  22.    I am sure there are better programs for this, but it is small, and did
  23.    what I needed it to do.
  24.  
  25.    To Compile and Run:
  26.  
  27.        Examine the #defines below, and decide what you want the program
  28.        to be called for each function. 
  29.  
  30.        do "cc ctape.c -o ctape"
  31.  
  32.        do "ln ctape ct_rewind" and so on, linking the ctape binary to
  33.        the names you chose for the functions.
  34.  
  35.        This way, there is only one binary, but no user interaction needed.
  36.  
  37.        Then, you can say "ct_rewind /dev/tape" and off it goes.
  38.  
  39.        Simple.
  40.  
  41. */
  42.  
  43. #include <stdio.h>
  44. #include <fcntl.h>
  45. #include <sys/types.h>
  46. #include <sys/gentape.h>
  47. #include <string.h>
  48.  
  49. #define REWIND_NAME "ct_rewind"
  50. #define RETENSION_NAME "ct_reten"
  51. #define ERASE_NAME "ct_erase"
  52.  
  53. int main(argc, argv)
  54. int argc;
  55. char **argv;
  56. {
  57.   int tapedev;
  58.  
  59.   if(argc < 2){ 
  60.     fprintf(stderr,"%s usage guide: \n",argv[0]);
  61.     fprintf(stderr,"\t%s <tape device name>\n",argv[0]);
  62.     return(1); 
  63.   }
  64.  
  65.   if( strcmp(REWIND_NAME, argv[0]) == 0 ){
  66.     tapedev = open( argv[1], O_RDONLY );
  67.     if( tapedev == -1 ){
  68.       fprintf(stderr,"Rewind: could not open %s to read!\n", argv[1]);
  69.       return(2);
  70.     }
  71.     fprintf(stderr,"Rewinding ...");
  72.     ioctl( tapedev, TC_REWIND );
  73.     fprintf(stderr," Done.\n");
  74.   }
  75.  
  76.   if( strcmp(RETENSION_NAME, argv[0]) == 0 ){
  77.     tapedev = open( argv[1], O_RDONLY );
  78.     if( tapedev == -1 ){
  79.       fprintf(stderr,"Retension: could not open %s to read!\n", argv[1]);
  80.       return(3);
  81.     }
  82.     fprintf(stderr,"Retensioning ...");
  83.     ioctl( tapedev, TC_RETENSION );
  84.     fprintf(stderr," Done.\n");
  85.   }
  86.  
  87.   if( strcmp(ERASE_NAME, argv[0]) == 0 ){
  88.     tapedev = open( argv[1], O_RDWR );
  89.     if( tapedev == -1 ){
  90.       fprintf(stderr,"Erase: could not open %s to read/write!\n", argv[1]);
  91.       return(4);
  92.     }
  93.     fprintf(stderr,"Erasing ...");
  94.     ioctl( tapedev, TC_ERASE );
  95.     fprintf(stderr," Done.\n");
  96.   }
  97.  
  98.   if( tapedev != -1 ){ close(tapedev); }
  99.  
  100.   return(0);
  101. }
  102.  
  103.  
  104. -- 
  105. ========[ Xanadu Enterprises Inc. Amiga & Unix Software Development]=======
  106. = "I know how you feel, you don't know if you want to hit me or kiss me - =
  107. =  --- I get a lot of that."  Madonna as Breathless Mahoney (Dick Tracy)  =
  108. =========== Ken Jamieson: uunet!tronsbox.xei.com!tron1  ===================
  109. =     NONE of the opinions represented here are endorsed by anybody.      =
  110. =  Unix is (tm) AT&T, Amiga is (tm) Commodore Business Machines, and all  =
  111. =  characters from Dick Tracy are (tm) Warner Bros.                       =
  112. ===========================================================================
  113.