case DBPREFIX_ARG: if(TRY_INC(i, argc)) { PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg); return OPTION_NEEDS_ARG_ERR; } dbprefix = argv[i]; break;
parse_args(int argc, char *argv[]){	int i;	char *arg;	int optionType;	/* Loop over all arguments */	for(i=1; i < argc; i++) {		arg = argv[i];		/* Make sure this is an option and not some floating argument */		if(arg[0] != '-') {			PR_fprintf(PR_STDERR, errStrings[UNEXPECTED_ARG_ERR], argv[i]);			return UNEXPECTED_ARG_ERR;		}		/* Find which option this is */		for(optionType=0; optionType < NUM_ARGS; optionType++) {			if(! strcmp(arg, optionStrings[optionType])) {				break;			}		}				/* Deal with this specific option */		switch(optionType) {		case NUM_ARGS:		default:			PR_fprintf(PR_STDERR, errStrings[UNKNOWN_OPTION_ERR], arg);			return UNKNOWN_OPTION_ERR;			break;		case ADD_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = ADD_COMMAND;			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			moduleName = argv[i];			break;		case CHANGEPW_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = CHANGEPW_COMMAND;			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			tokenName = argv[i];			break;		case CIPHERS_ARG:			if(ciphers != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			ciphers = argv[i];			break;		case CREATE_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = CREATE_COMMAND;			break;		case DBDIR_ARG:			if(dbdir != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			dbdir = argv[i];			break;		case UNDEFAULT_ARG:		case DEFAULT_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			if(optionType == DEFAULT_ARG) {				command = DEFAULT_COMMAND;			} else {				command = UNDEFAULT_COMMAND;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			moduleName = argv[i];			break;		case DELETE_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = DELETE_COMMAND;			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			moduleName = argv[i];			break;		case DISABLE_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = DISABLE_COMMAND;			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			moduleName = argv[i];			break;		case ENABLE_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = ENABLE_COMMAND;			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			moduleName = argv[i];			break;		case FIPS_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = FIPS_COMMAND;			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			fipsArg = argv[i];			break;		case FORCE_ARG:			force = 1;			break;		case NOCERTDB_ARG:			nocertdb = PR_TRUE;			break;		case INSTALLDIR_ARG:			if(installDir != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			installDir = argv[i];			break;		case TEMPDIR_ARG:			if(tempDir != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			tempDir = argv[i];			break;		case JAR_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = JAR_COMMAND;			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			jarFile = argv[i];			break;		case LIBFILE_ARG:			if(libFile != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			libFile = argv[i];			break;		case LIST_ARG:			if(command != NO_COMMAND) {				PR_fprintf(PR_STDERR, errStrings[MULTIPLE_COMMAND_ERR], arg);				return MULTIPLE_COMMAND_ERR;			}			command = LIST_COMMAND;			/* This option may or may not have an argument */			if( (i+1 < argc) && (argv[i+1][0] != '-') ) {					moduleName = argv[++i];			}			break;		case MECHANISMS_ARG:			if(mechanisms != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			mechanisms = argv[i];			break;		case NEWPWFILE_ARG:			if(newpwFile != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			newpwFile = argv[i];			break;		case PWFILE_ARG:			if(pwFile != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			pwFile = argv[i];			break;		case SLOT_ARG:			if(slotName != NULL) {				PR_fprintf(PR_STDERR, errStrings[DUPLICATE_OPTION_ERR], arg);				return DUPLICATE_OPTION_ERR;			}			if(TRY_INC(i, argc)) {				PR_fprintf(PR_STDERR, errStrings[OPTION_NEEDS_ARG_ERR], arg);				return OPTION_NEEDS_ARG_ERR;			}			slotName = argv[i];			break;		}	}	return SUCCESS;}