Add new message types for A1
[ric-plt/lib/rmr.git] / src / rmr / common / include / vet_mtypes.ksh
1 #!/usr/bin/env ksh
2
3 #==================================================================================
4 #        Copyright (c) 2019 Nokia
5 #        Copyright (c) 2018-2019 AT&T Intellectual Property.
6 #
7 #   Licensed under the Apache License, Version 2.0 (the "License");
8 #   you may not use this file except in compliance with the License.
9 #   You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #   Unless required by applicable law or agreed to in writing, software
14 #   distributed under the License is distributed on an "AS IS" BASIS,
15 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #   See the License for the specific language governing permissions and
17 #   limitations under the License.
18 #==================================================================================
19
20
21 # This provides a quick sanity check on the message types in
22 # the header file. The check is only to ensure that there are
23 # no duplicate constant names or values for any #define in the file.
24 #
25 # By default RIC_message_types.h is parsed, but it will accept the 
26 # filename as the first positional parameter on the command line should
27 # it be necessary.
28 #
29 # The script exits with a 0 return code if all is good, 1 to indicate errors.
30 #
31 # CAUTION:  this breaks if any define is more than a simple key/value
32 #       pair in the header file.
33
34 awk '
35         /#define/ { 
36                 vcount[$NF]++; 
37                 ncount[$2]++;
38                 next
39         } 
40
41         END { 
42                 vgood = 0
43                 ngood = 0
44                 bad = 0
45
46                 for( x in vcount ) { 
47                         if( vcount[x] != 1 ) { 
48                                 printf( "duplicate value? %s\n", x ); 
49                                 bad++ 
50                         } else { 
51                                 vgood++ 
52                         } 
53                 } 
54
55                 for( x in ncount ) { 
56                         if( ncount[x] != 1 ) { 
57                                 printf( "duplicate name? %s\n", x ); 
58                                 bad++ 
59                         } else { 
60                                 ngood++ 
61                         } 
62                 } 
63
64                 printf( "good values=%d good names=%d  bad things=%d\n", vgood, ngood, bad ) 
65
66                 exit( !! bad )
67         }' ${1:-RIC_message_types.h}