
/*
 * $Header: c:\\cygwin\\cvsroot/Vert03/acf_src/acf_main.c,v 1.1.1.1 2003/11/04 23:34:58 mjames
 Exp $
 *
 * $Log: acf_main.c,v $
 * Revision 1.1.1.1  2003/11/04 23:34:58  mjames
 * Imported into local repositrory
 *
 * Revision 1.17  2002/10/02 19:37:30  MJAMES
 * Moved dummy functions to a separate support file.
 *
 * Used correct number of arguments to define_pin
 *
 * Revision 1.16  2002/08/14 11:59:42  mjames
 * Initialised the include file stack pointer as this was not done previously
 *
 * Revision 1.15  2002/08/06 12:56:20  mjames
 * Merge in from latest version
 *
 *
 * Revision 1.16  2002/08/06 08:57:16  mjames
 * Updated copyright message
 *
 * Revision 1.15  2002/03/21 17:18:00  mjames
 * Added search path to vertical file opening for read,
 * altered order of setting up initial variable values and
 * then reading init file before handling the user's file
 *
 * Revision 1.14  2002/01/16 10:05:17  mjames
 * Tidied up copyright messages
 *
 * Revision 1.13  2002/01/02 10:47:07  mjames
 * Changed year on date in copyright message
 *
 * Revision 1.12  2001/12/24 21:15:23  mjames
 * Switched to #ident
 *
 * Revision 1.11  2001/11/19 10:41:54  mjames
 * Merged back DTC release
 *
 * Revision 1.10.2.1  2001/11/16 15:10:23  mjames
 * Suppressed an error message that TH was worried about
 *
 * Revision 1.10  2001/10/31 22:19:57  mjames
 * Tidying up problematical comments caused by CVS
 * 'intelligent' comment guessing
 *
 * Revision 1.9  2001/09/28 14:34:13  mjames
 * FIxed yydebug variable to exist when YYDEBUG macro
 * is not defined. Otherwise linker error will be reported.
 *
 * Revision 1.8  2001/09/16 20:01:49  mjames
 * changed command prompt
 *
 * Revision 1.7  2001/07/09 10:05:27  mjames
 * Placed the version string in an independent file to save time on building
 * all of the variants of Vertical
 *
 * Revision 1.6  2001/06/19 05:26:12  mjames
 * reordered the error message about inability to open file and
 * modifying argc to correctly print missing file name if given on
 * the command line
 *
 * Revision 1.5  2001/06/06 12:10:27  mjames
 * Move from HPUX
 *
 * Revision 1.4  2001/02/06 22:41:14  mjames
 * Added correct argument passing for 'read file comp_suffix arg0 arg1 arg2 ...
 *
 * Revision 1.3  2001/01/04 21:26:53  mjames
 * Modifications to add in the TCL style
 * argument list to all of the functions
 * .
 *
 * Revision 1.2  2000/10/19 22:35:44  mjames
 * Moved VERTICAL banner accross
 *
 * Revision 1.1.1.1  2000/10/19 21:58:34  mjames
 * Mike put it here

*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if defined HAS_TCL
#include "tcl_l.h"
#endif
#include "cmdlog.h"
#include "cmdparse.h"
#include "cmdutil.h"
#include "database.h"
#include "expression.h"
#include "generic.h"
#include "lx_support.h"
#include "printout.h"
#include "routing.h"
#include "vertcl_main.h"
#if defined YYDEBUG
extern int yydebug;
#else
int yydebug = 0;
#endif

#ident                                                                                        \
    "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/acf_src/acf_main.c,v 1.1.1.1 2003/11/04 23:34:58 mjames Exp $"

extern int include_stack_ptr;

int main (int argc, char *argv[])
{
        FILE *TopFile;
        int Status;

        include_stack_ptr = 0;

        /* setup intial path */
        InitialiseData ();

        InitErrorLog ();

        LogSilent ();
        ExecuteString (
            "echo running \\$(VERTICAL_INIT) file name = $(VERTICAL_INIT) ", argc, argv);
        /* this may change search path before argv[1] is opened */
        ExecuteString ("do $(VERTICAL_INIT) ", argc, argv);

        LogVerbose ();

        if (argc > 1)
                TopFile = trap_fopen (argv[1], "r");
        else
                TopFile = stdin;

        if (argc < 2)
                argc = 0;
        else
        {
                argc -= 2;
                argv += 2;
        }
        yy_nArgs = argc;
        yy_Args = argv;

        /* sort out potential argument lists */
        if (!TopFile)
                Log (LOG_ERROR, "ERROR : cannot open input file (%s)\n", argv[1]);
        else
        {
                Log (
                    LOG_GENERAL, "#  ---------------------------------------------------- \n");
                Log (
                    LOG_GENERAL, "# |                                         #          |\n");
                Log (
                    LOG_GENERAL, "# |                                       # #          |\n");
                Log (
                    LOG_GENERAL, "# |  Mikes                                  #          |\n");
                Log (
                    LOG_GENERAL, "# |   EDA              METAL                #          |\n");
                Log (
                    LOG_GENERAL, "# |    Tools                                #          |\n");
                Log (
                    LOG_GENERAL, "# |     And                                 #          |\n");
                Log (
                    LOG_GENERAL, "# |      Libraries                         ###         |\n");
                Log (
                    LOG_GENERAL, "# |----------------------------------------------------|\n");
#if defined PC
                Log (LOG_GENERAL, "# | Version: %30s (PC-CygWin)|\n", Vertical_Version);
#else
                Log (LOG_GENERAL, "# | Version:  %30s (HPUX)    |\n", Vertical_Version);
#endif
                Log (LOG_GENERAL, "# | Compiled: %30s           |\n", Vertical_Time);
                Log (
                    LOG_GENERAL, "# |                                                    |\n");
                Log (
                    LOG_GENERAL, "# | (C) Mike James 1995-2019 mike@hamble.online        |\n");
                Log (
                    LOG_GENERAL, "#  ---------------------------------------------------- \n");

                do
                {
                        if (TopFile == stdin)
                                printf ("Vertical : ");
                        Status =
                            ExecuteCommand (TopFile, argc, argv); /* execute the command from
                                                                     the stdin input stream */
                } while (Status != QUITCMD);
        }
        EndErrorLog ();
        return (0);
}
