summaryrefslogtreecommitdiff
path: root/genrandname.c
blob: 39ce1995502e0b517b3caf6d4413e16d8c172426 (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
50
51
52
53
54
55
56
57
#include <u.h>
#include <libc.h>

enum {
	NF,
	NM
};

typedef struct Name Name;
struct Name
{
	char *name;
	int sex;
};

void
genrandname(char *d, ulong len)
{
	Name names[] = {
		"mariana", NF,
		"jerca", NF,
		"repa", NF,
		"jaca", NF,
		"pinta", NF,
		"manolo", NM,
		"eustaquio", NM,
		"aberroncho", NM,
		"merovingio", NM,
		"trudi", NM
	};
	char *adjectives[] = {
		"atropelladX",
		"bacaladX",
		"acojonadX",
		"estrictX",
		"diarreas",
		"gordacX"
	}, buf[256], *p;
	int i;

	i = ntruerand(nelem(adjectives));
	snprint(buf, sizeof buf, "%s", adjectives[i]);
	i = ntruerand(nelem(names));
	if((p = strchr(buf, 'X')) != nil)
		*p = names[i].sex == NF ? 'a' : 'o';
	snprint(d, len, "%s%s", names[i].name, buf);
}

void
main()
{
	char buf[256];

	genrandname(buf, sizeof buf);
	print("%s\n", buf);
	exits(0);
}