mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
* taniwha salutes while taps is played
This commit is contained in:
parent
899ad6bebe
commit
867f964740
3 changed files with 35 additions and 175 deletions
|
@ -39,7 +39,7 @@ bin_PROGRAMS= qfcc
|
|||
noinst_PROGRAMS= qfodump
|
||||
|
||||
qfcc_SOURCES= \
|
||||
class.c cmdlib.c cpp.c debug.c def.c emit.c expr.c function.c idstuff.c \
|
||||
class.c cpp.c debug.c def.c emit.c expr.c function.c idstuff.c \
|
||||
immediate.c linker.c method.c obj_file.c opcodes.c options.c qc-lex.l \
|
||||
qc-parse.y qfcc.c reloc.c strpool.c struct.c switch.c type.c
|
||||
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
cmdlib.c
|
||||
|
||||
Command library
|
||||
|
||||
Copyright (C) 1996-1997 id Software, Inc.
|
||||
Copyright (C) 2001 Jeff Teunissen <deek@dusknet.dhs.org>
|
||||
|
||||
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:
|
||||
|
||||
Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330
|
||||
Boston, MA 02111-1307, USA
|
||||
|
||||
*/
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef NeXT
|
||||
#include <libc.h>
|
||||
#endif
|
||||
|
||||
#include <QF/sys.h>
|
||||
|
||||
#include "cmdlib.h"
|
||||
|
||||
/*
|
||||
Error
|
||||
|
||||
For abnormal program terminations
|
||||
*/
|
||||
void
|
||||
Error (char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
|
||||
printf ("************ ERROR ************\n");
|
||||
|
||||
va_start (argptr, error);
|
||||
vprintf (error, argptr);
|
||||
va_end (argptr);
|
||||
printf ("\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
MISC FUNCTIONS
|
||||
|
||||
=============================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
FileLength
|
||||
*/
|
||||
int
|
||||
FileLength (FILE *f)
|
||||
{
|
||||
int pos;
|
||||
int end;
|
||||
|
||||
pos = ftell (f);
|
||||
fseek (f, 0, SEEK_END);
|
||||
end = ftell (f);
|
||||
fseek (f, pos, SEEK_SET);
|
||||
|
||||
return end;
|
||||
}
|
||||
|
||||
|
||||
FILE *
|
||||
SafeOpenWrite (const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen (filename, "wb");
|
||||
|
||||
if (!f)
|
||||
Error ("Error opening %s: %s", filename, strerror (errno));
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
FILE *
|
||||
SafeOpenRead (const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen (filename, "rb");
|
||||
|
||||
if (!f)
|
||||
Error ("Error opening %s: %s", filename, strerror (errno));
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SafeRead (FILE *f, void *buffer, int count)
|
||||
{
|
||||
if (fread (buffer, 1, count, f) != (size_t) count)
|
||||
Error ("File read failure");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SafeWrite (FILE *f, void *buffer, int count)
|
||||
{
|
||||
if (fwrite (buffer, 1, count, f) != (size_t) count)
|
||||
Error ("File read failure");
|
||||
}
|
|
@ -164,7 +164,7 @@ WriteData (int crc)
|
|||
ddef_t *dd;
|
||||
dprograms_t progs;
|
||||
pr_debug_header_t debug;
|
||||
FILE *h;
|
||||
QFile *h;
|
||||
int i;
|
||||
|
||||
globals = calloc (pr.scope->num_defs + 1, sizeof (ddef_t));
|
||||
|
@ -201,14 +201,14 @@ WriteData (int crc)
|
|||
printf ("%6i entity fields\n", pr.entity_data->size);
|
||||
}
|
||||
|
||||
h = SafeOpenWrite (options.output_file);
|
||||
SafeWrite (h, &progs, sizeof (progs));
|
||||
h = Qopen (options.output_file, "wb");
|
||||
Qwrite (h, &progs, sizeof (progs));
|
||||
|
||||
progs.ofs_strings = ftell (h);
|
||||
progs.ofs_strings = Qtell (h);
|
||||
progs.numstrings = pr.strings->size;
|
||||
SafeWrite (h, pr.strings->strings, pr.strings->size);
|
||||
Qwrite (h, pr.strings->strings, pr.strings->size);
|
||||
|
||||
progs.ofs_statements = ftell (h);
|
||||
progs.ofs_statements = Qtell (h);
|
||||
progs.numstatements = pr.code->size;
|
||||
for (i = 0; i < pr.code->size; i++) {
|
||||
pr.code->code[i].op = LittleShort (pr.code->code[i].op);
|
||||
|
@ -216,12 +216,12 @@ WriteData (int crc)
|
|||
pr.code->code[i].b = LittleShort (pr.code->code[i].b);
|
||||
pr.code->code[i].c = LittleShort (pr.code->code[i].c);
|
||||
}
|
||||
SafeWrite (h, pr.code->code, pr.code->size * sizeof (dstatement_t));
|
||||
Qwrite (h, pr.code->code, pr.code->size * sizeof (dstatement_t));
|
||||
|
||||
{
|
||||
dfunction_t *df;
|
||||
|
||||
progs.ofs_functions = ftell (h);
|
||||
progs.ofs_functions = Qtell (h);
|
||||
progs.numfunctions = pr.num_functions;
|
||||
for (i = 0, df = pr.functions + 1; i < pr.num_functions; i++, df++) {
|
||||
df->first_statement = LittleLong (df->first_statement);
|
||||
|
@ -231,35 +231,35 @@ WriteData (int crc)
|
|||
df->numparms = LittleLong (df->numparms);
|
||||
df->locals = LittleLong (df->locals);
|
||||
}
|
||||
SafeWrite (h, pr.functions, pr.num_functions * sizeof (dfunction_t));
|
||||
Qwrite (h, pr.functions, pr.num_functions * sizeof (dfunction_t));
|
||||
}
|
||||
|
||||
progs.ofs_globaldefs = ftell (h);
|
||||
progs.ofs_globaldefs = Qtell (h);
|
||||
progs.numglobaldefs = numglobaldefs;
|
||||
for (i = 0; i < numglobaldefs; i++) {
|
||||
globals[i].type = LittleShort (globals[i].type);
|
||||
globals[i].ofs = LittleShort (globals[i].ofs);
|
||||
globals[i].s_name = LittleLong (globals[i].s_name);
|
||||
}
|
||||
SafeWrite (h, globals, numglobaldefs * sizeof (ddef_t));
|
||||
Qwrite (h, globals, numglobaldefs * sizeof (ddef_t));
|
||||
|
||||
progs.ofs_fielddefs = ftell (h);
|
||||
progs.ofs_fielddefs = Qtell (h);
|
||||
progs.numfielddefs = numfielddefs;
|
||||
for (i = 0; i < numfielddefs; i++) {
|
||||
fields[i].type = LittleShort (fields[i].type);
|
||||
fields[i].ofs = LittleShort (fields[i].ofs);
|
||||
fields[i].s_name = LittleLong (fields[i].s_name);
|
||||
}
|
||||
SafeWrite (h, fields, numfielddefs * sizeof (ddef_t));
|
||||
Qwrite (h, fields, numfielddefs * sizeof (ddef_t));
|
||||
|
||||
progs.ofs_globals = ftell (h);
|
||||
progs.ofs_globals = Qtell (h);
|
||||
progs.numglobals = pr.near_data->size;
|
||||
for (i = 0; i < pr.near_data->size; i++)
|
||||
G_INT (i) = LittleLong (G_INT (i));
|
||||
SafeWrite (h, pr.near_data->data, pr.near_data->size * 4);
|
||||
Qwrite (h, pr.near_data->data, pr.near_data->size * 4);
|
||||
|
||||
if (options.verbosity >= -1)
|
||||
printf ("%6i TOTAL SIZE\n", (int) ftell (h));
|
||||
printf ("%6i TOTAL SIZE\n", (int) Qtell (h));
|
||||
|
||||
progs.entityfields = pr.entity_data->size;
|
||||
|
||||
|
@ -270,28 +270,28 @@ WriteData (int crc)
|
|||
for (i = 0; i < sizeof (progs) / 4; i++)
|
||||
((int *) &progs)[i] = LittleLong (((int *) &progs)[i]);
|
||||
|
||||
fseek (h, 0, SEEK_SET);
|
||||
SafeWrite (h, &progs, sizeof (progs));
|
||||
fclose (h);
|
||||
Qseek (h, 0, SEEK_SET);
|
||||
Qwrite (h, &progs, sizeof (progs));
|
||||
Qclose (h);
|
||||
|
||||
if (!options.code.debug) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
h = SafeOpenRead (options.output_file);
|
||||
h = Qopen (options.output_file, "rb");
|
||||
|
||||
debug.version = LittleLong (PROG_DEBUG_VERSION);
|
||||
CRC_Init (&debug.crc);
|
||||
while ((i = fgetc (h)) != EOF)
|
||||
while ((i = Qgetc (h)) != EOF)
|
||||
CRC_ProcessByte (&debug.crc, i);
|
||||
fclose (h);
|
||||
Qclose (h);
|
||||
debug.crc = LittleShort (debug.crc);
|
||||
debug.you_tell_me_and_we_will_both_know = 0;
|
||||
|
||||
h = SafeOpenWrite (debugfile);
|
||||
SafeWrite (h, &debug, sizeof (debug));
|
||||
h = Qopen (debugfile, "wb");
|
||||
Qwrite (h, &debug, sizeof (debug));
|
||||
|
||||
debug.auxfunctions = LittleLong (ftell (h));
|
||||
debug.auxfunctions = LittleLong (Qtell (h));
|
||||
debug.num_auxfunctions = LittleLong (pr.num_auxfunctions);
|
||||
for (i = 0; i < pr.num_auxfunctions; i++) {
|
||||
pr.auxfunctions[i].function = LittleLong (pr.auxfunctions[i].function);
|
||||
|
@ -300,29 +300,29 @@ WriteData (int crc)
|
|||
pr.auxfunctions[i].local_defs = LittleLong (pr.auxfunctions[i].local_defs);
|
||||
pr.auxfunctions[i].num_locals = LittleLong (pr.auxfunctions[i].num_locals);
|
||||
}
|
||||
SafeWrite (h, pr.auxfunctions,
|
||||
pr.num_auxfunctions * sizeof (pr_auxfunction_t));
|
||||
Qwrite (h, pr.auxfunctions,
|
||||
pr.num_auxfunctions * sizeof (pr_auxfunction_t));
|
||||
|
||||
debug.linenos = LittleLong (ftell (h));
|
||||
debug.linenos = LittleLong (Qtell (h));
|
||||
debug.num_linenos = LittleLong (pr.num_linenos);
|
||||
for (i = 0; i < pr.num_linenos; i++) {
|
||||
pr.linenos[i].fa.addr = LittleLong (pr.linenos[i].fa.addr);
|
||||
pr.linenos[i].line = LittleLong (pr.linenos[i].line);
|
||||
}
|
||||
SafeWrite (h, pr.linenos, pr.num_linenos * sizeof (pr_lineno_t));
|
||||
Qwrite (h, pr.linenos, pr.num_linenos * sizeof (pr_lineno_t));
|
||||
|
||||
debug.locals = LittleLong (ftell (h));
|
||||
debug.locals = LittleLong (Qtell (h));
|
||||
debug.num_locals = LittleLong (pr.num_locals);
|
||||
for (i = 0; i < pr.num_locals; i++) {
|
||||
pr.locals[i].type = LittleShort (pr.locals[i].type);
|
||||
pr.locals[i].ofs = LittleShort (pr.locals[i].ofs);
|
||||
pr.locals[i].s_name = LittleLong (pr.locals[i].s_name);
|
||||
}
|
||||
SafeWrite (h, pr.locals, pr.num_locals * sizeof (ddef_t));
|
||||
Qwrite (h, pr.locals, pr.num_locals * sizeof (ddef_t));
|
||||
|
||||
fseek (h, 0, SEEK_SET);
|
||||
SafeWrite (h, &debug, sizeof (debug));
|
||||
fclose (h);
|
||||
Qseek (h, 0, SEEK_SET);
|
||||
Qwrite (h, &debug, sizeof (debug));
|
||||
Qclose (h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue