Copyright Digital Equipment Corp. All rights reserved.

Example

   /*
    *   Example of mrd_initialize(3mrd).  The command usage is:
    *
    *      mrd_init robot_name
    *
    *   It has been observed on an empty TL820 with all the
    *   bin-packs in place that this command takes just under
    *   23 minutes.
    */
   #ifndef   lint
   static   char   SccsId[] = "@(#)mrd_init.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   status ;      /* Status from mrd_inject(3mrd) */
      char   *robot ;      /* The name of the robot */
      char   log_info[MRD_MAX_LOG_STRING+1] ;  /* error string */

      /*
       *   Accept one required argument; robot name
       */
      if( argc < 2 ) {
         printf("usage: %s robot\n", argv[0]) ;
         exit(1) ;
      }

      /*
       *   Just use this directly from the command line.
       */
      robot = argv[1] ;

      /*
       *   Because this routine can take a long time we'll
       *   provide some positive feed-back that is doing
       *   something.
       */
      printf("Reinventory library %s...", robot); fflush(stdout) ;

      /*
       *   Call the function.  Because this routine can take a
       */
      status = mrd_initialize(robot, log_info) ;

      /*
       *   Done.
       */
      putchar('\n') ;

      /*
       *   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
       *   NULL 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("Initialize failed: %s: %s.\n", mrd_strstatus(status),
            log_info[0] ? log_info : "none") ;

      return 0 ;
   }