PL_strfree(localPath); }
nsGetNewsRoot(const char *hostname, nsFileSpec &result){  nsresult rv = NS_OK;  // retrieve the AccountManager  NS_WITH_SERVICE(nsIMsgMailSession, session, kMsgMailSessionCID, &rv);  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIMsgAccountManager> accountManager;  rv = session->GetAccountManager(getter_AddRefs(accountManager));  if (NS_FAILED(rv)) return rv;                      // find all news hosts matching the given hostname  nsCOMPtr<nsISupportsArray> hosts;  rv = accountManager->FindServersByHostname(hostname,                                            nsINntpIncomingServer::GetIID(),                                            getter_AddRefs(hosts));  if (NS_FAILED(rv)) return rv;   // use enumeration function to find the first nntp server  nsISupports *serverSupports = hosts->ElementAt(0);#ifdef DEBUG_NEWS  if (hosts->Count() <= 0)    fprintf(stderr, "Augh, no nntp server named %s?\n", hostname);  if (!serverSupports)    fprintf(stderr, "Huh, serverSupports returned nsnull\n");#endif  // if there are no nntp servers, how did we get here?  if (! serverSupports) return NS_ERROR_UNEXPECTED;  nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(serverSupports);  // this had better be a nsIMsgIncomingServer, otherwise  // FindServersByHostname is broken or we got some weird object back  PR_ASSERT(server);  // now ask the server what it's root is  char *localPath;  rv = server->GetLocalPath(&localPath);  if (NS_SUCCEEDED(rv))     result = localPath;  return rv;}