home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume18 / rh / rh.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-23  |  4.2 KB  |  162 lines

  1.  
  2. /* ----------------------------------------------------------------------
  3.  * FILE: rh.h
  4.  * (c) 1989 Ken Stauffer
  5.  * This header contains the #define's for the tokens.
  6.  * It also contains the initialized arrays. By having 
  7.  * rh.c define a symbol MAIN, the space is allocated for these globals
  8.  * only once.
  9.  *
  10.  * ---------------------------------------------------------------------- */
  11.  
  12. #include <stdio.h>
  13.  
  14. #define START        256
  15. #define OR        256    /* || */
  16. #define AND        257    /* && */
  17. #define LE        258    /* <= */
  18. #define LT        259    /* < */
  19. #define GE        260    /* >= */
  20. #define GT        261    /* > */
  21. #define NE        262    /* != */
  22. #define EQ        263    /* == */
  23. #define BOR        264    /* | */
  24. #define BAND        265    /* & */
  25. #define BXOR        266    /* ^ */
  26. #define NOT        267    /* ! */
  27. #define PLUS        268    /* + */
  28. #define MUL        269    /* * */
  29. #define MINUS        270    /* - */
  30. #define DIV        271    /* / */
  31. #define MOD        272    /* % */
  32. #define BNOT        273    /* ~ */
  33. #define UNIMINUS    274    /* - */
  34. #define SHIFTL        275    /* << */
  35. #define SHIFTR        276    /* >> */
  36. #define QM        277    /* ? */
  37. #define COLON        278    /* : */
  38. #define NOP        279    /* */
  39.  
  40. #define NUMBER        280    /* eg. 1234,NOW,IFDIR */
  41. #define STAR        281    /* eg. "*.BAK" */
  42. #define FIELD        282    /* mode, uid */
  43. #define MACRONAME    283
  44. #define UNKNOWN        284
  45.  
  46. #define NOW_INDEX    1    /* where to place the current time */
  47. #define MACRO_INDEX    0    /* where the macro name goes */
  48.  
  49. #define LENGTH        100    /* size of stack program */
  50. #define MEM        20    /* size of stack */
  51. #define IDLENGTH    20
  52. #define STARLEN        1000    /* total chars available for strings */
  53.  
  54. #if BSD || SUN
  55. #define DEPTH        getdtablesize()
  56. #endif
  57.  
  58. #if XENIX || SYSV
  59. /* This value was arbitrarily chosen */
  60. #define DEPTH        24
  61. #endif
  62.  
  63. struct instr {
  64.     int        i_type;
  65.     long        i_value;
  66. };
  67.  
  68. #ifdef MAIN
  69.  
  70. extern    c_or(),      c_and(),      c_le(),      c_lt(),      c_ge(),
  71.     c_gt(),      c_ne(),       c_eq(),      c_bor(),     c_band(),
  72.     c_bxor(),    c_not(),      c_plus(),    c_mul(),     c_minus(),
  73.     c_div(),     c_mod(),      c_number(),  c_atime(),   c_ctime(),
  74.     c_dev(),     c_gid(),      c_ino(),     c_mode(),    c_mtime(),
  75.     c_nlink(),   c_rdev(),     c_size(),    c_uid(),     c_star(),
  76.     c_bnot(),    c_uniminus(), c_lshift(),  c_rshift(),  c_qm(),
  77.     c_colon(),   c_nop();
  78.  
  79. #if SUN || BSD
  80. char *identifiers[]={ "", "NOW" , "IFBLK", "IFCHR", "IFDIR", "IFLNK", "IFMT",
  81.               "IFREG", "IFSOCK", "ISGID", "ISUID", "ISVTX",
  82.               "atime",  "ctime", "dev",   "gid",  "ino",
  83.               "mode",  "mtime",  "nlink", "rdev",  "size", "uid",
  84.               NULL };
  85.  
  86. long constants[]={ 0,0,
  87.     S_IFBLK, S_IFCHR, S_IFDIR, S_IFLNK, S_IFMT, S_IFREG, S_IFSOCK,
  88.     S_ISGID, S_ISUID, S_ISVTX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  89. #endif
  90.  
  91. #if XENIX || SYSV
  92. char *identifiers[]={ "", "NOW", "IFBLK", "IFCHR", "IFDIR", "IFMT",
  93.               "IFREG", "IFIFO", "ISGID", "ISUID", "ISVTX",
  94.                "atime",  "ctime", "dev",   "gid",  "ino",
  95.               "mode",  "mtime",  "nlink", "rdev",  "size", "uid",
  96.               NULL };
  97.  
  98. long constants[]={ 0,0,
  99.     S_IFBLK, S_IFCHR, S_IFDIR, S_IFMT, S_IFREG, S_IFIFO,
  100.     S_ISGID, S_ISUID, S_ISVTX, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
  101. #endif
  102.  
  103. int (*commands[])()= {
  104.     c_or,      c_and,      c_le,      c_lt,      c_ge,
  105.     c_gt,      c_ne,       c_eq,      c_bor,     c_band,
  106.     c_bxor,    c_not,      c_plus,    c_mul,     c_minus,
  107.     c_div,     c_mod,      c_bnot,    c_uniminus,c_lshift,
  108.     c_rshift,  c_qm,       c_colon,   c_nop,     c_number,
  109.     c_star,    c_atime,    c_ctime,   c_dev,     c_gid,
  110.     c_ino,     c_mode,     c_mtime,   c_nlink,   c_rdev,
  111.     c_size,    c_uid };
  112.  
  113.     long        tokenval;
  114.     long        token;
  115.  
  116.     struct instr    StackProgram[ LENGTH ];
  117.     int        PC;
  118.  
  119.     long        Stack[ MEM ];
  120.     int        SP;
  121.  
  122.     struct stat    *globuf;
  123.     char        *fname;
  124.     int        dashf;
  125.     int        dashl;
  126.     int        dashe;
  127.     int        dashr;
  128.     int        dashh;
  129.     int        dashm;
  130.     int        dasha;
  131.     char        *expstr;
  132.     FILE        *expfile;
  133.     
  134.     char        Starbuf[ STARLEN ];
  135.     int        starfree=0;
  136.  
  137. #else
  138.     extern long        constants[];
  139.     extern char        *identifiers[];
  140.     extern int        (*commands[])();
  141.  
  142.     extern long        tokenval;
  143.     extern long        token;
  144.     extern struct instr    StackProgram[];
  145.     extern int        PC;
  146.     extern long        Stack[];
  147.     extern int        SP;
  148.     extern struct stat    *globuf;
  149.     extern char        *fname;
  150.     extern char        Starbuf[];
  151.     extern int        starfree;
  152.     extern int        dashf;
  153.     extern int        dashl;
  154.     extern int        dashe;
  155.     extern int        dashr;
  156.     extern int        dashh;
  157.     extern int        dashm;
  158.     extern int        dasha;
  159.     extern char        *expstr;
  160.     extern FILE        *expfile;
  161. #endif
  162.