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

Annotation of /lbbs/src/regex.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Wed Apr 30 09:19:01 2025 UTC (10 months, 2 weeks ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
Content type: text/x-csrc
FILE REMOVED
Rename regex to reg_ex

1 sysadm 1.1 /***************************************************************************
2 sysadm 1.2 regex.c - description
3     -------------------
4     begin : Mon Oct 11 2004
5     copyright : (C) 2004 by Leaflet
6     email : leaflet@leafok.com
7 sysadm 1.1 ***************************************************************************/
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 <stdlib.h>
19     #include <regex.h>
20    
21 sysadm 1.2 int ireg(const char *pattern, const char *string, size_t nmatch,
22     regmatch_t pmatch[])
23 sysadm 1.1 {
24 sysadm 1.2 regex_t *preg;
25     int cflags = 0, eflags = 0, ret;
26 sysadm 1.1
27 sysadm 1.2 preg = (regex_t *)malloc(sizeof(regex_t));
28 sysadm 1.1
29 sysadm 1.2 cflags = REG_EXTENDED;
30 sysadm 1.1
31 sysadm 1.2 if (pmatch == NULL)
32     cflags |= REG_NOSUB;
33 sysadm 1.1
34 sysadm 1.2 if (regcomp(preg, pattern, cflags) != 0)
35     {
36     log_error("Compile regular expression pattern failed\n");
37     free(preg);
38     return -1;
39     }
40     ret = regexec(preg, string, nmatch, pmatch, eflags);
41 sysadm 1.1
42 sysadm 1.2 regfree(preg);
43     free(preg);
44 sysadm 1.1
45 sysadm 1.2 // For debug
46     // log_std(ret?"error\n":"ok\n");
47 sysadm 1.1
48 sysadm 1.2 return ret;
49 sysadm 1.1 }

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