allow rpm to custom systemd installation
[platform/upstream/rpm.git] / lib / gentagtbl.sh
1 #!/bin/sh
2
3 cat << EOF
4 static const struct headerTagTableEntry_s rpmTagTable[] = {
5 EOF
6
7 ${AWK} '/[\t ](RPMTAG_[A-Z0-9]*)[ \t]+([0-9]*)/ && !/internal/ && !/unimplemented/ {
8         tt = "NULL"
9         ta = "ANY"
10         ext = "0"
11         if ($5 == "c") {
12                 tt = "CHAR"
13                 ta = "SCALAR"
14         }
15         if ($5 == "c[]") {
16                 tt = "CHAR"
17                 ta = "ARRAY"
18         } 
19         if ($5 == "h") {
20                 tt = "INT16"
21                 ta = "SCALAR"
22         }
23         if ($5 == "h[]") {
24                 tt = "INT16"
25                 ta = "ARRAY"
26         }
27         if ($5 == "i") {
28                 tt = "INT32"
29                 ta = "SCALAR"
30         }
31         if ($5 == "i[]") {
32                 tt = "INT32"
33                 ta = "ARRAY"
34         }
35         if ($5 == "l") {
36                 tt = "INT64"
37                 ta = "SCALAR"
38         }
39         if ($5 == "l[]") {
40                 tt = "INT64"
41                 ta = "ARRAY"
42         }
43         if ($5 == "s") {
44                 tt = "STRING"
45                 ta = "SCALAR"
46         }
47         if ($5 == "s[]") {
48                 tt = "STRING_ARRAY"
49                 ta = "ARRAY"
50         }
51         if ($5 == "s{}") {
52                 tt = "I18NSTRING"
53                 ta = "SCALAR"
54         } 
55         if ($5 == "x") {
56                 tt = "BIN"
57                 ta = "SCALAR"
58         }
59         if ($6 == "extension") {
60                 ext = "1"
61         }
62         if ($2 == "=") {
63                 tnarg = $1
64         } else {
65                 tnarg = $2
66         }
67         tn = substr(tnarg, index(tnarg, "_") + 1)
68         sn = (substr(tn, 1, 1) tolower(substr(tn, 2)))
69         if ($2 == "=") {
70                 printf("    { \"%s\", \"%s\", %s, RPM_%s_TYPE, RPM_%s_RETURN_TYPE, %d },\n", tnarg, sn, tnarg, tt, ta, ext)
71         } else {
72                 printf("    { \"%s\", \"%s\", %s, RPM_%s_TYPE, RPM_%s_RETURN_TYPE, %d },\n", tnarg, sn, $3, tt, ta, ext)
73         }
74 }' < $1 | sort
75
76 cat << EOF
77     { NULL, NULL, RPMTAG_NOT_FOUND, RPM_NULL_TYPE, 0 }
78 };
79 EOF
80