summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Nazarov <skuller@skuller.net>2010-08-02 15:07:41 +0000
committerAndrey Nazarov <skuller@skuller.net>2010-08-02 15:07:41 +0000
commit9bcc513cd43c78dee3c32446f353aaa0668c2180 (patch)
tree9617fbee93f86f629880ac300c8c1d283e7b3f36
parent5c73f165141b30d93309d25e1324bc0170eb4da5 (diff)
Made client and server buildable with mingw32 again.
Use uint64_t type for network counters.
-rw-r--r--source/files.c2
-rw-r--r--source/io_sleep.c4
-rw-r--r--source/net_common.c28
-rw-r--r--source/q_shared.h1
-rw-r--r--source/sv_ac.c6
-rw-r--r--source/sys_win.c21
6 files changed, 38 insertions, 24 deletions
diff --git a/source/files.c b/source/files.c
index 943be95..94f84dc 100644
--- a/source/files.c
+++ b/source/files.c
@@ -673,7 +673,9 @@ static ssize_t open_file_write( file_t *file, const char *name ) {
fail1:
ret = Q_ERR(errno);
+#ifdef __unix__
fail2:
+#endif
fclose( fp );
return ret;
}
diff --git a/source/io_sleep.c b/source/io_sleep.c
index 00e5144..79f3a4b 100644
--- a/source/io_sleep.c
+++ b/source/io_sleep.c
@@ -22,7 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "sys_public.h"
#include "io_sleep.h"
#ifdef _WIN32
-#error not yet implemented
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
#else
#include <sys/select.h>
#include <sys/time.h>
diff --git a/source/net_common.c b/source/net_common.c
index 81561fd..b569f8f 100644
--- a/source/net_common.c
+++ b/source/net_common.c
@@ -138,15 +138,15 @@ static size_t net_rate_dn;
static size_t net_rate_up;
// lifetime statistics
-static unsigned long long net_recv_errors;
-static unsigned long long net_send_errors;
+static uint64_t net_recv_errors;
+static uint64_t net_send_errors;
#if USE_ICMP
-static unsigned long long net_icmp_errors;
+static uint64_t net_icmp_errors;
#endif
-static unsigned long long net_bytes_rcvd;
-static unsigned long long net_bytes_sent;
-static unsigned long long net_packets_rcvd;
-static unsigned long long net_packets_sent;
+static uint64_t net_bytes_rcvd;
+static uint64_t net_bytes_sent;
+static uint64_t net_packets_rcvd;
+static uint64_t net_packets_sent;
//=============================================================================
@@ -593,8 +593,10 @@ qboolean NET_GetPacket( netsrc_t sock ) {
int ret;
#if USE_ICMP
int tries;
+#ifndef _WIN32
int saved_error;
#endif
+#endif
ioentry_t *e;
if( udp_sockets[sock] == INVALID_SOCKET ) {
@@ -1443,19 +1445,19 @@ static void NET_Stats_f( void ) {
Com_FormatTime( buffer, sizeof( buffer ), diff );
Com_Printf( "Network uptime: %s\n", buffer );
- Com_Printf( "Bytes sent: %llu (%llu bytes/sec)\n",
+ Com_Printf( "Bytes sent: %"PRIu64" (%"PRIu64" bytes/sec)\n",
net_bytes_sent, net_bytes_sent / diff );
- Com_Printf( "Bytes rcvd: %llu (%llu bytes/sec)\n",
+ Com_Printf( "Bytes rcvd: %"PRIu64" (%"PRIu64" bytes/sec)\n",
net_bytes_rcvd, net_bytes_rcvd / diff );
- Com_Printf( "Packets sent: %llu (%llu packets/sec)\n",
+ Com_Printf( "Packets sent: %"PRIu64" (%"PRIu64" packets/sec)\n",
net_packets_sent, net_packets_sent / diff );
- Com_Printf( "Packets rcvd: %llu (%llu packets/sec)\n",
+ Com_Printf( "Packets rcvd: %"PRIu64" (%"PRIu64" packets/sec)\n",
net_packets_rcvd, net_packets_rcvd / diff );
#if USE_ICMP
- Com_Printf( "Total errors: %llu/%llu/%llu (send/recv/icmp)\n",
+ Com_Printf( "Total errors: %"PRIu64"/%"PRIu64"/%"PRIu64" (send/recv/icmp)\n",
net_send_errors, net_recv_errors, net_icmp_errors );
#else
- Com_Printf( "Total errors: %llu/%llu (send/recv)\n",
+ Com_Printf( "Total errors: %"PRIu64"/%"PRIu64" (send/recv)\n",
net_send_errors, net_recv_errors );
#endif
Com_Printf( "Current upload rate: %"PRIz" bytes/sec\n", net_rate_up );
diff --git a/source/q_shared.h b/source/q_shared.h
index 3f2b463..9d5806d 100644
--- a/source/q_shared.h
+++ b/source/q_shared.h
@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
+#include <inttypes.h>
#include <limits.h>
#include <time.h>
#if HAVE_ENDIAN_H
diff --git a/source/sv_ac.c b/source/sv_ac.c
index e481c9a..e08caed 100644
--- a/source/sv_ac.c
+++ b/source/sv_ac.c
@@ -1158,7 +1158,11 @@ STARTUP STUFF
static void AC_Spin( void ) {
// sleep on stdin and AC server socket
- IO_Sleepv( 100, 0, ac.stream.socket, -1 );
+ IO_Sleepv( 100,
+#ifdef __unix__
+ 0,
+#endif
+ ac.stream.socket, -1 );
#if USE_SYSCON
Sys_RunConsole();
#endif
diff --git a/source/sys_win.c b/source/sys_win.c
index 8a36bb5..329130a 100644
--- a/source/sys_win.c
+++ b/source/sys_win.c
@@ -808,11 +808,11 @@ static inline time_t file_time_to_unix( FILETIME *f ) {
Sys_GetPathInfo
================
*/
-qboolean Sys_GetPathInfo( const char *path, file_info_t *info ) {
- WIN32_FILE_ATTRIBUTE_DATA data;
+qerror_t Sys_GetPathInfo( const char *path, file_info_t *info ) {
+ WIN32_FILE_ATTRIBUTE_DATA data;
if( !GetFileAttributesExA( path, GetFileExInfoStandard, &data ) ) {
- return qfalse;
+ return Q_ERR_NOENT; // TODO: return proper error code
}
if( info ) {
@@ -821,20 +821,23 @@ qboolean Sys_GetPathInfo( const char *path, file_info_t *info ) {
info->mtime = file_time_to_unix( &data.ftLastWriteTime );
}
- return qtrue;
+ return Q_ERR_SUCCESS;
}
-qboolean Sys_GetFileInfo( FILE *fp, file_info_t *info ) {
- int pos;
+qerror_t Sys_GetFileInfo( FILE *fp, file_info_t *info ) {
+ int pos, end;
+ // TODO: check for errors
pos = ftell( fp );
fseek( fp, 0, SEEK_END );
- info->size = ftell( fp );
+ end = ftell( fp );
+ fseek( fp, pos, SEEK_SET );
+
+ info->size = end;
info->ctime = 0;
info->mtime = 0;
- fseek( fp, pos, SEEK_SET );
- return qtrue;
+ return Q_ERR_SUCCESS;
}