PR_Unlock(vr_lock); #if defined(XP_UNIX) && !defined(STANDALONE_REGISTRY)
static REGERR vr_Init(void){    REGERR  err = REGERR_OK;    char    *regname = "";#if defined(XP_UNIX) || defined(STANDALONE_REGISTRY)    char    curstr[MAXREGNAMELEN];    RKEY    navKey;#endif#ifdef XP_UNIX    char    *regbuf = NULL;#endif#ifndef STANDALONE_REGISTRY	if (vr_monitor == NULL)		return REGERR_FAIL;    PR_EnterMonitor(vr_monitor);#endif    if (!isInited)    {#ifdef XP_UNIX        /* need browser directory to find the correct registry */        if (app_dir != NULL) {            regbuf = (char*)XP_ALLOC( 10 + XP_STRLEN(app_dir) );            if (regbuf != NULL ) {                XP_STRCPY( regbuf, app_dir );                XP_STRCAT( regbuf, "registry" );            }             else {                err = REGERR_MEMORY;            }        }         else {            err = REGERR_PARAM;        }        if ( err != REGERR_OK )            goto done;        if (bGlobalRegistry)             regname = regbuf;#endif        /* Open version registry */    	err = NR_RegOpen( regname, &vreg );#ifndef STANDALONE_REGISTRY        if (err == REGERR_NOFILE) {            /* create it if not found */            err = VR_CreateRegistry( VERSION_NAME, app_dir, "" );        }        else if (err == REGERR_OK) {            /* otherwise find/set the current nav node */            err = vr_SetCurrentNav( VERSION_NAME, app_dir, NULL );            if ( REGERR_OK != err ) {                /* couldn't find or set current nav -- big problems! */                NR_RegClose( vreg );                goto done;            }        }#ifdef XP_UNIX        /* try to open shared Unix registry, but not an error if you can't */        unixreg = NULL;        if (!bGlobalRegistry && err == REGERR_OK ) {            unixver = 0;            if (NR_RegOpen( regbuf, &unixreg ) == REGERR_OK) {                if (NR_RegGetKey( unixreg, ROOTKEY_VERSIONS, NAVIGATOR_NODE,                     &navKey) == REGERR_OK)                 {                    if (NR_RegGetEntryString( unixreg, navKey, CURRENT_VER,                        curstr, sizeof(curstr)) == REGERR_OK )                     {                        NR_RegGetKey( unixreg, navKey, curstr, &unixver );                    }                }            }        }#endif    	if (err == REGERR_OK) {            /* successfully opened! */            isInited = 1;        }        goto done;#else    	if (err != REGERR_OK)		    goto done;    	/* Determine 'curver' key and ensure correct structure by adding */        /* ...find top-level "Navigator" node (add if missing) */    	err = NR_RegAddKey( vreg, ROOTKEY_VERSIONS, NAVIGATOR_NODE, &navKey );    	if (err != REGERR_OK)            goto done;        /* ...look for "Current Version" entry */        err = NR_RegGetEntryString( vreg, navKey, CURRENT_VER, curstr,                                    sizeof(curstr) );        if ( err == REGERR_NOFIND ) {            /* If not found create one with the built-in version */            err = NR_RegSetEntryString( vreg, navKey, CURRENT_VER, VERSION_NAME );            XP_STRCPY( curstr, VERSION_NAME );        }        if ( err != REGERR_OK )            goto done;        /* ...look for "curstr" child key of the navigator node */        err = NR_RegAddKey( vreg, navKey, curstr, &curver );    	if (err == REGERR_OK) {            /* successfully opened! */            isInited = 1;        }#endif    }done:#ifndef STANDALONE_REGISTRY    PR_ExitMonitor(vr_monitor);#ifdef XP_UNIX    XP_FREEIF(regbuf);#endif#endif    return err;}	/* Init */