#!/usr/bin/perl -w

# CALLBACKS umwandeln:

use strict;

print "(*  (C)2000 by Tjabo Kloppenburg <tjabo\@unix-ag.org> *)\n";
print "(*  -+- This is the glade_c to FreePascal Converter -+-*)\n";

if ($#ARGV != 0) {
  print "Usage: gc2pas /glade/project/src/callbacks.c >testapp.pas\n";
  print "       gi2pas /glade/project/src/interface.c >>testapp.pas\n";
  print "       ppc386 testapp.pas\n";
  exit;
}

my $infile = $ARGV[0];
my $firstfuncname = "";

# --------------------------------------------------------------------------

open(INFILE, "<$infile") || die "Infile $infile nicht lesbar!";
my $zeile;
my ($fz1,$fz2,$callback,$widgettyp);

while($zeile = <INFILE>) {
  chop($zeile);
  if ($zeile !~ /^#.*$/) {

    if ($zeile =~ /^void.*$/) {
      chomp($fz1 = <INFILE>);
      chomp($fz2 = <INFILE>);

      if ($fz1 =~ /([^\ ]+)\ +\(([^\ ]+)\ +\*([^\ ]+),$/) {
        $callback  = $1;
        $widgettyp = $2;

        print "procedure $callback(widget : p$widgettyp;  data : pgpointer ); cdecl;\n";
        print "{ var ... }\n";
        print "begin\n";
        print "  (* automagic *)\n";
        print "end;\n\n";
      }

    }

  }
}
close(INFILE);

exit;
# -----------------------------------------------------------------------------

