# memory-monitor.pl
# Check the free memory

sub get_memory_status
{
return { 'up' => -1 } if (!&foreign_check("proc"));
&foreign_require("proc", "proc-lib.pl");
local @mem;
eval "\@mem = &proc::get_memory_info()";
if ($@) {
	return { 'up' => -1 };
	}
elsif ($mem[1] < $_[0]->{'min'}) {
	return { 'up' => 0 };
	}
else {
	return { 'up' => 1,
		 'desc' => &text('memory_free', $mem[1]) };
	}
}

sub show_memory_dialog
{
print "<tr> <td><b>$text{'memory_min'}</b></td>\n";
print "<td><input name=min size=8 value='$_[0]->{'min'}'></td> </tr>\n";
}

sub parse_memory_dialog
{
&depends_check($_[0], "proc");
&foreign_require("proc", "proc-lib.pl");
defined(&proc::get_memory_info) || &error($text{'memory_eproc'});
$in{'min'} =~ /^\d+$/ || &error($text{'memory_emin'});
$_[0]->{'min'} = $in{'min'};
}

