2003-12-22 21:22:51 +01:00
|
|
|
/* $OpenBSD: c_test.h,v 1.2 2003/10/22 07:40:38 jmc Exp $ */
|
Import OpenBSD 3.3 source repository from CTM 3132 the first time
This opens an OpenBSD-mirabile (aka MirBSD) repository.
### MirBSD is:
# Copyright (c) 1982-2003 by Thorsten "mirabile" Glaser <x86@ePost.de>
# Copyright © 1968-2003 The authors of And contributors to UNIX®, the
# C Language, BSD/Berkeley Unix; 386BSD, NetBSD 1.1 and OpenBSD.
#
# Anyone who obtained a copy of this work is hereby permitted to freely use,
# distribute, modify, merge, sublicence, give away or sell it as long as the
# authors are given due credit and the following notice is retained:
#
# This work is provided "as is", with no explicit or implicit warranty what-
# soever. Use it only at your own risk. In no event may an author or contri-
# butor be held liable for any damage, directly or indirectly, that origina-
# ted through or is caused by creation or modification of this work.
MirBSD is my private tree. MirBSD does not differ very much from OpenBSD
and intentionally tracks OpenBSD. That's why it _is_ OpenBSD, just not the
official one. It's like with DarrenBSD.
At time of this writing, no advertising for MirBSD must be done,
because the advertising clause has not yet been sorted out.
http://templeofhate.com/tglaser/MirBSD/index.php
2003-03-22 18:35:03 +01:00
|
|
|
|
|
|
|
/* Various types of operations. Keeping things grouped nicely
|
2003-12-22 21:22:51 +01:00
|
|
|
* (unary,binary) makes switch() statements more efficient.
|
Import OpenBSD 3.3 source repository from CTM 3132 the first time
This opens an OpenBSD-mirabile (aka MirBSD) repository.
### MirBSD is:
# Copyright (c) 1982-2003 by Thorsten "mirabile" Glaser <x86@ePost.de>
# Copyright © 1968-2003 The authors of And contributors to UNIX®, the
# C Language, BSD/Berkeley Unix; 386BSD, NetBSD 1.1 and OpenBSD.
#
# Anyone who obtained a copy of this work is hereby permitted to freely use,
# distribute, modify, merge, sublicence, give away or sell it as long as the
# authors are given due credit and the following notice is retained:
#
# This work is provided "as is", with no explicit or implicit warranty what-
# soever. Use it only at your own risk. In no event may an author or contri-
# butor be held liable for any damage, directly or indirectly, that origina-
# ted through or is caused by creation or modification of this work.
MirBSD is my private tree. MirBSD does not differ very much from OpenBSD
and intentionally tracks OpenBSD. That's why it _is_ OpenBSD, just not the
official one. It's like with DarrenBSD.
At time of this writing, no advertising for MirBSD must be done,
because the advertising clause has not yet been sorted out.
http://templeofhate.com/tglaser/MirBSD/index.php
2003-03-22 18:35:03 +01:00
|
|
|
*/
|
|
|
|
enum Test_op {
|
|
|
|
TO_NONOP = 0, /* non-operator */
|
|
|
|
/* unary operators */
|
|
|
|
TO_STNZE, TO_STZER, TO_OPTION,
|
|
|
|
TO_FILAXST,
|
|
|
|
TO_FILEXST,
|
|
|
|
TO_FILREG, TO_FILBDEV, TO_FILCDEV, TO_FILSYM, TO_FILFIFO, TO_FILSOCK,
|
|
|
|
TO_FILCDF, TO_FILID, TO_FILGID, TO_FILSETG, TO_FILSTCK, TO_FILUID,
|
|
|
|
TO_FILRD, TO_FILGZ, TO_FILTT, TO_FILSETU, TO_FILWR, TO_FILEX,
|
|
|
|
/* binary operators */
|
|
|
|
TO_STEQL, TO_STNEQ, TO_STLT, TO_STGT, TO_INTEQ, TO_INTNE, TO_INTGT,
|
|
|
|
TO_INTGE, TO_INTLT, TO_INTLE, TO_FILEQ, TO_FILNT, TO_FILOT
|
|
|
|
};
|
|
|
|
typedef enum Test_op Test_op;
|
|
|
|
|
|
|
|
/* Used by Test_env.isa() (order important - used to index *_tokens[] arrays) */
|
|
|
|
enum Test_meta {
|
|
|
|
TM_OR, /* -o or || */
|
|
|
|
TM_AND, /* -a or && */
|
|
|
|
TM_NOT, /* ! */
|
|
|
|
TM_OPAREN, /* ( */
|
|
|
|
TM_CPAREN, /* ) */
|
|
|
|
TM_UNOP, /* unary operator */
|
|
|
|
TM_BINOP, /* binary operator */
|
|
|
|
TM_END /* end of input */
|
|
|
|
};
|
|
|
|
typedef enum Test_meta Test_meta;
|
|
|
|
|
|
|
|
#define TEF_ERROR BIT(0) /* set if we've hit an error */
|
|
|
|
#define TEF_DBRACKET BIT(1) /* set if [[ .. ]] test */
|
|
|
|
|
|
|
|
typedef struct test_env Test_env;
|
|
|
|
struct test_env {
|
|
|
|
int flags; /* TEF_* */
|
|
|
|
union {
|
|
|
|
char **wp; /* used by ptest_* */
|
|
|
|
XPtrV *av; /* used by dbtestp_* */
|
|
|
|
} pos;
|
|
|
|
char **wp_end; /* used by ptest_* */
|
|
|
|
int (*isa) ARGS((Test_env *te, Test_meta meta));
|
|
|
|
const char *(*getopnd) ARGS((Test_env *te, Test_op op, int do_eval));
|
|
|
|
int (*eval) ARGS((Test_env *te, Test_op op, const char *opnd1,
|
|
|
|
const char *opnd2, int do_eval));
|
|
|
|
void (*error) ARGS((Test_env *te, int offset, const char *msg));
|
|
|
|
};
|
|
|
|
|
|
|
|
Test_op test_isop ARGS((Test_env *te, Test_meta meta, const char *s));
|
|
|
|
int test_eval ARGS((Test_env *te, Test_op op, const char *opnd1,
|
|
|
|
const char *opnd2, int do_eval));
|
|
|
|
int test_parse ARGS((Test_env *te));
|