Files
libgtop/sysdeps/guile/guile.awk
Martin Baulig 954a78f200 New file.
1998-07-22  Martin Baulig  <martin@home-of-linux.org>

	* include/glibtop/fsusage.h: New file.

	* features.def: Added new feature `fsusage'.

	* sysdeps/common/fsusage.c (glibtop_get_fsusage_s): New function.
	(get_fs_usage): Declared as `static'.

	* sysdeps/names/fsusage.c: New file.
1998-07-22 22:56:09 +00:00

94 lines
2.8 KiB
Awk

BEGIN {
print "/* guile.c */";
print "/* This is a generated file. Please modify `guile.awk' */";
print "";
print "#include <glibtop.h>";
print "#include <glibtop/xmalloc.h>";
print "#include <glibtop/sysdeps.h>";
print "";
print "#include <guile/gh.h>";
print "";
convert["long"] = "gh_long2scm ";
convert["ulong"] = "gh_ulong2scm ";
convert["double"] = "gh_double2scm";
convert["str"] = "gh_str02scm ";
convert["char"] = "gh_char2scm ";
}
/^(\w+)/ {
features[$1] = $1;
if ($1 ~ /^proclist$/) {
output = "SCM\nglibtop_guile_get_proclist (void)\n{\n";
output = output"\tglibtop_proclist proclist;\n\tunsigned i, *ptr;\n";
output = output"\tSCM list;\n\n\tptr = glibtop_get_proclist (&proclist);\n\n";
output = output"\tlist = gh_list (gh_ulong2scm ("$1".flags),\n\t\t\t";
} else {
if ($1 ~ /^proc_/) {
output = "SCM\nglibtop_guile_get_"$1" (SCM pid)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1", (pid_t) gh_scm2long (pid));\n\n";
} else if ($1 ~ /^fsusage$/) {
output = "SCM\nglibtop_guile_get_"$1" (SCM mountdir)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1", gh_scm2newstr (mountdir, NULL));\n\n";
} else {
output = "SCM\nglibtop_guile_get_"$1" (void)\n{\n";
output = output"\tglibtop_"$1" "$1";\n\n";
output = output"\tglibtop_get_"$1" (&"$1");\n\n";
}
output = output"\treturn gh_list (gh_ulong2scm ("$1".flags),\n\t\t\t";
}
nr_elements = split ($2, elements, /:/);
for (element = 1; element <= nr_elements; element++) {
list = elements[element];
type = elements[element];
sub(/\(.*/, "", type);
sub(/^\w+\(/, "", list); sub(/\)$/, "", list);
count = split (list, fields, /,/);
for (field = 1; field <= count; field++) {
output = output""convert[type]" ("$1"."fields[field]"),\n\t\t\t";
}
}
output = output"SCM_UNDEFINED);";
print output;
if ($1 ~ /^proclist$/) {
print "";
print "\tif (ptr) {";
print "\t\tfor (i = 0; i < proclist.number; i++)";
print "\t\t\tlist = scm_append";
print "\t\t\t\t(gh_list (list,";
print "\t\t\t\t\t gh_list (gh_ulong2scm ((unsigned long) ptr [i])),";
print "\t\t\t\t\t SCM_UNDEFINED));";
print "\t}";
print "";
print "\tglibtop_free (ptr);";
print "";
print "\treturn list;";
}
print "}";
print "";
}
END {
print "void";
print "glibtop_boot_guile (void)";
print "{";
for (feature in features) {
if (feature ~ /^proc_/) {
print "\tgh_new_procedure1_0";
} else if (feature ~ /^fsusage$/) {
print "\tgh_new_procedure1_0";
} else {
print "\tgh_new_procedure0_0";
}
print "\t\t(\"glibtop-get-"feature"\", glibtop_guile_get_"feature");";
}
print "}";
}