Small changes to compile (not link) under Solaris, AIX, & Irix

This commit is contained in:
Loring Holden 2000-02-10 06:18:57 +00:00
parent ccbb656250
commit aa720bf076
4 changed files with 27 additions and 37 deletions

View file

@ -59,6 +59,7 @@
#include "screen.h" #include "screen.h"
#include "sbar.h" #include "sbar.h"
#include "mathlib.h" #include "mathlib.h"
#include "client.h"
extern int host_hunklevel; extern int host_hunklevel;

View file

@ -1,5 +1,6 @@
#include <malloc.h> #include <malloc.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h>
#include "quakeio.h" #include "quakeio.h"
QFile *Qopen(const char *path, const char *mode) QFile *Qopen(const char *path, const char *mode)

View file

@ -36,7 +36,6 @@ int total_channels;
volatile dma_t *shm = 0; volatile dma_t *shm = 0;
cvar_t loadas8bit = {"loadas8bit", "0"}; cvar_t loadas8bit = {"loadas8bit", "0"};
int paintedtime; // sample PAIRS int paintedtime; // sample PAIRS
snd_t snd;
cvar_t bgmvolume = {"bgmvolume", "1", true}; cvar_t bgmvolume = {"bgmvolume", "1", true};

View file

@ -89,40 +89,29 @@ int filelength (QFile *f)
int pos; int pos;
int end; int end;
pos = ftell (f); pos = Qtell (f);
fseek (f, 0, SEEK_END); Qseek (f, 0, SEEK_END);
end = ftell (f); end = Qtell (f);
fseek (f, pos, SEEK_SET); Qseek (f, pos, SEEK_SET);
return end; return end;
} }
int Sys_FileOpenRead (char *path, int *hndl) /* from sys_linux.c */
int Sys_FileOpenRead (char *path, int *handle)
{ {
QFile *f; int h;
int i; struct stat fileinfo;
i = findhandle ();
f = fopen(path, "rb");
if (!f)
{
*hndl = -1;
return -1;
}
sys_handles[i].hFile = f;
sys_handles[i].nLen = filelength(f);
sys_handles[i].nPos = 0;
sys_handles[i].pMap = mmap(NULL, sys_handles[i].nLen, PROT_READ,
MAP_SHARED, fileno(sys_handles[i].hFile), 0 );
if (sys_handles[i].pMap == MAP_FAILED) {
printf( "mmap %s failed!", path );
sys_handles[i].pMap = NULL;
}
*hndl = i; h = open (path, O_RDONLY, 0666);
*handle = h;
return( sys_handles[i].nLen ); 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 Sys_FileOpenWrite (char *path)
@ -132,7 +121,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;
@ -149,7 +138,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;
} }
@ -159,7 +148,7 @@ void Sys_FileSeek (int handle, int position)
{ {
sys_handles[handle].nPos = position; sys_handles[handle].nPos = position;
} }
else fseek (sys_handles[handle].hFile, position, SEEK_SET); else Qseek (sys_handles[handle].hFile, position, SEEK_SET);
} }
int Sys_FileRead (int handle, void *dest, int count) int Sys_FileRead (int handle, void *dest, int count)
@ -174,14 +163,14 @@ int Sys_FileRead (int handle, void *dest, int count)
sys_handles[handle].nPos = nPos + count; sys_handles[handle].nPos = nPos + count;
return( count ); return( count );
} }
else return fread (dest, 1, count, sys_handles[handle].hFile); else return Qread (sys_handles[handle].hFile, dest, count);
} }
int Sys_FileWrite (int handle, void *data, int count) int Sys_FileWrite (int handle, void *data, int count)
{ {
if (sys_handles[handle].pMap) if (sys_handles[handle].pMap)
Sys_Error( "Attempted to write to read-only file %d!\n", handle ); Sys_Error( "Attempted to write to read-only file %d!\n", handle );
return fwrite (data, 1, count, sys_handles[handle].hFile); return Qwrite (sys_handles[handle].hFile, data, count);
} }
void Sys_DebugLog(char *file, char *fmt, ...) { void Sys_DebugLog(char *file, char *fmt, ...) {
@ -196,11 +185,11 @@ void Sys_DebugLog(char *file, char *fmt, ...) {
vsnprintf(data, sizeof(data), fmt, argptr); vsnprintf(data, sizeof(data), fmt, argptr);
va_end(argptr); va_end(argptr);
// fd = open(file, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, 0666); // fd = open(file, O_WRONLY | O_BINARY | O_CREAT | O_APPEND, 0666);
stream = fopen(file, "a"); stream = Qopen(file, "a");
for (p = (unsigned char *) data; *p; p++) { for (p = (unsigned char *) data; *p; p++) {
putc(trans_table[*p], stream); Qputc(stream, trans_table[*p]);
} }
fclose(stream); Qclose(stream);
/* /*
fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666); fd = open(file, O_WRONLY | O_CREAT | O_APPEND, 0666);
write(fd, data, strlen(data)); write(fd, data, strlen(data));