##########################################################################
#
# Routine: parse_sms.pl
#
# Purpose: Opens the msc_file and parses the header to get the SMS_id.
#
# Usage:
#    $sms_id = Parse_SMS($msc_file); -- returns sms_id from header of $msc_file
#
# Calls:
#    PrintMsg,  which must be declared prior to this module.
#
# Modification history:
#
#   date    opr     who     reason
# -------- -----  --------  --------------------------------------
# 04/26/02 45738  J.Baum    first version
# 
#########################################################################
sub Parse_SMS($)
{
  my ($msc_file) = @_;
  my $calendar;
  my $inline;
  my $count=0;

  if (!open( MSC_FILE, "<".$msc_file)) {
    PrintMsg("F","Cannot open $msc_file.");
    return;    # no return arguments indicates error
  }
  while (<MSC_FILE>)
  {
    $inline = $_;
    $count++;
    last if ($count>50);
    if ($inline=~/CALENDAR\(/) {
      ($calendar) = ($inline=~m/CALENDAR\((.+?)\)/);
      last;
    }
  }
  close MSC_FILE;

  if ($calendar eq "") {
    PrintMsg("E","Cannot parse header lines of SMS.");
    return;
  }
  return ($calendar);
}
1;
