// Serial Number Reader.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <afx.h>
#include <sys\stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/timeb.h>
/* Main ---------------------------------------------------------------------*/
void main(int argc, char *argv[])
{
	int i = 0, iInstLen = 34;         
	char cFileName[128];
	int  iRet = 0;
	int iNumberInstructions = 0;
	int RUN_TEST_CODE = 1;
	struct stat statBuf;

	/* Timing Code */
	struct timeb startTime, endTime;
	ftime(&startTime);
      

	for(i=1;i<argc;i++)
	{
		if ((argv[i][0] == '/') || (argv[i][0] == '-') )
		{ 
			switch(argv[i][1])
			{
			case 'F':
			case 'f':
			   break;
			case 's':
			case 'S':
			   break;
			case 'P':
			   break;
			case 'p':
			   break;
			case 'c':
			case 'C':
			   break;
			case '1':
			case '2':
			case '3':
			   break;
			case '?':
			   printf("\nFlags for %s\n\n",argv[0]);
			   printf("/F<Filename> :  Test File to Run \n");
			   printf("     default :  %s\n\n",cFileName);
			   printf("/S           :  Pause between print steps\n");
			   printf("/P           :  Print every step\n");
			   printf("/p           :  Print error steps\n");
			   printf("/C           :  Compare Timing (Test Code run 100x)\n\n");
			   printf("/1           :  Run Test Code 1 : File read and executed line by line.\n");
			   printf("                                : Test Code 1 is the default.\n");
			   printf("/2           :  Run Test Code 2 : File read entirely and then executed\n");
			   return;
			   break;
			default:
			   printf("Unknown argument <%s>\n",argv[i]);
			   return;
			   break;
			}
		}
		else 
		{ 
		 printf("\nIncorrect input parameter structure.\n\n");
		 printf("Please type %s /? for help.\n\n", argv[0]);
		 return;
		}
	}


	printf("argc = %d\n",argc);
	for(i = 0;i<argc;i++)
		printf("argv[%d] = %s\n", i, argv[i]);	

	sprintf(cFileName,"%s", argv[0]);  /* default file name */ 

	if (stat(cFileName, &statBuf)!=0) {
		fprintf(stderr,"\n%s couldn't be found!\n\r",cFileName);
	   return;
	}

	ftime(&endTime);
	float fTime = (float)endTime.time
				    +(float)endTime.millitm/(float)1000.0
					-(float)startTime.time-
					(float)startTime.millitm/(float)1000.0;
	fprintf(stderr,"\nTotal Time is %4.3f \n", fTime);

	return;
}
