Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS

Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
This commit is contained in:
Cyd
2026-06-24 21:28:16 -05:00
commit 2b8ca921cb
66341 changed files with 7923174 additions and 0 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,642 @@
#include "comline.hpp"
//#include <exception>
#include <stdio.h>
#include "comline.h"
#define COMLINE_WINDOW_NAME "Command Window"
#define COMLINE_WINDOW_CLASS_NAME "COMLINEWindowClass"
namespace NCOMLINE
{
const DWORD c_dwWindowedStyle = WS_OVERLAPPED|WS_VSCROLL;
const DWORD c_dwWindowedStyleEx = WS_EX_WINDOWEDGE;
const int c_FontSize = 12;
const int c_LineSpace = 2;
const int c_FlashTimerID = 37;
const int c_FlashElapse = 125;
const int c_ServerTimerID = 38;
const int c_ServerTimerElapse = 1000;
CCom_String n_Commands[] = // order is VERY important, see the ExecuteCommand function
{
"dumpfile",
"exit",
"attach",
"detach",
"killserver"
};
// CCommandLineClient *n_CurClient;
};
int CCommandLineClient::m_WndClassRefCount = 0;
using namespace NCOMLINE;
void CCommandLineClient::PushLine (const LineData& data)
{
if (m_NumLines == m_SizeLines)
{
int i;
LineData *temp;
temp = new LineData[m_SizeLines+50];
for (i=0;i<m_NumLines;i++)
{
temp[i] = m_Lines[i];
}
delete[] m_Lines;
m_Lines = temp;
m_SizeLines+=50;
}
m_Lines[m_NumLines] = data;
m_NumLines++;
LineData *iter;
iter = &(m_Lines[m_TopDisplay]);
int count=0;
int i;
for (i=m_TopDisplay;i<m_NumLines;i++)
{
count++;
iter++;
}
if (count > m_DisplayLines)
{
int min,max;
m_TopDisplay++;
GetScrollRange (m_Window,SB_VERT,&min,&max);
SetScrollRange (m_Window,SB_VERT,0,max+1,FALSE);
}
}
CCommandLineClient::CCommandLineClient (HINSTANCE inst)
{
m_Instance = inst;
m_Attached = false;
if (!m_WndClassRefCount)
{
WNDCLASS rootclass;
rootclass.style = CS_OWNDC|CS_DBLCLKS;
rootclass.lpfnWndProc = CommandLineWndProc;
rootclass.cbClsExtra = 0;
rootclass.cbWndExtra = sizeof (DWORD);
rootclass.hInstance = m_Instance;
rootclass.hIcon = LoadIcon (NULL,MAKEINTRESOURCE (IDI_APPLICATION));
rootclass.hCursor = LoadCursor (NULL,MAKEINTRESOURCE (IDC_ARROW));
rootclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
rootclass.lpszMenuName = NULL;
rootclass.lpszClassName = COMLINE_WINDOW_CLASS_NAME;
if (!RegisterClass (&rootclass)) // register the class for the command line window
return;
}
m_WndClassRefCount++;
m_Window = CreateWindowEx (c_dwWindowedStyleEx,COMLINE_WINDOW_CLASS_NAME,COMLINE_WINDOW_NAME,c_dwWindowedStyle,
CW_USEDEFAULT,CW_USEDEFAULT,80*12,(50*c_FontSize)+10,NULL,NULL,m_Instance,this);
if (!m_Window)
return;
SetScrollRange (m_Window,SB_VERT,0,1,FALSE);
SetWindowLong (m_Window,GWL_USERDATA,(LONG) this);
SetTimer (m_Window,c_FlashTimerID,c_FlashElapse,NULL);
SetTimer (m_Window,c_ServerTimerID,c_ServerTimerElapse,NULL);
m_Font = CreateFont (-c_FontSize,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,
DEFAULT_PITCH+FF_DONTCARE,"Courier");
m_CursorPen = CreatePen (PS_SOLID,1,RGB (0,0,0));
m_ShowCursor = true;
m_CursorLoc.x = 5;
m_CursorLoc.y = 1;
m_CursorPos = 0;
m_CurrentLine = "";
m_Lines = new NCOMLINE::LineData[50];
m_NumLines = 0;
m_SizeLines = 50;
// m_Lines.clear ();
m_TopDisplay = 0;
PushLine (LineData ("Command Line interface started",LINE_OUTPUT));
m_CurLineColor = RGB (0,0,0 );
m_CommandColor = RGB (128,0,0);
m_ArgColor = RGB (0,128,0);
m_OutColor = RGB (0,0,255);
// NCOMLINE::n_CurClient = this;
}
CCommandLineClient::~CCommandLineClient (void)
{
LineData data ("detach all",LINE_COMMAND);
ParseLine (data);
if (m_Attached)
DetachServer (data);
DeleteObject (m_Font);
DeleteObject (m_CursorPen);
m_WndClassRefCount--;
if (!m_WndClassRefCount)
UnregisterClass (COMLINE_WINDOW_CLASS_NAME,m_Instance);
}
RPC_STATUS CCommandLineClient::AttachServer (NCOMLINE::LineData& data)
{
if (m_Attached)
{
LineData fred ("detach all",LINE_COMMAND);
ParseLine (fred);
DetachServer (fred);
}
char compname[255];
RPC_STATUS status;
unsigned char * pszUuid = (unsigned char *) NULL;
// unsigned char * pszProtocolSequence = (unsigned char *) "ncalrpc";
// unsigned char * pszEndpoint = (unsigned char *) "ComLine";
// unsigned char * pszProtocolSequence = (unsigned char *) "ncacn_ip_tcp";
// unsigned char * pszEndpoint = (unsigned char *) "morfane[1404]";
unsigned char * pszNetworkAddress = (unsigned char *) NULL;
unsigned char * pszOptions = (unsigned char *) NULL;
/*
pszStringBinding = (unsigned char *) NULL;
status = RpCCom_StringBindingCompose(pszUuid,pszProtocolSequence,pszNetworkAddress,pszEndpoint,pszOptions,&pszStringBinding);
if (status)
return status;
*/
if (data.m_NumArgs == 1)
{
sprintf ((char *) pszStringBinding,"ncalrpc:[ComLine]");
}
else
{
CCom_String name;
name = data.m_Data.Mid (data.m_ArgBreak[0]+1,data.m_ArgBreak[1]-data.m_ArgBreak[0]+1);
strcpy (compname,(LPCTSTR) name);
sprintf ((char *) pszStringBinding,"ncacn_ip_tcp:%s[1404]",compname);
}
// pszStringBinding = (unsigned char *) "ncacn_ip_tcp:209.20.251.178[1404]";
/* Set the binding handle that will be used to bind to the server. */
status = RpcBindingFromStringBinding(pszStringBinding,&comline_IfHandle);
if (status)
return status;
m_Attached = true;
return 0;
}
RPC_STATUS CCommandLineClient::DetachServer (NCOMLINE::LineData& data)
{
RPC_STATUS status;
m_Attached = false;
#if 0
status = RpCCom_StringFree(&pszStringBinding); // remote calls done; unbind
if (status)
return (status);
#endif
pszStringBinding[0] = 0;
status = RpcBindingFree(&comline_IfHandle); // remote calls done; unbind
if (status)
return (status);
return 0;
}
void CCommandLineClient::ListServers (void)
{
}
void CCommandLineClient::ShowWindow (void)
{
assert (m_Window);
::ShowWindow (m_Window,SW_SHOW);
GetClientRect (m_Window,&m_WindowRect);
m_DisplayLines = (m_WindowRect.bottom - m_WindowRect.top) / (c_FontSize+c_LineSpace);
}
void CCommandLineClient::HideWindow (void)
{
assert (m_Window);
::ShowWindow (m_Window,SW_HIDE);
}
bool CCommandLineClient::DumpFile (NCOMLINE::LineData& data)
{
CCom_String filename;
if (data.m_NumArgs < 2)
return false;
filename = data.m_Data.Left (data.m_ArgBreak[1]);
filename = filename.Right (data.m_ArgBreak[1] - data.m_ComBreak-1);
return DumpFile (filename);
}
bool CCommandLineClient::DumpFile (const CCom_String& filename)
{
FILE *thefile;
CCom_String temp;
LineData *iter;
int i;
thefile = fopen (filename,"w");
if (!thefile)
return false;
iter = m_Lines;
for (i=0;i<m_NumLines;i++)
{
fprintf (thefile,(LPCTSTR) iter->m_Data);
fprintf (thefile,"\n");
iter++;
}
fprintf (thefile,(LPCTSTR) m_CurrentLine);
temp = "Data dumped to file ";
temp += filename;
PushLine ((LPCTSTR) temp);
if (!fclose (thefile))
return false;
return true;
}
void CCommandLineClient::DumpToFile (const char *filename)
{
DumpFile (filename);
}
void CCommandLineClient::PushLine (const char *line)
{
LineData data(line,LINE_OUTPUT);
PushLine (data);
InvalidateRect (m_Window,NULL,TRUE);
}
void CCommandLineClient::ExecuteLine (const char *line)
{
LineData data(line,LINE_COMMAND);
ParseLine (data);
PushLine (data);
ExecuteLine (data);
}
void CCommandLineClient::KillServer (NCOMLINE::LineData& data)
{
unsigned long ulCode;
m_Attached = false;
RpcTryExcept
{
Shutdown(); // shut down the server side
}
RpcExcept(1)
{
ulCode = RpcExceptionCode();
}
RpcEndExcept
}
void CCommandLineClient::ExecuteLine (LineData& data)
{
int i,count;
CCom_String com;
bool flag = false;
com = data.m_Data.Left (data.m_ComBreak);
count = sizeof (n_Commands) /sizeof (CCom_String);
for (i=0;i<count;i++)
{
if (com == n_Commands[i])
{
switch (i)
{
case 0: //dumpfile
DumpFile (data);
flag = true;
break;
case 1: // exit
PostQuitMessage (0);
flag = true;
break;
case 2: // attach
AttachServer (data);
flag = true;
break;
case 3: //detach
DetachServer (data);
flag = true;
break;
case 4: //kill server
KillServer (data);
flag = true;
break;
}
}
}
if (!flag)
{
if (m_Attached)
{
try
{
::ExecuteLine ((const unsigned char *) ((LPCTSTR) data.m_Data));
}
catch (...)
{
LineData data ("detach all",LINE_COMMAND);
ParseLine (data);
DetachServer (data);
PushLine ("Error: Had to detach from server");
}
}
}
}
void CCommandLineClient::ParseLine (LineData& data)
{
char *buf;
int i,size;
bool ignore;
ignore = false;
data.m_Data.TrimLeft ();
data.m_ComBreak = -1;
size = data.m_Data.GetLength ();
buf = data.m_Data.GetBuffer (0);
for (i=0;i<size;i++,buf++)
{
if ((*buf == ' ') && !ignore)
{
data.m_ArgBreak[data.m_NumArgs] = i;
data.m_NumArgs++;
}
else if (*buf == '\"')
{
ignore = !ignore;
}
}
data.m_Data.ReleaseBuffer ();
data.m_ArgBreak[data.m_NumArgs] = data.m_Data.GetLength ();
data.m_NumArgs++;
data.m_ComBreak = data.m_ArgBreak[0];
}
LRESULT CCommandLineClient::WndProc (HWND thewnd,UINT themsg,WPARAM wParam,LPARAM lParam)
{
switch (themsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
HPEN temppen;
HFONT oldfont;
SIZE TextSize;
BeginPaint (thewnd,&ps);
int curx,cury;
LineData *iter;
int i;
SetTextAlign (ps.hdc,TA_LEFT+TA_TOP);
SetTextColor (ps.hdc,m_CommandColor);
SetBkColor (ps.hdc,RGB (0,0,0));
SetBkMode (ps.hdc,TRANSPARENT);
oldfont = (HFONT) SelectObject (ps.hdc,m_Font);
curx = 0;
cury = 0;
iter = &(m_Lines[m_TopDisplay]);
for (i=m_TopDisplay;i<m_NumLines;i++)
{
if (iter->m_Type == LINE_OUTPUT)
{
SetTextColor (ps.hdc,m_OutColor);
TextOut (ps.hdc,curx,cury,(LPCTSTR)iter->m_Data,iter->m_Data.GetLength ());
}
else if (iter->m_Type == LINE_COMMAND)
{
char *buf;
buf = iter->m_Data.GetBuffer (0);
SetTextColor (ps.hdc,m_CommandColor);
TextOut (ps.hdc,curx,cury,(LPCTSTR)buf,iter->m_ComBreak);
if ((iter->m_Data.GetLength () - iter->m_ComBreak) > 0)
{
GetTextExtentPoint32 ( ps.hdc, (LPCTSTR)buf,iter->m_ComBreak ,&TextSize );
LPtoDP (ps.hdc,(POINT *)&TextSize,1);
curx += TextSize.cx;
SetTextColor (ps.hdc,m_ArgColor);
TextOut (ps.hdc,curx,cury,(LPCTSTR)&(buf[iter->m_ComBreak]),iter->m_Data.GetLength () - iter->m_ComBreak);
}
iter->m_Data.ReleaseBuffer ();
curx = 0;
}
else
{
}
cury += c_FontSize;
cury += c_LineSpace;
iter++;
}
SetTextColor (ps.hdc,m_CurLineColor);
TextOut (ps.hdc,curx,cury,(LPCTSTR)m_CurrentLine,m_CurrentLine.GetLength ());
GetTextExtentPoint32 ( ps.hdc, (LPCTSTR)m_CurrentLine, m_CursorPos ,&TextSize );
LPtoDP (ps.hdc,(POINT *)&TextSize,1);
m_CursorLoc.x = TextSize.cx;
m_CursorLoc.y = cury;
if (m_ShowCursor && m_CursorFlash)
{
temppen = (HPEN) SelectObject (ps.hdc,m_CursorPen);
MoveToEx (ps.hdc,m_CursorLoc.x,m_CursorLoc.y,NULL);
LineTo (ps.hdc,m_CursorLoc.x,m_CursorLoc.y+c_FontSize);
SelectObject (ps.hdc,temppen);
}
SelectObject (ps.hdc,oldfont);
EndPaint (thewnd,&ps);
return 0;
}
break;
case WM_TIMER:
if (wParam == c_FlashTimerID)
{
m_CursorFlash = !m_CursorFlash;
{
RECT temprect;
temprect.left = m_CursorLoc.x;
temprect.top = m_CursorLoc.y;
temprect.right = m_CursorLoc.x+2;
temprect.bottom = m_CursorLoc.y+c_FontSize;
InvalidateRect (m_Window,&temprect,TRUE);
}
}
else if (wParam == c_ServerTimerID)
{
int num,i;
char line[256];
if (m_Attached)
{
try
{
num = NumOutputLines ();
for (i=0;i<num;i++)
{
GetOutputLine (256,(unsigned char *) line);
PushLine (line);
}
}
catch (...)
{
LineData data ("detach all",LINE_COMMAND);
ParseLine (data);
DetachServer (data);
PushLine ("Error: Had to detach from server");
}
}
}
break;
case WM_KEYDOWN:
switch (wParam)
{
case VK_LEFT:
m_CursorPos = clamp<int> (0,m_CursorPos-1,m_CurrentLine.GetLength ());
InvalidateRect (m_Window,NULL,TRUE);
break;
case VK_RIGHT:
m_CursorPos = clamp<int> (0,m_CursorPos+1,m_CurrentLine.GetLength ());
InvalidateRect (m_Window,NULL,TRUE);
break;
case VK_HOME:
m_CursorPos = 0;
InvalidateRect (m_Window,NULL,TRUE);
break;
case VK_END:
m_CursorPos = m_CurrentLine.GetLength ();
InvalidateRect (m_Window,NULL,TRUE);
break;
case VK_DELETE:
m_CurrentLine.Delete (m_CursorPos);
InvalidateRect (m_Window,NULL,TRUE);
break;
}
break;
case WM_VSCROLL:
switch (LOWORD (wParam))
{
case SB_BOTTOM:
break;
case SB_ENDSCROLL:
break;
case SB_LINEDOWN:
break;
case SB_LINEUP:
break;
case SB_PAGEDOWN:
break;
case SB_PAGEUP:
break;
case SB_THUMBPOSITION:
break;
case SB_THUMBTRACK:
break;
case SB_TOP:
break;
}
InvalidateRect (m_Window,NULL,FALSE);
break;
case WM_CHAR:
switch (wParam)
{
case '\b':
if (m_CursorPos)
{
m_CurrentLine.Delete (m_CursorPos-1);
m_CursorPos--;
}
break;
case '\r':
{
m_CurrentLine.Insert (m_CursorPos,'\0');
LineData data(m_CurrentLine,LINE_COMMAND);
ParseLine (data);
PushLine (data);
ExecuteLine (data);
m_CurrentLine = "";
m_CursorPos = 0;
LineData *iter;
iter = &(m_Lines[m_TopDisplay]);
int count=0;
int i;
for (i=m_TopDisplay;i<m_NumLines;i++)
{
count++;
iter++;
}
if (count > m_DisplayLines)
{
int min,max;
m_TopDisplay++;
GetScrollRange (m_Window,SB_VERT,&min,&max);
SetScrollRange (m_Window,SB_VERT,0,max+1,FALSE);
}
}
break;
default:
m_CurrentLine.Insert (m_CursorPos,wParam);
m_CursorPos++;
break;
}
InvalidateRect (m_Window,NULL,TRUE);
break;
}
return DefWindowProc (thewnd,themsg,wParam,lParam);
}
LRESULT WINAPI NCOMLINE::CommandLineWndProc (HWND thewnd,UINT themsg,WPARAM wParam,LPARAM lParam)
{
void *temp;
switch (themsg)
{
case WM_CREATE:
CREATESTRUCT *cs;
cs = (CREATESTRUCT *) lParam;
temp = cs->lpCreateParams;
SetWindowLong (thewnd,GWL_USERDATA,(long) temp);
break;
case WM_DESTROY:
SetWindowLong (thewnd,GWL_USERDATA,0);
break;
default:
CCommandLineClient *fred = (CCommandLineClient *) GetWindowLong (thewnd,GWL_USERDATA);
if (fred)
return fred->WndProc (thewnd,themsg,wParam,lParam);
break;
}
return DefWindowProc (thewnd,themsg,wParam,lParam);
}
@@ -0,0 +1,126 @@
# Microsoft Developer Studio Project File - Name="client" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=client - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "client.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "client.mak" CFG="client - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "client - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "client - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "client - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "client___Win32_Release"
# PROP Intermediate_Dir "client___Win32_Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\Code" /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /I "..\..\Libraries\stlport" /D "NDEBUG" /D "_LIB" /D "COMCLIENT" /D "WIN32" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "client - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "client___Win32_Debug"
# PROP Intermediate_Dir "client___Win32_Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\Code" /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /I "..\..\Libraries\stlport" /D "_DEBUG" /D "_LIB" /D "COMCLIENT" /D "WIN32" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "client - Win32 Release"
# Name "client - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\client.cpp
# End Source File
# Begin Source File
SOURCE=.\comline.cpp
# End Source File
# Begin Source File
SOURCE=.\comline.idl
# End Source File
# Begin Source File
SOURCE=.\comline_c.c
# End Source File
# Begin Source File
SOURCE=.\comutil.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\comline.h
# End Source File
# Begin Source File
SOURCE=.\comline.hpp
# End Source File
# Begin Source File
SOURCE=.\comutil.hpp
# End Source File
# Begin Source File
SOURCE=.\critical.hpp
# End Source File
# End Group
# End Target
# End Project
@@ -0,0 +1,5 @@
[implicit_handle(handle_t comline_IfHandle)]
interface ComLine
{
}
@@ -0,0 +1,64 @@
#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
@@ -0,0 +1,67 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 5.01.0164 */
/* at Sun Sep 12 20:27:38 1999
*/
/* Compiler settings for comline.idl:
Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext, oldnames
error checks: allocation ref bounds_check enum stub_data
*/
//@@MIDL_FILE_HEADING( )
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 440
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __comline_h__
#define __comline_h__
#ifdef __cplusplus
extern "C"{
#endif
/* Forward Declarations */
void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);
void __RPC_USER MIDL_user_free( void __RPC_FAR * );
#ifndef __ComLine_INTERFACE_DEFINED__
#define __ComLine_INTERFACE_DEFINED__
/* interface ComLine */
/* [implicit_handle][version][uuid] */
void ExecuteLine(
/* [string][in] */ const unsigned char __RPC_FAR *pszString);
int NumOutputLines( void);
void GetOutputLine(
/* [in] */ int size,
/* [size_is][string][out] */ unsigned char __RPC_FAR *pszString);
void Shutdown( void);
extern handle_t comline_IfHandle;
extern RPC_IF_HANDLE ComLine_ClientIfHandle;
extern RPC_IF_HANDLE ComLine_ServerIfHandle;
#endif /* __ComLine_INTERFACE_DEFINED__ */
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,237 @@
#pragma once
#ifndef __COMLINEHPP__
#define __COMLINEHPP__
#include <windows.h>
#include "comutil.hpp"
#include "critical.hpp"
class CCommandLineClient;
class CCommandLineServer;
namespace NCOMLINE
{
enum LineType {LINE_UNDEF,LINE_OUTPUT,LINE_COMMAND};
const int MAXARGS = 25;
const int MAXLINES = 100;
struct LineData
{
CCom_String m_Data;
LineType m_Type;
int m_ComBreak;
int m_ArgBreak[MAXARGS];
int m_NumArgs;
void PushArg (int loc)
{
m_ArgBreak[m_NumArgs] = loc;
m_NumArgs++;
}
void Argument (int id,char *arg,int len)
{
assert (id >= 0);
assert (id <m_NumArgs);
arg[0] = 0;
len--;
if (id == 0)
{
if (len < m_ArgBreak[0])
return;
strncpy (arg,(LPCTSTR) m_Data,m_ArgBreak[0]);
len = m_ArgBreak[0];
}
else
{
if (len < (m_ArgBreak[id]-m_ArgBreak[id-1]-1))
return;
strncpy (arg,&(((LPCTSTR) m_Data)[m_ArgBreak[id-1]+1]),(m_ArgBreak[id]-m_ArgBreak[id-1]-1));
len = m_ArgBreak[id]-m_ArgBreak[id-1]-1;
}
// strncpy (arg,(LPCTSTR) name,len);
arg[len] = 0;
}
LineData (void)
{
m_NumArgs = 0;
m_Data.Empty ();
m_ComBreak = 0;
m_Type = LINE_UNDEF;
}
LineData (const CCom_String& p1,LineType p2)
{
m_NumArgs = 0;
m_Data = p1;
m_Type = p2;
}
LineData (const LineData& p1)
{
int i;
for (i=0;i<MAXARGS;i++)
m_ArgBreak[i] = p1.m_ArgBreak[i];
m_Data = p1.m_Data;
m_ComBreak = p1.m_ComBreak;
m_Type = p1.m_Type;
m_NumArgs = p1.m_NumArgs;
}
~LineData (void)
{
}
};
typedef bool (*ComFunc) (CCommandLineServer *thisptr,LineData& p1);
struct CommandMap
{
CCom_String m_Command;
ComFunc m_Function;
CommandMap (void)
{
m_Function = NULL;
m_Command = "";
}
CommandMap (const CommandMap& p1)
{
m_Command = p1.m_Command;
m_Function = p1.m_Function;
}
CommandMap (CCom_String p1,ComFunc p2)
{
m_Command = p1;
m_Function = p2;
}
};
LRESULT WINAPI CommandLineWndProc (HWND thewnd,UINT themsg,WPARAM wParam,LPARAM lParam);
DWORD WINAPI ServerThreadProc (void *data);
extern CCommandLineServer *n_CurServer;
};
#ifdef LAB_ONLY
#define COMSPEW(x) if(NCOMLINE::n_CurServer)NCOMLINE::n_CurServer->PushLine (x)
#else
#define COMSPEW(x) ((void)0)
#endif
typedef void (* CommandLineCallProc) (int);
#ifdef COMCLIENT
class CCommandLineClient
{
friend LRESULT WINAPI NCOMLINE::CommandLineWndProc (HWND thewnd,UINT themsg,WPARAM wParam,LPARAM lParam);
static int m_WndClassRefCount;
private:
HWND m_Window; // window for the command line
NCOMLINE::LineData *m_Lines; // each line that appears in the command line window
int m_NumLines,m_SizeLines;
int m_TopDisplay; // line that is the top of the command window
HFONT m_Font; // font used for text
COLORREF m_CurLineColor; // color of current line
COLORREF m_CommandColor; // color of command on previous lines
COLORREF m_ArgColor; // color of arguments on previous lines
COLORREF m_OutColor; // color of output on previous lines
HPEN m_CursorPen; // pen used to draw the cursor
int m_CursorPos; // pos of cursor within current text
POINT m_CursorLoc; // location of cursor on the screen at top of bar
bool m_ShowCursor; // true if we should show the cursor at all
bool m_CursorFlash; // current state of cursor flash
CCom_String m_CurrentLine; // current line being edited.
RECT m_WindowRect; // size of the window
int m_DisplayLines; // number of lines displayed in the window
unsigned char pszStringBinding[255]; // rpc binding
bool m_Attached;
LRESULT WndProc (HWND thewnd,UINT themsg,WPARAM wParam,LPARAM lParam);
void ParseLine (NCOMLINE::LineData& data);
void ExecuteLine (NCOMLINE::LineData& data);
bool DumpFile (NCOMLINE::LineData& data);
void KillServer (NCOMLINE::LineData& data);
HINSTANCE m_Instance; // main application instance
bool DumpFile (const CCom_String& filename);
void PushLine (const NCOMLINE::LineData& data);
public:
CCommandLineClient (HINSTANCE inst);
~CCommandLineClient (void);
void ExecuteLine (const char *line);
void PushLine (const char *line);
void DumpToFile (const char *filename);
RPC_STATUS AttachServer (NCOMLINE::LineData& data);
RPC_STATUS DetachServer (NCOMLINE::LineData& data);
void ListServers (void);
void ShowWindow (void);
void HideWindow (void);
};
#endif
#ifdef COMSERVER
class CCommandLineServer
{
friend DWORD WINAPI NCOMLINE::ServerThreadProc (void *data);
private:
NCOMLINE::LineData *m_Lines; // each line that appears in the command line window
int m_NumLines,m_SizeLines;
// std::list<NCOMLINE::LineData> m_Lines; // list of lines pending on the server side.
HANDLE m_Thread;
DWORD m_ThreadID;
ROOT_CRITICAL m_Critical;
HANDLE m_Semaphore;
HANDLE m_ExitSemaphore;
HANDLE hMappedFile;
bool m_Inited;
HINSTANCE m_Instance;
NCOMLINE::CommandMap *m_Commands;
int m_NumCommands,m_SizeCommands;
void ParseLine (NCOMLINE::LineData& data);
void PushLine (const NCOMLINE::LineData& data);
void PushCommand (const NCOMLINE::CommandMap& data);
void RemoveLine (void);
public:
CCommandLineServer (void);//,bool startclient = false);
~CCommandLineServer (void);
bool Inited (void) const
{ return m_Inited; }
void ExecuteLine (const char * line);
void PushLine (const char *line);
int NumOutputLines(void);
void GetOutputLine(int size,unsigned char * pszString);
bool AddCommand (NCOMLINE::ComFunc func,const CCom_String& name);
bool RemoveCommand (const CCom_String& name);
};
#endif
#endif
@@ -0,0 +1,11 @@
[
uuid(43750760-625d-11d3-9155-00aa00c14b4e),
version(1.0),
]
interface ComLine
{
void ExecuteLine([in, string] const char * pszString);
int NumOutputLines(void);
void GetOutputLine([in] int size,[out, string, size_is(size)] char * pszString);
void Shutdown(void);
}
@@ -0,0 +1,338 @@
/* this ALWAYS GENERATED file contains the RPC client stubs */
/* File created by MIDL compiler version 5.01.0164 */
/* at Sun Sep 12 20:27:38 1999
*/
/* Compiler settings for comline.idl:
Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext, oldnames
error checks: allocation ref bounds_check enum stub_data
*/
//@@MIDL_FILE_HEADING( )
#include <string.h>
#if defined( _ALPHA_ )
#include <stdarg.h>
#endif
#include "comline.h"
#define TYPE_FORMAT_STRING_SIZE 17
#define PROC_FORMAT_STRING_SIZE 19
typedef struct _MIDL_TYPE_FORMAT_STRING
{
short Pad;
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
} MIDL_TYPE_FORMAT_STRING;
typedef struct _MIDL_PROC_FORMAT_STRING
{
short Pad;
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
} MIDL_PROC_FORMAT_STRING;
extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
/* Standard interface: ComLine, ver. 1.0,
GUID={0x43750760,0x625d,0x11d3,{0x91,0x55,0x00,0xaa,0x00,0xc1,0x4b,0x4e}} */
handle_t comline_IfHandle;
static const RPC_CLIENT_INTERFACE ComLine___RpcClientInterface =
{
sizeof(RPC_CLIENT_INTERFACE),
{{0x43750760,0x625d,0x11d3,{0x91,0x55,0x00,0xaa,0x00,0xc1,0x4b,0x4e}},{1,0}},
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
0,
0,
0,
0,
0,
0
};
RPC_IF_HANDLE ComLine_ClientIfHandle = (RPC_IF_HANDLE)& ComLine___RpcClientInterface;
extern const MIDL_STUB_DESC ComLine_StubDesc;
static RPC_BINDING_HANDLE ComLine__MIDL_AutoBindHandle;
void ExecuteLine(
/* [string][in] */ const unsigned char __RPC_FAR *pszString)
{
RPC_BINDING_HANDLE _Handle = 0;
RPC_MESSAGE _RpcMessage;
MIDL_STUB_MESSAGE _StubMsg;
if(!pszString)
{
RpcRaiseException(RPC_X_NULL_REF_POINTER);
}
RpcTryFinally
{
NdrClientInitializeNew(
( PRPC_MESSAGE )&_RpcMessage,
( PMIDL_STUB_MESSAGE )&_StubMsg,
( PMIDL_STUB_DESC )&ComLine_StubDesc,
0);
_Handle = comline_IfHandle;
_StubMsg.BufferLength = 12U;
NdrConformantStringBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR *)pszString,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[4] );
NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
NdrConformantStringMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg,
(unsigned char __RPC_FAR *)pszString,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[4] );
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
}
RpcFinally
{
NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
}
RpcEndFinally
}
int NumOutputLines( void)
{
RPC_BINDING_HANDLE _Handle = 0;
int _RetVal;
RPC_MESSAGE _RpcMessage;
MIDL_STUB_MESSAGE _StubMsg;
RpcTryFinally
{
NdrClientInitializeNew(
( PRPC_MESSAGE )&_RpcMessage,
( PMIDL_STUB_MESSAGE )&_StubMsg,
( PMIDL_STUB_DESC )&ComLine_StubDesc,
1);
_Handle = comline_IfHandle;
_StubMsg.BufferLength = 0U;
NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[6] );
_RetVal = *(( int __RPC_FAR * )_StubMsg.Buffer)++;
}
RpcFinally
{
NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
}
RpcEndFinally
return _RetVal;
}
void GetOutputLine(
/* [in] */ int size,
/* [size_is][string][out] */ unsigned char __RPC_FAR *pszString)
{
RPC_BINDING_HANDLE _Handle = 0;
RPC_MESSAGE _RpcMessage;
MIDL_STUB_MESSAGE _StubMsg;
if(!pszString)
{
RpcRaiseException(RPC_X_NULL_REF_POINTER);
}
RpcTryFinally
{
NdrClientInitializeNew(
( PRPC_MESSAGE )&_RpcMessage,
( PMIDL_STUB_MESSAGE )&_StubMsg,
( PMIDL_STUB_DESC )&ComLine_StubDesc,
2);
_Handle = comline_IfHandle;
_StubMsg.BufferLength = 4U;
NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
*(( int __RPC_FAR * )_StubMsg.Buffer)++ = size;
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[8] );
NdrConformantStringUnmarshall( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR * __RPC_FAR *)&pszString,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[10],
(unsigned char)0 );
}
RpcFinally
{
NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
}
RpcEndFinally
}
void Shutdown( void)
{
RPC_BINDING_HANDLE _Handle = 0;
RPC_MESSAGE _RpcMessage;
MIDL_STUB_MESSAGE _StubMsg;
RpcTryFinally
{
NdrClientInitializeNew(
( PRPC_MESSAGE )&_RpcMessage,
( PMIDL_STUB_MESSAGE )&_StubMsg,
( PMIDL_STUB_DESC )&ComLine_StubDesc,
3);
_Handle = comline_IfHandle;
_StubMsg.BufferLength = 0U;
NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
}
RpcFinally
{
NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
}
RpcEndFinally
}
static const MIDL_STUB_DESC ComLine_StubDesc =
{
(void __RPC_FAR *)& ComLine___RpcClientInterface,
MIDL_user_allocate,
MIDL_user_free,
&comline_IfHandle,
0,
0,
0,
0,
__MIDL_TypeFormatString.Format,
1, /* -error bounds_check flag */
0x10001, /* Ndr library version */
0,
0x50100a4, /* MIDL Version 5.1.164 */
0,
0,
0, /* notify & notify_flag routine table */
1, /* Flags */
0, /* Reserved3 */
0, /* Reserved4 */
0 /* Reserved5 */
};
#if !defined(__RPC_WIN32__)
#error Invalid build platform for this stub.
#endif
static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
{
0,
{
0x4d, /* FC_IN_PARAM */
#ifndef _ALPHA_
0x1, /* x86, MIPS & PPC Stack size = 1 */
#else
0x2, /* Alpha Stack size = 2 */
#endif
/* 2 */ NdrFcShort( 0x2 ), /* Type Offset=2 */
/* 4 */ 0x5b, /* FC_END */
0x5c, /* FC_PAD */
/* 6 */ 0x53, /* FC_RETURN_PARAM_BASETYPE */
0x8, /* FC_LONG */
/* 8 */ 0x4e, /* FC_IN_PARAM_BASETYPE */
0x8, /* FC_LONG */
/* 10 */
0x51, /* FC_OUT_PARAM */
#ifndef _ALPHA_
0x1, /* x86, MIPS & PPC Stack size = 1 */
#else
0x2, /* Alpha Stack size = 2 */
#endif
/* 12 */ NdrFcShort( 0x6 ), /* Type Offset=6 */
/* 14 */ 0x5b, /* FC_END */
0x5c, /* FC_PAD */
/* 16 */ 0x5b, /* FC_END */
0x5c, /* FC_PAD */
0x0
}
};
static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
{
0,
{
NdrFcShort( 0x0 ), /* 0 */
/* 2 */
0x11, 0x8, /* FC_RP [simple_pointer] */
/* 4 */
0x22, /* FC_C_CSTRING */
0x5c, /* FC_PAD */
/* 6 */
0x11, 0x0, /* FC_RP */
/* 8 */ NdrFcShort( 0x2 ), /* Offset= 2 (10) */
/* 10 */
0x22, /* FC_C_CSTRING */
0x44, /* FC_STRING_SIZED */
/* 12 */ 0x28, /* Corr desc: parameter, FC_LONG */
0x0, /* */
#ifndef _ALPHA_
/* 14 */ NdrFcShort( 0x0 ), /* x86, MIPS, PPC Stack size/offset = 0 */
#else
NdrFcShort( 0x0 ), /* Alpha Stack size/offset = 0 */
#endif
0x0
}
};
@@ -0,0 +1,385 @@
/* this ALWAYS GENERATED file contains the RPC server stubs */
/* File created by MIDL compiler version 5.01.0164 */
/* at Sun Sep 12 20:27:38 1999
*/
/* Compiler settings for comline.idl:
Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext, oldnames
error checks: allocation ref bounds_check enum stub_data
*/
//@@MIDL_FILE_HEADING( )
#include <string.h>
#include "comline.h"
#ifdef LAB_ONLY
#define TYPE_FORMAT_STRING_SIZE 17
#define PROC_FORMAT_STRING_SIZE 19
typedef struct _MIDL_TYPE_FORMAT_STRING
{
short Pad;
unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];
} MIDL_TYPE_FORMAT_STRING;
typedef struct _MIDL_PROC_FORMAT_STRING
{
short Pad;
unsigned char Format[ PROC_FORMAT_STRING_SIZE ];
} MIDL_PROC_FORMAT_STRING;
extern const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString;
extern const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString;
/* Standard interface: ComLine, ver. 1.0,
GUID={0x43750760,0x625d,0x11d3,{0x91,0x55,0x00,0xaa,0x00,0xc1,0x4b,0x4e}} */
extern RPC_DISPATCH_TABLE ComLine_DispatchTable;
static const RPC_SERVER_INTERFACE ComLine___RpcServerInterface =
{
sizeof(RPC_SERVER_INTERFACE),
{{0x43750760,0x625d,0x11d3,{0x91,0x55,0x00,0xaa,0x00,0xc1,0x4b,0x4e}},{1,0}},
{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},
&ComLine_DispatchTable,
0,
0,
0,
0,
0
};
RPC_IF_HANDLE ComLine_ServerIfHandle = (RPC_IF_HANDLE)& ComLine___RpcServerInterface;
extern const MIDL_STUB_DESC ComLine_StubDesc;
void __RPC_STUB
ComLine_ExecuteLine(
PRPC_MESSAGE _pRpcMessage )
{
MIDL_STUB_MESSAGE _StubMsg;
const unsigned char __RPC_FAR *pszString;
RPC_STATUS _Status;
((void)(_Status));
NdrServerInitializeNew(
_pRpcMessage,
&_StubMsg,
&ComLine_StubDesc);
( unsigned char __RPC_FAR * )pszString = 0;
RpcTryFinally
{
RpcTryExcept
{
if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[0] );
NdrConformantStringUnmarshall( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR * __RPC_FAR *)&pszString,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[4],
(unsigned char)0 );
if(_StubMsg.Buffer > _StubMsg.BufferEnd)
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
}
RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
RpcEndExcept
ExecuteLine(pszString);
}
RpcFinally
{
}
RpcEndFinally
_pRpcMessage->BufferLength =
(unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer);
}
void __RPC_STUB
ComLine_NumOutputLines(
PRPC_MESSAGE _pRpcMessage )
{
int _RetVal;
MIDL_STUB_MESSAGE _StubMsg;
RPC_STATUS _Status;
((void)(_Status));
NdrServerInitializeNew(
_pRpcMessage,
&_StubMsg,
&ComLine_StubDesc);
RpcTryFinally
{
RpcTryExcept
{
if(_StubMsg.Buffer > _StubMsg.BufferEnd)
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
}
RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
RpcEndExcept
_RetVal = NumOutputLines();
_StubMsg.BufferLength = 4U;
_pRpcMessage->BufferLength = _StubMsg.BufferLength;
_Status = I_RpcGetBuffer( _pRpcMessage );
if ( _Status )
RpcRaiseException( _Status );
_StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer;
*(( int __RPC_FAR * )_StubMsg.Buffer)++ = _RetVal;
}
RpcFinally
{
}
RpcEndFinally
_pRpcMessage->BufferLength =
(unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer);
}
void __RPC_STUB
ComLine_GetOutputLine(
PRPC_MESSAGE _pRpcMessage )
{
MIDL_STUB_MESSAGE _StubMsg;
unsigned char __RPC_FAR *pszString;
int size;
RPC_STATUS _Status;
((void)(_Status));
NdrServerInitializeNew(
_pRpcMessage,
&_StubMsg,
&ComLine_StubDesc);
( unsigned char __RPC_FAR * )pszString = 0;
RpcTryFinally
{
RpcTryExcept
{
if ( (_pRpcMessage->DataRepresentation & 0X0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION )
NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING) &__MIDL_ProcFormatString.Format[8] );
size = *(( int __RPC_FAR * )_StubMsg.Buffer)++;
if(_StubMsg.Buffer > _StubMsg.BufferEnd)
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
}
RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
RpcEndExcept
if(size * 1 < 0)
{
RpcRaiseException(RPC_X_INVALID_BOUND);
}
pszString = NdrAllocate(&_StubMsg,size * 1);
GetOutputLine(size,pszString);
_StubMsg.BufferLength = 12U;
_StubMsg.MaxCount = size;
NdrConformantStringBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR *)pszString,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[10] );
_pRpcMessage->BufferLength = _StubMsg.BufferLength;
_Status = I_RpcGetBuffer( _pRpcMessage );
if ( _Status )
RpcRaiseException( _Status );
_StubMsg.Buffer = (unsigned char __RPC_FAR *) _pRpcMessage->Buffer;
_StubMsg.MaxCount = size;
NdrConformantStringMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg,
(unsigned char __RPC_FAR *)pszString,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[10] );
}
RpcFinally
{
_StubMsg.MaxCount = size;
NdrPointerFree( &_StubMsg,
(unsigned char __RPC_FAR *)pszString,
&__MIDL_TypeFormatString.Format[6] );
}
RpcEndFinally
_pRpcMessage->BufferLength =
(unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer);
}
void __RPC_STUB
ComLine_Shutdown(
PRPC_MESSAGE _pRpcMessage )
{
MIDL_STUB_MESSAGE _StubMsg;
RPC_STATUS _Status;
((void)(_Status));
NdrServerInitializeNew(
_pRpcMessage,
&_StubMsg,
&ComLine_StubDesc);
RpcTryFinally
{
RpcTryExcept
{
if(_StubMsg.Buffer > _StubMsg.BufferEnd)
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
}
RpcExcept( RPC_BAD_STUB_DATA_EXCEPTION_FILTER )
{
RpcRaiseException(RPC_X_BAD_STUB_DATA);
}
RpcEndExcept
Shutdown();
}
RpcFinally
{
}
RpcEndFinally
_pRpcMessage->BufferLength =
(unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer);
}
static const MIDL_STUB_DESC ComLine_StubDesc =
{
(void __RPC_FAR *)& ComLine___RpcServerInterface,
MIDL_user_allocate,
MIDL_user_free,
0,
0,
0,
0,
0,
__MIDL_TypeFormatString.Format,
1, /* -error bounds_check flag */
0x10001, /* Ndr library version */
0,
0x50100a4, /* MIDL Version 5.1.164 */
0,
0,
0, /* notify & notify_flag routine table */
1, /* Flags */
0, /* Reserved3 */
0, /* Reserved4 */
0 /* Reserved5 */
};
static RPC_DISPATCH_FUNCTION ComLine_table[] =
{
ComLine_ExecuteLine,
ComLine_NumOutputLines,
ComLine_GetOutputLine,
ComLine_Shutdown,
0
};
RPC_DISPATCH_TABLE ComLine_DispatchTable =
{
4,
ComLine_table
};
#if !defined(__RPC_WIN32__)
#error Invalid build platform for this stub.
#endif
static const MIDL_PROC_FORMAT_STRING __MIDL_ProcFormatString =
{
0,
{
0x4d, /* FC_IN_PARAM */
#ifndef _ALPHA_
0x1, /* x86, MIPS & PPC Stack size = 1 */
#else
0x2, /* Alpha Stack size = 2 */
#endif
/* 2 */ NdrFcShort( 0x2 ), /* Type Offset=2 */
/* 4 */ 0x5b, /* FC_END */
0x5c, /* FC_PAD */
/* 6 */ 0x53, /* FC_RETURN_PARAM_BASETYPE */
0x8, /* FC_LONG */
/* 8 */ 0x4e, /* FC_IN_PARAM_BASETYPE */
0x8, /* FC_LONG */
/* 10 */
0x51, /* FC_OUT_PARAM */
#ifndef _ALPHA_
0x1, /* x86, MIPS & PPC Stack size = 1 */
#else
0x2, /* Alpha Stack size = 2 */
#endif
/* 12 */ NdrFcShort( 0x6 ), /* Type Offset=6 */
/* 14 */ 0x5b, /* FC_END */
0x5c, /* FC_PAD */
/* 16 */ 0x5b, /* FC_END */
0x5c, /* FC_PAD */
0x0
}
};
static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =
{
0,
{
NdrFcShort( 0x0 ), /* 0 */
/* 2 */
0x11, 0x8, /* FC_RP [simple_pointer] */
/* 4 */
0x22, /* FC_C_CSTRING */
0x5c, /* FC_PAD */
/* 6 */
0x11, 0x0, /* FC_RP */
/* 8 */ NdrFcShort( 0x2 ), /* Offset= 2 (10) */
/* 10 */
0x22, /* FC_C_CSTRING */
0x44, /* FC_STRING_SIZED */
/* 12 */ 0x28, /* Corr desc: parameter, FC_LONG */
0x0, /* */
#ifndef _ALPHA_
/* 14 */ NdrFcShort( 0x0 ), /* x86, MIPS, PPC Stack size/offset = 0 */
#else
NdrFcShort( 0x0 ), /* Alpha Stack size/offset = 0 */
#endif
0x0
}
};
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,366 @@
#ifndef __COMUTILHPP__
#define __COMUTILHPP__
#pragma once
#include <tchar.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <windows.h>
template<typename type>
inline type clamp (const type& min,const type& x,const type& max)
{
if (x < min)
return min;
if (x>max)
return max;
return x;
}
#if 0
template<typename type>
type max(const type& a,const type& b)
{
return (((a) > (b)) ? (a) : (b));
}
template<typename type>
type min(const type& a,const type& b)
{
return (((a) < (b)) ? (a) : (b));
}
#endif
inline bool IsAlNum(BYTE bChar)
{
#pragma warning (disable:4800)
WORD wResult;
BOOL bRc;
bRc = GetStringTypeEx(LOCALE_SYSTEM_DEFAULT, CT_CTYPE1, (LPCTSTR)&bChar, 1, &wResult);
assert(bRc);
return (bool)(wResult & (C1_ALPHA | C1_DIGIT));
}
inline bool IsSpace(BYTE bChar)
{
#pragma warning (disable:4800)
WORD wResult;
BOOL bRc;
bRc = GetStringTypeEx(LOCALE_SYSTEM_DEFAULT, CT_CTYPE1, (LPCTSTR)&bChar, 1, &wResult);
assert(bRc);
return (bool)(wResult & (C1_SPACE));
}
inline bool IsSpace(WORD bChar)
{
#pragma warning (disable:4800)
WORD wResult;
BOOL bRc;
bRc = GetStringTypeEx(LOCALE_SYSTEM_DEFAULT, CT_CTYPE1, (LPCTSTR)&bChar, 2, &wResult);
assert(bRc);
return (bool)(wResult & (C1_SPACE));
}
#define _countof(array) (sizeof(array)/sizeof(array[0]))
#ifdef OLE2ANSI
typedef LPSTR BSTR;
#else
typedef LPWSTR BSTR;// must (semantically) match typedef in oleauto.h
#endif
struct CCom_StringData
{
long nRefs; // reference count
int nDataLength;
int nAllocLength;
// TCHAR data[nAllocLength]
TCHAR* data()
{ return (TCHAR*)(this+1); }
};
bool comline_AfxIsValidString(LPCWSTR lpsz, int nLength = -1);
bool comline_AfxIsValidString(LPCSTR lpsz, int nLength = -1);
bool comline_AfxIsValidAddress(const void* lp,UINT nBytes, bool bReadWrite = true);
int comline_AfxLoadString(UINT nID, LPTSTR lpszBuf, UINT nMaxBuf,HINSTANCE inst);
class CCom_String
{
public:
// Constructors
CCom_String();
CCom_String(const CCom_String& stringSrc);
CCom_String(TCHAR ch, int nRepeat = 1);
CCom_String(LPCTSTR lpsz);
CCom_String(LPCWSTR lpsz);
CCom_String(LPCTSTR lpch, int nLength);
CCom_String(const unsigned char* psz);
// Attributes & Operations
// as an array of characters
int GetLength() const;
bool IsEmpty() const;
void Empty(); // free up the data
TCHAR GetAt(int nIndex) const; // 0 based
TCHAR operator[](int nIndex) const; // same as GetAt
void SetAt(int nIndex, TCHAR ch);
operator LPCTSTR() const; // as a C string
// overloaded assignment
const CCom_String& operator=(const CCom_String& stringSrc);
const CCom_String& operator=(TCHAR ch);
#ifdef _UNICODE
const CCom_String& operator=(char ch);
#endif
const CCom_String& operator=(LPCSTR lpsz);
const CCom_String& operator=(LPCWSTR lpsz);
const CCom_String& operator=(const unsigned char* psz);
// string concatenation
const CCom_String& operator+=(const CCom_String& string);
const CCom_String& operator+=(TCHAR ch);
#ifdef _UNICODE
const CCom_String& operator+=(char ch);
#endif
const CCom_String& operator+=(LPCTSTR lpsz);
friend CCom_String operator+(const CCom_String& string1,
const CCom_String& string2);
friend CCom_String operator+(const CCom_String& string, TCHAR ch);
friend CCom_String operator+(TCHAR ch, const CCom_String& string);
#ifdef _UNICODE
friend CCom_String operator+(const CCom_String& string, char ch);
friend CCom_String operator+(char ch, const CCom_String& string);
#endif
friend CCom_String operator+(const CCom_String& string, LPCTSTR lpsz);
friend CCom_String operator+(LPCTSTR lpsz, const CCom_String& string);
// string comparison
int Compare(LPCTSTR lpsz) const; // straight character
int CompareNoCase(LPCTSTR lpsz) const; // ignore case
int Collate(LPCTSTR lpsz) const; // NLS aware
// simple sub-string extraction
CCom_String Mid(int nFirst, int nCount) const;
CCom_String Mid(int nFirst) const;
CCom_String Left(int nCount) const;
CCom_String Right(int nCount) const;
CCom_String SpanIncluding(LPCTSTR lpszCharSet) const;
CCom_String SpanExcluding(LPCTSTR lpszCharSet) const;
// upper/lower/reverse conversion
void MakeUpper();
void MakeLower();
void MakeReverse();
// trimming whitespace (either side)
void TrimRight();
void TrimLeft();
// searching (return starting index, or -1 if not found)
// look for a single character match
int Find(TCHAR ch) const; // like "C" strchr
int ReverseFind(TCHAR ch) const;
int FindOneOf(LPCTSTR lpszCharSet) const;
// advanced manipulation
int Replace(TCHAR chOld, TCHAR chNew);
int Replace(LPCTSTR lpszOld, LPCTSTR lpszNew);
int Remove(TCHAR chRemove);
int Insert(int nIndex, TCHAR ch);
int Insert(int nIndex, LPCTSTR pstr);
int Delete(int nIndex, int nCount = 1);
// look for a specific sub-string
int Find(LPCTSTR lpszSub) const; // like "C" strstr
// simple formatting
void _cdecl Format(LPCTSTR lpszFormat, ...);
void _cdecl Format(UINT nFormatID,HINSTANCE inst, ...);
void _cdecl FormatHex (char *mem,int count);
void FormatV(LPCTSTR lpszFormat, va_list argList);
#ifndef _MAC
// formatting for localization (uses FormatMessage API)
void _cdecl FormatMessage(LPCTSTR lpszFormat, ...);
void _cdecl FormatMessage(UINT nFormatID,HINSTANCE inst, ...);
#endif
// Windows support
bool LoadString(UINT nID,HINSTANCE inst=NULL); // load from string resource
// 255 chars max
#ifndef _UNICODE
// ANSI <-> OEM support (convert string in place)
void AnsiToOem();
void OemToAnsi();
#endif
#ifndef _AFX_NO_BSTR_SUPPORT
// OLE BSTR support (use for OLE automation)
BSTR AllocSysString() const;
BSTR SetSysString(BSTR* pbstr) const;
#endif
// Access to string implementation buffer as "C" character array
LPTSTR GetBuffer(int nMinBufLength);
void ReleaseBuffer(int nNewLength = -1);
LPTSTR GetBufferSetLength(int nNewLength);
void FreeExtra();
// Use LockBuffer/UnlockBuffer to turn refcounting off
LPTSTR LockBuffer();
void UnlockBuffer();
// Implementation
public:
~CCom_String();
int GetAllocLength() const;
protected:
LPTSTR m_pchData; // pointer to ref counted string data
// implementation helpers
CCom_StringData* GetData() const;
void Init();
void AllocCopy(CCom_String& dest, int nCopyLen, int nCopyIndex, int nExtraLen) const;
void AllocBuffer(int nLen);
void AssignCopy(int nSrcLen, LPCTSTR lpszSrcData);
void ConcatCopy(int nSrc1Len, LPCTSTR lpszSrc1Data, int nSrc2Len, LPCTSTR lpszSrc2Data);
void ConcatInPlace(int nSrcLen, LPCTSTR lpszSrcData);
void CopyBeforeWrite();
void AllocBeforeWrite(int nLen);
void Release();
static void PASCAL Release(CCom_StringData* pData);
static int PASCAL SafeStrlen(LPCTSTR lpsz);
};
// Compare helpers
bool operator==(const CCom_String& s1, const CCom_String& s2);
bool operator==(const CCom_String& s1, LPCTSTR s2);
bool operator==(LPCTSTR s1, const CCom_String& s2);
bool operator!=(const CCom_String& s1, const CCom_String& s2);
bool operator!=(const CCom_String& s1, LPCTSTR s2);
bool operator!=(LPCTSTR s1, const CCom_String& s2);
bool operator<(const CCom_String& s1, const CCom_String& s2);
bool operator<(const CCom_String& s1, LPCTSTR s2);
bool operator<(LPCTSTR s1, const CCom_String& s2);
bool operator>(const CCom_String& s1, const CCom_String& s2);
bool operator>(const CCom_String& s1, LPCTSTR s2);
bool operator>(LPCTSTR s1, const CCom_String& s2);
bool operator<=(const CCom_String& s1, const CCom_String& s2);
bool operator<=(const CCom_String& s1, LPCTSTR s2);
bool operator<=(LPCTSTR s1, const CCom_String& s2);
bool operator>=(const CCom_String& s1, const CCom_String& s2);
bool operator>=(const CCom_String& s1, LPCTSTR s2);
bool operator>=(LPCTSTR s1, const CCom_String& s2);
// conversion helpers
int _cdecl _wcstombsz(char* mbstr, const wchar_t* wcstr, size_t count);
int _cdecl _mbstowcsz(wchar_t* wcstr, const char* mbstr, size_t count);
// Globals
extern TCHAR comline_afxChNil;
const CCom_String& comline_AfxGetEmptyString();
#define comline_afxEmptyString comline_AfxGetEmptyString()
// CCom_String
inline CCom_StringData* CCom_String::GetData() const
{ assert(m_pchData != NULL); return ((CCom_StringData*)m_pchData)-1; }
inline void CCom_String::Init()
{ m_pchData = comline_afxEmptyString.m_pchData; }
inline CCom_String::CCom_String(const unsigned char* lpsz)
{ Init(); *this = (LPCSTR)lpsz; }
inline const CCom_String& CCom_String::operator=(const unsigned char* lpsz)
{ *this = (LPCSTR)lpsz; return *this; }
#ifdef _UNICODE
inline const CCom_String& CCom_String::operator+=(char ch)
{ *this += (TCHAR)ch; return *this; }
inline const CCom_String& CCom_String::operator=(char ch)
{ *this = (TCHAR)ch; return *this; }
inline CCom_String operator+(const CCom_String& string, char ch)
{ return string + (TCHAR)ch; }
inline CCom_String operator+(char ch, const CCom_String& string)
{ return (TCHAR)ch + string; }
#endif
inline int CCom_String::GetLength() const
{ return GetData()->nDataLength; }
inline int CCom_String::GetAllocLength() const
{ return GetData()->nAllocLength; }
inline bool CCom_String::IsEmpty() const
{ return GetData()->nDataLength == 0; }
inline CCom_String::operator LPCTSTR() const
{ return m_pchData; }
inline int PASCAL CCom_String::SafeStrlen(LPCTSTR lpsz)
{ return (lpsz == NULL) ? 0 : lstrlen(lpsz); }
// CCom_String support (windows specific)
inline int CCom_String::Compare(LPCTSTR lpsz) const
{ return _tcscmp(m_pchData, lpsz); } // MBCS/Unicode aware
inline int CCom_String::CompareNoCase(LPCTSTR lpsz) const
{ return _tcsicmp(m_pchData, lpsz); } // MBCS/Unicode aware
// CCom_String::Collate is often slower than Compare but is MBSC/Unicode
// aware as well as locale-sensitive with respect to sort order.
inline int CCom_String::Collate(LPCTSTR lpsz) const
{ return _tcscoll(m_pchData, lpsz); } // locale sensitive
inline TCHAR CCom_String::GetAt(int nIndex) const
{
assert(nIndex >= 0);
assert(nIndex < GetData()->nDataLength);
return m_pchData[nIndex];
}
inline TCHAR CCom_String::operator[](int nIndex) const
{
// same as GetAt
assert(nIndex >= 0);
assert(nIndex < GetData()->nDataLength);
return m_pchData[nIndex];
}
inline bool operator==(const CCom_String& s1, const CCom_String& s2)
{ return s1.Compare(s2) == 0; }
inline bool operator==(const CCom_String& s1, LPCTSTR s2)
{ return s1.Compare(s2) == 0; }
inline bool operator==(LPCTSTR s1, const CCom_String& s2)
{ return s2.Compare(s1) == 0; }
inline bool operator!=(const CCom_String& s1, const CCom_String& s2)
{ return s1.Compare(s2) != 0; }
inline bool operator!=(const CCom_String& s1, LPCTSTR s2)
{ return s1.Compare(s2) != 0; }
inline bool operator!=(LPCTSTR s1, const CCom_String& s2)
{ return s2.Compare(s1) != 0; }
inline bool operator<(const CCom_String& s1, const CCom_String& s2)
{ return s1.Compare(s2) < 0; }
inline bool operator<(const CCom_String& s1, LPCTSTR s2)
{ return s1.Compare(s2) < 0; }
inline bool operator<(LPCTSTR s1, const CCom_String& s2)
{ return s2.Compare(s1) > 0; }
inline bool operator>(const CCom_String& s1, const CCom_String& s2)
{ return s1.Compare(s2) > 0; }
inline bool operator>(const CCom_String& s1, LPCTSTR s2)
{ return s1.Compare(s2) > 0; }
inline bool operator>(LPCTSTR s1, const CCom_String& s2)
{ return s2.Compare(s1) < 0; }
inline bool operator<=(const CCom_String& s1, const CCom_String& s2)
{ return s1.Compare(s2) <= 0; }
inline bool operator<=(const CCom_String& s1, LPCTSTR s2)
{ return s1.Compare(s2) <= 0; }
inline bool operator<=(LPCTSTR s1, const CCom_String& s2)
{ return s2.Compare(s1) >= 0; }
inline bool operator>=(const CCom_String& s1, const CCom_String& s2)
{ return s1.Compare(s2) >= 0; }
inline bool operator>=(const CCom_String& s1, LPCTSTR s2)
{ return s1.Compare(s2) >= 0; }
inline bool operator>=(LPCTSTR s1, const CCom_String& s2)
{ return s2.Compare(s1) <= 0; }
#endif
@@ -0,0 +1,67 @@
#ifndef __CRITICALHPP__
#define __CRITICALHPP__
#include <windows.h>
#include <assert.h>
// macro to help with using the SMART_CRITICAL class
// you can just say CRITICAL_CONTROL(ThreadSafe), this will
// place the current scope in a critical section
#define CRITICAL_CONTROL(x) SMART_CRITICAL crit##x (x)
#define CRITICAL_CONTROL_2(x,y) SMART_CRITICAL crit##x (y)
// class to handle controling critical sections
// you would use this class to create thread safe and exception safe code
// since the LeaveCriticalSection is in the destructor it will automatically
// be called when the class goes out of scope, for instance when the stack
// is unwinding from an exception
class SMART_CRITICAL {
private:
CRITICAL_SECTION *m_Crit;
public:
SMART_CRITICAL (CRITICAL_SECTION& crit)
{
m_Crit = &crit;
EnterCriticalSection (m_Crit);
}
~SMART_CRITICAL (void)
{
LeaveCriticalSection (m_Crit);
}
};
// class to handle global critical sections
// the constructor will automatically init the critical section and
// the destructor will automatically delete the critical section.
// This makes it useful for globals for instance, the class will automatically
// create and destroy the critical section for you.
// Note: for various reason I made it bad to create this class dynamically
class ROOT_CRITICAL : public CRITICAL_SECTION {
public:
ROOT_CRITICAL (void)
{
InitializeCriticalSection (this);
}
ROOT_CRITICAL( const ROOT_CRITICAL&)
{
InitializeCriticalSection( this );
}
~ROOT_CRITICAL (void)
{
DeleteCriticalSection (this);
}
void Lock(void)
{
EnterCriticalSection(this);
}
void Unlock(void)
{
LeaveCriticalSection(this);
}
void *operator new (size_t)
{
assert (false);
return NULL;
}
};
#endif
@@ -0,0 +1,383 @@
#include "comline.hpp"
//#include <exception>
#include <stdio.h>
#include "comline.h"
static void* __cdecl operator new (unsigned int size)
{
return malloc (size);
}
static void __cdecl operator delete (void *buffer)
{
free (buffer);
}
using namespace NCOMLINE;
CCommandLineServer *NCOMLINE::n_CurServer = NULL;
void ExecuteLine(const unsigned char * pszString)
{
if (n_CurServer)
n_CurServer->ExecuteLine ((const char *) pszString);
}
int NumOutputLines(void)
{
if (n_CurServer)
return n_CurServer->NumOutputLines ();
return 0;
}
void GetOutputLine(int size,unsigned char * pszString)
{
if (n_CurServer)
n_CurServer->GetOutputLine (size,pszString);
}
void Shutdown(void)
{
#ifdef LAB_ONLY
RPC_STATUS status;
status = RpcMgmtStopServerListening(NULL);
if (!status)
{
status = RpcServerUnregisterIf(NULL, NULL, FALSE);
}
#endif
}
DWORD WINAPI NCOMLINE::ServerThreadProc (void *p1)
{
#if LAB_ONLY
CCommandLineServer *data;
data = static_cast<CCommandLineServer *> (p1);
WaitForSingleObject (data->m_Semaphore,INFINITE);
ReleaseSemaphore (data->m_ExitSemaphore,1,NULL);
ReleaseSemaphore (data->m_Semaphore,1,NULL);
RPC_STATUS status;
unsigned char * pszProtocolSequence1 = (unsigned char *) "ncacn_ip_tcp";
unsigned char * pszEndpoint1 = (unsigned char *) "1404";
unsigned char * pszProtocolSequence2 = (unsigned char *) "ncalrpc";
unsigned char * pszEndpoint2 = (unsigned char *) "ComLine";
unsigned char * pszSecurity = (unsigned char *) NULL;
unsigned int cMinCalls = 1;
unsigned int cMaxCalls = 20;
unsigned int fDontWait = FALSE;
// status = RpcServerUseAllProtseqs (cMaxCalls,pszSecurity);
status = RpcServerUseProtseqEp(pszProtocolSequence1,cMaxCalls,pszEndpoint1,pszSecurity); // Security descriptor
if (status)
return (status);
status = RpcServerUseProtseqEp(pszProtocolSequence2,cMaxCalls,pszEndpoint2,pszSecurity); // Security descriptor
if (status)
return (status);
RPC_BINDING_VECTOR *inq;
status = RpcServerInqBindings (&inq);
status = RpcServerRegisterIf(ComLine_ServerIfHandle, // interface to register
NULL, // MgrTypeUuid
NULL); // MgrEpv; null means use default
if (status)
return (status);
status = RpcServerListen(cMinCalls,cMaxCalls,fDontWait);
if (status)
return status;
WaitForSingleObject (data->m_ExitSemaphore,INFINITE);
#endif
return 0;
}
void CCommandLineServer::PushLine (const LineData& data)
{
CRITICAL_CONTROL (m_Critical);
if (!m_Inited)
return;
if (m_NumLines == m_SizeLines)
{
int i;
LineData *temp;
temp = new LineData[m_SizeLines+50];
for (i=0;i<m_NumLines;i++)
{
temp[i] = m_Lines[i];
}
delete[] m_Lines;
m_Lines = temp;
m_SizeLines+=50;
}
m_Lines[m_NumLines] = data;
m_NumLines++;
}
void CCommandLineServer::RemoveLine (void)
{
int i;
CRITICAL_CONTROL (m_Critical);
if (!m_Inited)
return;
assert (m_NumLines);
m_NumLines--;
for (i=0;i<m_NumLines;i++)
{
m_Lines[i] = m_Lines[i+1];
}
}
void CCommandLineServer::PushCommand (const CommandMap& data)
{
CRITICAL_CONTROL (m_Critical);
if (!m_Inited)
return;
if (m_NumLines == m_SizeLines)
{
int i;
CommandMap *temp;
temp = new CommandMap[m_SizeCommands+50];
for (i=0;i<m_NumCommands;i++)
{
temp[i] = m_Commands[i];
}
delete[] m_Commands;
m_Commands = temp;
m_SizeCommands+=50;
}
m_Commands[m_NumCommands] = data;
m_NumCommands++;
}
CCommandLineServer::CCommandLineServer (void)
{
m_Inited = false;
m_Lines = NULL;
m_NumLines = 0;
m_SizeLines = 0;
m_Commands = NULL;
m_NumCommands = 0;
m_SizeCommands = 0;
m_Semaphore = NULL;
m_ExitSemaphore = NULL;
m_Thread = NULL;
hMappedFile=NULL;
#if LAB_ONLY
hMappedFile=CreateFileMapping( (HANDLE)0xffffffff, //-1 hFile flag
NULL, // no sharing allowed
PAGE_READONLY|SEC_RESERVE, // no writing or physical space allocated
0, // high-byte size
4, // low byte size
"AHF_COMLINE_FILE"); // use class string as file name
if (hMappedFile!=NULL && GetLastError() == ERROR_ALREADY_EXISTS)
{
//another T2 is running, it just hasn't created it's window yet
CloseHandle(hMappedFile);
hMappedFile=NULL;
return;
}
m_Lines = new LineData[50];
m_NumLines = 0;
m_SizeLines = 50;
PushLine (LineData ("Command Line server started",LINE_OUTPUT));
m_Commands = new CommandMap[50];
m_NumCommands = 0;
m_SizeCommands = 50;
m_Semaphore = CreateSemaphore (NULL,0,1,NULL);
if (!m_Semaphore)
assert (false);
m_ExitSemaphore = CreateSemaphore (NULL,0,1,NULL);
if (!m_ExitSemaphore)
assert (false);
m_Thread = CreateThread (NULL,0,NCOMLINE::ServerThreadProc,(void *) this,0,&m_ThreadID);
if (!m_Thread)
assert (false);
ReleaseSemaphore (m_Semaphore,1,NULL);
WaitForSingleObject (m_ExitSemaphore,INFINITE);
WaitForSingleObject (m_Semaphore,INFINITE);
n_CurServer = this;
m_Inited = true;
#endif
}
CCommandLineServer::~CCommandLineServer (void)
{
if (!m_Inited)
return;
#ifdef LAB_ONLY
RPC_STATUS status;
status = RpcMgmtStopServerListening(NULL);
if (!status)
{
status = RpcServerUnregisterIf(NULL, NULL, FALSE);
}
#endif
n_CurServer = NULL;
ReleaseSemaphore (m_ExitSemaphore,1,NULL);
WaitForSingleObject (m_Thread,INFINITE);
CloseHandle (m_ExitSemaphore);
CloseHandle (m_Semaphore);
CloseHandle (m_Thread);
if (hMappedFile)
CloseHandle (hMappedFile);
hMappedFile = NULL;
delete[] m_Lines;
delete[] m_Commands;
m_Inited = false;
}
void CCommandLineServer::PushLine (const char *line)
{
CRITICAL_CONTROL (m_Critical);
if (!m_Inited)
return;
LineData data (line,LINE_OUTPUT);
PushLine (data);
}
void CCommandLineServer::ExecuteLine (const char *line)
{
CRITICAL_CONTROL (m_Critical);
int iter;
LineData data (line,LINE_COMMAND);
CCom_String name (line);
if (!m_Inited)
return;
ParseLine (data);
if (data.m_ComBreak != name.GetLength ())
{
name.SetAt (data.m_ComBreak,0);
}
for (iter = 0;iter<m_NumCommands;iter++)
{
if (m_Commands[iter].m_Command == name)
break;
}
if (iter != m_NumCommands)
{
if (!m_Commands[iter].m_Function (this,data))
PushLine (LineData ("Function failed",LINE_OUTPUT));
}
else
{
PushLine (LineData ("Function not found",LINE_OUTPUT));
}
}
void CCommandLineServer::ParseLine (LineData& data)
{
char *buf;
int i,size;
bool ignore;
CRITICAL_CONTROL (m_Critical);
ignore = false;
data.m_Data.TrimLeft ();
data.m_ComBreak = -1;
size = data.m_Data.GetLength ();
buf = data.m_Data.GetBuffer (0);
for (i=0;i<size;i++,buf++)
{
if ((*buf == ' ') && !ignore)
{
data.m_ArgBreak[data.m_NumArgs] = i;
data.m_NumArgs++;
}
else if (*buf == '\"')
{
ignore = !ignore;
}
}
data.m_Data.ReleaseBuffer ();
data.m_ArgBreak[data.m_NumArgs] = data.m_Data.GetLength ();
data.m_NumArgs++;
data.m_ComBreak = data.m_ArgBreak[0];
}
int CCommandLineServer::NumOutputLines(void)
{
return m_NumLines;
}
void CCommandLineServer::GetOutputLine(int size,unsigned char * pszString)
{
CRITICAL_CONTROL (m_Critical);
LineData *iter;
iter = m_Lines;
if (m_NumLines)
{
const char *buffer = (LPCTSTR) iter->m_Data;
strncpy ((char *) pszString,buffer,size-1);
pszString[size-1] = 0;
RemoveLine ();
}
else
pszString[0] = 0;
}
bool CCommandLineServer::AddCommand (NCOMLINE::ComFunc func,const CCom_String& name)
{
CRITICAL_CONTROL (m_Critical);
int iter;
if (!m_Inited)
return false;
for (iter = 0;iter<m_NumCommands;iter++)
{
if (m_Commands[iter].m_Command == name)
break;
}
if (iter != m_NumCommands)
m_Commands[iter].m_Function = func;
else
PushCommand (CommandMap (name,func));
return true;
}
bool CCommandLineServer::RemoveCommand (const CCom_String& name)
{
CRITICAL_CONTROL (m_Critical);
int iter;
int i;
if (!m_Inited)
return false;
for (iter = 0;iter<m_NumCommands;iter++)
{
if (m_Commands[iter].m_Command == name)
break;
}
if (iter == m_NumCommands)
return false;
m_NumCommands--;
for (i=iter;i<m_NumCommands;i++)
{
m_Commands[i] = m_Commands[i+1];
}
return true;
}
@@ -0,0 +1,213 @@
# Microsoft Developer Studio Project File - Name="server" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=server - Win32 icecap
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "server.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "server.mak" CFG="server - Win32 icecap"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "server - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "server - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "server - Win32 Armor" (based on "Win32 (x86) Static Library")
!MESSAGE "server - Win32 Profile" (based on "Win32 (x86) Static Library")
!MESSAGE "server - Win32 icecap" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GameLeapCode/mw4/Libraries/server", KPIAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "server - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../../../rel.bin"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /GR /Oa /Og /Oi /Oy /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "RELEASE" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "COMSERVER" /D "NDEBUG" /D "WIN32" /YX /FD /c
# SUBTRACT CPP /WX /Fr
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "server - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "server___Win32_Debug"
# PROP BASE Intermediate_Dir "server___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../dbg.bin"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /G6 /Zp4 /MDd /W3 /GR /Zi /Od /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "LAB_ONLY" /D "USE_PROTOTYPES" /D "STRICT" /D "_ARMOR" /D "_WINDOWS" /D "COMSERVER" /D "WIN32" /D "_DEBUG" /FR /YX /FD /GZ /c
# SUBTRACT CPP /WX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "server - Win32 Armor"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "server___Win32_Armor"
# PROP BASE Intermediate_Dir "server___Win32_Armor"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../arm.bin"
# PROP Intermediate_Dir "Armor"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "COMSERVER" /D "WIN32" /YX /FD /GZ /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /GR /Zi /Ox /Ot /Oa /Og /Oi /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "LAB_ONLY" /D "NDEBUG" /D "_ARMOR" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "WIN32" /D "COMSERVER" /YX /FD /c
# SUBTRACT CPP /WX /Fr
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "server - Win32 Profile"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "server___Win32_Profile"
# PROP BASE Intermediate_Dir "server___Win32_Profile"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../pro.bin"
# PROP Intermediate_Dir "Profile"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "COMSERVER" /D "WIN32" /YX /FD /GZ /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /Zi /O2 /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "LAB_ONLY" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "COMSERVER" /D "NDEBUG" /D "WIN32" /YX /FD /c
# SUBTRACT CPP /WX /Fr
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "server - Win32 icecap"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "server___Win32_icecap"
# PROP BASE Intermediate_Dir "server___Win32_icecap"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../../../ice.bin"
# PROP Intermediate_Dir "icecap"
# PROP Target_Dir ""
MTL=midl.exe
# ADD BASE CPP /nologo /G6 /Zp4 /MD /W3 /WX /Zi /Ox /Ot /Oa /Og /Oi /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "LAB_ONLY" /D "NDEBUG" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "WIN32" /D "COMSERVER" /YX /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /Zi /Ot /Oa /Oi /Gy /I "..\..\Libraries" /I "..\..\..\CoreTech\Libraries" /D "LAB_ONLY" /D "USE_PROTOTYPES" /D "STRICT" /D "_WINDOWS" /D "COMSERVER" /D "NDEBUG" /D "WIN32" /D "_ICECAP" /YX /FD /c
# SUBTRACT CPP /WX /Og /Fr
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "server - Win32 Release"
# Name "server - Win32 Debug"
# Name "server - Win32 Armor"
# Name "server - Win32 Profile"
# Name "server - Win32 icecap"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\comline.cpp
# End Source File
# Begin Source File
SOURCE=.\comline.idl
# End Source File
# Begin Source File
SOURCE=.\comline_s.c
# End Source File
# Begin Source File
SOURCE=.\comutil.cpp
# End Source File
# Begin Source File
SOURCE=.\server.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\comline.h
# End Source File
# Begin Source File
SOURCE=.\comline.hpp
# End Source File
# Begin Source File
SOURCE=.\comutil.hpp
# End Source File
# Begin Source File
SOURCE=.\critical.hpp
# End Source File
# End Group
# End Target
# End Project
@@ -0,0 +1,16 @@
<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: server - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
<h3>Results</h3>
server.lib - 0 error(s), 0 warning(s)
</pre>
</body>
</html>
Binary file not shown.