#include "comline.hpp"
//#include <exception>
#include <stdio.h>
#include "comline.h"

using namespace NCOMLINE;

/*********************************************************************/
/*                MIDL allocate and free                             */
/*********************************************************************/

void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
{
    return(malloc(len));
}

void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
    free(ptr);
}

#if 0
DWORD WINAPI NCOMLINE::ServerClientThreadProc (void *p1)
{
	CCommandLineServer *data;

	data = static_cast<CCommandLineServer *> (p1);

	WaitForSingleObject (data->m_ClientSemaphore,INFINITE);
	ReleaseSemaphore (data->m_ExitClientSemaphore,1,NULL);
	if (data->m_StartClient)
	{
		SMART_CRITICAL (data->m_Critical);
		data->m_Client = new CCommandLineClient (data->m_Instance);
		data->m_Client->ShowWindow ();
		n_CurClient = data->m_Client;
	}

	ReleaseSemaphore (data->m_ClientSemaphore,1,NULL);

	while (true)
	{
		if (MsgWaitForMultipleObjects (1,&data->m_ExitClientSemaphore,FALSE,INFINITE,QS_ALLEVENTS)==WAIT_OBJECT_0+1)
		{
			MSG msg;
			if (PeekMessage (&msg,NULL,0,0,PM_REMOVE))
			{
				if (msg.message == WM_QUIT)
					break;
				TranslateMessage (&msg);
				DispatchMessage (&msg);
			}
		}
		else
			break;
	}

	return 0;
}
#endif




