mirror of
https://git.code.sf.net/p/quake/nuq
synced 2024-11-22 04:01:11 +00:00
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:
parent
44e9299f29
commit
10c6a3a42f
12 changed files with 61 additions and 37 deletions
|
@ -88,5 +88,8 @@
|
||||||
/* Define this to something sane if you don't have stricmp */
|
/* Define this to something sane if you don't have stricmp */
|
||||||
#undef stricmp
|
#undef stricmp
|
||||||
|
|
||||||
|
/* Define this if FPOS_T is a struct */
|
||||||
|
#undef HAVE_FPOS_T_STRUCT
|
||||||
|
|
||||||
@BOTTOM@
|
@BOTTOM@
|
||||||
#endif // _CONFIG_H_
|
#endif // _CONFIG_H_
|
||||||
|
|
|
@ -83,6 +83,15 @@ AC_HEADER_TIME
|
||||||
AC_STRUCT_TM
|
AC_STRUCT_TM
|
||||||
AC_C_BIGENDIAN
|
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_MSG_CHECKING(for socklen_t in sys/types.h)
|
||||||
AC_TRY_COMPILE(
|
AC_TRY_COMPILE(
|
||||||
[#include <sys/types.h>],
|
[#include <sys/types.h>],
|
||||||
|
|
|
@ -148,6 +148,9 @@
|
||||||
/* Define this to something sane if you don't have stricmp */
|
/* Define this to something sane if you don't have stricmp */
|
||||||
#undef stricmp
|
#undef stricmp
|
||||||
|
|
||||||
|
/# Define this if FPOS_T is a struct */
|
||||||
|
#undef HAVE_FPOS_T_STRUCT
|
||||||
|
|
||||||
/* Define if you have the _ftime function. */
|
/* Define if you have the _ftime function. */
|
||||||
#undef HAVE__FTIME
|
#undef HAVE__FTIME
|
||||||
|
|
||||||
|
|
|
@ -748,7 +748,7 @@ void SaveGamestate()
|
||||||
snprintf (name, sizeof(name), "%s/%s.gip", com_gamedir, sv.name);
|
snprintf (name, sizeof(name), "%s/%s.gip", com_gamedir, sv.name);
|
||||||
|
|
||||||
Con_Printf ("Saving game to %s...\n", name);
|
Con_Printf ("Saving game to %s...\n", name);
|
||||||
f = fopen (name, "w");
|
f = Qopen (name, "w");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("ERROR: couldn't open.\n");
|
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);
|
snprintf (name, sizeof(name), "%s/%s.gip", com_gamedir, level);
|
||||||
|
|
||||||
Con_Printf ("Loading game from %s...\n", name);
|
Con_Printf ("Loading game from %s...\n", name);
|
||||||
f = fopen (name, "r");
|
f = Qopen (name, "r");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
Con_Printf ("ERROR: couldn't open.\n");
|
Con_Printf ("ERROR: couldn't open.\n");
|
||||||
|
|
|
@ -339,12 +339,21 @@ Qeof(QFile *file)
|
||||||
int
|
int
|
||||||
Qgetpos(QFile *file, fpos_t *pos)
|
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);
|
*pos = Qtell(file);
|
||||||
return *pos==-1?-1:0;
|
return *pos==-1?-1:0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Qsetpos(QFile *file, fpos_t *pos)
|
Qsetpos(QFile *file, fpos_t *pos)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_FPOS_T_STRUCT
|
||||||
|
return Qseek(file, pos->__pos, 0);
|
||||||
|
#else
|
||||||
return Qseek(file, *pos, 0);
|
return Qseek(file, *pos, 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,7 @@ static char *stripped_fgets(char *s, int n, QFile *f)
|
||||||
// Opens an .INI file. Works like fopen
|
// Opens an .INI file. Works like fopen
|
||||||
QFile *ini_fopen(const char *filename, const char *modes)
|
QFile *ini_fopen(const char *filename, const char *modes)
|
||||||
{
|
{
|
||||||
return(fopen(filename,modes));
|
return(Qopen(filename,modes));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Closes a .INI file. Works like fclose
|
// Closes a .INI file. Works like fclose
|
||||||
|
@ -350,7 +350,7 @@ int ini_fclose(QFile *f)
|
||||||
{
|
{
|
||||||
if (f==current_file)
|
if (f==current_file)
|
||||||
reset_buffer(NULL);
|
reset_buffer(NULL);
|
||||||
return(fclose(f));
|
return(Qclose(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Puts "field" from "section" from .ini file "f" into "s".
|
// Puts "field" from "section" from .ini file "f" into "s".
|
||||||
|
|
|
@ -79,7 +79,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
*hndl = -1;
|
*hndl = -1;
|
||||||
|
@ -98,7 +98,7 @@ int Sys_FileOpenWrite (char *path)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "wb");
|
f = Qopen(path, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
||||||
sys_handles[i] = f;
|
sys_handles[i] = f;
|
||||||
|
@ -108,7 +108,7 @@ int Sys_FileOpenWrite (char *path)
|
||||||
|
|
||||||
void Sys_FileClose (int handle)
|
void Sys_FileClose (int handle)
|
||||||
{
|
{
|
||||||
fclose (sys_handles[handle]);
|
Qclose (sys_handles[handle]);
|
||||||
sys_handles[handle] = NULL;
|
sys_handles[handle] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,10 +131,10 @@ int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
QFile *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
*hndl = -1;
|
*hndl = -1;
|
||||||
|
@ -129,7 +129,7 @@ int Sys_FileOpenWrite (char *path)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "wb");
|
f = Qopen(path, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
||||||
sys_handles[i].hFile = f;
|
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)
|
if (munmap( sys_handles[handle].pMap, sys_handles[handle].nLen ) != 0)
|
||||||
printf( "failed to unmap handle %d\n", handle );
|
printf( "failed to unmap handle %d\n", handle );
|
||||||
|
|
||||||
fclose (sys_handles[handle].hFile);
|
Qclose (sys_handles[handle].hFile);
|
||||||
sys_handles[handle].hFile = NULL;
|
sys_handles[handle].hFile = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,10 +185,10 @@ int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
QFile *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
|
@ -180,7 +180,7 @@ int Sys_FileOpenWrite (char *path)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "wb");
|
f = Qopen(path, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
||||||
sys_handles[i] = f;
|
sys_handles[i] = f;
|
||||||
|
@ -195,7 +195,7 @@ void Sys_FileClose (int handle)
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
t = VID_ForceUnlockedAndReturnState ();
|
t = VID_ForceUnlockedAndReturnState ();
|
||||||
fclose (sys_handles[handle]);
|
Qclose (sys_handles[handle]);
|
||||||
sys_handles[handle] = NULL;
|
sys_handles[handle] = NULL;
|
||||||
VID_ForceLockState (t);
|
VID_ForceLockState (t);
|
||||||
}
|
}
|
||||||
|
@ -236,11 +236,11 @@ int Sys_FileTime (char *path)
|
||||||
|
|
||||||
t = VID_ForceUnlockedAndReturnState ();
|
t = VID_ForceUnlockedAndReturnState ();
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -83,7 +83,7 @@ int Sys_FileOpenRead (char *path, int *hndl)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
{
|
{
|
||||||
*hndl = -1;
|
*hndl = -1;
|
||||||
|
@ -102,7 +102,7 @@ int Sys_FileOpenWrite (char *path)
|
||||||
|
|
||||||
i = findhandle ();
|
i = findhandle ();
|
||||||
|
|
||||||
f = fopen(path, "wb");
|
f = Qopen(path, "wb");
|
||||||
if (!f)
|
if (!f)
|
||||||
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
Sys_Error ("Error opening %s: %s", path,strerror(errno));
|
||||||
sys_handles[i] = f;
|
sys_handles[i] = f;
|
||||||
|
@ -112,7 +112,7 @@ int Sys_FileOpenWrite (char *path)
|
||||||
|
|
||||||
void Sys_FileClose (int handle)
|
void Sys_FileClose (int handle)
|
||||||
{
|
{
|
||||||
fclose (sys_handles[handle]);
|
Qclose (sys_handles[handle]);
|
||||||
sys_handles[handle] = NULL;
|
sys_handles[handle] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,10 +135,10 @@ int Sys_FileTime (char *path)
|
||||||
{
|
{
|
||||||
QFile *f;
|
QFile *f;
|
||||||
|
|
||||||
f = fopen(path, "rb");
|
f = Qopen(path, "rb");
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
fclose(f);
|
Qclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ static qboolean vid_initialized = false;
|
||||||
static GLXContext ctx = NULL;
|
static GLXContext ctx = NULL;
|
||||||
|
|
||||||
unsigned short d_8to16table[256];
|
unsigned short d_8to16table[256];
|
||||||
unsigned d_8to24table[256];
|
unsigned int d_8to24table[256];
|
||||||
unsigned char d_15to8table[65536];
|
unsigned char d_15to8table[65536];
|
||||||
|
|
||||||
cvar_t *vid_mode;
|
cvar_t *vid_mode;
|
||||||
|
@ -198,17 +198,17 @@ void VID_ShiftPalette(unsigned char *p)
|
||||||
|
|
||||||
void VID_SetPalette (unsigned char *palette)
|
void VID_SetPalette (unsigned char *palette)
|
||||||
{
|
{
|
||||||
byte *pal;
|
byte *pal;
|
||||||
unsigned r,g,b;
|
unsigned int r,g,b;
|
||||||
unsigned v;
|
unsigned int v;
|
||||||
int r1,g1,b1;
|
int r1,g1,b1;
|
||||||
int k;
|
int k;
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
unsigned *table;
|
unsigned int *table;
|
||||||
QFile *f;
|
QFile *f;
|
||||||
char s[255];
|
char s[255];
|
||||||
float dist, bestdist;
|
float dist, bestdist;
|
||||||
static qboolean palflag = false;
|
static qboolean palflag = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// 8 8 8 encoding
|
// 8 8 8 encoding
|
||||||
|
|
|
@ -784,7 +784,7 @@ void VID_SetPalette (unsigned char *palette)
|
||||||
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
snprintf(s, sizeof(s), "%s/glquake", com_gamedir);
|
||||||
Sys_mkdir (s);
|
Sys_mkdir (s);
|
||||||
snprintf(s, sizeof(s), "%s/glquake/15to8.pal", com_gamedir);
|
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);
|
Qwrite(f, d_15to8table, 1<<15);
|
||||||
Qclose(f);
|
Qclose(f);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue