michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* To edit this file, set TABSTOPS to 4 spaces. michael@0: * This is not the normal NSS convention. michael@0: */ michael@0: michael@0: #include "modutil.h" michael@0: #include "install.h" michael@0: #include michael@0: #include "certdb.h" /* for CERT_DB_FILE_VERSION */ michael@0: #include "nss.h" michael@0: michael@0: static void install_error(char *message); michael@0: static char* PR_fgets(char *buf, int size, PRFileDesc *file); michael@0: static char *progName; michael@0: michael@0: michael@0: /* This enum must be kept in sync with the commandNames list */ michael@0: typedef enum { michael@0: NO_COMMAND, michael@0: ADD_COMMAND, michael@0: CHANGEPW_COMMAND, michael@0: CREATE_COMMAND, michael@0: DEFAULT_COMMAND, michael@0: DELETE_COMMAND, michael@0: DISABLE_COMMAND, michael@0: ENABLE_COMMAND, michael@0: FIPS_COMMAND, michael@0: JAR_COMMAND, michael@0: LIST_COMMAND, michael@0: RAW_LIST_COMMAND, michael@0: RAW_ADD_COMMAND, michael@0: CHKFIPS_COMMAND, michael@0: UNDEFAULT_COMMAND michael@0: } Command; michael@0: michael@0: /* This list must be kept in sync with the Command enum */ michael@0: static char *commandNames[] = { michael@0: "(no command)", michael@0: "-add", michael@0: "-changepw", michael@0: "-create", michael@0: "-default", michael@0: "-delete", michael@0: "-disable", michael@0: "-enable", michael@0: "-fips", michael@0: "-jar", michael@0: "-list", michael@0: "-rawlist", michael@0: "-rawadd", michael@0: "-chkfips", michael@0: "-undefault" michael@0: }; michael@0: michael@0: michael@0: /* this enum must be kept in sync with the optionStrings list */ michael@0: typedef enum { michael@0: ADD_ARG=0, michael@0: RAW_ADD_ARG, michael@0: CHANGEPW_ARG, michael@0: CIPHERS_ARG, michael@0: CREATE_ARG, michael@0: DBDIR_ARG, michael@0: DBPREFIX_ARG, michael@0: DEFAULT_ARG, michael@0: DELETE_ARG, michael@0: DISABLE_ARG, michael@0: ENABLE_ARG, michael@0: FIPS_ARG, michael@0: FORCE_ARG, michael@0: JAR_ARG, michael@0: LIBFILE_ARG, michael@0: LIST_ARG, michael@0: RAW_LIST_ARG, michael@0: MECHANISMS_ARG, michael@0: NEWPWFILE_ARG, michael@0: PWFILE_ARG, michael@0: SLOT_ARG, michael@0: UNDEFAULT_ARG, michael@0: INSTALLDIR_ARG, michael@0: TEMPDIR_ARG, michael@0: SECMOD_ARG, michael@0: NOCERTDB_ARG, michael@0: STRING_ARG, michael@0: CHKFIPS_ARG, michael@0: michael@0: NUM_ARGS /* must be last */ michael@0: } Arg; michael@0: michael@0: /* This list must be kept in sync with the Arg enum */ michael@0: static char *optionStrings[] = { michael@0: "-add", michael@0: "-rawadd", michael@0: "-changepw", michael@0: "-ciphers", michael@0: "-create", michael@0: "-dbdir", michael@0: "-dbprefix", michael@0: "-default", michael@0: "-delete", michael@0: "-disable", michael@0: "-enable", michael@0: "-fips", michael@0: "-force", michael@0: "-jar", michael@0: "-libfile", michael@0: "-list", michael@0: "-rawlist", michael@0: "-mechanisms", michael@0: "-newpwfile", michael@0: "-pwfile", michael@0: "-slot", michael@0: "-undefault", michael@0: "-installdir", michael@0: "-tempdir", michael@0: "-secmod", michael@0: "-nocertdb", michael@0: "-string", michael@0: "-chkfips", michael@0: }; michael@0: michael@0: /* Increment i if doing so would have i still be less than j. If you michael@0: are able to do this, return 0. Otherwise return 1. */ michael@0: #define TRY_INC(i,j) ( ((i+1)