aboutsummaryrefslogtreecommitdiff
path: root/xD-gen-replies.awk
blob: 015e743d10ac84cc0d4f50b6467a3bcbb33e8edf (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
#!/usr/bin/awk -f
BEGIN {
	# The message catalog is a by-product
	msg = "xD.msg"
	print "$quote \"" > msg
	print "$set 1" > msg
}

/^[0-9]+ *IRC_(ERR|RPL)_[A-Z]+ *".*"$/ {
	match($0, /".*"/)
	ids[$1] = $2
	texts[$2] = substr($0, RSTART, RLENGTH)
	print $1 " " texts[$2] > msg
}

END {
	printf("enum\n{")
	for (i in ids) {
		if (seen_first)
			printf(",")
		seen_first = 1
		printf("\n\t%s = %s", ids[i], i)
	}
	print "\n};\n"
	print "static const char *g_default_replies[] =\n{"
	for (i in ids)
		print "\t[" ids[i] "] = " texts[ids[i]] ","
	print "};"
}