#!/usr/bin/perl

die "can not open program" unless (open (PP, "showrgb |"));

$DATE=`date`;
$HOST=`hostname`;
chomp ($DATE);
chomp ($HOST);
print <<EOD0;
//
// Generated by rgb.pl 
// Hostname: $HOST
// Date: $DATE
//

typedef struct SS_RGBStruct 
{
  char* name;
  int red;
  int green;
  int blue;
} _SS_RGBStruct;

SS_RGBStruct rgb_colors[] =
{
EOD0
while (<PP>)
{
  chomp ();
  next if (split != 4);
  $was= " { \"$_[3]\", $_[0], $_[1], $_[2] }";
  printf ("%s,\n", $was);
}
printf (" { 0, 0, 0, 0 } \n");
close (PP);

print <<EOD2;
};
EOD2

exit (0);
