regex.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:4k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* regcomp.c - regular expression handling */
  2. /*
  3. modification history
  4. --------------------
  5. 01c,13apr98,wmd  rename host versions of regXXX functions.
  6. 01b,30sep96,elp  put in share/ (SPR# 6775).
  7. 01a,10jan95,jcf   created.
  8. */
  9. /*
  10. DESCRIPTION
  11. This library is *not* the original BSD distribution.  Though the changes
  12. were completely cosmetic (file naming, and such), the user of this library
  13. is forewarned.
  14. AUTHOR: Henry Spencer
  15. */
  16. /*-
  17.  * Copyright (c) 1992 Henry Spencer.
  18.  * Copyright (c) 1992, 1993
  19.  * The Regents of the University of California.  All rights reserved.
  20.  *
  21.  * This code is derived from software contributed to Berkeley by
  22.  * Henry Spencer of the University of Toronto.
  23.  *
  24.  * Redistribution and use in source and binary forms, with or without
  25.  * modification, are permitted provided that the following conditions
  26.  * are met:
  27.  * 1. Redistributions of source code must retain the above copyright
  28.  *    notice, this list of conditions and the following disclaimer.
  29.  * 2. Redistributions in binary form must reproduce the above copyright
  30.  *    notice, this list of conditions and the following disclaimer in the
  31.  *    documentation and/or other materials provided with the distribution.
  32.  * 3. All advertising materials mentioning features or use of this software
  33.  *    must display the following acknowledgement:
  34.  * This product includes software developed by the University of
  35.  * California, Berkeley and its contributors.
  36.  * 4. Neither the name of the University nor the names of its contributors
  37.  *    may be used to endorse or promote products derived from this software
  38.  *    without specific prior written permission.
  39.  *
  40.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  41.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  44.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50.  * SUCH DAMAGE.
  51.  *
  52.  * @(#)regex.h 8.2 (Berkeley) 1/3/94
  53.  */
  54. #ifndef _REGEX_H_
  55. #define _REGEX_H_
  56. #ifdef HOST
  57. #include <sys/types.h> /* XXX was sys/cdef.h from POSIX.2 */
  58. #endif
  59. /* types */
  60. typedef off_t regoff_t;
  61. typedef struct {
  62. int re_magic;
  63. size_t re_nsub; /* number of parenthesized subexpressions */
  64. const char *re_endp; /* end pointer for REG_PEND */
  65. struct re_guts *re_g; /* none of your business :-) */
  66. } regex_t;
  67. typedef struct {
  68. regoff_t rm_so; /* start of match */
  69. regoff_t rm_eo; /* end of match */
  70. } regmatch_t;
  71. /* regcomp() flags */
  72. #define REG_BASIC 0000
  73. #define REG_EXTENDED 0001
  74. #define REG_ICASE 0002
  75. #define REG_NOSUB 0004
  76. #define REG_NEWLINE 0010
  77. #define REG_NOSPEC 0020
  78. #define REG_PEND 0040
  79. #define REG_DUMP 0200
  80. /* regerror() flags */
  81. #define REG_NOMATCH  1
  82. #define REG_BADPAT  2
  83. #define REG_ECOLLATE  3
  84. #define REG_ECTYPE  4
  85. #define REG_EESCAPE  5
  86. #define REG_ESUBREG  6
  87. #define REG_EBRACK  7
  88. #define REG_EPAREN  8
  89. #define REG_EBRACE  9
  90. #define REG_BADBR 10
  91. #define REG_ERANGE 11
  92. #define REG_ESPACE 12
  93. #define REG_BADRPT 13
  94. #define REG_EMPTY 14
  95. #define REG_ASSERT 15
  96. #define REG_INVARG 16
  97. #define REG_ATOI 255 /* convert name to number (!) */
  98. #define REG_ITOA 0400 /* convert number to name (!) */
  99. /* regexec() flags */
  100. #define REG_NOTBOL 00001
  101. #define REG_NOTEOL 00002
  102. #define REG_STARTEND 00004
  103. #define REG_TRACE 00400 /* tracing of execution */
  104. #define REG_LARGE 01000 /* force large representation */
  105. #define REG_BACKR 02000 /* force use of backref code */
  106. /* function declarations */
  107. #ifdef HOST
  108. #define regcomp wtxRegComp
  109. #define regerror wtxRegError
  110. #define regexec wtxRegExec
  111. #define regfree wtxRegFree
  112. extern int wtxRegComp (regex_t *, const char *, int);
  113. extern size_t wtxRegError (int, const regex_t *, char *, size_t);
  114. extern int wtxRegExec (const regex_t *,const char *,size_t,regmatch_t[],int);
  115. extern void wtxRegFree (regex_t *);
  116. #else
  117. extern int regcomp (regex_t *, const char *, int);
  118. extern size_t regerror (int, const regex_t *, char *, size_t);
  119. extern int regexec  (const regex_t *,const char *,size_t,regmatch_t[],int);
  120. extern void regfree (regex_t *);
  121. #endif  /* HOST */
  122. #endif /* !_REGEX_H_ */