NSS_Shutdown();
if (NSS_Shutdown() != SECSuccess) { exit(1); }
main(int argc, char **argv){    PRFileDesc     *infile        = NULL;    PRFileDesc     *outfile       = NULL;    char           *profiledir       = "./";#if 0    secuPWData      pwdata        = { PW_NONE, 0 };#endif    int             objclass      = 3; /* ANY */    NSSTrustDomain *root_cert_td  = NULL;    char           *rootpath      = NULL;    char            builtin_name[]= "libnssckbi.so"; /* temporary hardcode */    PRStatus        rv            = PR_SUCCESS;    int cmdToRun;    cmdCommand pkiutil;    pkiutil.ncmd = pkiutil_num_commands;    pkiutil.nopt = pkiutil_num_options;    pkiutil.cmd = pkiutil_commands;    pkiutil.opt = pkiutil_options;    progName = strrchr(argv[0], '/');    progName = progName ? progName+1 : argv[0];    cmdToRun = CMD_ParseCommandLine(argc, argv, progName, &pkiutil);#if 0    { int i, nc;    for (i=0; i<pkiutil.ncmd; i++)	printf("%s: %s <%s>\n", pkiutil.cmd[i].s, 	                        (pkiutil.cmd[i].on) ? "on" : "off",				pkiutil.cmd[i].arg);    for (i=0; i<pkiutil.nopt; i++)	printf("%s: %s <%s>\n", pkiutil.opt[i].s, 	                        (pkiutil.opt[i].on) ? "on" : "off",				pkiutil.opt[i].arg);    }#endif    if (pkiutil.opt[opt_Help].on)	CMD_LongUsage(progName, &pkiutil, pkiutil_usage);    if (cmdToRun < 0)	CMD_Usage(progName, &pkiutil);    /* -d */    if (pkiutil.opt[opt_ProfileDir].on) {	profiledir = strdup(pkiutil.opt[opt_ProfileDir].arg);    }    /* -i */    if (pkiutil.opt[opt_InputFile].on) {	char *fn = pkiutil.opt[opt_InputFile].arg;	infile = PR_Open(fn, PR_RDONLY, 0660);    } else {	infile = PR_STDIN;    }    /* -o */    if (pkiutil.opt[opt_OutputFile].on) {	char *fn = pkiutil.opt[opt_OutputFile].arg;	outfile = PR_Open(fn, PR_WRONLY | PR_CREATE_FILE, 0660);    } else {	outfile = PR_STDOUT;    }    /* --type can be found on many options */    if (pkiutil.opt[opt_Type].on)	objclass = get_object_class(pkiutil.opt[opt_Type].arg);    else if (cmdToRun == cmd_Dump && pkiutil.cmd[cmd_Dump].arg)	objclass = get_object_class(pkiutil.cmd[cmd_Dump].arg);    else if (cmdToRun == cmd_List && pkiutil.cmd[cmd_List].arg)	objclass = get_object_class(pkiutil.cmd[cmd_List].arg);    else if (cmdToRun == cmd_Add && pkiutil.cmd[cmd_Add].arg)	objclass = get_object_class(pkiutil.cmd[cmd_Add].arg);    if (objclass < 0)	goto done;    /* --print is an alias for --list --nickname */    if (cmdToRun == cmd_Dump) cmdToRun = cmd_List;    /* if list has raw | ascii must have -n.  can't have both raw and ascii */    if (pkiutil.opt[opt_Binary].on || pkiutil.opt[opt_Ascii].on) {	if (cmdToRun == cmd_List && !pkiutil.opt[opt_Nickname].on) {	    fprintf(stderr, "%s: specify a object to output with -n\n", 	                     progName);	    CMD_LongUsage(progName, &pkiutil, pkiutil_usage);	}    }    /* initialize */    PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1);    /* NSS_InitReadWrite(profiledir); */    NSS_NoDB_Init(NULL);    /* Display version info and exit */    if (cmdToRun == cmd_Version) {	printf("%s\nNSS Version %s\n", PKIUTIL_VERSION_STRING, NSS_VERSION);	goto done;    }    /* XXX okay - bootstrap stan by loading the root cert module for testing */    root_cert_td = NSSTrustDomain_Create(NULL, NULL, NULL, NULL);    {	int rootpathlen = strlen(profiledir) + strlen(builtin_name) + 1;	rootpath = (char *)malloc(rootpathlen);	memcpy(rootpath, profiledir, strlen(profiledir));	memcpy(rootpath + strlen(profiledir),                builtin_name, strlen(builtin_name));	rootpath[rootpathlen - 1] = '\0';    }    NSSTrustDomain_LoadModule(root_cert_td, "Builtin Root Module", rootpath,                               NULL, NULL);    printf("\n");    if (pkiutil.opt[opt_Nickname].on) {	int i;	NSSCertificate **certs;	NSSCertificate *cert;	certs = NSSTrustDomain_FindCertificatesByNickname(root_cert_td,			pkiutil.opt[opt_Nickname].arg, NULL, 0, NULL);	i = 0;	while ((cert = certs[i++]) != NULL) {	    printf("Found cert:\n");	    print_cert_callback(cert, NULL);	}    } else {        NSSTrustDomain_TraverseCertificates(root_cert_td, print_cert_callback, 0);    }    NSSTrustDomain_Destroy(root_cert_td);    /* List token objects */    if (cmdToRun == cmd_List)  {#if 0	rv = list_token_objects(slot, objclass, 	                        pkiutil.opt[opt_Nickname].arg,	                        pkiutil.opt[opt_Binary].on,	                        pkiutil.opt[opt_Ascii].on,	                        outfile, &pwdata);#endif	goto done;    }#if 0    /* Import an object into the token. */    if (cmdToRun == cmd_Add) {	rv = add_object_to_token(slot, object);	goto done;    }#endifdone:    NSS_Shutdown();    return rv;}