rem: index_type_str = optarg; if (strncmp("int", optarg, 3) == 0) index_type = B_INT32_TYPE; else if (strncmp("llong", optarg, 5) == 0) index_type = B_INT64_TYPE; else if (strncmp("string", optarg, 6) == 0) index_type = B_STRING_TYPE; else if (strncmp("float", optarg, 5) == 0) index_type = B_FLOAT_TYPE; else if (strncmp("double", optarg, 6) == 0) index_type = B_DOUBLE_TYPE; else usage(1); break;
add: indexTypeName = optarg; if (strncmp("int", optarg, 3) == 0) indexType = B_INT32_TYPE; else if (strncmp("llong", optarg, 5) == 0) indexType = B_INT64_TYPE; else if (strncmp("string", optarg, 6) == 0) indexType = B_STRING_TYPE; else if (strncmp("float", optarg, 5) == 0) indexType = B_FLOAT_TYPE; else if (strncmp("double", optarg, 6) == 0) indexType = B_DOUBLE_TYPE; else usage(1); break;
context: int main (int32 argc, char **argv){	int c;	int verbose = 0;	dev_t vol_device = 0;	char *index_type_str = NULL;	int index_type = B_STRING_TYPE;	char *index_name = NULL;	int retval;	char *error_message;		while ((c = getopt_long(argc, argv, "d:ht:v", longopts, NULL)) != -1)	{		switch (c)		{			case 0:			  break;			case 'd':			  vol_device = dev_for_path(optarg);			  if (vol_device < 0)			  {			      fprintf(stderr, "%s: can't get information about volume: %s\n", argv[0], optarg);			      return (-1);			  }			  break;			case GETOPT_HELP_CHAR:			  usage(0);			  break;			case 't':			  index_type_str = optarg;			  if (strncmp("int", optarg, 3) == 0)			    index_type = B_INT32_TYPE;			  else if (strncmp("llong", optarg, 5) == 0)			    index_type = B_INT64_TYPE;			  else if (strncmp("string", optarg, 6) == 0)			    index_type = B_STRING_TYPE;			  else if (strncmp("float", optarg, 5) == 0)			    index_type = B_FLOAT_TYPE;			  else if (strncmp("double", optarg, 6) == 0)			    index_type = B_DOUBLE_TYPE;			  else			    usage(1);			  break;			case 'v':			  verbose = 1;			  break;			default:			  usage(1);			  break;		}	}	/* Create the index on the volume of the current	   directory if no volume was specified. */	if (vol_device == 0)	{		index_type_str = "string";		vol_device	=	dev_for_path(".");		if (vol_device < 0)		{			fprintf(stderr, "%s: can't get information about current volume\n", argv[0]);			return (-1);		}	}	if (argc - optind == 1)  // last argument	{		index_name = argv[optind];	} else	{		usage(1);	}	if (verbose)	{		/* Get the mount point of the specified volume. */		BVolume volume(vol_device);		BDirectory dir;		volume.GetRootDirectory(&dir);		BPath path(&dir, NULL);		fprintf(stdout, "Creating index \"%s\" of type %s on volume mounted at %s.\n", index_name, index_type_str, path.Path());	}	if ((retval = fs_create_index(vol_device, index_name, index_type, 0)) != 0)	{		switch (errno)		{			B_BAD_VALUE:			  error_message = "The device does not exist, or name is reserved.";			  break;			B_NOT_ALLOWED:			  error_message = "The device is read-only.";			  break;			B_NO_MEMORY:			  error_message = "Insufficient memory to complete the operation.";			  break;			B_FILE_EXISTS:			  error_message = "The index already exists.";			  break;			B_DEVICE_FULL:			  error_message = "There's not enough room on the device to create the index.";			  break;			B_FILE_ERROR:			  error_message = "Invalid directory reference.";			  break;			B_ERROR:			  error_message = "The index type passed isn't supported.";			  break;			default:			  error_message = "An unknown error has occured.";			  break;		}		fprintf(stderr, "%s\n", error_message);	}	return (0);}