mirror of
https://github.com/debauchee/barrier.git
synced 2026-05-08 14:41:57 +08:00
checkpoint. merging win32 code. server on X is currently broken
and client probably is.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user