//***************************************************************************
// File name : main.c
// Designer : Chih-Chieh Tsao
// Create date: Aug. 30, 2007
// Description:
//
//
//***************************************************************************

#include "locator.h"
#include "startup.h"


int main(int argc, char *argv[])
{

    if(argc != 2)
    {
 	fprintf(stderr, "input error\n format: locator [filename]\n");
        return -1;
    }
    else
    {
        /* parser */
        fprintf(stderr, "\n\t[Parser] start ...\n\n");
        if (parser(argv[1]) != 0)
            exit(1);
        fprintf(stderr, "\n\t[Parser] end successfully!!!\n");
        fprintf(stderr, "\n--------------------------------------------\n");

        /* static loader */
        fprintf(stderr, "\n\t[Static Loader] start ...\n\n");
        if (loader() != 0)
            exit(2);
        fprintf(stderr, "\n\t[Static Loader] end successfully!!!\n");
        fprintf(stderr, "\n--------------------------------------------\n");

        /* static locator */
        fprintf(stderr, "\n\t[Locator] start ...\n\n");
        if (locator(argv[1]) != 0)
            exit(3);
        fprintf(stderr, "\n\t[Locator] end successfully!!!\n");
        fprintf(stderr, "\n--------------------------------------------\n");

        /* startup code */
        fprintf(stderr, "\n\t[Startup Code Attached] start ...\n\n");
        if (startup(argv[1]) != 0)
            exit(4);
        fprintf(stderr, "\n\t[Startup Code Attached] end successfully!!!\n");
        fprintf(stderr, "\n--------------------------------------------\n");
        
    }

    return 0;
}

