]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/plumb/plumber.h
/sys/src/cmd/ndb/dns.h:
[plan9front.git] / sys / src / cmd / plumb / plumber.h
1 typedef struct Exec Exec;
2 typedef struct Rule Rule;
3 typedef struct Ruleset Ruleset;
4
5 /*
6  * Object
7  */
8 enum
9 {
10         OArg,
11         OAttr,
12         OData,
13         ODst,
14         OPlumb,
15         OSrc,
16         OType,
17         OWdir,
18 };
19
20 /*
21  * Verbs
22  */
23 enum
24 {
25         VAdd,   /* apply to OAttr only */
26         VClient,
27         VDelete,        /* apply to OAttr only */
28         VIs,
29         VIsdir,
30         VIsfile,
31         VMatches,
32         VSet,
33         VStart,
34         VTo,
35 };
36
37 struct Rule
38 {
39         int     obj;
40         int     verb;
41         char    *arg;           /* unparsed string of all arguments */
42         char    *qarg;  /* quote-processed arg string */
43         Reprog  *regex;
44 };
45
46 struct Ruleset
47 {
48         int     npat;
49         int     nact;
50         Rule    **pat;
51         Rule    **act;
52         char    *port;
53 };
54
55 struct Exec
56 {
57         Plumbmsg        *msg;
58         char                    *match[10];
59         int                     p0;             /* begin and end of match */
60         int                     p1;
61         int                     clearclick;     /* click was expanded; remove attribute */
62         int                     setdata;        /* data should be set to $0 */
63         int                     holdforclient;  /* exec'ing client; keep message until port is opened */
64         /* values of $variables */
65         char                    *file;
66         char                    *dir;
67 };
68
69 void            parseerror(char*, ...);
70 void            error(char*, ...);
71 void*   emalloc(long);
72 void*   erealloc(void*, long);
73 char*   estrdup(char*);
74 Ruleset**       readrules(char*, int);
75 void            startfsys(void);
76 Exec*   matchruleset(Plumbmsg*, Ruleset*);
77 void            freeexec(Exec*);
78 char*   startup(Ruleset*, Exec*);
79 char*   printrules(void);
80 void            addport(char*);
81 char*   writerules(char*, int);
82 char*   expand(Exec*, char*, char**);
83 void            makeports(Ruleset*[]);
84 void            freeruleset(Ruleset*);
85 void            printinputstack(void);
86 int             popinput(void);
87
88 Ruleset **rules;
89 char            *user;
90 char            *home;
91 jmp_buf parsejmp;
92 char            *lasterror;
93 char            **ports;
94 int             nports;