plumber.h 1.5 KB

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