/[LeafOK_CVS]/lbbs/src/reg_ex.c
ViewVC logotype

Contents of /lbbs/src/reg_ex.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Wed Apr 30 09:19:01 2025 UTC (10 months, 2 weeks ago) by sysadm
Branch: MAIN
Content type: text/x-csrc
Rename regex to reg_ex

1 /***************************************************************************
2 reg_ex.c - description
3 -------------------
4 begin : Mon Oct 11 2004
5 copyright : (C) 2004 by Leaflet
6 email : leaflet@leafok.com
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "log.h"
19 #include "reg_ex.h"
20 #include <stdlib.h>
21 #include <regex.h>
22
23 int ireg(const char *pattern, const char *string, size_t nmatch,
24 regmatch_t pmatch[])
25 {
26 regex_t *preg;
27 int cflags = 0, eflags = 0, ret;
28
29 preg = (regex_t *)malloc(sizeof(regex_t));
30
31 cflags = REG_EXTENDED;
32
33 if (pmatch == NULL)
34 cflags |= REG_NOSUB;
35
36 if (regcomp(preg, pattern, cflags) != 0)
37 {
38 log_error("Compile regular expression pattern failed\n");
39 free(preg);
40 return -1;
41 }
42 ret = regexec(preg, string, nmatch, pmatch, eflags);
43
44 regfree(preg);
45 free(preg);
46
47 // For debug
48 // log_std(ret?"error\n":"ok\n");
49
50 return ret;
51 }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1