#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/kdev_t.h>
#include <rsbac/types.h>
#include <rsbac/syscalls.h>
#include <rsbac/getname.h>
#include <rsbac/error.h>

int main(int argc, char ** argv)
{
  int res = 0;
  int correct;
  char name[80];
  char * progname;
  
  progname = argv[0];
  if (argc == 2)
    {
      correct=strtol(argv[1],0,0);
      res = rsbac_check(correct);
      if(res)
        {
          if((res > -RSBAC_EPERM) || (res < -RSBAC_EDECISIONMISMATCH))
            fprintf(stderr,"%s: error: %s\n", progname, strerror(-res));
          else
            {
              get_error_name(name,res);
              fprintf(stderr,"%s: error: %s\n", progname, name);
            }
          exit(1);
        }
    }
  else
    {
      printf("%s (RSBAC %s)\n***\n", argv[0], VERSION);
      printf("Use: %s correct\n", progname);
      printf("     if correct != 0 correct errors\n");
    }
  return (res);
}

