nsresult result = NS_OK; nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &result)); if (NS_FAILED(result) || !pPref) return NS_ERROR_FAILURE;  char *children;  (*list) = new nsVoidArray(); if (!(*list)) return NS_ERROR_OUT_OF_MEMORY;  if (obsoleteList) { (*obsoleteList) = new nsVoidArray(); if (!(*obsoleteList)) return NS_ERROR_OUT_OF_MEMORY; }  if (pPref->CreateChildList(PREF_LDAP_SERVER_TREE_NAME, &children) == PREF_NOERROR) {  if (dir_UserId == 0) pPref->GetIntPref(PREF_LDAP_GLOBAL_TREE_NAME".user_id", &dir_UserId);  PRInt16 i = 0; char *child;  while ((pPref->NextChild(children, &i, &child)) == NS_OK) { DIR_Server *server;  server = (DIR_Server *)PR_Calloc(1, sizeof(DIR_Server)); if (server) { DIR_InitServer(server); server->prefName = nsCRT::strdup(child); DIR_GetPrefsForOneServer(server, PR_FALSE, PR_FALSE); if (   server->description && server->description[0] && (   (server->dirType == PABDirectory || server->dirType == MAPIDirectory || server->dirType == FixedQueryLDAPDirectory)  || (server->serverName  && server->serverName[0]))) { if (!dir_IsServerDeleted(server)) { (*list)->AppendElement(server); } else if (obsoleteList) (*obsoleteList)->AppendElement(server); } else { DIR_DeleteServer(server); } } }  PR_Free(children); }  return result;
nsresult result = NS_OK; nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &result)); if (NS_FAILED(result) || !pPref) return NS_ERROR_FAILURE;  char *children;  (*list) = new nsVoidArray(); if (!(*list)) return NS_ERROR_OUT_OF_MEMORY;  if (obsoleteList) { (*obsoleteList) = new nsVoidArray(); if (!(*obsoleteList)) return NS_ERROR_OUT_OF_MEMORY; }  if (pPref->CreateChildList(PREF_LDAP_SERVER_TREE_NAME, &children) == PREF_NOERROR) {  if (dir_UserId == 0) pPref->GetIntPref(PREF_LDAP_GLOBAL_TREE_NAME".user_id", &dir_UserId);  PRInt16 i = 0; char *child;  while ((pPref->NextChild(children, &i, &child)) == NS_OK) { DIR_Server *server;  server = (DIR_Server *)PR_Calloc(1, sizeof(DIR_Server)); if (server) { DIR_InitServer(server); server->prefName = nsCRT::strdup(child); DIR_GetPrefsForOneServer(server, PR_FALSE, PR_FALSE); if (   server->description && server->description[0] && (   (server->dirType == PABDirectory || server->dirType == MAPIDirectory || server->dirType == FixedQueryLDAPDirectory)  || (server->serverName  && server->serverName[0]))) { if (!dir_IsServerDeleted(server)) { (*list)->AppendElement(server); } else if (obsoleteList) (*obsoleteList)->AppendElement(server); else DIR_DeleteServer(server); } else { DIR_DeleteServer(server); } } }  PR_Free(children); }  return result;
static nsresult dir_GetPrefsFrom45Branch(nsVoidArray **list, nsVoidArray **obsoleteList){    nsresult result = NS_OK;    nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &result));     if (NS_FAILED(result) || !pPref) 		return NS_ERROR_FAILURE; 	char *children;	(*list) = new nsVoidArray();	if (!(*list))		return NS_ERROR_OUT_OF_MEMORY;	if (obsoleteList)	{		(*obsoleteList) = new nsVoidArray();		if (!(*obsoleteList))			return NS_ERROR_OUT_OF_MEMORY;	}	if (pPref->CreateChildList(PREF_LDAP_SERVER_TREE_NAME, &children) == PREF_NOERROR)	{			/* TBD: Temporary code to read broken "ldap" preferences tree.		 *      Remove line with if statement after M10.		 */		if (dir_UserId == 0)			pPref->GetIntPref(PREF_LDAP_GLOBAL_TREE_NAME".user_id", &dir_UserId);		PRInt16 i = 0;		char *child;		while ((pPref->NextChild(children, &i, &child)) == NS_OK)		{			DIR_Server *server;			server = (DIR_Server *)PR_Calloc(1, sizeof(DIR_Server));			if (server)			{				DIR_InitServer(server);                server->prefName = nsCRT::strdup(child);				DIR_GetPrefsForOneServer(server, PR_FALSE, PR_FALSE);				if (   server->description && server->description[0]                    && (   (server->dirType == PABDirectory ||                         server->dirType == MAPIDirectory ||                        server->dirType == FixedQueryLDAPDirectory)                          					    || (server->serverName  && server->serverName[0])))				{					if (!dir_IsServerDeleted(server))					{						(*list)->AppendElement(server);					}					else if (obsoleteList)						(*obsoleteList)->AppendElement(server);				}				else				{					DIR_DeleteServer(server);				}			}		}		PR_Free(children);	}	return result;}