#!/usr/bin/perl -s

$title = "Centralized Conferencing (XCON) - IETF 65 Agenda";

if ($t)
{
  print "Content-Type: text/plain\n\n";
  print "$title\n\n";
  print "CHAIRS: Alan Johnston <alan\@sipstation.com>\n".
        "        Adam Roach <adam\@nostrum.com>\n\n";
}
else
{
print
  "Content-Type: text/html\n".
  "\n".
  "<HTML><HEAD><TITLE>$title</TITLE></HEAD>\n".
  "<BODY>\n".
  "<H1>$title</h1>\n".
  "\n".
  "<pre>\n".
  "\n".
  "CHAIRS: Alan Johnston &lt;alan&#64;sipstation.com>\n".
  "        Adam Roach &lt;adam&#64;nostrum.com>\n".
  "\n".
  "</pre>\n";
}

foreach $entry (<DATA>)
{
  chop;
  ($time, $name, $topic, $drafts, $presentations) = split(';', $entry);
  if ($time && !$topic)
  {
    if ($t)
    {
      print "\n$name======================================\n\n";
    }
    else
    {
      if ($tod)
      {
        print "</TABLE></CENTER><p>\n";
      }
      print 
      "<h3>$name</h3>\n".
      "<CENTER><TABLE border=1>\n".
      "<TR>\n".
      "  <TH>Time</TH>\n".
      "  <TH>Length</TH>\n".
      "  <TH>Discussion Leader</TH>\n".
      "  <TH>Topic</TH>\n".
      "  <TH>Draft</TH>\n".
      "  <TH>Slides</TH>\n";
    }
    $tod = $time;
    next;
  }
  @drafts = split(',', $drafts);
  @presentations = split(',', $presentations);
  $start = $tod;
  $h = int($tod / 100);
  $m = $tod % 100;
  $m += $time;
  $h += int($m / 60);
  $m %= 60;
  $tod = $h*100 + $m;
  if ($t)
  {
    $name =~ s/<br>//i;
    printf ("%4.4d - %4.4d  $topic\n", $start, $tod);
    print "             $name ($time minutes)\n";
    foreach $draft(@drafts)
    {
      print "             $draft\n";
    }
    print "\n";
  }
  else
  {
    foreach $draft (@drafts)
    {
      if (-e "../../drafts/$draft")
      {
        $draft =~ s/(.*)/<a href="\/xcon\/drafts\/$1">$1<\/a>/;
      }
      else
      {
        if ($f)
        {
          system ("cd ../../drafts; wget http://www.ietf.org/internet-drafts/$draft");
        }
        $draft =~ s/(.*)/<a href="http:\/\/www.ietf.org\/internet-drafts\/$1">$1<\/a><sup>*<\/sup>/;
        $nonlocal++;
      }
    }

    foreach $presentation (@presentations)
    {
      $presentation =~ s/([^.]*)\.(.*)/<a href="slides\/$1.$2">$2<\/a>/;
    }

    print "<TR>\n";
    printf ("  <TD>%4.4d - %4.4d</TD>\n", $start, $tod);
    print "  <TD>$time minutes</TD>\n";
    print "  <TD>$name</TD>\n";
    print "  <TD>$topic</TD>\n";
    print "  <TD>";
    print join ("<BR>",@drafts);
    print "  &nbsp;</TD>\n";
    print "  <TD>";
    print join (", ",@presentations);
    print "  &nbsp;</TD>\n";
    print "</TR>\n";
  }
}


print "</TABLE></CENTER></BODY></HTML>" unless ($t);
# time (in minutes);presenter;topic;drafts,drafts;slides,slides
__DATA__
1740;MONDAY, March 20th, 2006, 1740-1950
5;Chairs;Agenda Bash;;
10;Chairs;Status Update;;
20;Mary Barnes;Framework: Open Issues;draft-ietf-xcon-framework-03.txt;
5;Oscar Novo;Conferencing Common Data Model;draft-novo-xcon-common-data-model-01.txt;
5;Oscar Novo;Conference State Change Protocol;draft-jennings-xcon-cscp-03.txt;
70;Chairs;Protocol Decision;draft-levin-xcon-cccp-04.txt,draft-jennings-xcon-cscp-03.txt,draft-barnes-xcon-ccmp-00.txt,draft-schulzrinne-xcon-comp-00.txt;
15;Gonzalo Camarillo;BFCP Connection Establishment;draft-ietf-xcon-bfcp-connection-00.txt;
