Moved Sys_Printf into common/sys_common.c

This commit is contained in:
Marcus Sundberg 2000-01-06 16:56:38 +00:00
parent f816a6dbc1
commit 6e9074153f
12 changed files with 74 additions and 136 deletions

62
common/sys_common.c Normal file
View file

@ -0,0 +1,62 @@
/*
sys_common.c - Common system routines.
Copyright (C) 1996-1997 Id Software, Inc.
Copyright (C) 1999-2000 contributors of the QuakeForge project
Please see the file "AUTHORS" for a list of contributors
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 the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "quakedef.h"
#include <stdio.h>
#include <stdarg.h>
int nostdout = 0;
cvar_t sys_nostdout = {"sys_nostdout","0"};
/*
================
Sys_Printf
================
*/
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
char text[2048];
unsigned char *p;
if (nostdout || sys_nostdout.value) return;
va_start(argptr, fmt);
vsnprintf(text, sizeof(text), fmt, argptr);
va_end(argptr);
for (p = (unsigned char *)text; *p; p++) {
if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9)
printf("[%02x]", *p);
else
putc(*p, stdout);
}
/* Make sure output is seen. */
fflush(stdout);
}

View file

@ -46,11 +46,12 @@
#include "quakedef.h"
#ifndef QUAKEWORLD
qboolean isDedicated;
qboolean isDedicated;
#endif
extern int nostdout;
int noconinput = 0;
int nostdout = 0;
char *basedir = ".";
char *cachedir = "/tmp";
@ -64,28 +65,6 @@ cvar_t sys_linerefresh = {"sys_linerefresh","0"};// set for entity display
void Sys_DebugNumber(int y, int val) {
}
void Sys_Printf (char *fmt, ...) {
va_list argptr;
char text[2048];
unsigned char *p;
va_start (argptr,fmt);
vsprintf (text,fmt,argptr);
va_end (argptr);
if (strlen(text) > sizeof(text))
Sys_Error("memory overwrite in Sys_Printf");
if (nostdout)
return;
for (p = (unsigned char *)text; *p; p++)
if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9)
printf("[%02x]", *p);
else
putc(*p, stdout);
}
void Sys_Quit (void) {
Host_Shutdown();
fcntl (0, F_SETFL, fcntl (0, F_GETFL, 0) & ~O_NDELAY);

View file

@ -159,15 +159,6 @@ void Sys_Error (char *error, ...)
exit (1);
}
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
va_start (argptr,fmt);
vprintf (fmt,argptr);
va_end (argptr);
}
void Sys_Quit (void)
{
exit (0);

View file

@ -122,7 +122,7 @@ endif
CD_AUDIO_SRC = cd_wrapper.c
# Sound source
SND_STYLE = @SND_STYLE@
SND_SRC = snd_null.c
@ -144,10 +144,9 @@ endif
SND_SRC += snd_mem.c snd_mix.c $(XTRA_SND_SRC)
SYS_SRC = @QW_CL_SYS_SRC@
SYS_SRC = sys_common.c @QW_CL_SYS_SRC@
# Networking source files
# FIXME: Should not assume UNIX
QW_NET_SRC = net_udp.c net_com.c mdfour.c

View file

@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define NOT_FOCUS_SLEEP 20 // sleep time when not focus
int starttime;
qboolean ActiveApp, Minimized;
qboolean ActiveApp, Minimized;
qboolean WinNT;
HWND hwnd_dialog; // startup dialog box
@ -41,7 +41,7 @@ HWND hwnd_dialog; // startup dialog box
static double pfreq;
static double curtime = 0.0;
static double lastcurtime = 0.0;
static int lowshift;
static int lowshift;
static HANDLE hinput, houtput;
HANDLE qwclsemaphore;
@ -249,17 +249,6 @@ void Sys_Error (char *error, ...)
exit (1);
}
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
char text[1024];
DWORD dummy;
va_start (argptr,fmt);
vprintf (fmt, argptr);
va_end (argptr);
}
void Sys_Quit (void)
{
VID_ForceUnlockedAndReturnState ();

View file

@ -34,7 +34,7 @@ endif
# Source files
#
QW_SRV_SYS_SRC = @QW_SRV_SYS_SRC@
QW_SRV_SYS_SRC = sys_common.c @QW_SRV_SYS_SRC@
# Networking source files
# FIXME: Should not assume UNIX

View file

@ -34,9 +34,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <sys/dir.h>
#endif
cvar_t sys_nostdout = {"sys_nostdout","0"};
cvar_t sys_extrasleep = {"sys_extrasleep","0"};
extern cvar_t sys_nostdout;
cvar_t sys_extrasleep = {"sys_extrasleep","0"};
qboolean stdin_ready;
/*
@ -120,37 +120,6 @@ void Sys_Error (char *error, ...)
exit (1);
}
/*
================
Sys_Printf
================
*/
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
static char text[2048];
unsigned char *p;
va_start (argptr,fmt);
vsprintf (text,fmt,argptr);
va_end (argptr);
if (strlen(text) > sizeof(text))
Sys_Error("memory overwrite in Sys_Printf");
if (sys_nostdout.value)
return;
for (p = (unsigned char *)text; *p; p++) {
*p &= 0x7f;
if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9)
printf("[%02x]", *p);
else
putc(*p, stdout);
}
fflush(stdout);
}
/*
================

View file

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <conio.h>
cvar_t sys_nostdout = {"sys_nostdout","0"};
extern cvar_t sys_nostdout;
/*
================
@ -143,23 +143,6 @@ char *Sys_ConsoleInput (void)
}
/*
================
Sys_Printf
================
*/
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
if (sys_nostdout.value)
return;
va_start (argptr,fmt);
vprintf (fmt,argptr);
va_end (argptr);
}
/*
================
Sys_Quit

View file

@ -144,7 +144,7 @@ endif
SND_SRC += snd_mem.c snd_mix.c $(XTRA_SND_SRC)
SYS_SRC = @SYS_SRC@
SYS_SRC = sys_common.c @SYS_SRC@
# Networking source files
# FIXME: Should not assume UNIX

View file

@ -233,15 +233,6 @@ void Sys_Error (char *error, ...)
exit (1);
}
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
va_start (argptr,fmt);
vprintf (fmt,argptr);
va_end (argptr);
}
void Sys_Quit (void)
{
Host_Shutdown();

View file

@ -428,22 +428,6 @@ void Sys_Error (char *error, ...)
exit (1);
}
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
char text[1024];
DWORD dummy;
if (isDedicated)
{
va_start (argptr,fmt);
vsprintf (text, fmt, argptr);
va_end (argptr);
WriteFile(houtput, text, strlen (text), &dummy, NULL);
}
}
void Sys_Quit (void)
{

View file

@ -172,15 +172,6 @@ void Sys_Error (char *error, ...)
exit (1);
}
void Sys_Printf (char *fmt, ...)
{
va_list argptr;
va_start (argptr,fmt);
vprintf (fmt,argptr);
va_end (argptr);
}
void Sys_Quit (void)
{
exit (0);