quakeio.c now compiles with newer glibc versions (fpos_t changed)

vid_glx.c has some unsigned changes ported over from newtree
the rest have had fclose and fopen converted to Q*
This commit is contained in:
Bill Currie 2000-09-22 17:07:42 +00:00
parent 44e9299f29
commit 10c6a3a42f
12 changed files with 61 additions and 37 deletions

View file

@ -88,5 +88,8 @@
/* Define this to something sane if you don't have stricmp */
#undef stricmp
/* Define this if FPOS_T is a struct */
#undef HAVE_FPOS_T_STRUCT
@BOTTOM@
#endif // _CONFIG_H_

View file

@ -83,6 +83,15 @@ AC_HEADER_TIME
AC_STRUCT_TM
AC_C_BIGENDIAN
AC_MSG_CHECKING(for type of fpos_t)
AC_TRY_COMPILE(
[#include <stdio.h>],
[fpos_t x = 0],
AC_MSG_RESULT(off_t),
AC_DEFINE(HAVE_FPOS_T_STRUCT)
AC_MSG_RESULT(struct)
)
AC_MSG_CHECKING(for socklen_t in sys/types.h)
AC_TRY_COMPILE(
[#include <sys/types.h>],

View file

@ -148,6 +148,9 @@
/* Define this to something sane if you don't have stricmp */
#undef stricmp
/# Define this if FPOS_T is a struct */
#undef HAVE_FPOS_T_STRUCT
/* Define if you have the _ftime function. */
#undef HAVE__FTIME

View file

@ -748,7 +748,7 @@ void SaveGamestate()
snprintf (name, sizeof(name), "%s/%s.gip", com_gamedir, sv.name);
Con_Printf ("Saving game to %s...\n", name);
f = fopen (name, "w");
f = Qopen (name, "w");
if (!f)
{
Con_Printf ("ERROR: couldn't open.\n");
@ -804,7 +804,7 @@ int LoadGamestate(char *level, char *startspot)
snprintf (name, sizeof(name), "%s/%s.gip", com_gamedir, level);
Con_Printf ("Loading game from %s...\n", name);
f = fopen (name, "r");
f = Qopen (name, "r");
if (!f)
{
Con_Printf ("ERROR: couldn't open.\n");

View file

@ -339,12 +339,21 @@ Qeof(QFile *file)
int
Qgetpos(QFile *file, fpos_t *pos)
{
#ifdef HAVE_FPOS_T_STRUCT
pos->__pos = Qtell(file);
return pos->__pos==-1?-1:0;
#else
*pos = Qtell(file);
return *pos==-1?-1:0;
#endif
}
int
Qsetpos(QFile *file, fpos_t *pos)
{
#ifdef HAVE_FPOS_T_STRUCT
return Qseek(file, pos->__pos, 0);
#else
return Qseek(file, *pos, 0);
#endif
}

View file

@ -342,7 +342,7 @@ static char *stripped_fgets(char *s, int n, QFile *f)
// Opens an .INI file. Works like fopen
QFile *ini_fopen(const char *filename, const char *modes)
{
return(fopen(filename,modes));
return(Qopen(filename,modes));
}
// Closes a .INI file. Works like fclose
@ -350,7 +350,7 @@ int ini_fclose(QFile *f)
{
if (f==current_file)
reset_buffer(NULL);
return(fclose(f));
return(Qclose(f));
}
// Puts "field" from "section" from .ini file "f" into "s".

View file

@ -79,7 +79,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
i = findhandle ();
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (!f)
{
*hndl = -1;
@ -98,7 +98,7 @@ int Sys_FileOpenWrite (char *path)
i = findhandle ();
f = fopen(path, "wb");
f = Qopen(path, "wb");
if (!f)
Sys_Error ("Error opening %s: %s", path,strerror(errno));
sys_handles[i] = f;
@ -108,7 +108,7 @@ int Sys_FileOpenWrite (char *path)
void Sys_FileClose (int handle)
{
fclose (sys_handles[handle]);
Qclose (sys_handles[handle]);
sys_handles[handle] = NULL;
}
@ -131,10 +131,10 @@ int Sys_FileTime (char *path)
{
QFile *f;
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (f)
{
fclose(f);
Qclose(f);
return 1;
}

View file

@ -101,7 +101,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
i = findhandle ();
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (!f)
{
*hndl = -1;
@ -129,7 +129,7 @@ int Sys_FileOpenWrite (char *path)
i = findhandle ();
f = fopen(path, "wb");
f = Qopen(path, "wb");
if (!f)
Sys_Error ("Error opening %s: %s", path,strerror(errno));
sys_handles[i].hFile = f;
@ -146,7 +146,7 @@ void Sys_FileClose (int handle)
if (munmap( sys_handles[handle].pMap, sys_handles[handle].nLen ) != 0)
printf( "failed to unmap handle %d\n", handle );
fclose (sys_handles[handle].hFile);
Qclose (sys_handles[handle].hFile);
sys_handles[handle].hFile = NULL;
}
@ -185,10 +185,10 @@ int Sys_FileTime (char *path)
{
QFile *f;
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (f)
{
fclose(f);
Qclose(f);
return 1;
}

View file

@ -151,7 +151,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
i = findhandle ();
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (!f)
{
@ -180,7 +180,7 @@ int Sys_FileOpenWrite (char *path)
i = findhandle ();
f = fopen(path, "wb");
f = Qopen(path, "wb");
if (!f)
Sys_Error ("Error opening %s: %s", path,strerror(errno));
sys_handles[i] = f;
@ -195,7 +195,7 @@ void Sys_FileClose (int handle)
int t;
t = VID_ForceUnlockedAndReturnState ();
fclose (sys_handles[handle]);
Qclose (sys_handles[handle]);
sys_handles[handle] = NULL;
VID_ForceLockState (t);
}
@ -236,11 +236,11 @@ int Sys_FileTime (char *path)
t = VID_ForceUnlockedAndReturnState ();
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (f)
{
fclose(f);
Qclose(f);
retval = 1;
}
else

View file

@ -83,7 +83,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
i = findhandle ();
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (!f)
{
*hndl = -1;
@ -102,7 +102,7 @@ int Sys_FileOpenWrite (char *path)
i = findhandle ();
f = fopen(path, "wb");
f = Qopen(path, "wb");
if (!f)
Sys_Error ("Error opening %s: %s", path,strerror(errno));
sys_handles[i] = f;
@ -112,7 +112,7 @@ int Sys_FileOpenWrite (char *path)
void Sys_FileClose (int handle)
{
fclose (sys_handles[handle]);
Qclose (sys_handles[handle]);
sys_handles[handle] = NULL;
}
@ -135,10 +135,10 @@ int Sys_FileTime (char *path)
{
QFile *f;
f = fopen(path, "rb");
f = Qopen(path, "rb");
if (f)
{
fclose(f);
Qclose(f);
return 1;
}

View file

@ -86,7 +86,7 @@ static qboolean vid_initialized = false;
static GLXContext ctx = NULL;
unsigned short d_8to16table[256];
unsigned d_8to24table[256];
unsigned int d_8to24table[256];
unsigned char d_15to8table[65536];
cvar_t *vid_mode;
@ -198,17 +198,17 @@ void VID_ShiftPalette(unsigned char *p)
void VID_SetPalette (unsigned char *palette)
{
byte *pal;
unsigned r,g,b;
unsigned v;
int r1,g1,b1;
int k;
unsigned short i;
unsigned *table;
QFile *f;
char s[255];
float dist, bestdist;
static qboolean palflag = false;
byte *pal;
unsigned int r,g,b;
unsigned int v;
int r1,g1,b1;
int k;
unsigned short i;
unsigned int *table;
QFile *f;
char s[255];
float dist, bestdist;
static qboolean palflag = false;
//
// 8 8 8 encoding

View file

@ -784,7 +784,7 @@ void VID_SetPalette (unsigned char *palette)
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
Sys_mkdir (s);
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
if ((f = fopen(s, "wb")) != NULL) {
if ((f = Qopen(s, "wb")) != NULL) {
Qwrite(f, d_15to8table, 1<<15);
Qclose(f);
}