genrandom.c revision 1b2ae58ef163d9369ac1b693dde667ec49627ad9
/*
* Copyright (C) 2004, 2005, 2007, 2009, 2010, 2012, 2014 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 2000-2003 Internet Software Consortium.
*
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: genrandom.c,v 1.7 2010/05/17 23:51:04 tbox Exp $ */
/*! \file */
#include <config.h>
#include <isc/commandline.h>
#include <stdio.h>
#include <string.h>
const char *program = "genrandom";
ISC_PLATFORM_NORETURN_PRE static void
usage(void) ISC_PLATFORM_NORETURN_POST;
static void
usage(void) {
exit(1);
}
static void
exit(1);
}
while (bytes > 0) {
#ifndef HAVE_ARC4RANDOM
unsigned short int x = (rand() & 0xFFFF);
#else
unsigned short int x = (arc4random() & 0xFFFF);
#endif
unsigned char c = x & 0xFF;
exit(1);
}
c = x >> 8;
exit(1);
}
bytes -= 2;
}
}
int
unsigned int bytes;
unsigned int k;
char *endp;
int c, i, n = 1;
char *name;
switch (c) {
case 'n':
usage();
break;
case '?':
if (isc_commandline_option != '?')
/* FALLTHROUGH */
case 'h':
usage();
default:
exit(1);
}
}
usage();
if (*endp != 0)
usage();
bytes = k << 10;
#ifndef HAVE_ARC4RANDOM
srand(0x12345678);
#endif
if (n == 1) {
return (0);
}
len += 2;
perror("malloc");
exit(1);
}
for (i = 1; i <= n; i++) {
}
return (0);
}