1*cdf0e10cSrcweir# 2*cdf0e10cSrcweir# checknewapi - a perl script to check for new API's 3*cdf0e10cSrcweir# using two outputs from regview and dump the interscetion 4*cdf0e10cSrcweir# of new types 5*cdf0e10cSrcweir# 6*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 7*cdf0e10cSrcweir# 8*cdf0e10cSrcweir 9*cdf0e10cSrcweirif($#ARGV != 3) 10*cdf0e10cSrcweir{ 11*cdf0e10cSrcweir die "usage: checknewapi <new_type_library> <reference_type_library> <buildinfodescr> <fullpath_regview>\n"; 12*cdf0e10cSrcweir} 13*cdf0e10cSrcweir 14*cdf0e10cSrcweir-e "$ARGV[0]" || die "ERROR: type library \"$ARGV[0]\" does not exist\n"; 15*cdf0e10cSrcweir-e "$ARGV[1]" || die "ERROR: reference type library \"$ARGV[1]\" does not exist\n"; 16*cdf0e10cSrcweir-e "$ARGV[3]" || die "ERROR: invalid path to the regview tool \"$ARGV[3]\", please specify the full qualified path\n"; 17*cdf0e10cSrcweir 18*cdf0e10cSrcweir# debug flag 19*cdf0e10cSrcweir$DEBUG = 0; 20*cdf0e10cSrcweir 21*cdf0e10cSrcweir$main::buildinfo = "$ARGV[2]"; 22*cdf0e10cSrcweir$main::regview = "$ARGV[3]"; 23*cdf0e10cSrcweir%{$main::reftypes} = (); 24*cdf0e10cSrcweir%{$main::currenttypes} = (); 25*cdf0e10cSrcweir%{$main::removedtypes} = (); 26*cdf0e10cSrcweir 27*cdf0e10cSrcweiropen ( FILEIN, "$main::regview \"$ARGV[0]\" |" ) || die "could not use content of current typelibrary \"$ARGV[0]\", regview doesn't work\n"; 28*cdf0e10cSrcweir 29*cdf0e10cSrcweirif ($DEBUG == 1) 30*cdf0e10cSrcweir{ 31*cdf0e10cSrcweir open( CURRENT, ">current_types.txt" ) || die "\nERROR: could not open current_types.txt for writing"; 32*cdf0e10cSrcweir} 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir$first = 1; 35*cdf0e10cSrcweir$linebefore = ""; 36*cdf0e10cSrcweir$published = 0; 37*cdf0e10cSrcweir$typeclass = ""; 38*cdf0e10cSrcweirwhile (<FILEIN>) 39*cdf0e10cSrcweir{ 40*cdf0e10cSrcweir if ($first == 0) 41*cdf0e10cSrcweir { 42*cdf0e10cSrcweir if ( $linebefore =~ m#type class: published (.+)# ) 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir $published = 1; 45*cdf0e10cSrcweir $typeclass = $1; 46*cdf0e10cSrcweir } elsif ( $linebefore =~ m#type class: (.+)# ) 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir $published = 0; 49*cdf0e10cSrcweir $typeclass = $1; 50*cdf0e10cSrcweir } else 51*cdf0e10cSrcweir { 52*cdf0e10cSrcweir $published = 0; 53*cdf0e10cSrcweir $typeclass = ""; 54*cdf0e10cSrcweir } 55*cdf0e10cSrcweir } else 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir $first = 0; 58*cdf0e10cSrcweir } 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) ) 61*cdf0e10cSrcweir { 62*cdf0e10cSrcweir if ($DEBUG == 1) 63*cdf0e10cSrcweir { 64*cdf0e10cSrcweir print CURRENT "$1\n"; 65*cdf0e10cSrcweir } 66*cdf0e10cSrcweir if ( ! exists $main::currenttypes->{$1} ) 67*cdf0e10cSrcweir { 68*cdf0e10cSrcweir $main::currenttypes->{$1} = { PUBLISHED => $published, 69*cdf0e10cSrcweir TYPECLASS => $typeclass, 70*cdf0e10cSrcweir COUNT => 1 }; 71*cdf0e10cSrcweir# print "### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n"; 72*cdf0e10cSrcweir } 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir $linebefore = $_; 75*cdf0e10cSrcweir} 76*cdf0e10cSrcweirclose( FILEIN ); 77*cdf0e10cSrcweirclose( CURRENT ); 78*cdf0e10cSrcweir 79*cdf0e10cSrcweiropen ( FILEIN, "$main::regview \"$ARGV[1]\" |" ) || die "could not use content of reference type library \"$ARGV[1]\", regview doesn't work\n"; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweirif ($DEBUG == 1) 82*cdf0e10cSrcweir{ 83*cdf0e10cSrcweir open( REFERENCE, ">reference_types.txt" ) || die "\nERROR: could not open reference_types.txt for writing"; 84*cdf0e10cSrcweir} 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir# reset variables 87*cdf0e10cSrcweir$first = 1; 88*cdf0e10cSrcweir$linebefore = ""; 89*cdf0e10cSrcweir$published = 0; 90*cdf0e10cSrcweir$typeclass = ""; 91*cdf0e10cSrcweirwhile (<FILEIN>) 92*cdf0e10cSrcweir{ 93*cdf0e10cSrcweir if ($first == 0) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir if ( $linebefore =~ m#type class: published (.+)# ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir $published = 1; 98*cdf0e10cSrcweir $typeclass = $1; 99*cdf0e10cSrcweir } elsif ( $linebefore =~ m#type class: (.+)# ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir $published = 0; 102*cdf0e10cSrcweir $typeclass = $1; 103*cdf0e10cSrcweir } else 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir $published = 0; 106*cdf0e10cSrcweir $typeclass = ""; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } else 109*cdf0e10cSrcweir { 110*cdf0e10cSrcweir $first = 0; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir if ( (!$typeclass eq "") && ($_ =~ m# *type name: \"([^\[.]+)\"#) ) 114*cdf0e10cSrcweir { 115*cdf0e10cSrcweir if ($DEBUG == 1) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir print REFERENCE "$1\n"; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir if ( ! exists $main::reftypes->{$1} ) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir $main::reftypes->{$1}++; 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir if ( exists $main::currenttypes->{$1} ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir $main::currenttypes->{$1}->{COUNT}++; 126*cdf0e10cSrcweir# print "###### $main::currenttypes->{$1}->{PUBLISHED} $main::currenttypes->{$1}->{TYPECLASS} $main::currenttypes->{$1}->{COUNT}\n"; 127*cdf0e10cSrcweir } else 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir if ($published == 0) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir $main::removedtypes->{$1} = { PUBLISHED => $published, 132*cdf0e10cSrcweir TYPECLASS => $typeclass }; 133*cdf0e10cSrcweir } else 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir print "ERROR: type $1 is only in reference type library, this can't be happen\n"; 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir } 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir $linebefore = $_; 141*cdf0e10cSrcweir} 142*cdf0e10cSrcweirclose( FILEIN ); 143*cdf0e10cSrcweirclose( REFERENCE ); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir@typekeys = keys %{$main::currenttypes}; 147*cdf0e10cSrcweir$allunotypes = $#typekeys+1; 148*cdf0e10cSrcweir$newunotypes = 0; 149*cdf0e10cSrcweir$newpublished = 0; 150*cdf0e10cSrcweir$draftscount = 0; 151*cdf0e10cSrcweir$draftspublished = 0; 152*cdf0e10cSrcweirforeach $i ( sort @typekeys ) 153*cdf0e10cSrcweir{ 154*cdf0e10cSrcweir if ( $main::currenttypes->{$i}->{COUNT} == 1 && 155*cdf0e10cSrcweir !("$main::currenttypes->{$i}->{TYPECLASS}" eq "module")) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir $newunotypes++; 158*cdf0e10cSrcweir my $t = $i; 159*cdf0e10cSrcweir $t =~ s#/#\.#go; 160*cdf0e10cSrcweir if ($main::currenttypes->{$i}->{PUBLISHED} == 1) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir print "published "; 163*cdf0e10cSrcweir $newpublished++; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir if ( $t =~ m#drafts\.com.+#) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir $draftscount++; 168*cdf0e10cSrcweir if ($main::currenttypes->{$i}->{PUBLISHED} == 1) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir $draftspublished++; 171*cdf0e10cSrcweir } 172*cdf0e10cSrcweir } 173*cdf0e10cSrcweir print "$main::currenttypes->{$i}->{TYPECLASS} = $t\n"; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir} 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir# count removed not yet published types 178*cdf0e10cSrcweir$removednotpublished = 0; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir@removedtypekeys = keys %{$main::removedtypes}; 181*cdf0e10cSrcweirforeach $i ( sort @removedtypekeys ) 182*cdf0e10cSrcweir{ 183*cdf0e10cSrcweir $removednotpublished++; 184*cdf0e10cSrcweir my $t = $i; 185*cdf0e10cSrcweir $t =~ s#/#\.#go; 186*cdf0e10cSrcweir print "removed not yet published $main::currenttypes->{$i}->{TYPECLASS} = $t\n"; 187*cdf0e10cSrcweir} 188*cdf0e10cSrcweir 189*cdf0e10cSrcweirprint "\n=======================================================\n\n"; 190*cdf0e10cSrcweirprint "Summary [last check for $main::buildinfo]:\n\n"; 191*cdf0e10cSrcweirprint "Number of UNO types = $allunotypes\n"; 192*cdf0e10cSrcweirprint "Number of new UNO types = $newunotypes\n"; 193*cdf0e10cSrcweirprint "New and published types = $newpublished\n"; 194*cdf0e10cSrcweirprint "New and draft types = $draftscount\n"; 195*cdf0e10cSrcweirprint "New, draft and published = $draftspublished\n"; 196*cdf0e10cSrcweirprint "Removed and not published = $removednotpublished\n"; 197*cdf0e10cSrcweir 198*cdf0e10cSrcweirexit 0; 199