#include "CommandLine.h"
#include <windows.h> //Sleep's in here, for utils.h
#include "utils.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>


CommandLine::CommandLine( int CmdBufSize )
{
	m_nCmdBufSize = DEFAULT_CMD_LENGTH;

	m_pCommandLine = (char *)malloc( sizeof( char ) * CmdBufSize );
	if ( m_pCommandLine == NULL )
	{
		SLEEP_TILL_DEATH();
	}
	m_nCmdBufSize = CmdBufSize;
	m_pCursor = m_pCommandLine; //cursor is at start of commandline
}


CommandLine::AddOption( char *option )
{
	int i;
	int len = strlen( option );
	
	for( i = 0; i < len && i < m_nCmdBufSize ; i++,m_pCursor++ ) 
	{
		*m_pCursor = option[i];
	}
	*m_pCursor = ' ';
	
	if ( m_pCursor - m_pCommandLine >= m_nCmdBufSize )
		SLEEP_TILL_DEATH( );

	m_pCursor++;
}


char * CommandLine::GetCmdLine( void )
{
	return m_pCommandLine;
}


