#!/usr/bin/perl

print <<EOF;

#
# This file was automatically generated by genacc,
# modifications will be lost!
#

PROTOTYPES: DISABLE
EOF

while(<DATA>) {
   chomp;
   if (/::/) {
      $pkg = $_;
      print "\nMODULE = Video::Capture::V4l		PACKAGE = $pkg\n\n";
   } elsif (/^(.*?)(\w+\??)$/) {
      my ($type,$field) = ($1,$2);
      my $ro = $field =~ s/\?$//;

      my $get = "RETVAL = s->$field;";
      my $set = "s->$field = $field;";

      if ($type eq "char *") {
         $get = "RETVAL = s->$field;";
         $set = "strcpy (s->$field, $field);";
      }

      if ($ro) {
         $set = "croak (\"attribute '$field' is readonly\");";
      }

      print <<EOF;

$type
$field(s,$field=0)
	$pkg	s
        $type	$field
        CODE:
	if (items==1)
          { $get }
        else
          { $set }
        OUTPUT:
        RETVAL
EOF
   }
}

__END__
Video::Capture::V4l::Capability
char *name?
int type?
int channels?
int audios?
int maxwidth?
int maxheight?
int minwidth?
int minheight?

Video::Capture::V4l::Channel
int channel
char *name?
int tuners?
U32 flags?
U16 type?
U16 norm

Video::Capture::V4l::Audio
int audio
U16 volume
U16 bass
U16 treble
U32 flags
char *name?
U16 mode
U16 balance
U16 step

Video::Capture::V4l::Picture
U16 brightness
U16 hue
U16 colour
U16 contrast
U16 whiteness
U16 depth
U16 palette

Video::Capture::V4l::Tuner
int tuner
char *name?
unsigned long rangelow?
unsigned long rangehigh?
U32 flags?
U16 mode
U16 signal?

