*** empty log message ***

svn path=/trunk/boinc/; revision=2880
This commit is contained in:
David Anderson 2004-01-15 01:42:49 +00:00
parent 9a790726c6
commit b885e31677
4 changed files with 92 additions and 48 deletions

View File

@ -9195,3 +9195,12 @@ David Jan 14 2004
client/win/ client/win/
wingui_mainwindow.cpp,h wingui_mainwindow.cpp,h
David Jan 14 2004
- windows console version works again (from Rom Walton)
client/
main.C
net_xfer.C
win_build/
boinc_cli.vcproj

View File

@ -22,6 +22,11 @@
// This file contains no GUI-related code, // This file contains no GUI-related code,
// and is not included in the source code for Mac or Win GUI clients // and is not included in the source code for Mac or Win GUI clients
#ifdef WIN32
#include <afxwin.h>
#include "stackwalker.h"
#endif
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -141,22 +146,50 @@ void quit_client(int a) {
gstate.requested_exit = true; gstate.requested_exit = true;
} }
#ifndef _WIN32
void susp_client(int a) { void susp_client(int a) {
gstate.active_tasks.suspend_all(); gstate.active_tasks.suspend_all();
msg_printf(NULL, MSG_INFO, "Suspending activity - user request"); msg_printf(NULL, MSG_INFO, "Suspending activity - user request");
signal(SIGTSTP, SIG_DFL); #ifndef _WIN32
signal(SIGTSTP, SIG_DFL);
raise(SIGTSTP); raise(SIGTSTP);
#endif
} }
void resume_client(int a) { void resume_client(int a) {
gstate.active_tasks.unsuspend_all(); gstate.active_tasks.unsuspend_all();
msg_printf(NULL, MSG_INFO, "Resuming activity"); msg_printf(NULL, MSG_INFO, "Resuming activity");
} }
#ifdef _WIN32
BOOL WINAPI ConsoleControlHandler ( DWORD dwCtrlType ){
BOOL bReturnStatus = FALSE;
switch( dwCtrlType ){
case CTRL_C_EVENT:
if(gstate.activities_suspended)
resume_client(NULL);
else
susp_client(NULL);
bReturnStatus = TRUE;
break;
case CTRL_BREAK_EVENT:
case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT:
quit_client(NULL);
bReturnStatus = TRUE;
break;
}
return bReturnStatus;
}
#endif #endif
int main(int argc, char** argv) { int main(int argc, char** argv) {
int retval;
#ifdef WIN32
InitAllocCheck();
#endif
int retval;
double dt; double dt;
setbuf(stdout, 0); setbuf(stdout, 0);
@ -165,13 +198,8 @@ int main(int argc, char** argv) {
exit(1); exit(1);
} }
read_log_flags(); // Unix/Linux console controls
gstate.parse_cmdline(argc, argv); #ifndef WIN32
gstate.parse_env_vars();
retval = gstate.init();
if (retval) exit(retval);
#ifndef _WIN32
// Handle quit signals gracefully // Handle quit signals gracefully
signal(SIGHUP, quit_client); signal(SIGHUP, quit_client);
signal(SIGINT, quit_client); signal(SIGINT, quit_client);
@ -183,6 +211,25 @@ int main(int argc, char** argv) {
signal(SIGCONT, resume_client); signal(SIGCONT, resume_client);
#endif #endif
// Windows console controls
#ifdef WIN32
if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleControlHandler, TRUE)){
fprintf(stderr, "Failed to register the console control handler\n");
exit(1);
} else {
printf(
"\nTo pause/resume tasks hit CTRL-C, to exit hit CTRL-BREAK\n"
);
}
#endif
read_log_flags();
gstate.parse_cmdline(argc, argv);
gstate.parse_env_vars();
retval = gstate.init();
if (retval) exit(retval);
while (1) { while (1) {
if (!gstate.do_something()) { if (!gstate.do_something()) {
dt = dtime(); dt = dtime();
@ -207,5 +254,10 @@ int main(int argc, char** argv) {
} }
} }
gstate.cleanup_and_exit(); gstate.cleanup_and_exit();
return 0;
#ifdef WIN32
DeInitAllocCheck();
#endif
return 0;
} }

View File

@ -18,7 +18,7 @@
// //
// Revision History: // Revision History:
// $Log$ // $Log$
// Revision 1.78 2004/01/10 06:40:44 davea // Revision 1.79 2004/01/15 01:42:48 davea
// *** empty log message *** // *** empty log message ***
// //
// Revision 1.77 2003/12/12 23:13:01 davea // Revision 1.77 2003/12/12 23:13:01 davea
@ -100,7 +100,7 @@ typedef size_t socklen_t;
int get_socket_error(int fd) { int get_socket_error(int fd) {
socklen_t intsize = sizeof(int); socklen_t intsize = sizeof(int);
int n; int n;
#ifdef _WIN32 #ifdef WIN32
getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&n, &intsize); getsockopt(fd, SOL_SOCKET, SO_ERROR, (char *)&n, &intsize);
#elif __APPLE__ #elif __APPLE__
getsockopt(fd, SOL_SOCKET, SO_ERROR, &n, (int *)&intsize); getsockopt(fd, SOL_SOCKET, SO_ERROR, &n, (int *)&intsize);
@ -113,7 +113,7 @@ int get_socket_error(int fd) {
int NET_XFER::get_ip_addr(char *hostname, int &ip_addr) { int NET_XFER::get_ip_addr(char *hostname, int &ip_addr) {
hostent* hep; hostent* hep;
#ifdef _WIN32 #ifdef WIN32
int retval; int retval;
retval = NetOpen(); retval = NetOpen();
if (retval) return retval; if (retval) return retval;
@ -124,7 +124,7 @@ int NET_XFER::get_ip_addr(char *hostname, int &ip_addr) {
int n; int n;
n = sprintf(msg, "Can't resolve hostname %s ", hostname); n = sprintf(msg, "Can't resolve hostname %s ", hostname);
#ifdef _WIN32 #ifdef WIN32
switch (WSAGetLastError()) { switch (WSAGetLastError()) {
case WSANOTINITIALISED: case WSANOTINITIALISED:
@ -194,13 +194,13 @@ int NET_XFER::open_server() {
fd = ::socket(AF_INET, SOCK_STREAM, 0); fd = ::socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0) { if (fd < 0) {
#ifdef _WIN32 #ifdef WIN32
NetClose(); NetClose();
#endif #endif
return ERR_SOCKET; return ERR_SOCKET;
} }
#ifdef _WIN32 #ifdef WIN32
unsigned long one = 1; unsigned long one = 1;
ioctlsocket(fd, FIONBIO, &one); ioctlsocket(fd, FIONBIO, &one);
#else #else
@ -219,14 +219,14 @@ int NET_XFER::open_server() {
addr.sin_addr.s_addr = ((long)ipaddr); addr.sin_addr.s_addr = ((long)ipaddr);
retval = connect(fd, (sockaddr*)&addr, sizeof(addr)); retval = connect(fd, (sockaddr*)&addr, sizeof(addr));
if (retval) { if (retval) {
#ifdef _WIN32 #ifdef WIN32
errno = WSAGetLastError(); errno = WSAGetLastError();
if (errno != WSAEINPROGRESS && errno != WSAEWOULDBLOCK) { if (errno != WSAEINPROGRESS && errno != WSAEWOULDBLOCK) {
closesocket(fd); closesocket(fd);
NetClose(); NetClose();
return ERR_CONNECT; return ERR_CONNECT;
} }
#ifndef WIN_CLI #ifndef WIN32 && _CONSOLE
if (WSAAsyncSelect( fd, g_myWnd->GetSafeHwnd(), g_myWnd->m_nNetActivityMsg, FD_READ|FD_WRITE )) { if (WSAAsyncSelect( fd, g_myWnd->GetSafeHwnd(), g_myWnd->m_nNetActivityMsg, FD_READ|FD_WRITE )) {
errno = WSAGetLastError(); errno = WSAGetLastError();
if (errno != WSAEINPROGRESS && errno != WSAEWOULDBLOCK) { if (errno != WSAEINPROGRESS && errno != WSAEWOULDBLOCK) {
@ -251,7 +251,7 @@ int NET_XFER::open_server() {
} }
void NET_XFER::close_socket() { void NET_XFER::close_socket() {
#ifdef _WIN32 #ifdef WIN32
NetClose(); NetClose();
if (socket) closesocket(socket); if (socket) closesocket(socket);
#else #else
@ -364,7 +364,7 @@ int NET_XFER_SET::net_sleep(double x) {
// //
int NET_XFER_SET::do_select(double& bytes_transferred, double timeout) { int NET_XFER_SET::do_select(double& bytes_transferred, double timeout) {
int n, fd, retval, nsocks_queried; int n, fd, retval, nsocks_queried;
unsigned int i; unsigned int i;
NET_XFER *nxp; NET_XFER *nxp;
struct timeval tv; struct timeval tv;
@ -517,7 +517,7 @@ int NET_XFER::do_xfer(int& nbytes_transferred) {
ScopeMessages scope_messages(log_messages, ClientMessages::DEBUG_NET_XFER); ScopeMessages scope_messages(log_messages, ClientMessages::DEBUG_NET_XFER);
if (want_download) { if (want_download) {
#ifdef _WIN32 #ifdef WIN32
n = recv(socket, buf, blocksize, 0); n = recv(socket, buf, blocksize, 0);
#else #else
n = read(socket, buf, blocksize); n = read(socket, buf, blocksize);
@ -558,7 +558,7 @@ int NET_XFER::do_xfer(int& nbytes_transferred) {
} }
nleft = file_read_buf_len - file_read_buf_offset; nleft = file_read_buf_len - file_read_buf_offset;
while (nleft) { while (nleft) {
#ifdef _WIN32 #ifdef WIN32
n = send(socket, file_read_buf+file_read_buf_offset, nleft, 0); n = send(socket, file_read_buf+file_read_buf_offset, nleft, 0);
would_block = (WSAGetLastError() == WSAEWOULDBLOCK); would_block = (WSAGetLastError() == WSAEWOULDBLOCK);
#else #else

View File

@ -22,7 +22,7 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="../lib/,../api/,../RSAEuro/source/,../client/win/,../client" AdditionalIncludeDirectories="../lib/,../api/,../RSAEuro/source/,../client/win/,../client"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;WIN_CLI" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CONSOLE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="0" RuntimeLibrary="0"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
@ -46,7 +46,7 @@
IgnoreDefaultLibraryNames="libc,nafxcwd,libcmtd,libcmt,libcd" IgnoreDefaultLibraryNames="libc,nafxcwd,libcmtd,libcmt,libcd"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Build\Debug/boinc_cli.pdb" ProgramDatabaseFile=".\Build\Debug/boinc_cli.pdb"
SubSystem="2" SubSystem="1"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
@ -979,6 +979,9 @@
CompileAs="2"/> CompileAs="2"/>
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath="..\client\win\Stackwalker.cpp">
</File>
<File <File
RelativePath="..\Client\time_stats.C"> RelativePath="..\Client\time_stats.C">
<FileConfiguration <FileConfiguration
@ -1048,29 +1051,6 @@
CompileAs="2"/> CompileAs="2"/>
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath="..\Client\win\Win_main.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BasicRuntimeChecks="3"
BrowseInformation="1"
CompileAs="2"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
CompileAs="2"/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\Client\win\Win_net.cpp"> RelativePath="..\Client\win\Win_net.cpp">
<FileConfiguration <FileConfiguration
@ -1170,6 +1150,9 @@
<File <File
RelativePath="..\client\ss_logic.h"> RelativePath="..\client\ss_logic.h">
</File> </File>
<File
RelativePath="..\client\win\Stackwalker.h">
</File>
<File <File
RelativePath="..\client\time_stats.h"> RelativePath="..\client\time_stats.h">
</File> </File>