Just updating a test harness... THIS IS NOT PART OF ANY BUILD!

This commit is contained in:
rhp%netscape.com 2000-03-02 06:14:01 +00:00
parent fb8782b61f
commit c8143e7e8c

View File

@ -269,35 +269,42 @@ NS_IMETHODIMP ConsoleOutputStreamListener::OnDataAvailable(nsIChannel * aChannel
return NS_OK; return NS_OK;
} }
PRBool mDoIndentProcessing = PR_FALSE;
for (i=0; i<aCount; i++) for (i=0; i<aCount; i++)
{ {
// First, check if we are in a new level of html... if (mDoIndentProcessing)
if (aBuf[i] == '<')
{ {
if ( (i < aCount) && (aBuf[i+1] == '/') ) // First, check if we are in a new level of html...
if (aBuf[i] == '<')
{ {
--mIndentCount; if ( (i < aCount) && (aBuf[i+1] == '/') )
mInClosingTag = PR_TRUE; {
} --mIndentCount;
else mInClosingTag = PR_TRUE;
{ }
++mIndentCount; else
DoIndent(); {
mInClosingTag = PR_FALSE; ++mIndentCount;
} DoIndent();
mInClosingTag = PR_FALSE;
}
if (mIndentCount < 0) if (mIndentCount < 0)
mIndentCount = 0; mIndentCount = 0;
}
} }
// Now, write the HTML character... // Now, write the HTML character...
PR_Write(PR_GetSpecialFD(PR_StandardOutput), aBuf+i, 1); PR_Write(PR_GetSpecialFD(PR_StandardOutput), aBuf+i, 1);
if (aBuf[i] == '>') if (mDoIndentProcessing)
{ {
// Now, write out the correct number or spaces for the indent count... if (aBuf[i] == '>')
if (mInClosingTag) {
DoIndent(); // Now, write out the correct number or spaces for the indent count...
if (mInClosingTag)
DoIndent();
}
} }
} }
@ -457,13 +464,13 @@ int
main(int argc, char** argv) main(int argc, char** argv)
{ {
nsresult DoFormattingOnly(char *filename); nsresult DoFormattingOnly(char *filename);
nsresult DoRFC822toHTMLConversion(char *filename, int numArgs); nsresult DoRFC822toHTMLConversion(char *filename, int numArgs, int format);
nsresult rv; nsresult rv;
// Do some sanity checking... // Do some sanity checking...
if (argc < 2) if (argc < 2)
{ {
fprintf(stderr, "usage: %s <rfc822_disk_file> <any_arg_for_XUL_output - 19 for simple processing>\n", argv[0]); fprintf(stderr, "usage: %s <rfc822_disk_file> <output_format>\n\nwhere output_format is:\n\n19 - indentation formatting\n1 - nsMimeMessageBodyDisplay\n", argv[0]);
return 1; return 1;
} }
@ -483,8 +490,15 @@ main(int argc, char** argv)
// Do the conversion or just process the file! // Do the conversion or just process the file!
if ( (argc >= 3) && (atoi(argv[2]) == 19) ) if ( (argc >= 3) && (atoi(argv[2]) == 19) )
DoFormattingOnly(argv[1]); DoFormattingOnly(argv[1]);
else else
DoRFC822toHTMLConversion(argv[1], argc); {
int format;
if (argc >= 3)
format = atoi(argv[2]);
else
format = nsMimeOutput::nsMimeMessagePrintOutput;
DoRFC822toHTMLConversion(argv[1], argc, format);
}
// Cleanup stuff necessary... // Cleanup stuff necessary...
NS_IF_RELEASE(ccMan); NS_IF_RELEASE(ccMan);
@ -492,18 +506,17 @@ main(int argc, char** argv)
} }
nsresult nsresult
DoRFC822toHTMLConversion(char *filename, int numArgs) DoRFC822toHTMLConversion(char *filename, int numArgs, int outFormat)
{ {
nsresult rv; nsresult rv;
char newURL[1024] = ""; // URL for filename char newURL[1024] = ""; // URL for filename
nsIURI *theURI = nsnull; nsIURI *theURI = nsnull;
nsMimeOutputType outFormat;
char *contentType = nsnull; char *contentType = nsnull;
if (numArgs >= 3) if (outFormat == 1)
outFormat = nsMimeOutput::nsMimeMessageXULDisplay;
else
outFormat = nsMimeOutput::nsMimeMessagePrintOutput; outFormat = nsMimeOutput::nsMimeMessagePrintOutput;
else if (outFormat == 2)
outFormat = nsMimeOutput::nsMimeMessageBodyDisplay;
char *opts = PL_strchr(filename, '?'); char *opts = PL_strchr(filename, '?');
char save; char save;
@ -623,8 +636,8 @@ DoFormattingOnly(char *filename)
{ {
char newURL[1024] = ""; // URL for filename char newURL[1024] = ""; // URL for filename
nsIURI *theURI = nsnull; nsIURI *theURI = nsnull;
nsMimeOutputType outFormat;
char *contentType = nsnull; char *contentType = nsnull;
int outFormat;
outFormat = nsMimeOutput::nsMimeMessagePrintOutput; outFormat = nsMimeOutput::nsMimeMessagePrintOutput;