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

Diff of /lbbs/src/bwf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.4 by sysadm, Fri Nov 7 09:18:58 2025 UTC Revision 1.7 by sysadm, Thu Dec 18 02:56:00 2025 UTC
# Line 6  Line 6 
6   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7   */   */
8    
9    #ifdef HAVE_CONFIG_H
10    #include "config.h"
11    #endif
12    
13  #define PCRE2_CODE_UNIT_WIDTH 8  #define PCRE2_CODE_UNIT_WIDTH 8
14    
15  #include "bwf.h"  #include "bwf.h"
# Line 31  int bwf_load(const char *filename) Line 35  int bwf_load(const char *filename)
35          size_t len_line;          size_t len_line;
36          char *p = bwf_pattern_str;          char *p = bwf_pattern_str;
37          int line_id = 0;          int line_id = 0;
         int errorcode;  
         PCRE2_SIZE erroroffset;  
38    
39          if (filename == NULL)          if (filename == NULL)
40          {          {
# Line 89  int bwf_load(const char *filename) Line 91  int bwf_load(const char *filename)
91    
92          fclose(fp);          fclose(fp);
93    
94  #ifdef _DEBUG          log_debug("Debug: bwf_pattern_str: %s\n", bwf_pattern_str);
95          log_error("Debug: bwf_pattern_str: %s\n", bwf_pattern_str);  
96  #endif          return 0;
97    }
98    
99          bwf_unload();  int bwf_compile(void)
100    {
101            int errorcode;
102            PCRE2_SIZE erroroffset;
103    
104            bwf_cleanup();
105    
106          bwf_code = pcre2_compile((PCRE2_SPTR)bwf_pattern_str, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &errorcode, &erroroffset, NULL);          bwf_code = pcre2_compile((PCRE2_SPTR)bwf_pattern_str, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &errorcode, &erroroffset, NULL);
107          if (bwf_code == NULL)          if (bwf_code == NULL)
108          {          {
109                  log_error("pcre2_compile() error: %d", errorcode);                  log_error("pcre2_compile() error: %d", errorcode);
110                  return -4;                  return -1;
111          }          }
112    
113          return 0;          return 0;
114  }  }
115    
116  void bwf_unload(void)  void bwf_cleanup(void)
117  {  {
118          if (bwf_code != NULL)          if (bwf_code != NULL)
119          {          {
# Line 162  int check_badwords(char *str, char c_mas Line 170  int check_badwords(char *str, char c_mas
170                          }                          }
171                          else                          else
172                          {                          {
173  #ifdef _DEBUG                                  log_debug("Debug: match pattern #%d of %d at offsets [%d, %d]\n",
                                 log_error("Debug: match pattern #%d of %d at offsets [%d, %d]\n",  
174                                                    i, match_count, ovector[i * 2], ovector[i * 2 + 1] - ovector[i * 2]);                                                    i, match_count, ovector[i * 2], ovector[i * 2 + 1] - ovector[i * 2]);
 #endif  
175                                  memset(str + ovector[i * 2], c_mask, ovector[i * 2 + 1] - ovector[i * 2]);                                  memset(str + ovector[i * 2], c_mask, ovector[i * 2 + 1] - ovector[i * 2]);
176                                  total_match_count++;                                  total_match_count++;
177                                  startoffset = ovector[i * 2 + 1];                                  startoffset = ovector[i * 2 + 1];


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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