New directory. Defines `Libgtop::Names' module with is the Perl interface
1998-10-10 Martin Baulig <martin@home-of-linux.org> * Names: New directory. Defines `Libgtop::Names' module with is the Perl interface of the LibGTop names library.
This commit is contained in:
committed by
Martin Baulig
parent
f3c73befd2
commit
d1f3444da1
@@ -1,3 +1,8 @@
|
||||
1998-10-10 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* Names: New directory. Defines `Libgtop::Names' module with
|
||||
is the Perl interface of the LibGTop names library.
|
||||
|
||||
1998-10-10 Martin Baulig <martin@home-of-linux.org>
|
||||
|
||||
* typemap: New file.
|
||||
|
@@ -11,9 +11,7 @@ require AutoLoader;
|
||||
# Items to export into callers namespace by default. Note: do not export
|
||||
# names by default without a very good reason. Use EXPORT_OK instead.
|
||||
# Do not simply export all your public functions/methods/constants.
|
||||
@EXPORT = qw(
|
||||
|
||||
);
|
||||
@EXPORT = qw[];
|
||||
$VERSION = '0.01';
|
||||
|
||||
bootstrap Libgtop $VERSION;
|
||||
|
@@ -3,6 +3,7 @@ use ExtUtils::MakeMaker;
|
||||
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
|
||||
# the contents of the Makefile that is written.
|
||||
WriteMakefile('NAME' => 'Libgtop',
|
||||
'DIR' => ['Names'],
|
||||
'VERSION_FROM' => '@srcdir@/Libgtop.pm',
|
||||
'TYPEMAPS' => ['@srcdir@/typemap' ],
|
||||
'LIBS' => ['@LIBGTOP_GUILE_LIBS@ @LIBGTOP_EXTRA_LIBS@'],
|
||||
|
1
perl/Names/.cvsignore
Normal file
1
perl/Names/.cvsignore
Normal file
@@ -0,0 +1 @@
|
||||
Names.xs Makefile blib pm_to_blib Names.c Names.bs Makefile.PL
|
5
perl/Names/MANIFEST
Normal file
5
perl/Names/MANIFEST
Normal file
@@ -0,0 +1,5 @@
|
||||
MANIFEST
|
||||
Makefile.PL.in
|
||||
Names.pm
|
||||
names.awk
|
||||
test.pl
|
10
perl/Names/Makefile.PL.in
Normal file
10
perl/Names/Makefile.PL.in
Normal file
@@ -0,0 +1,10 @@
|
||||
# -*-cperl-*-
|
||||
use ExtUtils::MakeMaker;
|
||||
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
|
||||
# the contents of the Makefile that is written.
|
||||
WriteMakefile('NAME' => 'Libgtop::Names',
|
||||
'VERSION_FROM' => '@srcdir@/Names.pm',
|
||||
'LIBS' => ['@LIBGTOP_NAMES_LIBS@ @LIBGTOP_EXTRA_LIBS@'],
|
||||
'DEFINE' => '',
|
||||
'INC' => '@LIBGTOP_NAMES_INCS@',
|
||||
);
|
24
perl/Names/Names.pm
Normal file
24
perl/Names/Names.pm
Normal file
@@ -0,0 +1,24 @@
|
||||
package Libgtop::Names;
|
||||
|
||||
use strict;
|
||||
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
|
||||
|
||||
require Exporter;
|
||||
require DynaLoader;
|
||||
require AutoLoader;
|
||||
|
||||
@ISA = qw(Exporter AutoLoader DynaLoader);
|
||||
# Items to export into callers namespace by default. Note: do not export
|
||||
# names by default without a very good reason. Use EXPORT_OK instead.
|
||||
# Do not simply export all your public functions/methods/constants.
|
||||
@EXPORT_OK = qw[%names %labels %types %descriptions];
|
||||
$VERSION = '0.01';
|
||||
|
||||
bootstrap Libgtop::Names $VERSION;
|
||||
|
||||
# Preloaded methods go here.
|
||||
|
||||
# Autoload methods go after __END__, and are processed by the autosplit program.
|
||||
|
||||
1;
|
||||
__END__
|
88
perl/Names/names.awk
Normal file
88
perl/Names/names.awk
Normal file
@@ -0,0 +1,88 @@
|
||||
BEGIN {
|
||||
print "/* Names.xs */";
|
||||
print "/* This is a generated file. Please modify `names.awk' */";
|
||||
print "";
|
||||
|
||||
print "#ifdef __cplusplus";
|
||||
print "extern \"C\" {";
|
||||
print "#endif";
|
||||
print "#include \"EXTERN.h\"";
|
||||
print "#include \"perl.h\"";
|
||||
print "#include \"XSUB.h\"";
|
||||
print "#ifdef __cplusplus";
|
||||
print "}";
|
||||
print "#endif";
|
||||
print "";
|
||||
print "#undef PACKAGE";
|
||||
print "";
|
||||
print "#include <glibtop.h>";
|
||||
print "#include <glibtop/union.h>";
|
||||
print "#include <glibtop/xmalloc.h>";
|
||||
print "";
|
||||
print "MODULE = Libgtop::Names\t\tPACKAGE = Libgtop::Names";
|
||||
print "";
|
||||
print "PROTOTYPES: ENABLE";
|
||||
print "";
|
||||
}
|
||||
|
||||
function output(line) {
|
||||
split (line, line_fields, /\|/);
|
||||
retval = line_fields[1];
|
||||
feature = line_fields[2];
|
||||
element_def = line_fields[3];
|
||||
param_def = line_fields[4];
|
||||
|
||||
orig = feature; sub(/^@/,"",feature);
|
||||
space = feature; gsub(/./," ",space);
|
||||
|
||||
features[feature] = feature;
|
||||
}
|
||||
|
||||
/^[^#]/ { output($0) }
|
||||
|
||||
END {
|
||||
print "BOOT:";
|
||||
print "{";
|
||||
print "\tHV *names = perl_get_hv (\"Libgtop::Names::names\", TRUE);";
|
||||
print "\tHV *labels = perl_get_hv (\"Libgtop::Names::labels\", TRUE);";
|
||||
print "\tHV *types = perl_get_hv (\"Libgtop::Names::types\", TRUE);";
|
||||
print "\tHV *descriptions = perl_get_hv (\"Libgtop::Names::descriptions\", TRUE);";
|
||||
print "\tAV *array;";
|
||||
print "\tSV *ref;";
|
||||
print "\tint i;";
|
||||
|
||||
for (feature in features) {
|
||||
print "\tarray = newAV ();";
|
||||
print "\tref = newRV_inc ((SV*)array);";
|
||||
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
|
||||
print "\t{";
|
||||
print "\t\tav_push (array, newSVpv ((char*)glibtop_names_"feature" [i], 0));";
|
||||
print "\t}";
|
||||
print "\thv_store (names, \""feature"\", "length(feature)+1", ref, 0);";
|
||||
print "\tarray = newAV ();";
|
||||
print "\tref = newRV_inc ((SV*)array);";
|
||||
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
|
||||
print "\t{";
|
||||
print "\t\tav_push (array, newSVpv ((char*)_(glibtop_labels_"feature" [i]), 0));";
|
||||
print "\t}";
|
||||
print "\thv_store (labels, \""feature"\", "length(feature)+1", ref, 0);";
|
||||
print "\tarray = newAV ();";
|
||||
print "\tref = newRV_inc ((SV*)array);";
|
||||
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
|
||||
print "\t{";
|
||||
print "\t\tav_push (array, newSViv (glibtop_types_"feature" [i]));";
|
||||
print "\t}";
|
||||
print "\thv_store (types, \""feature"\", "length(feature)+1", ref, 0);";
|
||||
|
||||
print "\tarray = newAV ();";
|
||||
print "\tref = newRV_inc ((SV*)array);";
|
||||
print "\tfor (i = 0; i < GLIBTOP_MAX_"toupper(feature)"; i++)";
|
||||
print "\t{";
|
||||
print "\t\tav_push (array, newSVpv ((char*)_(glibtop_descriptions_"feature" [i]), 0));";
|
||||
print "\t}";
|
||||
print "\thv_store (descriptions, \""feature"\", "length(feature)+1", ref, 0);";
|
||||
}
|
||||
|
||||
print "}";
|
||||
print "";
|
||||
}
|
20
perl/Names/test.pl
Normal file
20
perl/Names/test.pl
Normal file
@@ -0,0 +1,20 @@
|
||||
# Before `make install' is performed this script should be runnable with
|
||||
# `make test'. After `make install' it should work as `perl test.pl'
|
||||
|
||||
######################### We start with some black magic to print on failure.
|
||||
|
||||
# Change 1..1 below to 1..last_test_to_print .
|
||||
# (It may become useful if the test is moved to ./t subdirectory.)
|
||||
|
||||
BEGIN { $| = 1; print "1..1\n"; }
|
||||
END {print "not ok 1\n" unless $loaded;}
|
||||
use Libgtop::Names;
|
||||
$loaded = 1;
|
||||
print "ok 1\n";
|
||||
|
||||
######################### End of black magic.
|
||||
|
||||
# Insert your test code below (better if it prints "ok 13"
|
||||
# (correspondingly "not ok 13") depending on the success of chunk 13
|
||||
# of the test code):
|
||||
|
@@ -8,9 +8,9 @@ use Libgtop;
|
||||
|
||||
my $server = Libgtop->new;
|
||||
|
||||
print "CPU Usage: ".join (':', $server->cpu)."\n";
|
||||
print "Memory Usage: ".join (':', $server->mem)."\n";
|
||||
print "Swap Usage: ".join (':', $server->swap)."\n";
|
||||
print "CPU Usage: ".join (' ', $server->cpu)."\n";
|
||||
print "Memory Usage: ".join (' ', $server->mem)."\n";
|
||||
print "Swap Usage: ".join (' ', $server->swap)."\n";
|
||||
|
||||
print "Process List: ".join (' ', $server->proclist (0,0))."\n";
|
||||
|
||||
|
Reference in New Issue
Block a user