(file) Return to customizedefs.pl CVS log (file) (dir) Up to [Development] / JSOC

File: [Development] / JSOC / Attic / customizedefs.pl (download)
Revision: 1.6, Wed Aug 10 23:04:16 2011 UTC (11 years, 9 months ago) by arta
Branch: MAIN
CVS Tags: Ver_6-3, Ver_6-2, Ver_6-1, Ver_6-0, Ver_5-14
Changes since 1.5: +1 -1 lines
Add support for 3 new configurable parameters - SUM_NUMSUM, SUM_MAXNUMSUMS, and SUMS_MULTIPLE_PARTNSETS.

#!/usr/bin/perl -w 

use constant kSTATUSOK => 0;
use constant kSTATUSCONF => 1;

use constant kUNKSECTION => 0;
use constant kDEFSSECTION => 1;
use constant kMAKESECTION => 2;

use constant kCONFIGFILE => "config.local";
use constant kHEADER => "base/include/customizeddefs.h";

my($line);
my($section);
my($status);
my(@defs);
my(%defines);
my($adef);
my($defname);
my($val);
my($tmp);

$status = kSTATUSOK;

# create hash table to hold all customizable define names
@defs = qw(SERVER DRMS_LOCAL_SITE_CODE USER PASSWD DBNAME DRMSPGPORT POSTGRES_ADMIN SUMS_MANAGER SUMS_MANAGER_UID SUMS_GROUP SUMLOG_BASEDIR SUMBIN_BASEDIR SUMSERVER SUMPGPORT SUM_NUMSUM SUM_MAXNUMSUM SUMS_TAPE_AVAILABLE SUMS_MULTIPLE_PARTNSETS AUTOSELCOMP LOC_SUMEXP_METHFMT LOC_SUMEXP_USERFMT LOC_SUMEXP_HOSTFMT LOC_SUMEXP_PORTFMT);
foreach $adef (@defs)
{
   $defines{$adef} = 1;
}

$section = kUNKSECTION;
$tmp = kCONFIGFILE;
if (open(CONFLOC, "<$tmp"))
{
   $tmp = kHEADER;
   if (!open(HEADER, ">$tmp"))
   {
      print STDERR "Can't open file '$tmp' for writing.\n"
   }
   else
   {
      while (defined($line = <CONFLOC>))
      {
         chomp($line);

         if ($line =~ /^\#/ || $line =~ /^\s*$/)
         {
            next;
         }

         if ($line =~ /__DEFS__/)
         {
            $section = kDEFSSECTION;
            next;
         }
         elsif ($line =~ /__MAKE__/)
         {
            $section = kMAKESECTION;
            next;
         }

         if ($section == kDEFSSECTION)
         {
            $val = "";

            if ($line =~ /^\s*(\S+)\s+(\S+.*)/)
            {
               $defname = $1;
               $val = $2;
            }
            elsif ($line =~ /^\s*(\S+)\s*/)
            {
               $defname = $1;
            }
            else
            {
               print STDERR "Invalid line '$line' in configuration file.\n";
               $status = kSTATUSCONF;
               last;
            }

            if (defined($defines{$defname}))
            {
               if (length($val) > 0)
               {
                  print HEADER "#ifdef $defname\n  #undef $defname\n#endif\n#define $defname $val\n";
               }
               else
               {
                  print HEADER "#ifdef $defname\n  #undef $defname\n#endif#define $defname\n";
               }
            }
            else
            {
               print STDERR "Invalid parameter '$defname'.\n";
               $status = kSTATUSCONF;
               last;
            }
         }
         elsif ($section == kMAKESECTION)
         {
            # Done - use customizemake.pl to create the custom.mk file from config.local
            last;
         }
         else
         {
            print STDERR "Invalid configuration file format.\n";
            $status = kSTATUSCONF;
         }
      }

      close(HEADER);
   }

   close(CONFLOC);
}

exit($status);

Karen Tian
Powered by
ViewCVS 0.9.4