home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / sectools / fragrouter / Libnet-0.99b / test / Random / prand_trials.c < prev   
Encoding:
C/C++ Source or Header  |  1999-07-26  |  3.2 KB  |  116 lines

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