diff --git a/source/utils/debug2html.c b/source/utils/debug2html.c index 1349da5b284..c7f36da0c05 100644 --- a/source/utils/debug2html.c +++ b/source/utils/debug2html.c @@ -28,13 +28,20 @@ * does a decent job of converting Samba logs into HTML. * -------------------------------------------------------------------------- ** * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * * ========================================================================== ** */ #include "includes.h" +/* -------------------------------------------------------------------------- ** + * Global values. + */ + +FILE *infile = stdin; +FILE *outfile = stdout; + /* -------------------------------------------------------------------------- ** * The size of the read buffer. */ @@ -74,7 +81,7 @@ static dbg_Token modechange( dbg_Token new, dbg_Token mode ) if( dbg_message != mode ) { /* Switching to message mode. */ - (void)printf( "
\n" ); + (void)fprintf( outfile, "\n\n" ); return( dbg_null ); } } @@ -110,29 +117,29 @@ static void newblock( dbg_Token old, dbg_Token new ) switch( old ) { case dbg_timestamp: - (void)printf( "," ); + (void)fprintf( outfile, "," ); break; case dbg_level: - (void)printf( "]\n " ); + (void)fprintf( outfile, "]\n " ); break; case dbg_sourcefile: - (void)printf( ":" ); + (void)fprintf( outfile, ":" ); break; case dbg_lineno: - (void)printf( ")" ); + (void)fprintf( outfile, ")" ); break; } switch( new ) { case dbg_timestamp: - (void)printf( "[" ); + (void)fprintf( outfile, "[" ); break; case dbg_level: - (void)printf( " " ); + (void)fprintf( outfile, " " ); break; case dbg_lineno: - (void)printf( "(" ); + (void)fprintf( outfile, "(" ); break; } } /* newblock */ @@ -156,41 +163,38 @@ static void charprint( dbg_Token tok, int c ) break; case dbg_null: case dbg_eof: - (void)putchar( '\n' ); + (void)putc( '\n', outfile ); break; default: switch( c ) { case '<': - (void)printf( "<" ); + (void)fprintf( outfile, "<" ); break; case '>': - (void)printf( ">" ); + (void)fprintf( outfile, ">" ); break; case '&': - (void)printf( "&" ); + (void)fprintf( outfile, "&" ); break; case '\"': - (void)printf( """ ); + (void)fprintf( outfile, """ ); break; default: - (void)putchar( c ); + (void)putc( c, outfile ); break; } } } /* charprint */ -int main( int argc, char *argv[] ) +static void convert( void ) /* ------------------------------------------------------------------------ ** - * This simple program scans and parses Samba debug logs, and produces HTML - * output. + * Read the input logfile, converting the entries to HTML. * - * Input: argc - Currently ignored. - * argv - Currently ignored. - * - * Output: Always zero. - * - * Notes: The HTML output is sent to stdout. + * Input: none. + * output: none. + * Notes: Reads from the global infile, writes to the global outfile. + * These default to stdin and stdout, respectively. * * ------------------------------------------------------------------------ ** */ @@ -203,12 +207,8 @@ int main( int argc, char *argv[] ) state = dbg_null, mode = dbg_null; - (void)printf( "\n" ); - (void)printf( "\n\n" ); - (void)printf( "\n" ); return( dbg_message ); } break; @@ -82,7 +89,7 @@ static dbg_Token modechange( dbg_Token new, dbg_Token mode ) if( dbg_message == mode ) { /* Switching out of message mode. */ - (void)printf( "\n\n" ); + (void)fprintf( outfile, "