home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / fileutil / rh / rhdata.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-27  |  3.6 KB  |  132 lines

  1.  
  2. /* ----------------------------------------------------------------------
  3.  * FILE: rhdata.c
  4.  * VERSION: 2
  5.  * Written by: Ken Stauffer
  6.  * This file contains the predefined symbol table, and related data
  7.  * structures.
  8.  *
  9.  * ---------------------------------------------------------------------- */
  10.  
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <time.h>
  14. #define DATA
  15. #include "rh.h"
  16.  
  17. struct symbol    *symbols;
  18.  
  19. struct symbol    *tokensym;
  20. long        tokenval;
  21. long        token;
  22.  
  23. char        Strbuf[ STRLEN+1 ];
  24. int        strfree=0;
  25.  
  26. struct instr    StackProgram[ LENGTH ];
  27. int        PC;
  28. int        startPC;
  29.  
  30. long        Stack[ MEM+3 ];
  31. int        SP;
  32. int        FP;
  33.  
  34. struct runtime    attr;
  35.  
  36. /*
  37.  * The following variables specify where the input is comming from.
  38.  * If expstr == NULL then the input is certainly not from there, and
  39.  * instead is taken from expfile.
  40.  * else expstr is used as input.
  41.  *
  42.  */
  43.  
  44. char        *expstr;
  45. FILE        *expfile;
  46. char        *expfname;
  47.  
  48. static struct symbol init_syms[]={
  49.         { "NOW",        NUMBER, 0,              c_number,       NULL },
  50.         { "now",        NUMBER, 0,              c_number,       NULL },
  51.     { "IFMT",    NUMBER,    S_IFMT,        c_number,    NULL },
  52. #ifdef S_IFBLK
  53.         { "IFBLK",      NUMBER, S_IFBLK,        c_number,       NULL },
  54. #endif
  55.     { "IFCHR",    NUMBER,    S_IFCHR,    c_number,    NULL },
  56.     { "IFDIR",    NUMBER,    S_IFDIR,    c_number,    NULL },
  57.         { "IFREG",      NUMBER, S_IFREG,        c_number,       NULL },
  58. #ifdef MSDOS
  59.         { "IHID",       NUMBER, S_IHID,         c_number,       NULL },
  60.         { "ISYS",       NUMBER, S_ISYS,         c_number,       NULL },
  61.         { "IMOD",       NUMBER, S_IMOD,         c_number,       NULL },
  62.         { "IREAD",      NUMBER, S_IREAD,        c_number,       NULL },
  63.         { "IWRITE",     NUMBER, S_IWRITE,       c_number,       NULL },
  64.         { "IEXEC",      NUMBER, S_IEXEC,        c_number,       NULL },
  65. #endif
  66. #ifdef S_ISGID
  67.     { "ISGID",    NUMBER,    S_ISGID,    c_number,    NULL },
  68. #endif
  69. #ifdef S_ISUID
  70.     { "ISUID",    NUMBER,    S_ISUID,    c_number,    NULL },
  71. #endif
  72. #ifdef S_ISVTX
  73.     { "ISVTX",    NUMBER,    S_ISVTX,    c_number,    NULL },
  74. #endif
  75. #ifdef S_IFLNK
  76.     { "IFLNK",    NUMBER,    S_IFLNK,    c_number,    NULL },
  77. #endif
  78. #ifdef S_IFSOCK
  79.     { "IFSOCK",    NUMBER,    S_IFSOCK,    c_number,    NULL },
  80. #endif
  81. #ifdef S_IFIFO
  82.     { "IFIFO",    NUMBER,    S_IFIFO,    c_number,    NULL },
  83. #endif
  84.     { "atime",    FIELD,    0,        c_atime,    NULL },
  85.     { "ctime",    FIELD,    0,        c_ctime,    NULL },
  86.     { "dev",    FIELD,    0,        c_dev,        NULL },
  87.     { "gid",    FIELD,    0,        c_gid,        NULL },
  88.     { "ino",    FIELD,    0,        c_ino,        NULL },
  89.     { "mode",    FIELD,    0,        c_mode,        NULL },
  90.     { "mtime",    FIELD,    0,        c_mtime,    NULL },
  91.     { "nlink",    FIELD,    0,        c_nlink,    NULL },
  92.     { "rdev",    FIELD,    0,        c_rdev,        NULL },
  93.     { "size",    FIELD,    0,        c_size,        NULL },
  94.     { "uid",    FIELD,    0,        c_uid,        NULL },
  95.     { "depth",    FIELD,    0,        c_depth,    NULL },
  96.     { "prune",    FIELD,    0,        c_prune,    NULL },
  97.         { "days",       NUMBER, 24L*3600L,      c_number,       NULL },
  98.         { "weeks",      NUMBER, 24L*3600L*7L,   c_number,       NULL },
  99.         { "hours",      NUMBER, 3600L,          c_number,       NULL },
  100.     { "strlen",    FIELD,  0,        c_baselen,    NULL },
  101.     { "return",    RETURN,    0,        c_return,    NULL }
  102. };
  103.  
  104. rhinit()
  105. {
  106.     int i;
  107.     struct symbol *s,*locatename();
  108.  
  109.     symbols = &init_syms[0];
  110.  
  111.     for(i=0; i< sizeof(init_syms)/sizeof(struct symbol)-1; i++ )
  112.         init_syms[i].next = &init_syms[i+1];
  113.  
  114.     /* initialize the NOW variable to the time right now */
  115.     s = locatename( "NOW" );
  116.     s->value = time(0);
  117.         s = locatename( "now" );
  118.     s->value = time(0);
  119. }
  120.  
  121. rhfinish()
  122. {
  123.     struct symbol *s;
  124.  
  125.     while(symbols->type == PARAM || symbols->type == FUNCTION) {
  126.         s = symbols;
  127.         symbols = symbols->next;
  128.         free(s->name);
  129.         free(s);
  130.     }
  131. }
  132.