Subversion Repositories DevTools

Rev

Rev 267 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*============================================================================
**
**    ERG TRANSIT SYSTEMS      Licensed software
**    (C) 2008                 All rights reserved
**
**============================================================================
**
**  Project/Product : 
**  Filename        : stdouterr.c
**  Author(s)       : DDP
**
**  Description     : Test utility
**                    Generate data on stdout and stderr
**                    May take two arguments
**                      Messages for stdout
**                      Messages for stderr
**
**
**
**  Information     :
**   Compiler       : ANSI C
**   Target         : Test
**
**
**==========================================================================*/

#include "stdio.h"
#include <stdlib.h>

int main( int argc, char *argv[] )
{
    int i;
    int ocount = 10;
    int ecount = 10;
    int count;

    if (argc > 1)
    {
        char *endp;
        ocount = strtol(argv[1], &endp, 10);
        if (argc > 2)
        {
            ecount = strtol(argv[2], &endp, 10);
        }
        else
        {
            ecount = ocount;
        }
    }

    count = ecount > ocount ? ecount : ocount;


    for ( i = 0; i < count; i++ )
    {
        if ( i < ecount )
        {
            fprintf (stderr, "This is STDERR(%d)\n", i);
            fflush (stderr);
        }

        if ( i < ocount )
        {
            fprintf (stdout, "This is STDOUT(%d)\n", i);
            fflush (stdout);
        }
    }
    fflush (stdout);
    fflush (stderr);

    exit (7);
}