gen.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1996-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* Doug McIlroy <doug@research.bell-labs.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* generate test data
*/
static const char id[] = "\n@(#)$Id: gen (AT&T Research) 1998-05-11 $\0\n";
#include <ast.h>
#include <error.h>
#define ALPHA 62
#define NUMERIC 10
#define ROUND(n,s) ((n)=(((n)+(s)-1)/(s))*(s))
typedef struct
{
unsigned long min;
unsigned long max;
} Range_t;
static struct
{
unsigned char* buf;
int charset;
int part;
unsigned long seed;
} state;
static int
gen(register int m)
{
int c;
{
RAND();
}
return c;
}
{
register unsigned int c;
register unsigned int i;
register unsigned int k;
register unsigned long n;
int newline = 0;
char* e;
i = 0;
e = "0123456789";
while (c = *e++)
{
hit[c] = 1;
data[i++] = c;
}
e = "abcdefghijklmnopqrstuvwxyz";
while (c = *e++)
{
hit[c] = 1;
data[i++] = c;
}
e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
while (c = *e++)
{
hit[c] = 1;
data[i++] = c;
}
#if 0
e = "`-=[]\\{}|;':\",./<>?~!@#$%^&*()_+";
while (c = *e++)
{
hit[c] = 1;
data[i++] = c;
}
#endif
for (c = 0; c <= elementsof(data); c++)
if (!hit[c])
data[i++] = c;
while (c = optget(argv, "bd:[dup[:max]]f:[float-key[:max]]i:[int-key[:max]]k:[key]l:[lcm]p:[prefix[:max]]r:[record:[max]]s:[size]"))
switch (c)
{
case 'b':
break;
case 'd':
case 'f':
case 'i':
case 'k':
case 'l':
case 'n':
case 'p':
case 'r':
case 's':
if (*e)
break;
case '?':
break;
case ':':
break;
}
{
newline = 1;
else
}
else
{
else
}
{
else
}
{
else
}
1)))
do
{
i = 0;
{
while (i < k)
}
{
while (i < k)
}
{
while (i < k)
}
k = state.range['k'].min ? state.range['k'].min : state.range['r'].min + (RAND() % state.range['r'].max);
while (i < k)
{
while (i < k)
}
if (newline)
if (i > n)
{
i = n;
if (newline)
}
} while (n -= i);
exit(0);
}