#!/usr/bin/env perl # # Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved. # Copyright (c) 2015 Intel, Inc. All rights reserved. # $COPYRIGHT$ use strict; use Getopt::Long; # globals my $myfile; my $mylib; my $myprefix; my $mysuffix; my $mycapprefix; # Set to true if the script should merely check for symbols in # the library that are not in the provided output file - useful # for determining if something has changed prior to doing an update my $CHECK_ONLY = 0; # Set to true to suppress most informational messages. Only missing # symbols will be printed. my $QUIET = 0; # Set to true if we just want to see the help message my $HELP = 0; # Set to true if we want to reverse the hiding direction my $REVERSE = 0; GetOptions( "help" => \$HELP, "quiet" => \$QUIET, "check-only" => \$CHECK_ONLY, "prefix=s" => \$myprefix, "suffix=s" => \$mysuffix, "lib=s" => \$mylib, "file=s" => \$myfile, "reverse" => \$REVERSE, ) or die "unable to parse options, stopped"; if ($HELP) { print <$myfile" || die "file could not be opened"; } sub checkCase { if ($_[0] =~ /^[[:upper:]]/) { return 1; } else { return 0; } } foreach my $sym (@symbols) { my $out; if ($REVERSE) { # if the first char is a cap, then use the cap prefix if (checkCase($sym)) { $out = "#define " . $mycapprefix . $sym . $mysuffix; } else { $out = "#define " . $myprefix . $sym . $mysuffix; } } else { $out = "#define " . $sym; } my $diff = $len - length($sym); for (my $i=0; $i < $diff; $i++) { $out = $out . " "; } if ($REVERSE) { $out = $out . $sym . "\n"; } else { # if the first char is a cap, then use the cap prefix if (checkCase($sym)) { $out = $out . $mycapprefix . $sym . $mysuffix . "\n"; } else { $out = $out . $myprefix . $sym . $mysuffix . "\n"; } } if ($myfile ne "") { print FILE $out; } else { print $out; } } if ($myfile ne "") { close FILE; }