All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
regeng.h
Go to the documentation of this file.
1 /*
2  * regeng.h - APme: Aion Automatic Abyss Point Tracker
3  *
4  * Copyright (C) 2012 Mitja Horvat <pinkfluid@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or (at
9  * your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  */
20 
28 #ifndef REGENG_H_INCLUDED
29 #define REGENG_H_INCLUDED
30 
31 #include <pcreposix.h>
32 
45 #define RE_MATCH(x) (((x).rm_so != -1) && ((x).rm_eo != -1))
46 
48 #define RE_INVALID_ID 0xffffffff
49 
50 #define RE_REMATCH_MAX 32
51 
53 #define RE_REGENG_VALID(x) (((x)->re_id != RE_INVALID_ID) && \
54  ((x)->re_exp != NULL))
55 
57 #define RE_REGENG_END { .re_id = RE_INVALID_ID, .re_exp = NULL }
58 
64 struct regeng
65 {
66  uint32_t re_id;
68  regex_t re_comp;
70  char *re_exp;
71 };
72 
84 typedef void re_callback_t(uint32_t re_id, const char *str, regmatch_t *rematch, size_t rematch_max);
85 
86 extern bool re_init(struct regeng *re_array);
87 extern bool re_parse(re_callback_t re_callback, struct regeng *re_array, char *str);
88 
89 extern void re_strlcpy(char *outstr, const char *instr, size_t outsz, regmatch_t rem);
90 extern size_t re_strlen(regmatch_t rem);
91 
95 #endif /* REGENG_H_INCLUDE */