libarmutils  1.4
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups
regex_utils.h
Go to the documentation of this file.
1 /*******************************************************************************
2 *
3 * COPYRIGHT (C) 2010 Battelle Memorial Institute. All Rights Reserved.
4 *
5 ********************************************************************************
6 *
7 * Author:
8 * name: Brian Ermold
9 * phone: (509) 375-2277
10 * email: brian.ermold@pnl.gov
11 *
12 ********************************************************************************
13 *
14 * REPOSITORY INFORMATION:
15 * $Revision: 6421 $
16 * $Author: ermold $
17 * $Date: 2011-04-26 01:23:44 +0000 (Tue, 26 Apr 2011) $
18 *
19 ********************************************************************************
20 *
21 * NOTE: DOXYGEN is used to generate documentation for this file.
22 *
23 *******************************************************************************/
24 
25 /** @file regex_utils.h
26  * Regular Expression Utilities
27  */
28 
29 #ifndef _REGEX_UTILS_H
30 #define _REGEX_UTILS_H
31 
32 /**
33  * @defgroup ARMUTILS_REGEX_UTILS Regex Utils
34  */
35 /*@{*/
36 
37 /**
38  * Regular Expressions List.
39  */
40 typedef struct {
41 
42  int nregs; /**< number of regular expressions in the list */
43  char **patterns; /**< list of regular expression patterns */
44  int *cflags; /**< list of compile flags used */
45  regex_t **regs; /**< list of compiled regular expressions */
46 
47  char *string; /**< string compared to regular expressions */
48  int eflags; /**< execute flags used */
49  int mindex; /**< index of the expression that was matched */
50  size_t nsubs; /**< number of parenthesised subexpressions */
51  regmatch_t *offsets; /**< arrary of substring offsets */
52  char **substrs; /**< array of substrings */
53 
54 } REList;
55 
56 /***** Wrappers to regex funtions *****/
57 
58 int re_compile(
59  regex_t *preg,
60  const char *pattern,
61  int cflags);
62 
63 char *re_error(
64  int errcode,
65  regex_t *preg);
66 
67 int re_execute(
68  regex_t *preg,
69  const char *string,
70  size_t nmatch,
71  regmatch_t pmatch[],
72  int eflags);
73 
74 void re_free(
75  regex_t *preg);
76 
77 /***** Extract substrings from regex match *****/
78 
80  size_t nmatch,
81  char **substrings);
82 
83 char **re_substrings(
84  const char *string,
85  size_t nmatch,
86  regmatch_t *pmatch);
87 
88 /***** REList functions *****/
89 
91  REList *re_list,
92  int npatterns,
93  const char **patterns,
94  int cflags);
95 
96 int relist_execute(
97  REList *re_list,
98  const char *string,
99  int eflags,
100  int *mindex,
101  size_t *nsubs,
102  regmatch_t **pmatch,
103  char ***substrings);
104 
105 void relist_free(
106  REList *re_list);
107 
108 /*@}*/
109 
110 #endif /* _REGEX_UTILS_H */