VMS Help  —  MRD Library, mrd_unload, Example
    This example applies to the OpenVMS operating system.

    /*
     * Example of mrd_unload(3mrd).  The command usage is:
     *
     *  mrd_unload robot_name drive slot [ volume_tag ]
     *
     * This version is VMS specific since it excludes the example
     * for taking a tape drive offline.  That is moderately complicated
     * but something that should be in the VMS documentation.
     */
    #ifndef lint
    static char SccsId[] = "@(#)mrd_unload.c 1.2A (mrd-example) 3/5/97" ;
    #endif

    #include <stdio.h>
    #include <string.h>
    #include <errno.h>
    #include <stdlib.h>

    #include <mrd_common.h>
    #include <mrd_message.h>

    main(int argc, char *argv[])
    {
     int status ;  /* Status from mrd_load(3mrd) */
     char *robot ;  /* The name of the robot */
     char *cart = NULL ;  /* Optional volume tag to check */
     char *slot ;   /* Source slot */
     char *drive ;  /* Destination drive */
     char log_info[MRD_MAX_LOG_STRING+1] ; /* error string */

     /*
      * Accept three required argument; robot, port and slot.  The
      * volume tag and tape drive name are optional.
      */
     if( argc < 4 ) {
      printf("usage: %s robot slot drive [ volume-tag ]\n",
       argv[0]) ;
      exit(1) ;
     }

     /*
      * Just use these directly from the command line.
      */
     robot  = argv[1] ;
     slot   = argv[2] ;
     drive  = argv[3] ;

     /*
      * If there is an extra argument present, assume it is
      * a cartridge name.  The habit of the DECC runtime
      * start-up mapping all characters to lower case,
      * might require special handling of the cartridge
      * name.
      */
     if( argc > 4 )
      cart = argv[4] ;

     /*
      * Call the function.
      */
     status = mrd_unload(robot, cart, slot, drive, log_info) ;

     /*
      * Print an error message if there is a failure.  The
      * routine mrd_strstatus(3mrd) will accept an MRD
      * error status and return the corresponding string.
      * If the log_info data has something other than a
      * NUL as the first character print it as well.  It
      * typically be the SCSI sense data or a operating
      * system specific message for the error.
      */
     if( status != MRD_STATUS_SUCCESS )
      printf("Load failed: %s: %s.\n", mrd_strstatus(status),
       log_info[0] ? log_info : "none") ;
     else
      printf("Unloaded media from Drive #%s to Slot #%s.\n",
       drive, slot) ;

     return 0 ;
    }
Close Help