Moved gib_*.h into include/ and moved the necessary declarations and struct

definitions to QF/gib.h to interface with libQFgib.
This commit is contained in:
Brian Koropoff 2003-04-13 22:07:58 +00:00
parent 3b703db4d4
commit e707e9bb89
37 changed files with 176 additions and 157 deletions

View file

@ -2,10 +2,8 @@ AUTOMAKE_OPTIONS = foreign
SUBDIRS = GL plugin
includedir = $(prefix)/include/QF
include_HEADERS = bspfile.h cbuf.h cdaudio.h checksum.h clip_hull.h cmd.h \
console.h crc.h csqc.h cvar.h dstring.h draw.h gib_buffer.h \
gib_builtin.h gib_execute.h gib_function.h gib_init.h gib_parse.h \
gib_process.h gib_regex.h gib_semantics.h gib_thread.h gib_tree.h \
gib_vars.h hash.h hl.h idparse.h in_event.h info.h input.h joystick.h \
console.h crc.h csqc.h cvar.h dstring.h draw.h gib.h \
hash.h hl.h idparse.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 pak.h \
pakfile.h pcx.h plugin.h pr_comp.h pr_debug.h pr_obj.h progs.h qargs.h \
qdefs.h qendian.h qfplist.h qtypes.h quakefs.h quakeio.h render.h riff.h \

View file

@ -3,7 +3,7 @@
#DESCRIPTION#
Copyright (C) 2002 #AUTHOR#
Copyright (C) 2003 #AUTHOR#
Author: #AUTHOR#
Date: #DATE#
@ -29,14 +29,40 @@
$Id$
*/
#include "QF/cbuf.h" // For cbuf_active
#include "QF/gib_buffer.h" // For GIB_DATA()
#include "QF/dstring.h" // For ->str
#ifndef __gib_h
#define __gib_h
typedef struct gib_builtin_s {
const char *name;
void (*func) (void);
} gib_builtin_t;
// Dependencies
#include "QF/dstring.h"
#include "QF/cbuf.h"
// Buffer access (required to use GIB_Arg* macros)
#define GIB_DATA(buffer) ((gib_buffer_data_t *)(buffer->data))
typedef struct gib_script_s {
const char *text, *file;
unsigned int refs;
} gib_script_t;
typedef struct gib_buffer_data_s {
struct gib_script_s *script;
struct gib_tree_s *program, *ip;
struct dstring_s *arg_composite;
qboolean waitret;
struct gib_sstack_s {
struct gib_dsarray_s {
struct dstring_s **dstrs;
unsigned int realsize, size;
} *values;
unsigned int size, p;
} stack;
struct hashtab_s *locals; // Local variables
struct hashtab_s *globals; // Current domain
} gib_buffer_data_t;
// Builtin function interface
extern char gib_null_string[];
@ -50,11 +76,33 @@ extern char gib_null_string[];
#define GIB_CanReturn() (GIB_DATA(cbuf_active)->waitret)
void GIB_Arg_Strip_Delim (unsigned int arg);
dstring_t *GIB_Return (const char *str);
void GIB_Error (const char *type, const char *fmt, ...);
gib_builtin_t *GIB_Builtin_Add (const char *name, void (*func) (void));
void GIB_Builtin_Add (const char *name, void (*func) (void));
void GIB_Builtin_Remove (const char *name);
qboolean GIB_Builtin_Exists (const char *name);
gib_builtin_t *GIB_Builtin_Find (const char *name);
void GIB_Builtin_Init (qboolean sandbox);
// Event interface
typedef struct gib_event_s {
const char *name;
struct gib_function_s *func;
} gib_event_t;
gib_event_t *GIB_Event_New (const char *name);
void GIB_Event_Callback (gib_event_t *event, unsigned int argc, ...);
// Interpreter interface (for creating GIB cbufs)
cbuf_interpreter_t *GIB_Interpreter (void);
// Thread interface
void GIB_Thread_Execute (void);
// Init interface
void GIB_Init (qboolean sandbox);
#endif

View file

@ -33,40 +33,10 @@
#define __gib_buffer_h
#include "QF/cbuf.h"
#include "QF/gib_tree.h"
#include "gib_tree.h"
#include "QF/dstring.h"
#define GIB_DATA(buffer) ((gib_buffer_data_t *)(buffer->data))
typedef struct gib_script_s {
const char *text, *file;
unsigned int refs;
} gib_script_t;
typedef struct gib_buffer_data_s {
struct gib_script_s *script;
struct gib_tree_s *program, *ip;
struct dstring_s *arg_composite;
qboolean waitret;
struct gib_sstack_s {
struct gib_dsarray_s {
struct dstring_s **dstrs;
unsigned int realsize, size;
} *values;
unsigned int size, p;
} stack;
struct hashtab_s *locals; // Local variables
struct hashtab_s *globals; // Current domain
} gib_buffer_data_t;
void GIB_Buffer_Construct (struct cbuf_s *cbuf);
void GIB_Buffer_Destruct (struct cbuf_s *cbuf);
void GIB_Buffer_Reset (struct cbuf_s *cbuf);
void GIB_Buffer_Set_Program (cbuf_t *cbuf, gib_tree_t *program);
void GIB_Buffer_Add (cbuf_t *cbuf, const char *str);
void GIB_Buffer_Insert (cbuf_t *cbuf, const char *str);
void GIB_Buffer_Push_Sstack (struct cbuf_s *cbuf);
void GIB_Buffer_Pop_Sstack (struct cbuf_s *cbuf);
dstring_t *GIB_Buffer_Dsarray_Get (struct cbuf_s *cbuf);

View file

@ -29,4 +29,12 @@
$Id$
*/
void GIB_Init (qboolean sandbox);
#include "QF/gib.h"
typedef struct gib_builtin_s {
const char *name;
void (*func) (void);
} gib_builtin_t;
gib_builtin_t *GIB_Builtin_Find (const char *name);
void GIB_Builtin_Init (qboolean sandbox);

View file

@ -29,5 +29,4 @@
$Id$
*/
int GIB_Execute_For_Next (cbuf_t *cbuf);
void GIB_Execute (cbuf_t *cbuf);

View file

@ -34,8 +34,8 @@
#include "QF/dstring.h"
#include "QF/hash.h"
#include "QF/gib_tree.h"
#include "QF/gib_buffer.h"
#include "gib_tree.h"
typedef struct gib_function_s {
const char *name;

View file

@ -29,7 +29,7 @@
$Id$
*/
#include "QF/gib_tree.h"
#include "gib_tree.h"
inline qboolean GIB_Escaped (const char *str, int i);

View file

@ -29,7 +29,10 @@
$Id$
*/
#include "QF/dstring.h"
#include "gib_tree.h"
int GIB_Process_Embedded (gib_tree_t *node, cbuf_args_t *args);
int GIB_Process_Math (struct dstring_s *token, unsigned int i);
int GIB_Process_Math (dstring_t *token, unsigned int i);
void GIB_Process_Escapes (char *str);

View file

@ -32,7 +32,7 @@
#ifndef __gib_thread_h
#define __gib_thread_h
#include "QF/gib_function.h"
#include "gib_function.h"
typedef struct gib_thread_s {
unsigned long int id;
@ -40,20 +40,13 @@ typedef struct gib_thread_s {
struct gib_thread_s *prev, *next;
} gib_thread_t;
typedef struct gib_event_s {
const char *name;
struct gib_function_s *func;
} gib_event_t;
void GIB_Thread_Add (gib_thread_t *thread);
void GIB_Thread_Remove (gib_thread_t *thread);
void GIB_Thread_Delete (gib_thread_t *thread);
gib_thread_t *GIB_Thread_Find (unsigned long int id);
gib_thread_t *GIB_Thread_New (void);
void GIB_Thread_Execute (void);
gib_event_t *GIB_Event_New (const char *name);
int GIB_Event_Register (const char *name, gib_function_t *func);
void GIB_Event_Callback (gib_event_t *event, unsigned int argc, ...);
void GIB_Event_Init (void);
extern gib_thread_t *gib_threads;

View file

@ -56,7 +56,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/gib_builtin.h"
#include "QF/gib.h"
#include "compat.h"

View file

@ -45,7 +45,8 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/hash.h"
#include "QF/progs.h"
#include "QF/sys.h"
#include "QF/gib_builtin.h"
#include "QF/gib.h"
#include "gib_builtin.h"
typedef struct bi_gib_builtin_s {
struct bi_gib_builtin_s *next;
@ -123,7 +124,9 @@ bi_GIB_Builtin_Add (progs_t *pr)
builtin = malloc (sizeof (bi_gib_builtin_t));
builtin->builtin = GIB_Builtin_Add (name, bi_gib_builtin_f);
GIB_Builtin_Add (name, bi_gib_builtin_f);
builtin->builtin = GIB_Builtin_Find (name);
builtin->pr = pr;
builtin->func = func;
builtin->next = res->builtins;

View file

@ -43,14 +43,16 @@ const char rcsid[] = "$Id$";
#include "QF/dstring.h"
#include "QF/cbuf.h"
#include "QF/hash.h"
#include "QF/gib_parse.h"
#include "QF/gib_buffer.h"
#include "QF/gib_tree.h"
#include "QF/gib_vars.h"
#include "QF/gib_execute.h"
#include "QF/gib.h"
#include "QF/idparse.h"
void
#include "gib_tree.h"
#include "gib_parse.h"
#include "gib_vars.h"
#include "gib_execute.h"
#include "gib_buffer.h"
static void
GIB_Buffer_Construct (struct cbuf_s *cbuf)
{
cbuf->data = calloc (1, sizeof (gib_buffer_data_t));
@ -59,7 +61,7 @@ GIB_Buffer_Construct (struct cbuf_s *cbuf)
cbuf->strict = true;
}
void
static void
GIB_Buffer_Destruct (struct cbuf_s *cbuf)
{
gib_buffer_data_t *g = GIB_DATA (cbuf);
@ -86,7 +88,7 @@ GIB_Buffer_Destruct (struct cbuf_s *cbuf)
free (cbuf->data);
}
void
static void
GIB_Buffer_Reset (struct cbuf_s *cbuf)
{
gib_buffer_data_t *g = GIB_DATA (cbuf);
@ -125,7 +127,7 @@ GIB_Buffer_Get_Line_Num (const char *program, unsigned int pos)
return line;
}
void
static void
GIB_Buffer_Add (cbuf_t * cbuf, const char *str)
{
gib_buffer_data_t *g = GIB_DATA (cbuf);
@ -166,7 +168,7 @@ GIB_Buffer_Add (cbuf_t * cbuf, const char *str)
);
}
void
static void
GIB_Buffer_Insert (cbuf_t * cbuf, const char *str)
{
gib_buffer_data_t *g = GIB_DATA (cbuf);
@ -308,3 +310,9 @@ cbuf_interpreter_t gib_interp = {
GIB_Execute,
GIB_Execute,
};
cbuf_interpreter_t *
GIB_Interpreter (void)
{
return &gib_interp;
}

View file

@ -54,15 +54,16 @@ const char rcsid[] =
#include "QF/cbuf.h"
#include "QF/hash.h"
#include "QF/dstring.h"
#include "QF/gib_parse.h"
#include "QF/gib_execute.h"
#include "QF/gib_builtin.h"
#include "QF/gib_buffer.h"
#include "QF/gib_function.h"
#include "QF/gib_vars.h"
#include "QF/gib_regex.h"
#include "QF/gib_thread.h"
#include "QF/gib.h"
#include "regex.h"
#include "gib_buffer.h"
#include "gib_parse.h"
#include "gib_function.h"
#include "gib_vars.h"
#include "gib_regex.h"
#include "gib_thread.h"
#include "gib_builtin.h"
char gib_null_string[] = "";
@ -92,7 +93,7 @@ GIB_Builtin_Free (void *ele, void *ptr)
Registers a new builtin GIB command.
*/
gib_builtin_t *
void
GIB_Builtin_Add (const char *name, void (*func) (void))
{
gib_builtin_t *new;
@ -105,8 +106,6 @@ GIB_Builtin_Add (const char *name, void (*func) (void))
new->func = func;
new->name = strdup (name);
Hash_Add (gib_builtins, new);
return new;
}
void

View file

@ -41,12 +41,15 @@ const char rcsid[] =
#include "QF/cbuf.h"
#include "QF/cmd.h"
#include "QF/gib_buffer.h"
#include "QF/gib_vars.h"
#include "QF/gib_process.h"
#include "QF/gib_builtin.h"
#include "QF/gib_function.h"
#include "QF/gib_execute.h"
#include "QF/gib.h"
#include "gib_buffer.h"
#include "gib_builtin.h"
#include "gib_function.h"
#include "gib_vars.h"
#include "gib_tree.h"
#include "gib_process.h"
#include "gib_execute.h"
static void
GIB_Execute_Generate_Composite (struct cbuf_s *cbuf)
@ -172,7 +175,7 @@ GIB_Execute_Prepare_Line (cbuf_t * cbuf, gib_tree_t * line)
return 0;
}
int
static int
GIB_Execute_For_Next (cbuf_t * cbuf)
{
unsigned int index;

View file

@ -43,12 +43,13 @@ const char rcsid[] =
#include "QF/dstring.h"
#include "QF/hash.h"
#include "QF/cbuf.h"
#include "QF/gib_parse.h"
#include "QF/gib_buffer.h"
#include "QF/gib_function.h"
#include "QF/gib_vars.h"
#include "QF/gib_tree.h"
#include "QF/va.h"
#include "QF/gib.h"
#include "gib_buffer.h"
#include "gib_tree.h"
#include "gib_function.h"
#include "gib_vars.h"
hashtab_t *gib_functions = 0;

View file

@ -42,17 +42,17 @@ const char rcsid[] =
#include "QF/qtypes.h"
#include "QF/cbuf.h"
#include "QF/quakefs.h"
#include "QF/gib_parse.h"
#include "QF/gib_builtin.h"
#include "QF/gib_regex.h"
#include "QF/gib_thread.h"
#include "QF/gib_vars.h"
#include "QF/gib_buffer.h"
#include "QF/gib_init.h"
#include "QF/cmd.h"
#include "QF/sys.h"
#include "QF/zone.h"
#include "QF/cvar.h"
#include "QF/gib.h"
#include "gib_parse.h"
#include "gib_vars.h"
#include "gib_regex.h"
#include "gib_builtin.h"
#include "gib_thread.h"
static void
GIB_Exec_Override_f (void)
@ -75,16 +75,16 @@ GIB_Exec_Override_f (void)
&& (cmd_warncmd->int_val || (developer && developer->int_val)))
Sys_Printf ("execing %s\n", Cmd_Argv (1));
if (!strcmp (Cmd_Argv (1) + strlen (Cmd_Argv (1)) - 4, ".gib")
|| cbuf_active->interpreter == &gib_interp) {
|| cbuf_active->interpreter == GIB_Interpreter ()) {
// GIB script, put it in a new buffer on the stack
cbuf_t *sub = Cbuf_PushStack (&gib_interp);
cbuf_t *sub = Cbuf_PushStack (GIB_Interpreter ());
GIB_DATA (sub)->script = malloc (sizeof (gib_script_t));
GIB_DATA (sub)->script->file = strdup (Cmd_Argv (1));
GIB_DATA (sub)->script->text = strdup (f);
GIB_DATA (sub)->script->refs = 1;
Cbuf_AddText (sub, f);
if (gib_parse_error && cbuf_active->interpreter == &gib_interp)
if (gib_parse_error && cbuf_active->interpreter == GIB_Interpreter ())
GIB_Error ("parse", "%s: Parse error while executing %s.",
Cmd_Argv (0), Cmd_Argv (1));
} else

View file

@ -44,14 +44,11 @@ const char rcsid[] = "$Id$";
#include "QF/va.h"
#include "QF/cmd.h"
#include "QF/cbuf.h"
#include "QF/gib_buffer.h"
#include "QF/gib_process.h"
#include "QF/gib_builtin.h"
#include "QF/gib_function.h"
#include "QF/gib_vars.h"
#include "QF/gib_parse.h"
#include "QF/gib_semantics.h"
#include "QF/gib.h"
#include "gib_parse.h"
#include "gib_process.h"
#include "gib_semantics.h"
/*
GIB_Escaped

View file

@ -43,13 +43,12 @@ const char rcsid[] = "$Id$";
#include "QF/dstring.h"
#include "QF/cbuf.h"
#include "QF/cvar.h"
#include "QF/gib_buffer.h"
#include "QF/gib_parse.h"
#include "QF/gib_vars.h"
#include "QF/gib_process.h"
#include "QF/gib_builtin.h"
#include "QF/gib.h"
#include "exp.h"
#include "gib_buffer.h"
#include "gib_vars.h"
#include "gib_process.h"
int
GIB_Process_Math (struct dstring_s *token, unsigned int i)

View file

@ -44,7 +44,7 @@ const char rcsid[] =
#include "regex.h"
#include "QF/dstring.h"
#include "QF/hash.h"
#include "QF/gib_regex.h"
#include "gib_regex.h"
#include "QF/qtypes.h"
hashtab_t *gib_regexs;

View file

@ -31,9 +31,9 @@
#include <string.h>
#include "QF/qtypes.h"
#include "QF/gib_tree.h"
#include "QF/gib_parse.h"
#include "QF/gib_semantics.h"
#include "gib_tree.h"
#include "gib_parse.h"
#include "gib_semantics.h"
static gib_tree_t *
GIB_Semantic_Normal_To_Lines (gib_tree_t * tokens, const char *program, gib_tree_flags_t flags, unsigned int start, unsigned int end)

View file

@ -41,13 +41,14 @@ const char rcsid[] = "$Id$";
#include "QF/sys.h"
#include "QF/cbuf.h"
#include "QF/gib_parse.h"
#include "QF/gib_thread.h"
#include "QF/gib_function.h"
#include "QF/gib_buffer.h"
#include "QF/gib.h"
#include "QF/dstring.h"
#include "QF/hash.h"
#include "gib_tree.h"
#include "gib_function.h"
#include "gib_thread.h"
gib_thread_t *gib_threads = 0;
gib_thread_t **gib_thread_p = &gib_threads;
@ -94,7 +95,7 @@ GIB_Thread_New (void)
{
gib_thread_t *new = calloc (1, sizeof (gib_thread_t));
new->cbuf = Cbuf_New (&gib_interp);
new->cbuf = Cbuf_New (GIB_Interpreter ());
new->id = nextid;
nextid++;
return new;

View file

@ -40,7 +40,7 @@ const char rcsid[] = "$Id$";
#include "QF/sys.h"
#include "QF/qtypes.h"
#include "QF/gib_tree.h"
#include "gib_tree.h"
gib_tree_t *
GIB_Tree_New (enum gib_tree_type_e type)

View file

@ -42,9 +42,9 @@ const char rcsid[] = "$Id$";
#include "QF/va.h"
#include "QF/hash.h"
#include "QF/cvar.h"
#include "QF/gib_vars.h"
#include "QF/gib_buffer.h"
#include "QF/gib_parse.h"
#include "gib_parse.h"
#include "gib_vars.h"
hashtab_t *gib_globals = 0;
hashtab_t *gib_domains = 0;

View file

@ -51,7 +51,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/screen.h"
#include "QF/sys.h"
#include "QF/zone.h"
#include "QF/gib_builtin.h"
#include "QF/gib.h"
#include "compat.h"
#include "old_keys.h"

View file

@ -50,8 +50,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/gib_thread.h"
#include "QF/gib_init.h"
#include "QF/gib.h"
#include "buildnum.h"
#include "chase.h"

View file

@ -29,7 +29,7 @@
$Id$
*/
#include "QF/gib_thread.h"
#include "QF/gib.h"
extern gib_event_t *sv_chat_e;
extern gib_event_t *sv_client_connect_e;

View file

@ -83,8 +83,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/teamplay.h"
#include "QF/va.h"
#include "QF/vid.h"
#include "QF/gib_thread.h"
#include "QF/gib_init.h"
#include "QF/gib.h"
#include "bothdefs.h"
#include "buildnum.h"

View file

@ -58,8 +58,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/teamplay.h"
#include "QF/va.h"
#include "QF/dstring.h"
#include "QF/gib_vars.h"
#include "QF/gib_thread.h"
#include "QF/gib.h"
#include "bothdefs.h"
#include "cl_cam.h"

View file

@ -41,8 +41,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/dstring.h"
#include "QF/hash.h"
#include "QF/info.h"
#include "QF/gib_builtin.h"
#include "QF/gib_thread.h"
#include "QF/gib.h"
#include "server.h"
#include "client.h"

View file

@ -65,10 +65,6 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/cbuf.h"
#include "QF/idparse.h"
#include "QF/gib_parse.h"
#include "QF/gib_buffer.h"
#include "QF/gib_thread.h"
#include "QF/gib_init.h"
#include "QF/cmd.h"
#include "QF/console.h"
#include "QF/cvar.h"

View file

@ -55,7 +55,6 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/quakefs.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/gib_thread.h"
#include "bothdefs.h"
#include "compat.h"

View file

@ -52,7 +52,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/teamplay.h"
#include "QF/va.h"
#include "QF/skin.h"
#include "QF/gib_builtin.h"
#include "QF/gib.h"
#include "bothdefs.h"
#include "cl_input.h"

View file

@ -10,15 +10,13 @@
#include "QF/zone.h"
#include "QF/quakefs.h"
#include "QF/quakeio.h"
#include "QF/gib_parse.h"
#include "QF/gib_init.h"
#include "QF/gib_thread.h"
#include "QF/gib_function.h"
#include "QF/gib_builtin.h"
#include "QF/gib_buffer.h"
#include "QF/gib.h"
#include "QF/dstring.h"
#include "QF/va.h"
#include "gib_thread.h"
#include "gib_parse.h"
extern gib_thread_t *gib_threads;
static qboolean carne_done = false;
@ -39,7 +37,7 @@ static int
Carne_Execute_Script (const char *path, cbuf_args_t *args)
{
QFile *file;
cbuf_t *mbuf = Cbuf_New (&gib_interp);
cbuf_t *mbuf = Cbuf_New (GIB_Interpreter ());
char *f;
int len, i;
@ -92,7 +90,7 @@ static int
Carne_Execute_Stdin (void)
{
char linebuf[1024];
cbuf_t *cbuf = Cbuf_New (&gib_interp);
cbuf_t *cbuf = Cbuf_New (GIB_Interpreter ());
memset (linebuf, 0, sizeof(linebuf));