1#************************************************************** 2# 3# Licensed to the Apache Software Foundation (ASF) under one 4# or more contributor license agreements. See the NOTICE file 5# distributed with this work for additional information 6# regarding copyright ownership. The ASF licenses this file 7# to you under the Apache License, Version 2.0 (the 8# "License"); you may not use this file except in compliance 9# with the License. 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, 14# software distributed under the License is distributed on an 15# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16# KIND, either express or implied. See the License for the 17# specific language governing permissions and limitations 18# under the License. 19# 20#************************************************************** 21 22 23 24$ARGV0 = shift @ARGV; 25$ARGV1 = shift @ARGV; 26$ARGV2 = shift @ARGV; 27 28# parse input file 29 30open( INFILE, $ARGV0 ) or die "Error: cannot open input file: $!"; 31my %props; 32while( <INFILE> ) 33{ 34 # trim newline 35 chomp( $_ ); 36 # trim leading/trailing whitespace 37 $_ =~ s/^\s*//g; 38 $_ =~ s/\s*$//g; 39 # check for valid characters 40 $_ =~ /^[A-Z][a-zA-Z0-9]*$/ or die "Error: invalid character in property '$_'"; 41 $id = "PROP_$_"; 42 $props{$_} = $id; 43} 44close( INFILE ); 45 46# generate output files 47 48open( IDFILE, ">$ARGV1" ) or die "Error: cannot open output file: $!"; 49open( NAMEFILE, ">$ARGV2" ) or die "Error: cannot open output file: $!"; 50 51$i = 0; 52foreach( sort( keys( %props ) ) ) 53{ 54 print( IDFILE "const sal_Int32 $props{$_} = $i;\n" ); 55 print( NAMEFILE "/* $i */ \"$_\",\n" ); 56 ++$i; 57} 58 59print( IDFILE "const sal_Int32 PROP_COUNT = $i;\n" ); 60print( IDFILE "const sal_Int32 PROP_INVALID = -1;\n" ); 61 62close( IDFILE ); 63close( NAMEFILE ); 64