OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / lib / Libnet / test / Random / prand_trials.c
1 /*
2  *  $Id: prand_trials.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
3  *
4  *  libnet
5  *  prand_trials.c - psuedorandom number generation
6  *
7  *  Copyright (c) 1998, 1999, 2000 Mike D. Schiffman <mike@infonexus.com>
8  *  All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  */
32
33 #if (HAVE_CONFIG_H)
34 #include "../../include/config.h"
35 #endif
36 #include "../libnet_test.h"
37
38 int
39 main(int argc, char **argv)
40 {
41
42     int i, j;
43
44     printf("Psuedorandom number generation\n");
45     printf("For each trial, 1000 numbers will be generated\n");
46     libnet_seed_prand();
47
48     printf("\n\nPress return for trial 1 (0 - 1)\n\n");
49     getc(stdin);
50     for (i = 1000; i; i--)
51     {
52         printf("%ld ", libnet_get_prand(LIBNET_PR2));
53     }
54
55     printf("\n\nPress return for trial 2 (0 - 255)\n\n");
56     getc(stdin);
57     for (i = 1000; i; i--)
58     {
59         printf("%3ld ", libnet_get_prand(LIBNET_PR8));
60     }
61
62     printf("\n\nPress return for trial 3 (0 - 32767)\n\n");
63     getc(stdin);
64     for (j = 13, i = 1000; i; i--, j--)
65     {
66         if (!j)
67         {
68             printf("\n");
69             j = 13;
70         }
71         printf("%5ld ", libnet_get_prand(LIBNET_PR16));
72     }
73
74     printf("\n\nPress return for trial 4 (0 - 65535)\n\n");
75     getc(stdin);
76     for (j = 13, i = 1000; i; i--, j--)
77     {
78         if (!j)
79         {
80             printf("\n");
81             j = 13;
82         }
83         printf("%5ld ", libnet_get_prand(LIBNET_PRu16));
84     }
85
86     printf("\n\nPress return for trial 5 (0 - 2147483647)\n\n");
87     getc(stdin);
88     for (j = 7, i = 1000; i; i--, j--)
89     {
90         if (!j)
91         {
92             printf("\n");
93             j = 7;
94         }
95         printf("%10ld ", libnet_get_prand(LIBNET_PR32));
96     }
97
98     printf("\n\nPress return for trial 6 (0 - 4294967295)\n\n");
99     getc(stdin);
100     for (j = 7, i = 1000; i; i--, j--)
101     {
102         if (!j)
103         {
104             printf("\n");
105             j = 7;
106         }
107         printf("%10ld ", libnet_get_prand(LIBNET_PRu32));
108     }
109
110     printf("\nCompleted\n");
111     return (EXIT_SUCCESS);
112 }
113
114 /* EOF */