另类设置程序参数

  for ( argp = argv+1 ; *argp ; argp++ ) {
    if ( **argp == '-' ) {
      opt = *argp + 1;
      if ( !*opt )
	usage();

      while ( *opt ) {
	switch ( *opt ) {
	case 's':		/* Use "safe, slow and stupid" code */
	  stupid = 1;
	  break;
	case 'r':		/* RAID mode */
	  raid_mode = 1;
	  break;
	case 'f':		/* Force install */
	  force = 1;
	  break;
	case 'm':		/* Install MBR */
	  mbr = 1;
	  break;
	case 'a':		/* Mark this partition active */
	  setactive = 1;
	  break;
	case 'd':
	  if ( argp[1] )
	    subdir = *++argp;
	  break;
	default:
	  usage();
	  break;
	}
	opt++;
      }
    } else {
      if ( bootsecfile )
	usage();
      else if ( drive )
	bootsecfile = *argp;
      else
	drive = *argp;
    }
  }


你可能感兴趣的:(另类设置程序参数)