summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorMartin Baulig <martin@home-of-linux.org>1998-10-10 21:39:11 +0000
committerMartin Baulig <martin@src.gnome.org>1998-10-10 21:39:11 +0000
commitd1f3444da184f57b22e749340c4858ead9d84f6c (patch)
tree4a864ac4067604377caabfb8c7d9d9b94df0ba9b /perl
parentf3c73befd2cad1813ba868b832907cbd8c828662 (diff)
downloadlibgtop-d1f3444da184f57b22e749340c4858ead9d84f6c.tar.gz
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.
Diffstat (limited to 'perl')
-rw-r--r--perl/ChangeLog5
-rw-r--r--perl/Libgtop.pm4
-rw-r--r--perl/Makefile.PL.in1
-rw-r--r--perl/Names/.cvsignore1
-rw-r--r--perl/Names/MANIFEST5
-rw-r--r--perl/Names/Makefile.PL.in10
-rw-r--r--perl/Names/Names.pm24
-rw-r--r--perl/Names/names.awk88
-rw-r--r--perl/Names/test.pl20
-rwxr-xr-xperl/new.pl6
10 files changed, 158 insertions, 6 deletions
diff --git a/perl/ChangeLog b/perl/ChangeLog
index 1dd10238..6575c5eb 100644
--- a/perl/ChangeLog
+++ b/perl/ChangeLog
@@ -1,5 +1,10 @@
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.
* perl.awk: Make it work with the new format of `features.def'.
diff --git a/perl/Libgtop.pm b/perl/Libgtop.pm
index 3618a457..25055539 100644
--- a/perl/Libgtop.pm
+++ b/perl/Libgtop.pm
@@ -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;
diff --git a/perl/Makefile.PL.in b/perl/Makefile.PL.in
index 45757cbb..87e0ff96 100644
--- a/perl/Makefile.PL.in
+++ b/perl/Makefile.PL.in
@@ -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@'],
diff --git a/perl/Names/.cvsignore b/perl/Names/.cvsignore
new file mode 100644
index 00000000..77b6e8b1
--- /dev/null
+++ b/perl/Names/.cvsignore
@@ -0,0 +1 @@
+Names.xs Makefile blib pm_to_blib Names.c Names.bs Makefile.PL
diff --git a/perl/Names/MANIFEST b/perl/Names/MANIFEST
new file mode 100644
index 00000000..cf3e9ee9
--- /dev/null
+++ b/perl/Names/MANIFEST
@@ -0,0 +1,5 @@
+MANIFEST
+Makefile.PL.in
+Names.pm
+names.awk
+test.pl
diff --git a/perl/Names/Makefile.PL.in b/perl/Names/Makefile.PL.in
new file mode 100644
index 00000000..0b8132c9
--- /dev/null
+++ b/perl/Names/Makefile.PL.in
@@ -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@',
+ );
diff --git a/perl/Names/Names.pm b/perl/Names/Names.pm
new file mode 100644
index 00000000..7bc15410
--- /dev/null
+++ b/perl/Names/Names.pm
@@ -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__
diff --git a/perl/Names/names.awk b/perl/Names/names.awk
new file mode 100644
index 00000000..5ca734f9
--- /dev/null
+++ b/perl/Names/names.awk
@@ -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 "";
+}
diff --git a/perl/Names/test.pl b/perl/Names/test.pl
new file mode 100644
index 00000000..644643dd
--- /dev/null
+++ b/perl/Names/test.pl
@@ -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):
+
diff --git a/perl/new.pl b/perl/new.pl
index 5dabd099..734ec202 100755
--- a/perl/new.pl
+++ b/perl/new.pl
@@ -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";