ramstart.c 1.44 KB
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

#ifndef MSDOS /* { */
# include <sys/types.h>
# include <unistd.h>
#endif

/*
 * Types
 */

/*
 * Definitions
 */

/*
 * Globals
 */
char    *command_name;
long	diskType;

void usage(void)
{
  fprintf(stderr, "Usage: ramstart type\n");
  
  return;
  
} /* usage() */

int             ramStartLba[] = 
{
  1418, 1966, 2514, 3062, 3610, 4088, 4292
};

int main(int argc, char **argv)
{
  char          *p;
  
#ifdef MSDOS
  command_name = (char *)cut_dir_fname(argv[0]);
#else
  if ((command_name = rindex(argv[0], '/')) != NULL)
    command_name++;
  else
    command_name = argv[0];
#endif
    
  /*
   * Parse arguments
   */
  while( --argc > 0 )
  {

    if ( **(++argv) == '-' )
    {
      usage();
      exit(1);
      
    } /* if ( **(++argv) == '-' ) */
    else
      break;

  } /* while( argc > 0 ) */
       
  if (argc == 1)
  {
    diskType = strtol( *argv, (char **)NULL, 0);
  }
  else 
  {
    usage();
    exit(1);
  }
  
  /*
   * ディスクタイプが合法的なものかチェック
   */
  if ( (diskType < 0) || (diskType > 6) )
  {
    fprintf(stderr, "%s: type is illegal. It must be in [0-6].\n",
	    command_name);
    exit(1);
  }

  /*
   * ram start を表示(タイプ6 には ram 領域はない)
   */
  if (diskType == 6)
  {
    fprintf(stdout, "Disk type 6 does not have ram area.\n");
  }
  else
    fprintf(stdout, "%d\n", ramStartLba[diskType]);

  exit(0);
  
  /* NOTREACHED */
  
} /* main() */