regex.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Minimal version of Henry Spencer's regex library
  3. with minor modifications
  4. */
  5. #ifndef _REGEX_H_
  6. #define _REGEX_H_
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. typedef off_t regoff_t;
  11. typedef struct {
  12. int re_magic;
  13. size_t re_nsub; /* number of parenthesized subexpressions */
  14. const char *re_endp; /* end pointer for REG_PEND */
  15. struct re_guts *re_g; /* none of your business :-) */
  16. } regex_t;
  17. typedef struct {
  18. regoff_t rm_so; /* start of match */
  19. regoff_t rm_eo; /* end of match */
  20. } regmatch_t;
  21. extern int regcomp(regex_t *, const char *, int);
  22. #define REG_BASIC 0000
  23. #define REG_EXTENDED 0001
  24. #define REG_ICASE 0002
  25. #define REG_NOSUB 0004
  26. #define REG_NEWLINE 0010
  27. #define REG_NOSPEC 0020
  28. #define REG_PEND 0040
  29. #define REG_DUMP 0200
  30. #define REG_OKAY 0
  31. #define REG_NOMATCH 1
  32. #define REG_BADPAT 2
  33. #define REG_ECOLLATE 3
  34. #define REG_ECTYPE 4
  35. #define REG_EESCAPE 5
  36. #define REG_ESUBREG 6
  37. #define REG_EBRACK 7
  38. #define REG_EPAREN 8
  39. #define REG_EBRACE 9
  40. #define REG_BADBR 10
  41. #define REG_ERANGE 11
  42. #define REG_ESPACE 12
  43. #define REG_BADRPT 13
  44. #define REG_EMPTY 14
  45. #define REG_ASSERT 15
  46. #define REG_INVARG 16
  47. #define REG_ATOI 255 /* convert name to number (!) */
  48. #define REG_ITOA 0400 /* convert number to name (!) */
  49. extern int regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
  50. #define REG_NOTBOL 00001
  51. #define REG_NOTEOL 00002
  52. #define REG_STARTEND 00004
  53. #define REG_TRACE 00400 /* tracing of execution */
  54. #define REG_LARGE 01000 /* force large representation */
  55. #define REG_BACKR 02000 /* force use of backref code */
  56. extern void regfree(regex_t *);
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif