1
0

regexp.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef __REGEXP_H
  2. #define __REGEXP_H
  3. #ifndef _REGEXP_EXTENSION
  4. This header file is an extension to ANSI/POSIX
  5. #endif
  6. #pragma lib "/$M/lib/ape/libregexp.a"
  7. #ifdef UTF
  8. #define Runeself 0xA0
  9. #else
  10. #define Runeself 0
  11. #endif
  12. typedef struct Resub Resub;
  13. typedef struct Reclass Reclass;
  14. typedef struct Reinst Reinst;
  15. typedef struct Reprog Reprog;
  16. /*
  17. * Sub expression matches
  18. */
  19. struct Resub{
  20. union
  21. {
  22. char *sp;
  23. wchar_t *rsp;
  24. } s;
  25. union
  26. {
  27. char *ep;
  28. wchar_t *rep;
  29. } e;
  30. };
  31. /*
  32. * character class, each pair of rune's defines a range
  33. */
  34. struct Reclass{
  35. wchar_t *end;
  36. wchar_t spans[64];
  37. };
  38. /*
  39. * Machine instructions
  40. */
  41. struct Reinst{
  42. int type; /* < 0200 ==> literal, otherwise action */
  43. union {
  44. Reclass *cp; /* class pointer */
  45. wchar_t r; /* character */
  46. int subid; /* sub-expression id for RBRA and LBRA */
  47. Reinst *right; /* right child of OR */
  48. } r;
  49. union { /* regexp relies on these two being in the same union */
  50. Reinst *left; /* left child of OR */
  51. Reinst *next; /* next instruction for CAT & LBRA */
  52. } l;
  53. };
  54. /*
  55. * Reprogram definition
  56. */
  57. struct Reprog{
  58. Reinst *startinst; /* start pc */
  59. Reclass class[16]; /* .data */
  60. Reinst firstinst[5]; /* .text */
  61. };
  62. extern Reprog *regcomp(char*);
  63. extern Reprog *regcomplit(char*);
  64. extern Reprog *regcompnl(char*);
  65. extern void regerror(char*);
  66. extern int regexec(Reprog*, char*, Resub*, int);
  67. extern void regsub(char*, char*, int, Resub*, int);
  68. extern int rregexec(Reprog*, wchar_t*, Resub*, int);
  69. extern void rregsub(wchar_t*, wchar_t*, int, Resub*, int);
  70. #endif