nsresult rv = AddBookmark(aContainer, cURL, name, addDate,
nsresult rv = AddBookmark(aContainer, cURL, name.GetUnicode(), addDate,
BookmarkParser::ParseBookmark(const nsString& aLine, nsIRDFResource* aContainer, nsIRDFResource *nodeType){    NS_PRECONDITION(aContainer != nsnull, "null ptr");    if (! aContainer)        return NS_ERROR_NULL_POINTER;    PRInt32 start = aLine.Find(kHREFEquals);    NS_ASSERTION(start >= 0, "no 'HREF=\"' string: how'd we get here?");    if (start < 0)        return NS_ERROR_UNEXPECTED;    // 1. Crop out the URL    // Skip past the first double-quote    start += (sizeof(kHREFEquals) - 1);    // ...and find the next so we can chop the URL.    PRInt32 end = aLine.Find(PRUnichar('"'), start);    NS_ASSERTION(end >= 0, "unterminated string");    if (end < 0)        return NS_ERROR_UNEXPECTED;    nsAutoString url;    aLine.Mid(url, start, end - start);    {        // Now do properly replace %22's (this is what 4.5 did, anyway...)        static const char kEscape22[] = "%22";        PRInt32 offset;        while ((offset = url.Find(kEscape22)) >= 0) {            url.SetCharAt(' ',offset);            url.Cut(offset + 1, sizeof(kEscape22) - 2);        }    }    // XXX At this point, the URL may be relative. 4.5 called into    // netlib to make an absolute URL, and there was some magic    // "relative_URL" parameter that got sent down as well. We punt on    // that stuff.    // 2. Parse the name    start = aLine.Find(PRUnichar('>'), end + 1); // 'end' still points to the end of the URL    NS_ASSERTION(start >= 0, "open anchor tag not terminated");    if (start < 0)        return NS_ERROR_UNEXPECTED;    nsAutoString name;    aLine.Right(name, aLine.Length() - (start + 1));    end = name.Find(kCloseAnchor);    NS_ASSERTION(end >= 0, "anchor tag not terminated");    if (end < 0)        return NS_ERROR_UNEXPECTED;    name.Truncate(end);    // 3. Parse the target    nsAutoString target;    start = aLine.Find(kTargetEquals);    if (start >= 0) {        start += (sizeof(kTargetEquals) - 1);        end = aLine.Find(PRUnichar('"'), start);        aLine.Mid(target, start, end - start);    }    // 4. Parse the addition date    PRInt32 addDate = 0;    {        nsAutoString s;        ParseAttribute(aLine, kAddDateEquals, sizeof(kAddDateEquals) - 1, s);        if (s.Length() > 0) {            PRInt32 err;            addDate = s.ToInteger(&err); // ignored.        }    }    // 5. Parse the last visit date    PRInt32 lastVisitDate = 0;    {        nsAutoString s;        ParseAttribute(aLine, kLastVisitEquals, sizeof(kLastVisitEquals) - 1, s);        if (s.Length() > 0) {            PRInt32 err;            lastVisitDate = s.ToInteger(&err); // ignored.        }    }    // 6. Parse the last modified date    PRInt32 lastModifiedDate;    {        nsAutoString s;        ParseAttribute(aLine, kLastModifiedEquals, sizeof(kLastModifiedEquals) - 1, s);        if (s.Length() > 0) {            PRInt32 err;            lastModifiedDate = s.ToInteger(&err); // ignored.        }    }    // 7. Parse the shortcut URL    nsAutoString	shortcut("");    ParseAttribute(aLine, kShortcutURLEquals, sizeof(kShortcutURLEquals) -1, shortcut);    // Dunno. 4.5 did it, so will we.    if (!lastModifiedDate)        lastModifiedDate = lastVisitDate;    // XXX There was some other cruft here to deal with aliases, but    // since I have no clue what those are, I'll punt.	char *cURL = url.ToNewCString();	if (cURL)	{		char *cShortcutURL = shortcut.ToNewCString();		nsresult rv = AddBookmark(aContainer, cURL, name, addDate,			lastVisitDate, lastModifiedDate, cShortcutURL, nodeType);		delete [] cURL;		if (cShortcutURL)	delete [] cShortcutURL;	}	return(NS_OK);}