blob: cb92133bda74c98db088a74498ce56ab19923a15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <stdlib.h>
#include <stdio.h>
#include <libgen.h>
#include <errno.h>
#include <time.h>
#include <wchar.h>
#include <unistd.h>
#include "config.h"
int
main (int argc, char *argv[])
{
if (argc != 2) {
fprintf (stderr, "Usage: %s {outfile}\n", basename (argv[0]));
return EXIT_FAILURE;
}
FILE *stream = fopen (argv[1], "w,ccs="CCS);
if (stream == NULL) {
perror (NULL);
return EXIT_FAILURE;
}
srand (time (NULL));
size_t letter_count = 15;
for (int i = 0; i < 15; ++i)
fputwc (ALPHABET[rand () % wcslen (ALPHABET)], stream);
while (letter_count < LETTER_COUNT) {
int count = rand () % 15 + 1;
size_t letters_left = LETTER_COUNT - letter_count;
count = count > letters_left ? letters_left : count;
if (rand () % 2) {
for (int i = 0; i < count; ++i)
fputwc (ALPHABET[rand () % wcslen (ALPHABET)], stream);
} else {
wchar_t wc = ALPHABET[rand () % wcslen (ALPHABET)];
for (int i = 0; i < count; ++i)
fputwc (wc, stream);
}
letter_count += count;
}
if (fclose (stream) == EOF) {
perror (NULL);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
|