Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
randseed.c File Reference
#include "plgetopt.h"
#include "nspr.h"
#include "prrng.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

static void Help (void)
static void PrintRand (void *buf, PRIntn size)
PRIntn main (PRIntn argc, char *argv[])

Variables

PRLogModuleInfolm
PRLogModuleLevel msgLevel = PR_LOG_NONE
PRIntn debug = 0
PRUint32 failed_already = 0
PRIntn optRandCount = 30
char buf [40]
PRSize bufSize = sizeof(buf)
PRSize rSize
PRIntn i

Function Documentation

static void Help ( void  ) [static]

Definition at line 74 of file randseed.c.

{
    printf("Template: Help(): display your help message(s) here");
    exit(1);
} /* end Help() */

Here is the call graph for this function:

PRIntn main ( PRIntn  argc,
char *  argv[] 
)

Definition at line 116 of file randseed.c.

{
    {
        /*
        ** Get command line options
        */
        PLOptStatus os;
        PLOptState *opt = PL_CreateOptState(argc, argv, "hdv");

           while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
        {
                  if (PL_OPT_BAD == os) continue;
            switch (opt->option)
            {
            case 'd':  /* debug */
                debug = 1;
                         msgLevel = PR_LOG_ERROR;
                break;
            case 'v':  /* verbose mode */
                         msgLevel = PR_LOG_DEBUG;
                break;
            case 'h':  /* help message */
                         Help();
                break;
             default:
                break;
            }
        }
           PL_DestroyOptState(opt);
    }

    lm = PR_NewLogModule("Test");       /* Initialize logging */
    for ( i = 0; i < optRandCount ; i++ ) {
        memset( buf, 0, bufSize );
        rSize = PR_GetRandomNoise( buf, bufSize );
        if (!rSize) {
            fprintf(stderr, "Not implemented\n" );
            failed_already = PR_TRUE;
            break;
        }
        if (debug) PrintRand( buf, rSize );
    }

    if (debug) printf("%s\n", (failed_already)? "FAIL" : "PASS");
    return( (failed_already == PR_TRUE )? 1 : 0 );
}  /* main() */

Here is the call graph for this function:

static void PrintRand ( void buf,
PRIntn  size 
) [static]

Definition at line 80 of file randseed.c.

{
    PRUint32 *rp = buf;
    PRIntn   i;

    printf("%4.4d--\n", size );
    while (size > 0 ) {
        switch( size )  {
            case 1 :
                printf("%2.2X\n", *(rp++) );
                size -= 4;    
                break;
            case 2 :
                printf("%4.4X\n", *(rp++) );
                size -= 4;    
                break;
            case 3 :
                printf("%6.6X\n", *(rp++) );
                size -= 4;    
                break;
            default:
                while ( size >= 4) {
                    PRIntn i = 3;
                    do {
                        printf("%8.8X ", *(rp++) );
                        size -= 4;    
                    } while( i-- );
                    i = 3;
                    printf("\n");
                }
                break;
        } /* end switch() */
    } /* end while() */
} /* end PrintRand() */

Here is the caller graph for this function:


Variable Documentation

char buf[40]

Definition at line 66 of file randseed.c.

PRSize bufSize = sizeof(buf)

Definition at line 67 of file randseed.c.

PRIntn debug = 0

Definition at line 61 of file randseed.c.

Definition at line 62 of file randseed.c.

PRIntn i

Definition at line 69 of file randseed.c.

Definition at line 59 of file randseed.c.

Definition at line 60 of file randseed.c.

PRIntn optRandCount = 30

Definition at line 65 of file randseed.c.

Definition at line 68 of file randseed.c.