00001 /***************************************************************************** 00002 * Copyright (c) 2008, Mooneer Salem 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * * Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * * Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * * Neither the name of the Kite Language organization nor the 00013 * names of its contributors may be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY MOONEER SALEM ``AS IS'' AND ANY 00017 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00018 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 * DISCLAIMED. IN NO EVENT SHALL MOONEER SALEM BE LIABLE FOR ANY 00020 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00021 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00022 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00023 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00024 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00025 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ****************************************************************************/ 00027 00028 #ifndef MICROREGEX_H 00029 #define MICROREGEX_H 00030 00031 /**************************************************************************** 00032 * These types should not be internally accessable by users. 00033 ****************************************************************************/ 00034 #ifndef __MICROREGEX_INTERNAL 00035 typedef void* microregex_t; 00036 typedef void* microregex_nfa_t; 00037 typedef void* microregex_state_t; 00038 #else 00039 struct microregex_t; 00040 struct microregex_nfa_t; 00041 struct microregex_state_t; 00042 typedef struct microregex_t* microregex_t; 00043 typedef struct microregex_nfa_t* microregex_nfa_t; 00044 typedef struct microregex_state_t* microregex_state_t; 00045 #endif /* __MICROREGEX_INTERNAL */ 00046 00047 /**************************************************************************** 00048 * Regular expression creation/destruction 00049 ****************************************************************************/ 00050 00056 microregex_t microregex_create(char *regex); 00057 00062 void microregex_destroy(microregex_t *regex_obj); 00063 00064 /**************************************************************************** 00065 * Regular expression matching 00066 ****************************************************************************/ 00067 00072 void microregex_state_destroy(microregex_state_t *st); 00073 00081 microregex_state_t 00082 microregex_match(microregex_t regex_obj, char *str, int start); 00083 00089 int microregex_state_get_num_captured(microregex_state_t st); 00090 00097 char *microregex_state_get_subexpression(microregex_state_t st, int n); 00098 00099 #endif /* MICROREGEX_H */ 00100