From 544ca8118a5f6ec7889c5876493b95aad71eaa0f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 5 Mar 2002 21:47:03 +0000 Subject: [PATCH] "gib" never got all that useful, and with the new command parser coming in and csqc, it's pretty obsolete, too. --- include/QF/Makefile.am | 2 +- include/QF/gib.h | 73 ---------- libs/Makefile.am | 2 +- libs/gib/Makefile.am | 13 -- libs/gib/gib.c | 98 -------------- libs/gib/gib_error.h | 43 ------ libs/gib/gib_instructions.c | 261 ------------------------------------ libs/gib/gib_instructions.h | 43 ------ libs/gib/gib_interpret.c | 233 -------------------------------- libs/gib/gib_interpret.h | 48 ------- libs/gib/gib_modules.c | 191 -------------------------- libs/gib/gib_modules.h | 41 ------ libs/gib/gib_parse.c | 246 --------------------------------- libs/gib/gib_parse.h | 41 ------ libs/gib/gib_stack.c | 105 --------------- libs/gib/gib_stack.h | 62 --------- libs/gib/gib_vars.c | 104 -------------- libs/gib/gib_vars.h | 37 ----- nq/source/Makefile.am | 1 - nq/source/host.c | 3 - 20 files changed, 2 insertions(+), 1645 deletions(-) delete mode 100644 include/QF/gib.h delete mode 100644 libs/gib/Makefile.am delete mode 100644 libs/gib/gib.c delete mode 100644 libs/gib/gib_error.h delete mode 100644 libs/gib/gib_instructions.c delete mode 100644 libs/gib/gib_instructions.h delete mode 100644 libs/gib/gib_interpret.c delete mode 100644 libs/gib/gib_interpret.h delete mode 100644 libs/gib/gib_modules.c delete mode 100644 libs/gib/gib_modules.h delete mode 100644 libs/gib/gib_parse.c delete mode 100644 libs/gib/gib_parse.h delete mode 100644 libs/gib/gib_stack.c delete mode 100644 libs/gib/gib_stack.h delete mode 100644 libs/gib/gib_vars.c delete mode 100644 libs/gib/gib_vars.h diff --git a/include/QF/Makefile.am b/include/QF/Makefile.am index b269ae6d9..2733aae92 100644 --- a/include/QF/Makefile.am +++ b/include/QF/Makefile.am @@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = foreign SUBDIRS = GL plugin includedir = $(prefix)/include/QF include_HEADERS = bspfile.h cdaudio.h checksum.h clip_hull.h cmd.h \ - console.h crc.h csqc.h cvar.h draw.h gcc_attr.h gib.h hash.h hl.h \ + console.h crc.h csqc.h cvar.h draw.h gcc_attr.h hash.h hl.h \ in_event.h info.h input.h joystick.h keys.h link.h locs.h \ mathlib.h mdfour.h model.h modelgen.h msg.h pcx.h plugin.h \ pr_comp.h pr_debug.h progs.h qargs.h qdefs.h qendian.h qfplist.h \ diff --git a/include/QF/gib.h b/include/QF/gib.h deleted file mode 100644 index fc89aee68..000000000 --- a/include/QF/gib.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - gib.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#ifndef __GIB_H -#define __GIB_H - -typedef int (*gib_func_t) (void); - -typedef struct gib_var_s -{ - char *key; - char *value; - struct gib_var_s *next; -} gib_var_t; - - -typedef struct gib_sub_s -{ - char *name; - char *code; - gib_var_t *vars; - struct gib_sub_s *next; -} gib_sub_t; - -typedef struct gib_module_s -{ - char *name; - gib_sub_t *subs; - gib_var_t *vars; - struct gib_module_s *next; -} gib_module_t; - -typedef struct gib_inst_s -{ - char *name; - gib_func_t func; - struct gib_inst_s *next; -} gib_inst_t; - -void GIB_Init (void); -void GIB_Gib_f (void); -void GIB_Load_f (void); -void GIB_Stats_f (void); - -#endif // __GIB_H diff --git a/libs/Makefile.am b/libs/Makefile.am index 86127765d..25104c51c 100644 --- a/libs/Makefile.am +++ b/libs/Makefile.am @@ -1,3 +1,3 @@ AUTOMAKE_OPTIONS= foreign -SUBDIRS= audio console gamecode gib models video util +SUBDIRS= audio console gamecode models video util diff --git a/libs/gib/Makefile.am b/libs/gib/Makefile.am deleted file mode 100644 index 59602850b..000000000 --- a/libs/gib/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -AUTOMAKE_OPTIONS= foreign - -INCLUDES= -I$(top_srcdir)/include - -lib_LTLIBRARIES = libQFgib.la - -libQFgib_la_LDFLAGS = -version-info 1:0:0 -libQFgib_la_SOURCES = gib.c gib_instructions.c gib_interpret.c \ - gib_modules.c gib_parse.c gib_stack.c gib_vars.c -EXTRA_DIST = gib_error.h gib_instructions.h gib_interpret.h gib_modules.h \ - gib_parse.h gib_stack.h gib_vars.h - -LIBLIST = libQFgib.la @LIBRARY_SEARCH_PATH@ diff --git a/libs/gib/gib.c b/libs/gib/gib.c deleted file mode 100644 index 685d8cd8a..000000000 --- a/libs/gib/gib.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - gib.c - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 -#endif - - -#include "QF/cmd.h" -#include "QF/gib.h" -#include "QF/sys.h" -#include "QF/vfs.h" - -#include "compat.h" -#include "gib_instructions.h" -#include "gib_interpret.h" -#include "gib_modules.h" -#include "gib_parse.h" - - -void -GIB_Init (void) -{ - Cmd_AddCommand ("gibload", GIB_Load_f, "No Description"); - Cmd_AddCommand ("gibstats", GIB_Stats_f, "No Description"); - Cmd_AddCommand ("gib", GIB_Gib_f, "No Description"); - GIB_Init_Instructions (); -} - -void -GIB_Gib_f (void) -{ - int i, ret; - gib_module_t *mod; - gib_sub_t *sub; - - if (!(mod = GIB_Get_ModSub_Mod (Cmd_Argv (1)))) { - Sys_Printf ("Module not found!\n"); - return; - } - if (!(sub = GIB_Get_ModSub_Sub (Cmd_Argv (1)))) - Sys_Printf ("Subroutine not found!\n"); - else { - gib_subargc = Cmd_Argc () - 1; - gib_subargv[0] = sub->name; - for (i = 1; i <= gib_subargc; i++) - gib_subargv[i] = Cmd_Argv (i + 1); - ret = GIB_Run_Sub (mod, sub); - if (ret != 0) - Sys_Printf ("Error in execution of %s!\nError code: %i\n", - Cmd_Argv (1), ret); - } -} - -void -GIB_Load_f (void) -{ - char filename[256]; - VFile *f; - - snprintf (filename, sizeof (filename), "%s/%s.gib", com_gamedir, - Cmd_Argv (1)); - f = Qopen (filename, "r"); - if (f) { - GIB_Module_Load (Cmd_Argv (1), f); - Qclose (f); - } else - Sys_Printf ("gibload: File not found.\n"); -} diff --git a/libs/gib/gib_error.h b/libs/gib/gib_error.h deleted file mode 100644 index a757cf347..000000000 --- a/libs/gib/gib_error.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - gib_error.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#define GIB_E_EXIT -2 -#define GIB_E_RETURN -1 -#define GIB_E_PARSE 1 -#define GIB_E_NUMARGS 2 -#define GIB_E_ARG 3 -#define GIB_E_CALLS 4 -#define GIB_E_NOSUB 5 -#define GIB_E_NOVAR 6 -#define GIB_E_BUFFER 7 -#define GIB_E_TYPE 8 -#define GIB_E_ULIMIT 9 -#define GIB_E_ILLINST 10 diff --git a/libs/gib/gib_instructions.c b/libs/gib/gib_instructions.c deleted file mode 100644 index 8129959cf..000000000 --- a/libs/gib/gib_instructions.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - gib_instructions.c - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 -#endif -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif - -#include -#include - -#include "QF/cmd.h" -#include "QF/gib.h" -#include "QF/sys.h" - -#include "gib_error.h" -#include "gib_instructions.h" -#include "gib_interpret.h" -#include "gib_parse.h" -#include "gib_vars.h" - -static gib_inst_t *gibinstructions; - -char *gib_subret; - - -void -GIB_AddInstruction (const char *name, gib_func_t func) -{ - gib_inst_t *new; - - new = malloc (sizeof (gib_inst_t)); - new->name = malloc (strlen (name) + 1); - new->func = func; - strcpy (new->name, name); - new->next = gibinstructions; - gibinstructions = new; -} - -gib_inst_t * -GIB_Find_Instruction (const char *name) -{ - gib_inst_t *inst; - - if (!(gibinstructions)) - return 0; - for (inst = gibinstructions; strcmp (inst->name, name); inst = inst->next) - if (!(inst->next)) - return 0; - return inst; -} - -void -GIB_Init_Instructions (void) -{ - GIB_AddInstruction ("echo", GIB_Echo_f); - GIB_AddInstruction ("call", GIB_Call_f); - GIB_AddInstruction ("return", GIB_Return_f); - GIB_AddInstruction ("con", GIB_Con_f); - GIB_AddInstruction ("listfetch", GIB_ListFetch_f); -} - -int -GIB_Echo_f (void) -{ - Sys_Printf (GIB_Argv (1)); - return 0; -} - -int -GIB_Call_f (void) -{ - int ret, i; - gib_module_t *mod; - gib_sub_t *sub; - - mod = GIB_Get_ModSub_Mod (GIB_Argv (1)); - if (!mod) - return GIB_E_NOSUB; - sub = GIB_Get_ModSub_Sub (GIB_Argv (1)); - if (!sub) - return GIB_E_NOSUB; - gib_subargc = GIB_Argc () - 1; - gib_subargv[0] = sub->name; - for (i = 1; i <= gib_subargc; i++) - gib_subargv[i] = GIB_Argv (i + 1); - ret = GIB_Run_Sub (mod, sub); - if (gib_subret) { - GIB_Var_Set ("retval", gib_subret); - free (gib_subret); - } - gib_subret = 0; - return ret; -} - -int -GIB_VarPrint_f (void) -{ - int i; - gib_var_t *var; - - for (i = 1; i <= GIB_Argc (); i++) { - var = GIB_Var_FindLocal (GIB_Argv (i)); - if (!var) - return GIB_E_NOVAR; - Sys_Printf ("%s", var->value); - } - Sys_Printf ("\n"); - return 0; -} - -int -GIB_Return_f (void) -{ - if (GIB_Argc () != 1) - return GIB_E_NUMARGS; - gib_subret = malloc (strlen (GIB_Argv (1)) + 1); - strcpy (gib_subret, GIB_Argv (1)); - return GIB_E_RETURN; // Signal to block executor to return - // - // - // immediately -} - -int -GIB_ListFetch_f (void) -{ - char *element; - int i, m, n; - gib_var_t *var; - - if (GIB_Argc () != 2) - return GIB_E_NUMARGS; - - if (!(var = GIB_Var_FindLocal (GIB_Argv (1)))) - return GIB_E_NOVAR; - for (i = 0; isspace ((byte)var->value[i]); i++); - for (n = 1; n < atoi (GIB_Argv (2)); n++) { - if ((m = GIB_Get_Arg (var->value + i)) < 1) - return GIB_E_ULIMIT; - i += m; - for (; isspace ((byte)var->value[i]); i++); - } - if ((m = GIB_Get_Arg (var->value + i)) < 1) - return GIB_E_ULIMIT; - element = malloc (m + 1); - strncpy (element, var->value + i, m); - element[m] = 0; - GIB_Var_Set ("retval", element); - return 0; -} - -int -GIB_Con_f (void) -{ - if (GIB_Argc () != 1) - return GIB_E_NUMARGS; - - Cmd_ExecuteString (GIB_Argv (1), src_command); - - return 0; -} - -int -GIB_ExpandVars (const char *source, char *buffer, int buffersize) -{ - char varname[256]; - int i, m, n; - gib_var_t *var; - - for (i = 0, n = 0; i <= strlen (source); i++) { - if (source[i] == '$') { - m = 0; - while (isalnum ((byte)source[++i])) - varname[m++] = source[i]; - - varname[m++] = 0; - if (!(var = GIB_Var_FindLocal (varname))) - return GIB_E_NOVAR; - if (n + strlen (var->value) >= buffersize) - return GIB_E_BUFFER; - memcpy (buffer + n, var->value, strlen (var->value)); - - n += strlen (var->value); - i--; - } else { - if (n >= buffersize + 1) - return GIB_E_BUFFER; - buffer[n++] = source[i]; - } - } - return 0; -} - -int -GIB_ExpandBackticks (const char *source, char *buffer, int buffersize) -{ - char tick[256]; - int ret, i, m, n; - gib_var_t *var; - - for (i = 0, n = 0; i <= strlen (source); i++) { - if (source[i] == '`') { - m = 0; - while (source[++i] != '`') - tick[m++] = source[i]; - - tick[m++] = 0; - ret = GIB_Run_Inst (tick); - if (ret) { - return ret; - } - if (!(var = GIB_Var_FindLocal ("retval"))) - return GIB_E_NOVAR; - if (n + strlen (var->value) >= buffersize) - return GIB_E_BUFFER; - memcpy (buffer + n, var->value, strlen (var->value)); - - n += strlen (var->value); - } else { - if (n >= buffersize + 1) - return GIB_E_BUFFER; - buffer[n++] = source[i]; - } - } - return 0; -} diff --git a/libs/gib/gib_instructions.h b/libs/gib/gib_instructions.h deleted file mode 100644 index f9554a5ab..000000000 --- a/libs/gib/gib_instructions.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - gib_instructions.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#include "QF/gib.h" - -void GIB_AddInstruction (const char *name, gib_func_t func); -gib_inst_t *GIB_Find_Instruction (const char *name); -void GIB_Init_Instructions (void); -int GIB_Echo_f (void); -int GIB_Call_f (void); -int GIB_Return_f (void); -int GIB_Con_f (void); -int GIB_ListFetch_f (void); -int GIB_ExpandVars (const char *source, char *buffer, int bufferlen); -int GIB_ExpandBackticks (const char *source, char *buffer, int bufferlen); diff --git a/libs/gib/gib_interpret.c b/libs/gib/gib_interpret.c deleted file mode 100644 index 6fa604114..000000000 --- a/libs/gib/gib_interpret.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - gib_interpret.c - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 -#endif -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif - -#include -#include -#include - -#include "QF/gib.h" - -#include "compat.h" -#include "gib_error.h" -#include "gib_instructions.h" -#include "gib_interpret.h" -#include "gib_parse.h" -#include "gib_stack.h" -#include "gib_vars.h" - -const char *gib_subargv[256]; -int gib_subargc; - - -const char * -GIB_Argv (int i) -{ - return gib_instack[gib_insp - 1].argv[i]; -} - -int -GIB_Argc (void) -{ - return gib_instack[gib_insp - 1].argc; -} - -void -GIB_Strip_Arg (char *arg) -{ - if (arg[0] == '{' || arg[0] == '\'' || arg[0] == '\"') { - arg[strlen (arg) - 1] = 0; - memmove (arg, arg + 1, strlen (arg)); - } -} - -int -GIB_Execute_Block (const char *block, int retflag) -{ - char *code; - int len, ret, i; - - i = 0; - - while ((len = GIB_Get_Inst (block + i)) > 0) { - code = malloc (len + 1); - strncpy (code, block + i, len); - code[len] = 0; - if ((ret = GIB_Interpret_Inst (code))) { - free (code); - return ret; - } - if ((ret = GIB_Execute_Inst ())) { - free (code); - if (ret == GIB_E_RETURN && retflag) - return 0; - return ret; - } - i += len + 1; - free (code); - } - if (len == -1) - return GIB_E_PARSE; - return 0; -} - -int -GIB_Execute_Inst (void) -{ - int ret; - - ret = gib_instack[gib_insp - 1].instruction->func (); - GIB_InStack_Pop (); - return ret; -} - -int -GIB_Interpret_Inst (const char *inst) -{ - char *buffer, *buffer2, *buffer3; - char *gib_argv[256]; - int gib_argc, len, ret, i, n; - gib_inst_t *ginst; - - buffer = malloc (strlen (inst) + 1); - i = 0; - - while (isspace ((unsigned char) inst[i])) - i++; - - for (n = 0; i <= strlen (inst); i++) { - if (inst[i] == '\n' || inst[i] == '\t') - buffer[n] = ' '; - else - buffer[n] = inst[i]; - n++; - } - - buffer2 = malloc (2048); - buffer3 = malloc (2048); - ret = GIB_ExpandVars (buffer, buffer2, 2048); - if (ret) - return ret; - ret = GIB_ExpandBackticks (buffer2, buffer3, 2048); - if (ret) - return ret; - gib_argc = 0; - for (i = 0; buffer3[i] != ' '; i++) - if (buffer3[i] == '\0') - return GIB_E_PARSE; - - gib_argv[0] = malloc (i + 1); - strncpy (gib_argv[0], buffer3, i); - gib_argv[0][i] = 0; - for (n = 0;; n++) { - for (; isspace ((int) buffer3[i]); i++); - if (buffer3[i] == 0) - break; - if ((len = GIB_Get_Arg (buffer3 + i)) < 0) - return GIB_E_PARSE; - else { - gib_argv[n + 1] = malloc (len + 1); - strncpy (gib_argv[n + 1], buffer3 + i, len); - gib_argv[n + 1][len] = 0; - GIB_ExpandEscapes (gib_argv[n + 1]); - i += len; - } - } - gib_argc = n; - - free (buffer); - free (buffer2); - free (buffer3); - - for (i = 1; i <= n; i++) - GIB_Strip_Arg (gib_argv[i]); - if (!(ginst = GIB_Find_Instruction (gib_argv[0]))) - return GIB_E_ILLINST; - GIB_InStack_Push (ginst, gib_argc, gib_argv); - - for (i = 0; i <= n; i++) - free (gib_argv[i]); - return 0; -} - -int -GIB_Run_Sub (gib_module_t * mod, gib_sub_t * sub) -{ - char buf[256]; - int ret, i; - - GIB_SubStack_Push (mod, sub, 0); - - for (i = 0; i <= gib_subargc; i++) { - snprintf (buf, sizeof (buf), "arg%i", i); - GIB_Var_Set (buf, gib_subargv[i]); - } - - snprintf (buf, sizeof (buf), "%i", gib_subargc); - GIB_Var_Set ("argc", buf); - - ret = GIB_Execute_Sub (); - - if (GIB_LOCALS) - GIB_Var_FreeAll (GIB_LOCALS); - - GIB_SubStack_Pop (); - return ret; -} - -int -GIB_Execute_Sub (void) -{ - return GIB_Execute_Block (GIB_CURRENTSUB->code, 1); -} - -int -GIB_Run_Inst (const char *inst) -{ - int ret; - - ret = GIB_Interpret_Inst (inst); - if (ret) { - GIB_InStack_Pop (); - return ret; - } - return GIB_Execute_Inst (); -} diff --git a/libs/gib/gib_interpret.h b/libs/gib/gib_interpret.h deleted file mode 100644 index efb454180..000000000 --- a/libs/gib/gib_interpret.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - gib_interpret.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#include "QF/gib.h" - -#define GIB_MAXCALLS 2048 -#define GIB_MAXSUBARGS 256 - -extern const char *gib_subargv[256]; -extern int gib_subargc; - -const char *GIB_Argv(int i); -int GIB_Argc(void); -void GIB_Strip_Arg (char *arg); -int GIB_Execute_Block (const char *block, int retflag); -int GIB_Execute_Inst (void); -int GIB_Execute_Sub (void); -int GIB_Interpret_Inst (const char *inst); -int GIB_Run_Inst (const char *inst); -int GIB_Run_Sub (gib_module_t *mod, gib_sub_t *sub); diff --git a/libs/gib/gib_modules.c b/libs/gib/gib_modules.c deleted file mode 100644 index f4b41a4bf..000000000 --- a/libs/gib/gib_modules.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - gib_modules.c - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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: - - 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 -#endif -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif - -#include -#include - -#include "QF/gib.h" -#include "QF/sys.h" -#include "QF/vfile.h" - -#include "gib_modules.h" - -static gib_module_t *gibmodules; - - -void -GIB_Module_Load (const char *name, VFile *f) -{ - unsigned char line[1024]; - int namelen, nameofs; - gib_module_t *newmod; - gib_sub_t *newsub; - - newmod = GIB_Create_Module (name); - - while (Qgets (f, line, 1024)) { - if (strncmp ("sub", line, 3) == 0) { - nameofs = 3; - while (isspace (line[nameofs])) - nameofs++; - namelen = 0; - while (!(isspace (line[nameofs + namelen]))) { - namelen++; - } - line[nameofs + namelen] = 0; - newsub = GIB_Create_Sub (newmod, line + nameofs); - GIB_Read_Sub (newsub, f); - } - } -} - -gib_module_t * -GIB_Create_Module (const char *name) -{ - gib_module_t *new; - - new = malloc (sizeof (gib_module_t)); - new->name = malloc (strlen (name) + 1); - strcpy (new->name, name); - new->subs = 0; - new->vars = 0; - new->next = gibmodules; - gibmodules = new; - return new; -} - -gib_sub_t * -GIB_Create_Sub (gib_module_t * mod, const char *name) -{ - gib_sub_t *new; - - new = malloc (sizeof (gib_sub_t)); - new->name = malloc (strlen (name) + 1); - strcpy (new->name, name); - new->code = 0; - new->vars = 0; - new->next = mod->subs; - mod->subs = new; - return new; -} - -void -GIB_Read_Sub (gib_sub_t * sub, VFile *f) -{ - char line[1024]; - int insub = 0, sublen = 0; - fpos_t begin; - - while (Qgets (f, line, 1024)) { - if (strncmp ("}}", line, 2) == 0 && insub == 1) { - insub = 0; - break; - } - if (insub == 1) { - sublen += strlen (line); - } - if (strncmp ("{{", line, 2) == 0) { - Qgetpos (f, &begin); - insub = 1; - } - } - - sub->code = malloc (sublen + 1); - Qsetpos (f, &begin); - Qread (f, sub->code, sublen); - sub->code[sublen] = 0; - Sys_Printf ("Loaded sub %s\n", sub->name); -} - -gib_module_t * -GIB_Find_Module (const char *name) -{ - gib_module_t *mod; - - if (!(gibmodules)) - return 0; - for (mod = gibmodules; strcmp (mod->name, name); mod = mod->next) - if (mod->next == 0) - return 0; - return mod; -} - -gib_sub_t * -GIB_Find_Sub (gib_module_t * mod, const char *name) -{ - gib_sub_t *sub; - - if (!(mod->subs)) - return 0; - for (sub = mod->subs; strcmp (sub->name, name); sub = sub->next) - if (sub->next == 0) - return 0; - return sub; -} - -void -GIB_Stats_f (void) -{ - int modc, subc; - gib_module_t *mod; - gib_sub_t *sub; - - modc = 0; - Sys_Printf ("---=== GIB statistics ===---\n"); - for (mod = gibmodules; mod; mod = mod->next) { - Sys_Printf ("\nSubroutines for module %s:\n", mod->name); - Sys_Printf ("-------------------------------------\n"); - subc = 0; - for (sub = mod->subs; sub; sub = sub->next) { - Sys_Printf ("%s::%s\n", mod->name, sub->name); - subc++; - } - Sys_Printf ("-------------------------------------\nSubroutines: %i\n", - subc); - modc++; - } - Sys_Printf ("Modules installed: %i\n", modc); - Sys_Printf ("---=== GIB statistics ===---\n"); -} diff --git a/libs/gib/gib_modules.h b/libs/gib/gib_modules.h deleted file mode 100644 index 33868cb9c..000000000 --- a/libs/gib/gib_modules.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - gib_modules.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#include "QF/gib.h" -#include "QF/vfile.h" - -void GIB_Module_Load (const char *name, VFile *f); -gib_module_t *GIB_Create_Module (const char *name); -gib_sub_t *GIB_Create_Sub (gib_module_t *mod, const char *name); -void GIB_Read_Sub (gib_sub_t *sub, VFile *f); -gib_module_t *GIB_Find_Module (const char *name); -gib_sub_t *GIB_Find_Sub (gib_module_t *mod, const char *name); -void GIB_Stats_f (void); diff --git a/libs/gib/gib_parse.c b/libs/gib/gib_parse.c deleted file mode 100644 index 3e336bfa5..000000000 --- a/libs/gib/gib_parse.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - gib_parse.c - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 -#endif -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif - -#include "QF/gib.h" - -#include "gib_error.h" -#include "gib_modules.h" -#include "gib_parse.h" - -int -GIB_Get_Inst (const char *start) -{ - int i; - int len = 0; - - for (i = 0; start[i] != ';'; i++) { - if (start[i] == '\'') { - if ((len = GIB_End_Quote (start + i)) < 0) - return len; - else - i += len; - } - if (start[i] == '\"') { - if ((len = GIB_End_DQuote (start + i)) < 0) - return len; - else - i += len; - } - if (start[i] == '{') { - if ((len = GIB_End_Bracket (start + i)) < 0) - return len; - else - i += len; - } - if (start[i] == 0) - return 0; - } - return i; -} -int -GIB_Get_Arg (const char *start) -{ - int i; - int ret = -2; - - if (*start == '\'') { - ret = GIB_End_Quote (start) + 1; - } - if (*start == '\"') { - ret = GIB_End_DQuote (start) + 1; - } - if (*start == '{') { - ret = GIB_End_Bracket (start) + 1; - } - - if (ret == -1) - return -1; - if (ret >= 0) - return ret; - - for (i = 1; (start[i] != ' ' && start[i] != 0 && start[i] != '\'' && - start[i] != '\"' && start[i] != '{') || start[i - 1] == '\\'; - i++); - return i; -} - -int -GIB_End_Quote (const char *start) -{ - int i; - int len = 0; - - for (i = 1; start[i] != '\''; i++) { - if (start[i - 1] != '\\') { - if (start[i] == '\"') { - if ((len = GIB_End_DQuote (start + i)) < 0) - return len; - else - i += len; - } - if (start[i] == '{') { - if ((len = GIB_End_Bracket (start + i)) < 0) - return len; - else - i += len; - } - if (start[i] == 0) - return -1; - } - } - return i; -} - -int -GIB_End_DQuote (const char *start) -{ - int ret, i; - - for (i = 1; start[i] != '\"'; i++) { - if (start[i - 1] != '\\') { - if (start[i] == '\'') { - if ((ret = GIB_End_Quote (start + i)) < 0) - return ret; - else - i += ret; - } - if (start[i] == '{') { - if ((ret = GIB_End_Bracket (start + i)) < 0) - return ret; - else - i += ret; - } - if (start[i] == 0) - return -1; - } - } - return i; -} - -int -GIB_End_Bracket (const char *start) -{ - int ret, i; - - for (i = 1; start[i] != '}'; i++) { - if (start[i - 1] != '\\') { - if (start[i] == '\'') { - if ((ret = GIB_End_Quote (start + i)) < 0) - return ret; - else - i += ret; - } - if (start[i] == '\"') { - if ((ret = GIB_End_DQuote (start + i)) < 0) - return ret; - else - i += ret; - } - if (start[i] == '{') { - if ((ret = GIB_End_Bracket (start + i)) < 0) - return ret; - else - i += ret; - } - if (start[i] == 0) - return -1; - } - } - return i; -} - -gib_sub_t * -GIB_Get_ModSub_Sub (const char *modsub) -{ - char *divider; - gib_module_t *mod; - gib_sub_t *sub; - - if (!(divider = strstr (modsub, "::"))) - return 0; - *divider = 0; - mod = GIB_Find_Module (modsub); - *divider = ':'; - if (!mod) - return 0; - sub = GIB_Find_Sub (mod, divider + 2); - return sub; -} - -gib_module_t * -GIB_Get_ModSub_Mod (const char *modsub) -{ - char *divider; - gib_module_t *mod; - - if (!(divider = strstr (modsub, "::"))) - return 0; - *divider = 0; - mod = GIB_Find_Module (modsub); - *divider = ':'; - return mod; -} - -int -GIB_ExpandEscapes (char *source) -{ - int i, m; - - for (i = 0, m = 0; i <= strlen (source); i++) { - if (source[i] == '\\') { - switch (source[++i]) { - case 0: - return GIB_E_PARSE; - break; - case 'n': - case 'N': - source[m] = '\n'; - break; - default: - source[m] = source[i]; - } - } else - source[m] = source[i]; - m++; - } - return 0; -} diff --git a/libs/gib/gib_parse.h b/libs/gib/gib_parse.h deleted file mode 100644 index 9428e8f7a..000000000 --- a/libs/gib/gib_parse.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - gib_parse.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#include "QF/gib.h" - -int GIB_Get_Inst (const char *start); -int GIB_Get_Arg (const char *start); -int GIB_End_Quote (const char *start); -int GIB_End_DQuote (const char *start); -int GIB_End_Bracket (const char *start); -gib_sub_t *GIB_Get_ModSub_Sub (const char *modsub); -gib_module_t *GIB_Get_ModSub_Mod (const char *modsub); -int GIB_ExpandEscapes (char *source); diff --git a/libs/gib/gib_stack.c b/libs/gib/gib_stack.c deleted file mode 100644 index 4d49cd917..000000000 --- a/libs/gib/gib_stack.c +++ /dev/null @@ -1,105 +0,0 @@ -/* - gib_stack.c - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 -#endif -#include -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif - -#include "QF/gib.h" - -#include "gib_stack.h" - -gib_instack_t *gib_instack = 0; -gib_substack_t *gib_substack = 0; - -int gib_insp = 0; -int gib_subsp = 0; - - -void -GIB_InStack_Push (gib_inst_t * instruction, int argc, char **argv) -{ - int i; - - gib_instack = - realloc (gib_instack, sizeof (gib_instack_t) * (gib_insp + 1)); - gib_instack[gib_insp].argv = malloc ((argc + 1) * sizeof(char *)); - - 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]); - } - - gib_instack[gib_insp].argc = argc; - gib_instack[gib_insp].instruction = instruction; - gib_insp++; -} - -void -GIB_InStack_Pop (void) -{ - int i; - - gib_insp--; - - for (i = 0; i <= gib_instack[gib_insp].argc; i++) - free (gib_instack[gib_insp].argv[i]); - - free (gib_instack[gib_insp].argv); - - gib_instack = realloc (gib_instack, sizeof (gib_instack_t) * gib_insp); -} - -void -GIB_SubStack_Push (gib_module_t * mod, gib_sub_t * sub, gib_var_t * local) -{ - gib_substack = - realloc (gib_substack, sizeof (gib_substack_t) * (gib_subsp + 1)); - gib_substack[gib_subsp].mod = mod; - gib_substack[gib_subsp].sub = sub; - gib_substack[gib_subsp].local = local; - gib_subsp++; -} - -void -GIB_SubStack_Pop (void) -{ - gib_instack = realloc (gib_instack, sizeof (gib_instack_t) * - (--gib_subsp)); -} diff --git a/libs/gib/gib_stack.h b/libs/gib/gib_stack.h deleted file mode 100644 index 1b54e801d..000000000 --- a/libs/gib/gib_stack.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - gib_stack.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#include "QF/gib.h" - -#define GIB_LOCALS gib_substack[gib_subsp - 1].local -#define GIB_CURRENTMOD gib_substack[gib_subsp - 1].mod -#define GIB_CURRENTSUB gib_substack[gib_subsp - 1].sub - -typedef struct gib_instack_s -{ - gib_inst_t *instruction; - char **argv; - int argc; -} gib_instack_t; - -typedef struct gib_substack_s -{ - gib_module_t *mod; - gib_sub_t *sub; - gib_var_t *local; -} gib_substack_t; - -extern gib_instack_t *gib_instack; -extern gib_substack_t *gib_substack; - -extern int gib_insp; -extern int gib_subsp; - -void GIB_InStack_Push (gib_inst_t *instruction, int argc, char **argv); -void GIB_InStack_Pop (); -void GIB_SubStack_Push (gib_module_t *mod, gib_sub_t *sub, gib_var_t *local); -void GIB_SubStack_Pop (); - diff --git a/libs/gib/gib_vars.c b/libs/gib/gib_vars.c deleted file mode 100644 index eb881a63f..000000000 --- a/libs/gib/gib_vars.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - gib_vars.c - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 -#endif -#include -#ifdef HAVE_STRING_H -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif - -#include "QF/gib.h" - -#include "gib_stack.h" - - -gib_var_t * -GIB_Var_FindLocal (char *key) -{ - gib_var_t *var; - - if (!(GIB_LOCALS)) - return 0; - for (var = GIB_LOCALS; strcmp (key, var->key); var = var->next) - if (!(var->next)) - return 0; - return var; -} - -gib_var_t * -GIB_Var_FindGlobal (char *key) -{ - gib_var_t *var; - - if (!(GIB_CURRENTMOD->vars)) - return 0; - for (var = GIB_CURRENTMOD->vars; strcmp (key, var->key); var = var->next) - if (!(var->next)) - return 0; - return var; -} - -void -GIB_Var_Set (char *key, char *value) -{ - gib_var_t *var; - - if ((var = GIB_Var_FindLocal (key))) { - free (var->value); - } else { - var = malloc (sizeof (gib_var_t)); - var->key = malloc (strlen (key) + 1); - strcpy (var->key, key); - var->next = GIB_LOCALS; - GIB_LOCALS = var; - } - var->value = malloc (strlen (value) + 1); - strcpy (var->value, value); -} - -void -GIB_Var_FreeAll (gib_var_t * var) -{ - gib_var_t *temp; - - for (; var; var = temp) { - temp = var->next; - free (var->key); - free (var->value); - free (var); - } -} diff --git a/libs/gib/gib_vars.h b/libs/gib/gib_vars.h deleted file mode 100644 index 7d5159218..000000000 --- a/libs/gib/gib_vars.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - gib_vars.h - - #DESCRIPTION# - - Copyright (C) 2000 #AUTHOR# - - Author: #AUTHOR# - Date: #DATE# - - 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 - - $Id$ -*/ - -#include "QF/gib.h" - -gib_var_t *GIB_Var_FindLocal (const char *key); -gib_var_t *GIB_Var_FindGlobal (const char *key); -void GIB_Var_Set (const char *key, const char *value); -void GIB_Var_FreeAll (gib_var_t *var); diff --git a/nq/source/Makefile.am b/nq/source/Makefile.am index c052b7d3e..d93a5bb20 100644 --- a/nq/source/Makefile.am +++ b/nq/source/Makefile.am @@ -84,7 +84,6 @@ common_LIBFILES= \ $(top_builddir)/libs/console/libQFconsole.la \ $(top_builddir)/libs/gamecode/builtins/libQFgamecode_builtins.la \ $(top_builddir)/libs/gamecode/engine/libQFgamecode.la \ - $(top_builddir)/libs/gib/libQFgib.la \ $(top_builddir)/libs/util/libQFutil.la client_LIBS= $(client_LIBFILES) $(common_LIBFILES) diff --git a/nq/source/host.c b/nq/source/host.c index bc4c6299c..527c491c2 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -37,7 +37,6 @@ static const char rcsid[] = #include "QF/csqc.h" #include "QF/cvar.h" #include "QF/draw.h" -#include "QF/gib.h" #include "QF/input.h" #include "QF/keys.h" #include "QF/msg.h" @@ -934,8 +933,6 @@ Host_Init (void) con_module->data->console->quit = Host_Quit_f; } - GIB_Init (); - Host_InitVCR (&host_parms); Host_InitLocal ();