/* * This is an example of using mrd_prevent_allow(3mrd) to * prevent or allow media removal, where allowed. For * robot name on the command line, the desired version * of the command will be used according lock value. * name. * * Usage: * * mrd_prevent_allow lock-value robot [ robot... ] */ #ifndef lint static char SccsId[] = "@(#)mrd_prevent_allow.c 1.2 3/5/97" ; #endif #include <stdio.h> #include <stdlib.h> #include <mrd_common.h> #include <mrd_message.h> main(int argc, char *argv[]) { int rc ; /* Counter */ int lock ; /* Lock value */ int status ; /* return status */ char *robot ; /* Robot to open */ robot_info_t robot_info ; /* Robot data */ dev_status_t dev_status ; /* Device status */ char log_info[MRD_MAX_LOG_STRING+1] ; /* * Check that there are enough arguments. */ if( argc < 3 ) { printf("usage: %s lock-value robot [ robot... ]\n", argv[0]) ; exit(1) ; } else lock = atoi(argv[1]) ; /* * Initialize the channel field of the robot_info, so * mrd_startup(3mrd) will actually open the robot. */ robot_info.channel = BAD_CHANNEL ; for(rc = 2; rc < argc; rc++) { /* * The robot for this command. */ robot = argv[rc] ; status = mrd_startup(robot, &robot_info, log_info) ; if( status != MRD_STATUS_SUCCESS ) { printf("Startup failed on %s: %s.\n", robot, mrd_strstatus(status)) ; continue ; } printf("Lock value %d on %s.\n", lock, robot) ; status = mrd_prevent_allow(&robot_info, lock, &dev_status) ; if( status != MRD_STATUS_SUCCESS ) printf("Prevent/Allow failed on %s: %s.\n", robot, mrd_strstatus(status)) ; (void)mrd_shutdown(&robot_info) ; } return 0 ; }