home *** CD-ROM | disk | FTP | other *** search
- From: tron1@tronsbox.xei.com (Kenneth Jamieson)
- Newsgroups: alt.sources
- Subject: ctape.c (ISC SysV386 tape utility)
- Message-ID: <1656@tronsbox.xei.com>
- Date: 2 Jun 91 21:05:50 GMT
-
- /* ctape.c:
-
- NOTE: ctape is PD. Do what you want with it. It has only been tested under
- Interactive Systems 2.0.2 with a Wangtek tape drive.
-
- If it blows up the world, destroys your data, or eats your pets
- it is NOT my responsibility.
-
- Kenneth jamieson
-
- What does it do ?
-
- ctape allows you to control tape drives in the most basic way. It is NOT
- a general purpose tape manager, it just REWINDS, RETENSIONS, and ERASES.
-
- I am sure there are better programs for this, but it is small, and did
- what I needed it to do.
-
- To Compile and Run:
-
- Examine the #defines below, and decide what you want the program
- to be called for each function.
-
- do "cc ctape.c -o ctape"
-
- do "ln ctape ct_rewind" and so on, linking the ctape binary to
- the names you chose for the functions.
-
- This way, there is only one binary, but no user interaction needed.
-
- Then, you can say "ct_rewind /dev/tape" and off it goes.
-
- Simple.
-
- */
-
- #include <stdio.h>
- #include <fcntl.h>
- #include <sys/types.h>
- #include <sys/gentape.h>
- #include <string.h>
-
- #define REWIND_NAME "ct_rewind"
- #define RETENSION_NAME "ct_reten"
- #define ERASE_NAME "ct_erase"
-
- int main(argc, argv)
- int argc;
- char **argv;
- {
- int tapedev;
-
- if(argc < 2){
- fprintf(stderr,"%s usage guide: \n",argv[0]);
- fprintf(stderr,"\t%s <tape device name>\n",argv[0]);
- return(1);
- }
-
- if( strcmp(REWIND_NAME, argv[0]) == 0 ){
- tapedev = open( argv[1], O_RDONLY );
- if( tapedev == -1 ){
- fprintf(stderr,"Rewind: could not open %s to read!\n", argv[1]);
- return(2);
- }
- fprintf(stderr,"Rewinding ...");
- ioctl( tapedev, TC_REWIND );
- fprintf(stderr," Done.\n");
- }
-
- if( strcmp(RETENSION_NAME, argv[0]) == 0 ){
- tapedev = open( argv[1], O_RDONLY );
- if( tapedev == -1 ){
- fprintf(stderr,"Retension: could not open %s to read!\n", argv[1]);
- return(3);
- }
- fprintf(stderr,"Retensioning ...");
- ioctl( tapedev, TC_RETENSION );
- fprintf(stderr," Done.\n");
- }
-
- if( strcmp(ERASE_NAME, argv[0]) == 0 ){
- tapedev = open( argv[1], O_RDWR );
- if( tapedev == -1 ){
- fprintf(stderr,"Erase: could not open %s to read/write!\n", argv[1]);
- return(4);
- }
- fprintf(stderr,"Erasing ...");
- ioctl( tapedev, TC_ERASE );
- fprintf(stderr," Done.\n");
- }
-
- if( tapedev != -1 ){ close(tapedev); }
-
- return(0);
- }
-
-
- --
- ========[ Xanadu Enterprises Inc. Amiga & Unix Software Development]=======
- = "I know how you feel, you don't know if you want to hit me or kiss me - =
- = --- I get a lot of that." Madonna as Breathless Mahoney (Dick Tracy) =
- =========== Ken Jamieson: uunet!tronsbox.xei.com!tron1 ===================
- = NONE of the opinions represented here are endorsed by anybody. =
- = Unix is (tm) AT&T, Amiga is (tm) Commodore Business Machines, and all =
- = characters from Dick Tracy are (tm) Warner Bros. =
- ===========================================================================
-