Return to regex.h CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / libpdel / structs / type |
1.1 ! misho 1: ! 2: /* ! 3: * Copyright (c) 2001-2002 Packet Design, LLC. ! 4: * All rights reserved. ! 5: * ! 6: * Subject to the following obligations and disclaimer of warranty, ! 7: * use and redistribution of this software, in source or object code ! 8: * forms, with or without modifications are expressly permitted by ! 9: * Packet Design; provided, however, that: ! 10: * ! 11: * (i) Any and all reproductions of the source or object code ! 12: * must include the copyright notice above and the following ! 13: * disclaimer of warranties; and ! 14: * (ii) No rights are granted, in any manner or form, to use ! 15: * Packet Design trademarks, including the mark "PACKET DESIGN" ! 16: * on advertising, endorsements, or otherwise except as such ! 17: * appears in the above copyright notice or in the software. ! 18: * ! 19: * THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND ! 20: * TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO ! 21: * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING ! 22: * THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED ! 23: * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, ! 24: * OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE, ! 25: * OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS ! 26: * OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, ! 27: * RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE ! 28: * LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE ! 29: * OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT, ! 30: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL ! 31: * DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF ! 32: * USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF ! 33: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ! 34: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF ! 35: * THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF ! 36: * THE POSSIBILITY OF SUCH DAMAGE. ! 37: * ! 38: * Author: Archie Cobbs <archie@freebsd.org> ! 39: */ ! 40: ! 41: #ifndef _PDEL_STRUCTS_TYPE_REGEX_H_ ! 42: #define _PDEL_STRUCTS_TYPE_REGEX_H_ ! 43: ! 44: /********************************************************************* ! 45: REGULAR EXPRESSION TYPE ! 46: *********************************************************************/ ! 47: ! 48: /* ! 49: * Support for regular expressions (see regex(3)). ! 50: * ! 51: * The data is a "struct structs_regex". The "reg" argument is compiled ! 52: * and filled in automatically. ! 53: */ ! 54: ! 55: struct structs_regex { ! 56: const char *pat; /* ascii pattern */ ! 57: regex_t reg; /* compiled pattern */ ! 58: }; ! 59: ! 60: __BEGIN_DECLS ! 61: ! 62: extern structs_equal_t structs_regex_equal; ! 63: extern structs_ascify_t structs_regex_ascify; ! 64: extern structs_binify_t structs_regex_binify; ! 65: extern structs_uninit_t structs_regex_free; ! 66: ! 67: __END_DECLS ! 68: ! 69: /* ! 70: * Macro arguments: ! 71: * [const char *] Memory allocation type for byte buffer ! 72: * [int] "cflags" argument to regcomp(3) ! 73: */ ! 74: #define STRUCTS_REGEX_TYPE(mtype, flags) { \ ! 75: sizeof(struct structs_regex), \ ! 76: "regex", \ ! 77: STRUCTS_TYPE_PRIMITIVE, \ ! 78: structs_region_init, \ ! 79: structs_ascii_copy, \ ! 80: structs_regex_equal, \ ! 81: structs_regex_ascify, \ ! 82: structs_regex_binify, \ ! 83: structs_string_encode, \ ! 84: structs_string_decode, \ ! 85: structs_regex_free, \ ! 86: { { (void *)(mtype) }, { (void *)(flags) }, { NULL } } \ ! 87: } ! 88: ! 89: #define STRUCTS_REGEX_MTYPE "structs_regex" ! 90: ! 91: __BEGIN_DECLS ! 92: ! 93: /* Regex with mtype STRUCTS_REGEX_MTYPE and flags REG_EXTENDED */ ! 94: extern const struct structs_type structs_type_regex; ! 95: ! 96: /* Regex with mtype STRUCTS_REGEX_MTYPE and flags REG_EXTENDED | REG_ICASE */ ! 97: extern const struct structs_type structs_type_regex_icase; ! 98: ! 99: __END_DECLS ! 100: ! 101: #endif /* _PDEL_STRUCTS_TYPE_REGEX_H_ */ ! 102: