mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-21 11:11:37 +00:00
bare bones sys stuff moved into libQFutil. unix stuff seems to work just fine,
but win32 is probably borked atm
This commit is contained in:
parent
c227fbc3cc
commit
99535102d7
12 changed files with 291 additions and 258 deletions
12
acconfig.h
12
acconfig.h
|
@ -118,5 +118,17 @@
|
|||
/* Define strcasecmp as stricmp if you have one but not the other */
|
||||
#undef strcasecmp
|
||||
|
||||
/* Define this if you have access */
|
||||
#undef HAVE_access
|
||||
|
||||
/* Define this if you have _access */
|
||||
#undef HAVE__access
|
||||
|
||||
/* Define this if you have mkdir */
|
||||
#undef HAVE_mkdir
|
||||
|
||||
/* Define this if you have _mkdir */
|
||||
#undef HAVE__mkdir
|
||||
|
||||
@BOTTOM@
|
||||
#endif // __config_h_
|
||||
|
|
12
configure.in
12
configure.in
|
@ -276,6 +276,18 @@ if test "x$ac_cv_func_dlopen" != "xyes"; then
|
|||
fi
|
||||
AC_SUBST(DL_LIBS)
|
||||
|
||||
dnl Checks for access/_access
|
||||
AC_CHECK_FUNC(access,
|
||||
AC_DEFINE(HAVE_access),
|
||||
AC_CHECK_FUNC(_access, AC_DEFINE(HAVE__access))
|
||||
)
|
||||
|
||||
dnl Checks for mkdir/_mkdir
|
||||
AC_CHECK_FUNC(mkdir,
|
||||
AC_DEFINE(HAVE_mkdir),
|
||||
AC_CHECK_FUNC(mkdir, AC_DEFINE(HAVE__mkdir))
|
||||
)
|
||||
|
||||
dnl Checks for stricmp/strcasecmp
|
||||
AC_CHECK_FUNC(strcasecmp,
|
||||
,
|
||||
|
|
|
@ -31,41 +31,12 @@
|
|||
|
||||
#include "QF/gcc_attr.h"
|
||||
|
||||
//
|
||||
// file IO
|
||||
//
|
||||
|
||||
// returns the file size
|
||||
// return -1 if file is not present
|
||||
// the file should be in BINARY mode for stupid OSs that care
|
||||
int Sys_FileOpenRead (char *path, int *hndl);
|
||||
|
||||
int Sys_FileOpenWrite (char *path);
|
||||
void Sys_FileClose (int handle);
|
||||
void Sys_FileSeek (int handle, int position);
|
||||
int Sys_FileRead (int handle, void *dest, int count);
|
||||
int Sys_FileWrite (int handle, void *data, int count);
|
||||
int Sys_FileTime (char *path);
|
||||
void Sys_mkdir (char *path);
|
||||
|
||||
//
|
||||
// memory protection
|
||||
//
|
||||
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
|
||||
|
||||
//
|
||||
// system IO
|
||||
//
|
||||
void Sys_DebugLog(char *file, char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||
|
||||
void Sys_Error (char *error, ...) __attribute__((format(printf,1,2)));
|
||||
// an error will cause the entire program to exit
|
||||
|
||||
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||
// send text to the console
|
||||
int Sys_FileTime (const char *path);
|
||||
void Sys_mkdir (const char *path);
|
||||
|
||||
void Sys_Printf (const char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||
void Sys_Error (const char *error, ...) __attribute__((format(printf,1,2)));
|
||||
void Sys_Quit (void);
|
||||
|
||||
double Sys_DoubleTime (void);
|
||||
|
||||
char *Sys_ConsoleInput (void);
|
||||
|
@ -78,10 +49,19 @@ void Sys_LowFPPrecision (void);
|
|||
void Sys_HighFPPrecision (void);
|
||||
void Sys_SetFPCW (void);
|
||||
|
||||
void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2)));
|
||||
// send text to the console
|
||||
|
||||
void Sys_Init (void);
|
||||
void Sys_Init_Cvars (void);
|
||||
|
||||
//
|
||||
// memory protection
|
||||
//
|
||||
void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
|
||||
|
||||
//
|
||||
// system IO
|
||||
//
|
||||
void Sys_DebugLog(char *file, char *fmt, ...) __attribute__((format(printf,2,3)));
|
||||
|
||||
#endif // __sys_h
|
||||
|
|
|
@ -4,6 +4,6 @@ libQFutil_la_LDFLAGS = -version-info 1:0:0
|
|||
libQFutil_la_SOURCES = \
|
||||
checksum.c cmd.c crc.c cvar.c hash.c info.c link.c math.S mathlib.c \
|
||||
mdfour.c msg.c qargs.c qendian.c qfplist.c quakefs.c quakeio.c \
|
||||
sizebuf.c va.c ver_check.c zone.c
|
||||
sizebuf.c sys.c va.c ver_check.c zone.c
|
||||
|
||||
LIBLIST = libQFutil.la @LIBRARY_SEARCH_PATH@
|
||||
|
|
207
libs/util/sys.c
Normal file
207
libs/util/sys.c
Normal file
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
sys.c
|
||||
|
||||
virtual filesystem functions
|
||||
|
||||
Copyright (C) 1996-1997 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
$Id$
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/sys.h"
|
||||
|
||||
cvar_t *sys_nostdout;
|
||||
|
||||
/* The translation table between the graphical font and plain ASCII --KB */
|
||||
static char qfont_table[256] = {
|
||||
'\0', '#', '#', '#', '#', '.', '#', '#',
|
||||
'#', 9, 10, '#', ' ', 13, '.', '.',
|
||||
'[', ']', '0', '1', '2', '3', '4', '5',
|
||||
'6', '7', '8', '9', '.', '<', '=', '>',
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', '{', '|', '}', '~', '<',
|
||||
|
||||
'<', '=', '>', '#', '#', '.', '#', '#',
|
||||
'#', '#', ' ', '#', ' ', '>', '.', '.',
|
||||
'[', ']', '0', '1', '2', '3', '4', '5',
|
||||
'6', '7', '8', '9', '.', '<', '=', '>',
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', '{', '|', '}', '~', '<'
|
||||
};
|
||||
|
||||
#define MAXPRINTMSG 4096
|
||||
|
||||
void
|
||||
Sys_mkdir (const char *path)
|
||||
{
|
||||
#ifdef HAVE_mkdir
|
||||
if (mkdir (path, 0777) == 0)
|
||||
return;
|
||||
#else
|
||||
# ifdef HAVE__mkdir
|
||||
if (_mkdir (path) == 0)
|
||||
return;
|
||||
# else
|
||||
# error do not know how to make directories
|
||||
# endif
|
||||
#endif
|
||||
if (errno != EEXIST)
|
||||
Sys_Error ("mkdir %s: %s", path, strerror (errno));
|
||||
}
|
||||
|
||||
void __attribute__ ((weak))
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
va_start (argptr, error);
|
||||
vsnprintf (string, sizeof (string), error, argptr);
|
||||
fprintf (stderr, "Error: %s\n", string);
|
||||
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileTime (const char *path)
|
||||
{
|
||||
#ifdef HAVE_access
|
||||
if (access (path, R_OK) == 0)
|
||||
return 0;
|
||||
#else
|
||||
# ifdef HAVE__access
|
||||
if (_access (path, R_OK) == 0)
|
||||
return 0;
|
||||
# else
|
||||
# error do not know how to make directories
|
||||
# endif
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_Printf
|
||||
*/
|
||||
void
|
||||
Sys_Printf (const char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char msg[MAXPRINTMSG];
|
||||
|
||||
unsigned char *p;
|
||||
|
||||
if (sys_nostdout && sys_nostdout->int_val)
|
||||
return;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (msg, sizeof (msg), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
/* translate to ASCII instead of printing [xx] --KB */
|
||||
for (p = (unsigned char *) msg; *p; p++)
|
||||
putc (qfont_table[*p], stdout);
|
||||
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_DoubleTime
|
||||
*/
|
||||
double
|
||||
Sys_DoubleTime (void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
static DWORD starttime;
|
||||
static qboolean first = true;
|
||||
DWORD now;
|
||||
|
||||
now = timeGetTime ();
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
starttime = now;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (now < starttime) // wrapped?
|
||||
return (now / 1000.0) + (LONG_MAX - starttime / 1000.0);
|
||||
|
||||
if (now - starttime == 0)
|
||||
return 0.0;
|
||||
|
||||
return (now - starttime) / 1000.0;
|
||||
#else
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday (&tp, &tzp);
|
||||
|
||||
if (!secbase) {
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
|
||||
#endif
|
||||
}
|
|
@ -802,7 +802,7 @@ Host_Frame (float time)
|
|||
//============================================================================
|
||||
|
||||
|
||||
extern int vcrFile;
|
||||
extern QFile *vcrFile;
|
||||
|
||||
#define VCR_SIGNATURE 0x56435231
|
||||
// "VCR1"
|
||||
|
@ -817,24 +817,24 @@ Host_InitVCR (quakeparms_t *parms)
|
|||
if (com_argc != 2)
|
||||
Sys_Error ("No other parameters allowed with -playback\n");
|
||||
|
||||
Sys_FileOpenRead ("quake.vcr", &vcrFile);
|
||||
if (vcrFile == -1)
|
||||
vcrFile = Qopen ("quake.vcr", "rbz");
|
||||
if (!vcrFile)
|
||||
Sys_Error ("playback file not found\n");
|
||||
|
||||
Sys_FileRead (vcrFile, &i, sizeof (int));
|
||||
Qread (vcrFile, &i, sizeof (int));
|
||||
|
||||
if (i != VCR_SIGNATURE)
|
||||
Sys_Error ("Invalid signature in vcr file\n");
|
||||
|
||||
Sys_FileRead (vcrFile, &com_argc, sizeof (int));
|
||||
Qread (vcrFile, &com_argc, sizeof (int));
|
||||
com_argv = malloc (com_argc * sizeof (char *));
|
||||
|
||||
com_argv[0] = parms->argv[0];
|
||||
for (i = 0; i < com_argc; i++) {
|
||||
Sys_FileRead (vcrFile, &len, sizeof (int));
|
||||
Qread (vcrFile, &len, sizeof (int));
|
||||
|
||||
p = malloc (len);
|
||||
Sys_FileRead (vcrFile, p, len);
|
||||
Qread (vcrFile, p, len);
|
||||
com_argv[i + 1] = p;
|
||||
}
|
||||
com_argc++; /* add one for arg[0] */
|
||||
|
@ -843,26 +843,26 @@ Host_InitVCR (quakeparms_t *parms)
|
|||
}
|
||||
|
||||
if ((n = COM_CheckParm ("-record")) != 0) {
|
||||
vcrFile = Sys_FileOpenWrite ("quake.vcr");
|
||||
vcrFile = Qopen ("quake.vcr", "wb");
|
||||
|
||||
i = VCR_SIGNATURE;
|
||||
Sys_FileWrite (vcrFile, &i, sizeof (int));
|
||||
Qwrite (vcrFile, &i, sizeof (int));
|
||||
|
||||
i = com_argc - 1;
|
||||
Sys_FileWrite (vcrFile, &i, sizeof (int));
|
||||
Qwrite (vcrFile, &i, sizeof (int));
|
||||
|
||||
for (i = 1; i < com_argc; i++) {
|
||||
if (i == n) {
|
||||
len = 10;
|
||||
Sys_FileWrite (vcrFile, &len, sizeof (int));
|
||||
Qwrite (vcrFile, &len, sizeof (int));
|
||||
|
||||
Sys_FileWrite (vcrFile, "-playback", len);
|
||||
Qwrite (vcrFile, "-playback", len);
|
||||
continue;
|
||||
}
|
||||
len = strlen (com_argv[i]) + 1;
|
||||
Sys_FileWrite (vcrFile, &len, sizeof (int));
|
||||
Qwrite (vcrFile, &len, sizeof (int));
|
||||
|
||||
Sys_FileWrite (vcrFile, com_argv[i], len);
|
||||
Qwrite (vcrFile, com_argv[i], len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "QF/sizebuf.h"
|
||||
#include "QF/console.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/quakeio.h"
|
||||
#include "server.h"
|
||||
|
||||
qsocket_t *net_activeSockets = NULL;
|
||||
|
@ -102,7 +103,7 @@ cvar_t *config_modem_clear;
|
|||
cvar_t *config_modem_init;
|
||||
cvar_t *config_modem_hangup;
|
||||
|
||||
int vcrFile = -1;
|
||||
QFile *vcrFile;
|
||||
qboolean recording = false;
|
||||
|
||||
// these two macros are to make the code more readable
|
||||
|
@ -491,8 +492,8 @@ NET_CheckNewConnections (void)
|
|||
vcrConnect.time = host_time;
|
||||
vcrConnect.op = VCR_OP_CONNECT;
|
||||
vcrConnect.session = (long) ret;
|
||||
Sys_FileWrite (vcrFile, &vcrConnect, sizeof (vcrConnect));
|
||||
Sys_FileWrite (vcrFile, ret->address, NET_NAMELEN);
|
||||
Qwrite (vcrFile, &vcrConnect, sizeof (vcrConnect));
|
||||
Qwrite (vcrFile, ret->address, NET_NAMELEN);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -502,7 +503,7 @@ NET_CheckNewConnections (void)
|
|||
vcrConnect.time = host_time;
|
||||
vcrConnect.op = VCR_OP_CONNECT;
|
||||
vcrConnect.session = 0;
|
||||
Sys_FileWrite (vcrFile, &vcrConnect, sizeof (vcrConnect));
|
||||
Qwrite (vcrFile, &vcrConnect, sizeof (vcrConnect));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
@ -594,8 +595,8 @@ NET_GetMessage (qsocket_t * sock)
|
|||
vcrGetMessage.session = (long) sock;
|
||||
vcrGetMessage.ret = ret;
|
||||
vcrGetMessage.len = _net_message_message.cursize;
|
||||
Sys_FileWrite (vcrFile, &vcrGetMessage, 24);
|
||||
Sys_FileWrite (vcrFile, _net_message_message.data,
|
||||
Qwrite (vcrFile, &vcrGetMessage, 24);
|
||||
Qwrite (vcrFile, _net_message_message.data,
|
||||
_net_message_message.cursize);
|
||||
}
|
||||
} else {
|
||||
|
@ -604,7 +605,7 @@ NET_GetMessage (qsocket_t * sock)
|
|||
vcrGetMessage.op = VCR_OP_GETMESSAGE;
|
||||
vcrGetMessage.session = (long) sock;
|
||||
vcrGetMessage.ret = ret;
|
||||
Sys_FileWrite (vcrFile, &vcrGetMessage, 20);
|
||||
Qwrite (vcrFile, &vcrGetMessage, 20);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -653,7 +654,7 @@ NET_SendMessage (qsocket_t * sock, sizebuf_t *data)
|
|||
vcrSendMessage.op = VCR_OP_SENDMESSAGE;
|
||||
vcrSendMessage.session = (long) sock;
|
||||
vcrSendMessage.r = r;
|
||||
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
|
||||
Qwrite (vcrFile, &vcrSendMessage, 20);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -683,7 +684,7 @@ NET_SendUnreliableMessage (qsocket_t * sock, sizebuf_t *data)
|
|||
vcrSendMessage.op = VCR_OP_SENDMESSAGE;
|
||||
vcrSendMessage.session = (long) sock;
|
||||
vcrSendMessage.r = r;
|
||||
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
|
||||
Qwrite (vcrFile, &vcrSendMessage, 20);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -718,7 +719,7 @@ NET_CanSendMessage (qsocket_t * sock)
|
|||
vcrSendMessage.op = VCR_OP_CANSENDMESSAGE;
|
||||
vcrSendMessage.session = (long) sock;
|
||||
vcrSendMessage.r = r;
|
||||
Sys_FileWrite (vcrFile, &vcrSendMessage, 20);
|
||||
Qwrite (vcrFile, &vcrSendMessage, 20);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
@ -911,9 +912,9 @@ NET_Shutdown (void)
|
|||
}
|
||||
}
|
||||
|
||||
if (vcrFile != -1) {
|
||||
if (vcrFile) {
|
||||
Con_Printf ("Closing vcrfile.\n");
|
||||
Sys_FileClose (vcrFile);
|
||||
Qclose (vcrFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "QF/sys.h"
|
||||
#include "server.h"
|
||||
|
||||
extern int vcrFile;
|
||||
extern QFile *vcrFile;
|
||||
|
||||
// This is the playback portion of the VCR. It reads the file produced
|
||||
// by the recorder and plays it back to the host. The recording contains
|
||||
|
@ -63,14 +63,14 @@ VCR_Init (void)
|
|||
net_drivers[0].Close = VCR_Close;
|
||||
net_drivers[0].Shutdown = VCR_Shutdown;
|
||||
|
||||
Sys_FileRead (vcrFile, &next, sizeof (next));
|
||||
Qread (vcrFile, &next, sizeof (next));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
VCR_ReadNext (void)
|
||||
{
|
||||
if (Sys_FileRead (vcrFile, &next, sizeof (next)) == 0) {
|
||||
if (Qread (vcrFile, &next, sizeof (next)) == 0) {
|
||||
next.op = 255;
|
||||
Sys_Error ("=== END OF PLAYBACK===\n");
|
||||
}
|
||||
|
@ -100,16 +100,16 @@ VCR_GetMessage (qsocket_t * sock)
|
|||
|| next.session != *(long *) (&sock->driverdata))
|
||||
Sys_Error ("VCR missmatch");
|
||||
|
||||
Sys_FileRead (vcrFile, &ret, sizeof (int));
|
||||
Qread (vcrFile, &ret, sizeof (int));
|
||||
|
||||
if (ret != 1) {
|
||||
VCR_ReadNext ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
Sys_FileRead (vcrFile, &net_message->message->cursize, sizeof (int));
|
||||
Qread (vcrFile, &net_message->message->cursize, sizeof (int));
|
||||
|
||||
Sys_FileRead (vcrFile, net_message->message->data,
|
||||
Qread (vcrFile, net_message->message->data,
|
||||
net_message->message->cursize);
|
||||
|
||||
VCR_ReadNext ();
|
||||
|
@ -127,7 +127,7 @@ VCR_SendMessage (qsocket_t * sock, sizebuf_t *data)
|
|||
|| next.session != *(long *) (&sock->driverdata))
|
||||
Sys_Error ("VCR missmatch");
|
||||
|
||||
Sys_FileRead (vcrFile, &ret, sizeof (int));
|
||||
Qread (vcrFile, &ret, sizeof (int));
|
||||
|
||||
VCR_ReadNext ();
|
||||
|
||||
|
@ -144,7 +144,7 @@ VCR_CanSendMessage (qsocket_t * sock)
|
|||
|| next.session != *(long *) (&sock->driverdata))
|
||||
Sys_Error ("VCR missmatch");
|
||||
|
||||
Sys_FileRead (vcrFile, &ret, sizeof (int));
|
||||
Qread (vcrFile, &ret, sizeof (int));
|
||||
|
||||
VCR_ReadNext ();
|
||||
|
||||
|
@ -187,7 +187,7 @@ VCR_CheckNewConnections (void)
|
|||
sock = NET_NewQSocket ();
|
||||
*(long *) (&sock->driverdata) = next.session;
|
||||
|
||||
Sys_FileRead (vcrFile, sock->address, NET_NAMELEN);
|
||||
Qread (vcrFile, sock->address, NET_NAMELEN);
|
||||
VCR_ReadNext ();
|
||||
|
||||
return sock;
|
||||
|
|
|
@ -53,8 +53,6 @@
|
|||
|
||||
qboolean isDedicated;
|
||||
|
||||
int nostdout = 0;
|
||||
|
||||
char *basedir = ".";
|
||||
char *cachedir = "/tmp";
|
||||
|
||||
|
@ -62,130 +60,6 @@ cvar_t *sys_linerefresh;
|
|||
cvar_t *timestamps;
|
||||
cvar_t *timeformat;
|
||||
|
||||
/* The translation table between the graphical font and plain ASCII --KB */
|
||||
static char qfont_table[256] = {
|
||||
'\0', '#', '#', '#', '#', '.', '#', '#',
|
||||
'#', 9, 10, '#', ' ', 13, '.', '.',
|
||||
'[', ']', '0', '1', '2', '3', '4', '5',
|
||||
'6', '7', '8', '9', '.', '<', '=', '>',
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', '{', '|', '}', '~', '<',
|
||||
|
||||
'<', '=', '>', '#', '#', '.', '#', '#',
|
||||
'#', '#', ' ', '#', ' ', '>', '.', '.',
|
||||
'[', ']', '0', '1', '2', '3', '4', '5',
|
||||
'6', '7', '8', '9', '.', '<', '=', '>',
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', '{', '|', '}', '~', '<'
|
||||
};
|
||||
|
||||
/*
|
||||
* File I/O
|
||||
*/
|
||||
|
||||
/*
|
||||
Sys_FileTime
|
||||
|
||||
Returns -1 if file not present
|
||||
*/
|
||||
int
|
||||
Sys_FileTime (char *path)
|
||||
{
|
||||
struct stat buf;
|
||||
|
||||
if (stat (path, &buf) == -1)
|
||||
return -1;
|
||||
|
||||
return buf.st_mtime;
|
||||
}
|
||||
|
||||
/*
|
||||
Sys_mkdir
|
||||
|
||||
Creates a directory
|
||||
*/
|
||||
void
|
||||
Sys_mkdir (char *path)
|
||||
{
|
||||
mkdir (path, 0777);
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileOpenRead (char *path, int *handle)
|
||||
{
|
||||
struct stat fileinfo;
|
||||
int h;
|
||||
|
||||
h = open (path, O_RDONLY, 0666);
|
||||
*handle = h;
|
||||
if (h == -1)
|
||||
return -1;
|
||||
|
||||
if (fstat (h, &fileinfo) == -1)
|
||||
Sys_Error ("Error fstating %s", path);
|
||||
|
||||
return fileinfo.st_size;
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileOpenWrite (char *path)
|
||||
{
|
||||
int handle;
|
||||
|
||||
umask (0);
|
||||
|
||||
handle = open (path, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (handle == -1)
|
||||
Sys_Error ("Error opening %s: %s", path, strerror (errno));
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileWrite (int handle, void *src, int count)
|
||||
{
|
||||
return write (handle, src, count);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_FileClose (int handle)
|
||||
{
|
||||
close (handle);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_FileSeek (int handle, int position)
|
||||
{
|
||||
lseek (handle, position, SEEK_SET);
|
||||
}
|
||||
|
||||
int
|
||||
Sys_FileRead (int handle, void *dest, int count)
|
||||
{
|
||||
return read (handle, dest, count);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_DebugLog (char *file, char *fmt, ...)
|
||||
{
|
||||
|
@ -251,45 +125,8 @@ Sys_DebugNumber (int y, int val)
|
|||
{
|
||||
}
|
||||
|
||||
#define MAX_PRINT_MSG 4096
|
||||
void
|
||||
Sys_Printf (char *fmt, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char start[MAX_PRINT_MSG]; // String we started with
|
||||
char stamp[MAX_PRINT_MSG]; // Time stamp
|
||||
char final[MAX_PRINT_MSG]; // String we print
|
||||
|
||||
time_t mytime = 0;
|
||||
struct tm *local = NULL;
|
||||
|
||||
unsigned char *p;
|
||||
|
||||
va_start (argptr, fmt);
|
||||
vsnprintf (start, sizeof (start), fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
if (nostdout)
|
||||
return;
|
||||
|
||||
if (timestamps && timeformat && timestamps->int_val && timeformat->string) {
|
||||
mytime = time (NULL);
|
||||
local = localtime (&mytime);
|
||||
strftime (stamp, sizeof (stamp), timeformat->string, local);
|
||||
|
||||
snprintf (final, sizeof (final), "%s%s", stamp, start);
|
||||
} else {
|
||||
snprintf (final, sizeof (final), "%s", start);
|
||||
}
|
||||
|
||||
for (p = (unsigned char *) final; *p; p++) {
|
||||
putc (qfont_table[*p], stdout);
|
||||
}
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
void
|
||||
Sys_Error (char *error, ...)
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
@ -336,23 +173,6 @@ Sys_Warn (char *warning, ...)
|
|||
fprintf (stderr, "Warning: %s", string);
|
||||
}
|
||||
|
||||
double
|
||||
Sys_DoubleTime (void)
|
||||
{
|
||||
struct timeval tp;
|
||||
struct timezone tzp;
|
||||
static int secbase;
|
||||
|
||||
gettimeofday (&tp, &tzp);
|
||||
|
||||
if (!secbase) {
|
||||
secbase = tp.tv_sec;
|
||||
return tp.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// Sleeps for microseconds
|
||||
// =======================================================================
|
||||
|
@ -454,8 +274,9 @@ main (int c, char **v)
|
|||
|
||||
Sys_Init ();
|
||||
|
||||
sys_nostdout = Cvar_Get ("sys_nostdout", "0", CVAR_NONE, "set to disable std out");
|
||||
if (COM_CheckParm ("-nostdout"))
|
||||
nostdout = 1;
|
||||
Cvar_Set (sys_nostdout, "1");
|
||||
else {
|
||||
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);
|
||||
printf ("Quake -- Version %s\n", NQ_VERSION);
|
||||
|
|
|
@ -72,9 +72,9 @@ EXTRA_libqfnet_a_SOURCES= net_chan.c net_udp.c net_udp6.c
|
|||
if SYSTYPE_WIN32
|
||||
libqfsys_sv_a_SOURCES= fnmatch.c dirent.c sv_sys_win.c sys_win.c
|
||||
else
|
||||
libqfsys_sv_a_SOURCES= sv_sys_unix.c sys_unix.c
|
||||
libqfsys_sv_a_SOURCES= sv_sys_unix.c
|
||||
endif
|
||||
EXTRA_libqfsys_sv_a_SOURCES= fnmatch.c dirent.c sv_sys_unix.c sv_sys_win.c sys_unix.c sys_win.c
|
||||
EXTRA_libqfsys_sv_a_SOURCES= fnmatch.c dirent.c sv_sys_unix.c sv_sys_win.c
|
||||
|
||||
if ASM_ARCH
|
||||
world_ASM= worlda.S
|
||||
|
@ -97,9 +97,9 @@ qw_server_DEPENDENCIES= libqfnet.a libqfsys_sv.a
|
|||
if SYSTYPE_WIN32
|
||||
libqfsys_cl_a_SOURCES= cl_sys_win.c fnmatch.c dirent.c sys_win.c
|
||||
else
|
||||
libqfsys_cl_a_SOURCES= cl_sys_unix.c sys_unix.c
|
||||
libqfsys_cl_a_SOURCES= cl_sys_unix.c
|
||||
endif
|
||||
EXTRA_libqfsys_cl_a_SOURCES= cl_sys_sdl.c cl_sys_unix.c cl_sys_win.c sys_win.c sys_unix.c fnmatch.c dirent.c
|
||||
EXTRA_libqfsys_cl_a_SOURCES= cl_sys_sdl.c cl_sys_unix.c cl_sys_win.c sys_win.c fnmatch.c dirent.c
|
||||
|
||||
#
|
||||
# ... Digital audio
|
||||
|
|
|
@ -91,7 +91,7 @@ Sys_Init (void)
|
|||
}
|
||||
|
||||
void
|
||||
Sys_Error (char *error, ...)
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
|
|
@ -71,7 +71,7 @@ char *svs_info = svs.info;
|
|||
Sys_Error
|
||||
*/
|
||||
void
|
||||
Sys_Error (char *error, ...)
|
||||
Sys_Error (const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
|
Loading…
Reference in a new issue