]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - modules/core/m_nick.c
Various changes for libratbox.
[irc/rqf/shadowircd.git] / modules / core / m_nick.c
index 3a58402237e00ae9cb8fb4441500015e6c3e7b54..b8b6771e524be8e03b09ea6f3630c9054cf9345e 100644 (file)
@@ -156,7 +156,7 @@ mr_nick(struct Client *client_p, struct Client *source_p, int parc, const char *
                return 0;
        }
 
-       if(hash_find_nd(nick))
+       if(irc_dictionary_find(nd_dict, nick))
        {
                sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
                           me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick);
@@ -217,7 +217,7 @@ m_nick(struct Client *client_p, struct Client *source_p, int parc, const char *p
                return 0;
        }
 
-       if(hash_find_nd(nick))
+       if(irc_dictionary_find(nd_dict, nick))
        {
                sendto_one(source_p, form_str(ERR_UNAVAILRESOURCE),
                           me.name, EmptyString(source_p->name) ? "*" : source_p->name, nick);
@@ -284,7 +284,7 @@ mc_nick(struct Client *client_p, struct Client *source_p, int parc, const char *
                ServerStats->is_kill++;
                sendto_realops_snomask(SNO_DEBUG, L_ALL,
                                     "Bad Nick: %s From: %s(via %s)",
-                                    parv[1], source_p->user->server, client_p->name);
+                                    parv[1], source_p->servptr->name, client_p->name);
                sendto_one(client_p, ":%s KILL %s :%s (Bad Nickname)", me.name, parv[1], me.name);
 
                /* bad nick change, issue kill for the old nick to the rest
@@ -731,6 +731,7 @@ static void
 set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick)
 {
        char buf[USERLEN + 1];
+       char note[NICKLEN + 10];
 
        /* This had to be copied here to avoid problems.. */
        source_p->tsinfo = CurrentTime;
@@ -740,8 +741,8 @@ set_initial_nick(struct Client *client_p, struct Client *source_p, char *nick)
        strcpy(source_p->name, nick);
        add_to_client_hash(nick, source_p);
 
-       /* fd_desc is long enough */
-       comm_note(client_p->localClient->fd, "Nick: %s", nick);
+       rb_snprintf(note, sizeof(note), "Nick: %s", nick);
+       rb_note(client_p->localClient->F, note);
 
        if(source_p->flags & FLAGS_SENTUSER)
        {
@@ -758,8 +759,9 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
                char *nick, int dosend)
 {
        struct Client *target_p;
-       dlink_node *ptr, *next_ptr;
+       rb_dlink_node *ptr, *next_ptr;
        struct Channel *chptr;
+       char note[NICKLEN + 10];
        int samenick;
 
        if (dosend)
@@ -841,16 +843,16 @@ change_local_nick(struct Client *client_p, struct Client *source_p,
         * to clear a clients own list of accepted clients.  So just remove
         * them from everyone elses list --anfl
         */
-       DLINK_FOREACH_SAFE(ptr, next_ptr, source_p->on_allow_list.head)
+       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, source_p->on_allow_list.head)
        {
                target_p = ptr->data;
 
-               dlinkFindDestroy(source_p, &target_p->localClient->allow_list);
-               dlinkDestroy(ptr, &source_p->on_allow_list);
+               rb_dlinkFindDestroy(source_p, &target_p->localClient->allow_list);
+               rb_dlinkDestroy(ptr, &source_p->on_allow_list);
        }
 
-       /* fd_desc is long enough */
-       comm_note(client_p->localClient->fd, "Nick: %s", nick);
+       rb_snprintf(note, sizeof(note), "Nick: %s", nick);
+       rb_note(client_p->localClient->F, note);
 
        return;
 }
@@ -890,7 +892,7 @@ change_remote_nick(struct Client *client_p, struct Client *source_p,
        del_from_client_hash(source_p->name, source_p);
 
        /* invalidate nick delay when a remote client uses the nick.. */
-       if((nd = hash_find_nd(nick)))
+       if((nd = irc_dictionary_retrieve(nd_dict, nick)))
                free_nd_entry(nd);
 
        strcpy(source_p->name, nick);
@@ -1172,9 +1174,22 @@ register_client(struct Client *client_p, struct Client *server,
        const char *m;
        int flag;
 
+       if(server == NULL)
+       {
+               if((server = find_server(NULL, parv[7])) == NULL)
+               {
+                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
+                                            "Ghost killed: %s on invalid server %s",
+                                            nick, parv[7]);
+                       sendto_one(client_p, ":%s KILL %s :%s (Server doesn't exist)",
+                                       get_id(&me, client_p), nick, me.name);
+                       return 0;
+               }
+       }
+
        source_p = make_client(client_p);
        user = make_user(source_p);
-       dlinkAddTail(source_p, &source_p->node, &global_client_list);
+       rb_dlinkAddTail(source_p, &source_p->node, &global_client_list);
 
        source_p->hopcount = atoi(parv[2]);
        source_p->tsinfo = newts;
@@ -1186,7 +1201,6 @@ register_client(struct Client *client_p, struct Client *server,
 
        if(parc == 12)
        {
-               user->server = find_or_add(server->name);
                strlcpy(source_p->info, parv[11], sizeof(source_p->info));
                strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost));
                strlcpy(source_p->id, parv[8], sizeof(source_p->id));
@@ -1202,7 +1216,6 @@ register_client(struct Client *client_p, struct Client *server,
        }
        else if(parc == 10)
        {
-               user->server = find_or_add(server->name);
                strlcpy(source_p->info, parv[9], sizeof(source_p->info));
                strlcpy(source_p->sockhost, parv[7], sizeof(source_p->sockhost));
                strlcpy(source_p->id, parv[8], sizeof(source_p->id));
@@ -1210,12 +1223,11 @@ register_client(struct Client *client_p, struct Client *server,
        }
        else
        {
-               user->server = find_or_add(parv[7]);
                strlcpy(source_p->info, parv[8], sizeof(source_p->info));
        }
 
        /* remove any nd entries for this nick */
-       if((nd = hash_find_nd(nick)))
+       if((nd = irc_dictionary_retrieve(nd_dict, nick)))
                free_nd_entry(nd);
 
        add_to_client_hash(nick, source_p);
@@ -1230,11 +1242,11 @@ register_client(struct Client *client_p, struct Client *server,
                if(flag & UMODE_SERVICE)
                {
                        int hit = 0;
-                       dlink_node *ptr;
+                       rb_dlink_node *ptr;
 
-                       DLINK_FOREACH(ptr, service_list.head)
+                       RB_DLINK_FOREACH(ptr, service_list.head)
                        {
-                               if(!irccmp((const char *) ptr->data, user->server))
+                               if(!irccmp((const char *) ptr->data, server->name))
                                {
                                        hit++;
                                        break;
@@ -1261,29 +1273,16 @@ register_client(struct Client *client_p, struct Client *server,
        }
 
        if(IsOper(source_p) && !IsService(source_p))
-               dlinkAddAlloc(source_p, &oper_list);
+               rb_dlinkAddAlloc(source_p, &oper_list);
 
        SetRemoteClient(source_p);
 
        if(++Count.total > Count.max_tot)
                Count.max_tot = Count.total;
 
-       if(server == NULL)
-       {
-               if((source_p->servptr = find_server(NULL, user->server)) == NULL)
-               {
-                       sendto_realops_snomask(SNO_GENERAL, L_ALL,
-                                            "Ghost killed: %s on invalid server %s",
-                                            source_p->name, user->server);
-                       kill_client(client_p, source_p, "%s (Server doesn't exist)", me.name);
-                       source_p->flags |= FLAGS_KILLED;
-                       return exit_client(NULL, source_p, &me, "Ghosted Client");
-               }
-       }
-       else
-               source_p->servptr = server;
+       source_p->servptr = server;
 
-       dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
+       rb_dlinkAdd(source_p, &source_p->lnode, &source_p->servptr->serv->users);
 
        /* fake direction */
        if(source_p->servptr->from != source_p->from)
@@ -1294,10 +1293,10 @@ register_client(struct Client *client_p, struct Client *server,
                                     "Bad User [%s] :%s USER %s@%s %s, != %s[%s]",
                                     client_p->name, source_p->name,
                                     source_p->username, source_p->host,
-                                    user->server, target_p->name, target_p->from->name);
+                                    server->name, target_p->name, target_p->from->name);
                kill_client(client_p, source_p,
                            "%s (NICK from wrong direction (%s != %s))",
-                           me.name, user->server, target_p->from->name);
+                           me.name, server->name, target_p->from->name);
                source_p->flags |= FLAGS_KILLED;
                return exit_client(source_p, source_p, &me, "USER server wrong direction");
        }