From 10c6a3a42fec926d762da721a3b1b511451f0874 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 22 Sep 2000 17:07:42 +0000 Subject: [PATCH] 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* --- acconfig.h | 3 +++ configure.in | 9 +++++++++ include/config.h.in | 3 +++ source/host_cmd.c | 4 ++-- source/quakeio.c | 9 +++++++++ source/snd_gus.c | 4 ++-- source/sys_null.c | 10 +++++----- source/sys_sun.c | 10 +++++----- source/sys_win.c | 10 +++++----- source/sys_wind.c | 10 +++++----- source/vid_glx.c | 24 ++++++++++++------------ source/vid_wgl.c | 2 +- 12 files changed, 61 insertions(+), 37 deletions(-) diff --git a/acconfig.h b/acconfig.h index 133a8ff..1e4d207 100644 --- a/acconfig.h +++ b/acconfig.h @@ -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_ diff --git a/configure.in b/configure.in index 0391465..ae7deed 100644 --- a/configure.in +++ b/configure.in @@ -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 ], + [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 ], diff --git a/include/config.h.in b/include/config.h.in index 87f4ac3..f36ab63 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -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 diff --git a/source/host_cmd.c b/source/host_cmd.c index 45cb81b..24ac21c 100644 --- a/source/host_cmd.c +++ b/source/host_cmd.c @@ -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"); diff --git a/source/quakeio.c b/source/quakeio.c index 9109a1e..1c54972 100644 --- a/source/quakeio.c +++ b/source/quakeio.c @@ -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 } diff --git a/source/snd_gus.c b/source/snd_gus.c index d6e9dff..c393bc8 100644 --- a/source/snd_gus.c +++ b/source/snd_gus.c @@ -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". diff --git a/source/sys_null.c b/source/sys_null.c index 249a0a0..23d4f00 100644 --- a/source/sys_null.c +++ b/source/sys_null.c @@ -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; } diff --git a/source/sys_sun.c b/source/sys_sun.c index 05fddc8..943a14a 100644 --- a/source/sys_sun.c +++ b/source/sys_sun.c @@ -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; } diff --git a/source/sys_win.c b/source/sys_win.c index 1a27091..e24a305 100644 --- a/source/sys_win.c +++ b/source/sys_win.c @@ -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 diff --git a/source/sys_wind.c b/source/sys_wind.c index 2144be5..1da7990 100644 --- a/source/sys_wind.c +++ b/source/sys_wind.c @@ -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; } diff --git a/source/vid_glx.c b/source/vid_glx.c index 3ecf5e3..efb518e 100644 --- a/source/vid_glx.c +++ b/source/vid_glx.c @@ -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 diff --git a/source/vid_wgl.c b/source/vid_wgl.c index 198107e..b3a51be 100644 --- a/source/vid_wgl.c +++ b/source/vid_wgl.c @@ -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); }