/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/

static char sccsid_easn_c[] = "@(#)easn.C	1.3 10/20/92 08:35:53  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	8/10/90

	PROGRAM:	easn
			Compile with CC

*/
/*
	ROUTINE:	Asn.1-Encoder main program

PURPOSE:
	Control the ASN.1-Encoder parse

IN:
	1 argument is the input filename

OUT:
	encoded form sent to standard output

CALLED ROUTINES:
	

	
MODIFICATION HISTORY:


*/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* GLOBAL Variables: */

FILE *vinputfile,*listfile;
char *vinputfilename = "";

#define fileerror(X)	asn_error("File error",(X))
#define usageerror(X)	asn_error("Usage error",(X))


extern FILE *yyin;
extern int yydebug;

void parse_arguments(int argc, char *argv[]);
void asn_error(char *,char *);
int yyparse();
void yygenerate();

main(int argc, char *argv[])

{

   int return_code;

   parse_arguments(argc,argv);
   yydebug = 0;


   return_code = yyparse();


   exit(return_code);
}

void parse_arguments(int argc, char *argv[])

{

   listfile = fopen("/dev/null","w");

   if (argc>1)
      vinputfilename = argv[1];

	/* If an input file is specified, take open it for input to lex,
	   otherwise take input from stdin */


   if (strlen(vinputfilename)==0)
      yyin = stdin;
   else
   {
      yyin = fopen(vinputfilename,"r");
   }
   if (yyin==NULL)
      fileerror("Can't open primary input file");


}


/*
	ROUTINE:	asn_error

PURPOSE:
	print an error message raised during the parse

IN:
	s - category of error
	t - specific error

OUT:

CALLED ROUTINES:
	

	
MODIFICATION HISTORY:


*/


void asn_error(char *s, char *t)

{
   extern int vlinenumber;

   /*fprintf(listfile,"<<<\nFile %s,  Line %d  %s: %s\n",vinputfilename,vlinenumber,s,t);*/
   printf("File %s,  Line %d,  %s: %s\n",vinputfilename,vlinenumber,s,t);
   exit(1);
}

int yywrap()

{
   return(1);	/* always return 1*/
}

