ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid-8/src/csvlib.c
(Generate patch)

Comparing ircd-hybrid-8/src/csvlib.c (file contents):
Revision 1517 by michael, Fri Jul 6 14:23:09 2012 UTC vs.
Revision 1518 by michael, Sun Sep 2 16:50:40 2012 UTC

# Line 10 | Line 10
10   */
11  
12   #include "config.h"
13 #ifdef HAVE_LIBPCRE
14 #include <pcre.h>
15 #endif
13   #include "stdinc.h"
14   #include "list.h"
15   #include "log.h"
# Line 121 | Line 118 | parse_csv_file(FILE *file, ConfType conf
118        if (aconf->host != NULL)
119          add_conf_by_address(CONF_KLINE, aconf);
120        break;
124 #ifdef HAVE_LIBPCRE
125    case RKLINE_TYPE:
126    {
127      const char *errptr = NULL;
128      pcre *exp_user = NULL, *exp_host = NULL;
129
130      parse_csv_line(line, &user_field, &host_field, &reason_field, NULL);
131
132      if (host_field == NULL || user_field == NULL)
133        break;
134
135      if (!(exp_user = ircd_pcre_compile(user_field, &errptr)) ||
136          !(exp_host = ircd_pcre_compile(host_field, &errptr)))
137      {
138        sendto_realops_flags(UMODE_ALL, L_ALL,
139                  "Failed to add regular expression based K-Line: %s", errptr);
140        break;
141      }
142
143      aconf = map_to_conf(make_conf_item(RKLINE_TYPE));
144
145      aconf->regexuser = exp_user;
146      aconf->regexhost = exp_host;
147
148      DupString(aconf->user, user_field);
149      DupString(aconf->host, host_field);
150
151      if (reason_field != NULL)
152        DupString(aconf->reason, reason_field);
153      else
154        DupString(aconf->reason, "No reason");
155
156    }
157      break;
158 #endif
121      case DLINE_TYPE:
122        parse_csv_line(line, &host_field, &reason_field, NULL);
123  
# Line 184 | Line 146 | parse_csv_file(FILE *file, ConfType conf
146        if (reason_field != NULL)
147          DupString(match_item->reason, reason_field);
148        break;
187 #ifdef HAVE_LIBPCRE
188    case RXLINE_TYPE:
189    {
190      const char *errptr = NULL;
191      pcre *exp_p = NULL;
192
193      parse_csv_line(line, &name_field, &reason_field, &oper_reason, NULL);
194
195      if (name_field == NULL)
196        break;
197
198      if (!(exp_p = ircd_pcre_compile(name_field, &errptr)))
199      {
200        sendto_realops_flags(UMODE_ALL, L_ALL,
201                             "Failed to add regular expression based X-Line: %s", errptr);
202        break;
203      }
204
205      conf = make_conf_item(RXLINE_TYPE);
206      conf->regexpname = exp_p;
207      match_item = map_to_conf(conf);
208      DupString(conf->name, name_field);
209
210      if (reason_field != NULL)
211        DupString(match_item->reason, reason_field);
212      else
213        DupString(match_item->reason, "No reason");
214    }
215      break;
216 #endif
149      case CRESV_TYPE:
150        parse_csv_line(line, &name_field, &reason_field, NULL);
151        (void)create_channel_resv(name_field, reason_field, 0);
# Line 334 | Line 266 | write_conf_line(struct Client *source_p,
266                     aconf->reason, aconf->oper_reason, current_date,
267                     get_oper_name(source_p), cur_time);
268      break;
337 #ifdef HAVE_LIBPCRE
338  case RKLINE_TYPE:
339    aconf = map_to_conf(conf);
340    sendto_realops_flags(UMODE_ALL, L_ALL,
341                         "%s added RK-Line for [%s@%s] [%s]",
342                         get_oper_name(source_p),
343                         aconf->user, aconf->host, aconf->reason);
344    sendto_one(source_p, ":%s NOTICE %s :Added RK-Line [%s@%s]",
345               from, to, aconf->user, aconf->host);
346    ilog(LOG_TYPE_IRCD, "%s added K-Line for [%s@%s] [%s]",
347         source_p->name, aconf->user, aconf->host, aconf->reason);
348
349    write_csv_line(out, "%s%s%s%s%s%s%d",
350                   aconf->user, aconf->host,
351                   aconf->reason, aconf->oper_reason, current_date,
352                   get_oper_name(source_p), cur_time);
353    break;
354 #endif
269    case DLINE_TYPE:
270      aconf = (struct AccessItem *)map_to_conf(conf);
271      sendto_realops_flags(UMODE_ALL, L_ALL,
# Line 383 | Line 297 | write_conf_line(struct Client *source_p,
297                     conf->name, xconf->reason, xconf->oper_reason,
298                     current_date, get_oper_name(source_p), cur_time);
299      break;
386 #ifdef HAVE_LIBPCRE
387  case RXLINE_TYPE:
388    xconf = (struct MatchItem *)map_to_conf(conf);
389    sendto_realops_flags(UMODE_ALL, L_ALL,
390                         "%s added RX-Line for [%s] [%s]",
391                         get_oper_name(source_p), conf->name,
392                         xconf->reason);
393    sendto_one(source_p,
394               ":%s NOTICE %s :Added RX-Line [%s] [%s] to %s",
395               from, to, conf->name,
396               xconf->reason, filename);
397    ilog(LOG_TYPE_IRCD, "%s added X-Line for [%s] [%s]",
398         get_oper_name(source_p), conf->name, xconf->reason);
399    write_csv_line(out, "%s%s%s%s%s%d",
400                   conf->name, xconf->reason, xconf->oper_reason,
401                   current_date, get_oper_name(source_p), cur_time);
402    break;
403 #endif
300    case CRESV_TYPE:
301      cresv_p = (struct ResvChannel *)map_to_conf(conf);
302  
# Line 622 | Line 518 | remove_conf_line(ConfType type, struct C
518    char *found1;
519    char *found2;
520    int oldumask;
625  int (*cmpfunc)(const char *, const char *) = irccmp;
626
627  if (type == RXLINE_TYPE || type == RKLINE_TYPE)
628    cmpfunc = strcmp;
521  
522    filename = get_conf_name(type);
523  
# Line 678 | Line 570 | remove_conf_line(ConfType type, struct C
570          continue;
571        }
572  
573 <      if (!cmpfunc(pat1, found1) && !cmpfunc(pat2, found2))
573 >      if (!irccmp(pat1, found1) && !irccmp(pat2, found2))
574        {
575          pairme = 1;
576          continue;
# Line 692 | Line 584 | remove_conf_line(ConfType type, struct C
584      }
585      else
586      {
587 <      if (!cmpfunc(pat1, found1))
587 >      if (!irccmp(pat1, found1))
588        {
589          pairme = 1;
590          continue;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines