2002-07-30 17:08:53 +00:00
|
|
|
/*
|
|
|
|
#FILENAME#
|
|
|
|
|
|
|
|
#DESCRIPTION#
|
|
|
|
|
|
|
|
Copyright (C) 2002 #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 __QF_cbuf_h
|
|
|
|
#define __QF_cbuf_h
|
|
|
|
|
2002-08-02 04:07:25 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/qtypes.h"
|
|
|
|
|
2002-07-30 17:08:53 +00:00
|
|
|
typedef struct cbuf_args_s {
|
|
|
|
int argc;
|
|
|
|
struct dstring_s **argv;
|
|
|
|
const char **args;
|
|
|
|
int argv_size;
|
|
|
|
} cbuf_args_t;
|
|
|
|
|
2002-08-03 06:04:00 +00:00
|
|
|
|
2002-07-30 17:08:53 +00:00
|
|
|
typedef struct cbuf_s {
|
|
|
|
struct dstring_s *buf;
|
|
|
|
struct dstring_s *line;
|
|
|
|
cbuf_args_t *args;
|
2002-08-03 06:04:00 +00:00
|
|
|
struct cbuf_interpreter_s *interpreter;
|
2002-07-31 22:03:53 +00:00
|
|
|
|
|
|
|
struct cbuf_s *up, *down; // The stack
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CBUF_STATE_NORMAL = 0, // Normal condition
|
|
|
|
CBUF_STATE_WAIT, // Buffer is stalled until next frame
|
|
|
|
CBUF_STATE_ERROR, // An unrecoverable error occured
|
|
|
|
CBUF_STATE_STACK, // A buffer has been added to the stack
|
|
|
|
} state;
|
|
|
|
|
2002-11-14 02:10:55 +00:00
|
|
|
qboolean strict; // Should we tolerate unknown commands?
|
|
|
|
|
2002-10-13 19:46:47 +00:00
|
|
|
double resumetime; // Time when stack can be executed again
|
|
|
|
|
2002-07-31 22:03:53 +00:00
|
|
|
void *data; // Pointer to a custom structure if needed
|
2002-07-30 17:08:53 +00:00
|
|
|
} cbuf_t;
|
|
|
|
|
2002-08-03 06:04:00 +00:00
|
|
|
typedef struct cbuf_interpreter_s {
|
|
|
|
void (*extract_line) (struct cbuf_s *cbuf);
|
|
|
|
void (*parse_line) (struct cbuf_s *cbuf);
|
|
|
|
void (*execute_line) (struct cbuf_s *cbuf);
|
|
|
|
void (*construct) (struct cbuf_s *cbuf);
|
|
|
|
void (*destruct) (struct cbuf_s *cbuf);
|
|
|
|
} cbuf_interpreter_t;
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
extern cbuf_t *cbuf_active;
|
|
|
|
|
|
|
|
cbuf_args_t *Cbuf_ArgsNew (void);
|
|
|
|
void Cbuf_ArgsDelete (cbuf_args_t *);
|
|
|
|
void Cbuf_ArgsAdd (cbuf_args_t *args, const char *arg);
|
|
|
|
|
2002-08-03 06:04:00 +00:00
|
|
|
cbuf_t * Cbuf_New (cbuf_interpreter_t *interp);
|
2002-08-02 04:07:25 +00:00
|
|
|
|
2002-08-01 02:42:19 +00:00
|
|
|
void Cbuf_Delete (cbuf_t *cbuf);
|
2002-08-03 06:04:00 +00:00
|
|
|
void Cbuf_DeleteStack (cbuf_t *stack);
|
2002-07-30 17:08:53 +00:00
|
|
|
void Cbuf_AddText (cbuf_t *cbuf, const char *text);
|
|
|
|
void Cbuf_InsertText (cbuf_t *cbuf, const char *text);
|
|
|
|
void Cbuf_Execute (cbuf_t *cbuf);
|
2002-08-03 06:04:00 +00:00
|
|
|
void Cbuf_Execute_Stack (cbuf_t *cbuf);
|
2002-07-30 17:08:53 +00:00
|
|
|
void Cbuf_Execute_Sets (cbuf_t *cbuf);
|
2002-08-02 04:07:25 +00:00
|
|
|
void Cbuf_Error (const char *class, const char *fmt, ...);
|
2002-07-30 17:08:53 +00:00
|
|
|
|
|
|
|
#endif//__QF_cbuf_h
|