pcreposix.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*************************************************
  2. * Perl-Compatible Regular Expressions *
  3. *************************************************/
  4. /* Copyright (c) 1997-2000 University of Cambridge */
  5. #ifndef _PCREPOSIX_H
  6. #define _PCREPOSIX_H
  7. /* This is the header for the POSIX wrapper interface to the PCRE Perl-
  8. Compatible Regular Expression library. It defines the things POSIX says should
  9. be there. I hope. */
  10. /* Have to include stdlib.h in order to ensure that size_t is defined. */
  11. #include <stdlib.h>
  12. /* Allow for C++ users */
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /* Options defined by POSIX. */
  17. #define REG_ICASE 0x01
  18. #define REG_NEWLINE 0x02
  19. #define REG_NOTBOL 0x04
  20. #define REG_NOTEOL 0x08
  21. /* These are not used by PCRE, but by defining them we make it easier
  22. to slot PCRE into existing programs that make POSIX calls. */
  23. #define REG_EXTENDED 0
  24. #define REG_NOSUB 0
  25. /* Error values. Not all these are relevant or used by the wrapper. */
  26. enum {
  27. REG_ASSERT = 1, /* internal error ? */
  28. REG_BADBR, /* invalid repeat counts in {} */
  29. REG_BADPAT, /* pattern error */
  30. REG_BADRPT, /* ? * + invalid */
  31. REG_EBRACE, /* unbalanced {} */
  32. REG_EBRACK, /* unbalanced [] */
  33. REG_ECOLLATE, /* collation error - not relevant */
  34. REG_ECTYPE, /* bad class */
  35. REG_EESCAPE, /* bad escape sequence */
  36. REG_EMPTY, /* empty expression */
  37. REG_EPAREN, /* unbalanced () */
  38. REG_ERANGE, /* bad range inside [] */
  39. REG_ESIZE, /* expression too big */
  40. REG_ESPACE, /* failed to get memory */
  41. REG_ESUBREG, /* bad back reference */
  42. REG_INVARG, /* bad argument */
  43. REG_NOMATCH /* match failed */
  44. };
  45. /* The structure representing a compiled regular expression. */
  46. typedef struct {
  47. void *re_pcre;
  48. size_t re_nsub;
  49. size_t re_erroffset;
  50. } regex_t;
  51. /* The structure in which a captured offset is returned. */
  52. typedef int regoff_t;
  53. typedef struct {
  54. regoff_t rm_so;
  55. regoff_t rm_eo;
  56. } regmatch_t;
  57. /* The functions */
  58. extern int regcomp(regex_t *, const char *, int);
  59. extern int regexec(regex_t *, const char *, size_t, regmatch_t *, int);
  60. extern size_t regerror(int, const regex_t *, char *, size_t);
  61. extern void regfree(regex_t *);
  62. #ifdef __cplusplus
  63. } /* extern "C" */
  64. #endif
  65. #endif /* End of pcreposix.h */