CRLGEN_DestroyCrlGenParserLock();
int main(int argc, char **argv){    SECItem privKeyDER;    CERTCertDBHandle *certHandle;    FILE *certFile;    PRFileDesc *inFile;    int listCRL;    int importCRL;    int deleteCRL;    int rv;    char *nickName;    char *url;    char *dbPrefix = "";    int crlType;    PLOptState *optstate;    PLOptStatus status;    SECStatus secstatus;    PRInt32 decodeOptions = CRL_DECODE_DEFAULT_OPTIONS;    PRInt32 importOptions = CRL_IMPORT_DEFAULT_OPTIONS;    PRBool test = PR_FALSE;    PRBool erase = PR_FALSE;    PRInt32 i = 0;    PRInt32 iterations = 1;    progName = strrchr(argv[0], '/');    progName = progName ? progName+1 : argv[0];    rv = 0;    deleteCRL = importCRL = listCRL = 0;    certFile = NULL;    inFile = NULL;    nickName = url = NULL;    privKeyDER.data = NULL;    certHandle = NULL;    crlType = SEC_CRL_TYPE;    /*     * Parse command line arguments     */    optstate = PL_CreateOptState(argc, argv, "BCDILP:d:i:n:pt:u:TEr:");    while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {	switch (optstate->option) {	  case '?':	    Usage(progName);	    break;          case 'T':            test = PR_TRUE;            break;          case 'E':            erase = PR_TRUE;            break;	  case 'B':            importOptions |= CRL_IMPORT_BYPASS_CHECKS;            break;	  case 'C':	      listCRL = 1;	      break;	  case 'D':	      deleteCRL = 1;	      break;	  case 'I':	      importCRL = 1;	      break;	           	  case 'L':	      listCRL = 1;	      break;	  case 'P':	    dbPrefix = strdup(optstate->value);	    break;	           	  case 'd':	    SECU_ConfigDirectory(optstate->value);	    break;	  case 'i':	    inFile = PR_Open(optstate->value, PR_RDONLY, 0);	    if (!inFile) {		fprintf(stderr, "%s: unable to open \"%s\" for reading\n",			progName, optstate->value);		PL_DestroyOptState(optstate);		return -1;	    }	    break;	    	  case 'n':	    nickName = strdup(optstate->value);	    break;	  case 'p':	    decodeOptions |= CRL_DECODE_SKIP_ENTRIES;	    break;	  case 'r': {	    const char* str = optstate->value;	    if (str && atoi(str)>0)		iterations = atoi(str);	    }	    break;	    	  case 't': {	    char *type;	    	    type = strdup(optstate->value);	    crlType = atoi (type);	    if (crlType != SEC_CRL_TYPE && crlType != SEC_KRL_TYPE) {		fprintf(stderr, "%s: invalid crl type\n", progName);		PL_DestroyOptState(optstate);		return -1;	    }	    break;	  case 'u':	    url = strdup(optstate->value);	    break;          }	}    }    PL_DestroyOptState(optstate);    if (deleteCRL && !nickName) Usage (progName);    if (!(listCRL || deleteCRL || importCRL || test || erase)) Usage (progName);    if (importCRL && !inFile) Usage (progName);        PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);    secstatus = NSS_Initialize(SECU_ConfigDirectory(NULL), dbPrefix, dbPrefix,			       "secmod.db", 0);    if (secstatus != SECSuccess) {	SECU_PrintPRandOSError(progName);	return -1;    }    SECU_RegisterDynamicOids();    certHandle = CERT_GetDefaultCertDB();    if (certHandle == NULL) {	SECU_PrintError(progName, "unable to open the cert db");	    		/*ignoring return value of NSS_Shutdown() as code returns -1*/	(void) NSS_Shutdown();	return (-1);    }    for (i=0; i<iterations; i++) {	/* Read in the private key info */	if (deleteCRL) 	    DeleteCRL (certHandle, nickName, crlType);	else if (listCRL) {	    ListCRL (certHandle, nickName, crlType);	}	else if (importCRL) {	    rv = ImportCRL (certHandle, url, crlType, inFile, importOptions,			    decodeOptions);	}	else if (erase) {	    /* list and delete all CRLs */	    ListCRLNames (certHandle, crlType, PR_TRUE);	}#ifdef DEBUG	else if (test) {	    /* list and delete all CRLs */	    ListCRLNames (certHandle, crlType, PR_TRUE);	    /* list CRLs */	    ListCRLNames (certHandle, crlType, PR_FALSE);	    /* import CRL as a blob */	    rv = ImportCRL (certHandle, url, crlType, inFile, importOptions,			    decodeOptions);	    /* list CRLs */	    ListCRLNames (certHandle, crlType, PR_FALSE);	}#endif        }    if (NSS_Shutdown() != SECSuccess) {        rv = SECFailure;    }    return (rv != SECSuccess);}