#! /usr/bin/perl

@cipher = qw(blowfish cast128 cast256 des des3 idea rc2 rc5 rijndael serpent
	     skipjack square tea twofish xtea);
@streams = qw(rc4 seal);
@hash = qw(md5 md4 md2 tiger
	   sha sha256 sha384 sha512 
	   rmd128 rmd160 rmd256 rmd320);

sub enum {
  $x = shift;
  if (!ref($x)) { return $x; }
  elsif (ref($x) eq ARRAY) { return @$x }
  else { die "bad ref"; }
}

sub cross {
  my $x = [];
  foreach my $i (@_) {
    my @y = enum($i);
    if (@$x) {
      my @x = ();
      foreach my $j (@$x) { foreach my $k (@y) { push(@x, $j.$k); } }
      $x = \@x;
    } else {
      $x = \@y;
    }
  }
  return @$x;
}

print <<EOF;
/* -*-c-*-
 *
 * Cipher.xs [generated]
 */

#include <assert.h>

#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>

#include <catacomb/gcipher.h>

EOF
print cross("#include <catacomb/", \@cipher, "-",
	    [qw(ecb cbc cfb counter ofb)], ".h>\n"), "\n";
print cross("#include <catacomb/", \@hash, ".h>\n"), "\n";
print cross("#include <catacomb/", \@hash, "-",
	    [qw(mgf hmac)], ".h>\n"), "\n";
