update dev300-m58
[ooovba.git] / solenv / bin / converttags.pl
blob49581bae9fe3b4fbce19d2b73ac95a71187ee3a7
2 # converttags - a perl script to coonvert some predefined tags
3 # to user specified values
5 # Copyright (c) 2000 Sun Microsystems, Inc.
8 if($#ARGV == -1)
10 die "No parameters were specified.\nperl converttags.pl <mode> <title> <productname> [<color1>] [<color2>] file_1 [... file_n]\n";
12 if($#ARGV < 2)
14 die "No file were specified -> no file must be converted!\n";
17 # mode = 1 -> convert
18 # = 2 -> exit without conversion
19 $mode = shift @ARGV;
21 $title = shift @ARGV;
22 $productname = shift @ARGV;
24 $color1 = "";
25 $color2 = "";
27 if( $mode =~ s/2/$1/go )
29 exit 0;
32 if( $ARGV[0] =~ s/(#[\w]{6})/$1/go )
34 $color1 = shift @ARGV;
36 if( $ARGV[0] =~ s/(#[\w]{6})/$1/go )
38 $color2 = shift @ARGV;
41 print "$title\n";
42 print "$productname\n";
43 print "$color1\n";
44 print "$color2\n";
46 $return = 0;
48 while (@ARGV)
50 my $lineCount = 0;
51 $ARGV = shift @ARGV;
52 print "convert tags: $ARGV ";
54 open ( FILEIN, $ARGV ) || die "could not open $ARGV for reading";
55 @lines = <FILEIN>;
56 close( FILEIN );
57 open( FILEOUT, ">$ARGV.tmp" ) || die "could not open $ARGV.tmp for writing";
60 foreach $_ (@lines)
62 $lineCount++;
63 if ( $lineCount == 10 )
65 $lineCount = 0;
66 print ".";
68 # change [TITLE] tag
69 s#\[TITLE\]#$title#go;
71 # change [PRODUCTNAME] tag
72 s#\[PRODUCTNAME\]#$productname#go;
74 # change color #003399 to #$color1 if color1 was specified!
75 if ( ! "$color1" eq "" )
77 s/#003399/$color1/go;
80 # change color #99CCFF to #$color2 if color2 was specified!
81 if ( ! "$color2" eq "" )
83 s/#99CCFF/$color2/go;
85 print FILEOUT $_;
87 print " OK\n";
89 close FILEOUT;
90 chmod 0666, $ARGV;
91 rename "$ARGV.tmp", $ARGV || die "could not rename $ARGV.tmp to $ARGV";
94 exit $return;