R:/projects/actioncube/_svn/trunk/ac/source/src/command.cpp File Reference

#include "pch.h"
#include "cube.h"

Include dependency graph for command.cpp:


Classes

struct  completekey
struct  completeval

Defines

#define _GETVAR(id, vartype, name, retval)
#define GETVAR(id, name, retval)   _GETVAR(id, ID_VAR, name, retval)
#define setretval(v)   { char *rv = v; if(rv) retval = rv; }
#define whitespaceskip   s += strspn(s, "\n\t ")
#define elementskip   *s=='"' ? (++s, s += strcspn(s, "\"\n\0"), s += *s=='"') : s += strcspn(s, "\n\t \0")
#define COMPAREF(opname, func, op)

Enumerations

enum  { COMPLETE_FILE = 0, COMPLETE_LIST, COMPLETE_NICK }

Functions

bool allowidentaccess (ident *id)
char * exchangestr (char *o, const char *n)
void clearstack (ident &id)
void pushident (ident &id, char *val, int context=execcontext)
void popident (ident &id)
ident * newident (const char *name, int context=execcontext)
void pusha (const char *name, char *action)
void push (const char *name, const char *action)
void pop (const char *name)
 COMMAND (push, ARG_2STR)
 COMMAND (pop, ARG_1STR)
void alias (const char *name, const char *action)
 COMMAND (alias, ARG_2STR)
int variable (const char *name, int minval, int cur, int maxval, int *storage, void(*fun)(), bool persist)
float fvariable (const char *name, float minval, float cur, float maxval, float *storage, void(*fun)(), bool persist)
char * svariable (const char *name, const char *cur, char **storage, void(*fun)(), bool persist)
void setvar (const char *name, int i, bool dofunc)
void setfvar (const char *name, float f, bool dofunc)
void setsvar (const char *name, const char *str, bool dofunc)
int getvar (const char *name)
bool identexists (const char *name)
const char * getalias (const char *name)
bool addcommand (const char *name, void(*fun)(), int narg)
char * parseexp (const char *&p, int right)
char * lookup (char *n)
char * parseword (const char *&p, int arg, int &infix)
char * conc (char **w, int n, bool space)
 VARN (numargs, _numargs, 0, 0, 25)
void intret (int v)
const char * floatstr (float v)
void floatret (float v)
void result (const char *s)
char * executeret (const char *p)
int execute (const char *p)
void resetcomplete ()
bool nickcomplete (char *s)
static bool htcmp (const completekey &x, const completekey &y)
static uint hthash (const completekey &k)
void addcomplete (char *command, int type, char *dir, char *ext)
void addfilecomplete (char *command, char *dir, char *ext)
void addlistcomplete (char *command, char *list)
void addnickcomplete (char *command)
 COMMANDN (complete, addfilecomplete, ARG_3STR)
 COMMANDN (listcomplete, addlistcomplete, ARG_2STR)
 COMMANDN (nickcomplete, addnickcomplete, ARG_1STR)
void commandcomplete (char *s)
void complete (char *s)
bool execfile (const char *cfgfile)
void exec (const char *cfgfile)
void ifthen (char *cond, char *thenp, char *elsep)
void loopa (char *var, char *times, char *body)
void whilea (char *cond, char *body)
void concat (char *s)
void concatword (char *s)
void format (char **args, int numargs)
void explodelist (const char *s, vector< char * > &elems)
char * indexlist (const char *s, int pos)
int listlen (char *s)
void at (char *s, char *pos)
int find (const char *s, const char *key)
void findlist (char *s, char *key)
 COMMANDN (loop, loopa, ARG_3STR)
 COMMANDN (while, whilea, ARG_2STR)
 COMMANDN (if, ifthen, ARG_3STR)
 COMMAND (exec, ARG_1STR)
 COMMAND (concat, ARG_CONC)
 COMMAND (concatword, ARG_CONCW)
 COMMAND (format, ARG_VARI)
 COMMAND (result, ARG_1STR)
 COMMAND (at, ARG_2STR)
 COMMAND (listlen, ARG_1EST)
 COMMAND (findlist, ARG_2STR)
int add (int a, int b)
 COMMANDN (+, add, ARG_2EXP)
int mul (int a, int b)
int sub (int a, int b)
 COMMANDN (-, sub, ARG_2EXP)
int div_ (int a, int b)
 COMMANDN (div, div_, ARG_2EXP)
int mod_ (int a, int b)
 COMMANDN (mod, mod_, ARG_2EXP)
float addf (float a, float b)
 COMMANDN (+f, addf, ARG_2EXPF)
float mulf (float a, float b)
float subf (float a, float b)
 COMMANDN (-f, subf, ARG_2EXPF)
float divf_ (float a, float b)
 COMMANDN (divf, divf_, ARG_2EXPF)
float modf_ (float a, float b)
 COMMANDN (modf, modf_, ARG_2EXPF)
int not_ (int a)
 COMMANDN (!, not_, ARG_1EXP)
int equal (int a, int b)
 COMMANDN (=, equal, ARG_2EXP)
int notequal (int a, int b)
 COMMANDN (!=, notequal, ARG_2EXP)
int lt (int a, int b)
 COMMANDN (<, lt, ARG_2EXP)
int gt (int a, int b)
 COMMANDN (>, gt, ARG_2EXP)
int lte (int a, int b)
 COMMANDN (<=, lte, ARG_2EXP)
int gte (int a, int b)
 COMMANDN (>=, gte, ARG_2EXP)
 COMPAREF (=f, equalf,==)
 COMPAREF (!=f, notequalf,!=)
 COMPAREF (< f, ltf,<)
 COMPAREF (>f, gtf, >)
 COMPAREF (<=f, ltef,<=)
 COMPAREF (>=f, gtef, >=)
void anda (char *a, char *b)
void ora (char *a, char *b)
 COMMANDN (||, ora, ARG_2STR)
int strcmpa (char *a, char *b)
 COMMANDN (strcmp, strcmpa, ARG_2EST)
int rndn (int a)
 COMMANDN (rnd, rndn, ARG_1EXP)
void writecfg ()
 COMMAND (writecfg, ARG_NONE)
void deletecfg ()
void identnames (vector< const char * > &names, bool builtinonly)
void pushscontext (int newcontext)
int popscontext ()
void scriptcontext (char *context, char *idname)
void isolatecontext (int context)
void sealcontexts ()
 COMMAND (scriptcontext, ARG_2STR)
 COMMAND (isolatecontext, ARG_1INT)
 COMMAND (sealcontexts, ARG_NONE)
void _watchingdemo ()
 COMMANDN (watchingdemo, _watchingdemo, ARG_NONE)
void systime ()
void timestamp ()
void datestring ()
void timestring ()
int millis_ ()
 COMMANDN (millis, millis_, ARG_IVAL)
 COMMAND (systime, ARG_NONE)
 COMMAND (timestamp, ARG_NONE)
 COMMAND (datestring, ARG_NONE)
 COMMAND (timestring, ARG_NONE)
void currentserver (int i)
 COMMANDN (curserver, currentserver, ARG_1INT)

Variables

vector< int > contextstack
bool contextsealed = false
bool contextisolated [IEXC_NUM] = { false }
int execcontext
hashtable< const char *, ident > * idents = NULL
bool persistidents = true
char * commandret = NULL
static int completesize = -1
static int completeidx = 0
static playerent * completeplayer = NULL
static hashtable< completekey,
completeval * > 
completedata
static hashtable< char
*, completeval * > 
completions
COMMANDN * mul
COMMANDN * f
COMMANDN && anda

Define Documentation

#define _GETVAR ( id,
vartype,
name,
retval   ) 

Value:

ident *id = idents->access(name); \
    if(!id || id->type!=vartype) return retval;

#define COMPAREF ( opname,
func,
op   ) 

Value:

void func(char *a, char *b) { intret((int)(atof(a) op atof(b))); } \
    COMMANDN(opname, func, ARG_2STR);

#define elementskip   *s=='"' ? (++s, s += strcspn(s, "\"\n\0"), s += *s=='"') : s += strcspn(s, "\n\t \0")

#define GETVAR ( id,
name,
retval   )     _GETVAR(id, ID_VAR, name, retval)

#define setretval ( v   )     { char *rv = v; if(rv) retval = rv; }

#define whitespaceskip   s += strspn(s, "\n\t ")


Enumeration Type Documentation

anonymous enum

Enumerator:
COMPLETE_FILE 
COMPLETE_LIST 
COMPLETE_NICK 


Function Documentation

void _watchingdemo (  ) 

int add ( int  a,
int  b 
)

bool addcommand ( const char *  name,
void(*)()  fun,
int  narg 
)

void addcomplete ( char *  command,
int  type,
char *  dir,
char *  ext 
)

float addf ( float  a,
float  b 
)

void addfilecomplete ( char *  command,
char *  dir,
char *  ext 
)

void addlistcomplete ( char *  command,
char *  list 
)

void addnickcomplete ( char *  command  ) 

void alias ( const char *  name,
const char *  action 
)

bool allowidentaccess ( ident *  id  ) 

void anda ( char *  a,
char *  b 
)

void at ( char *  s,
char *  pos 
)

void clearstack ( ident &  id  ) 

COMMAND ( timestring  ,
ARG_NONE   
)

COMMAND ( datestring  ,
ARG_NONE   
)

COMMAND ( timestamp  ,
ARG_NONE   
)

COMMAND ( systime  ,
ARG_NONE   
)

COMMAND ( sealcontexts  ,
ARG_NONE   
)

COMMAND ( isolatecontext  ,
ARG_1INT   
)

COMMAND ( scriptcontext  ,
ARG_2STR   
)

COMMAND ( writecfg  ,
ARG_NONE   
)

COMMAND ( findlist  ,
ARG_2STR   
)

COMMAND ( listlen  ,
ARG_1EST   
)

COMMAND ( at  ,
ARG_2STR   
)

COMMAND ( result  ,
ARG_1STR   
)

COMMAND ( format  ,
ARG_VARI   
)

COMMAND ( concatword  ,
ARG_CONCW   
)

COMMAND ( concat  ,
ARG_CONC   
)

COMMAND ( exec  ,
ARG_1STR   
)

COMMAND ( alias  ,
ARG_2STR   
)

COMMAND ( pop  ,
ARG_1STR   
)

COMMAND ( push  ,
ARG_2STR   
)

void commandcomplete ( char *  s  ) 

COMMANDN ( curserver  ,
currentserver  ,
ARG_1INT   
)

COMMANDN ( millis  ,
millis_  ,
ARG_IVAL   
)

COMMANDN ( watchingdemo  ,
_watchingdemo  ,
ARG_NONE   
)

COMMANDN ( rnd  ,
rndn  ,
ARG_1EXP   
)

COMMANDN ( strcmp  ,
strcmpa  ,
ARG_2EST   
)

COMMANDN ( ||  ,
ora  ,
ARG_2STR   
)

COMMANDN ( >=  ,
gte  ,
ARG_2EXP   
)

COMMANDN ( <=  ,
lte  ,
ARG_2EXP   
)

COMMANDN ( gt  ,
ARG_2EXP   
)

COMMANDN (  ) 

COMMANDN ( !  ,
notequal  ,
ARG_2EXP   
)

COMMANDN ( equal  ,
ARG_2EXP   
)

COMMANDN ( !  ,
not_  ,
ARG_1EXP   
)

COMMANDN ( modf  ,
modf_  ,
ARG_2EXPF   
)

COMMANDN ( divf  ,
divf_  ,
ARG_2EXPF   
)

COMMANDN ( -  f,
subf  ,
ARG_2EXPF   
)

COMMANDN ( +  f,
addf  ,
ARG_2EXPF   
)

COMMANDN ( mod  ,
mod_  ,
ARG_2EXP   
)

COMMANDN ( div  ,
div_  ,
ARG_2EXP   
)

COMMANDN ( -  ,
sub  ,
ARG_2EXP   
)

COMMANDN ( +  ,
add  ,
ARG_2EXP   
)

COMMANDN ( if  ,
ifthen  ,
ARG_3STR   
)

COMMANDN ( while  ,
whilea  ,
ARG_2STR   
)

COMMANDN ( loop  ,
loopa  ,
ARG_3STR   
)

COMMANDN ( nickcomplete  ,
addnickcomplete  ,
ARG_1STR   
)

COMMANDN ( listcomplete  ,
addlistcomplete  ,
ARG_2STR   
)

COMMANDN ( complete  ,
addfilecomplete  ,
ARG_3STR   
)

COMPAREF ( >=  f,
gtef  ,
>=   
)

COMPAREF ( <=  f,
ltef  ,
<=   
)

COMPAREF ( f  ,
gtf   
)

COMPAREF (  ) 

COMPAREF ( !  = f,
notequalf  ,
!   
)

COMPAREF ( equalf   ) 

void complete ( char *  s  ) 

char* conc ( char **  w,
int  n,
bool  space 
)

void concat ( char *  s  ) 

void concatword ( char *  s  ) 

void currentserver ( int  i  ) 

void datestring (  ) 

void deletecfg (  ) 

int div_ ( int  a,
int  b 
)

float divf_ ( float  a,
float  b 
)

int equal ( int  a,
int  b 
)

char* exchangestr ( char *  o,
const char *  n 
)

void exec ( const char *  cfgfile  ) 

bool execfile ( const char *  cfgfile  ) 

int execute ( const char *  p  ) 

char* executeret ( const char *  p  ) 

void explodelist ( const char *  s,
vector< char * > &  elems 
)

int find ( const char *  s,
const char *  key 
)

void findlist ( char *  s,
char *  key 
)

void floatret ( float  v  ) 

const char* floatstr ( float  v  ) 

void format ( char **  args,
int  numargs 
)

float fvariable ( const char *  name,
float  minval,
float  cur,
float  maxval,
float *  storage,
void(*)()  fun,
bool  persist 
)

const char* getalias ( const char *  name  ) 

int getvar ( const char *  name  ) 

int gt ( int  a,
int  b 
)

int gte ( int  a,
int  b 
)

static bool htcmp ( const completekey &  x,
const completekey &  y 
) [inline, static]

static uint hthash ( const completekey &  k  )  [inline, static]

bool identexists ( const char *  name  ) 

void identnames ( vector< const char * > &  names,
bool  builtinonly 
)

void ifthen ( char *  cond,
char *  thenp,
char *  elsep 
)

char* indexlist ( const char *  s,
int  pos 
)

void intret ( int  v  ) 

void isolatecontext ( int  context  ) 

int listlen ( char *  s  ) 

char* lookup ( char *  n  ) 

void loopa ( char *  var,
char *  times,
char *  body 
)

int lt ( int  a,
int  b 
)

int lte ( int  a,
int  b 
)

int millis_ (  ) 

int mod_ ( int  a,
int  b 
)

float modf_ ( float  a,
float  b 
)

int mul ( int  a,
int  b 
)

float mulf ( float  a,
float  b 
)

ident* newident ( const char *  name,
int  context = execcontext 
)

bool nickcomplete ( char *  s  ) 

int not_ ( int  a  ) 

int notequal ( int  a,
int  b 
)

void ora ( char *  a,
char *  b 
)

char* parseexp ( const char *&  p,
int  right 
)

char* parseword ( const char *&  p,
int  arg,
int &  infix 
)

void pop ( const char *  name  ) 

void popident ( ident &  id  ) 

int popscontext (  ) 

void push ( const char *  name,
const char *  action 
)

void pusha ( const char *  name,
char *  action 
)

void pushident ( ident &  id,
char *  val,
int  context = execcontext 
)

void pushscontext ( int  newcontext  ) 

void resetcomplete (  ) 

void result ( const char *  s  ) 

int rndn ( int  a  ) 

void scriptcontext ( char *  context,
char *  idname 
)

void sealcontexts (  ) 

void setfvar ( const char *  name,
float  f,
bool  dofunc 
)

void setsvar ( const char *  name,
const char *  str,
bool  dofunc 
)

void setvar ( const char *  name,
int  i,
bool  dofunc 
)

int strcmpa ( char *  a,
char *  b 
)

int sub ( int  a,
int  b 
)

float subf ( float  a,
float  b 
)

char* svariable ( const char *  name,
const char *  cur,
char **  storage,
void(*)()  fun,
bool  persist 
)

void systime (  ) 

void timestamp (  ) 

void timestring (  ) 

int variable ( const char *  name,
int  minval,
int  cur,
int  maxval,
int *  storage,
void(*)()  fun,
bool  persist 
)

VARN ( numargs  ,
_numargs  ,
0  ,
0  ,
25   
)

void whilea ( char *  cond,
char *  body 
)

void writecfg (  ) 


Variable Documentation

COMMANDN&& anda

char* commandret = NULL

int completeidx = 0 [static]

playerent* completeplayer = NULL [static]

int completesize = -1 [static]

hashtable<char *, completeval *> completions [static]

bool contextisolated[IEXC_NUM] = { false }

bool contextsealed = false

COMMANDN* f

hashtable<const char *, ident>* idents = NULL

COMMANDN* mul


Generated on Mon Dec 8 21:41:31 2008 for AssaultCube by  doxygen 1.5.7.1