if (NS_FAILED(rv) || pPref == nsnull)
if (NS_FAILED(rv) || !pPref)
void DIR_GetPrefsForOneServer (DIR_Server *server, PRBool reinitialize, PRBool oldstyle /* 4.0 Branch */){    nsresult rv = NS_OK;    NS_WITH_SERVICE(nsIPref, pPref, kPrefCID, &rv);     if (NS_FAILED(rv) || pPref == nsnull) 		return;	PRBool  prefBool;	char    *prefstring = server->prefName;	char     tempstring[256];	char    *csidString  = nsnull;	PRBool forcePrefSave = PR_FALSE;  /* if when reading in the prefs we did something that forces us to save the branch...*/	if (reinitialize)	{		/* If we're reinitializing, we need to save off the runtime volatile		 * data which isn't stored in persistent JS prefs and restore it		 */		PRUint32 oldRefCount = server->refCount;		server->prefName = nsnull;		dir_DeleteServerContents(server);		DIR_InitServer(server);		server->prefName = prefstring;		server->refCount = oldRefCount; 	}		PRBool bIsLocked;	pPref->PrefIsLocked(tempstring, &bIsLocked);	server->position = DIR_GetIntPref (prefstring, "position", tempstring, kDefaultPosition);	DIR_ForceFlag(server, DIR_UNDELETABLE | DIR_POSITION_LOCKED, bIsLocked);	server->isSecure = DIR_GetBoolPref (prefstring, "isSecure", tempstring, PR_FALSE);	server->saveResults = DIR_GetBoolPref (prefstring, "saveResults", tempstring, PR_TRUE);					server->efficientWildcards = DIR_GetBoolPref (prefstring, "efficientWildcards", tempstring, PR_TRUE);					server->port = DIR_GetIntPref (prefstring, "port", tempstring, server->isSecure ? LDAPS_PORT : LDAP_PORT);	if (server->port == 0)		server->port = server->isSecure ? LDAPS_PORT : LDAP_PORT;	server->maxHits = DIR_GetIntPref (prefstring, "maxHits", tempstring, kDefaultMaxHits);	server->description = DIR_GetStringPref (prefstring, "description", tempstring, "");	server->serverName = DIR_GetStringPref (prefstring, "serverName", tempstring, "");	server->searchBase = DIR_GetStringPref (prefstring, "searchBase", tempstring, "");	server->isOffline = DIR_GetBoolPref (prefstring, "isOffline", tempstring, kDefaultIsOffline);	server->dirType = (DirectoryType)DIR_GetIntPref (prefstring, "dirType", tempstring, LDAPDirectory);	if (server->dirType == PABDirectory)	{		/* make sure there is a PR_TRUE PAB */		if (PL_strlen (server->serverName) == 0)			server->isOffline = PR_FALSE;		server->saveResults = PR_TRUE; /* never let someone delete their PAB this way */	}	/* load in the column attributes */	if (server->dirType == PABDirectory)		server->columnAttributes = DIR_GetStringPref(prefstring, "columns", tempstring, kDefaultPABColumnHeaders);	else		server->columnAttributes = DIR_GetStringPref(prefstring, "columns", tempstring, kDefaultLDAPColumnHeaders);	server->fileName = DIR_GetStringPref (prefstring, "filename", tempstring, "");	if ( (!server->fileName || !*(server->fileName)) && !oldstyle) /* if we don't have a file name and this is the new branch get a file name */			DIR_SetServerFileName (server, server->serverName);	if (server->fileName && *server->fileName)		DIR_ConvertServerFileName(server);	server->lastSearchString = DIR_GetStringPref (prefstring, "searchString", tempstring, "");	/* This is where site-configurable attributes and filters are read from JavaScript */	DIR_GetCustomAttributePrefs (prefstring, server, tempstring);	DIR_GetCustomFilterPrefs (prefstring, server, tempstring);	/* The replicated attributes and basic search attributes can only be	 * attributes which are in our predefined set (DIR_AttributeId) so	 * store those in an array of IDs for more convenient access	 */	dir_GetReplicationInfo (prefstring, server, tempstring);	/* Get authentication prefs */	server->enableAuth = DIR_GetBoolPref (prefstring, "auth.enabled", tempstring, kDefaultEnableAuth);	server->authDn = DIR_GetStringPref (prefstring, "auth.dn", tempstring, nsnull);	server->savePassword = DIR_GetBoolPref (prefstring, "auth.savePassword", tempstring, kDefaultSavePassword);	if (server->savePassword)		server->password = DIR_GetStringPref (prefstring, "auth.password", tempstring, "");	prefBool = DIR_GetBoolPref (prefstring, "autoComplete.enabled", tempstring, kDefaultAutoCompleteEnabled);	DIR_ForceFlag (server, DIR_AUTO_COMPLETE_ENABLED, prefBool);	prefBool = DIR_GetBoolPref (prefstring, "autoComplete.never", tempstring, kDefaultAutoCompleteNever);	DIR_ForceFlag (server, DIR_AUTO_COMPLETE_NEVER, prefBool);	server->autoCompleteFilter = DIR_GetStringPref (prefstring, "autoComplete.filter", tempstring, nsnull);	/* read in the I18N preferences for the directory --> locale and csid */	/* okay we used to write out the csid as a integer pref called "charset" then we switched to a string pref called "csid" 	   for I18n folks. So we want to read in the old integer pref and if it is not kDefaultPABCSID (which is a bogus -1), 	   then use it as the csid and when we save the server preferences later on we'll clear the old "charset" pref so we don't	   have to do this again. Otherwise, we already have a string pref so use that one */	csidString = DIR_GetStringPref (prefstring, "csid", tempstring, nsnull);	if (csidString) /* do we have a csid string ? */	{		server->csid = CS_UTF8;//		server->csid = INTL_CharSetNameToID (csidString);		PR_Free(csidString);	}	else 	{ 		/* try to read it in from the old integer style char set preference */		if (server->dirType == PABDirectory)			server->csid = (PRInt16) DIR_GetIntPref (prefstring, "charset", tempstring, kDefaultPABCSID);		else			server->csid = (PRInt16) DIR_GetIntPref (prefstring, "charset", tempstring, kDefaultLDAPCSID);			forcePrefSave = PR_TRUE; /* since we read from the old pref we want to force the new pref to be written out */	}	if (server->csid == CS_DEFAULT || server->csid == CS_UNKNOWN)		server->csid = CS_UTF8;//		server->csid = INTL_GetCharSetID(INTL_DefaultTextWidgetCsidSel);	/* now that the csid is taken care of, read in the locale preference */	server->locale = DIR_GetStringPref (prefstring, "locale", tempstring, nsnull);		prefBool = DIR_GetBoolPref (prefstring, "vlvDisabled", tempstring, kDefaultVLVDisabled);	DIR_ForceFlag (server, DIR_LDAP_VLV_DISABLED | DIR_LDAP_ROOTDSE_PARSED, prefBool);	server->customDisplayUrl = DIR_GetStringPref (prefstring, "customDisplayUrl", tempstring, "");	if (!oldstyle /* we don't care about saving old directories */ && forcePrefSave && !dir_IsServerDeleted(server) )		DIR_SavePrefsForOneServer(server); }