NAME
GTop - Perl interface to libgtop
SYNOPSIS
use GTop ();
my \$gtop = GTop->new;
DESCRIPTION
Perl interface to libgtop:
http://home-of-linux.org/gnome/libgtop/
CLASSES
EOF
my %constructors = map {$_,1} qw(mountlist proclist proc_map mountentry proc_args map_entry); my %notunion = map {$_,1} qw(mountentry map_entry);
for my $if (sort keys %interface) { local *FH; (my $leaf = $if) =~ s/_(.)/uc $1/e; my $class = sprintf "GTop::%s", ucfirst $leaf; (my $typedef = $class) =~ s/:/_/g;
print BOOTXS " boot_GTop_$if();\n";
print TYPEMAP "$class\tT_PTROBJ\n";
print BOOTINC "typedef glibtop_$if * $typedef;\n";
print BOOTINC qq(\#include "$if.boot"\n);
my(@args) = ('','','','()');
if ($if =~ /^proc_/) {
@args = (', pid', 'pid_t pid', '($pid)', '($$)');
}
elsif ($if =~ /^netload/) {
@args = (', interface', 'char * interface',
'($interface)', '(\'eth0\')');
}
elsif ($if =~ /^mountlist/) {
@args = (', all_fs', 'int all_fs', '($all_fs)', '(1)');
}
elsif ($if =~ /^fsusage/) {
@args = (', disk', 'char *disk', '($disk)', '(\'/\')');
}
print XS <<EOF unless $constructors{$if};
$class $if(gtop$args[0]) GTop gtop $args[1]
CODE:
RETVAL = (glibtop_$if *)safemalloc(sizeof(*RETVAL));
glibtop_get_$if(RETVAL$args[0]);
OUTPUT:
RETVAL
EOF
print TEST <<EOF unless $notunion{$if};
my \$$if = \$gtop->$if$args[3]; print "$if\\n"; for (qw(@{ $interface{$if} })) { s/:\\w+\$//; printf " %s => %d\\n", \$_, \$$if->\$_(); }
EOF
unless ($notunion{$if}) {
print POD "\n=head2 $class\n\n";
print POD "\n my \$$if = \$gtop->$if$args[2];\n\n";
print POD "=over 4\n\n";
}
open FH, ">$if.boot" or die $!;
print FH "static void boot_GTop_$if (void)\n{\n";
for my $entry (@{ $interface{$if} }) {
my $type = 'u_int64_t';
if ($entry =~ s/:(\w+)$//) {
$type = $1;
}
my $field = $entry;
my $method = join '::', $class, $field;
print FH qq{ newGTopXS_$type("$method", glibtop_$if, $field);\n};
unless ($notunion{$if}) {
print POD "\n=item $field\n\n";
print POD " my \$$field = \$$if->$field;\n\n";
}
}
print FH qq{ newXS("$class\::DESTROY", XS_GTop_destroy, __FILE__);\n}
unless $notunion{$if};
print FH "\n}\n";
print POD "\n\n=back\n\n" unless $notunion{$if};
}
print BOOTXS "\n}\n"; print POD <<EOF;
AUTHOR
Doug MacEachern
EOF
close TYPEMAP; close BOOTINC; close BOOTXS; close XS; close POD; close TEST;
my $GTOP_LIB = $ENV{GTOP_LIB} || "."; my $GTOP_INCLUDE = $ENV{GTOP_INCLUDE} || ".";
chomp(my $ginc = `glib-config --cflags`);
WriteMakefile( NAME => 'GTop', VERSION_FROM => 'GTop.pm', INC => "-I$GTOP_INCLUDE $ginc", LIBS => ["-L$GTOP_LIB -lgtop -lgtop_sysdeps -lgtop_common -lglib"], TYPEMAPS => [qw(typemap.gtop typemap)], clean => { FILES => "@{[<*.boot>, <*.gtop>]}", }, 'macro' => { CVSROOT => 'modperl.com:/local/cvs_repository', }, );
sub MY::postamble { return <<'EOF';
cvs_tag : cvs -d $(CVSROOT) tag v$(VERSION_SYM) . @echo update GTop.pm VERSION now EOF }