regexp.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef regexp_h
  2. #define regexp_h
  3. #define regcompx js_regcompx
  4. #define regfreex js_regfreex
  5. #define regcomp js_regcomp
  6. #define regexec js_regexec
  7. #define regfree js_regfree
  8. typedef struct Reprog Reprog;
  9. typedef struct Resub Resub;
  10. Reprog *regcompx(void *(*alloc)(void *ctx, void *p, int n), void *ctx,
  11. const char *pattern, int cflags, const char **errorp);
  12. void regfreex(void *(*alloc)(void *ctx, void *p, int n), void *ctx,
  13. Reprog *prog);
  14. Reprog *regcomp(const char *pattern, int cflags, const char **errorp);
  15. int regexec(Reprog *prog, const char *string, Resub *sub, int eflags);
  16. void regfree(Reprog *prog);
  17. enum {
  18. /* regcomp flags */
  19. REG_ICASE = 1,
  20. REG_NEWLINE = 2,
  21. /* regexec flags */
  22. REG_NOTBOL = 4,
  23. REG_RUNAWAY = 8, /* detect runaway backtracking */
  24. };
  25. /* If you redefine REG_MAXSUB, you must make sure both the calling
  26. * code and the regexp.c compilation unit use the same value!
  27. */
  28. #ifndef REG_MAXSUB
  29. #define REG_MAXSUB 16
  30. #endif
  31. struct Resub {
  32. int nsub;
  33. struct {
  34. const char *sp;
  35. const char *ep;
  36. } sub[REG_MAXSUB];
  37. };
  38. #endif