2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/console.h"
|
|
|
|
#include "QF/qargs.h"
|
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/zone.h"
|
|
|
|
#include "QF/quakefs.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "gib.h"
|
|
|
|
#include "gib_instructions.h"
|
|
|
|
#include "gib_interpret.h"
|
|
|
|
#include "gib_modules.h"
|
|
|
|
#include "gib_parse.h"
|
|
|
|
#include "gib_vars.h"
|
|
|
|
#include "gib_error.h"
|
|
|
|
#include "gib_stack.h"
|
|
|
|
|
|
|
|
gib_instack_t *gib_instack = 0;
|
|
|
|
gib_substack_t *gib_substack = 0;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int gib_insp = 0;
|
|
|
|
int gib_subsp = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
GIB_InStack_Push (gib_inst_t * instruction, int argc, char **argv)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
gib_instack =
|
|
|
|
realloc (gib_instack, sizeof (gib_instack_t) * (gib_insp + 1));
|
|
|
|
gib_instack[gib_insp].argv = malloc (argc + 1);
|
|
|
|
|
|
|
|
for (i = 0; i <= argc; i++) {
|
|
|
|
gib_instack[gib_insp].argv[i] = malloc (strlen (argv[i]) + 1);
|
|
|
|
strcpy (gib_instack[gib_insp].argv[i], argv[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gib_instack[gib_insp].argc = argc;
|
|
|
|
gib_instack[gib_insp].instruction = instruction;
|
|
|
|
gib_insp++;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
GIB_InStack_Pop (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
gib_insp--;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0; i <= gib_instack[gib_insp].argc; i++)
|
2001-02-26 06:48:02 +00:00
|
|
|
free (gib_instack[gib_insp].argv[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
free (gib_instack[gib_insp].argv);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
gib_instack = realloc (gib_instack, sizeof (gib_instack_t) * gib_insp);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
GIB_SubStack_Push (gib_module_t * mod, gib_sub_t * sub, gib_var_t * local)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
gib_substack =
|
|
|
|
realloc (gib_substack, sizeof (gib_substack_t) * (gib_subsp + 1));
|
2001-02-19 21:15:25 +00:00
|
|
|
gib_substack[gib_subsp].mod = mod;
|
|
|
|
gib_substack[gib_subsp].sub = sub;
|
|
|
|
gib_substack[gib_subsp].local = local;
|
|
|
|
gib_subsp++;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
GIB_SubStack_Pop (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
gib_instack = realloc (gib_instack, sizeof (gib_instack_t) * (--gib_subsp));
|
|
|
|
}
|