Make the public interface use a flags variable instead of a billion little
Bools. suggested and reviewed by wtc in bug 66230
This commit is contained in:
Родитель
70fccf2bc5
Коммит
fc4874ebfb
|
@ -2463,7 +2463,7 @@ main(int argc, char **argv)
|
|||
/* Initialize NSPR and NSS. */
|
||||
PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);
|
||||
rv = NSS_Initialize(SECU_ConfigDirectory(NULL), certPrefix, certPrefix,
|
||||
"secmod.db", PR_FALSE, PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
"secmod.db", 0);
|
||||
if (rv != SECSuccess) {
|
||||
SECU_PrintPRandOSError(progName);
|
||||
return -1;
|
||||
|
|
|
@ -506,6 +506,7 @@ init_crypto(PRBool create, PRBool readOnly)
|
|||
#endif
|
||||
Error retval;
|
||||
SECStatus rv;
|
||||
int flags = 0;
|
||||
|
||||
|
||||
if(SECU_ConfigDirectory(dbdir)[0] == '\0') {
|
||||
|
@ -617,8 +618,11 @@ init_crypto(PRBool create, PRBool readOnly)
|
|||
}
|
||||
|
||||
/* Open/create key database */
|
||||
flags = 0;
|
||||
if (readOnly) flags |= NSS_INIT_READONLY;
|
||||
if (nocertdb) flags |= NSS_INIT_NOCERTDB;
|
||||
rv = NSS_Initialize(SECU_ConfigDirectory(NULL), dbprefix, dbprefix,
|
||||
"secmod.db", readOnly, nocertdb, PR_FALSE, PR_FALSE);
|
||||
"secmod.db", flags);
|
||||
if (rv != SECSuccess) {
|
||||
SECU_PrintPRandOSError(progName);
|
||||
retval=NSS_INITIALIZE_FAILED_ERR;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
* $Id: nss.h,v 1.8 2001-02-09 01:34:12 relyea%netscape.com Exp $
|
||||
* $Id: nss.h,v 1.9 2001-02-10 02:02:57 relyea%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#ifndef __nss_h_
|
||||
|
@ -55,6 +55,7 @@ SEC_BEGIN_PROTOS
|
|||
#define NSS_VPATCH 0
|
||||
#define NSS_BETA PR_FALSE
|
||||
|
||||
|
||||
/*
|
||||
* Return a boolean that indicates whether the underlying library
|
||||
* will perform as the caller expects.
|
||||
|
@ -93,12 +94,32 @@ extern SECStatus NSS_InitReadWrite(const char *configdir);
|
|||
* and an alternate name for the secmod database. NOTE: In future releases,
|
||||
* the database prefixes my not necessarily map to database names.
|
||||
*
|
||||
* configdir - base directory where all the cert, key, and module datbases live.
|
||||
* certPrefix - prefix added to the beginning of the cert database example: "
|
||||
* "https-server1-"
|
||||
* keyPrefix - prefix added to the beginning of the key database example: "
|
||||
* "https-server1-"
|
||||
* secmodName - name of the security module database (usually "secmod.db").
|
||||
* flags - change the open options of NSS_Initialize as follows:
|
||||
* NSS_INIT_READONLY - Open the databases read only.
|
||||
* NSS_INIT_NOCERTDB - Don't open the cert DB and key DB's, just
|
||||
* initialize the volatile certdb.
|
||||
* NSS_INIT_NOMODDB - Don't open the security module DB, just
|
||||
* initialize the PKCS #11 module.
|
||||
* NSS_INIT_FORCEOPEN - Continue to force initializations even if the
|
||||
* databases cannot be opened.
|
||||
*
|
||||
* Also NOTE: This is not the recommended method for initializing NSS.
|
||||
* The prefered method is NSS_init().
|
||||
*/
|
||||
#define NSS_INIT_READONLY 0x1
|
||||
#define NSS_INIT_NOCERTDB 0x2
|
||||
#define NSS_INIT_NOMODDB 0x4
|
||||
#define NSS_INIT_FORCEOPEN 0x8
|
||||
|
||||
extern SECStatus NSS_Initialize(const char *configdir,
|
||||
const char *certPrefix, const char *keyPrefix, const char *secmodName,
|
||||
PRBool readOnly, PRBool noCertDB, PRBool noModDB, PRBool forceOpen);
|
||||
const char *certPrefix, const char *keyPrefix,
|
||||
const char *secmodName, PRUint32 flags);
|
||||
|
||||
/*
|
||||
* initialize NSS without a creating cert db's, key db's, or secmod db's.
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
# $Id: nssinit.c,v 1.15 2001-02-09 01:34:12 relyea%netscape.com Exp $
|
||||
# $Id: nssinit.c,v 1.16 2001-02-10 02:02:57 relyea%netscape.com Exp $
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -301,13 +301,33 @@ NSS_InitReadWrite(const char *configdir)
|
|||
PR_FALSE, PR_FALSE, PR_FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* OK there are now lots of options here, lets go through them all:
|
||||
*
|
||||
* configdir - base directory where all the cert, key, and module datbases live.
|
||||
* certPrefix - prefix added to the beginning of the cert database example: "
|
||||
* "https-server1-"
|
||||
* keyPrefix - prefix added to the beginning of the key database example: "
|
||||
* "https-server1-"
|
||||
* secmodName - name of the security module database (usually "secmod.db").
|
||||
* flags - change the open options of NSS_Initialize as follows:
|
||||
* NSS_INIT_READONLY - Open the databases read only.
|
||||
* NSS_INIT_NOCERTDB - Don't open the cert DB and key DB's, just
|
||||
* initialize the volatile certdb.
|
||||
* NSS_INIT_NOMODDB - Don't open the security module DB, just
|
||||
* initialize the PKCS #11 module.
|
||||
* NSS_INIT_FORCEOPEN - Continue to force initializations even if the
|
||||
* databases cannot be opened.
|
||||
*/
|
||||
SECStatus
|
||||
NSS_Initialize(const char *configdir, const char *certPrefix,
|
||||
const char *keyPrefix, const char *secmodName,
|
||||
PRBool readOnly, PRBool noCertDB, PRBool noModDB, PRBool forceOpen)
|
||||
const char *keyPrefix, const char *secmodName, PRUint32 flags)
|
||||
{
|
||||
return nss_Init(configdir, certPrefix, keyPrefix, secmodName,
|
||||
readOnly, noCertDB, noModDB, forceOpen);
|
||||
((flags & NSS_INIT_READONLY) == NSS_INIT_READONLY),
|
||||
((flags & NSS_INIT_NOCERTDB) == NSS_INIT_NOCERTDB),
|
||||
((flags & NSS_INIT_NOMODDB) == NSS_INIT_NOMODDB),
|
||||
((flags & NSS_INIT_FORCEOPEN) == NSS_INIT_FORCEOPEN));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче