]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/m_etrace.c
Add helpfiles for all extensions that provide commands.
[irc/rqf/shadowircd.git] / modules / m_etrace.c
index 30b5b98ef3fb4674c1e5867d56ba99a5fbe4bec4..9441a0ee457c743b1ac0e9345ace692e205dbf2d 100644 (file)
@@ -29,7 +29,7 @@
  *  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  *  POSSIBILITY OF SUCH DAMAGE.
  *
- *  $Id: m_etrace.c 2775 2006-11-27 11:45:31Z jilles $
+ *  $Id: m_etrace.c 3161 2007-01-25 07:23:01Z nenolod $
  */
 
 #include "stdinc.h"
 #include "hash.h"
 #include "common.h"
 #include "hash.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
-#include "commio.h"
 #include "s_serv.h"
 #include "s_conf.h"
 #include "s_newconf.h"
@@ -53,7 +52,7 @@
 
 static int mo_etrace(struct Client *, struct Client *, int, const char **);
 static int me_etrace(struct Client *, struct Client *, int, const char **);
-static int mo_chantrace(struct Client *, struct Client *, int, const char **);
+static int m_chantrace(struct Client *, struct Client *, int, const char **);
 static int mo_masktrace(struct Client *, struct Client *, int, const char **);
 
 struct Message etrace_msgtab = {
@@ -62,7 +61,7 @@ struct Message etrace_msgtab = {
 };
 struct Message chantrace_msgtab = {
        "CHANTRACE", 0, 0, 0, MFLG_SLOW,
-       {mg_ignore, mg_not_oper, mg_ignore, mg_ignore, mg_ignore, {mo_chantrace, 2}}
+       {mg_ignore, {m_chantrace, 2}, mg_ignore, mg_ignore, mg_ignore, {m_chantrace, 2}}
 };
 struct Message masktrace_msgtab = {
        "MASKTRACE", 0, 0, 0, MFLG_SLOW,
@@ -70,7 +69,7 @@ struct Message masktrace_msgtab = {
 };
 
 mapi_clist_av1 etrace_clist[] = { &etrace_msgtab, &chantrace_msgtab, &masktrace_msgtab, NULL };
-DECLARE_MODULE_AV1(etrace, NULL, NULL, etrace_clist, NULL, NULL, "$Revision: 2775 $");
+DECLARE_MODULE_AV1(etrace, NULL, NULL, etrace_clist, NULL, NULL, "$Revision: 3161 $");
 
 static void do_etrace(struct Client *source_p, int ipv4, int ipv6);
 static void do_etrace_full(struct Client *source_p);
@@ -81,7 +80,6 @@ static const char *spoofed_sockhost = "0";
 
 /*
  * m_etrace
- *      parv[0] = sender prefix
  *      parv[1] = options [or target]
  *     parv[2] = [target]
  */
@@ -92,7 +90,7 @@ mo_etrace(struct Client *client_p, struct Client *source_p, int parc, const char
        {
                if(!irccmp(parv[1], "-full"))
                        do_etrace_full(source_p);
-#ifdef IPV6
+#ifdef RB_IPV6
                else if(!irccmp(parv[1], "-v6"))
                        do_etrace(source_p, 0, 1);
                else if(!irccmp(parv[1], "-v4"))
@@ -107,7 +105,7 @@ mo_etrace(struct Client *client_p, struct Client *source_p, int parc, const char
                                if(!MyClient(target_p))
                                        sendto_one(target_p, ":%s ENCAP %s ETRACE %s",
                                                get_id(source_p, target_p),
-                                               target_p->user->server,
+                                               target_p->servptr->name,
                                                get_id(target_p, target_p));
                                else
                                        do_single_etrace(source_p, target_p);
@@ -145,14 +143,14 @@ static void
 do_etrace(struct Client *source_p, int ipv4, int ipv6)
 {
        struct Client *target_p;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
 
        /* report all direct connections */
-       DLINK_FOREACH(ptr, lclient_list.head)
+       RB_DLINK_FOREACH(ptr, lclient_list.head)
        {
                target_p = ptr->data;
 
-#ifdef IPV6
+#ifdef RB_IPV6
                if((!ipv4 && target_p->localClient->ip.ss_family == AF_INET) ||
                   (!ipv6 && target_p->localClient->ip.ss_family == AF_INET6))
                        continue;
@@ -173,9 +171,9 @@ do_etrace(struct Client *source_p, int ipv4, int ipv6)
 static void
 do_etrace_full(struct Client *source_p)
 {
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
 
-       DLINK_FOREACH(ptr, lclient_list.head)
+       RB_DLINK_FOREACH(ptr, lclient_list.head)
        {
                do_single_etrace(source_p, ptr->data);
        }
@@ -214,14 +212,14 @@ do_single_etrace(struct Client *source_p, struct Client *target_p)
 }
 
 static int
-mo_chantrace(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_chantrace(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        struct Client *target_p;
        struct Channel *chptr;
        struct membership *msptr;
        const char *sockhost;
        const char *name;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
        int operspy = 0;
 
        name = parv[1];
@@ -257,7 +255,7 @@ mo_chantrace(struct Client *client_p, struct Client *source_p, int parc, const c
                return 0;
        }
 
-       DLINK_FOREACH(ptr, chptr->members.head)
+       RB_DLINK_FOREACH(ptr, chptr->members.head)
        {
                msptr = ptr->data;
                target_p = msptr->client_p;
@@ -283,53 +281,15 @@ mo_chantrace(struct Client *client_p, struct Client *source_p, int parc, const c
 }
 
 static void
-match_masktrace(struct Client *source_p, dlink_list *list,
+match_masktrace(struct Client *source_p, rb_dlink_list *list,
        const char *username, const char *hostname, const char *name,
        const char *gecos)
 {
        struct Client *target_p;
-       dlink_node *ptr;
+       rb_dlink_node *ptr;
        const char *sockhost;   
-       char *mangle_gecos = NULL;
        
-       if(gecos != NULL)
-       {
-               if(strstr(gecos, "\\s"))
-               {
-                       char *tmp = LOCAL_COPY(gecos);
-                       char *orig = tmp;
-                       char *new = tmp;
-                       while(*orig)
-                       {
-                               if(*orig == '\\' && *(orig + 1) != '\0')
-                                       {
-                                       if(*(orig + 1) == 's')
-                                       {
-                                               *new++ = ' ';
-                                               orig += 2;   
-                                       }
-                                       /* otherwise skip that and the escaped
-                                        * character after it, so we dont mistake
-                                        * \\s as \s --fl
-                                        */
-                                       else
-                                       {   
-                                               *new++ = *orig++;
-                                               *new++ = *orig++;
-                                       }
-                               }
-                               else
-                                       *new++ = *orig++;
-                       }
-       
-                       *new = '\0';
-                       mangle_gecos = LOCAL_COPY(tmp);
-               }
-               else
-                       mangle_gecos = LOCAL_COPY(gecos);
-       }
-
-       DLINK_FOREACH(ptr, list->head)
+       RB_DLINK_FOREACH(ptr, list->head)
        {
                target_p = ptr->data;
                if(!IsPerson(target_p))
@@ -350,7 +310,7 @@ match_masktrace(struct Client *source_p, dlink_list *list,
                        if(name != NULL && !match(name, target_p->name))
                                continue;
 
-                       if(mangle_gecos != NULL && !match_esc(mangle_gecos, target_p->info))
+                       if(gecos != NULL && !match_esc(gecos, target_p->info))
                                continue;
                        
                        sendto_one(source_p, form_str(RPL_ETRACE),
@@ -393,7 +353,7 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
 
        if((hostname = strchr(name, '@')) == NULL)
        {
-               sendto_one(source_p, ":%s NOTICE %s :Invalid parameters", me.name, source_p->name);
+               sendto_one_notice(source_p, ":Invalid parameters");
                return 0;
        }
 
@@ -408,7 +368,7 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
 
        if(EmptyString(username) || EmptyString(hostname))
        {
-               sendto_one(source_p, ":%s NOTICE %s :Invalid parameters", me.name, source_p->name);
+               sendto_one_notice(source_p, ":Invalid parameters");
                return 0;
        }
                        
@@ -416,10 +376,10 @@ mo_masktrace(struct Client *client_p, struct Client *source_p, int parc,
                if (!ConfigFileEntry.operspy_dont_care_user_info)
                {
                        char buf[512];
-                       strlcpy(buf, mask, sizeof(buf));
+                       rb_strlcpy(buf, mask, sizeof(buf));
                        if(!EmptyString(gecos)) {
-                               strlcat(buf, " ", sizeof(buf));
-                               strlcat(buf, gecos, sizeof(buf));
+                               rb_strlcat(buf, " ", sizeof(buf));
+                               rb_strlcat(buf, gecos, sizeof(buf));
                        }               
 
                        report_operspy(source_p, "MASKTRACE", buf);