-
Notifications
You must be signed in to change notification settings - Fork 1
/
mklibapnd
executable file
·318 lines (293 loc) · 10.2 KB
/
mklibapnd
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/usr/bin/perl
use Getopt::Long;
use DBI;
use Env qw(LSBUSER LSBDBPASSWD LSBDB LSBDBHOST);
sub usage()
{
print STDERR "mklibapnd -a <archname> -v <lsbversion> [-m submodule]\n Default submodule is LSB_Base\n";
die;
}
# Uncomment to trace SQL statments
#$trace=1;
#
# 1) process the arguments
#
GetOptions("a=s" => \$archname,
"v=s" => \$lsbversion,
"m=s" => \$submodule);
if( !$submodule ) { $submodule='LSB_Base'; }
if( !$archname ) { usage(); }
if( !$lsbversion ) { usage(); }
#
# 2) Establish connection to the database
#
$dbh = DBI->connect('DBI:mysql:database='.$LSBDB.';host='.$LSBDBHOST, $LSBUSER, $LSBDBPASSWD)
or die "Couldn't connect to database: ".DBI->errstr;
#
# 3) get & print the architecture info
#
$select = "SELECT * FROM Architecture WHERE ";
$select.= "Architecture.Aname=".$dbh->quote($archname);
print STDERR $select,"\n" if $trace;
$sth = $dbh->prepare($select) or die "Couldn't prepare $select query: ".DBI->errstr;
$sth->execute or die "Couldn't execute $select query: ".DBI->errstr;
$entry=$sth->fetchrow_hashref;
$Aid=$entry->{'Aid'};
$Aname=$entry->{'Aname'};
$sth->finish;
printf("<!-- Start of generated text - do not edit! -->\n");
printf("<!-- generated from the LSB specification database by mklibapnd -->\n");
#
# 4) get & print the library info
#
if ( ! $submodule ) {
$submodule = "LSB_Base";
}
$select = "SELECT * FROM Library ";
$select.= "LEFT JOIN ArchLib ON ALlid=Lid ";
$select.= "LEFT JOIN SModLib ON SMLlid=Lid ";
$select.= "LEFT JOIN SubModule ON SMLsmid=SMid ";
$select.= "WHERE (ALappearedin <= '$lsbversion' AND ALappearedin > '' ";
$select.= "AND (ALwithdrawnin IS NULL OR ALwithdrawnin > '$lsbversion') ) ";
$select.= "AND (SMLappearedin <= '$lsbversion' AND SMLappearedin > '' ";
$select.= "AND (SMLwithdrawnin IS NULL OR SMLwithdrawnin > '$lsbversion') ) ";
$select.= "AND SMname='".$submodule."' ";
if( $Aid != 1 ) {
$select.= "AND (ALaid=$Aid OR (ALaid=1 AND Lid NOT IN ( ";
$select.= "SELECT Lid FROM Library ";
$select.= "LEFT JOIN ArchLib ON ALlid=Lid ";
$select.= "WHERE (ALappearedin <= '$lsbversion' AND ALappearedin > '' ";
$select.= "AND (ALwithdrawnin IS NULL OR ALwithdrawnin > '$lsbversion') ) ";
$select.= "AND ALaid=$Aid ) ) ) ";
}
else {
$select.= "AND ALaid=$Aid ";
}
$select.= "AND Library.Lname!='libstdcxx' ";
$select.= "ORDER BY Lname ";
print STDERR $select,"\n" if $trace;
$lth = $dbh->prepare($select) or die "Couldn't prepare $select query: ".DBI->errstr;
$lth->execute or die "Couldn't execute $select query: ".DBI->errstr;
for(1..$lth->rows) {
$entry=$lth->fetchrow_hashref;
$Lid=$entry->{'Lid'};
$Lname=$entry->{'Lname'};
$select = "SELECT Iname,ISsid,Vname,Sname,Stag ";
$select.= "FROM Interface ";
$select.= "INNER JOIN LGInt ON Iid=LGIint ";
$select.= "INNER JOIN LibGroup ON LGIlibg=LGid ";
$select.= "LEFT JOIN ArchInt ON Iid=AIint ";
$select.= "LEFT JOIN Version ON Vid=AIversion ";
$select.= "LEFT JOIN IntStd ON ISiid=Iid ";
$select.= "LEFT JOIN Standard ON Sid=ISsid ";
$select.= "WHERE Itype='Function' ";
$select.= "AND LGlib=$Lid AND AIarch=$Aid ";
$select.= "AND AIappearedin <= '$lsbversion' AND AIappearedin > '' ";
$select.= "AND (AIwithdrawnin IS NULL OR AIwithdrawnin >'$lsbversion')";
$select.= "AND ISappearedin <= '$lsbversion' AND ISappearedin > '' ";
$select.= "AND (ISwithdrawnin IS NULL OR ISwithdrawnin >'$lsbversion') ";
$select.= "ORDER BY Iname,Vname ";
print STDERR $select,"\n" if $trace;
$inh = $dbh->prepare($select) or die "Couldn't prepare $select query: ".DBI->errstr;
$inh->execute or die "Couldn't execute $select query: ".DBI->errstr;
if( $inh->rows == 0) {
$inh->finish;
next;
}
# id tags cannot contain underscore, make sure they don't
$safeLname = $Lname;
$safeLname =~ s/_/-/g;
# $safeLname = $Lname =~ tr/_/-/r; # another version, also works
print "<sect1 id=app-", $safeLname, ">\n";
print "<title>", $Lname, "</title>\n";
print "<para>\n";
print "</para>\n";
#
# 6) Get a list of the Standards that are used by this library
#
print "<para>\n";
$select = "SELECT DISTINCT Sname,Sid,Stag FROM Standard,LibGroup,LGInt,Interface ";
$select.= "LEFT JOIN ArchInt ON Iid=AIint ";
$select.= "LEFT JOIN IntStd ON Iid=ISiid ";
$select.= "WHERE Sid=ISsid AND Iid=LGIint AND LGIlibg=LGid ";
$select.= "AND LGlib=$Lid AND AIarch=$Aid ";
$select.= "AND ISappearedin <= '$lsbversion' AND ISappearedin > '' ";
$select.= "AND (ISwithdrawnin IS NULL OR ISwithdrawnin >'$lsbversion') ";
$select.= "AND Sappearedin <= '$lsbversion' AND Sappearedin > '' ";
$select.= "AND (Swithdrawnin IS NULL OR Swithdrawnin >'$lsbversion') ";
$select.= "ORDER BY Sname";
print STDERR $select,"\n" if $trace;
$lsh = $dbh->prepare($select) or die "Couldn't prepare $select query: ".DBI->errstr;
$lsh->execute or die "Couldn't execute $select query: ".DBI->errstr;
local @refname;
if( $lsh->rows) {
print "The behavior of the interfaces in this library is specified ";
print "by the following Standards.";
print "<simplelist columns=1>\n";
for(1..$lsh->rows) {
local(*entry);
$entry=$lsh->fetchrow_hashref;
$refname[$_] = $entry->{'Sname'};
print "<member>\n";
printf "<xref linkend=\"std.%s\"> [%s]\n",
$entry->{'Stag'}, $entry->{'Sname'};
print "</member>\n";
}
print "</simplelist>\n";
}
$lsh->finish;
print "</para>\n";
print "<table>\n";
print "<title>$Lname Function Interfaces</title>\n";
print "<tgroup cols=3>\n";
print "<tbody>\n";
#
# 7) Get a list of the interfaces in the library
#
{
local(*std);
local(*symver);
local(*entry);
local(*xrefs);
local(*refs);
# we did the following query back at step 4,
# and the results are still there waiting to be fetched ...
#$select = "SELECT Iname,ISsid,Vname,Sname,Stag ";
#$select.= "FROM Interface,LGInt,LibGroup ";
#$select.= "LEFT JOIN Version ON Vid=Iversion ";
#$select.= "LEFT JOIN IntStd ON ISiid=Iid ";
#$select.= "LEFT JOIN Standard ON Sid=ISsid ";
#$select.= "WHERE Iid=LGIint AND LGIlibg=LGid AND Itype='Function' ";
#$select.= "AND LGlib=$Lid AND Iarch=$Aid AND Istdstatus='Included' ";
#$select.= "AND (ISappearedin <= '$lsbversion' and ISappearedin<>'') ";
#$select.= "AND (ISwithdrawnin IS NULL OR ISwithdrawnin >'$lsbversion') ";
#$select.= "AND (Sappearedin <= '$lsbversion' and Sappearedin<>'') ";
#$select.= "AND (Swithdrawnin IS NULL OR Swithdrawnin >'$lsbversion') ";
#$select.= "ORDER BY Iname,Vname";
#$inh = $dbh->prepare($select) or die "Couldn't prepare $select query: ".DBI->errstr;
#$inh->execute or die "Couldn't execute $select query: ".DBI->errstr;
print STDERR $select,"\n" if $trace;
for(1..$inh->rows) {
$entry=$inh->fetchrow_hashref;
$entry[$_]=$entry->{'Iname'};
$std[$_]=$entry->{'ISsid'};
$xrefs[$_]=sprintf ("std.%s", $entry->{'Stag'});
$refs[$_]=sprintf "[%s]", $entry->{'Sname'};
$symver[$_]=$entry->{'Vname'};
}
# we now have @entry, an array of interface names
# @std, an array of Standards (by Sid),
# @refs, an array of xref labels to the standards in the normative refs,
# and @symver, an array of symbol versions
#
#
# this is a three column table
#
# inc is the last row number ...
$inc=int(($inh->rows+2)/3);
for(1..$inc) {
print "<row>";
printf "<entry>%s", $entry[$_];
if( $symver[$_] ) {
printf "(%s)", $symver[$_];
}
if( $std[$_] ) {
printf "<link linkend=\"%s\">%s</link>", $xrefs[$_], $refs[$_];
}
printf "</entry>";
printf "<entry>%s", $entry[$_+$inc];
if( $symver[$_+$inc] ) {
printf "(%s)", $symver[$_+$inc];
}
if( $std[$_+$inc] ) {
printf "<link linkend=\"%s\">%s</link>", $xrefs[$_+$inc], $refs[$_+$inc];
}
printf "</entry>";
printf "<entry>%s", $entry[$_+(2*$inc)];
if( $symver[$_+(2*$inc)] ) {
printf "(%s)", $symver[$_+(2*$inc)];
}
if( $std[$_+(2*$inc)] ) {
printf "<link linkend=\"%s\">%s</link>", $xrefs[$_+(2*$inc)], $refs[$_+(2*$inc)];
}
printf "</entry>";
print "</row>\n";
}
}
$inh->finish;
print "</tbody>\n";
print "</tgroup>\n";
print "</table>\n";
#
# 8) Make a table of data interfaces
#
{
local(*datasym);
local(*symver);
local(*std);
local(*xrefs);
local(*refs);
$select = "SELECT Iname,ISsid,Vname,Sname,Stag ";
$select.= "FROM Interface ";
$select.= "INNER JOIN LGInt ON Iid=LGIint ";
$select.= "INNER JOIN LibGroup ON LGIlibg=LGid ";
$select.= "LEFT JOIN ArchInt ON Iid=AIint ";
$select.= "LEFT JOIN IntStd ON Iid=ISiid ";
$select.= "LEFT JOIN Version ON Vid=AIversion ";
$select.= "LEFT JOIN Standard ON Sid=ISsid ";
$select.= "WHERE Itype='Data' ";
$select.= "AND LGlib=$Lid AND AIarch=$Aid ";
$select.= "AND AIappearedin <= '$lsbversion' AND AIappearedin > '' ";
$select.= "AND (AIwithdrawnin IS NULL OR AIwithdrawnin >'$lsbversion') ";
$select.= "AND ISappearedin <= '$lsbversion' AND ISappearedin > '' ";
$select.= "AND (ISwithdrawnin IS NULL OR ISwithdrawnin >'$lsbversion') ";
$select.= "AND Sappearedin <= '$lsbversion' AND Sappearedin > '' ";
$select.= "AND (Swithdrawnin IS NULL OR Swithdrawnin >'$lsbversion') ";
$select.= "ORDER BY Iname,Vname";
print STDERR $select,"\n" if $trace;
$sth = $dbh->prepare($select) or die "Couldn't prepare $select query: ".DBI->errstr;
$sth->execute or die "Couldn't execute $select query: ".DBI->errstr;
if ($sth->rows > 0 ) {
for(1..$sth->rows) {
$datasym=$sth->fetchrow_hashref;
$datasym[$_]=$datasym->{'Iname'};
$std[$_]=$datasym->{'ISsid'};
$xrefs[$_]=sprintf ("std.%s", $datasym->{'Stag'});
$refs[$_]=sprintf "[%s]", $datasym->{'Sname'};
$symver[$_]=$datasym->{'Vname'};
}
print "<table>\n";
print "<title>$Lname Data Interfaces</title>\n";
print "<tgroup cols=3>\n";
print "<tbody>\n";
$inc=($sth->rows+2)/3;
for(1..$inc) {
print "<row>";
printf "<entry>%s",$datasym[$_];
if( $datasym[$_] && $std[$_] ) {
printf "<link linkend=\"%s\">%s</link>", $xrefs[$_], $refs[$_];
}
printf "</entry>";
printf "<entry>%s",$datasym[$_+$inc];
if( $datasym[$_+$inc] && $std[$_+$inc] ) {
printf "<link linkend=\"%s\">%s</link>", $xrefs[$_+$inc], $refs[$_+$inc];
}
printf "</entry>";
printf "<entry>%s",$datasym[$_+(2*$inc)];
if( $datasym[$_+(2*$inc)] && $std[$_+(2*$inc)] ) {
printf "<link linkend=\"%s\">%s</link>", $xrefs[$_+(2*$inc)], $refs[$_+(2*$inc)];
}
printf "</entry>";
print "</row>\n";
}
print "</tbody>\n";
print "</tgroup>\n";
print "</table>\n";
}
$sth->finish;
}
print "</sect1>\n";
}
$lth->finish;
$dbh->disconnect;
printf("<!-- End of text generated from database -->\n");