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

Comparing ircd-hybrid/trunk/modules/m_set.c (file contents):
Revision 1837 by michael, Sun Apr 21 09:27:27 2013 UTC vs.
Revision 1997 by michael, Sat May 11 17:35:07 2013 UTC

# Line 42 | Line 42
42   #include "s_misc.h"
43  
44  
45 /* Structure used for the SET table itself */
46 struct SetStruct
47 {
48  const char *name;
49  void (*handler)();
50  const int wants_char; /* 1 if it expects (char *, [int]) */
51  const int wants_int;  /* 1 if it expects ([char *], int) */
52  /* eg:  0, 1 == only an int arg
53   * eg:  1, 1 == char and int args */
54 };
55
56 static void quote_autoconn(struct Client *, const char *, int);
57 static void quote_autoconnall(struct Client *, int);
58 static void quote_floodcount(struct Client *, int);
59 static void quote_identtimeout(struct Client *, int);
60 static void quote_max(struct Client *, int);
61 static void quote_spamnum(struct Client *, int);
62 static void quote_spamtime(struct Client *, int);
63 static void quote_splitmode(struct Client *, char *);
64 static void quote_splitnum(struct Client *, int);
65 static void quote_splitusers(struct Client *, int);
66 static void list_quote_commands(struct Client *);
67 static void quote_jfloodtime(struct Client *, int);
68 static void quote_jfloodcount(struct Client *, int);
69
70 /*
71 * If this ever needs to be expanded to more than one arg of each
72 * type, want_char/want_int could be the count of the arguments,
73 * instead of just a boolean flag...
74 *
75 * -davidt
76 */
77
78 static const struct SetStruct set_cmd_table[] =
79 {
80  /* name               function        string arg  int arg */
81  /* -------------------------------------------------------- */
82  { "AUTOCONN",         quote_autoconn,         1,      1 },
83  { "AUTOCONNALL",      quote_autoconnall,      0,      1 },
84  { "FLOODCOUNT",       quote_floodcount,       0,      1 },
85  { "IDENTTIMEOUT",     quote_identtimeout,     0,      1 },
86  { "MAX",              quote_max,              0,      1 },
87  { "SPAMNUM",          quote_spamnum,          0,      1 },
88  { "SPAMTIME",         quote_spamtime,         0,      1 },
89  { "SPLITMODE",        quote_splitmode,        1,      0 },
90  { "SPLITNUM",         quote_splitnum,         0,      1 },
91  { "SPLITUSERS",       quote_splitusers,       0,      1 },
92  { "JFLOODTIME",       quote_jfloodtime,       0,      1 },
93  { "JFLOODCOUNT",      quote_jfloodcount,      0,      1 },
94  /* -------------------------------------------------------- */
95  { NULL,               NULL,                   0,      0 }
96 };
97
98 /*
99 * list_quote_commands() sends the client all the available commands.
100 * Four to a line for now.
101 */
102 static void
103 list_quote_commands(struct Client *source_p)
104 {
105  int j = 0;
106  const struct SetStruct *tab = set_cmd_table;
107  const char *names[4] = { "", "", "", "" };
108
109  sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
110             me.name, source_p->name);
111
112  for (; tab->handler; ++tab)
113  {
114    names[j++] = tab->name;
115
116    if (j > 3)
117    {
118      sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
119                 me.name, source_p->name,
120                 names[0], names[1],
121                 names[2], names[3]);
122      j = 0;
123      names[0] = names[1] = names[2] = names[3] = "";
124    }
125
126  }
127
128  if (j)
129    sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
130               me.name, source_p->name,
131               names[0], names[1],
132               names[2], names[3]);
133 }
134
45   /* SET AUTOCONN */
46   static void
47   quote_autoconn(struct Client *source_p, const char *arg, int newval)
# Line 443 | Line 353 | quote_jfloodcount(struct Client *source_
353                 me.name, source_p->name, GlobalSetOptions.joinfloodcount);
354   }
355  
356 + /* Structure used for the SET table itself */
357 + struct SetStruct
358 + {
359 +  const char *name;
360 +  void (*handler)();
361 +  const int wants_char; /* 1 if it expects (char *, [int]) */
362 +  const int wants_int;  /* 1 if it expects ([char *], int) */
363 +  /* eg:  0, 1 == only an int arg
364 +   * eg:  1, 1 == char and int args */
365 + };
366 +
367 + /*
368 + * If this ever needs to be expanded to more than one arg of each
369 + * type, want_char/want_int could be the count of the arguments,
370 + * instead of just a boolean flag...
371 + *
372 + * -davidt
373 + */
374 + static const struct SetStruct set_cmd_table[] =
375 + {
376 +  /* name               function        string arg  int arg */
377 +  /* -------------------------------------------------------- */
378 +  { "AUTOCONN",         quote_autoconn,         1,      1 },
379 +  { "AUTOCONNALL",      quote_autoconnall,      0,      1 },
380 +  { "FLOODCOUNT",       quote_floodcount,       0,      1 },
381 +  { "IDENTTIMEOUT",     quote_identtimeout,     0,      1 },
382 +  { "MAX",              quote_max,              0,      1 },
383 +  { "SPAMNUM",          quote_spamnum,          0,      1 },
384 +  { "SPAMTIME",         quote_spamtime,         0,      1 },
385 +  { "SPLITMODE",        quote_splitmode,        1,      0 },
386 +  { "SPLITNUM",         quote_splitnum,         0,      1 },
387 +  { "SPLITUSERS",       quote_splitusers,       0,      1 },
388 +  { "JFLOODTIME",       quote_jfloodtime,       0,      1 },
389 +  { "JFLOODCOUNT",      quote_jfloodcount,      0,      1 },
390 +  /* -------------------------------------------------------- */
391 +  { NULL,               NULL,                   0,      0 }
392 + };
393 +
394 + /*
395 + * list_quote_commands() sends the client all the available commands.
396 + * Four to a line for now.
397 + */
398 + static void
399 + list_quote_commands(struct Client *source_p)
400 + {
401 +  int j = 0;
402 +  const struct SetStruct *tab = set_cmd_table;
403 +  const char *names[4] = { "", "", "", "" };
404 +
405 +  sendto_one(source_p, ":%s NOTICE %s :Available QUOTE SET commands:",
406 +             me.name, source_p->name);
407 +
408 +  for (; tab->handler; ++tab)
409 +  {
410 +    names[j++] = tab->name;
411 +
412 +    if (j > 3)
413 +    {
414 +      sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
415 +                 me.name, source_p->name,
416 +                 names[0], names[1],
417 +                 names[2], names[3]);
418 +      j = 0;
419 +      names[0] = names[1] = names[2] = names[3] = "";
420 +    }
421 +
422 +  }
423 +
424 +  if (j)
425 +    sendto_one(source_p, ":%s NOTICE %s :%s %s %s %s",
426 +               me.name, source_p->name,
427 +               names[0], names[1],
428 +               names[2], names[3]);
429 + }
430 +
431   /*
432   * mo_set - SET command handler
433   * set options while running

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines