# Syscall.pm --- define SYS_* for syscall
# Author: Noah Friedman <friedman@splode.com>
# Created: 1997-04-03
# Public domain

# $Id: Syscall.pm,v 1.3 1999/12/30 19:35:33 friedman Exp $

# Commentary:
# Code:

package NF::Syscall;
use Symbol;

use Exporter ();
use vars qw ($VERSION @ISA @EXPORT_OK);
$VERSION     = 1.00;
@ISA         = qw (Exporter);
@EXPORT_OK   = qw (initialize require_soft);


sub initialize
{
  return 1 if ((require_soft ("syscall.ph")
                || require_soft ("sys/syscall.ph")));

  my ($h2ph) = gensym;

  open ($h2ph, "h2ph < /usr/include/sys/syscall.h |")
    || return 0;

  while (<$h2ph>)
    {
      package main;
      next if ($_ !~ /eval .sub SYS_[^ \t]+[ \t]+{[0-9]+;}.;/o);
      eval $_;
    }
  close ($h2ph);
}

sub require_soft
{
  my ($f) = @_;

  foreach $dir (@INC)
    {
      if (-f "$dir/$f")
        {
          require "$f";
          return "$dir";
        }
    }
  return 0;
}

1;
