/*
* Copyright (C) 2008, Alexander Sherstnev 
* ------------------------------------------------------
*/
#include <unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#include "num/include/evnt_tools.h"

#include "lem_interface.h"

int main (int argc, char** argv)
{
  int frmt;
  char name[2048];
  FILE * inFile;

  if (argc < 2 || !strcmp (argv[1], "-h")) {
    lem_ShowHelp (0);
    return 0;
  }

  if (!strcmp (argv[1], "-help") || !strcmp (argv[1], "--help")) {
    lem_ShowHelp (1);
    return 0;
  }

  inFile = fopen (argv[1], "r");
  if (!inFile) {
    fprintf (stderr,"lem: (error) file not found: %s\n", argv[1]);
    return -1;
  }
  frmt = CheckFormat (inFile);
  fclose (inFile);
  strcpy (name, argv[1]);

  if (4 == frmt) {
    fprintf (stdout, "lem: lhe format detected in the event file\n");
    lem (name);
  } else {
    fprintf (stderr, "lem: (error) lem works with lhef event files only...\n");
    return -2;
  }

  return 0;
}
