1 1.3 mycroft /* $NetBSD: c_test.h,v 1.3 2004/07/07 19:20:09 mycroft Exp $ */ 2 1.2 tls 3 1.1 jtc /* Various types of operations. Keeping things grouped nicely 4 1.3 mycroft * (unary,binary) makes switch() statements more efficient. 5 1.1 jtc */ 6 1.1 jtc enum Test_op { 7 1.1 jtc TO_NONOP = 0, /* non-operator */ 8 1.1 jtc /* unary operators */ 9 1.1 jtc TO_STNZE, TO_STZER, TO_OPTION, 10 1.1 jtc TO_FILAXST, 11 1.1 jtc TO_FILEXST, 12 1.1 jtc TO_FILREG, TO_FILBDEV, TO_FILCDEV, TO_FILSYM, TO_FILFIFO, TO_FILSOCK, 13 1.1 jtc TO_FILCDF, TO_FILID, TO_FILGID, TO_FILSETG, TO_FILSTCK, TO_FILUID, 14 1.1 jtc TO_FILRD, TO_FILGZ, TO_FILTT, TO_FILSETU, TO_FILWR, TO_FILEX, 15 1.1 jtc /* binary operators */ 16 1.1 jtc TO_STEQL, TO_STNEQ, TO_STLT, TO_STGT, TO_INTEQ, TO_INTNE, TO_INTGT, 17 1.1 jtc TO_INTGE, TO_INTLT, TO_INTLE, TO_FILEQ, TO_FILNT, TO_FILOT 18 1.1 jtc }; 19 1.1 jtc typedef enum Test_op Test_op; 20 1.1 jtc 21 1.1 jtc /* Used by Test_env.isa() (order important - used to index *_tokens[] arrays) */ 22 1.1 jtc enum Test_meta { 23 1.1 jtc TM_OR, /* -o or || */ 24 1.1 jtc TM_AND, /* -a or && */ 25 1.1 jtc TM_NOT, /* ! */ 26 1.1 jtc TM_OPAREN, /* ( */ 27 1.1 jtc TM_CPAREN, /* ) */ 28 1.1 jtc TM_UNOP, /* unary operator */ 29 1.1 jtc TM_BINOP, /* binary operator */ 30 1.1 jtc TM_END /* end of input */ 31 1.1 jtc }; 32 1.1 jtc typedef enum Test_meta Test_meta; 33 1.1 jtc 34 1.1 jtc #define TEF_ERROR BIT(0) /* set if we've hit an error */ 35 1.1 jtc #define TEF_DBRACKET BIT(1) /* set if [[ .. ]] test */ 36 1.1 jtc 37 1.1 jtc typedef struct test_env Test_env; 38 1.1 jtc struct test_env { 39 1.1 jtc int flags; /* TEF_* */ 40 1.1 jtc union { 41 1.1 jtc char **wp; /* used by ptest_* */ 42 1.1 jtc XPtrV *av; /* used by dbtestp_* */ 43 1.1 jtc } pos; 44 1.1 jtc char **wp_end; /* used by ptest_* */ 45 1.1 jtc int (*isa) ARGS((Test_env *te, Test_meta meta)); 46 1.1 jtc const char *(*getopnd) ARGS((Test_env *te, Test_op op, int do_eval)); 47 1.1 jtc int (*eval) ARGS((Test_env *te, Test_op op, const char *opnd1, 48 1.1 jtc const char *opnd2, int do_eval)); 49 1.1 jtc void (*error) ARGS((Test_env *te, int offset, const char *msg)); 50 1.1 jtc }; 51 1.1 jtc 52 1.1 jtc Test_op test_isop ARGS((Test_env *te, Test_meta meta, const char *s)); 53 1.1 jtc int test_eval ARGS((Test_env *te, Test_op op, const char *opnd1, 54 1.1 jtc const char *opnd2, int do_eval)); 55 1.1 jtc int test_parse ARGS((Test_env *te)); 56