plumber.h (1606B)
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 enum 56 { 57 NMATCHSUBEXP = 100 /* bounded by ../../libregexp/regcomp.h:/NSUBEXP */ 58 }; 59 60 struct Exec 61 { 62 Plumbmsg *msg; 63 char *match[NMATCHSUBEXP]; 64 int p0; /* begin and end of match */ 65 int p1; 66 int clearclick; /* click was expanded; remove attribute */ 67 int setdata; /* data should be set to $0 */ 68 int holdforclient; /* exec'ing client; keep message until port is opened */ 69 /* values of $variables */ 70 char *file; 71 char *dir; 72 }; 73 74 void parseerror(char*, ...); 75 void error(char*, ...); 76 void* emalloc(long); 77 void* erealloc(void*, long); 78 char* estrdup(char*); 79 Ruleset** readrules(char*, int); 80 void startfsys(int); 81 Exec* matchruleset(Plumbmsg*, Ruleset*); 82 void freeexec(Exec*); 83 char* startup(Ruleset*, Exec*); 84 char* printrules(void); 85 void addport(char*); 86 char* writerules(char*, int); 87 char* expand(Exec*, char*, char**); 88 void makeports(Ruleset*[]); 89 void printinputstack(void); 90 int popinput(void); 91 92 Ruleset **rules; 93 char *user; 94 char *home; 95 jmp_buf parsejmp; 96 char *lasterror; 97 char **ports; 98 int nports; 99 int debug;