/[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.3 - (show annotations)
Sun May 11 13:48:45 2025 UTC (10 months ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
Content type: text/x-csrc
FILE REMOVED
Remove legacy code

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

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