/* accton.c */

/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.

This file contains the code for GNU accton.

The GNU Accounting Utilities are free software; you can redistribute
them and/or modify them under the terms of the GNU General Public
License as published by the Free Software Foundation; either version
2, or (at your option) any later version.

The GNU Accounting Utilities are distributed in the hope that they will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with the GNU Accounting Utilities; see the file COPYING.  If
not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
MA 02139, USA.

Simplified by W. Batelaan NXP B.V.

*/

#include <stdio.h>
#include <sys/types.h>
#include <errno.h>

#include <stdlib.h>
#include <unistd.h>

#define ACCT_FILE_LOC "/var/account/pacct"

/* globals */

char *program_name;		/* name of this executable */


/* protos */

int main(int argc, char *argv[]);
void usage(void);


/* code */

/* Print the default acct file (for accton, lastcomm). */

void
print_acct_file_location (void)
{
  printf ("\nThe system's default process accounting file is %s.\n",
	  ACCT_FILE_LOC);
}

void
usage (void)
{
  printf ("\
Usage: %s [-h] [file]\n\
       [--help]\n",
	  program_name);
  print_acct_file_location ();
}

int main (int argc, char *argv[])
{
  char *acct_file = NULL;

  program_name = argv[0];
  argc--;
  argv++;
  
  if (argc > 1)
  {
      usage ();
      exit (1);
  }

  if (argc > 0)
  {
      if (argv[0][0] == '-')
      {
          usage ();
          exit (1);
      }
      acct_file = argv[0];
  }

  if (acct(acct_file) == -1)
  {
      int err;
      extern int errno;

      err = errno;
      perror ("accton");
      exit (err);
  }

  exit(0);
  return 0;
}

