checkpoint. merging win32 code. server on X is currently broken

and client probably is.
This commit is contained in:
crs
2001-11-19 00:33:36 +00:00
parent 51505783aa
commit 3f6146b15f
66 changed files with 5222 additions and 424 deletions

View File

@@ -1,24 +1,76 @@
#include "CClient.h"
#include "CString.h"
#include "CNetwork.h"
#include "CNetworkAddress.h"
#include "CThread.h"
void realMain(const CString& name,
const CString& hostname,
SInt32 port)
{
CThread::init();
CNetwork::init();
CClient* client = NULL;
try {
CNetworkAddress addr(hostname, port);
client = new CClient(name);
client->run(addr);
delete client;
CNetwork::cleanup();
}
catch (...) {
delete client;
CNetwork::cleanup();
throw;
}
}
#if defined(CONFIG_PLATFORM_WIN32)
#include "CMSWindowsScreen.h"
int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int)
{
CMSWindowsScreen::init(instance);
if (__argc != 2) {
CString msg = "hostname required. exiting.";
MessageBox(NULL, msg.c_str(), "error", MB_OK | MB_ICONERROR);
return 1;
}
try {
realMain("ingrid", __argv[1], 50001);
return 0;
}
catch (XBase& e) {
CString msg = "failed: ";
msg += e.what();
MessageBox(NULL, msg.c_str(), "error", MB_OK | MB_ICONERROR);
return 1;
}
}
#else
#include <stdio.h>
int main(int argc, char** argv)
{
CThread::init();
if (argc != 2) {
fprintf(stderr, "usage: %s <hostname>\n", argv[0]);
return 1;
}
try {
CClient* client = new CClient("ingrid");
client->run(CNetworkAddress(argv[1], 50001));
realMain("ingrid", argv[1], 50001);
return 0;
}
catch (XBase& e) {
fprintf(stderr, "failed: %s\n", e.what());
return 1;
}
return 0;
}
#endif