printf("Couldn't create new content sink: 0x%x\n", rv);
printf("Couldn't create new HTML DTD: 0x%x\n", rv);
nsresult HTML2text(int toHTML){  nsresult rv = NS_OK;  nsString inString;  nsString outString;  // Read in the string from the file: very inefficient, but who cares?  char c;  while ((c = getchar()) != EOF)    inString += c;#if 0  printf("Input string is: %s\n-------------------- \n",         inString.ToNewCString());  printf("------------------------------------\n");#endif  // Create a parser  nsIParser* parser;   rv = nsComponentManager::CreateInstance(kParserCID, nsnull,                                           kIParserIID,(void**)&parser);  if (NS_FAILED(rv))  {    printf("Unable to create a parser : 0x%x\n", rv);    return NS_ERROR_FAILURE;  }  nsIHTMLContentSink* sink = nsnull;  // Create the appropriate output sink  if (toHTML)    rv = NS_New_HTML_ContentSinkStream(&sink, &outString, 0);  else  // default to plaintext    rv = NS_New_HTMLToTXT_SinkStream(&sink, &outString, 72, 0);  if (NS_FAILED(rv))  {    printf("Couldn't create new content sink: 0x%x\n", rv);    return rv;  }  parser->SetContentSink(sink);  nsIDTD* dtd = nsnull;  rv = NS_NewNavHTMLDTD(&dtd);  if (NS_FAILED(rv))  {    printf("Couldn't create new content sink: 0x%x\n", rv);    return rv;  }  parser->RegisterDTD(dtd);  parser->Parse(inString, 0, "text/html", PR_FALSE, PR_TRUE);  printf("Output string is: %s\n-------------------- \n",         outString.ToNewCString());  NS_IF_RELEASE(dtd);  NS_IF_RELEASE(sink);  NS_RELEASE(parser);  return rv;}