summaryrefslogtreecommitdiff
path: root/lib/gentagtbl.sh
blob: 0558d09f330ff1e7477737f8cd5036847f8bf329 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh

cat << EOF
static const struct headerTagTableEntry_s rpmTagTable[] = {
EOF

${AWK} '/[\t ](RPMTAG_[A-Z0-9]*)[ \t]+([0-9]*)/ && !/internal/ && !/unimplemented/ {
	tt = "NULL"
	ta = "ANY"
	ext = "0"
	if ($5 == "c") {
		tt = "CHAR"
		ta = "SCALAR"
	}
	if ($5 == "c[]") {
		tt = "CHAR"
		ta = "ARRAY"
	} 
	if ($5 == "h") {
		tt = "INT16"
		ta = "SCALAR"
	}
	if ($5 == "h[]") {
		tt = "INT16"
		ta = "ARRAY"
	}
	if ($5 == "i") {
		tt = "INT32"
		ta = "SCALAR"
	}
	if ($5 == "i[]") {
		tt = "INT32"
		ta = "ARRAY"
	}
	if ($5 == "l") {
		tt = "INT64"
		ta = "SCALAR"
	}
	if ($5 == "l[]") {
		tt = "INT64"
		ta = "ARRAY"
	}
	if ($5 == "s") {
		tt = "STRING"
		ta = "SCALAR"
	}
	if ($5 == "s[]") {
		tt = "STRING_ARRAY"
		ta = "ARRAY"
	}
	if ($5 == "s{}") {
		tt = "I18NSTRING"
		ta = "SCALAR"
	} 
	if ($5 == "x") {
		tt = "BIN"
		ta = "SCALAR"
	}
	if ($6 == "extension") {
		ext = "1"
	}
	if ($2 == "=") {
		tnarg = $1
	} else {
		tnarg = $2
	}
	tn = substr(tnarg, index(tnarg, "_") + 1)
	sn = (substr(tn, 1, 1) tolower(substr(tn, 2)))
	if ($2 == "=") {
		printf("    { \"%s\", \"%s\", %s, RPM_%s_TYPE, RPM_%s_RETURN_TYPE, %d },\n", tnarg, sn, tnarg, tt, ta, ext)
	} else {
		printf("    { \"%s\", \"%s\", %s, RPM_%s_TYPE, RPM_%s_RETURN_TYPE, %d },\n", tnarg, sn, $3, tt, ta, ext)
	}
}' < $1 | sort

cat << EOF
    { NULL, NULL, RPMTAG_NOT_FOUND, RPM_NULL_TYPE, 0 }
};
EOF