*/
nsMsgAccountManager::MigrateNewsAccounts(nsIMsgIdentity *identity, PRInt32 baseAccountNum){	PRInt32 numAccounts = 0;	nsresult rv;	// there should be one imap or one pop by this point.	// if there isn't, bail now?	//if (accountNum < 1) return 0;	nsFileSpec profileDir;		NS_WITH_SERVICE(nsIProfile, profile, kProfileCID, &rv);	if (NS_FAILED(rv)) return NS_ERROR_FAILURE;		rv = profile->GetCurrentProfileDir(&profileDir);	if (NS_FAILED(rv)) return NS_ERROR_FAILURE;	nsFileSpec newsDir(profileDir);	PRBool dirExists;		// turn profileDir into the News dir.	newsDir += "News";	if (!newsDir.Exists()) {		newsDir.CreateDir();	}#ifdef USE_NEWSRC_MAP_FILE		// use news.directory to find the fat file	// for each news server in the fat file call MigrateNewsAccount();		// use news.directory?	nsFileSpec fatFile(newsDir);	fatFile += NEWS_FAT_FILE_NAME;		char buffer[512];	char psuedo_name[512];	char filename[512];	char is_newsgroup[512];	PRBool ok;	nsInputFileStream inputStream(fatFile);		if (inputStream.eof()) {		inputStream.close();		return 0;	}	    /* we expect the first line to be NEWSRC_MAP_FILE_COOKIE */	ok = inputStream.readline(buffer, sizeof(buffer));	    if ((!ok) || (PL_strncmp(buffer, NEWSRC_MAP_FILE_COOKIE, PL_strlen(NEWSRC_MAP_FILE_COOKIE)))) {		inputStream.close();		return 0;	}   		while (!inputStream.eof()) {		char * p;		PRInt32 i;				ok = inputStream.readline(buffer, sizeof(buffer));		if (!ok) {			inputStream.close();			return 0;		}  				/* sspitzer todo:  replace this with nsString code */		/*		This used to be scanf() call which would incorrectly		parse long filenames with spaces in them.  - JRE		*/				filename[0] = '\0';		is_newsgroup[0]='\0';				for (i = 0, p = buffer; *p && *p != '\t' && i < 500; p++, i++)			psuedo_name[i] = *p;		psuedo_name[i] = '\0';		if (*p) 		{			for (i = 0, p++; *p && *p != '\t' && i < 500; p++, i++)				filename[i] = *p;			filename[i]='\0';			if (*p) 			{				for (i = 0, p++; *p && *p != '\r' && i < 500; p++, i++)					is_newsgroup[i] = *p;				is_newsgroup[i]='\0';			}		}				if(!PL_strncmp(is_newsgroup, "TRUE", 4)) {						printf("is_newsgroups_file = TRUE\n");		}		else {			printf("is_newsgroups_file = FALSE\n");						printf("psuedo_name=%s,filename=%s\n", psuedo_name, filename);			#ifdef NEWS_FAT_STORES_ABSOLUTE_NEWSRC_FILE_PATHS			// most likely, the fat file has been copied (or moved ) from			// its old location.  So the absolute file paths will be wrong.			// all we care about is the leaf, so use that.			nsFileSpec oldRcFile(filename);			char *leaf = oldRcFile.GetLeafName();			// use news.directory instead of newsDir?			nsFileSpec rcFile(newsDir);			rcFile += leaf;			nsCRT::free(leaf);			leaf = nsnull;#else		    // use news.directory instead of newsDir?			nsFileSpec rcFile(newsDir);			rcFile += filename;#endif /* NEWS_FAT_STORES_ABSOLUTE_NEWSRC_FILE_PATHS */			numAccounts++;							// psuedo-name is of the form newsrc-<host>.  need to get the host part out.			NS_ASSERTION(PL_strncmp(PSUEDO_NAME_PREFIX,psuedo_name,PL_strlen(PSUEDO_NAME_PREFIX)) == 0, "all psuedo names should begin with newsrc-");			if (PL_strncmp(PSUEDO_NAME_PREFIX,psuedo_name,PL_strlen(PSUEDO_NAME_PREFIX)) != 0) {				return 0;			}			NS_ASSERTION(PL_strlen(psuedo_name) > PL_strlen(PSUEDO_NAME_PREFIX), "psuedo_name is too short");			if (PL_strlen(psuedo_name) <= PL_strlen(PSUEDO_NAME_PREFIX)) {				return 0;			}			char *hostname = psuedo_name + PL_strlen(PSUEDO_NAME_PREFIX);			if (NS_FAILED(MigrateNewsAccount(identity, hostname, rcFile, baseAccountNum + numAccounts))) {				// failed to migrate.  bail out				return 0;			}		}	}		inputStream.close();#else	/*	get the $HOME directory	for each file of the form .newsrc-%, do this:	for (each file of the form .newsrc-%) {		numAccounts++;		if (NS_FAILED(MigrateNewsAccount(identity, psuedo_name, filename, baseAccountNum + numAccounts))) {			// failed to migrate.  bail out			return 0;		}	}/*	char *str = nsnull;		str = PR_smprintf(".newsrc-%s", newshostname);	if (!str) {		return NS_ERROR_OUT_OF_MEMORY;	}	newsrcFile = path;	newsrcFile.SetLeafName(str);	PR_FREEIF(str);	str = nsnull;	rv = NS_OK;	*/#endif /* USE_NEWSRC_MAP_FILE */	return numAccounts;}