source: trunk/athena/etc/synctree/synctree.h @ 7942

Revision 7942, 2.6 KB checked in by cfields, 30 years ago (diff)
If we're not macroing alloca to malloc, include alloca.h to get alloca. Except for Ultrix, where the include uses the compiler built-in that we don't want.
  • Property svn:executable set to *
Line 
1/* Copyright (C) 1988  Tim Shepard   All rights reserved. */
2
3#if defined(_AIX) || defined(_AUX_SOURCE)
4#define alloca malloc
5#define freea free
6#else
7#ifndef ultrix
8/* Under Ultrix cc (4.2a), including alloca.h gets the compiler built-in
9   version, which isn't smart enough for this program. */
10#include <alloca.h>
11#endif
12#define freea(x)
13#endif
14
15#if defined(_AUX_SOURCE)
16#define NO_RLIMIT
17#define NO_LINEBUF
18#endif
19
20#include <ctype.h>
21#define MAXNRULES 2000
22
23#ifdef FALSE
24#undef FALSE
25#endif
26#ifdef TRUE
27#undef TRUE
28#endif
29typedef enum bool { FALSE, TRUE} bool;
30
31
32typedef struct boolstruct {
33  enum boolexp_type { VARIABLE, UNARY, BINARY } type;
34  enum bool_operator { NOT, AND, OR } op;
35  char *variable;
36  struct boolstruct *left;
37  struct boolstruct *right;
38} *bool_exp;
39
40bool_exp bool_var();
41bool_exp bool_not();
42bool_exp bool_and();
43bool_exp bool_or();
44void bool_free();
45bool bool_eval();
46bool getvar();
47
48
49typedef struct {
50  enum rule_type { R_MAP, R_CHASE, R_ACTION, R_WHEN,
51                     R_IF, R_IF_ELSE, R_SKIP,
52                     R_FRAMEMARKER } type;
53  union { struct { char *globexp;
54                   unsigned int file_types;
55                   char **dests;
56                 } u_map;
57          struct { char *globexp; } u_chase;
58          struct { enum action_type
59                     {  ACTION_COPY, ACTION_LOCAL, ACTION_LINK,
60                          ACTION_DELETE, ACTION_IGNORE } type;
61                   char *globexp;
62                   unsigned int file_types;
63                   unsigned int options;
64                 } u_action;
65          struct { enum when_type { WHEN_SH, WHEN_CSH } type;
66                   char *globexp;
67                   unsigned int file_types;
68                   char **cmds;
69                 } u_when;
70          struct { bool_exp boolexp;
71                   int first;
72                   bool inactive;  /* this is not filled in by readrules */
73                 } u_if;
74          struct { int first;
75                 } u_skip;
76        } u;
77} rule;
78
79#define letternum(c) (c - (isupper(c)? 'A':'a'))
80#define set_option(bf,c) (bf |= (0x01 << letternum(c)))
81#define option_on(rno,c) ((bool) ((rules[rno].type == R_ACTION)? \
82                                  (((rules[rno].u.u_action.options) >> letternum(c)) & 0x01): \
83                                  panic("option_on: rules[rno].type is not R_ACTION")))
84
85/* definitions for 'types' field */
86#define TYPE_D 0x01
87#define TYPE_C 0x02
88#define TYPE_B 0x04
89#define TYPE_R 0x08
90#define TYPE_L 0x10
91#define TYPE_S 0x20
92#define TYPE_X 0x40
93#define TYPE_V 0x80
94#define TYPE_ALL (TYPE_D|TYPE_C|TYPE_B|TYPE_R|TYPE_L|TYPE_S|TYPE_V)
95
96#define hastype(bf,tp) ((bool) ((bf & tp) != 0))
97
98
99/*  now implemented as a procedure in rules.c
100#define newrule()  { if (++lastrule == MAXNRULES) { \
101    fprintf(stderr,"Too many rules.\n"); \
102    exit(1); }}
103*/
104void newrule();
105#define lstrule rules[lastrule]
106
107
108/* definitions for 'rflag' variable */
109#define RFLAG_SCAN_TARGET       0x01    /* Target directory scan necessary */
Note: See TracBrowser for help on using the repository browser.