plumber.h 1.9 KB

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