7 convert(int unique
, char* buf
)
12 for (i
=0; i
<7; i
++) buf
[i
] = 'A';
15 while ( unique
> 0 ) {
24 randNum(int seed
, int limit
, int generator
, int prime
)
27 seed
= (generator
* seed
) % prime
;
33 static unsigned long initSelection
= 0xFFFFFFFFL
;
34 static unsigned long querySelection
= 0xFFFFFFFFL
;
39 /* Check the (queryNum-1)th bit of the querySpec */
41 if ((1 << (queryNum
- 1)) & querySelection
)
50 setQueries(char* queryString
)
52 /* If never called then querySelection = all,
53 if called, set query to none. and start processing
55 if (querySelection
== initSelection
)
58 /* Parse the string into comma separated tokens */
60 char* tokens
[MAX_TOKENS
];
70 tokens
[numTokens
] = strtok(queryString
, ",");
71 while (tokens
[numTokens
] != NULL
) {
72 if (numTokens
< MAX_TOKENS
) {
73 tokens
[++numTokens
] = strtok(NULL
, ",");
76 fprintf (stderr
, "Too many queries specified.\n");
81 /* Check to see if you got any tokens (return if not) */
87 /* Process each token, expanding ranges if present,
88 * and adding the query numbers to the return value */
90 for (tokenPtr
= 0; tokenPtr
< numTokens
; tokenPtr
++) {
92 /* Check for a range '-' of tokens */
94 dash
= strchr(tokens
[tokenPtr
], '-');
97 /* Get the start and end range specifiers (set the dash to null) */
99 if (sscanf(tokens
[tokenPtr
], "%d", &start
) == -1 ||
100 sscanf(dash
+1, "%d", &end
) == -1) {
101 fprintf (stderr
, "Invalid query range specified (%s-%s).\n",
102 tokens
[tokenPtr
], dash
+1);
106 /* Make sure that the start and end values are in range
107 * (return -1 to signal error in caller) */
108 if ((start
< 1) || (start
> 32) || (end
< 1) || (end
> 32) || (start
>= end
)) {
109 fprintf (stderr
, "Invalid query range specified (%d-%d).\n", start
, end
);
113 /* From start to end, set the bit in the querySpec */
114 for (i
= start
; i
< (end
+1); i
++) {
115 querySelection
= querySelection
| (1 << (i
- 1));
119 /* Set the (tokenPtr) bit in the querySpec */
120 if (sscanf(tokens
[tokenPtr
], "%d", &tokenValue
) == -1) {
121 fprintf (stderr
, "Invalid query specified (%s).\n", tokens
[tokenPtr
]);
124 if (tokenValue
< 1 || tokenValue
> 32) {
125 fprintf (stderr
, "Invalid query specified (%d).\n", tokenValue
);
128 querySelection
= querySelection
| (1 << (tokenValue
- 1));